Reduced buildfont recursions.
This commit is contained in:
parent
9f993b0e97
commit
ab627c1da5
|
@ -267,13 +267,18 @@ define [buildFont para recursive] : begin
|
||||||
### Glyph slots and dependency profile generation (used for recursive subfonts)
|
### Glyph slots and dependency profile generation (used for recursive subfonts)
|
||||||
local dependencyProfile {.}
|
local dependencyProfile {.}
|
||||||
local nTemp 0
|
local nTemp 0
|
||||||
|
local nPending 0
|
||||||
local pickHash : if recursive
|
local pickHash : if recursive
|
||||||
then : let [h {.}] : begin
|
then : let [h {.}] : begin
|
||||||
foreach j [items-of recursive] : set h.(j) j
|
foreach j [items-of recursive] : set h.(j) j
|
||||||
|
set nPending recursive.length
|
||||||
* h
|
* h
|
||||||
else nothing
|
else nothing
|
||||||
define [create-glyph name actions] : piecewise
|
define [create-glyph name actions] : piecewise
|
||||||
(name && actions) : begin
|
(name && actions) : begin
|
||||||
|
if (pickHash && nPending <= 0) : begin
|
||||||
|
console.log " Done recursive build for \[if (recursive.length > 3) [recursive.slice 0 3 :.concat {'...'} :.join ','] [recursive.join ',']] in \(font.name.uniqueSubFamily)"
|
||||||
|
throw {.glyfMap glyphs}
|
||||||
if (pickHash && [not pickHash.(name)]) : return nothing
|
if (pickHash && [not pickHash.(name)]) : return nothing
|
||||||
set dependencyProfile.(name) {}
|
set dependencyProfile.(name) {}
|
||||||
define glyphObject [new Glyph name]
|
define glyphObject [new Glyph name]
|
||||||
|
@ -286,6 +291,7 @@ define [buildFont para recursive] : begin
|
||||||
local allAliases : Object.keys glyphs :.filter ([k] -> (glyphs.(k) === glyphs.(d)))
|
local allAliases : Object.keys glyphs :.filter ([k] -> (glyphs.(k) === glyphs.(d)))
|
||||||
dependencyProfile.(name) = [dependencyProfile.(name).concat dependencyProfile.(d) allAliases]
|
dependencyProfile.(name) = [dependencyProfile.(name).concat dependencyProfile.(d) allAliases]
|
||||||
# process.stderr.write "\[if recursive 'Recursive ' '']Built Glyph /\(name).\n"
|
# process.stderr.write "\[if recursive 'Recursive ' '']Built Glyph /\(name).\n"
|
||||||
|
dec nPending
|
||||||
return glyphObject
|
return glyphObject
|
||||||
true : begin
|
true : begin
|
||||||
local actions arguments.0
|
local actions arguments.0
|
||||||
|
|
10
generate.js
10
generate.js
|
@ -8,10 +8,10 @@ var toml = require('toml');
|
||||||
var parametersData = toml.parse(fs.readFileSync(path.join(path.dirname(require.main.filename), 'parameters.toml'), 'utf-8'));
|
var parametersData = toml.parse(fs.readFileSync(path.join(path.dirname(require.main.filename), 'parameters.toml'), 'utf-8'));
|
||||||
var emptyFont = toml.parse(fs.readFileSync(path.join(path.dirname(require.main.filename), 'emptyfont.toml'), 'utf-8'));
|
var emptyFont = toml.parse(fs.readFileSync(path.join(path.dirname(require.main.filename), 'emptyfont.toml'), 'utf-8'));
|
||||||
var para = parameters.build(parametersData, argv._);
|
var para = parameters.build(parametersData, argv._);
|
||||||
|
var fontUniqueName = para.family + ' ' + para.style + ' ' + para.version + ' (' + para.codename + ')'
|
||||||
|
|
||||||
var ttfFont = buildGlyphs.build.call(emptyFont, para);
|
console.log(' Start build font' + fontUniqueName);
|
||||||
|
var font = buildGlyphs.build.call(emptyFont, para);
|
||||||
|
console.log(' ' + fontUniqueName + " Successfully built.");
|
||||||
|
|
||||||
if(argv.o) {
|
if(argv.o) fs.writeFileSync(argv.o, JSON.stringify(font));
|
||||||
console.log(argv.o + " Successfully built. Styles: " + argv._)
|
|
||||||
fs.writeFileSync(argv.o, JSON.stringify(ttfFont));
|
|
||||||
}
|
|
|
@ -320,28 +320,28 @@ if [not recursive] : createCircledGlyphs : [list \\
|
||||||
foreach [j : range 0 26] : a.push {(0x24D0 + j) unicodeGlyphs.(['a'.charCodeAt 0] + j).name FULLWIDTH}
|
foreach [j : range 0 26] : a.push {(0x24D0 + j) unicodeGlyphs.(['a'.charCodeAt 0] + j).name FULLWIDTH}
|
||||||
* a
|
* a
|
||||||
|
|
||||||
|
if [not recursive] : let [df : Miniature {'a' 'o'} 0.7 0.7] : begin
|
||||||
create-glyph 'ordfeminine' : glyph-construction
|
create-glyph 'ordfeminine' : glyph-construction
|
||||||
assign-unicode 0xAA
|
assign-unicode 0xAA
|
||||||
include [Miniature {'a'} 3.7 0.7].a
|
include df.a
|
||||||
include : HBarBottom SB RIGHTSB DESCENDER
|
include : HBarBottom SB RIGHTSB DESCENDER
|
||||||
|
|
||||||
|
apply-transform : Upright
|
||||||
|
apply-transform : Translate (-MIDDLE) (-XH)
|
||||||
|
apply-transform : Scale 0.7
|
||||||
|
apply-transform : Translate MIDDLE CAP
|
||||||
|
apply-transform : Italify
|
||||||
|
|
||||||
apply-transform : Upright
|
create-glyph 'ordmasculine' : glyph-construction
|
||||||
apply-transform : Translate (-MIDDLE) (-XH)
|
assign-unicode 0xBA
|
||||||
apply-transform : Scale 0.7
|
include df.o
|
||||||
apply-transform : Translate MIDDLE CAP
|
include : HBarBottom SB RIGHTSB DESCENDER
|
||||||
apply-transform : Italify
|
|
||||||
|
apply-transform : Upright
|
||||||
create-glyph 'ordmasculine' : glyph-construction
|
apply-transform : Translate (-MIDDLE) (-XH)
|
||||||
assign-unicode 0xBA
|
apply-transform : Scale 0.7
|
||||||
include [Miniature {'o'} 3.7 0.7].o
|
apply-transform : Translate MIDDLE CAP
|
||||||
include : HBarBottom SB RIGHTSB DESCENDER
|
apply-transform : Italify
|
||||||
|
|
||||||
apply-transform : Upright
|
|
||||||
apply-transform : Translate (-MIDDLE) (-XH)
|
|
||||||
apply-transform : Scale 0.7
|
|
||||||
apply-transform : Translate MIDDLE CAP
|
|
||||||
apply-transform : Italify
|
|
||||||
|
|
||||||
|
|
||||||
createSMCPs : list
|
createSMCPs : list
|
||||||
|
|
|
@ -385,7 +385,13 @@ define [Fork glyphs params] : begin
|
||||||
local p : Object.create params
|
local p : Object.create params
|
||||||
local shouldBuildList {}
|
local shouldBuildList {}
|
||||||
foreach glyphid [items-of glyphs] : set shouldBuildList : shouldBuildList.concat {glyphid :: dependencyProfile.(glyphid)}
|
foreach glyphid [items-of glyphs] : set shouldBuildList : shouldBuildList.concat {glyphid :: dependencyProfile.(glyphid)}
|
||||||
local forkFont : buildFont.call [TempFont] p shouldBuildList
|
set shouldBuildList : shouldBuildList.filter : [x] -> [not [not x]]
|
||||||
|
try : begin
|
||||||
|
local forkFont : buildFont.call [TempFont] p shouldBuildList
|
||||||
|
: ex
|
||||||
|
: begin
|
||||||
|
if ex.glyfMap : return ex.glyfMap
|
||||||
|
: else : throw ex
|
||||||
return forkFont.glyfMap
|
return forkFont.glyfMap
|
||||||
|
|
||||||
define [Miniature glyphs fold scale] : begin
|
define [Miniature glyphs fold scale] : begin
|
||||||
|
|
|
@ -894,19 +894,18 @@ define [ErTail left w dohook] : glyph-construction
|
||||||
create-glyph 'rhotichook' : glyph-construction
|
create-glyph 'rhotichook' : glyph-construction
|
||||||
assign-unicode 0x2DE
|
assign-unicode 0x2DE
|
||||||
include : ErTail (-STROKE * CORRECTION_HX) STROKE true
|
include : ErTail (-STROKE * CORRECTION_HX) STROKE true
|
||||||
create-glyph 'er' : glyph-construction
|
|
||||||
assign-unicode 0x25A
|
|
||||||
include eMarks
|
|
||||||
local f : Thinner {'schwa'} 0.85
|
|
||||||
include f.schwa
|
|
||||||
include : ErTail (WIDTH * 0.85 - SB - markFine * CORRECTION_HX)
|
|
||||||
|
|
||||||
create-glyph 'revlatinepsiloner' : glyph-construction
|
if [not recursive] : let [thinfont : Thinner {'schwa' 'revlatinepsilon'} 0.85] : begin
|
||||||
assign-unicode 0x25D
|
create-glyph 'er' : glyph-construction
|
||||||
include eMarks
|
assign-unicode 0x25A
|
||||||
local f : Thinner {'revlatinepsilon'} 0.85
|
include eMarks
|
||||||
include f.revlatinepsilon
|
include thinfont.schwa
|
||||||
include : ErTail (WIDTH * 0.85 - SB - markFine * CORRECTION_HX)
|
include : ErTail (WIDTH * 0.85 - SB - markFine * CORRECTION_HX)
|
||||||
|
create-glyph 'revlatinepsiloner' : glyph-construction
|
||||||
|
assign-unicode 0x25D
|
||||||
|
include eMarks
|
||||||
|
include thinfont.revlatinepsilon
|
||||||
|
include : ErTail (WIDTH * 0.85 - SB - markFine * CORRECTION_HX)
|
||||||
|
|
||||||
# Belted
|
# Belted
|
||||||
define [Belt] : glyph-construction
|
define [Belt] : glyph-construction
|
||||||
|
@ -944,14 +943,11 @@ create-glyph 'ltildeover' : glyph-construction
|
||||||
# Double stack
|
# Double stack
|
||||||
if [not recursive]: create-glyph 'ww' : glyph-construction
|
if [not recursive]: create-glyph 'ww' : glyph-construction
|
||||||
assign-unicode 0x2AC
|
assign-unicode 0x2AC
|
||||||
local p : Object.create para
|
include : WShape (CAP / 2)
|
||||||
p.xheight = CAP / 2
|
|
||||||
local forked : Fork {'w'} p
|
|
||||||
include forked.w
|
|
||||||
apply-transform : Upright
|
apply-transform : Upright
|
||||||
apply-transform : Translate 0 (CAP / 2)
|
apply-transform : Translate 0 (CAP / 2)
|
||||||
apply-transform : Italify
|
apply-transform : Italify
|
||||||
include forked.w
|
include : WShape (CAP / 2)
|
||||||
|
|
||||||
create-glyph 'bidentalpercussive' : glyph-construction
|
create-glyph 'bidentalpercussive' : glyph-construction
|
||||||
assign-unicode 0x2AD
|
assign-unicode 0x2AD
|
||||||
|
|
|
@ -43,27 +43,26 @@ create-glyph 'product' : glyph-construction
|
||||||
include : PiShape parenTop parenBot 0 OPERATORSTROKE
|
include : PiShape parenTop parenBot 0 OPERATORSTROKE
|
||||||
|
|
||||||
turned 'coproduct' 0x2210 'product' MIDDLE parenMid
|
turned 'coproduct' 0x2210 'product' MIDDLE parenMid
|
||||||
create-glyph 'infty' : glyph-construction
|
if [not recursive] : let [s : (RIGHTSB - SB - O * 4) / CAP] : let [df : Miniature {'eight' 'rotetedpropto'} 5 s] : begin
|
||||||
assign-unicode 0x221E
|
create-glyph 'infty' : glyph-construction
|
||||||
local s : (RIGHTSB - SB - O * 4) / CAP
|
assign-unicode 0x221E
|
||||||
include [Miniature {'eight'} 5 s].eight
|
include df.eight
|
||||||
apply-transform : Upright
|
apply-transform : Upright
|
||||||
apply-transform : Translate (-MIDDLE) (-CAP / 2)
|
apply-transform : Translate (-MIDDLE) (-CAP / 2)
|
||||||
apply-transform : Rotate (Math.PI / 2)
|
apply-transform : Rotate (Math.PI / 2)
|
||||||
apply-transform : Scale s
|
apply-transform : Scale s
|
||||||
apply-transform : Translate MIDDLE parenMid
|
apply-transform : Translate MIDDLE parenMid
|
||||||
apply-transform : Italify
|
apply-transform : Italify
|
||||||
|
|
||||||
create-glyph 'propto' : glyph-construction
|
create-glyph 'propto' : glyph-construction
|
||||||
assign-unicode 0x221D
|
assign-unicode 0x221D
|
||||||
local s : (RIGHTSB - SB - O * 4) / CAP
|
include df.rotetedpropto
|
||||||
include [Miniature {'rotetedpropto'} 5 s].rotetedpropto
|
apply-transform : Upright
|
||||||
apply-transform : Upright
|
apply-transform : Translate (-MIDDLE) (-CAP / 2)
|
||||||
apply-transform : Translate (-MIDDLE) (-CAP / 2)
|
apply-transform : Rotate (Math.PI / 2)
|
||||||
apply-transform : Rotate (Math.PI / 2)
|
apply-transform : Scale s
|
||||||
apply-transform : Scale s
|
apply-transform : Translate MIDDLE parenMid
|
||||||
apply-transform : Translate MIDDLE parenMid
|
apply-transform : Italify
|
||||||
apply-transform : Italify
|
|
||||||
|
|
||||||
create-glyph 'partial' : glyph-construction
|
create-glyph 'partial' : glyph-construction
|
||||||
assign-unicode 0x2202
|
assign-unicode 0x2202
|
||||||
|
|
2
makefile
2
makefile
|
@ -1,3 +1,5 @@
|
||||||
|
default: fonts
|
||||||
|
|
||||||
OBJDIR = build
|
OBJDIR = build
|
||||||
include makesupport.mk
|
include makesupport.mk
|
||||||
PARAM_DEFAULT = FAST='$(FAST)' SUFFIX='' VARIANTNAME='$(VARIANTNAME)' STYLE_COMMON='$(STYLE_COMMON)' STYLE_UPRIGHT='$(STYLE_UPRIGHT)' STYLE_ITALIC='$(STYLE_ITALIC)' VERSION='$(VERSION)'
|
PARAM_DEFAULT = FAST='$(FAST)' SUFFIX='' VARIANTNAME='$(VARIANTNAME)' STYLE_COMMON='$(STYLE_COMMON)' STYLE_UPRIGHT='$(STYLE_UPRIGHT)' STYLE_ITALIC='$(STYLE_ITALIC)' VERSION='$(VERSION)'
|
||||||
|
|
|
@ -3,7 +3,7 @@ GLYPH_SEGMENTS = glyphs/common-shapes.patel glyphs/overmarks.patel glyphs/latin-
|
||||||
SCRIPTS = $(SUPPORT_FILES) buildglyphs.js
|
SCRIPTS = $(SUPPORT_FILES) buildglyphs.js
|
||||||
|
|
||||||
buildglyphs.js : buildglyphs.patel $(GLYPH_SEGMENTS)
|
buildglyphs.js : buildglyphs.patel $(GLYPH_SEGMENTS)
|
||||||
patel-c --optimize --mangle --strict $< -o $@
|
patel-c --optimize --strict $< -o $@
|
||||||
|
|
||||||
$(SUPPORT_FILES) :
|
$(SUPPORT_FILES) :
|
||||||
patel-c --strict $< -o $@
|
patel-c --strict $< -o $@
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
default: fonts
|
||||||
|
|
||||||
TARGETUPM = 1000
|
TARGETUPM = 1000
|
||||||
OBJDIR = build
|
OBJDIR = build
|
||||||
include makesupport.mk
|
include makesupport.mk
|
||||||
|
@ -63,11 +65,11 @@ $(PASS1) : $(OBJDIR)/.pass1-%.ttf : pass1-cleanup.py $(OBJDIR)/.pass0-%.ttf
|
||||||
$(PASS2) : $(OBJDIR)/.pass2-%.ttf : pass2-smartround.js $(OBJDIR)/.pass1-%.ttf
|
$(PASS2) : $(OBJDIR)/.pass2-%.ttf : pass2-smartround.js $(OBJDIR)/.pass1-%.ttf
|
||||||
$(NODE) $^ $@ --upm $(TARGETUPM)
|
$(NODE) $^ $@ --upm $(TARGETUPM)
|
||||||
$(PASS3) : $(OBJDIR)/.pass3-%.ttf : pass3-features.py $(OBJDIR)/.pass2-%.ttf $(OBJDIR)/.pass0-%.fea
|
$(PASS3) : $(OBJDIR)/.pass3-%.ttf : pass3-features.py $(OBJDIR)/.pass2-%.ttf $(OBJDIR)/.pass0-%.fea
|
||||||
fontforge -quiet -script $^ $@ $(TARGETUPM)
|
fontforge -quiet -script $^ $@ $(TARGETUPM) $(SUPPRESS_ERRORS)
|
||||||
$(PASS4) : $(OBJDIR)/.pass4-%.ttf : pass4-finalize.js $(OBJDIR)/.pass3-%.ttf
|
$(PASS4) : $(OBJDIR)/.pass4-%.ttf : pass4-finalize.js $(OBJDIR)/.pass3-%.ttf
|
||||||
@$(NODE) $^ $@.a.ttf
|
@$(NODE) $^ $@.a.ttf
|
||||||
@ttx -q -o $@.a.ttx $@.a.ttf
|
@ttx -q -o $@.a.ttx $@.a.ttf $(SUPPRESS_ERRORS)
|
||||||
@ttx -q -o $@ $@.a.ttx
|
@ttx -q -o $@ $@.a.ttx $(SUPPRESS_ERRORS)
|
||||||
@rm $@.a.ttf $@.a.ttx
|
@rm $@.a.ttf $@.a.ttx
|
||||||
$(TARGETS) : $(OBJDIR)/%.ttf : $(OBJDIR)/.pass4-%.ttf
|
$(TARGETS) : $(OBJDIR)/%.ttf : $(OBJDIR)/.pass4-%.ttf
|
||||||
ttfautohint $< $@
|
ttfautohint $< $@
|
||||||
|
|
|
@ -8,7 +8,7 @@ font = fontforge.open(source)
|
||||||
|
|
||||||
# Replace accented characters into references
|
# Replace accented characters into references
|
||||||
if len(sys.argv) <= 3:
|
if len(sys.argv) <= 3:
|
||||||
print "Reference finding: ", font.fontname
|
print " Reference finding: ", font.fontname
|
||||||
font.selection.select(("ranges", "unicode", None), 0x1FCD, 0x1FCF, 0x1FDD, 0x1FDF)
|
font.selection.select(("ranges", "unicode", None), 0x1FCD, 0x1FCF, 0x1FDD, 0x1FDF)
|
||||||
font.replaceWithReference(2)
|
font.replaceWithReference(2)
|
||||||
font.selection.all()
|
font.selection.all()
|
||||||
|
@ -16,7 +16,7 @@ if len(sys.argv) <= 3:
|
||||||
font.replaceWithReference(2)
|
font.replaceWithReference(2)
|
||||||
|
|
||||||
# Remove overlapped area
|
# Remove overlapped area
|
||||||
print "Overlap Removal: ", font.fontname
|
print " Overlap Removal: ", font.fontname
|
||||||
font.selection.all()
|
font.selection.all()
|
||||||
font.removeOverlap()
|
font.removeOverlap()
|
||||||
font.round()
|
font.round()
|
||||||
|
@ -33,12 +33,12 @@ if len(sys.argv) <= 3:
|
||||||
font.unlinkReferences()
|
font.unlinkReferences()
|
||||||
|
|
||||||
# Outline simplify
|
# Outline simplify
|
||||||
print "Simplify: ", font.fontname
|
print " Simplify: ", font.fontname
|
||||||
font.layers["Fore"].is_quadratic = False
|
font.layers["Fore"].is_quadratic = False
|
||||||
font.selection.all()
|
font.selection.all()
|
||||||
font.simplify(font.em / 2000.0, ("smoothcurves", "choosehv"), 0.1)
|
font.simplify(font.em / 2000.0, ("smoothcurves", "choosehv"), 0.1)
|
||||||
|
|
||||||
print "Finalize: ", font.fontname
|
print " Finalize: ", font.fontname
|
||||||
oldem = font.em
|
oldem = font.em
|
||||||
font.em = 1000
|
font.em = 1000
|
||||||
font.layers["Fore"].is_quadratic = True
|
font.layers["Fore"].is_quadratic = True
|
||||||
|
|
Loading…
Reference in New Issue
Block a user