mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r21006) -Fix (r21004): don't print the text direction character when ICU isn't linked and thus doesn't remove them
This commit is contained in:
parent
2d64b482ba
commit
b933819b0b
12
src/gfx.cpp
12
src/gfx.cpp
|
@ -380,7 +380,7 @@ static int TruncateString(char *str, int maxw, bool ignore_setxy, FontSize start
|
|||
ddd_w = ddd = GetCharacterWidth(size, '.') * 3;
|
||||
|
||||
for (ddd_pos = str; (c = Utf8Consume(const_cast<const char **>(&str))) != '\0'; ) {
|
||||
if (IsPrintable(c)) {
|
||||
if (IsPrintable(c) && !IsTextDirectionChar(c)) {
|
||||
w += GetCharacterWidth(size, c);
|
||||
|
||||
if (w > maxw) {
|
||||
|
@ -437,7 +437,7 @@ static int GetStringWidth(const UChar *str, FontSize start_fontsize)
|
|||
for (;;) {
|
||||
c = *str++;
|
||||
if (c == 0) break;
|
||||
if (IsPrintable(c)) {
|
||||
if (IsPrintable(c) && !IsTextDirectionChar(c)) {
|
||||
width += GetCharacterWidth(size, c);
|
||||
} else {
|
||||
switch (c) {
|
||||
|
@ -687,7 +687,7 @@ uint32 FormatStringLinebreaks(char *str, const char *last, int maxw, FontSize si
|
|||
/* whitespace is where we will insert the line-break */
|
||||
if (IsWhitespace(c)) last_space = str;
|
||||
|
||||
if (IsPrintable(c)) {
|
||||
if (IsPrintable(c) && !IsTextDirectionChar(c)) {
|
||||
int char_w = GetCharacterWidth(size, c);
|
||||
w += char_w;
|
||||
if (w > maxw) {
|
||||
|
@ -982,7 +982,7 @@ Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
|
|||
for (;;) {
|
||||
c = Utf8Consume(&str);
|
||||
if (c == 0) break;
|
||||
if (IsPrintable(c)) {
|
||||
if (IsPrintable(c) && !IsTextDirectionChar(c)) {
|
||||
br.width += GetCharacterWidth(size, c);
|
||||
} else {
|
||||
switch (c) {
|
||||
|
@ -1081,7 +1081,7 @@ skip_cont:;
|
|||
if (c == 0) {
|
||||
return x; // Nothing more to draw, get out. And here is the new x position
|
||||
}
|
||||
if (IsPrintable(c)) {
|
||||
if (IsPrintable(c) && !IsTextDirectionChar(c)) {
|
||||
if (x >= dpi->left + dpi->width) goto skip_char;
|
||||
if (x + _max_char_width >= dpi->left) {
|
||||
GfxMainBlitter(GetGlyph(params.fontsize, c), x, y, BM_COLOUR_REMAP);
|
||||
|
@ -1104,7 +1104,7 @@ skip_cont:;
|
|||
params.SetFontSize(FS_SMALL);
|
||||
} else if (c == SCC_BIGFONT) { // {BIGFONT}
|
||||
params.SetFontSize(FS_LARGE);
|
||||
} else {
|
||||
} else if (!IsTextDirectionChar(c)) {
|
||||
DEBUG(misc, 0, "[utf8] unknown string command character %d", c);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,6 +224,28 @@ static inline char *Utf8PrevChar(char *s)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the given character a text direction character.
|
||||
* @param c The character to test.
|
||||
* @return true iff the character is used to influence
|
||||
* the text direction.
|
||||
*/
|
||||
static inline bool IsTextDirectionChar(WChar c)
|
||||
{
|
||||
switch (c) {
|
||||
case CHAR_TD_LRM:
|
||||
case CHAR_TD_RLM:
|
||||
case CHAR_TD_LRE:
|
||||
case CHAR_TD_RLE:
|
||||
case CHAR_TD_LRO:
|
||||
case CHAR_TD_RLO:
|
||||
case CHAR_TD_PDF:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool IsPrintable(WChar c)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue