meshwriter-cudu 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +11 -0
- package/README.md +349 -0
- package/dist/fonts/comic-sans.d.ts +1105 -0
- package/dist/fonts/helvetica.d.ts +1208 -0
- package/dist/fonts/hiruko-pro.d.ts +658 -0
- package/dist/fonts/jura.d.ts +750 -0
- package/dist/fonts/webgl-dings.d.ts +109 -0
- package/dist/index.d.ts +295 -0
- package/dist/meshwriter.cjs.js +2645 -0
- package/dist/meshwriter.cjs.js.map +1 -0
- package/dist/meshwriter.esm.js +2606 -0
- package/dist/meshwriter.esm.js.map +1 -0
- package/dist/meshwriter.min.js +2 -0
- package/dist/meshwriter.min.js.map +1 -0
- package/dist/meshwriter.umd.js +7146 -0
- package/dist/meshwriter.umd.js.map +1 -0
- package/dist/src/babylonImports.d.ts +11 -0
- package/dist/src/bakedFontLoader.d.ts +43 -0
- package/dist/src/colorContrast.d.ts +117 -0
- package/dist/src/csg.d.ts +55 -0
- package/dist/src/curves.d.ts +20 -0
- package/dist/src/fogPlugin.d.ts +32 -0
- package/dist/src/fontCompression.d.ts +12 -0
- package/dist/src/fontRegistry.d.ts +54 -0
- package/dist/src/index.d.ts +47 -0
- package/dist/src/letterMesh.d.ts +46 -0
- package/dist/src/material.d.ts +34 -0
- package/dist/src/meshSplitter.d.ts +10 -0
- package/dist/src/meshwriter.d.ts +46 -0
- package/dist/src/sps.d.ts +27 -0
- package/dist/src/umd-entry.d.ts +3 -0
- package/dist/src/utils.d.ts +12 -0
- package/dist/src/variableFontCache.d.ts +56 -0
- package/dist/src/variableFontConverter.d.ts +21 -0
- package/dist/src/variableFontLoader.d.ts +99 -0
- package/fonts/Figure1.png +0 -0
- package/fonts/LICENSE-OFL.txt +93 -0
- package/fonts/README.md +174 -0
- package/fonts/atkinson-hyperlegible-next.d.ts +8 -0
- package/fonts/atkinson-hyperlegible-next.js +6576 -0
- package/fonts/atkinson-hyperlegible.js +3668 -0
- package/fonts/baked/atkinson-hyperlegible-next-200.json +1 -0
- package/fonts/baked/atkinson-hyperlegible-next-250.json +1 -0
- package/fonts/baked/atkinson-hyperlegible-next-300.json +1 -0
- package/fonts/baked/atkinson-hyperlegible-next-350.json +1 -0
- package/fonts/baked/atkinson-hyperlegible-next-400.json +1 -0
- package/fonts/baked/atkinson-hyperlegible-next-450.json +1 -0
- package/fonts/baked/atkinson-hyperlegible-next-500.json +1 -0
- package/fonts/baked/atkinson-hyperlegible-next-550.json +1 -0
- package/fonts/baked/atkinson-hyperlegible-next-600.json +1 -0
- package/fonts/baked/atkinson-hyperlegible-next-650.json +1 -0
- package/fonts/baked/atkinson-hyperlegible-next-700.json +1 -0
- package/fonts/baked/atkinson-hyperlegible-next-750.json +1 -0
- package/fonts/baked/atkinson-hyperlegible-next-800.json +1 -0
- package/fonts/baked/manifest.json +41 -0
- package/fonts/comic-sans.js +1532 -0
- package/fonts/helvetica.js +1695 -0
- package/fonts/hiruko-pro.js +838 -0
- package/fonts/index.js +16 -0
- package/fonts/jura.js +994 -0
- package/fonts/variable/atkinson-hyperlegible-next-variable.ttf +0 -0
- package/fonts/webgl-dings.js +113 -0
- package/package.json +76 -0
- package/src/babylonImports.js +29 -0
- package/src/bakedFontLoader.js +125 -0
- package/src/colorContrast.js +528 -0
- package/src/csg.js +220 -0
- package/src/curves.js +67 -0
- package/src/fogPlugin.js +98 -0
- package/src/fontCompression.js +141 -0
- package/src/fontRegistry.js +98 -0
- package/src/globals.d.ts +20 -0
- package/src/index.js +136 -0
- package/src/letterMesh.js +417 -0
- package/src/material.js +103 -0
- package/src/meshSplitter.js +337 -0
- package/src/meshwriter.js +303 -0
- package/src/sps.js +106 -0
- package/src/types.d.ts +551 -0
- package/src/umd-entry.js +130 -0
- package/src/utils.js +57 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load and parse a variable font from URL
|
|
3
|
+
* @param {string} url - URL to TTF or WOFF2 file
|
|
4
|
+
* @param {object} [options] - Loading options
|
|
5
|
+
* @param {number} [options.cacheSize=5000] - Maximum glyph cache size
|
|
6
|
+
* @param {number} [options.maxVariations=10] - Maximum cached weight variations
|
|
7
|
+
* @returns {Promise<VariableFontHandle>}
|
|
8
|
+
*/
|
|
9
|
+
export function loadVariableFont(url: string, options?: {
|
|
10
|
+
cacheSize?: number;
|
|
11
|
+
maxVariations?: number;
|
|
12
|
+
}): Promise<VariableFontHandle>;
|
|
13
|
+
export const DEFAULT_CHARSET: string;
|
|
14
|
+
/**
|
|
15
|
+
* Handle for a loaded variable font
|
|
16
|
+
* Provides methods to generate FontSpec at different weights
|
|
17
|
+
*/
|
|
18
|
+
export class VariableFontHandle {
|
|
19
|
+
/**
|
|
20
|
+
* @param {object} font - fontkit font object
|
|
21
|
+
* @param {object} fontkit - fontkit module reference
|
|
22
|
+
* @param {string} url - Source URL
|
|
23
|
+
* @param {object} axisInfo - Axis information
|
|
24
|
+
* @param {boolean} isVariable - Whether font is actually variable
|
|
25
|
+
* @param {number} cacheSize - Maximum glyph cache size
|
|
26
|
+
* @param {number} maxVariations - Maximum cached weight variations
|
|
27
|
+
*/
|
|
28
|
+
constructor(font: object, fontkit: object, url: string, axisInfo: object, isVariable: boolean, cacheSize: number, maxVariations: number);
|
|
29
|
+
_baseFont: any;
|
|
30
|
+
_fontkit: any;
|
|
31
|
+
_url: string;
|
|
32
|
+
_axisInfo: any;
|
|
33
|
+
_isVariable: boolean;
|
|
34
|
+
_glyphCache: GlyphCache;
|
|
35
|
+
_kerningCache: Map<any, any>;
|
|
36
|
+
_fontCache: Map<any, any>;
|
|
37
|
+
_maxVariations: number;
|
|
38
|
+
_reverseShapes: boolean;
|
|
39
|
+
_reverseHoles: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Get axis information for this font
|
|
42
|
+
* @returns {object} - Axis info with weight min/max/default
|
|
43
|
+
*/
|
|
44
|
+
getAxisInfo(): object;
|
|
45
|
+
/**
|
|
46
|
+
* Get the source URL
|
|
47
|
+
* @returns {string}
|
|
48
|
+
*/
|
|
49
|
+
getUrl(): string;
|
|
50
|
+
/**
|
|
51
|
+
* Check if this is actually a variable font
|
|
52
|
+
* @returns {boolean}
|
|
53
|
+
*/
|
|
54
|
+
isVariable(): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Get or create a font instance at the specified weight
|
|
57
|
+
* @param {number} weight - Weight value
|
|
58
|
+
* @returns {object} - fontkit font instance
|
|
59
|
+
*/
|
|
60
|
+
_getFontAtWeight(weight: number): object;
|
|
61
|
+
/**
|
|
62
|
+
* Generate FontSpec for a specific weight
|
|
63
|
+
* @param {number} weight - Weight value (100-900 for most fonts)
|
|
64
|
+
* @param {string} [charset] - Characters to include (default: Latin + symbols)
|
|
65
|
+
* @returns {object} - FontSpec compatible with MeshWriter
|
|
66
|
+
*/
|
|
67
|
+
generateFontSpec(weight: number, charset?: string): object;
|
|
68
|
+
/**
|
|
69
|
+
* Get or create a cached glyph specification
|
|
70
|
+
* @param {object} font - fontkit font instance at specific weight
|
|
71
|
+
* @param {string} char - Character
|
|
72
|
+
* @param {number} weight - Weight value
|
|
73
|
+
* @returns {object|null} - GlyphSpec or null if glyph not found
|
|
74
|
+
*/
|
|
75
|
+
_getOrCreateGlyph(font: object, char: string, weight: number): object | null;
|
|
76
|
+
/**
|
|
77
|
+
* Clear all cached glyphs and font instances
|
|
78
|
+
* Call this when changing weight frequently to free memory
|
|
79
|
+
*/
|
|
80
|
+
clearCache(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Get current cache statistics
|
|
83
|
+
* @returns {{ glyphCount: number, kerningCount: number, fontCount: number, maxSize: number, maxVariations: number }}
|
|
84
|
+
*/
|
|
85
|
+
getCacheStats(): {
|
|
86
|
+
glyphCount: number;
|
|
87
|
+
kerningCount: number;
|
|
88
|
+
fontCount: number;
|
|
89
|
+
maxSize: number;
|
|
90
|
+
maxVariations: number;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Ensure a cache map respects the max variations limit (simple LRU)
|
|
94
|
+
* @param {Map} map
|
|
95
|
+
* @private
|
|
96
|
+
*/
|
|
97
|
+
private _evictIfNeeded;
|
|
98
|
+
}
|
|
99
|
+
import { GlyphCache } from './variableFontCache.js';
|
|
Binary file
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2020, 2024 Braille Institute of America, Inc. (https://www.brailleinstitute.org/)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
https://openfontlicense.org
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
package/fonts/README.md
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# So you want to build a 3-D font, eh?
|
|
2
|
+
|
|
3
|
+
3-D font conversion is now an automatic process.
|
|
4
|
+
The documentation further below is no longer needed (although you are welcome to read it).
|
|
5
|
+
Instead, go to https://github.com/briantbutton/meshwriter-font for a package that will convert full font files.
|
|
6
|
+
When you have done that, come back here for further instructions.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Building MeshWriter with a customized font set
|
|
10
|
+
|
|
11
|
+
MeshWriter can build with an arbitrary selection of font files.
|
|
12
|
+
All font files should be converted into MeshWriter form and placed in this directory.
|
|
13
|
+
Linking the font files into your build is done with a require statement.
|
|
14
|
+
Easy.
|
|
15
|
+
Open /meshwriter/index.js and take a look at the steps described in the first fifty lines of that file.
|
|
16
|
+
Three steps for each font file.
|
|
17
|
+
|
|
18
|
+
### Step 1 - reference the font files into variable names
|
|
19
|
+
|
|
20
|
+
### Step 2 - call each font with 'codelist'
|
|
21
|
+
|
|
22
|
+
This just passes along the encoding function.
|
|
23
|
+
Sorry if it seems awkward.
|
|
24
|
+
|
|
25
|
+
### Step 3 - Assign a text name (or two) to each font
|
|
26
|
+
|
|
27
|
+
This is used to invoke it.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## Build a package
|
|
31
|
+
|
|
32
|
+
Make sure that you have loaded Earcut in npm – this is the only dependency.
|
|
33
|
+
On your dev machine (set up as described in meshwriter-font) go to the /meshwriter repo.
|
|
34
|
+
Type:
|
|
35
|
+
|
|
36
|
+
npm run build
|
|
37
|
+
|
|
38
|
+
This has placed an unminified version of meshwriter, with all your fonts, in /meshwriter/dist.
|
|
39
|
+
Almost there!
|
|
40
|
+
It only remains to minify it.
|
|
41
|
+
Use any tool you want. However, save "MeshWriter" as a reserved word. Here is the command I use:
|
|
42
|
+
|
|
43
|
+
terser meshwriter.js -m reserved=['MeshWriter'] --mangle-props regex=/^[xyw][Md][tia][nxh]/
|
|
44
|
+
|
|
45
|
+
We are now *finished*.
|
|
46
|
+
Back to our regularly scheduled programming, describing in detail how shapes are specified.
|
|
47
|
+
|
|
48
|
+
You may turn off your television sets now.
|
|
49
|
+
|
|
50
|
+
Stop reading.
|
|
51
|
+
|
|
52
|
+
## Background information: How shapes are specified
|
|
53
|
+
|
|
54
|
+
### Basic shapes
|
|
55
|
+
|
|
56
|
+
Meshwriter curves follow SVG-style rules. These include:
|
|
57
|
+
~ 'M' move to, only at the beginning
|
|
58
|
+
~ 'L' line, never at the beginning
|
|
59
|
+
~ 'l' line
|
|
60
|
+
~ 'Q' quadratic curve
|
|
61
|
+
~ 'q' quadratic curve
|
|
62
|
+
~ 'C' cubic curve
|
|
63
|
+
~ 'c' cubic curve
|
|
64
|
+
|
|
65
|
+
Just below is an example from Comic (a gnarly font) showing the letter 'j' in SVG and in MeshWriter.
|
|
66
|
+
In MeshWriter, the commands are placed in arrays.
|
|
67
|
+
The length of the array indicates the command type.
|
|
68
|
+
~ 2: M or L
|
|
69
|
+
~ 3: l
|
|
70
|
+
~ 4: Q
|
|
71
|
+
~ 5: q
|
|
72
|
+
~ 6: C
|
|
73
|
+
~ 7: c
|
|
74
|
+
|
|
75
|
+
**Key** **Point** Meshwriter shapes are superficially similar to SVG shapes but, instead of a parseable text string, commands are in arrays.
|
|
76
|
+
The size of the array indicates which command is specified.
|
|
77
|
+
|
|
78
|
+
Since 'j' has two shapes, including the dot, the fullPath shows two M commands.
|
|
79
|
+
In Meshwriter, this converted to two arrays, one for each shape.
|
|
80
|
+
So this means that shapeCmds has three levels.
|
|
81
|
+
At the top is an array containing all shapes, usually one or more.
|
|
82
|
+
Each shape is an array of commands, each command containing multiple coordinates.
|
|
83
|
+
|
|
84
|
+
Three encodings for the letter 'j'
|
|
85
|
+
fullPath : "M 233.5 632.5 Q 209.5 632.5 192 649.5 Q 175 666.5 175 690 Q 175 714 192 731 Q 209.5 748 233.5 748 Q 257.5 748 275 731 Q 292.5 714 292.5 690 Q 292.5 666.5 275 649.5 Q 257.5 632.5 233.5 632.5 Z M 229.5 -116 Q 230 -57.5 212.5 183.5 L 195.5 459 Q 195.5 484 209.5 503.5 Q 224 523 246 523 Q 263 523 280 510.5 Q 297 498 298 485 L 314.5 197 L 328 -111 Q 328 -180.5 286.5 -237 Q 241.5 -298.5 177 -298.5 Q 69.5 -298.5 -3 -133 Q -9 -119.5 -9 -109 Q -9 -89 6.5 -74.5 Q 22.5 -60 42.5 -60 Q 72 -60 104 -125 Q 112 -142 132 -174 Q 151.5 -199 177 -199 Q 199 -199 214.5 -166 Q 226.5 -141 229.5 -116 Z",
|
|
86
|
+
shapeCmds : [[[233.5,632.5],[209.5,632.5,192,649.5],[175,666.5,175,690],[175,714,192,731],[209.5,748,233.5,748],[257.5,748,275,731],[292.5,714,292.5,690],[292.5,666.5,275,649.5],[257.5,632.5,233.5,632.5]],[[229.5,-116],[230,-57.5,212.5,183.5],[195.5,459],[195.5,484,209.5,503.5],[224,523,246,523],[263,523,280,510.5],[297,498,298,485],[314.5,197],[328,-111],[328,-180.5,286.5,-237],[241.5,-298.5,177,-298.5],[69.5,-298.5,-3,-133],[-9,-119.5,-9,-109],[-9,-89,6.5,-74.5],[22.5,-60,42.5,-60],[72,-60,104,-125],[112,-142,132,-174],[151.5,-199,177,-199],[199,-199,214.5,-166],[226.5,-141,229.5,-116]]],
|
|
87
|
+
sC : ['D¸K3 DfK3DBKU CÃKxCÃL% CÃLVDBLy DfL½D¸L½ EEL½EiLy E®LVE®L% E®KxEiKU EEK3D¸K3','D°?Z D±@ODlD1 DIHX DIHDfI1 D¥IXE.IX EPIXEsI? E·I%E¹H¯ F7DL FR?e FR>YE¢=i E$<nD#<n BM<nA<?8 A0?SA0?i A0?³AO@- Ap@JAº@J BR@JBµ?H C!?%CJ>g Cr>4D#>4 DP>4Dp>w Dª?(D°?Z'],
|
|
88
|
+
|
|
89
|
+
The third version, sC is an encoded version, saving 45% of the space.
|
|
90
|
+
This may be handy should we want a lot of fonts in one package.
|
|
91
|
+
The encoding is proprietary, simple and built into MeshWriter.
|
|
92
|
+
It puts an array of arrays into an ASCII string.
|
|
93
|
+
|
|
94
|
+
Furthermore it is optional; any given symbol may present either shapeCmds or sC.
|
|
95
|
+
I usually encode stable symbols after a while.
|
|
96
|
+
|
|
97
|
+
### Acquiring the shapes
|
|
98
|
+
|
|
99
|
+
My approach has been to visit https://opentype.js.org/glyph-inspector.html, upload my font and then acquire glyphs in semi-SVG form.
|
|
100
|
+
|
|
101
|
+
I have not been able to use the output of Glyph Inspector without review and, often, tuning.
|
|
102
|
+
More on that below.
|
|
103
|
+
|
|
104
|
+
### Holes
|
|
105
|
+
|
|
106
|
+
Many letters have holes in them.
|
|
107
|
+
Glyph Inspector also outputs the holes.
|
|
108
|
+
Meshwriter supports holes.
|
|
109
|
+
The basic task here is that fonts need not line up the hole to the shape it is coming from.
|
|
110
|
+
For MeshWriter, we must.
|
|
111
|
+
The '%', shown just below, is a classic example.
|
|
112
|
+
|
|
113
|
+
Commands for Percent '%', with three shapes and two holes
|
|
114
|
+
shapeCmds : [
|
|
115
|
+
[[338,-24],[260,-24],[649,724],[725,724],[338,-24]],
|
|
116
|
+
[[751,-14],[665,-14,622,45],[584,96,584,185],[584,272,624,325],[668,384,751,384],[834,384,878,325],[918,272,918,185],[918,96,880,45],[837,-14,751,-14]],
|
|
117
|
+
[[249,316],[163,316,120,375],[82,426,82,515],[82,602,122,655],[166,714,249,714],[332,714,376,655],[416,602,416,515],[416,426,378,375],[335,316,249,316]]
|
|
118
|
+
],
|
|
119
|
+
holeCmds : [
|
|
120
|
+
[],
|
|
121
|
+
[[[674,185],[674,51,750,51],[828,51,828,185],[828,319,750,319],[674,319,674,185]]],
|
|
122
|
+
[[[172,515],[172,381,248,381],[326,381,326,515],[326,649,248,649],[172,649,172,515]]]
|
|
123
|
+
]
|
|
124
|
+
|
|
125
|
+
**Key** **Point** Hole commands are always one array level deeper than shape commands.
|
|
126
|
+
This is necessary because a single shape may have multiple holes, like 'B'.
|
|
127
|
+
|
|
128
|
+
### Tuning A, lining up holes
|
|
129
|
+
|
|
130
|
+
The hole commands must line up with the shape commands and, AFAIK, this must be done manually.
|
|
131
|
+
Fonts do not seem to need to do this at all.
|
|
132
|
+
They might list the holes in any order and they may come before or after the shapes.
|
|
133
|
+
I seriously spend some time eyeballing shapes and holes and then organize them for correct results.
|
|
134
|
+
|
|
135
|
+
### Tuning B, rotation
|
|
136
|
+
|
|
137
|
+
Fonts may specify a Shape clockwise or counter-clockwise.
|
|
138
|
+
They may specify a Hole clockwise or counter-clockwise.
|
|
139
|
+
Any given font might pick any pair of directions.
|
|
140
|
+
Luckily, they seem to stick with it through all the symbols.
|
|
141
|
+
|
|
142
|
+
My experience is the Babylon is only happy with one direction; I forget which.
|
|
143
|
+
So, the output of the Glyph Inspector might need reversal for Babylon.
|
|
144
|
+
I put some font-level flags in place to handle this.
|
|
145
|
+
You will find them at the top of each font file.
|
|
146
|
+
My scientific method is to try all combinations until I find the one that looks good.
|
|
147
|
+
|
|
148
|
+
Declarations for each current font
|
|
149
|
+
(helvetica neue) { reverseHoles : false , reverseShapes : true };
|
|
150
|
+
(comic) { reverseHoles : false , reverseShapes : true };
|
|
151
|
+
(jura) { reverseHoles : true , reverseShapes : false };
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
## 'C' is for Cat
|
|
155
|
+
|
|
156
|
+
So let's start with a simple letter, C.
|
|
157
|
+
Because we believe life should be easy, we will use 'HelveticaNeue-Medium.ttf'.
|
|
158
|
+
(This is a modern font and its files are pretty well-behaved.)
|
|
159
|
+
Visit https://opentype.js.org/glyph-inspector.html, upload the font file, and then click on the letter C.
|
|
160
|
+
What you see should be similar to the screen capture immediately below.
|
|
161
|
+
|
|
162
|
+

|
|
163
|
+
|
|
164
|
+
Note that the information we need is immediately visible.
|
|
165
|
+
The key thing is to get that information into MeshWriter in a form it can take.
|
|
166
|
+
|
|
167
|
+
## This
|
|
168
|
+
|
|
169
|
+
document is not
|
|
170
|
+
|
|
171
|
+
## Finished
|
|
172
|
+
|
|
173
|
+
yet
|
|
174
|
+
|