Optimize footprint by reducing aliasable glyphs
This commit is contained in:
parent
73619b0d6d
commit
3d8e8ffd05
5 changed files with 52 additions and 28 deletions
|
@ -20,6 +20,7 @@ glyph-block Autobuild-Transformed-Shared : begin
|
|||
set name (name + j)
|
||||
return name
|
||||
|
||||
glyph-block-export suggestMappedName
|
||||
define [suggestMappedName map key name] : begin
|
||||
if map.(key) : return map.(key)
|
||||
local amended : suggestName name
|
||||
|
@ -538,6 +539,22 @@ glyph-block Autobuild-Transformed-Mathematical : begin
|
|||
|
||||
createMathDerivedSeriesImpl groupName tfm jobs
|
||||
|
||||
define [CreateMathAliasableImpl groupName altGroupName tfm base letters overrides] : begin
|
||||
if recursive : return nothing
|
||||
local overrideMap : new Map (overrides || {})
|
||||
foreach j [range 0 letters.length] : begin
|
||||
local letter letters.(j)
|
||||
local source : glyphStore.queryNameOfUnicode : letter.codePointAt 0
|
||||
if (source && altGroupName) : set source "\(source)+\(altGroupName)"
|
||||
local uDst : base + j
|
||||
if [overrideMap.has letter] : set uDst [overrideMap.get letter]
|
||||
if source : alias "\(source)+\(groupName)" uDst source
|
||||
|
||||
define [CreateMathAliasable cond groupName altGroupName tfm base letters overrides] : begin
|
||||
if cond
|
||||
CreateMathDerivatives groupName tfm base letters overrides
|
||||
CreateMathAliasableImpl groupName altGroupName tfm base letters overrides
|
||||
|
||||
# Math bold
|
||||
CreateMathDerivatives 'mathbf' tfBold 0x1D400 UpperLatin
|
||||
CreateMathDerivatives 'mathbf' tfBold 0x1D41A LowerLatin
|
||||
|
@ -558,28 +575,29 @@ glyph-block Autobuild-Transformed-Mathematical : begin
|
|||
CreateMathDerivatives 'mathbi' tfBoldItalic 0x1D736 LowerGreek
|
||||
|
||||
# Math Sans-serif
|
||||
CreateMathDerivatives 'mathss' tfSans 0x1D5A0 UpperLatin
|
||||
CreateMathDerivatives 'mathss' tfSans 0x1D5BA LowerLatin
|
||||
CreateMathDerivatives 'mathss' tfSans 0x1D7E2 Digits
|
||||
CreateMathAliasable SLAB 'mathss' null tfSans 0x1D5A0 UpperLatin
|
||||
CreateMathAliasable SLAB 'mathss' null tfSans 0x1D5BA LowerLatin
|
||||
CreateMathAliasable SLAB 'mathss' null tfSans 0x1D7E2 Digits
|
||||
|
||||
CreateMathDerivatives 'mathsi' tfSansItalic 0x1D608 UpperLatin
|
||||
CreateMathDerivatives 'mathsi' tfSansItalic 0x1D622 LowerLatin
|
||||
CreateMathAliasable SLAB 'mathsi' 'mathit' tfSansItalic 0x1D608 UpperLatin
|
||||
CreateMathAliasable SLAB 'mathsi' 'mathit' tfSansItalic 0x1D622 LowerLatin
|
||||
|
||||
CreateMathDerivatives 'mathsb' tfSansBold 0x1D5D4 UpperLatin
|
||||
CreateMathDerivatives 'mathsb' tfSansBold 0x1D5EE LowerLatin
|
||||
CreateMathDerivatives 'mathsb' tfSansBold 0x1D756 UpperGreek
|
||||
CreateMathDerivatives 'mathsb' tfSansBold 0x1D770 LowerGreek
|
||||
CreateMathDerivatives 'mathsb' tfSansBold 0x1D7EC Digits
|
||||
CreateMathAliasable SLAB 'mathsb' 'mathbf' tfSansBold 0x1D5D4 UpperLatin
|
||||
CreateMathAliasable SLAB 'mathsb' 'mathbf' tfSansBold 0x1D5EE LowerLatin
|
||||
CreateMathAliasable SLAB 'mathsb' 'mathbf' tfSansBold 0x1D756 UpperGreek
|
||||
CreateMathAliasable SLAB 'mathsb' 'mathbf' tfSansBold 0x1D770 LowerGreek
|
||||
CreateMathAliasable SLAB 'mathsb' 'mathbf' tfSansBold 0x1D7EC Digits
|
||||
|
||||
CreateMathDerivatives 'mathsz' tfSansBoldItalic 0x1D63C UpperLatin
|
||||
CreateMathDerivatives 'mathsz' tfSansBoldItalic 0x1D656 LowerLatin
|
||||
CreateMathDerivatives 'mathsz' tfSansBoldItalic 0x1D790 UpperGreek
|
||||
CreateMathDerivatives 'mathsz' tfSansBoldItalic 0x1D7AA LowerGreek
|
||||
CreateMathAliasable SLAB 'mathsz' 'mathbi' tfSansBoldItalic 0x1D63C UpperLatin
|
||||
CreateMathAliasable SLAB 'mathsz' 'mathbi' tfSansBoldItalic 0x1D656 LowerLatin
|
||||
CreateMathAliasable SLAB 'mathsz' 'mathbi' tfSansBoldItalic 0x1D790 UpperGreek
|
||||
CreateMathAliasable SLAB 'mathsz' 'mathbi' tfSansBoldItalic 0x1D7AA LowerGreek
|
||||
|
||||
# Math Typewriter
|
||||
CreateMathDerivatives 'mathtt' tfTypeWriter 0x1D670 UpperLatin
|
||||
CreateMathDerivatives 'mathtt' tfTypeWriter 0x1D68A LowerLatin
|
||||
CreateMathDerivatives 'mathtt' tfTypeWriter 0x1D7F6 Digits
|
||||
local doTypewriter : para.quasiProportionalDiversity > 0
|
||||
CreateMathAliasable doTypewriter 'mathtt' null tfTypeWriter 0x1D670 UpperLatin
|
||||
CreateMathAliasable doTypewriter 'mathtt' null tfTypeWriter 0x1D68A LowerLatin
|
||||
CreateMathAliasable doTypewriter 'mathtt' null tfTypeWriter 0x1D7F6 Digits
|
||||
|
||||
glyph-block Autobuild-Rhotic : begin
|
||||
glyph-block-import Marks : markFine
|
||||
|
|
|
@ -50,9 +50,11 @@ glyph-block Common-Derivatives : begin
|
|||
if [not goal] : throw : new Error "Cannot find glyph '\(id)'"
|
||||
this.includeGlyph goal copyAnchors copyWidth
|
||||
|
||||
define [with-related-glyphs sourceGid dstGid unicode Fn] : if [glyph-is-needed sourceGid] : begin
|
||||
define [with-related-glyphs sourceGid dstGid dstUnicode Fn] : begin
|
||||
if [not : glyph-is-needed sourceGid] : return nothing
|
||||
|
||||
local glyphSrc : glyphStore.queryByName sourceGid
|
||||
local glyphDst : create-glyph dstGid unicode : glyph-proc
|
||||
local glyphDst : create-glyph dstGid dstUnicode : glyph-proc
|
||||
include : Fn sourceGid null
|
||||
|
||||
if glyphDst : foreach [gr : items-of : AnyDerivingCv.query glyphSrc] : begin
|
||||
|
@ -60,12 +62,16 @@ glyph-block Common-Derivatives : begin
|
|||
create-glyph [gr.amendName dstGid] : glyph-proc
|
||||
include : Fn [gr.get glyphSrc] gr.tag
|
||||
|
||||
define [alias newid unicode id] : begin
|
||||
if [not newid] : throw : new Error "Target ID not specified"
|
||||
with-related-glyphs id newid unicode
|
||||
lambda [src sel] : glyph-proc
|
||||
include [refer-glyph src] AS_BASE ALSO_METRICS
|
||||
currentGlyph.cloneRankFromGlyph [query-glyph src]
|
||||
define [alias dstGid dstUnicode sourceGid] : begin
|
||||
if [not dstGid] : throw : new Error "Target ID not specified"
|
||||
if [not : glyph-is-needed sourceGid] : return nothing
|
||||
|
||||
local glyphSrc : glyphStore.queryByNameEnsured sourceGid
|
||||
local glyphDst : create-glyph dstGid dstUnicode : glyph-proc
|
||||
include [refer-glyph sourceGid] AS_BASE ALSO_METRICS
|
||||
|
||||
if glyphDst : foreach [gr : items-of : AnyDerivingCv.query glyphSrc] : begin
|
||||
gr.set glyphDst [gr.get glyphSrc]
|
||||
|
||||
define [turned newid unicode id _x _y mark] : begin
|
||||
if [not newid] : throw : new Error "Target ID not specified"
|
||||
|
|
|
@ -122,8 +122,7 @@ export : define [calculateMetrics para] : begin
|
|||
define OneBalance : fallback para.onebalance 0
|
||||
|
||||
# derived metrics
|
||||
define MONOSPACE : para.diversityM == 1 && para.diversityF == 1 && para.diversityI == 1 && para.diversityII == 1
|
||||
define WideWidth0 : if MONOSPACE (Width * 2) UPM
|
||||
define WideWidth0 : if (para.quasiProportionalDiversity === 0) (Width * 2) UPM
|
||||
define WideWidth1 : if (para.spacing >= 1) WideWidth0 Width
|
||||
define WideWidth2 : if (para.spacing >= 2) WideWidth0 Width
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ export : define [assignFontNames para metrics font] : begin
|
|||
if (minorVersion > 99 || patchVersion > 9) : throw : new Error "Version number overflow"
|
||||
set font.head.fontRevision : majorVersion + (minorVersion * 10 + patchVersion) / 1000
|
||||
|
||||
if (para.diversityM == 1 && para.diversityF == 1 && para.diversityI == 1 && para.diversityII == 1) : begin
|
||||
if (para.quasiProportionalDiversity === 0) : begin
|
||||
set font.OS_2.panose.bProportion 9 # Monospaced
|
||||
set font.post.isFixedPitch true
|
||||
: else : begin
|
||||
|
|
|
@ -13,6 +13,7 @@ function initPara(data, argv) {
|
|||
apply(para, data, ["shapeWidth"], { shapeWidth: argv.shape.width });
|
||||
apply(para, data, [`s-${argv.shape.slope}`]);
|
||||
apply(para, data, [`diversity-${argv.shape.quasiProportionalDiversity}`]);
|
||||
para.quasiProportionalDiversity = argv.shape.quasiProportionalDiversity || 0;
|
||||
if (argv.featureControl.noCvSs) para.enableCvSs = false;
|
||||
if (argv.featureControl.noLigation) para.enableLigation = false;
|
||||
return para;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue