Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

Font Rendering

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Ryan_001   Prime Members   


Posted 27 July 2014 - 01:24 PM

A while ago I wrote for my own uses a font loading/rendering helper library.  I posted it on sourceforge because a few people in other forums expressed interest.  There's been alot of talk lately on font rendering in games, so I thought I'd post a link in case anyone is interested.




Unlike most font rendering libraries, this doesn't use or produce a texture/sprite sheet.  Rather it triangulates the characters into an actual mesh.  There are a couple different choices of triangulators, one that produces very compact representations that uses the technique described here: http://http.developer.nvidia.com/GPUGems3/gpugems3_ch25.html.  There are a few others as well.


Its worked well for myself and from what I understand a few others.  If any bugs are found I'm happy to fix them.

#2 MaxDZ8   Members   


Posted 11 August 2014 - 07:27 AM

Hey, I also use that algo cool.png

Thank you for sharing hopefully someone will find it useful. I see it's a pretty broad library in terms of scope as it collects quite some data about the font as well. I'm surprised the triangolator is fast, it looks very simple.

Previously "Krohm"

#3 Ryan_001   Prime Members   


Posted 11 August 2014 - 07:53 AM

Ya, after reading the chapter in GPU Gems 3 I was inspired and couldn't think of a better place to use that than with font rendering.  Then I realized it could actually be useful and decided to clean it up a bit and post it.  But really it was just about having fun :)

#4 CaptainMurphy   Members   


Posted 15 August 2014 - 01:38 PM

This library really needs some kind of docs or at least example code, I wasn't able to figure it out.

#5 Ryan_001   Prime Members   


Posted 21 August 2014 - 08:58 AM

Ya I guess it does, when I have some time I will.  Really quickly the steps to use it would be...


1) Create a Font object like:

TTF::Font font("fonts/Nexa-Light.otf");

The Font object has all the font data, like bounding rects, kerning info, headers, code point to glyph index conversion, ect...


2) Create a triangulator:

TTF::TriangulatorI triangulator;

Currently there are 3.  Each triangulator will have different outputs.  TriangulatorI uses the GPU gems 3 vector rendering (ie. requires a pixel shader).  TriangulatorII on the other hand is just a standard mesh (no special pixel shader required) but requires you to supply a function to specify how to subdivide the curves.


3) Create a Mesh object to store the glyph:

TTF::MeshSmall mesh;

Mesh small is useful for most fonts, but its theoretically possible that some glyphs might be too large (have too many vertices) to be stored in a MeshSmall object, in which case you can use a MeshLarge object.  There's almost no difference from a user standpoint, a MeshLarge just uses a less compact storage.


4) Triangulate the glyph:

In this case text is a std::string.  Now you can do whatever you want with the glyph (add it to a vertex buffer perhaps).
5) Optionally get the kerning:
TTF::vec2s t = font.GetKerning(CodePoint(text[i]),CodePoint(text[i+1]));

Kerning is the distance between one glyph and the next.


Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.