Throw error when compat ligature is wider than unit if FC-mono is enforced

This commit is contained in:
be5invis 2020-11-23 17:57:47 -08:00
parent 0031b3362e
commit cfd0c3d741
2 changed files with 6 additions and 3 deletions

View file

@ -53,7 +53,7 @@ define [interpretLookup gs lut lookups] : match lut.type
define [interpretLookupAt gs j lut] : match lut.type define [interpretLookupAt gs j lut] : match lut.type
"gsub_single" : if lut.substitutions.(gs.(j)) : set gs.(j) lut.substitutions.(gs.(j)) "gsub_single" : if lut.substitutions.(gs.(j)) : set gs.(j) lut.substitutions.(gs.(j))
export : define [BuildCompatLigatures glyphStore GSUB GDEF config] : begin export : define [BuildCompatLigatures para glyphStore GSUB GDEF config] : begin
foreach [cldef : items-of config] : do foreach [cldef : items-of config] : do
if [not cldef.unicode] : break nothing if [not cldef.unicode] : break nothing
if [not cldef.featureTag] : break nothing if [not cldef.featureTag] : break nothing
@ -83,6 +83,9 @@ export : define [BuildCompatLigatures glyphStore GSUB GDEF config] : begin
g1.applyTransform : new Transform 1 0 0 1 (g1.advanceWidth) 0 g1.applyTransform : new Transform 1 0 0 1 (g1.advanceWidth) 0
set g1.advanceWidth : g1.advanceWidth + g.advanceWidth set g1.advanceWidth : g1.advanceWidth + g.advanceWidth
if(para.forceMonospace && [Math.round g1.advanceWidth] > [Math.round para.width])
throw : new Error "Compat ligature wider than one unit, conflicts with fontconfig-mono: \[cldef.unicode.toString 16]"
glyphStore.addGlyph g1Name g1 glyphStore.addGlyph g1Name g1
glyphStore.encodeGlyph cldef.unicode g1 glyphStore.encodeGlyph cldef.unicode g1
set GDEF.glyphClassDef.(g1Name) GDEF_LIGATURE set GDEF.glyphClassDef.(g1Name) GDEF_LIGATURE

View file

@ -80,7 +80,7 @@ export : define [buildOtl para glyphStore] : begin
local GSUB : buildGSUB para glyphStore markGlyphs local GSUB : buildGSUB para glyphStore markGlyphs
# Build compatibility ligatures # Build compatibility ligatures
if (para.spacing > 0 && para.compLig) : begin if (para.enableLigation && para.compLig) : begin
BuildCompatLigatures glyphStore GSUB GDEF para.compLig BuildCompatLigatures para glyphStore GSUB GDEF para.compLig
return [object GSUB GPOS GDEF] return [object GSUB GPOS GDEF]