diff options
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | dw/fltkplatform.cc | 16 | ||||
-rw-r--r-- | dw/fltkviewbase.cc | 19 | ||||
-rw-r--r-- | src/cssparser.cc | 2 |
4 files changed, 34 insertions, 5 deletions
@@ -35,6 +35,8 @@ dillo-2.2 [??] - Added 'save' key action (not bound by default). - Tooltips Patches: corvid ++- Support for the letter-spacing property. + Patch: Johannes Hofmann, corvid ----------------------------------------------------------------------------- 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) diff --git a/dw/fltkviewbase.cc b/dw/fltkviewbase.cc index 7969665f..97a78edb 100644 --- a/dw/fltkviewbase.cc +++ b/dw/fltkviewbase.cc @@ -479,8 +479,23 @@ void FltkWidgetView::drawText (core::style::Font *font, FltkFont *ff = (FltkFont*)font; setfont(ff->font, ff->size); setcolor(((FltkColor*)color)->colors[shading]); - drawtext(text, len, - translateCanvasXToViewX (x), translateCanvasYToViewY (y)); + + if (!font->letterSpacing) { + drawtext(text, len, + translateCanvasXToViewX (x), translateCanvasYToViewY (y)); + } else { + /* Nonzero letter spacing adjustment, draw each glyph individually */ + int viewX = translateCanvasXToViewX (x), + viewY = translateCanvasYToViewY (y); + int curr = 0, next = 0; + + while (next < len) { + next = theLayout->nextGlyph(text, curr); + drawtext(text + curr, next - curr, viewX, viewY); + viewX += font->letterSpacing + (int)getwidth(text + curr,next - curr); + curr = next; + } + } } void FltkWidgetView::drawImage (core::Imgbuf *imgbuf, int xRoot, int yRoot, diff --git a/src/cssparser.cc b/src/cssparser.cc index 39643149..932326d4 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -153,7 +153,7 @@ const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST] = { Css_font_weight_enum_vals}, {"height", {CSS_TYPE_LENGTH_PERCENTAGE, CSS_TYPE_UNUSED}, NULL}, {"left", {CSS_TYPE_UNUSED}, NULL}, - {"letter-spacing", {CSS_TYPE_ENUM, CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, + {"letter-spacing", {CSS_TYPE_ENUM, CSS_TYPE_SIGNED_LENGTH, CSS_TYPE_UNUSED}, Css_letter_spacing_enum_vals}, {"line-height", {CSS_TYPE_UNUSED}, NULL}, {"list-style-image", {CSS_TYPE_UNUSED}, NULL}, |