1

I have a font with OpenType alternates that I want to use in a program that doesn't support the selection of OpenType stylistic sets (like my game engine).

For example, I may want to use the non-default single-storey "a" from Montserrat, while keeping the angular capital "A".

Is there a program I can use to bake in only the selected OpenType features and discard the now unused glyphs for file size savings?

1
  • I know nothing about programming or game engines, but might it be possible to use outlines? - like convert text to outlines using vector software. Export as SVG. Then you could just use the vectors.
    – Billy Kerr
    Apr 10, 2022 at 10:14

1 Answer 1

1

I'm no font or FontForge expert, but I can give you some tips to get started.

If you open one of .ttf files of the Montserrat font in FontForge, by default you are presented with a view of all the glyphs in the font.

Near the bottom you can find the single-storey a. You can see it's the same unicode (U+0061) as the default a.

Simply select the glyph by left-clicking it and press Ctrl + C to copy it to clipboard.

Scroll back up to the default a in the top, select it by left-clicking it and press Ctrl + V to paste in the single-storey a.

Now you can use File > Generate Fonts to export a custom .ttf file with the altered "a". A quick test in a browser confirms that it works:

You can delete and move glyphs around as you please, but if you don't know what you are doing it's easy to make a mess.

You might have noticed in the gif that when selecting the default a, the a's with accents (àáâãäå) are also selected and when you paste in the single-storey a, they also get substituted, but with the accents positioned wrongly. That's because they are linked to the default a and the single-storey a has a different width than the default a.

You could select that range of glyphs (or all the glyphs in the font), right-click and perform Unlink Reference to "bake" all the glyphs to their current shape before moving around glyphs, but then you would be forced to manually copy/paste each of the correct accented a's.

Besides linked glyphs I would also worry that brutally unlinking, moving and deleting glyphs could mess up kerning, hinting or some other advanced feature under the hood I know little about. The font might seem to work at first glance, but just a tiny error you don't discover until later might be enough to make the custom font unusable.

I don't really understand how the file size could be a problem. Each of the Montserrat font files are around 200 KB. The whole font is less than 4 MB.

Just locating the glyphs you need and deleting all others seems like a lot of work. And can you even be 100% sure at the current time which glyphs you won't ever need?

Edit

I found this online Font Subsetter which enables you to specify which Unicode blocks you want the font to contain. You can also choose additional single characters.

I've tried to generate a subset only including Basic Latin and obviously the font looks a lot simpler when opened in FontForge.

Then I opened the original font, copied the single-storey a and pasted it into the subsetted font in place of the default a.

A quick comparison in a browser with lorem ipsum text in the original font, the subsetted font and the subsetted font with custom a indicates that the customized font seems to work as expected.

The file size have been reduced from 194 KB to 51 KB.

But there is sadly a potential issue with kerning using this method.

In the original font, with the default a, the av kerning pair has Kerning Offset set to -10.

And with the single-storey a, the av kerning pair has Kerning Offset set to 0

But in the edited file, the av kerning pair has Kerning Offset set to -10, so the metrics haven't been copied along with the glyph.

This isn't really surprising and could probably be fixed if you dive deeper into the kerning rabbit hole. In this particular case, the difference is probably negligible but I encounter some strange issues I can't explain with other glyphs.

The font file generated with the Font Subsetter seems to work as expected, but once I open it in FontForge and generate a new font, some of the kerning pairs get messed up. Even if I don't change anything. I've tried several combinations of options when generating the font, but nothing seems to fix it.

So I'm back to my initial conclusion: It's not worth editing fonts for this purpose. At least not with the free software I'm able to find at the moment. I'm sure professional font software has some advanced functions to streamline font editing like this, but I don't have access to any of these.

2
  • Yeah, that was my first approach, but the sheer amount of manual fiddling and broken kerning was the motivation for me to ask this question.
    – haley
    Apr 16, 2022 at 22:53
  • You already tried this? You should've described in your question what you have tried and why it didn't work. The more details and screenshots the better. Anyway, I looked at it another time and added some more information. Sadly I come to more or less the same conclusion. Altering a font is a bit like altering a code library. Everything is entwined. Hard to automate as different fonts could be using different logic. Doesn't make it easier that I don't fully trust FontForge - seems to do some strange things sometimes. And crash all the time.
    – Wolff
    Apr 17, 2022 at 12:30

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.