Hi All,
I’m working on inline styling with the Cinder-SdfText block (Paul’s fork) and am running into issues where measureStringImpl() returns inconsistent results for trailing spaces. It seems that whenever there is a trailing space, it gets clipped, but not entirely trimmed since it still adds a few pixels.
I tried isolating the issue and it appears that results coming from measureGlyphs() are consistent, and that measureStringImpl() is the place where the last space measurements are changed.
I’m not a typography expert and am not 100% sure what the different measurement stages are for, but tried isolating things in a simple test case. I logged out the width of the measured Rectf as characters were added to the same SdfText instance:
|debug | cinder::gl::SdfText::measureStringImpl[2427] "a": 14.835000
|debug | cinder::gl::SdfText::measureStringImpl[2427] "a ": 16.334991
|debug | cinder::gl::SdfText::measureStringImpl[2427] "a ": 23.054993
|debug | cinder::gl::SdfText::measureStringImpl[2427] "a ": 29.774994
|debug | cinder::gl::SdfText::measureStringImpl[2427] "a ": 36.494995
|debug | cinder::gl::SdfText::measureStringImpl[2427] "a a": 56.174995
So measurements are basically:
- Single
a:14.835 - Trailing space:
1.499991 - Non-trailing space:
6.720001 - Trailing
a:19.68
The trailing a wider than the single a, but the difference doesn’t add up to the same difference as between trailing and non-trailing spaces (4.845 difference between the as, but 5.22001 between the spaces).
Can anybody here shed some light on what might be happening? Is this a kerning issue and I’m chasing a red herring or is there a way to force SdfText to consistently measure trailing spaces?
Thanks!
Ben