mirror of https://github.com/OpenTTD/OpenTTD
(svn r21006) -Fix (r21004): don't print the text direction character when ICU isn't linked and thus doesn't remove them
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;
|
ddd_w = ddd = GetCharacterWidth(size, '.') * 3;
|
||||||
|
|
||||||
for (ddd_pos = str; (c = Utf8Consume(const_cast<const char **>(&str))) != '\0'; ) {
|
for (ddd_pos = str; (c = Utf8Consume(const_cast<const char **>(&str))) != '\0'; ) {
|
||||||
if (IsPrintable(c)) {
|
if (IsPrintable(c) && !IsTextDirectionChar(c)) {
|
||||||
w += GetCharacterWidth(size, c);
|
w += GetCharacterWidth(size, c);
|
||||||
|
|
||||||
if (w > maxw) {
|
if (w > maxw) {
|
||||||
|
@ -437,7 +437,7 @@ static int GetStringWidth(const UChar *str, FontSize start_fontsize)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
c = *str++;
|
c = *str++;
|
||||||
if (c == 0) break;
|
if (c == 0) break;
|
||||||
if (IsPrintable(c)) {
|
if (IsPrintable(c) && !IsTextDirectionChar(c)) {
|
||||||
width += GetCharacterWidth(size, c);
|
width += GetCharacterWidth(size, c);
|
||||||
} else {
|
} else {
|
||||||
switch (c) {
|
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 */
|
/* whitespace is where we will insert the line-break */
|
||||||
if (IsWhitespace(c)) last_space = str;
|
if (IsWhitespace(c)) last_space = str;
|
||||||
|
|
||||||
if (IsPrintable(c)) {
|
if (IsPrintable(c) && !IsTextDirectionChar(c)) {
|
||||||
int char_w = GetCharacterWidth(size, c);
|
int char_w = GetCharacterWidth(size, c);
|
||||||
w += char_w;
|
w += char_w;
|
||||||
if (w > maxw) {
|
if (w > maxw) {
|
||||||
|
@ -982,7 +982,7 @@ Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
c = Utf8Consume(&str);
|
c = Utf8Consume(&str);
|
||||||
if (c == 0) break;
|
if (c == 0) break;
|
||||||
if (IsPrintable(c)) {
|
if (IsPrintable(c) && !IsTextDirectionChar(c)) {
|
||||||
br.width += GetCharacterWidth(size, c);
|
br.width += GetCharacterWidth(size, c);
|
||||||
} else {
|
} else {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -1081,7 +1081,7 @@ skip_cont:;
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
return x; // Nothing more to draw, get out. And here is the new x position
|
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 >= dpi->left + dpi->width) goto skip_char;
|
||||||
if (x + _max_char_width >= dpi->left) {
|
if (x + _max_char_width >= dpi->left) {
|
||||||
GfxMainBlitter(GetGlyph(params.fontsize, c), x, y, BM_COLOUR_REMAP);
|
GfxMainBlitter(GetGlyph(params.fontsize, c), x, y, BM_COLOUR_REMAP);
|
||||||
|
@ -1104,7 +1104,7 @@ skip_cont:;
|
||||||
params.SetFontSize(FS_SMALL);
|
params.SetFontSize(FS_SMALL);
|
||||||
} else if (c == SCC_BIGFONT) { // {BIGFONT}
|
} else if (c == SCC_BIGFONT) { // {BIGFONT}
|
||||||
params.SetFontSize(FS_LARGE);
|
params.SetFontSize(FS_LARGE);
|
||||||
} else {
|
} else if (!IsTextDirectionChar(c)) {
|
||||||
DEBUG(misc, 0, "[utf8] unknown string command character %d", c);
|
DEBUG(misc, 0, "[utf8] unknown string command character %d", c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,6 +224,28 @@ static inline char *Utf8PrevChar(char *s)
|
||||||
return ret;
|
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)
|
static inline bool IsPrintable(WChar c)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue