question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[feaLib] "language dflt;" gets put into DFLT script

See original GitHub issue

foo.fea:

languagesystem latn dflt;

feature liga {
    script latn;
    sub a by x;
} liga;

feature liga {
    script latn;
    language dflt;
    sub b by y;
} liga;
$ shape foo.ttf 'abc'
[x=0+1073|b=1+1255|c=2+975]

What?

    <ScriptList>
      <!-- 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>
            <ReqFeatureIndex value="65535"/>
            <!-- FeatureCount=1 -->
            <FeatureIndex index="0" value="1"/>
          </DefaultLangSys>
          <!-- LangSysCount=0 -->
        </Script>
      </ScriptRecord>
    </ScriptList>
    <FeatureList>
      <!-- FeatureCount=2 -->
      <FeatureRecord index="0">
        <FeatureTag value="liga"/>
        <Feature>
          <!-- LookupCount=1 -->
          <LookupListIndex index="0" value="1"/>
        </Feature>
      </FeatureRecord>
      <FeatureRecord index="1">
        <FeatureTag value="liga"/>
        <Feature>
          <!-- LookupCount=1 -->
          <LookupListIndex index="0" value="0"/>
        </Feature>
      </FeatureRecord>
    </FeatureList>
    <LookupList>
      <!-- LookupCount=2 -->
      <Lookup index="0">
        <LookupType value="1"/>
        <LookupFlag value="0"/>
        <!-- SubTableCount=1 -->
        <SingleSubst index="0">
          <Substitution in="a" out="x"/>
        </SingleSubst>
      </Lookup>
      <Lookup index="1">
        <LookupType value="1"/>
        <LookupFlag value="0"/>
        <!-- SubTableCount=1 -->
        <SingleSubst index="0">
          <Substitution in="b" out="y"/>
        </SingleSubst>
      </Lookup>
    </LookupList>

That’s right, even though we asked for it to go into latn/dflt, it goes into DFLT/dflt! I don’t know if this is a feaLib builder bug, or a bug in the AFDKO spec, but it certainly doesn’t seem right.

(This is significant because ufo2ft feature writers write into <script>/dflt.)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
simoncozenscommented, Feb 2, 2022

Yes, it does. But this is still weird.

0reactions
simoncozenscommented, Feb 3, 2022

Okay, so maybe the problem is more a combination of this:

https://github.com/fonttools/fonttools/blob/31ba5e6b2428b088df6d0db029ac4e7d3d49bcd4/Lib/fontTools/feaLib/builder.py#L1024-L1026

and

https://github.com/fonttools/fonttools/blob/31ba5e6b2428b088df6d0db029ac4e7d3d49bcd4/Lib/fontTools/feaLib/builder.py#L1100-L1100

set_language puts the lookup into (self.script_, language), and self.script_ is set to DFLT if there is no other script statement. There may not be a DFLT script beforehand, but this combination (erroneously) creates one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Source code for fontTools.feaLib.builder
feaLib.variableScalar import VariableScalar from fontTools. ... ScriptCount > 0 or table.FeatureList. ... b.i if script == "DFLT" and language == "dflt" and ...
Read more >
fonttools/builder.py at main - GitHub
A library to manipulate font files from Python. Contribute to fonttools/fonttools development by creating an account on GitHub.
Read more >
Introduction to OpenType Programming
In this chapter, we're going to begin to look at these instructions, how we get them into our font, and how they work;...
Read more >
fonttools [python-library] - Occam :: Details
fontTools is a library for manipulating fonts, written in Python. ... [feaLib] Allow any languages other than dflt under DFLT script (#1278, #1292)....
Read more >
PKG-INFO - platform/external/fonttools - android Git repositories
fontTools is a library for manipulating fonts, written in Python. The ... [feaLib] Allow any languages other than ``dflt`` under ``DFLT`` script.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found