Skip to content

Commit

Permalink
Merge pull request #787 from googlefonts/fix-indesign-no-language-ker…
Browse files Browse the repository at this point in the history
…ning

Add LTR script kerning to DFLT for InDesign default composer
  • Loading branch information
anthrotype committed Oct 19, 2023
2 parents 8a512b8 + d47d973 commit efb4658
Show file tree
Hide file tree
Showing 16 changed files with 257 additions and 19 deletions.
22 changes: 19 additions & 3 deletions Lib/ufo2ft/featureWriters/kernFeatureWriter.py
Expand Up @@ -575,11 +575,27 @@ def _registerLookups(
) -> None:
# Ensure we have kerning for pure common script runs (e.g. ">1")
isKernBlock = feature.name == "kern"
dfltLookups: list[ast.LookupBlock] = []
if isKernBlock and COMMON_SCRIPT in lookups:
dfltLookups.extend(lookups[COMMON_SCRIPT].values())

# InDesign bugfix: register kerning lookups for all LTR scripts under DFLT
# so that the basic composer, without a language selected, will still kern.
# Register LTR lookups if any, otherwise RTL lookups.
if isKernBlock:
lookupsLTR: list[ast.LookupBlock] = []
lookupsRTL: list[ast.LookupBlock] = []
for script, scriptLookups in sorted(lookups.items()):
if script != COMMON_SCRIPT and script not in DIST_ENABLED_SCRIPTS:
if script_horizontal_direction(script, "LTR") == "LTR":
lookupsLTR.extend(scriptLookups.values())
elif script_horizontal_direction(script, "LTR") == "RTL":
lookupsRTL.extend(scriptLookups.values())
dfltLookups.extend(lookupsLTR or lookupsRTL)

if dfltLookups:
languages = feaLanguagesByScript.get("DFLT", ["dflt"])
ast.addLookupReferences(
feature, lookups[COMMON_SCRIPT].values(), "DFLT", languages
)
ast.addLookupReferences(feature, dfltLookups, "DFLT", languages)

