5

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?

5
  • Hang on, back up. why are you converting from otf to ttf? (the font will blow up in size, and all glyph outlines will get lossy-converted from cubic Bezier to quadratic Bezier form) Jul 30, 2015 at 22:31
  • Just because the program I want to use the font in supports ttf and not otf - I don't really mind about the losses involved when going backwards to a less advanced format.
    – Jack
    Jul 31, 2015 at 8:53
  • That leaves the question "which program?" because both ttf and otf are OpenType fonts, so programs that support OpenType fonts with a ttf extension but not with an otf extension are worth explaining as part of your "this is what I need it for" problem statement. Jul 31, 2015 at 15:57
  • @Mike'Pomax'Kamermans This is a useful question without such context. I need such a question answered for Magento 2: PHP Zend_Pdf, which is supported in Magento 2.3 doesn't implement a Japanese, Korean or Chinese charset, meaning that this font trickery is required as good free .ttf asian charsets are thin on the ground Feb 15, 2021 at 18:35
  • No, you don't: PDF, adobe's format, very much supports otf, Adobe's preferred format. In fact, it supports every OpenType flavour, becuase ttf and otf are both just opentype fonts. And there are plenty of good free opentpye CJK fonts out there. Feb 15, 2021 at 23:30

1 Answer 1

2

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()
1
  • Hey, this is all good, but how would I do this with the entire font? Feb 15, 2021 at 18:23

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.