2

I'm a font developer. I want to merge a DSIG code into a TrueType format (TTF) font, which makes it compatible with Microsofts applications that use OpenType features. I have had this working before but have now can only produce a zero bytes font.ttf file. I'm using Adobe Font development Kit (AFDKO). as prescribed along with Terminal to make the merge. I would appreciate knowing why I get a zero bytes file?

Here is my step-by-step method, followed by the resulting Terminal window code.

  1. Launch a new Terminal session and enter

    which ttx
    

    A path ending in ttx means good to go.

  2. Paste this snippet…

    FLDR="${HOME}/Desktop/Dsig fldr"
    mkdir -p "$FLDR"
    cd "$FLDR"
    cat > dsig.ttx<<EOF
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="2.4">
    <DSIG>
    <hexdata>
    00000001 00000000
    </hexdata>
    </DSIG>
    </ttFont>
    EOF
    

    then after entering the return key:

    open .
    

This creates a new Folder on the Desktop entitled ‘Dsig fldr’. Inside will be a newly created file entitled ‘dsig.ttx’ for use with this routine:

  1. Drag TTX app to Terminal (since it accepted your Dsig fldr snippet):

    /Users/adrianshome/Downloads/fonttools-2.4/Tools/ttx
    
  2. Type: -m (not forgetting a space after the m).

    /Users/adrianshome/Desktop/Dsig\ fldr/SassoBooIta.ttf /Users/adrianshome/Desktop/Dsig\ fldr/dsig.ttx
    

First remove all of the dsig#.ttf files in the Dsig fldr if there are any.

Then for each font file:

  1. Drag the ttf font file to terminal (say SassoBoo.ttf)
  2. Drag dsig.ttx to terminal and hit return

That will compile only dsig.ttx, merge the DSIG into SassoBoo.ttf and produce a file named dsig.ttf in the Dsig fldr, so now…

  1. Rename dsig.ttf as SassoBoo something.ttf (the original TrueType filename)

There are much better ways to proceed using scripts.

Don't switch steps 3 and 4. You need to put the .ttf file before the .ttx file.

Notes: dsig.ttx and all your .ttf files must reside in the Dsig fldr Folder. TTX app can live anywhere, since the drag of it inserts the path each time.


Here is the resulting Terminal code:

Last login: Thu Mar 31 11:41:06 on ttys001
Adrians-iMac:~ adrianshome$ which ttx
/Users/adrianshome/bin/FDK/Tools/osx/ttx
Adrians-iMac:~ adrianshome$ FLDR="${HOME}/Desktop/Dsig fldr"
Adrians-iMac:~ adrianshome$ mkdir -p "$FLDR"
Adrians-iMac:~ adrianshome$ cd "$FLDR"
Adrians-iMac:Dsig fldr adrianshome$ cat > dsig.ttx<<EOF
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="2.4">
> <DSIG>
> <hexdata>
> 00000001 00000000
> </hexdata>
> </DSIG>
> </ttFont>
> EOF
Adrians-iMac:Dsig fldr adrianshome$ open .
Adrians-iMac:Dsig fldr adrianshome$ /Applications/FDK/Tools/osx/ttx  -m /Applications/Dsig\ fldr/CUP\ Folder\ alpha/SassPenTra.ttf /Users/adrianshome/Desktop/Dsig\ fldr/dsig.ttx

