Strategies for background-thread text rendering

Since the jassert in Font::getGlyphPositions() it isn’t possible to draw text on a image without locking the MessageManagerLock.

I can’t use the MML for several reasons, what are possible alternatives to draw text on a background thread?

just skip the call to Font::getGlyphPositions:

Array<int> pos;
Array<int> xOffsets;
Font f;
String text = "hello";
f.getTypeface()->getGlyphPositions (text, pos, xOffsets);
Path p;
f.getTypeface()->getOutlineForGlyphs(pos[0], p); //store the outline for 'h' in Path p;

Hi makatmusic,

thanks! Unfortunately there is no getOutlineForGlyphs function, only getOutlineForGlyph.
I tried to reconstruct functionality from the juce classes, to allow simple text-rendering, but it seems much more complicated then i thought.

…also it seems the functionally already exists, for example in the CustomFont rendering classes (Is there anyway to use them with build-In fonts?)

Any help appreciated…

Did you ever find a solution for this? We’re bumping up against this issue again.

To summarize for anyone else who finds this:

As far as I know, it is currently not possible (at least not straightforwardly) to render 60 fps (or faster) text animations in JUCE.

This is because rendering text on a background thread in JUCE requires the message thread to be locked (specifically for getGlyphPositions() ). Locking the OpenGL thread, though, can cause deadlocks (see Another OpenGL deadlock thread) and other issues, and is generally fairly detrimental for performance/framerate, especially with multiple windows running.

1 Like