separate more

This commit is contained in:
be5invis 2016-06-14 06:56:14 +08:00
parent e7c6899f20
commit 2f159a39a0
6 changed files with 31 additions and 51 deletions

View File

@ -11,6 +11,7 @@ import './support/fairify' as fairify
import [mix linreg clamp fallback TempFont includeGlyphPart compsiteMarkSet suggestGC] from './support/utils'
import [calculateMetrics setFontMetrics] from './meta/aesthetics'
import [nameFont] from './meta/naming'
import './meta/features' as Features
### Autoarg macro
define [$NamedParameterPair$ l r] : begin
@ -20,8 +21,6 @@ define [$NamedParameterPair$ l r] : begin
define-operator "--" 890 'right' : syntax-rules
`(@l -- @r) [atom l] `[new $NamedParameterPair$ @{".quote" [formOf l]} @r]
define-operator "~>" 880 'right' : syntax-rules
`(@l ~> @r) `{.left @l .right @r}
define-macro params : syntax-rules
`[params @_pairs @body] : begin
@ -366,9 +365,10 @@ export as build : define [buildFont para recursive recursiveCodes] : begin
$$include 'glyphs/symbol-other.ptl'
# Autobuilds
set font.features {.}
$$include 'glyphs/autobuilds.ptl'
$$include 'glyphs/features.ptl'
if [not recursive] : begin
set {.GSUB font.GSUB .GPOS font.GPOS .GDEF font.GDEF} : Features.apply para glyphList
set font.glyfMap glyphs
return font

View File

@ -25,7 +25,6 @@ var font = function () {
console.log(' Start building font ' + fontUniqueName);
var font = buildGlyphs.build.call(emptyFont, para);
console.log(' ' + fontUniqueName + " Successfully built.");
font.features.sscompose = para.sscompose;
font.parameters = para;
font.glyf = font.glyf.sort(function(a, b){
var pri1 = a.cmpPriority || 0;
@ -46,23 +45,6 @@ if (argv.charmap) (function () {
})), 'utf8')
})();
if (argv.feature) (function () {
console.log(' Writing feature file -> ' + argv.feature);
var featurefile = '\n\n';
// MG groups
for (var key in font.features.markGlyphs) {
featurefile += '@MG_' + key + '= [' + font.features.markGlyphs[key].join(' ') + '];\n'
}
featurefile += fs.readFileSync(__dirname + '/features/common.fea', 'utf-8');
featurefile += fs.readFileSync(__dirname + '/features/' + (font.parameters.isItalic ? 'italiconly.fea' : 'uprightonly.fea'), 'utf-8');
if (font.parameters.spacing > 0) {
featurefile += fs.readFileSync(__dirname + '/features/ligation.fea', 'utf-8');
}
fs.writeFileSync(argv.feature, featurefile, 'utf-8');
})();
/*
// Currently unused
if(argv.ttf) (function(){
@ -169,8 +151,5 @@ if (argv.meta) (function () {
font.glyf = null;
font.glyfMap = null;
}
if (argv.feature) {
font.features = null;
}
fs.writeFileSync(argv.meta, JSON.stringify(font));
})();

View File

@ -126,7 +126,7 @@ define customDecompositions : object
."\u21AE" ""
let : begin
suggestGC
if [not recursive] : suggestGC
define [isAboveMark mark] : mark && mark.anchors && mark.anchors.above && mark.anchors.above.type === MARK
define [iotaBelowToLF p j parts] : if (p === glyphs.iotaBelow) : set parts.(j) glyphs.iotaLF
define [ogonekBelowToTR p j parts] : if (p === glyphs.ogonekBelow) : set parts.(j) glyphs.ogonekTR

View File

@ -8,9 +8,9 @@ snapshot/assets :
@- mkdir $@
PATELC = node ./node_modules/patel/bin/patel-c
SUPPORT_FILES_FROM_PTL = support/glyph.js support/spiroexpand.js support/spirokit.js parameters.js support/anchor.js support/point.js support/transform.js support/utils.js meta/aesthetics.js meta/naming.js
SUPPORT_FILES_FROM_PTL = support/glyph.js support/spiroexpand.js support/spirokit.js parameters.js support/anchor.js support/point.js support/transform.js support/utils.js meta/aesthetics.js meta/naming.js meta/features.js
SUPPORT_FILES = $(SUPPORT_FILES_FROM_PTL) generator.js emptyfont.toml parameters.toml support/fairify.js
GLYPH_SEGMENTS = glyphs/common-shapes.ptl glyphs/overmarks.ptl glyphs/letters-unified-basic.ptl glyphs/letters-unified-extended.ptl glyphs/numbers.ptl glyphs/symbol-punctuation.ptl glyphs/symbol-math.ptl glyphs/symbol-geometric.ptl glyphs/symbol-other.ptl glyphs/symbol-braille.ptl glyphs/symbol-letter.ptl glyphs/autobuilds.ptl glyphs/features.ptl
GLYPH_SEGMENTS = glyphs/common-shapes.ptl glyphs/overmarks.ptl glyphs/letters-unified-basic.ptl glyphs/letters-unified-extended.ptl glyphs/numbers.ptl glyphs/symbol-punctuation.ptl glyphs/symbol-math.ptl glyphs/symbol-geometric.ptl glyphs/symbol-other.ptl glyphs/symbol-braille.ptl glyphs/symbol-letter.ptl glyphs/autobuilds.ptl
SCRIPTS = $(SUPPORT_FILES) buildglyphs.js
SCRIPTS_FROM_aki = $(SUPPORT_FILES_FROM_PTL) buildglyphs.js
@ -28,6 +28,7 @@ support/spiroexpand.js : support/spiroexpand.ptl
support/utils.js : support/utils.ptl
meta/aesthetics.js : meta/aesthetics.ptl
meta/naming.js : meta/naming.ptl
meta/features.js : meta/features.ptl
parameters.js : parameters.ptl
cleanscripts :

View File

@ -1,8 +1,9 @@
### Generate Features and remove double-width glyphs when necessary
local markGlyphs {.all {} }
define-operator "~>" 880 'right' : syntax-rules
`(@l ~> @r) `{.left @l .right @r}
# GPOS
symbol-block 'GPOS' : if [not recursive] : begin
export : define [apply para glyphList] : begin
local markGlyphs {.all {} }
# GPOS
local lookup_mark
.type 'gpos_mark_to_base'
.subtables {}
@ -10,7 +11,7 @@ symbol-block 'GPOS' : if [not recursive] : begin
.type 'gpos_mark_to_mark'
.subtables {}
set font.GPOS : object
local GPOS : object
languages
.DFLT_DFLT {.features {'mark0', 'mkmk0'}}
.latn_DFLT {.features {'mark0', 'mkmk0'}}
@ -68,20 +69,18 @@ symbol-block 'GPOS' : if [not recursive] : begin
createMTSSubtable lookup_mkmk {'below'}
createMTSSubtable lookup_mkmk {'trailing' 'lf' 'topright' 'bottomright' 'overlay' 'slash'}
# GDEF
symbol-block 'GDEF' : if [not recursive] : begin
set font.GDEF {.glyphClassDef {.}}
# GDEF
local GDEF {.glyphClassDef {.}}
foreach glyph [items-of glyphList] : begin
set font.GDEF.glyphClassDef.(glyph.name) : if [[regex '_'].test glyph.name] 2 1
set GDEF.glyphClassDef.(glyph.name) : if [[regex '_'].test glyph.name] 2 1
if (glyph.anchors && [begin [local anchorKeys : Object.keys glyph.anchors] anchorKeys.length]) : begin
foreach key [items-of anchorKeys] : if (glyph.anchors.(key).type == 'mark') : begin
if [not markGlyphs.(key)] : set markGlyphs.(key) {}
markGlyphs.(key).push glyph.name
markGlyphs.all.push glyph.name
set font.GDEF.glyphClassDef.(glyph.name) 3
set GDEF.glyphClassDef.(glyph.name) 3
# GSUB
symbol-block 'GSUB' : if [not recursive] : begin
# GSUB
local commonList {}
local languages
.DFLT_DFLT {.features commonList}
@ -274,15 +273,14 @@ symbol-block 'GSUB' : if [not recursive] : begin
set features.locl_bgr {'locl_bgr'}
# cvxx
foreach [name : items-of : Object.keys glyphs] : begin
if glyphs.(name).featureSelector : begin
local fs glyphs.(name).featureSelector
foreach [feature : items-of : Object.keys fs] : begin
if [not lookups.(feature)] : begin
set features.(feature) {feature}
set lookups.(feature) {.type 'gsub_single' .subtables{{.}}}
commonList.push feature
set lookups.(feature).subtables.0.(name) fs.(feature)
foreach [glyph : items-of glyphList] : if glyph.featureSelector : begin
local fs glyph.featureSelector
foreach [feature : items-of : Object.keys fs] : begin
if [not lookups.(feature)] : begin
set features.(feature) {feature}
set lookups.(feature) {.type 'gsub_single' .subtables{{.}}}
commonList.push feature
set lookups.(feature).subtables.0.(glyph.name) fs.(feature)
# ssxx
local sscompose : if para.isItalic para.sscompose.italic para.sscompose.upright
foreach [name : items-of : Object.keys sscompose] : begin
@ -293,4 +291,6 @@ symbol-block 'GSUB' : if [not recursive] : begin
set languages.'cyrl_MKD ' {.features [{'locl_srb'}.concat commonList]}
set languages.'cyrl_BGR ' {.features [{'locl_bgr'}.concat commonList]}
set font.GSUB {.languages languages .features features .lookups lookups}
local GSUB {.languages languages .features features .lookups lookups}
return [object GSUB GPOS GDEF]

View File

@ -30,7 +30,7 @@ DISTDIR = dist/$(ARCPREFIX)$(ARCPREFIXB)
$(DISTDIR) : dist
@- $(MKDIR) $@
NODE_FDT = @node $(NODE_FDT_OPTIONS)
NODE_FDT = @node --expose-gc $(NODE_FDT_OPTIONS)
NODE = node
UPRIGHT = $(OBJDIR)/$(PREFIX)-thin.ttf $(OBJDIR)/$(PREFIX)-extralight.ttf $(OBJDIR)/$(PREFIX)-light.ttf $(OBJDIR)/$(PREFIX)-regular.ttf $(OBJDIR)/$(PREFIX)-medium.ttf $(OBJDIR)/$(PREFIX)-bold.ttf $(OBJDIR)/$(PREFIX)-heavy.ttf