Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I've used angel code's bitmap font generator quite a bit and though it's very good, I wondered if there would be a way of using the hinting information to provide a better readable result by using hinting to provide differing thickness based on size/pixel coverage.

I imagine any solution would have to use the distance field tech presented in the valve paper on smoothing fonts while maintaining or reducing asset size. (http://www.gamedev.net/community/forums/topic.asp?topic_id=494612) but I haven't found any demos of it being used with hinting information turned on or included in the field gradients in any way.

Another way of looking at this is whether there are any font bitmap generators that will output mipmaps that still maintain their readability in the face of pixel size. I think the lower mip levels would try to guarantee fill and space where it is necessary to maintain readability/topology over maintaining style/form (the point of hinting).

In response to "Is there a reason you can't just render the size you want", the problem lies in the fact that font rasterisers currently don't render in 3D, and hinting information would be important in different amounts due to the pixel density being different along different axes, even differing in importance along the length of a string due to the size reducing over distance. For example, I only want horizontal hinting in a texture that is viewed from the side, and only really want vertical hinting in a font that is viewed from below or above. This isn't meant to be a renderer that tries to render a perfect outline as accurately as possible, as hinting distorts the reality of the font, instead this is meant to be a rendering solution for quite static scenes, but scenes that have 3D transformed and warped text layout. In this case the legibility is important, more important than the accuracy of representation of the polygon shape.

share|improve this question
    
When you say hinting, do you mean subpixel hinting (I think only Direct2D can do this), or pixel-level hinting? The latter is already taken care of if you just render using (hinting-enabled) FreeType at the size you want; Valve's technique can be considered a form of auto-hinting, just not as good as the manual hinting, which by its nature requires manual sizing. –  user744 Nov 25 '10 at 14:56
1  
Not totally related, but this is a good article about text rasterization in general: antigrain.com/research/font_rasterization –  Tetrad Nov 25 '10 at 20:02
    
Unfortunately one goal of hinting is that different sizes of the same character may require slightly different ratios, and so plain mipmaps are not appropriate. Doing your own "pseudo-mipmaps" is the same as just rendering the font at different sizes and using the closest one; you're back to the high memory requirements the Valve technique tries to avoid, and your render path is more complicated than it would need to be. Is there a reason you can't just render the size you want? –  user744 Nov 25 '10 at 21:10

2 Answers 2

up vote 2 down vote accepted

My only good suggestion is to try making the thresholds in the distance field technique a function of the desired character size or (somewhat equivalently) the ratio between the rendered size and the desired size. (I think this is mathematically equivalent to applying a non-linear filter when scaling.) That would drastically increase the cost of the fragment shader (though maybe not significantly in a real program), and you'd end up duplicating non-trivial code if you also wanted a fixed-function path.

Another possibility would be to average the distance field across many font sizes while generating it, which would get you the hinting information "in" the texture. However, usually the distance fields store between 32px and 64px per character. The cases where manual hinting truly benefits is at small (8-16px) font sizes. I don't know how much meaningful information there is to get from averaging something intended for ~8px with something intended for ~256px and storing it in ~32px.

Any other techniques I can think of require more memory, at which point you're really better off just rendering the fonts in the size you want, and using them as-is.

share|improve this answer
    
The problem lies in the need to render fonts where size is not specifiable, due to screen size differences, and orientation of the font string to be rendered. Sometimes a font would render at ~50px tall, dwindling to ~10px tall at it's terminus. –  Richard Fabian Nov 26 '10 at 11:00
    
The size is always specifiable at some point; the problem only arises if the size changes often during runtime, because re-rasterizing is expensive. If at some point you know you're always going to need at at 50px, 30px, 12px, and 10px, you can just do those sizes. If you're trying to make a glyph string scale down gradually, pixel hinting can actually hurt a smooth look. –  user744 Nov 26 '10 at 11:12
    
the text is dwindling in size over space, not time. I guess the size would probably be specifiable per character at least. –  Richard Fabian Nov 26 '10 at 15:43
    
Whether space or time, hinting can make it look worse, because it means uniform reduction in nominal pixel size doesn't become uniform reduction in displayed pixel size. –  user744 Nov 26 '10 at 16:50

IANAL, but the hinting patents have recently expired. A TrueType implementation, such as FreeType should be usable with hinting enabled.

My group has built our own TrueType rasterizer, although I know several teams that are satisfied with the degraded quality found in the distance field technique (largely because they're using simple sans-serif fonts in simple situations such as subtitles and decals).

All that said, most fonts have crummy auto-generated hints in them. Stick to the major type houses or you'll just be looking at the output of FontLab.

Although we knew the hinting patents were expiring, we did not implement a bytecode interpreter because we felt that the small sizes where hints are most designed to help shouldn't be used on game consoles, which is what we target.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.