Compiling "/Users/adrianshome/Desktop/Dsig fldr/dsig.ttx" to "/Users/adrianshome/Desktop/Dsig fldr/dsig.ttf"...
Parsing 'DSIG' table...
Traceback (most recent call last):
File "/Applications/FDK/Tools/osx/../SharedData/FDKScripts/ttx.py", line 329, in <module>
main(sys.argv[1:])
File "/Applications/FDK/Tools/osx/../SharedData/FDKScripts/ttx.py", line 309, in main
process(jobs, options)
File "/Applications/FDK/Tools/osx/../SharedData/FDKScripts/ttx.py", line 294, in process
action(input, output, options)
File "/Applications/FDK/Tools/osx/../SharedData/FDKScripts/ttx.py", line 216, in ttCompile
ttf.save(output)
File "/Applications/FDK/Tools/osx/Python/Current/lib/python2.7/site-packages/FontToo ls/fontTools/ttLib/__init__.py", line 214, in save
self._writeTable(tag, writer, done)
File "/Applications/FDK/Tools/osx/Python/Current/lib/python2.7/site-packages/FontToo ls/fontTools/ttLib/__init__.py", line 629, in _writeTable
tabledata = self.getTableData(tag)
File "/Applications/FDK/Tools/osx/Python/Current/lib/python2.7/site-packages/FontToo ls/fontTools/ttLib/__init__.py", line 642, in getTableData
return self.tables[tag].compile(self)
File "/Applications/FDK/Tools/osx/Python/Current/lib/python2.7/site-packages/FontToo ls/fontTools/ttLib/tables/D_S_I_G_.py", line 60, in compile
packed = sstruct.pack(DSIG_HeaderFormat, self)
File "/Applications/FDK/Tools/osx/Python/Current/lib/python2.7/site-packages/FontToo ls/fontTools/misc/sstruct.py", line 68, in pack
value = obj[name]
KeyError: 'ulVersion'
2
  • I'll try to edit this so the formatting is more clear - you might need to re-enter some of the details if I mess up, though...
    – bmike
    Commented Mar 31, 2016 at 13:50
  • It looks like there were some spaces added and extra line breaks. One thing to try would be to use a text editor to check or re-do the file on the cat step. It looks like you have a sequence of digits then a line break before the file ends. You might try nano for editing that file since it doesn't encode the text and has on-screen help. Also - do you have a working example to check against the one that fails?
    – bmike
    Commented Mar 31, 2016 at 13:56

1 Answer 1

1

It's not the Terminal which creates the zero byte file but a bunch of Python scripts which either don't like your ttf font or the dummy DSIG file. Or the original ttf file already contains a digital signature!

The best you can try is the following:

Dump the copied ttf file (in my example I copied the TrueType font file Andale Mono.ttf to a folder named FontMod on my desktop):

ttx /Users/user/Desktop/FontMod/Andale\ Mono.ttf

Remove or rename the original ttf file in the working folder. Open the resulting ttx file with a decent text editor like TextWrangler, BBEdit or even nano.

If the ttx file doesn't contain a <DSIG>...</DSIG> section simply add the below snippet at the end just in front of the closing </ttFont> tag.

  <DSIG>
    <!-- note that the Digital Signature will be invalid after recompilation! -->
    <tableHeader flag="0x1" numSigs="1" version="1"/>
    <SignatureRecord format="1">
-----BEGIN PKCS7-----
0000000100000000
-----END PKCS7-----
    </SignatureRecord>
  </DSIG>

and save the result.

If the ttx file already contains a DSIG section you may try to replace the PKCS7 part:

  <DSIG>
    <!-- note that the Digital Signature will be invalid after recompilation! -->
    <tableHeader flag="0x1" numSigs="1" version="1"/>
    <SignatureRecord format="1">
-----BEGIN PKCS7-----
MIIllQYJKoZIhvcNAQcCoIIlhjCCJYICAQExCzAJBgUrDgMCGgUAMGEGCisGAQQBgjcCAQSgUzBR
...
tCPnxeRQVRtMEWQXYd27Fkhu/dLhBloN2ti3CGPKPTneEW7TrcwcpUH4yvX9gyzjXQ==
-----END PKCS7-----
    </SignatureRecord>
  </DSIG>

by

  <DSIG>
    <!-- note that the Digital Signature will be invalid after recompilation! -->
    <tableHeader flag="0x1" numSigs="1" version="1"/>
    <SignatureRecord format="1">
-----BEGIN PKCS7-----
0000000100000000
-----END PKCS7-----
    </SignatureRecord>
  </DSIG>

and save the result.

In either case rebuild the font file:

ttx /Users/user/Desktop/FontMod/Andale\ Mono.ttx

If you still need a snippet to create a disg.ttx file use something like that:

...
cat > dsig.ttx<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="3.0">
<DSIG>
<!-- note that the Digital Signature will be invalid after recompilation! -->
<tableHeader flag="0x1" numSigs="1" version="1"/>
<SignatureRecord format="1">
-----BEGIN PKCS7-----
0000000100000000
-----END PKCS7-----
</SignatureRecord>
</DSIG>
</ttFont>
EOF

Please note that the xml encoding and the ttLibVersion probably have to be adapted to the respective versions in the ttf file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .