Change embedding setting

DotlessHyphen's picture

How can I change the embedding setting of a TTF or OTF without opening each font with FL?
I recall there was a tool few years ago that could change the setting in a batch of files.

TIA

hrant's picture

Why would you want to do that?

hhp

DotlessHyphen's picture

Old fonts with Only printing ot editing restriction - need to change.

hrant's picture

I would ask the font publishers if that would be ethical and legal.

hhp

DotlessHyphen's picture

We are the publisher so this isn't an issue at all :-)

hrant's picture

Oh, you just want to save time over using FL - I get it. Must be a lot of fonts!

hhp

Michel Boyer's picture

Is it ok to give a script online? It is just a few lines of python with AFDKOPython installed (last version of AFDKO).

Michel Boyer's picture

On the mac, to change to 0x0008 the value of fsType of all otf and ttf files in the current directory and subdirectories, all you need to do is to type in the terminal window

find . -iname "*.[to]tf" -exec chngfs {} 0x0008 \;

provided the call chngfs fontfile 0x0008 changes the fsType of fontfile to 0x0008. The following code for chngfs does it if AFDKO 2.5 for Mac is installed:

#!/usr/bin/env AFDKOPython

import sys, os
from fontTools.ttLib import TTFont

f=TTFont(sys.argv[1])
f["OS/2"].fsType=int(sys.argv[2],16)
if len(sys.argv) == 4:
  f.save(sys.argv[3])
else:
  f.save("tmpfil")
  os.rename("tmpfil",sys.argv[1])

provided chngfs is made executable and put in your path.

As for Windows, the Python 2.7 documentation says it is not possible to rename with os.rename a file to a file name that is already in use. That is why chngfs above was written to take an additional, optional, argument. If AFDKOPython is made available at the command line on Windows then the command

AFDKOPython chngfs fontname.ttf 0x0008 newname.ttf

produces a new font with the chosen fsType (works the same on the mac).

You can also call chngfs with 0x0002 and 0x0004, 0x0008 as well as 0x0000 and variations 0x01?? and 0x02??; cf http://www.microsoft.com/typography/otspec/os2.htm#fst.

Michel

HVB's picture

There is a small PC command line program named 'embed' that does what you're looking for, very simply. Unfortunately it's not compatible with more recent versions of Windows such as Windows 7. I'm not sure whether the Windows 7 Professional's compatibility mode would solve the problem.

HVB's picture

hrant: At one time there was a bug in Fontographer that defaulted ALL fonts to 'no embedding'. If the font creator even knew about it, finding the fsType entry to set the bits properly wasn't clear either. That's why there are thousands of older fonts that routinely need this fix.
- Herb

Michel Boyer's picture

If there is no tool to give you simply the fsType of your files, here is a script that does it

#!/bin/sh
AFDKOPython <<EOF
from fontTools.ttLib import TTFont

f=TTFont("$1")
try:
  print "%s; 0x%04x" % ("$1", f["OS/2"].fsType)
except:
  print "%s; fsType not found" % ("$1")
EOF

If you call it fstype, make it executable and put it in a directory that is in your path on the Mac then

find . -iname "*.[ot]tf" -exec fstype {} \;

will list all ttf and otf files if the current directory and subdirectories with their fsType. I guess that should also work with Cygwin on Windows but I have no way to check.

Syndicate content Syndicate content