adobe-fonts / source-code-pro

Monospaced font family for user interface and coding environments
https://adobe-fonts.github.io/source-code-pro/
SIL Open Font License 1.1
19.85k stars 1.62k forks source link

error using ttx with variable font #258

Closed zePanzerfaust closed 3 years ago

zePanzerfaust commented 3 years ago

Hello,

I downloaded VAR-source-code-var-1.012 to make changes as discussed in

This used to work but now ttx gives me an error ERROR: Unknown file type: "SourceCodeVariable-Italic.otf" when executing ttx -t cmap SourceCodeVariable-Italic.otf or just ttx SourceCodeVariable-Italic.otf

ttx --version 4.18.2

The OTF and TTF versions worked fine.

Now the question is, should it work? If not, is there an alternative?

zePanzerfaust commented 3 years ago

The problem that lead to the issue, was that the merge of the font failed. This corrupted the file and therefore ttx no longer recognizes it. The reason it failed in the first place are the missing alternative glyphs, at least with the same name.

After opening the variable TTF font with FontForge it showed asterisk.ss01 as alternate glyph for the asterisk. But after using this I still got KeyError: 'asterisk.ss01' when merging with ttx. The variable OTF version could not be opened with FontForge, so I don't know what's in there.

For the OTF and TTF versions I used asterisk.a, which works fine.

punchcutter commented 3 years ago

@zePanzerfaust The alternate asterisk glyph in the variable OTF is named glyph00705 so if you replace asterisk with that in the dumped cmap and then merge with ttx -m SourceCodeVariable-Italic.otf SourceCodeVariable-Italic.ttx (or whatever the name of the dumped ttx file is) then it should work. I tried it here and it worked for me. If you have a problem like mentioned above ERROR: Unknown file type: "SourceCodeVariable-Italic.otf" then that means there's something wrong with the font so you should download it again from here and try again.

zePanzerfaust commented 3 years ago

This replaces the asterisk by the tilde or official Unicde name "Greek Perispomeni"? By generating the complete ttx output an entry <GlyphID id="705" name="uni1FC0"/> can be found. So the mentioned glyph00705 references uni1FC0, which I assume is the Unicode hex value of "Greek Perispomeni"? That's just my assumption and it seems to make sense. Now my question would be, what is the alternative asterisk name and how to find it? Do you use a visual tool to look them up? For this I dumped the Roman version of the font.

zePanzerfaust commented 3 years ago

Thank you! This pointed me in the right direction. Dumping the whole font file with ttx and searching for asterisk gives several matches. The ones in the cmap and then there is

        <!-- SubTableCount=1 -->
        <SingleSubst index="0" Format="1">
          <Substitution in="asterisk" out="glyph01001"/>
        </SingleSubst>

which is the alternative version I was looking for. Then following what you said, replacing asterisk with glyph01001 in the cmap and merging the font.

zePanzerfaust commented 3 years ago

Beware that the glyph ID in the Roman and Italic versions are not the same! In case of the asterisk it is the following. Roman: glyph01001 Italic: glyph00705