diff options
author | corvid <corvid@lavabit.com> | 2009-10-18 01:36:19 +0000 |
---|---|---|
committer | corvid <corvid@lavabit.com> | 2009-10-18 01:36:19 +0000 |
commit | 2a77f76cbd4d6136953893437d67fe752a751361 (patch) | |
tree | 9b137430dc44abec750cb434679324ee278a908b /dw/fltkplatform.cc | |
parent | a37f4d8c45f82a8d17b830ab7a4abfb8b137b0ef (diff) |
use letter spacing when drawing
Diffstat (limited to 'dw/fltkplatform.cc')
-rw-r--r-- | dw/fltkplatform.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc index e36c073a..56a73a19 100644 --- a/dw/fltkplatform.cc +++ b/dw/fltkplatform.cc @@ -65,7 +65,7 @@ FltkFont::FltkFont (core::style::FontAttrs *attrs) } setfont(font, size); - spaceWidth = (int)getwidth(" "); + spaceWidth = misc::max(0, (int)getwidth(" ") + letterSpacing); int xw, xh; measure("x", xw, xh); xHeight = xh; @@ -349,9 +349,21 @@ void FltkPlatform::detachView (core::View *view) int FltkPlatform::textWidth (core::style::Font *font, const char *text, int len) { + int width; FltkFont *ff = (FltkFont*) font; setfont (ff->font, ff->size); - return (int) getwidth (text, len); + width = (int) getwidth (text, len); + + if (font->letterSpacing) { + int curr = 0, next = 0; + + while (next < len) { + next = nextGlyph(text, curr); + width += font->letterSpacing; + curr = next; + } + } + return width; } int FltkPlatform::nextGlyph (const char *text, int idx) |