Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filling in missing glyphs in fonts with fontforge

Background

I'm trying to convert the Google Noto Sans JP font from a .otf to a .ttf, using the following fontforge script:

#!/usr/bin/env fontforge

Open($1)
CIDFlatten()
Generate($1:r + ".ttf")
Close()

When I call Open on the .otf, I get a load of errors saying that there are lots of missing glyphs:

No glyph with unicode U+07d22 in font
No glyph with unicode U+07d2f in font
No glyph with unicode U+07da0 in font
...

My script converts the .otf into a .ttf but, sure enough, when I load the font these characters aren't rendered (they look like this: [X]).

So I'd like to fill in the gaps and copy identical glyphs into the missing slots.

The Problem

So I run the following script to try and substitute one of the missing glyphs (U+7d22) with an identical one (U+f96a):

#!/usr/bin/env fontforge

Open($1)
CIDFlatten()

Select(0uf96a)
Copy()
Select(0u7d22)
Paste()
SelectNone()

Generate($1:r + ".ttf")
Close()

However fontforge fails to select the non-existent character U+7d22:

Select: Character not found: U+7D22

Does anyone know how to copy a glyph to a codepoint that doesn't have a glyph?

Or in other words, does anyone know how to fill the gaps in this font?

like image 738
Jack Avatar asked Oct 30 '22 22:10

Jack


1 Answers

It turns out you can "fill in the gaps" in ttf format, so I first converted the font, then copied the glyphs, like so:

#!/usr/bin/env fontforge

Open($1)
CIDFlatten()
Generate($1:r + ".ttf")
Close()

Open($1:r + ".ttf")

Select(0uf96a)
Copy()
Select(0u7d22)
Paste()
SelectNone()

Generate($1:r + ".ttf")
Close()
like image 167
Jack Avatar answered Nov 23 '22 02:11

Jack