Sort multiple-mapping sequentially in FontLab

Ray LarabieRay Larabie Posts: 978
edited October 2019 in Type Design Software
When I generate multiple-mapped glyphs in FontLab Studio 5, the order of the Unicode assignments can't be controlled *. For example I have an A that I want mapped to 0041 0391 0410 (A, Alpha, Cyrillic A) but FontLab generates a glyph mapped to 0410 0041 0391. This has no effect on the function of the font but when I sort the index by Unicode it results in a messy index table. FontLab only "sees" the first Unicode value when it chooses the index sorting order. I tried sorting the index by Unicode in FontLab IV and got the same result.

I think I need to fix the order of the multiple mapping for each glyph so I can get FontLab to sort the index neatly. Also, I'd like the order of the multimaps to be sequential for the sake of tidiness.  Otherwise, to anyone looking an Adobe glyph panel, Windows Character Map or the glyphs list on MyFonts, it looks like the A is missing from the alphabet and there's a general scrambled appearance.

Is there a tool that can order the Unicode multimaps sequentially? Ideally it would change my A from 0410 0041 0391 to 0041 0391 0410 so sorting the index table by Unicode won't result in chaos.

* Changing the order in the name table when generating has no effect. FontLab does whatever it wants with the order and it's seemingly random. And I need to process a few hundred fonts this way so I'd like to automate the process.


  • Agree 100%.

    Just to clarify, having a custom encoding (.enc file) just changes the view order in FontLab, when that encoding is invoked. If you want that glyph order baked into the font (changing the Glyph IDs), go to the menu and choose Glyph > Sort Glyphs > By Encoding.
  • Thank you. Yes, sorting by a custom encoding file makes a whole lot of sense; I'll go with that.
  • @Ray Larabie: Thanks for posting the question, it’s useful to know how to deal with arranging glyph order for design applications.

    @Thomas Phinney: Do you know from where you can open .enc files in the Fontlab VI interface? I can’t seem to find it. :-(
  • @""Claudio Piccinini"

    The default location of the FontLab VI encodings folder is:
    • macOS: "Macintosh HD/Users/Your_Name/Library/Application Support/FontLab/FontLab VI/Encoding/"
    • Windows: "C:\Users\Your_Name\AppData\Roaming\Fontlab\FontLab VI\Encoding"

    You can change the location in Preferences > General in FontLab VI.

    For more info on this and other custom data files for FontLab VI, see

    (Cribbed from my own writing at:
  • Mark SimonsonMark Simonson Posts: 1,209
    edited November 2019
    An easy way to make custom encodings is to rearrange glyphs in the Index view and then save as a custom encoding (Glyph > Glyph Names > Save Encoding). After you save it, you can open it and change the name of the encoding on the first line if you want. (This is the name that appears in the list of encodings to select.)
  • Mark’s suggestion works for FontLab Studio 5, but this feature has not (as yet) been implemented in FontLab VI.
  • Jameson R SpiresJameson R Spires Posts: 18
    edited November 2019
    FLS 5?

    from FL import fl

  • Mark’s suggestion works for FontLab Studio 5, but this feature has not (as yet) been implemented in FontLab VI.
    Yes, I couldn’t find it – that’s why I was asking.
    Thanks for the folder location, but the folder is empty and I can’t seem able to open older .enc files which were in the Fontlab Studio 5 application support folder.
    Also, if you want to export an .enc file in Fontlab VI how can you do?

  • Thanks for the folder location, but the folder is empty and I can’t seem able to open older .enc files which were in the Fontlab Studio 5 application support folder.
    Open them how? Why?

    They do not need to be “opened” to work. Just to be in a location FontLab VI knows about.

    If you do want to change the contents, they are just text files. You can use any plain text editor to open and edit them, such as NotePad on Windows, BBEdit or TextWrangler on Mac.

    But if you want to use an older .enc file, either:
    • just copy it to the new Fontlab VI location as discussed above:
      • macOS: "Macintosh HD/Users/Your_Name/Library/Application Support/FontLab/FontLab VI/Encoding/"
      • Windows: "C:\Users\Your_Name\AppData\Roaming\Fontlab\FontLab VI\Encoding"
    • Or go to Preferences > General and change the location of the "User data folder" to wherever you like ... which could be the old FontLab Studio 5 location if you like. 

    Also, if you want to export an .enc file in Fontlab VI how can you do?
    I see Jameson Spires shared a script above. I *think* his "FLS 5?" comment means it is an FLS 5 script, though.

    I expect it could still be scripted in VI, to export the current view order, and/or the current GID order, as an encoding. Somebody like @Vassil Kateliev could probably do so.

  • Just in case anyone is unclear how to save and load index encoding in FLS 5, here are the steps.
    1. Switch to index mode an arrange the glyphs however you like them
    2. Glyph/Glyph Names/Save Encoding
    3. Switch to Names mode 
    4. Click the dropdown beside the names mode button and go all the way to the bottom. You'll see the name of your font there
    5. Glyphs/Sort Glyphs/By Encoding
    6. Switch to index mode to confirm that sorting worked correctly
    If you want to change the name of the encoding, locate and edit the .enc file in Notepad etc.'ll see the name on the first line. Save then restart FontLab.

    If By Encoding is grayed out, you're probably in the wrong mode. This only works in Names mode.
  • Be sure to also change the number of the encoding.
  • @Thomas Phinney is the number there to determine sort order in the encoding dropdown?
  • No, it is a unique ID of sorts, that FontLab uses internally. Supposedly having a collision would be bad. I always change the ID for new versions; but perhaps it only is an issue if you have two active .enc files with the same number? @Adam Twardoch ?

  • Alex PetrovAlex Petrov Posts: 4
    edited November 2019
    Here is the simple script which exports the current glyph index order as an encoding:
    #FLM: Save encoding
    import os
    import fontlab
    if f == None:
    import sys
    sys.stdout = open(os.path.expanduser('~')+"/Desktop/my_new_enc.enc", "w")
    glyphs = f.glyphs
    print "%%FONTLAB ENCODING: 21000888; My New Encoding"
    for index in range(len(f.glyphs)):
       print f.glyphs[index].name, index
    Works in FontLab VI.
    After the export, you will only need to change the encoding ID (21000888) and the encoding file name.
  • Sticking with FL 5 so far, I can say I live rather well with custom encodings in the work process. As a matter of fact, when I work on a font, I have it displayed in the [encoding] mode with one of my own encodings, most of the time.
    The big advantage is that I can order all my glyphs according to design aspects, e.g. to group all figures, all currencies, all lc accents, to place eth besides dcroat (just to monitor how they match); to bring special ch.s such as mathematical operators, strokes and dashes in one row to see if they fit along together, and so on.
    I edit my encodings entirely in Textedit. When saving, one has to ensure that it is plain text, the right encoding (of that text file, I think it was UTF-8) and to give it the .enc suffix. And to follow the header syntax with a unique number, of course (as has been mentioned already).
  • Ugh! I need to wrap my head around this to work better…
Sign In or Register to comment.