Python Forum
Add DSIG to TTF font using ttx font tool
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Add DSIG to TTF font using ttx font tool
#1
I am using Adobe's Font Developer Kit (FDK) ttx tool to add a Digital Signature to a TrueType font. I have a routine which I've used successfully before, but it is now misbehaving. Code complies but I'm getting 'Zero bytes' as a file size.

I can post the step by step routine I use and also a the resulting Mac OS Terminal code if anyone can shed light on my problem Confused

Thanks,
Adrian
Reply
#2
Quote:As I have had many views but no replies, here is the step-by-step routine I'm using followed by the Mac OS Terminal output. Yes there are better, quicker ways to do this but I'm just trying to keep it simple to get it working for now!

1. Launch Terminal.

2. Command N for new session.

3. Enter:
which ttx
Return

A path ending in ttx mans good to go.

4. Paste this snippett…

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
open .

Enter return

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:

5. Drag TTX app to Terminal (since it accepted your Dsig fldr snippet) result:
/Users/adrianshome/Downloads/fonttools-2.4/Tools/ttx

6. Type: -m (not forgetting a space after the m).

7. Drag the ttf font file to terminal (say SassoonSansUSLine.ttf) result:
/Users/adrianshome/Desktop/Dsig\ fldr/SassoonSansUSLine.ttf

First remove all of the dsig#.ttf files in the Dsig fldr if there are any.
Then for each font file:


8. Drag dsig.ttx to terminal result:
/Users/adrianshome/Desktop/Dsig\ fldr/SassoonSansUSLine.ttf /Users/adrianshome/Desktop/Dsig\ fldr/dsig.ttx

9. 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…

10. Rename dsig.ttf as SassoonSansUSLine.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.

NOTE
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.


Last login: Sat Nov 11 11:47:38 on ttys002
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 /Users/adrianshome/Desktop/Dsig\ fldr/SassoonSansUSLine.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/FontTools/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/FontTools/fontTools/ttLib/__init__.py", line 629, in _writeTable
tabledata = self.getTableData(tag)
File "/Applications/FDK/Tools/osx/Python/Current/lib/python2.7/site-packages/FontTools/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/FontTools/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/FontTools/fontTools/misc/sstruct.py", line 68, in pack
value = obj[name]
KeyError: 'ulVersion'
Adrians-iMac:Dsig fldr adrianshome$
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python code for alignment and font size 1418 0 310 Jan-14-2024, 03:56 AM
Last Post: 1418
  Change font in a list or tuple apffal 4 2,670 Jun-16-2023, 02:55 AM
Last Post: schriftartenio
  can openpyxl read font colors mperemsky 3 1,732 May-09-2023, 11:18 AM
Last Post: MindKeeper
  Comparing two columns with same value but different font format doug2019 1 714 Jan-08-2023, 02:58 PM
Last Post: Larz60+
  Folium: Conflict with Font Awesome Kit jgomes_eu 0 1,214 Apr-23-2022, 03:18 PM
Last Post: jgomes_eu
  Print text with big font and style tomtom 5 14,027 Mar-03-2022, 01:29 AM
Last Post: tomtom
  how to change the font style on Linux? laylalogan337 2 1,933 Aug-10-2021, 04:31 PM
Last Post: deanhystad
  fpdf adding a new font to my report KatMac 0 2,163 Apr-23-2021, 02:19 PM
Last Post: KatMac
  Load external font and does not show font in the window ATARI_LIVE 16 8,139 Feb-05-2021, 10:36 PM
Last Post: EthanPayne
  Tkinter font style ATARI_LIVE 2 1,855 Oct-24-2020, 08:22 PM
Last Post: ATARI_LIVE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020