From: Ingo Ruhnke Date: Mon, 7 Dec 2009 18:17:43 +0000 (+0000) Subject: Changed Font code to use glyph.offset, instead of Rect() for variable width fonts... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=33eb93bd79322ef35fd0112373bbe5000342bdbe;p=supertux.git Changed Font code to use glyph.offset, instead of Rect() for variable width fonts, as using Rect leads to shadows being cut off SVN-Revision: 6197 --- diff --git a/TODO b/TODO index bf9d4a55f..9250d4373 100644 --- a/TODO +++ b/TODO @@ -186,9 +186,6 @@ drivers = oss * add a (border #t) flag to fonts, that allows to use fonts which have a 1px transparent border around glyphs, which is needed to get rid of blending artifacts in OpenGL - -* Change Font code to use glyph.offset, instead of Rect() for variable - width fonts, as using Rect leads to shadows being cut off Scenegraph and Physics Engine Restructuring =========================================== diff --git a/src/video/font.cpp b/src/video/font.cpp index 99b425e41..b7562faed 100644 --- a/src/video/font.cpp +++ b/src/video/font.cpp @@ -197,12 +197,14 @@ Font::loadFontSurface( Glyph glyph; glyph.surface_idx = surface_idx; - if( glyph_width == FIXED ) { + if( glyph_width == FIXED ) + { glyph.rect = Rectf(x, y, x + char_width, y + char_height); glyph.offset = Vector(0, 0); glyph.advance = char_width; } - else { + else + { int left = x; while (left < x + char_width && vline_empty(surface, left, y, y + char_height, 64)) left += 1; @@ -210,13 +212,18 @@ Font::loadFontSurface( while (right > left && vline_empty(surface, right, y, y + char_height, 64)) right -= 1; - if (left <= right) - glyph.rect = Rectf(left, y, right+1, y + char_height); - else // glyph is completely transparent - glyph.rect = Rectf(x, y, x + char_width, y + char_height); - - glyph.offset = Vector(0, 0); - glyph.advance = glyph.rect.get_width() + 1; // FIXME: might be useful to make spacing configurable + if (left <= right) + { + glyph.offset = Vector(x-left, 0); + glyph.advance = right - left + 1 + 1; // FIXME: might be useful to make spacing configurable + } + else + { // glyph is completly transparent + glyph.offset = Vector(0, 0); + glyph.advance = char_width + 1; // FIXME: might be useful to make spacing configurable + } + + glyph.rect = Rectf(x, y, x + char_width, y + char_height); } glyphs[*chr] = glyph;