5
\$\begingroup\$

I've used angel code's bitmap font generator quite a bit; though it's very good, I wonder if there would be a way to use the hinting information to provide a better and more 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. 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.


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 static scenes, where the scenes use 3D transformed and warped text layout. In this case, the legibility is important; more important than the accuracy of representation of the polygon shape.

\$\endgroup\$
4
  • \$\begingroup\$ 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. \$\endgroup\$
    – user744
    Commented Nov 25, 2010 at 14:56
  • 1
    \$\begingroup\$ Not totally related, but this is a good article about text rasterization in general: antigrain.com/research/font_rasterization \$\endgroup\$
    – Tetrad
    Commented Nov 25, 2010 at 20:02
  • \$\begingroup\$ 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? \$\endgroup\$
    – user744
    Commented Nov 25, 2010 at 21:10
  • \$\begingroup\$ I'm voting to close this question as off-topic because we do not support questions asking if a particular software exists based off requirements. You might find that such a question is on topic at Software Recommendations, but you should make sure to read their help page, first. \$\endgroup\$
    – Gnemlock
    Commented Jun 24, 2017 at 2:07

2 Answers 2

2
\$\begingroup\$

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.

\$\endgroup\$
4
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Nov 26, 2010 at 11:00
  • \$\begingroup\$ 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. \$\endgroup\$
    – user744
    Commented Nov 26, 2010 at 11:12
  • \$\begingroup\$ the text is dwindling in size over space, not time. I guess the size would probably be specifiable per character at least. \$\endgroup\$ Commented Nov 26, 2010 at 15:43
  • \$\begingroup\$ 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. \$\endgroup\$
    – user744
    Commented Nov 26, 2010 at 16:50
1
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .