Reduced buildfont recursions.

This commit is contained in:
be5invis 2015-11-26 00:35:09 +08:00
parent 9f993b0e97
commit ab627c1da5
10 changed files with 84 additions and 73 deletions

View File

@ -267,13 +267,18 @@ define [buildFont para recursive] : begin
### Glyph slots and dependency profile generation (used for recursive subfonts)
local dependencyProfile {.}
local nTemp 0
local nPending 0
local pickHash : if recursive
then : let [h {.}] : begin
foreach j [items-of recursive] : set h.(j) j
set nPending recursive.length
* h
else nothing
define [create-glyph name actions] : piecewise
(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
set dependencyProfile.(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)))
dependencyProfile.(name) = [dependencyProfile.(name).concat dependencyProfile.(d) allAliases]
# process.stderr.write "\[if recursive 'Recursive ' '']Built Glyph /\(name).\n"
dec nPending
return glyphObject
true : begin
local actions arguments.0

View File

@ -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 emptyFont = toml.parse(fs.readFileSync(path.join(path.dirname(require.main.filename), 'emptyfont.toml'), 'utf-8'));
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) {
console.log(argv.o + " Successfully built. Styles: " + argv._)
fs.writeFileSync(argv.o, JSON.stringify(ttfFont));
}
if(argv.o) fs.writeFileSync(argv.o, JSON.stringify(font));

View File

@ -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}
* a
create-glyph 'ordfeminine' : glyph-construction
assign-unicode 0xAA
include [Miniature {'a'} 3.7 0.7].a
include : HBarBottom SB RIGHTSB DESCENDER
if [not recursive] : let [df : Miniature {'a' 'o'} 0.7 0.7] : begin
create-glyph 'ordfeminine' : glyph-construction
assign-unicode 0xAA
include df.a
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
apply-transform : Translate (-MIDDLE) (-XH)
apply-transform : Scale 0.7
apply-transform : Translate MIDDLE CAP
apply-transform : Italify
create-glyph 'ordmasculine' : glyph-construction
assign-unicode 0xBA
include [Miniature {'o'} 3.7 0.7].o
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
create-glyph 'ordmasculine' : glyph-construction
assign-unicode 0xBA
include df.o
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
createSMCPs : list

View File

@ -385,7 +385,13 @@ define [Fork glyphs params] : begin
local p : Object.create params
local shouldBuildList {}
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
define [Miniature glyphs fold scale] : begin

View File

@ -894,19 +894,18 @@ define [ErTail left w dohook] : glyph-construction
create-glyph 'rhotichook' : glyph-construction
assign-unicode 0x2DE
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
assign-unicode 0x25D
include eMarks
local f : Thinner {'revlatinepsilon'} 0.85
include f.revlatinepsilon
include : ErTail (WIDTH * 0.85 - SB - markFine * CORRECTION_HX)
if [not recursive] : let [thinfont : Thinner {'schwa' 'revlatinepsilon'} 0.85] : begin
create-glyph 'er' : glyph-construction
assign-unicode 0x25A
include eMarks
include thinfont.schwa
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
define [Belt] : glyph-construction
@ -944,14 +943,11 @@ create-glyph 'ltildeover' : glyph-construction
# Double stack
if [not recursive]: create-glyph 'ww' : glyph-construction
assign-unicode 0x2AC
local p : Object.create para
p.xheight = CAP / 2
local forked : Fork {'w'} p
include forked.w
include : WShape (CAP / 2)
apply-transform : Upright
apply-transform : Translate 0 (CAP / 2)
apply-transform : Italify
include forked.w
include : WShape (CAP / 2)
create-glyph 'bidentalpercussive' : glyph-construction
assign-unicode 0x2AD

View File

