summaryrefslogtreecommitdiff
path: root/src/gfx.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-07-01 15:26:27 +0000
committerrubidium <rubidium@openttd.org>2013-07-01 15:26:27 +0000
commit7bc4845aac54eeb12388d7cf256a2c17f8a6cbdc (patch)
tree653cb9390669a5e250e2fd49b2e5b46c3c2649f5 /src/gfx.cpp
parentf4c9ba4981eef3bf9810e4aff0bf59e2d8ddd5e0 (diff)
downloadopenttd-7bc4845aac54eeb12388d7cf256a2c17f8a6cbdc.tar.xz
(svn r25547) -Fix [FS#5626]: ICU returns the width of the visual run as if the trailing space was added (in case a newline was added). This caused the width to be more than the requested width, but it would still be drawn correctly
Diffstat (limited to 'src/gfx.cpp')
-rw-r--r--src/gfx.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp
index 54a851221..7584ff0db 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -370,11 +370,12 @@ static void SetColourRemap(TextColour colour)
* case a right-to-left language is chosen this is inverted so it
* will be drawn in the right direction.
* @param underline Whether to underline what has been drawn or not.
+ * @param truncation Whether to perform string truncation or not.
*
* @return In case of left or center alignment the right most pixel we have drawn to.
* In case of right alignment the left most pixel we have drawn to.
*/
-static int DrawLayoutLine(ParagraphLayout::Line *line, int y, int left, int right, StringAlignment align, bool underline)
+static int DrawLayoutLine(ParagraphLayout::Line *line, int y, int left, int right, StringAlignment align, bool underline, bool truncation)
{
if (line->countRuns() == 0) return 0;
@@ -399,7 +400,7 @@ static int DrawLayoutLine(ParagraphLayout::Line *line, int y, int left, int righ
int min_x = left; // The minimum x position to draw normal glyphs on.
int max_x = right; // The maximum x position to draw normal glyphs on.
- bool truncation = max_w < w; // Whether we need to do truncation.
+ truncation &= max_w < w; // Whether we need to do truncation.
int dot_width = 0; // Cache for the width of the dot.
const Sprite *dot_sprite = NULL; // Cache for the sprite of the dot.
@@ -526,7 +527,7 @@ int DrawString(int left, int right, int top, const char *str, TextColour colour,
Layouter layout(str, INT32_MAX, colour, fontsize);
if (layout.Length() == 0) return 0;
- return DrawLayoutLine(*layout.Begin(), top, left, right, align, underline);
+ return DrawLayoutLine(*layout.Begin(), top, left, right, align, underline, true);
}
/**
@@ -668,7 +669,7 @@ int DrawStringMultiLine(int left, int right, int top, int bottom, const char *st
last_line = y + line_height;
if (first_line > y) first_line = y;
- DrawLayoutLine(line, y, left, right, align, underline);
+ DrawLayoutLine(line, y, left, right, align, underline, false);
}
y += line_height;
}