Export .enc files as .txt?

Max PhillipsMax Phillips Posts: 463
edited August 2012 in Technique and Theory
Is it possible to export the encoding file of a particular vfb as a separate text file, and not as part of a generated font? (I did try to RTFM, by the way, but couldn't find what I needed.) Can you do this in FL, or does it require some other utility? I'd like to capture the glyph complement of a family I'm working on and edit the encoding to put the glyphs in a more sensible order.


  • James PuckettJames Puckett Posts: 1,688
    Select all the glyphs and hit copy. Then paste into a text editor, which will dump all the names with slashes in front of them. Then find/replace all of the slashes with line breaks in Indesign, Textwrangler, etc. After that add a header and you’re done.
  • Dude! Now that's what I call cutting the Gordian Knot. Thanks, James.

    The glyphs won't be numbered, of course. Is it necessary to add a glyph number after each glyph name, as I've seen done? It does make it cumbersome to change the order of the glyphs, since you've then got to redo the numbering as well.
  • Matthew ButterickMatthew Butterick Posts: 143
    edited August 2012
    This Robofab script will save an encoding file to the Mac desktop in with the glyphname and index on each line. Robofab doesn't deal with encodings directly so you have to access the FL encoding object directly, which is called font.naked().encoding. The encoding object is an iterable list of records that have fields called name and unicode.
    import os, robofab.world
    font = robofab.world.CurrentFont()
    encoding_out = []
    for index, encodingRecord in enumerate(font.naked().encoding):
        encoding_out.append("%s %s" % (encodingRecord.name, index))
    encoding_out = "\n".join(encoding_out)
    path = os.path.join(os.path.expanduser("~"), "Desktop", "encoding_out.enc")
    file_object = open(path, 'w') 
  • You can also press the little button in FontLab called "Save Encoding".
  • There ya go!
  • Thanks, Matthew!
  • You can always rearrange the glyphs in Index Mode and then Save the Encoding file. Relaunch FontLab and select the new encoding scheme under Names
  • BTW you can import an encoding like this, where path is the path to the encoding on disk.
    font = robofab.world.CurrentFont()
    Yes, a script is overkill for one font. But I find that Fontlab has a habit of "forgetting" the encoding at inopportune times. So I build this into other scripts that do things that rely on the encoding (e.g., generate a font).
  • @ James M: How do you rearrange glyphs in Index mode? I've never been able to manage it. And where is Save the Encoding File? Or, as Göran calls it, the little button?

  • Mark SimonsonMark Simonson Posts: 1,202
    In Index mode, you can drag the glyphs around and rearrange them. Once you have an ordering you like, choose Glyph > Glyph Names > Save Encoding. (This is only available in Index mode.)
  • Mark SimonsonMark Simonson Posts: 1,202
    By the way, if you want to start with a particular existing encoding before you start rearranging glyphs, switch to Names mode, select the encoding, then choose Glyph > Sort Glyphs > By Encoding. When you go to Index mode, the glyphs will be arranged in this order.
  • Mark speaks the truth
  • The "little button" is here:


    After that you can open up the encoding end edit it, rename to something you like.
  • OK, I was grabbing the glyphs wrong, clicking the on cell instead of the cell header. That's why they didn't move. Now everything's lovely.

    Thanks, Göran, Mark, and James.
  • Mark SimonsonMark Simonson Posts: 1,202
    edited August 2012
    Oh, that button. I was wondering what you meant. I normally have my font windows with the tool bar at the bottom, which provides a slightly wider range of functions and takes up less space. The "save encoding" button is absent with that option.
Sign In or Register to comment.