for one, there is no glyph width for spaces. this throws off the calculation of the line width. is there any quick way to calculate this?
Yes, space has no width in some fonts. But you must use the
advance member of the glyphs, not the width. That will solve almost all your problems, but not all: for other whitespace glyphs (vertical and horizontal tab, new line) you must handle them manually. Have a look at the source code of sf::Text if you need some inspiration.
also, does the glyph not include whitespace between characters? this may affect the line calculation as well.
Again, use the advance, not the width
Note that you should also use the kerning to get the same result as in sf::Text.
lastly, what number does the iterator start at to access the string contents via string.operator[]? i started at 0, and it seems to not count the first letter.
It should start at 0.
I know that playing with fonts and glyphs directly can be tedious, and I'd like to write a simple wrapper to ease this kind of calculations; like a glyph iterator that would automatically calculate the glyphs positions in the final text. But, you know, there are so many other things to do...