A way to get a cyrillic character's shape

Hi Guys,

Font font = Font( "Lemon Tuesday", 30 );
Shape2d glyphShape = font.getGlyphShape( font.getGlyphChar( 'ั†' ) );

Throws a Character too large for enclosing character literal type compilation error.

The Font#getGlyphChar( **char** utf8Char ) **const** ;

seems to suggest that I could pass a utf8Char, however the type of this variable is just a char.

I would appreciate it if somebody showed me a way to get the shape of the utf character.

Thanks.

Hmm, not sure if that is a small oversight in the API, or perhaps itโ€™s a holdover from some old lowest common denominator platform support or something, but i was able to get that glyph data by being a bit cheeky with one of the other Glyph retrieval APIs.

Font::Glyph glyph = font.getGlyphs( "ั†" )[0];
Shape2d glyphShape = font.getGlyphShape( glyph );

Seems icky so comes with no warranty but it seemed to work for this case.

1 Like

Thanks @lithium, thanks. I also found this a workaround

    std::vector<uint16_t>  glyphs = mFont.getGlyphs( "ะขะžะ›ะกะขะžะ™" );
    size_t glyphIndex = rand() % glyphs.size();
    try {
        Shape2d glyphShape = mFont.getGlyphShape( glyphs[glyphIndex]);

which solves the problem, that it seems lays in the way how a code source encodes characters like โ€˜ั†โ€™ in the example above, although, in XCode, the source code encoding is set to utf8.