From 2a77f76cbd4d6136953893437d67fe752a751361 Mon Sep 17 00:00:00 2001 From: corvid Date: Sun, 18 Oct 2009 01:36:19 +0000 Subject: use letter spacing when drawing --- dw/fltkplatform.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'dw/fltkplatform.cc') 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) -- cgit v1.2.3