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

View File

@ -25,7 +25,6 @@ var font = function () {
console.log(' Start building font ' + fontUniqueName); console.log(' Start building font ' + fontUniqueName);
var font = buildGlyphs.build.call(emptyFont, para); var font = buildGlyphs.build.call(emptyFont, para);
console.log(' ' + fontUniqueName + " Successfully built."); console.log(' ' + fontUniqueName + " Successfully built.");
font.features.sscompose = para.sscompose;
font.parameters = para; font.parameters = para;
font.glyf = font.glyf.sort(function(a, b){ font.glyf = font.glyf.sort(function(a, b){
var pri1 = a.cmpPriority || 0; var pri1 = a.cmpPriority || 0;
@ -46,23 +45,6 @@ if (argv.charmap) (function () {
})), 'utf8') })), '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 // Currently unused
if(argv.ttf) (function(){ if(argv.ttf) (function(){
@ -169,8 +151,5 @@ if (argv.meta) (function () {
font.glyf = null; font.glyf = null;
font.glyfMap = null; font.glyfMap = null;
} }
if (argv.feature) {
font.features = null;
}
fs.writeFileSync(argv.meta, JSON.stringify(font)); fs.writeFileSync(argv.meta, JSON.stringify(font));
})(); })();

View File

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

View File

@ -8,9 +8,9 @@ snapshot/assets :
@- mkdir $@ @- mkdir $@
PATELC = node ./node_modules/patel/bin/patel-c 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 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 = $(SUPPORT_FILES) buildglyphs.js
SCRIPTS_FROM_aki = $(SUPPORT_FILES_FROM_PTL) 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 support/utils.js : support/utils.ptl
meta/aesthetics.js : meta/aesthetics.ptl meta/aesthetics.js : meta/aesthetics.ptl
meta/naming.js : meta/naming.ptl meta/naming.js : meta/naming.ptl
meta/features.js : meta/features.ptl
parameters.js : parameters.ptl parameters.js : parameters.ptl
cleanscripts : cleanscripts :

View File

@ -1,8 +1,9 @@
### Generate Features and remove double-width glyphs when necessary define-operator "~>" 880 'right' : syntax-rules
local markGlyphs {.all {} } `(@l ~> @r) `{.left @l .right @r}
# GPOS export : define [apply para glyphList] : begin
symbol-block 'GPOS' : if [not recursive] : begin local markGlyphs {.all {} }
# GPOS
local lookup_mark local lookup_mark
.type 'gpos_mark_to_base' .type 'gpos_mark_to_base'
.subtables {} .subtables {}
@ -10,7 +11,7 @@ symbol-block 'GPOS' : if [not recursive] : begin
.type 'gpos_mark_to_mark' .type 'gpos_mark_to_mark'
.subtables {} .subtables {}
set font.GPOS : object local GPOS : object
languages languages
.DFLT_DFLT {.features {'mark0', 'mkmk0'}} .DFLT_DFLT {.features {'mark0', 'mkmk0'}}
.latn_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 {'below'}
createMTSSubtable lookup_mkmk {'trailing' 'lf' 'topright' 'bottomright' 'overlay' 'slash'} createMTSSubtable lookup_mkmk {'trailing' 'lf' 'topright' 'bottomright' 'overlay' 'slash'}
# GDEF # GDEF
symbol-block 'GDEF' : if [not recursive] : begin local GDEF {.glyphClassDef {.}}
set font.GDEF {.glyphClassDef {.}}
foreach glyph [items-of glyphList] : begin 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 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 foreach key [items-of anchorKeys] : if (glyph.anchors.(key).type == 'mark') : begin
if [not markGlyphs.(key)] : set markGlyphs.(key) {} if [not markGlyphs.(key)] : set markGlyphs.(key) {}
markGlyphs.(key).push glyph.name markGlyphs.(key).push glyph.name
markGlyphs.all.push glyph.name markGlyphs.all.push glyph.name
set font.GDEF.glyphClassDef.(glyph.name) 3 set GDEF.glyphClassDef.(glyph.name) 3
# GSUB # GSUB
symbol-block 'GSUB' : if [not recursive] : begin
local commonList {} local commonList {}
local languages local languages
.DFLT_DFLT {.features commonList} .DFLT_DFLT {.features commonList}
@ -274,15 +273,14 @@ symbol-block 'GSUB' : if [not recursive] : begin
set features.locl_bgr {'locl_bgr'} set features.locl_bgr {'locl_bgr'}
# cvxx # cvxx
foreach [name : items-of : Object.keys glyphs] : begin foreach [glyph : items-of glyphList] : if glyph.featureSelector : begin
if glyphs.(name).featureSelector : begin local fs glyph.featureSelector
local fs glyphs.(name).featureSelector foreach [feature : items-of : Object.keys fs] : begin
foreach [feature : items-of : Object.keys fs] : begin if [not lookups.(feature)] : begin
if [not lookups.(feature)] : begin set features.(feature) {feature}
set features.(feature) {feature} set lookups.(feature) {.type 'gsub_single' .subtables{{.}}}
set lookups.(feature) {.type 'gsub_single' .subtables{{.}}} commonList.push feature
commonList.push feature set lookups.(feature).subtables.0.(glyph.name) fs.(feature)
set lookups.(feature).subtables.0.(name) fs.(feature)
# ssxx # ssxx
local sscompose : if para.isItalic para.sscompose.italic para.sscompose.upright local sscompose : if para.isItalic para.sscompose.italic para.sscompose.upright
foreach [name : items-of : Object.keys sscompose] : begin 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_MKD ' {.features [{'locl_srb'}.concat commonList]}
set languages.'cyrl_BGR ' {.features [{'locl_bgr'}.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 $(DISTDIR) : dist
@- $(MKDIR) $@ @- $(MKDIR) $@
NODE_FDT = @node $(NODE_FDT_OPTIONS) NODE_FDT = @node --expose-gc $(NODE_FDT_OPTIONS)
NODE = node 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 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