james_lohr's picture


I'd just like to announce the release of QuickFont, a text printing and font generation library: http://www.opentk.com/project/QuickFont

I could only upload 4 images on the project page, so I've uploaded the remaining screenshots here.

Enjoy. :)

James L.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
invisghost's picture

NICE! Sorry to hear about the girlfriend but its all in the name of science right? :D

tksuoran's picture

Looks nice. Couple of comments:

  • You really, really should have kerning pairs.
  • Don't forget to be gamma correct when you scale or filter.
  • All GL stuff is using the old fixed function. These days we would like to have shader support.
  • When you got shaders, you can do cool things like scaling using distance fields. Google for "valve distance field font"

I implemented my own font rendering on top of Angelcode Bitmap Font Generator. This is a shortcut but it does give you kerning pairs. I have not yet bothered to add drop shadows or distance field rendering yet though.

james_lohr's picture

Thanks Tksuoran, your feedback is extremely useful. I realise that I have approached writing this library slightly naively.

>>You really, really should have kerning pairs.

Absolutely. I knew something looked a bit wrong.

I will need to manually compute the kerning information for texture fonts (as glyph shape may have changed during texturing), and I'm not too worried about this because although it will be computationally very intensive, it can be done once per font and saved to the .qfont file so that it does not later affect application load times.

My concern is that manually calculating kerning every time a font is loaded (even those loaded directly from a .ttf file) will be slow. I take it that I can extract kerning information from the ttf files?

>>Don't forget to be gamma correct when you scale or filter.

Fair point. I will attempt to modify my scaling algorithm to compensate for this at some point. Even if it is very slow to compute, it would be a very nice feature to have when generating the texture fonts in the first place.

>>All GL stuff is using the old fixed function. These days we would like to have shader support.

Would this be a lot of work to support, and how would I go about doing it?

james_lohr's picture

Kerning pairs are done. In the end I realised that they can be calculated very quickly, even for large fonts, so I'm just calculating them from scratch every time a font is loaded. :)

The screenshots on this blog page are still pre-kerning. If you want to see shots after kerning, the screenshots on the project page have been updated: http://www.opentk.com/project/QuickFont

migueltk's picture

Excellent work ...

An ideal complement to work with OpenTK.


tksuoran's picture

I'm not sure if your kerning pairs are quite perfect yet, for example after letter f there seems to be too much space in the last picture. Proper kerning pairs have to be extracted from the font itself. Getting kerning pairs by examining the image is a new idea to me, and might work to some extent.

Here is another font rendering link which may be interesting: freetype-gl.

james_lohr's picture

>>for example after letter f there seems to be too much space in the last picture.

Which f do you mean? I've highlighted all fs in the last picture.

(I've deleted the pre-kerning pictures to avoid confusion)

As far as I can tell it's working perfectly. The only exception I've had is the _ character which tends to be below the glyphs and therefore gets kerned to the max. What I'll do is to allow the user to define kerning exceptions, and by default I will have such an exception set for underscore.

tksuoran's picture

I guess I saw an older version of the picture. The new one looks a lot better. I'm surprised how well you managed to get kerning pairs this way. It might be interesting to compare results with real kerning pairs from the font - it can't be too difficult to query them?

james_lohr's picture

I've compared it visually with a handful of fonts and it seems pretty flawless. The few cases where there are differences, I've not even been convinced that the manual kerning values are better than those selected automatically by my code. Though to be fair I've not tested it exhaustively, and as mentioned '_' gets auto-kerned wrong.

An easy way to see just how well the auto kerning is working is to set the character spacing (independent of kerning) to zero. I've done that in the second screenshot above. Basically it does exactly what I coded it to do: puts the glyphs as close as they'll go to each other without overlapping. :P

mastertnt's picture

I am playing a little bit with your library and I've got an issue with Monospaced fonts like "Courrier New".

When i draw a fixed size text with those fonts, the bounding box of the text is changing. I checked the size of the glyphes and the size is différent for each.

Is it normal ?