Font outlines

Member
Posts: 260
Joined: 2005.05
Post: #1
What is the best way to extract font outlines? Is there a simple, system independent method?

ATSUI can do it. There are some (not very simple) demos. But ATSUI is going away. It seems like a bad thing to spend time on.

Core Text is 10.5 only. This can be OK if it is good - but is it? Apple's APIs tend to be more and more complicated for every generation. Is this better, is this where I should dive down?

FreeType is platform independent (good!), but it was pretty hard to get rolling. Worth the trouble?

I can go with some nonportable solution if I have to. My goal is to extract simple outlines as sets of polygons, so I can draw my fonts regardles of what fonts are actually installed (doing what FTGL does but in safer and simpler way and without including FTGL/FT in my code). But what would be the easiest way? Comfortable, easy to work with, straight-forward?
Quote this message in a reply
Member
Posts: 749
Joined: 2003.01
Post: #2
I ended up using bitmap fonts. They're nice cause you can apply styles with photoshop to your font.

Here I write a small library for bitmap fonts in SDL and opengl, feel free to use the code as you wish. http://www.idevgames.com/forum/showthread.php?t=15986

if you're not using sdl you'll have to do bitmap blitting on your own.

©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #3
Najdorf Wrote:I ended up using bitmap fonts. They're nice cause you can apply styles with photoshop to your font.

Here I write a small library for bitmap fonts in SDL and opengl, feel free to use the code as you wish. http://www.idevgames.com/forum/showthread.php?t=15986

if you're not using sdl you'll have to do bitmap blitting on your own.

Thanks, but I have pretty good code for bitmap fonts, totally independent on anything beyond the OpenGL core. Nothing wrong with that, as long as that's what we need (no rotations, no scalings, just the straight text). But with outline fonts, I can extrude to 3D and other effects.

I am quite disappointed by FreeType. The instructions are vague, and don't work. And the demo programs don't work. I have to go elsewhere.
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #4
For high-quality font rendering you're pretty much stuck with either Quartz or FreeType. I don't know if you can get the outlines from Quartz (never bothered to try), but as you mentioned, you can get them from FreeType since FTGL does it (I didn't really care much for FTGL, BTW). For cross-platform, FreeType is really the only show in town that I know of (I wouldn't touch the old ATSUI stuff, since as you say, that's going away). I managed to figure FreeType out after reading carefully through the documentation. It definitely wasn't easy to get going with it, but in retrospect I can't say that it was impossible -- just lots of reading. It's been a while since I've used FreeType though, so maybe things have changed. I don't need the outlines or cross-platform so normally I just use bitmap fonts or Quartz and be done with it, but otherwise I'd say FreeType is probably the best bet for you.
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #5
Am I the only person who considers this a problem?

I am not sure I need "high quality" font rendering in games, not if it complicates things and ruins portability. I think I'll rather go for "decent quality", but portable.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #6
You could always run something like the marching squares algorithm on a medium-high resolution version of a bitmap font to vectorize it. I have some code that plus some polyline/loop simplification code that works very well together. I've been using it for extracting collision outlines from image masks, so it preserves correct windings for interiour/exterior loops.

At the moment, it's an offline tool written in a combination of C/Ruby, but the code is pretty simple and there isn't a ton of it. Shouldn't be too hard to convert to whatever language you prefer. I'd be willing to share if you are interested in trying it.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #7
Skorche Wrote:You could always run something like the marching squares algorithm on a medium-high resolution version of a bitmap font to vectorize it. I have some code that plus some polyline/loop simplification code that works very well together. I've been using it for extracting collision outlines from image masks, so it preserves correct windings for interiour/exterior loops.

At the moment, it's an offline tool written in a combination of C/Ruby, but the code is pretty simple and there isn't a ton of it. Shouldn't be too hard to convert to whatever language you prefer. I'd be willing to share if you are interested in trying it.
Marching squares? Never thought of that, but you are quite right, it should produce a pretty nice polygon from a dithered pixmap. I have considered to run a polygon approximation algorithm along the edge, which should produce something similar, but I think marching squares would be more exact.

I'll keep digging some more into the code I am working on, but I'll let you know if I'd rather try your code. Thanks!
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #8
My original ultimate goal was to find a way not only to find outlines but also to render text in both 2D and 3D. After a bit more work than I thought it should be, I now have a solution where the 2D text, outline and filled as I please, works nicely.

[Image: fonttest.png]

I don't know if this qualifies as high quality (some anti-aliasing would not hurt) but I think it is good enough for many purposes. And this is without using any system calls other than calling OpenGL for rendering! The little system dependency I have should be easy to remove. And it is not using FreeType/FTGL, but is much simpler.

I think this has a point. In particular, I don't have to mess with ATSUI or Core Text.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #9
Looks cool! What technique did you end up using?
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #10
ThemsAllTook Wrote:Looks cool! What technique did you end up using?
I found a code example that extracted outlines from a TrueType font and passed it to GLU tesselators for proper rendering. After some (pretty thorough) massaging of that code I got it running under OSX. So it is a kind of "lightweight FTGL". Straight C code, not extremely complex. Just 4 .c files and a bunch of .h files. Nice and managable.

To be precise, the code in question was David Phillip Oster's Mac version of Nehe lesson 15. I am sure some people here have seen it. It was for classic MacOS, which is why it needed some work. I'll share the code in some suitable way.

Making it fully portable is the next move. Right now, it uses "classic Mac" TrueType fonts, that is in resources. We can't have resource forks in portable code, but that is no disadvantage to speak of, I can move the resources to ordinary files and load from there. Modern Mac TrueType is also in data forks, but I don't know if the format is otherwise the same.
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #11
Hey, that looks pretty nice! Looks like a decent alternative to freetype/quartz/bitmap fonts. I like that it is using a slimmed down technique, straight from the font files. I'll be looking forward to seeing the code when you get the chance. Smile
Quote this message in a reply
Member
Posts: 749
Joined: 2003.01
Post: #12
Aliasing is very bad. I understand you might want to do models with the text (give them a real 3D thickness), for 2D I'd definitely stick with bitmap fonts.

I can't remember the last time I've seen a real 3D text (as opposed to 3D rendered), might be fun.

©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #13
Najdorf Wrote:Aliasing is very bad. I understand you might want to do models with the text (give them a real 3D thickness), for 2D I'd definitely stick with bitmap fonts.

I can't remember the last time I've seen a real 3D text (as opposed to 3D rendered), might be fun.
Aliasing is a problem for sure. I experimented with OpenGL antialiasing but nothing happened. The problem might be that my MacBook has an Intel GPU.

But bitmap fonts have other problems. In particular, they don't scale well. Texture fonts rotate nicely, but for a quality cost. And glBitmap fonts don't scale or rotate at all.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #14
Rotating works fairly well for bitmap text with a 1.5-2 times higher resolution than what you display them at, given the right filtering parameters are used.
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #15
After fixing some problems with normal vectors I managed to do this:

[Image: 3dtexttest.png]

Not too bad IMHO. Rather, I am pretty happy about it. (The dark spot at the bottom is the light source, rotating around the green ball.)

It still needs some anti-aliasing. Does anyone know if GMA GPUs are particularly bad on implementing OpenGL's built-in anti-aliasing?
Quote this message in a reply
Post Reply