I've written the following little function to tell me how many lines a piece of text will wrap to for a given pixel width window. This works fine for English text and most other Latin character sets (Spanish, French, German), but when I use it to count lines in Russian (Cyrillic alphabet) it seems to tell me about twice the number of lines it actually displays on the screen.
Code: Select all
int getWrappedTextLineCount(const CEGUI::String &text, const CEGUI::Font *font, const float width, const CEGUI::Window *ref_wnd)
{
CEGUI::RenderedStringTextComponent rstc(text);
rstc.setFont(font);
CEGUI::RenderedString rs;
rs.appendComponent(rstc);
CEGUI::RenderedStringWordWrapper<CEGUI::LeftAlignedRenderedString> rsww(rs);
rsww.format(ref_wnd, CEGUI::Sizef(width, 999999));
return rsww.getFormattedLineCount();
}
The font I'm using is Google's "NotoSansCJK", and as I said, it displays correctly on screen when displayed in the CEGUI window, so it's probably most likely that I've got something wrong in the function above as clearly CEGUI "can" get the metrics right for it. Just struggling a bit with this and would love some input.
Any help is most appreciated!