# Feature blocks use script tags to distinguish what to run for a
# Unicode script.
Expand Down
13 changes: 12 additions & 1 deletion tests/data/TestFont-CFF-compreffor.ttx
Expand Up @@ -390,8 +390,19 @@
<GPOS>
<Version value="0x00010000"/>
<ScriptList>
<!-- ScriptCount=1 -->
<!-- ScriptCount=2 -->
<ScriptRecord index="0">
<ScriptTag value="DFLT"/>
<Script>
<DefaultLangSys>
<ReqFeatureIndex value="65535"/>
<!-- FeatureCount=1 -->
<FeatureIndex index="0" value="0"/>
</DefaultLangSys>
<!-- LangSysCount=0 -->
</Script>
</ScriptRecord>
<ScriptRecord index="1">
<ScriptTag value="latn"/>
<Script>
<DefaultLangSys>
Expand Down
13 changes: 12 additions & 1 deletion tests/data/TestFont-CFF.ttx
Expand Up @@ -406,8 +406,19 @@
<GPOS>
<Version value="0x00010000"/>
<ScriptList>
<!-- ScriptCount=1 -->
<!-- ScriptCount=2 -->
<ScriptRecord index="0">
<ScriptTag value="DFLT"/>
<Script>
<DefaultLangSys>
<ReqFeatureIndex value="65535"/>
<!-- FeatureCount=1 -->
<FeatureIndex index="0" value="0"/>
</DefaultLangSys>
<!-- LangSysCount=0 -->
</Script>
</ScriptRecord>
<ScriptRecord index="1">
<ScriptTag value="latn"/>
<Script>
<DefaultLangSys>
Expand Down
13 changes: 12 additions & 1 deletion tests/data/TestFont-CFF2-cffsubr.ttx
Expand Up @@ -412,8 +412,19 @@
<GPOS>
<Version value="0x00010000"/>
<ScriptList>
<!-- ScriptCount=1 -->
<!-- ScriptCount=2 -->
<ScriptRecord index="0">
<ScriptTag value="DFLT"/>
<Script>
<DefaultLangSys>
<ReqFeatureIndex value="65535"/>
<!-- FeatureCount=1 -->
<FeatureIndex index="0" value="0"/>
</DefaultLangSys>
<!-- LangSysCount=0 -->
</Script>
</ScriptRecord>
<ScriptRecord index="1">
<ScriptTag value="latn"/>
<Script>
<DefaultLangSys>
Expand Down
13 changes: 12 additions & 1 deletion tests/data/TestFont-CFF2-post3.ttx
Expand Up @@ -387,8 +387,19 @@
<GPOS>
<Version value="0x00010000"/>
<ScriptList>
<!-- ScriptCount=1 -->
<!-- ScriptCount=2 -->
<ScriptRecord index="0">
<ScriptTag value="DFLT"/>
<Script>
<DefaultLangSys>
<ReqFeatureIndex value="65535"/>
<!-- FeatureCount=1 -->
<FeatureIndex index="0" value="0"/>
</DefaultLangSys>
<!-- LangSysCount=0 -->
</Script>
</ScriptRecord>
<ScriptRecord index="1">
<ScriptTag value="latn"/>
<Script>
<DefaultLangSys>
Expand Down
13 changes: 12 additions & 1 deletion tests/data/TestFont-NoOptimize-CFF.ttx
Expand Up @@ -409,8 +409,19 @@
<GPOS>
<Version value="0x00010000"/>
<ScriptList>
<!-- ScriptCount=1 -->
<!-- ScriptCount=2 -->
<ScriptRecord index="0">
<ScriptTag value="DFLT"/>
<Script>
<DefaultLangSys>
<ReqFeatureIndex value="65535"/>
<!-- FeatureCount=1 -->
<FeatureIndex index="0" value="0"/>
</DefaultLangSys>
<!-- LangSysCount=0 -->
</Script>
</ScriptRecord>
<ScriptRecord index="1">
<ScriptTag value="latn"/>
<Script>
<DefaultLangSys>
Expand Down
13 changes: 12 additions & 1 deletion tests/data/TestFont-NoOptimize-CFF2.ttx
Expand Up @@ -421,8 +421,19 @@
<GPOS>
<Version value="0x00010000"/>
<ScriptList>
<!-- ScriptCount=1 -->
<!-- ScriptCount=2 -->
<ScriptRecord index="0">
<ScriptTag value="DFLT"/>
<Script>
<DefaultLangSys>
<ReqFeatureIndex value="65535"/>
<!-- FeatureCount=1 -->
<FeatureIndex index="0" value="0"/>
</DefaultLangSys>
<!-- LangSysCount=0 -->
</Script>
</ScriptRecord>
<ScriptRecord index="1">
<ScriptTag value="latn"/>
<Script>
<DefaultLangSys>
Expand Down
13 changes: 12 additions & 1 deletion tests/data/TestFont-NoOverlaps-CFF-pathops.ttx
Expand Up @@ -401,8 +401,19 @@
<GPOS>
<Version value="0x00010000"/>
<ScriptList>
<!-- ScriptCount=1 -->
<!-- ScriptCount=2 -->
<ScriptRecord index="0">
<ScriptTag value="DFLT"/>
<Script>
<DefaultLangSys>
<ReqFeatureIndex value="65535"/>
<!-- FeatureCount=1 -->
<FeatureIndex index="0" value="0"/>
</DefaultLangSys>
<!-- LangSysCount=0 -->
</Script>
</ScriptRecord>
<ScriptRecord index="1">
<ScriptTag value="latn"/>
<Script>
<DefaultLangSys>
Expand Down
13 changes: 12 additions & 1 deletion tests/data/TestFont-NoOverlaps-CFF.ttx
Expand Up @@ -398,8 +398,19 @@
<GPOS>
<Version value="0x00010000"/>
<ScriptList>
<!-- ScriptCount=1 -->
<!-- ScriptCount=2 -->
<ScriptRecord index="0">
<ScriptTag value="DFLT"/>
<Script>
<DefaultLangSys>
<ReqFeatureIndex value="65535"/>
<!-- FeatureCount=1 -->
<FeatureIndex index="0" value="0"/>
</DefaultLangSys>
<!-- LangSysCount=0 -->
</Script>
</ScriptRecord>
<ScriptRecord index="1">
<ScriptTag value="latn"/>
<Script>
<DefaultLangSys>
Expand Down
13 changes: 12 additions & 1 deletion tests/data/TestFont-NoOverlaps-TTF-pathops.ttx
Expand Up @@ -485,8 +485,19 @@
<GPOS>
<Version value="0x00010000"/>
<ScriptList>
<!-- ScriptCount=1 -->
<!-- ScriptCount=2 -->
<ScriptRecord index="0">
<ScriptTag value="DFLT"/>
<Script>
<DefaultLangSys>
<ReqFeatureIndex value="65535"/>
<!-- FeatureCount=1 -->
<FeatureIndex index="0" value="0"/>
</DefaultLangSys>
<!-- LangSysCount=0 -->
</Script>
</ScriptRecord>
<ScriptRecord index="1">
<ScriptTag value="latn"/>
<Script>
<DefaultLangSys>
Expand Down
13 changes: 12 additions & 1 deletion tests/data/TestFont-NoOverlaps-TTF.ttx
Expand Up @@ -485,8 +485,19 @@
<GPOS>
<Version value="0x00010000"/>
<ScriptList>
<!-- ScriptCount=1 -->
<!-- ScriptCount=2 -->
<ScriptRecord index="0">
<ScriptTag value="DFLT"/>
<Script>
<DefaultLangSys>
<ReqFeatureIndex value="65535"/>
<!-- FeatureCount=1 -->
<FeatureIndex index="0" value="0"/>
</DefaultLangSys>
<!-- LangSysCount=0 -->
</Script>
</ScriptRecord>
<ScriptRecord index="1">
<ScriptTag value="latn"/>
<Script>
<DefaultLangSys>
Expand Down
13 changes: 12 additions & 1 deletion tests/data/TestFont-Specialized-CFF.ttx
Expand Up @@ -387,8 +387,19 @@
<GPOS>
<Version value="0x00010000"/>
<ScriptList>
<!-- ScriptCount=1 -->
<!-- ScriptCount=2 -->
<ScriptRecord index="0">
<ScriptTag value="DFLT"/>
<Script>
<DefaultLangSys>
<ReqFeatureIndex value="65535"/>
<!-- FeatureCount=1 -->
<FeatureIndex index="0" value="0"/>
</DefaultLangSys>
<!-- LangSysCount=0 -->
</Script>
</ScriptRecord>
<ScriptRecord index="1">
<ScriptTag value="latn"/>
<Script>
<DefaultLangSys>
Expand Down
13 changes: 12 additions & 1 deletion tests/data/TestFont-Specialized-CFF2.ttx
Expand Up @@ -399,8 +399,19 @@
<GPOS>
<Version value="0x00010000"/>
<ScriptList>
<!-- ScriptCount=1 -->
<!-- ScriptCount=2 -->
<ScriptRecord index="0">
<ScriptTag value="DFLT"/>
<Script>
<DefaultLangSys>
<ReqFeatureIndex value="65535"/>
<!-- FeatureCount=1 -->
<FeatureIndex index="0" value="0"/>
</DefaultLangSys>
<!-- LangSysCount=0 -->
</Script>
</ScriptRecord>
<ScriptRecord index="1">
<ScriptTag value="latn"/>
<Script>
<DefaultLangSys>
Expand Down
13 changes: 12 additions & 1 deletion tests/data/TestFont-TTF-post3.ttx
Expand Up @@ -458,8 +458,19 @@
<GPOS>
<Version value="0x00010000"/>
<ScriptList>
<!-- ScriptCount=1 -->
<!-- ScriptCount=2 -->
<ScriptRecord index="0">
<ScriptTag value="DFLT"/>
<Script>
<DefaultLangSys>
<ReqFeatureIndex value="65535"/>
<!-- FeatureCount=1 -->
<FeatureIndex index="0" value="0"/>
</DefaultLangSys>
<!-- LangSysCount=0 -->
</Script>
</ScriptRecord>
<ScriptRecord index="1">
<ScriptTag value="latn"/>
<Script>
<DefaultLangSys>
Expand Down
13 changes: 12 additions & 1 deletion tests/data/TestFont.ttx
Expand Up @@ -483,8 +483,19 @@
<GPOS>
<Version value="0x00010000"/>
<ScriptList>
<!-- ScriptCount=1 -->
<!-- ScriptCount=2 -->
<ScriptRecord index="0">
<ScriptTag value="DFLT"/>
<Script>
<DefaultLangSys>
<ReqFeatureIndex value="65535"/>
<!-- FeatureCount=1 -->
<FeatureIndex index="0" value="0"/>
</DefaultLangSys>
<!-- LangSysCount=0 -->
</Script>
</ScriptRecord>
<ScriptRecord index="1">
<ScriptTag value="latn"/>
<Script>
<DefaultLangSys>
Expand Down

0 comments on commit efb4658

Please sign in to comment.