I am trying to predict how wide the text will appear rendered by pango library but I am trying to achieve it in bare Freetype for performance sake.

To answer the commenters - yes I measured performance with the callgrind tool. And pango is spending most of its time in fontconfig, which is impossible to work around. The pango_layout_get_extents is also not terribly fast. Meanwhile freetype's performance is blazingly fast - yet results inaccurate due to lack of proper settings perhaps. Unfortunately I am unable to post rendered bitmaps since I do only plain measurements - but it might be a worthwhile endeavour to implement is for comparison's sake. The rendering in my use case is done by a web browser in SVG and my only need is to predict what length the rendered text will be - hence not providing bitmaps in the question since I have no rendering code.

Post images showing the text rendered by both methods. I'm guessing kerning. Are you sure there is a performance difference? Are you sure it matters for you? Did you measure?
–
Jacob ParkerMar 16 '13 at 22:00

2

As an aside, you should be aware that FreeType alone is not capable of correct text rendering, since it requires as input a sequence of glyphs, not a sequence of characters. You'll at least need harfbuzz to convert character strings to glyph strings for you. It's possible that the discrepency has something to do with this, e.g. if the font in question has ligatures for some of the character sequences contained in your string.
–
R..Mar 17 '13 at 0:14

Thanks for comments. As you see you I am trying to actually apply kerning. I have answered your comments in the question itself. I just read about harfbuzz - wouldn't it be an overkill for latin languages? As for the glyphs - FT_Get_Char_Index covers that. For 7-bit ASCII the char matches the UTF-32 which this function requires.
–
RushPLMar 17 '13 at 8:44

If you are worried about performance before you can even draw the text you are putting the cart before the horse. If you render the text you can see for yourself why the width is different and others can give tips. This is debugging 101.
–
Jacob ParkerMar 17 '13 at 13:48

With all due respect, you don't know about my use case - but for your information, rendering will not be done by me but by clients' machines. I would have written rendering code if I needed one but if I don't find a solution I will have to write it anyway (and scrap it).
–
RushPLMar 17 '13 at 20:21