<p>I display text using OpenGL which is aligned with (2D) objects that can have any rotation on display, making the text also appear at any angle on display. So far I've used FreeType to render raster for each supported symbol to file and load the files into OpenGL as textures at application start.</p>

<p>When the text is rotated (other than 90 degree increments) the hinting goes all bad. My plan so far to remedy the situation is to render a few rotated (transformed) variants of each symbol and linearly interpolate between the two closest variants. As an example I may render variants in 15 degree increments between 0-75 degrees inclusive, and if text is rotated by 5 degrees on display I'd take 1/3 from the 0 degree raster and 2/3 from the 15 degree raster.</p>

<p>...but this is only a theory of mine. Should work if having small enough increments, but if there are too many of them I'll run out of memory resources and making the shader awfully inefficient. I imagine the increment count depends on the pixel size of each symbol which could turn problematic...</p>

<p>So I reach out to the expert community: How to render rotated text with proper font hinting in real-time?</p>

<p>Using OpenGL ES 2.0. Font size ~16pix. If you need more info ask away.</p>

CC BY-SA 4.0
2018-05-11T09:37:39.930Z
Hinting is only for vertical or horizontal edges in the font glyphs, so I don't think it'll work for your rotations at all. You might need to use SDF font rendering, or rasterise the vector font each frame.
Dan Hulme
CC BY-SA 4.0
2018-05-11T10:07:46.173Z
@DanHulme "Hinting is only for vertical or horizontal edges" - That would be news to me. Reading the docs I understand hinting as a manual shift of the spline in any direction, sacrificing relative distance preservation between (edge-) features in favor of stronger "main" features, such as the three vertical bars in "m". I don't see why this would be a horizontal/vertical thing only... Guess I gotta re-read some books and articles.
Andreas
CC BY-SA 4.0
2018-05-11T10:13:17.030Z
@DanHulme I didn't think using SDF for 16pix font was applicable since many features are optimized on sub-pixel basis. Gonna look at it closer though. Thanks!
Andreas
CC BY-SA 4.0
2018-05-11T11:25:25.807Z
OK, I was thinking specifically of stem hints, and control point hints are also a thing in TrueType. [The old FontForge docs have a brief explanation](http://fontforge.github.io/overview.html#Hints). But the point is, hinting is about fitting the glyph onto a square grid, so that beams cover a whole pixel, so you don't get jaggies or blur. Reorienting the square grid obviously invalidates the hints.
Dan Hulme
CC BY-SA 4.0
2018-05-11T11:49:17.167Z
@DanHulme Ok, that makes sense. I would need a separate set of hints for each orientation since which parts of a glyph become beams is in part derived from orientation. Guess I'll have to ask the design department to make a font for each orientation they want to show ;-) Really though, I'll have to look closer at alternative solutions such as SDF. Thanks again.
Andreas
<opengl-es><font-rendering>
How to rendered arbitrary rotated text with decent hinting in real time?
Andreas
# How to rendered arbitrary rotated text with decent hinting in real time?

(Asked by: username_0 on 2018-05-11)

I display text using OpenGL which is aligned with (2D) objects that can have any rotation on display, making the text also appear at any angle on display. So far I've used FreeType to render raster for each supported symbol to file and load the files into OpenGL as textures at application start.

When the text is rotated (other than 90 degree increments) the hinting goes all bad. My plan so far to remedy the situation is to render a few rotated (transformed) variants of each symbol and linearly interpolate between the two closest variants. As an example I may render variants in 15 degree increments between 0-75 degrees inclusive, and if text is rotated by 5 degrees on display I'd take 1/3 from the 0 degree raster and 2/3 from the 15 degree raster.

...but this is only a theory of mine. Should work if having small enough increments, but if there are too many of them I'll run out of memory resources and making the shader awfully inefficient. I imagine the increment count depends on the pixel size of each symbol which could turn problematic...

So I reach out to the expert community: How to render rotated text with proper font hinting in real-time?

Using OpenGL ES 2.0. Font size ~16pix. If you need more info ask away.

**Tags:** opengl-es, font-rendering

> **Comments:**
> **username_1**: Hinting is only for vertical or horizontal edges in the font glyphs, so I don't think it'll work for your rotations at all. You might need to use SDF font rendering, or rasterise the vector font each frame.  
> **username_0**: @username_1 "Hinting is only for vertical or horizontal edges" - That would be news to me. Reading the docs I understand hinting as a manual shift of the spline in any direction, sacrificing relative distance preservation between (edge-) features in favor of stronger "main" features, such as the three vertical bars in "m". I don't see why this would be a horizontal/vertical thing only... Guess I gotta re-read some books and articles.  
> **username_0**: @username_1 I didn't think using SDF for 16pix font was applicable since many features are optimized on sub-pixel basis. Gonna look at it closer though. Thanks!  
> **username_1**: OK, I was thinking specifically of stem hints, and control point hints are also a thing in TrueType. [The old FontForge docs have a brief explanation](http://fontforge.github.io/overview.html#Hints). But the point is, hinting is about fitting the glyph onto a square grid, so that beams cover a whole pixel, so you don't get jaggies or blur. Reorienting the square grid obviously invalidates the hints.  
> **username_0**: @username_1 Ok, that makes sense. I would need a separate set of hints for each orientation since which parts of a glyph become beams is in part derived from orientation. Guess I'll have to ask the design department to make a font for each orientation they want to show ;-) Really though, I'll have to look closer at alternative solutions such as SDF. Thanks again.  

---

## 0 answers

