Get glyphs aligned on Windows


#1

Hey Embers,

I have a feeling that the answer to the question I’m about to ask is a simple no, but I figure it can’t hurt to ask.

On a recent thread I asked how render 3d text. I rely on the glyph placements provided by Cinder to properly place the individually rendered Shape2D objects I can get from the glyphs. Specifically, the getGlyphPlacementsWrapped() from the TextureFont object works quite well, despite Cinder comments indicating it’s for Mac and iOs only?

However, it’s not possible to change the overall alignment on the wrapped text via this approach.

I thought I could perhaps also rely on Cinder to help me align the glyphs. The TextBox class allows one to align the text and has a function entitled measureGlyphs() which according to the comments in Cinders code also does not support wrapping on windows. While it seems to wrap fine, the glyph placements do not appear to align any other way than left.

Just wondering if someone had any bright ideas to get Cinder to help here?

Cheers,
Gazoo


#2

i’m not sure i can help but do you have any screenshots of what you are getting with maybe a reference of what you are trying to achieve?


#3

The FreeType font library is built into Cinder. You can use it to retrieve font and glyph information. And then you can use that information to position your glyphs. It’s quite a lot of work, though, to get it right.

You could also rely on HarfBuzz to do the glyph positioning (also called text shaping). This is probably the most professional open source option.

Finally, you could try to harness the native OS’s power. In the case of Microsoft, the system component is called DirectWrite. It replaces FreeType and HarfBuzz, but is not easy to use together with OpenGL. The brief research I did on it showed that you can not access glyph information like in FreeType. Instead, you give it a string and it will call a callback function to render the text.

-Paul