Batch Processing

oldnick's picture

I am currently considering the idea of cross-branding distribution opportunities with several manufacturers with whom I have OEM deals. As envisioned, I would offer several thematic packages, as well as my entire collection, as add-ons to their product lines.

The fonts in the original OEM packages have customized copyright agreements, identifying the manufacturers as licensed distributors, and also include the manufacturer's logo as a glyph within the fonts included. Ideally, I would like to be able to include the same things in the co-branded fonts. And, ideally, I would like to automate the procedure, since I'm looking at approximately 600-650 fonts in each of several packages.

I imagine that inserting the glyph isn't a problem, if the slot already exists in the source font (no change in the GlyphIndex required), but I wonder about two other, slightly more complicated, changes. The first is the copyright DATE, which varies according to the creation date of the font; the second is the version number, which I would like to uptick one notch in all cases.

Off-the-shelf doable? Custom scripting doable? Just a pipe dream?

Wiewauters's picture

If you have a problem and nobody else can solve it … maybe better call the A-team … or one of these guys to work their magic:
http://kltf.de/kltf_catalog.shtml
http://www.typemytype.com/
http://talleming.com/

fontsquirrel's picture

This is very doable and not that complicated. I might be able to help you...

Ray Larabie's picture

I once had to customize the font copyright message on around 2 kilofonts. I need it done in two days and I didn't have time to get into scripting. On a spare laptop I installed Fontlab and a task automator.

http://www.spacetornado.com/DoItAgain/

It actually plays Steely Dan "Do it again" when you start it up.

I arranged the windows, rehearsed, recorded the sequence, speed it up and let it rip. It's inelegant but it got the job done by morning. Which is good because I made a typo and had to start all over again.

. . . and just be careful not to bump the mouse.

Ray Larabie's picture

To edit the copyright date, part of the process would cut and paste the line into a text editor and do a search & replace then copy & paste it back into the font.

This type of processing takes much longer to run than a script. Maybe take in a matinee.

oldnick's picture

Thanks for the input, Ray. The Macro solution might solve part of the problem for OTF fonts—but possibly not for TTF fonts—generated by FontLab. I have noticed FontLab's annoying tendency of unchecking the "Copy values to TrueType metrics" box under Most important font dimensions, thus screwing up the TTF metrics (according to FontValidator), and also failing to generate the GASP table unless you tab to its page each time you generate a TTF font. Different flavor, different macro I suppose...

Jeremy Dooley's picture

I use WinAutomation. http://www.winautomation.com/ It does the job well enough, but not as great as a program I used to use (that is no longer available). You could even include a conditional routine to check that TTF box.

Té Rowan's picture

If you have a Unix/Linux/OS-X machine, you can very likely script FontForge to do the job, either on its own or assisted by system software. Ware, FF drops tables it doesn't understand on the floor.

Michel Boyer's picture

In my opinion, ttx is much more likely to leave the font intact than fontforge. I'd first try using ttx and an xml parser, to keep things simple (that requires a font that is properly restored if you apply ttx once to get the .ttx file, and then ttx on the resulting .ttx file). If you simply want to replace strings, it is then quite simple. Here is an example (tested with the macport python26 @2.6.7_1+ucs4 on OS X 10.5 and 10.6). First run ttx -i on filename.ttf or filename.otf. Then run python substs.py filename.ttx where substs.py is a file containing

# -*- coding: utf-8 -*-
from xml.etree.ElementTree import ElementTree
import sys

tree=ElementTree()
tree.parse(sys.argv[1])

p=tree.find("name")
for r in p.findall('namerecord'):
  id=int(r.get('nameID'))
  if   id == 0:
    r.text="Copyright © 1642-2011".decode('utf-8')
  elif id == 5:
    r.text="Version 299.z"
tree.write("tmpout.xml")

(mutatis mutandis). You then add to the file tmpout.xml the following first line

<?xml version="1.0" encoding="ISO-8859-1"?>

rename the resulting file fontname.ttx and then run ttx on it to get your new font.

A bash script file that applies ttx, then calls the python script, adds the first line, and finally applies ttx back again is less than 20 lines long.

Arno Enslin's picture

Cool, Michael!

------------------------

Note, that it is not necessary to decompile the whole fonts with TTX, but the name table only (and the cff table, if present and if you also want to replace the copyright info there). The table can be merged into the source fonts with TTX. This is faster and the risk to damage anything is lower.

Michel Boyer's picture

Indeed, with   "ttx -t name"   and in the end   "ttx -m"   I can process a font that can't be processed otherwise. Hmm, I thought I had tried that before without success... Thanks.

Richard Fink's picture

I've never applied it to a task like this, but there is a Windows automation tool - free - called Autoit that works nicely.
http://www.autoitscript.com/site/autoit/

I've used it's dll version - called from within a Windows Script Host file - to read text and input the characters as keystrokes.

Worked great and quite robust.

Syndicate content Syndicate content