Parsing an OpenType Font File

Started by
3 comments, last by Anon Mike 12 years, 12 months ago
Greetings!

I'm trying to add OpenType font support to my game engine. I am aware of FreeType, but have decided to write the parsing code myself. The OpenType font specification is a monstrosity, but I've learned a lot about fonts in the process...

Anyway, I'm trying to test my character map ( "cmap" ) table parsing code. So far, I haven't been able to find a font that uses a character map with format 8.0 ( mixed 16-bit and 32-bit coverage ), 10.0 ( trimmed array ), or 13.0 ( many-to-one range mappings ). Does anyone know of a font I can download that uses these character map formats? Or a tool that can generate a font file with those character encodings?

Thanks,

-Dev578
Advertisement
Seeing as this is For Beginners forum .... Why are you parsing font files?

Fonts can contain a lot of information and are complex, as you have learned. Font rendering is built in to the major operating systems.


The goal is probably to make a game, not a font renderer. Let the system transform fonts into images for you, and then use the images.
I was expecting a response like this:)

I guess there is just a certain satisfaction that comes from rendering a font myself. If I don't get anything else from it, it's nice to learn the mechanics of how fonts work.

Since I'm developing cross platform ( Windows, Mac, Linux ), this reduces the amount of OS specific code in my engine. I'd much rather maintain one set of generic code than three sets of OS specific code that do the same thing.

Dealing with OTF at such a low level also gives me the opportunity to have performance configuration options to optimize based on the needs of the game.

For now I'll just not support the features I can't test due to not having a font that uses those features.

-Dev578
Use FreeType. Don't worry, you can still waste as many days as you want caching glyphs in textures, and if you still get bored, you can even try to get subpixel rendering to work. I don't think anyones ever bothered to do that in a 3D game, but hey, you can be the first.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
Quite frankly, I wouldn't worry about it. Especially not for a game.

Windows requires fonts to have a format 4 cmap. Font makers know this so the vast majority of fonts will have one. The more advanced stacks (i.e. DirectWrite and WPF) will use a format 12 if it's available but still fallback to format 4. You may also want to look at a symbol font as I know they're a bit special but can't remember the details offhand.

Some older Mac fonts may only support format 0. If you're targeting the Mac then you might want to support this as well.

The other more esoteric formats aren't worth the trouble.

If you're thinking of writing your own font renderer then all I can say is good luck. http://www.rastertragedy.com/ should be considered required reading.
-Mike

This topic is closed to new replies.

Advertisement