1

I have a font where the glyphs are encoded correctly (they have the right names/match properly with their Unicode code points), but the underlying glyph order (shown when selecting Encoding → Reencode → Glyph Order) is not what I want.

Some of this is important (for instance, glyph 0 must be .notdef for the font to work correctly), and some is just aesthetic — I'd like the rest of the glyphs to be in Unicode order for convenience.

FontForge's "Force Encoding" options will change the Unicode mappings based on the Glyph order. What I'm looking for is the opposite — I want to change the Glyph Order based on the Unicode mapping. Or really, be able to affect the Glyph Order at all, aside from them being set in stone after creation. Is it possible?

2 Answers 2

1

The easiest way I've found is by editing the .sfd file in a text editor.

Each character's definition begins with:

StartChar: <name> Encoding: <slot> <codepoint> <id> Width: <width> ...

e.g:

StartChar: ampersand Encoding: 38 38 9 Width: 719 ...

You can safely change each glyph's slot value to change the visual ordering (and the glyph order when generating a font). Note: make sure that each glyph has a unique number.

(In the sfd file, glyphs are always referenced either by name or by id, so changing the slot won't corrupt ligatures, compound glyphs, etc.)

1
  • It never even occurred to me that it might be a text file format!
    – D0SBoots
    Jul 29, 2023 at 6:47
0

After much frustration and a bit of trial and error, I found that you can swap 2 glyphs by attempting to rename one to an existing glyph.

  1. Open the Glyph Info for the one want to move AND for the one were you want it to go.
  2. Set (copy & paste) the destination's Unicode Char to that of the source (Glyph Name and Unicode Value will automatically update) and click OK.
  3. Fontforge will inform you that no two glyphs can have the same name and encoding, and asks if you want to swap them. Click Yes to complete the swap of the identifiers.
  4. However, this does not copy the glyph its self. Copy/paste the destination glyph to a holding place (add a new glyph if needed), copy/paste the glyph to the new position, and copy/paste the glyph in the holding place to the other.

It's a very tedious process, but seems to be working. There may be other glyph information that needs to be transferred, but that is beyond my current limited knowledge of Fontforge.

2
  • Welcome to GD.SE!
    – Mensch
    Dec 2, 2021 at 13:22
  • 1
    What you're doing is basically swapping all the information (char name, glyph design, etc.) between the two glyphs. That's what I ended up doing too, but in a less cumbersome way: I copied the entire glyph and duplicated them in the order I wanted, then deleted the earlier, badly ordered set. Both approaches are admitting that the answer is "No, there is no simple way."
    – D0SBoots
    Dec 3, 2021 at 3:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.