diff options
author | corvid <corvid@lavabit.com> | 2011-10-25 20:30:06 +0000 |
---|---|---|
committer | corvid <corvid@lavabit.com> | 2011-10-25 20:30:06 +0000 |
commit | 37e403c6422091c5e0a8c54d94a2e176509bde3a (patch) | |
tree | 0df4132419229664e109138c0e77f66dc13246e2 /dw/fltkviewbase.cc | |
parent | 789bccfa3ea03a59d1e1262ff7b6ddbf362697e7 (diff) |
fix letter-spacing with combining characters
Diffstat (limited to 'dw/fltkviewbase.cc')
-rw-r--r-- | dw/fltkviewbase.cc | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/dw/fltkviewbase.cc b/dw/fltkviewbase.cc index bf3aba22..d2a61ae5 100644 --- a/dw/fltkviewbase.cc +++ b/dw/fltkviewbase.cc @@ -548,7 +548,7 @@ void FltkWidgetView::drawText (core::style::Font *font, viewY = translateCanvasYToViewY (Y); int curr = 0, next = 0, nb; char chbuf[4]; - int c, cu; + int c, cu, width; if (font->fontVariant == core::style::FONT_VARIANT_SMALL_CAPS) { int sc_fontsize = lout::misc::roundInt(ff->size * 0.78); @@ -558,24 +558,30 @@ void FltkWidgetView::drawText (core::style::Font *font, if ((cu = fl_toupper(c)) == c) { /* already uppercase, just draw the character */ fl_font(ff->font, ff->size); + width = (int)fl_width(text + curr, next - curr); + if (curr && width) + viewX += font->letterSpacing; fl_draw(text + curr, next - curr, viewX, viewY); - viewX += font->letterSpacing; - viewX += (int)fl_width(text + curr, next - curr); + viewX += width; } else { /* make utf8 string for converted char */ nb = fl_utf8encode(cu, chbuf); fl_font(ff->font, sc_fontsize); + width = (int)fl_width(text + curr, next - curr); + if (curr && width) + viewX += font->letterSpacing; fl_draw(chbuf, nb, viewX, viewY); - viewX += font->letterSpacing; - viewX += (int)fl_width(chbuf, nb); + viewX += width; } } } else { while (next < len) { next = theLayout->nextGlyph(text, curr); + width = (int)fl_width(text + curr, next - curr); + if (curr && width) + viewX += font->letterSpacing; fl_draw(text + curr, next - curr, viewX, viewY); - viewX += font->letterSpacing + - (int)fl_width(text + curr,next - curr); + viewX += width; curr = next; } } |