Closed paulhoux closed 8 years ago
const vec2 kOffset = vec2( 0 );
const gl::SdfText::DrawOptions kOptions = gl::SdfText::DrawOptions().alignment( gl::SdfText::CENTER );
mSdfText->drawStringWrapped( mText, mBounds, kOffset, kOptions );
Right without and with adjustment:
Center without and with adjustment.
This is awesome! Thanks so much @paulhoux!
On the right with adjustment - the period renders outside the bounds, is that intentional?
Algorithm calculates offset per line during drawing and then shifts all characters on that line. This is faster than measuring the text twice. For "perfect" alignment, we now also take the exact glyph bounds into account (see: https://www.freetype.org/freetype2/docs/glyphs/glyphs-3.html). The bounds are saved to the SDFT file. Note that your old SDFT files will no longer work.