Recursive generation is now much smarter and faster.
This commit is contained in:
parent
036024ba7f
commit
b775d8db4e
7 changed files with 6337 additions and 5997 deletions
|
@ -1,7 +1,7 @@
|
|||
|
||||
### Zoom all glyphs
|
||||
|
||||
foreach glyph [items-of glyphList] : begin {
|
||||
if [upmscale != 1] : foreach glyph [items-of glyphList] : begin {
|
||||
glyph.advanceWidth = glyph.advanceWidth * upmscale
|
||||
if glyph.contours: foreach contour [items-of glyph.contours] : foreach point [items-of contour] : begin {
|
||||
point.x = point.x * upmscale
|
||||
|
@ -9,7 +9,9 @@ foreach glyph [items-of glyphList] : begin {
|
|||
}
|
||||
}
|
||||
|
||||
set font.glyf : font.glyf.filter : function [glyph] : glyph && [not glyph.dontExport]
|
||||
if [not recursive] : set font.glyf : font.glyf.filter : function [glyph] : glyph && [not glyph.dontExport]
|
||||
set font.glyfMap glyphs
|
||||
return font
|
||||
}
|
||||
|
||||
exports.build = buildFont
|
|
@ -8,12 +8,12 @@ define [mix a b p] : a + [b - a] * p
|
|||
define [linreg x0 y0 x1 y1 x] : y0 + [x - x0] * [y1 - y0] / [x1 - x0]
|
||||
define [fallback] : for [local j 0] [j < arguments.length] [inc j] : if [arguments`j !== nothing] : return arguments`j
|
||||
|
||||
define [exports.build para picks] : begin {
|
||||
define emptyFontStr : JSON.stringify [require './empty.json']
|
||||
|
||||
define [buildFont para recursive] : begin {
|
||||
|
||||
define variantSelector para.variantSelector
|
||||
|
||||
define font : JSON.parse : JSON.stringify [require './empty.json']
|
||||
|
||||
define font : JSON.parse emptyFontStr
|
||||
define glyphList font.glyf
|
||||
define glyphs (.'.notdef' glyphList.0)
|
||||
define unicodeGlyphs ()
|
||||
|
@ -194,9 +194,17 @@ define-macro glyph-construction : syntax-rules {
|
|||
|
||||
local dependencyProfile (.)
|
||||
local nTemp 0
|
||||
local pickHash : if recursive {
|
||||
then : let [h (.)] : begin {
|
||||
foreach j [items-of recursive] : set h.(j) j
|
||||
* h
|
||||
}
|
||||
else nothing
|
||||
}
|
||||
define [create-glyph name actions] : piecewise {
|
||||
[name && actions] : begin {
|
||||
if [picks && [picks.indexOf name] < 0] : return nothing
|
||||
if [pickHash && [not pickHash.(name)]] : return nothing
|
||||
console.log : "Building /" + name + [if recursive " (recursive)" ""] + " for " + para.family + ' ' + para.style
|
||||
set dependencyProfile`name ()
|
||||
define glyphObject [new Glyph name]
|
||||
glyphList.push glyphObject
|
||||
|
@ -216,13 +224,13 @@ define [create-glyph name actions] : piecewise {
|
|||
}
|
||||
}
|
||||
|
||||
define [select-variant glyphid unicode default] : begin {
|
||||
if [picks && [picks.indexOf glyphid] < 0] : return nothing
|
||||
local variant : variantSelector`glyphid || default
|
||||
local chosenGlyph glyphs`[glyphid + '.' + variant]
|
||||
set glyphs`glyphid chosenGlyph
|
||||
define [select-variant name unicode default] : begin {
|
||||
if [pickHash && [not pickHash.(name)]] : return nothing
|
||||
local variant : variantSelector`name || default
|
||||
local chosenGlyph glyphs`[name + '.' + variant]
|
||||
set glyphs`name chosenGlyph
|
||||
local allAliases : Object.keys glyphs :.filter [[k] -> [glyphs`k === glyphs.(chosenGlyph.name)]]
|
||||
set dependencyProfile`glyphid : allAliases.concat dependencyProfile.(chosenGlyph.name)
|
||||
set dependencyProfile`name : allAliases.concat dependencyProfile.(chosenGlyph.name)
|
||||
if unicode : begin {
|
||||
chosenGlyph.assign-unicode unicode
|
||||
set chosenGlyph.dontExport false
|
||||
|
@ -232,8 +240,6 @@ define [select-variant glyphid unicode default] : begin {
|
|||
|
||||
###### HERE WE GO!
|
||||
|
||||
define [xgrid p] : mix SB RIGHTSB p
|
||||
|
||||
create-glyph 'space' : glyph-construction {
|
||||
set-width WIDTH
|
||||
assign-unicode ' '
|
||||
|
|
11986
buildglyphs.js
11986
buildglyphs.js
File diff suppressed because it is too large
Load diff
|
@ -62,20 +62,20 @@ create-glyph 'latin1cedilla' : glyph-construction {
|
|||
include glyphs.cedillaBelow
|
||||
}
|
||||
|
||||
|
||||
define [Miniature glyphid fold scale] : begin {
|
||||
define [Miniature glyphs fold scale] : begin {
|
||||
local forkedPara : Object.create para
|
||||
forkedPara.upmscale = 1
|
||||
forkedPara.buildFor = glyphid
|
||||
forkedPara.stroke = [adviceBlackness fold] / scale
|
||||
forkedPara.sb = SB / 2
|
||||
local forkFont : exports.build forkedPara (glyphid :: dependencyProfile.(glyphid))
|
||||
return forkFont.glyfMap`glyphid
|
||||
local shouldBuildList ()
|
||||
foreach glyphid [items-of glyphs] : set shouldBuildList : shouldBuildList.concat (glyphid :: dependencyProfile.(glyphid))
|
||||
local forkFont : buildFont forkedPara shouldBuildList
|
||||
return forkFont.glyfMap
|
||||
}
|
||||
define [CircledGlyph glyphid] : glyph-construction {
|
||||
local sw [adviceBlackness 6]
|
||||
include : create-glyph : glyph-construction {
|
||||
include : Miniature glyphid 4.2 0.6
|
||||
include [Miniature (glyphid) 4.2 0.6].(glyphid)
|
||||
apply-transform : Upright
|
||||
apply-transform : Scale 0.45
|
||||
apply-transform : Translate [[WIDTH - WIDTH * 0.45] / 2] [sw * 2]
|
||||
|
@ -86,11 +86,13 @@ define [CircledGlyph glyphid] : glyph-construction {
|
|||
apply-transform : Translate 0 [parenMid - [CAP * 0.45 + sw * 4] / 2]
|
||||
apply-transform : Italify
|
||||
}
|
||||
define [createSuperscript unicode glyphid] : if glyphs`glyphid : begin {
|
||||
create-glyph ['superscript_' + glyphid] : glyph-construction {
|
||||
define [createSuperscripts records] : if [not recursive] : begin {
|
||||
local pendingGlyphs : records.map : [record] -> record.1
|
||||
local miniatureFont : Miniature pendingGlyphs 4.2 0.6
|
||||
foreach (unicode glyphid) [items-of records] : create-glyph ['superscript_' + glyphid] : glyph-construction {
|
||||
assign-unicode unicode
|
||||
include : create-glyph : glyph-construction {
|
||||
include : Miniature glyphid 4.2 0.6
|
||||
include miniatureFont.(glyphid)
|
||||
apply-transform : Upright
|
||||
apply-transform : Translate [-MIDDLE] [-CAP]
|
||||
apply-transform : Scale 0.6
|
||||
|
@ -99,11 +101,13 @@ define [createSuperscript unicode glyphid] : if glyphs`glyphid : begin {
|
|||
}
|
||||
}
|
||||
}
|
||||
define [createSubscript unicode glyphid] : if glyphs`glyphid : begin {
|
||||
create-glyph ['subscript_' + glyphid] : glyph-construction {
|
||||
define [createSubscripts records] : if [not recursive] : begin {
|
||||
local pendingGlyphs : records.map : [record] -> record.1
|
||||
local miniatureFont : Miniature pendingGlyphs 4.2 0.6
|
||||
foreach (unicode glyphid) [items-of records] : create-glyph ['subscript_' + glyphid] : glyph-construction {
|
||||
assign-unicode unicode
|
||||
include : create-glyph : glyph-construction {
|
||||
include : Miniature glyphid 4.2 0.6
|
||||
include miniatureFont.(glyphid)
|
||||
apply-transform : Upright
|
||||
apply-transform : Translate [-MIDDLE] 0
|
||||
apply-transform : Scale 0.6
|
||||
|
@ -155,85 +159,88 @@ create-glyph 'ordmasculine' : glyph-construction {
|
|||
apply-transform : Italify
|
||||
}
|
||||
|
||||
createSuperscript 0x2070 'zero'
|
||||
createSuperscript 0x00B9 'one'
|
||||
createSuperscript 0x00B2 'two'
|
||||
createSuperscript 0x00B3 'three'
|
||||
createSuperscript 0x2074 'four'
|
||||
createSuperscript 0x2075 'five'
|
||||
createSuperscript 0x2076 'six'
|
||||
createSuperscript 0x2077 'seven'
|
||||
createSuperscript 0x2078 'eight'
|
||||
createSuperscript 0x2079 'nine'
|
||||
createSuperscript 0x02B0 'h'
|
||||
createSuperscript 0x02B2 'j'
|
||||
createSuperscript 0x02B3 'r'
|
||||
createSuperscript 0x02B7 'w'
|
||||
createSuperscript 0x02B8 'y'
|
||||
createSuperscript 0x02E1 'l'
|
||||
createSuperscript 0x02E2 's'
|
||||
createSuperscript 0x02E3 'x'
|
||||
createSuperscript 0x2071 'i'
|
||||
createSuperscript 0x207F 'n'
|
||||
createSuperscript 0x1D43 'a'
|
||||
createSuperscript 0x1D47 'b'
|
||||
createSuperscript 0x1D48 'd'
|
||||
createSuperscript 0x1D49 'e'
|
||||
createSuperscript 0x1D4D 'g'
|
||||
createSuperscript 0x1D4F 'k'
|
||||
createSuperscript 0x1D50 'm'
|
||||
createSuperscript 0x1D52 'o'
|
||||
createSuperscript 0x1D56 'p'
|
||||
createSuperscript 0x1D57 't'
|
||||
createSuperscript 0x1D58 'u'
|
||||
createSuperscript 0x1D5B 'v'
|
||||
createSuperscript 0x1D9C 'c'
|
||||
createSuperscript 0x1DA0 'f'
|
||||
createSuperscript 0x1DBB 'z'
|
||||
createSuperscript 0x1D2C 'A'
|
||||
createSuperscript 0x1D2E 'B'
|
||||
createSuperscript 0x1D30 'D'
|
||||
createSuperscript 0x1D31 'E'
|
||||
createSuperscript 0x1D33 'G'
|
||||
createSuperscript 0x1D34 'H'
|
||||
createSuperscript 0x1D35 'I'
|
||||
createSuperscript 0x1D36 'J'
|
||||
createSuperscript 0x1D37 'K'
|
||||
createSuperscript 0x1D38 'L'
|
||||
createSuperscript 0x1D39 'M'
|
||||
createSuperscript 0x1D3A 'N'
|
||||
createSuperscript 0x1D3C 'O'
|
||||
createSuperscript 0x1D3E 'P'
|
||||
createSuperscript 0x1D3F 'R'
|
||||
createSuperscript 0x1D40 'T'
|
||||
createSuperscript 0x1D41 'U'
|
||||
createSuperscript 0x1D42 'W'
|
||||
createSuperscripts : list {
|
||||
list 0x2070 'zero'
|
||||
list 0x00B9 'one'
|
||||
list 0x00B2 'two'
|
||||
list 0x00B3 'three'
|
||||
list 0x2074 'four'
|
||||
list 0x2075 'five'
|
||||
list 0x2076 'six'
|
||||
list 0x2077 'seven'
|
||||
list 0x2078 'eight'
|
||||
list 0x2079 'nine'
|
||||
list 0x02B0 'h'
|
||||
list 0x02B2 'j'
|
||||
list 0x02B3 'r'
|
||||
list 0x02B7 'w'
|
||||
list 0x02B8 'y'
|
||||
list 0x02E1 'l'
|
||||
list 0x02E2 's'
|
||||
list 0x02E3 'x'
|
||||
list 0x2071 'i'
|
||||
list 0x207F 'n'
|
||||
list 0x1D43 'a'
|
||||
list 0x1D47 'b'
|
||||
list 0x1D48 'd'
|
||||
list 0x1D49 'e'
|
||||
list 0x1D4D 'g'
|
||||
list 0x1D4F 'k'
|
||||
list 0x1D50 'm'
|
||||
list 0x1D52 'o'
|
||||
list 0x1D56 'p'
|
||||
list 0x1D57 't'
|
||||
list 0x1D58 'u'
|
||||
list 0x1D5B 'v'
|
||||
list 0x1D9C 'c'
|
||||
list 0x1DA0 'f'
|
||||
list 0x1DBB 'z'
|
||||
list 0x1D2C 'A'
|
||||
list 0x1D2E 'B'
|
||||
list 0x1D30 'D'
|
||||
list 0x1D31 'E'
|
||||
list 0x1D33 'G'
|
||||
list 0x1D34 'H'
|
||||
list 0x1D35 'I'
|
||||
list 0x1D36 'J'
|
||||
list 0x1D37 'K'
|
||||
list 0x1D38 'L'
|
||||
list 0x1D39 'M'
|
||||
list 0x1D3A 'N'
|
||||
list 0x1D3C 'O'
|
||||
list 0x1D3E 'P'
|
||||
list 0x1D3F 'R'
|
||||
list 0x1D40 'T'
|
||||
list 0x1D41 'U'
|
||||
list 0x1D42 'W'
|
||||
}
|
||||
|
||||
createSubscript 0x2080 'zero'
|
||||
createSubscript 0x2081 'one'
|
||||
createSubscript 0x2082 'two'
|
||||
createSubscript 0x2083 'three'
|
||||
createSubscript 0x2084 'four'
|
||||
createSubscript 0x2085 'five'
|
||||
createSubscript 0x2086 'six'
|
||||
createSubscript 0x2087 'seven'
|
||||
createSubscript 0x2088 'eight'
|
||||
createSubscript 0x2089 'nine'
|
||||
|
||||
createSubscript 0x2090 'a'
|
||||
createSubscript 0x2091 'e'
|
||||
createSubscript 0x2092 'o'
|
||||
createSubscript 0x2093 'x'
|
||||
# createSubscript 0x2094 'reve'
|
||||
createSubscript 0x2095 'h'
|
||||
createSubscript 0x2096 'k'
|
||||
createSubscript 0x2097 'l'
|
||||
createSubscript 0x2098 'm'
|
||||
createSubscript 0x2099 'n'
|
||||
createSubscript 0x209A 'p'
|
||||
createSubscript 0x209B 's'
|
||||
createSubscript 0x209C 't'
|
||||
createSubscript 0x1D62 'i'
|
||||
createSubscript 0x1D63 'r'
|
||||
createSubscript 0x1D64 'u'
|
||||
createSubscript 0x1D65 'v'
|
||||
createSubscripts : list {
|
||||
list 0x2080 'zero'
|
||||
list 0x2081 'one'
|
||||
list 0x2082 'two'
|
||||
list 0x2083 'three'
|
||||
list 0x2084 'four'
|
||||
list 0x2085 'five'
|
||||
list 0x2086 'six'
|
||||
list 0x2087 'seven'
|
||||
list 0x2088 'eight'
|
||||
list 0x2089 'nine'
|
||||
list 0x2090 'a'
|
||||
list 0x2091 'e'
|
||||
list 0x2092 'o'
|
||||
list 0x2093 'x'
|
||||
# list 0x2094 'reve'
|
||||
list 0x2095 'h'
|
||||
list 0x2096 'k'
|
||||
list 0x2097 'l'
|
||||
list 0x2098 'm'
|
||||
list 0x2099 'n'
|
||||
list 0x209A 'p'
|
||||
list 0x209B 's'
|
||||
list 0x209C 't'
|
||||
list 0x1D62 'i'
|
||||
list 0x1D63 'r'
|
||||
list 0x1D64 'u'
|
||||
list 0x1D65 'v'
|
||||
}
|
|
@ -197,5 +197,5 @@ create-glyph 'nine' : glyph-construction {
|
|||
:.start-from RIGHTSB ymiddlea
|
||||
:.set-width 0 STROKE
|
||||
:.line-to RIGHTSB [CAP * 0.4]
|
||||
include : sHookLower 0 [CAP * 0.4] HOOK [xgrid 0.48]
|
||||
include : sHookLower 0 [CAP * 0.4] HOOK [mix SB RIGHTSB 0.48]
|
||||
}
|
|
@ -194,7 +194,7 @@
|
|||
return _r14_t3;
|
||||
};
|
||||
r0_Glyph['prototype']['include'] = function _r0_t13(r16_component, r16_copyAnchors) {
|
||||
var r16_component, r16_copyAnchors, r16_glyph, r16_otherwise, r16_contours, r16_it, r16_transform, r16_shiftx, r16_shifty, r16_markid, r16_anchorThis, r16_anchorThat, _r16_t0, _r16_t1, _r16_t2, _r16_t3, _r16_t4, _r16_t5, _r16_t6, _r16_t7, _r16_t8, _r16_t9, _r16_t10, _r16_t11, _r16_t12, _r16_t13, _r16_t14, _r16_t15, _r16_t16, _r16_t17, _r16_t18, _r16_t19, _r16_t20, _r16_t21, _r16_t22, _r16_tag23, _r16_t24, _r16_t25, _r16_t26;
|
||||
var r16_component, r16_copyAnchors, r16_glyph, r16_otherwise, r16_contours, r16_it, r16_transform, r16_shiftx, r16_shifty, r16_markid, r16_anchorThis, r16_anchorThat, _r16_t0, _r16_t1, _r16_t2, _r16_t3, _r16_t4, _r16_t5, _r16_t6, _r16_t7, _r16_t8, _r16_t9, _r16_t10, _r16_t11, _r16_t12, _r16_t13, _r16_t14, _r16_t15, _r16_t16, _r16_t17, _r16_t18, _r16_t19, _r16_t20, _r16_t21, _r16_t22, _r16_tag23, _r16_t24, _r16_t25, _r16_t26, _r16_t27;
|
||||
_r16_t7 = this;
|
||||
_r16_t0 = r16_component;
|
||||
if (_r16_t2 = r0_aFunction['unapply'](_r16_t0, 1)) {
|
||||
|
@ -245,16 +245,16 @@
|
|||
r16_shiftx = _r16_t6[0];
|
||||
r16_shifty = _r16_t6[1];
|
||||
if (r16_anchorThat['mbx'] !== void 0 && r16_anchorThat['mby'] !== void 0)
|
||||
_r16_t26 = _r16_t7['anchors'][r16_markid] = {
|
||||
_r16_t27 = _r16_t7['anchors'][r16_markid] = {
|
||||
'x': r16_anchorThis['x'] + r16_anchorThat['mbx'] - r16_anchorThat['x'],
|
||||
'y': r16_anchorThis['y'] + r16_anchorThat['mby'] - r16_anchorThat['y'],
|
||||
'type': r16_anchorThis['type'],
|
||||
'mbx': r16_anchorThis['mbx'],
|
||||
'mby': r16_anchorThis['mby']
|
||||
};
|
||||
_r16_t25 = _r16_t26;
|
||||
_r16_t26 = _r16_t27;
|
||||
} else
|
||||
_r16_t25 = void 0;
|
||||
_r16_t26 = void 0;
|
||||
_r16_t14 = _r16_t5 = _r16_t5 + 1;
|
||||
}
|
||||
_r16_t12 = _r16_t14;
|
||||
|
@ -292,6 +292,8 @@
|
|||
_r16_t17 = void 0;
|
||||
if (r16_glyph['name'])
|
||||
return _r16_t7['dependencies']['push'](r16_glyph['name']);
|
||||
else if (r16_glyph['dependencies'])
|
||||
return _r16_t7['dependencies'] = _r16_t7['dependencies']['concat'](r16_glyph['dependencies']);
|
||||
else
|
||||
return void 0;
|
||||
};
|
||||
|
|
|
@ -129,7 +129,10 @@ define [Glyph.prototype.include component copyAnchors] : begin {
|
|||
foreach k [items-of keys] [set a`k anchors`k]
|
||||
* a
|
||||
}
|
||||
if glyph.name : this.dependencies.push glyph.name
|
||||
piecewise {
|
||||
glyph.name : this.dependencies.push glyph.name
|
||||
glyph.dependencies : this.dependencies = [this.dependencies.concat glyph.dependencies]
|
||||
}
|
||||
}
|
||||
define [Glyph.prototype.apply-transform transform] : set this.contours : this.contours.map : function [contour] : begin {
|
||||
return : contour.map : function [point] [tp transform point]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue