I'm trying to add embedded bitmaps to my outline (vector) font. It's essentially a 'pixelfont' that is supposed to have a 1:1 "pixel perfect" representation at a size of 12px (which is 9pt, on my 96dpi monitor). My intention is to force that particular size to render as bitmaps (no anti-aliasing); all other sizes would show as outlines.
I used FontForge to generate bitmaps for the 12-pixel size, and embed them into the TrueType/OpenType files. This seems to work correctly - when I reopen the .TTF/.OTF in FontForge, it finds the 12px bitmaps and displays them as intended. However, when the font is installed in Windows, I only see outlines being rendered - even at 9pt (12px), instead of my bitmaps. (I've verified this by modifying a few bitmap glyphs to make the difference apparent.)
I'm using Windows 7 with ClearType enabled.
Microsoft says: "ClearType antialiasing is disabled [...] if the font has tuned embedded bitmaps, only for those font sizes that contain the embedded bitmaps." For some reason, this isn't working for me.
Any ideas why I'm not seeing my bitmaps being rendered? Is there some required property that I might be missing, or some way to debug this?
Comments
I wasn't aware it was even possible to embed bitmaps in an OpenType CFF font. I'm pretty sure nothing renders those.
(This is aside from other SFNT containers that store bitmap fonts, such as some of the recent color font solutions.)
I'm just not sure what the conditions are to make it happen; I'm trying to avoid having to split my font into separate versions (bitmap and outline). Of course, this whole headache could've been averted if Windows supported a true unicode bitmap font format (such as BDF).
So, assuming that Windows still renders bitmap data, it sounds like your bitmap tables themselves are not really functioning correctly. Maybe look in here?
http://www.microsoft.com/typography/otspec150/otff.htm#otttables
Rob tell me that you also need to set the GASP table correctly:
"Embedded bitmaps only show up if the gasp table has asymmetric rendering on for the desired size. (Change was made in 8.1)"
Thanks for that info, Aaron. I had a look at those East Asian TrueType fonts you mention: even with ClearType enabled, Windows 7 and 10 both render the contained bitmap strikes -- which confirms that Windows still supports this.
I opened a few of those fonts in FontForge (Batang and MS Gothic, specifically) to see how they pull it off, but somehow I still can't get this to work in my own font:
- The bitmaps for the desired size (12px) exist, and the bitmap data is embedded in the .ttf (EBDT+EBLC tables).
- I set the GASP table as per your tip - this is how those East Asian
fonts do it, too. For size 16px and under, I've got 'Grid Fit', 'No
Anti-Alias', 'No Symmetric-Smooth', and 'No Grid Fit w/Sym-Smooth'.
- I also ran my font through Microsoft's Font Validator. My bitmap tables (EBDT, EBLC) check out fine, and there are no rasterization errors. [EDIT:] same goes for the newly-updated Font Validator which I just found out about!
Windows still refuses to render the bitmap strikes in my font. Curiously enough, if I recreate a .ttf in FontForge from one of the aforementioned Asian fonts, the bitmaps work as expected. I'm forced to assume that there's yet another undocumented requirement - I just can't figure out what that might be...Any other clues would be appreciated!
That would be unfortunate... though not entirely unexpected. I haven't been able to find any official info regarding that -- is this documented anywhere?
At any rate: if true, I suppose the question would be what causes DirectWrite to identify a TrueType font as a 'legacy East Asian font', for rendering purposes. If there's some property I can set without breaking anything else, just to get the bitmaps, I'd happily do that.
Thanks. For what it's worth, when I changed an East Asian font's name in FontForge and exported my own .ttf, the bitmaps still worked; so if there's some hard-coding at work, it's probably not by name.
I'll be curious to hear the report back from Si and Mike. I was pretty sure we couldn't make bitmaps work in arbitrary new fonts on Windows, so any way to make it happen would be interesting news to me.
mkdir a;
cp yourfont.ttf a/a.ttf;
mkdir b;
cp msfont.ttf b/a.ttf;
ttx -s */a.ttf;
meld a b;
http://www.dutchtypelibrary.nl/FontMaster_rdrct.html
Open the 2 fonts and use the table comparator (tools -> table comparator)
Apparently, for modern versions of Windows to display the embedded bitmaps, (1) the "MS Codepages" OS/2 table has to specify at least one East Asian codepage -- that post recommends Traditional Chinese, but 'JIS/Japan' also worked when I tried it; and (2) a few seemingly-random glyphs in the Hiragana range have to actually exist(!).
The first requirement is a bit unfortunate, because it seems to make Windows ignore certain other codepages, even when they're explicitly specified alongside the East Asian one(s). Which makes it less than ideal for my purpose, but hey, at least it works and we've solved the mystery.