@ -43,27 +43,26 @@ create-glyph 'product' : glyph-construction
include : PiShape parenTop parenBot 0 OPERATORSTROKE
turned 'coproduct' 0x2210 'product' MIDDLE parenMid
create-glyph 'infty' : glyph-construction
assign-unicode 0x221E
local s : (RIGHTSB - SB - O * 4) / CAP
include [Miniature {'eight'} 5 s].eight
apply-transform : Upright
apply-transform : Translate (-MIDDLE) (-CAP / 2)
apply-transform : Rotate (Math.PI / 2)
apply-transform : Scale s
apply-transform : Translate MIDDLE parenMid
apply-transform : Italify
create-glyph 'propto' : glyph-construction
assign-unicode 0x221D
local s : (RIGHTSB - SB - O * 4) / CAP
include [Miniature {'rotetedpropto'} 5 s].rotetedpropto
apply-transform : Upright
apply-transform : Translate (-MIDDLE) (-CAP / 2)
apply-transform : Rotate (Math.PI / 2)
apply-transform : Scale s
apply-transform : Translate MIDDLE parenMid
apply-transform : Italify
if [not recursive] : let [s : (RIGHTSB - SB - O * 4) / CAP] : let [df : Miniature {'eight' 'rotetedpropto'} 5 s] : begin
create-glyph 'infty' : glyph-construction
assign-unicode 0x221E
include df.eight
apply-transform : Upright
apply-transform : Translate (-MIDDLE) (-CAP / 2)
apply-transform : Rotate (Math.PI / 2)
apply-transform : Scale s
apply-transform : Translate MIDDLE parenMid
apply-transform : Italify
create-glyph 'propto' : glyph-construction
assign-unicode 0x221D
include df.rotetedpropto
apply-transform : Upright
apply-transform : Translate (-MIDDLE) (-CAP / 2)
apply-transform : Rotate (Math.PI / 2)
apply-transform : Scale s
apply-transform : Translate MIDDLE parenMid
apply-transform : Italify
create-glyph 'partial' : glyph-construction
assign-unicode 0x2202

View File

@ -1,3 +1,5 @@
default: fonts
OBJDIR = build
include makesupport.mk
PARAM_DEFAULT = FAST='$(FAST)' SUFFIX='' VARIANTNAME='$(VARIANTNAME)' STYLE_COMMON='$(STYLE_COMMON)' STYLE_UPRIGHT='$(STYLE_UPRIGHT)' STYLE_ITALIC='$(STYLE_ITALIC)' VERSION='$(VERSION)'

View File

@ -3,7 +3,7 @@ GLYPH_SEGMENTS = glyphs/common-shapes.patel glyphs/overmarks.patel glyphs/latin-
SCRIPTS = $(SUPPORT_FILES) buildglyphs.js
buildglyphs.js : buildglyphs.patel $(GLYPH_SEGMENTS)
patel-c --optimize --mangle --strict $< -o $@
patel-c --optimize --strict $< -o $@
$(SUPPORT_FILES) :
patel-c --strict $< -o $@

View File

@ -1,3 +1,5 @@
default: fonts
TARGETUPM = 1000
OBJDIR = build
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
$(NODE) $^ $@ --upm $(TARGETUPM)
$(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
@$(NODE) $^ $@.a.ttf
@ttx -q -o $@.a.ttx $@.a.ttf
@ttx -q -o $@ $@.a.ttx
@ttx -q -o $@.a.ttx $@.a.ttf $(SUPPRESS_ERRORS)
@ttx -q -o $@ $@.a.ttx $(SUPPRESS_ERRORS)
@rm $@.a.ttf $@.a.ttx
$(TARGETS) : $(OBJDIR)/%.ttf : $(OBJDIR)/.pass4-%.ttf
ttfautohint $< $@

View File

@ -8,7 +8,7 @@ font = fontforge.open(source)
# Replace accented characters into references
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.replaceWithReference(2)
font.selection.all()
@ -16,7 +16,7 @@ if len(sys.argv) <= 3:
font.replaceWithReference(2)
# Remove overlapped area
print "Overlap Removal: ", font.fontname
print " Overlap Removal: ", font.fontname
font.selection.all()
font.removeOverlap()
font.round()
@ -33,12 +33,12 @@ if len(sys.argv) <= 3:
font.unlinkReferences()
# Outline simplify
print "Simplify: ", font.fontname
print " Simplify: ", font.fontname
font.layers["Fore"].is_quadratic = False
font.selection.all()
font.simplify(font.em / 2000.0, ("smoothcurves", "choosehv"), 0.1)
print "Finalize: ", font.fontname
print " Finalize: ", font.fontname
oldem = font.em
font.em = 1000
font.layers["Fore"].is_quadratic = True