Sort multiple-mapping sequentially in FontLab
Ray Larabie
Posts: 1,431
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.
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.
Tagged:
0
Comments
-
My recommendation would be to sort by a custom .enc file glyph list, rather than trying to sort by Unicode. That's always the tidiest option for control the GID order.5
-
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.2 -
Thank you. Yes, sorting by a custom encoding file makes a whole lot of sense; I'll go with that.0
-
@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. :-(0 -
@""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 https://help.fontlab.com/fontlab-vi/Custom-data-files-and-locations/
(Cribbed from my own writing at:
https://github.com/tphinney/science-gothic/blob/master/lib/encoding/ReadMe%20encoding.md)
0 -
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.)1
-
Mark’s suggestion works for FontLab Studio 5, but this feature has not (as yet) been implemented in FontLab VI.1
-
FLS 5?
from FL import fl<br><br>for glyph in fl.font.glyphs:<br> if len(glyph.unicodes) > 1:<br> glyph.unicodes = list(sorted(glyph.unicodes))<br> glyph.unicode = glyph.unicodes[0]<br> glyph.modified = 1<br> fl.font.modified = 1<br><br>fl.UpdateFont()<br>
1 -
Thomas Phinney said:Mark’s suggestion works for FontLab Studio 5, but this feature has not (as yet) been implemented in FontLab VI.
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?0 -
Claudio Piccinini said:
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.
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.
Claudio Piccinini said:
Also, if you want to export an .enc file in Fontlab VI how can you do?
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.
0 -
Just in case anyone is unclear how to save and load index encoding in FLS 5, here are the steps.
- Switch to index mode an arrange the glyphs however you like them
- Glyph/Glyph Names/Save Encoding
- Switch to Names mode
- 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
- Glyphs/Sort Glyphs/By Encoding
- Switch to index mode to confirm that sorting worked correctly
If By Encoding is grayed out, you're probably in the wrong mode. This only works in Names mode.0 -
Be sure to also change the number of the encoding.0
-
@Thomas Phinney is the number there to determine sort order in the encoding dropdown?0
-
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 ?
0 -
Here is the simple script which exports the current glyph index order as an encoding:
#FLM: Save encoding import os import fontlab f=fontlab.CurrentFont() if f == None: exit 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.2 -
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).3
-
Ugh! I need to wrap my head around this to work better…0
Categories
- All Categories
- 43 Introductions
- 3.7K Typeface Design
- 798 Font Technology
- 1K Technique and Theory
- 617 Type Business
- 444 Type Design Critiques
- 541 Type Design Software
- 30 Punchcutting
- 136 Lettering and Calligraphy
- 83 Technique and Theory
- 53 Lettering Critiques
- 483 Typography
- 301 History of Typography
- 114 Education
- 68 Resources
- 498 Announcements
- 79 Events
- 105 Job Postings
- 148 Type Releases
- 165 Miscellaneous News
- 269 About TypeDrawers
- 53 TypeDrawers Announcements
- 116 Suggestions and Bug Reports