From cfd0c3d7410ec6094e5d7afa0bedb5ab99b4b524 Mon Sep 17 00:00:00 2001 From: be5invis Date: Mon, 23 Nov 2020 17:57:47 -0800 Subject: [PATCH] Throw error when compat ligature is wider than unit if FC-mono is enforced --- font-src/otl/compat-ligature.ptl | 5 ++++- font-src/otl/index.ptl | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/font-src/otl/compat-ligature.ptl b/font-src/otl/compat-ligature.ptl index 04fff076d..aa6ac7d77 100644 --- a/font-src/otl/compat-ligature.ptl +++ b/font-src/otl/compat-ligature.ptl @@ -53,7 +53,7 @@ define [interpretLookup gs lut lookups] : 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)) -export : define [BuildCompatLigatures glyphStore GSUB GDEF config] : begin +export : define [BuildCompatLigatures para glyphStore GSUB GDEF config] : begin foreach [cldef : items-of config] : do if [not cldef.unicode] : 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 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.encodeGlyph cldef.unicode g1 set GDEF.glyphClassDef.(g1Name) GDEF_LIGATURE diff --git a/font-src/otl/index.ptl b/font-src/otl/index.ptl index b3071b805..a4a399741 100644 --- a/font-src/otl/index.ptl +++ b/font-src/otl/index.ptl @@ -80,7 +80,7 @@ export : define [buildOtl para glyphStore] : begin local GSUB : buildGSUB para glyphStore markGlyphs # Build compatibility ligatures - if (para.spacing > 0 && para.compLig) : begin - BuildCompatLigatures glyphStore GSUB GDEF para.compLig + if (para.enableLigation && para.compLig) : begin + BuildCompatLigatures para glyphStore GSUB GDEF para.compLig return [object GSUB GPOS GDEF]