mirror of https://github.com/OpenTTD/OpenTTD
(svn r27367) -Codechange: make a distinction between the layouting part of ICU (lx) or the sorting/collation part of ICU (i18n)
parent
bdf090b406
commit
69fac508c3
|
@ -1754,7 +1754,7 @@ make_cflags_and_ldflags() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$icu_config" ]; then
|
if [ -n "$icu_config" ]; then
|
||||||
CFLAGS="$CFLAGS -DWITH_ICU"
|
CFLAGS="$CFLAGS -DWITH_ICU_LAYOUT -DWITH_ICU_SORT"
|
||||||
CFLAGS="$CFLAGS `$icu_config --cppflags | tr '\n\r' ' '`"
|
CFLAGS="$CFLAGS `$icu_config --cppflags | tr '\n\r' ' '`"
|
||||||
|
|
||||||
# Some icu-configs have the 'feature' of not adding a space where others do add the space
|
# Some icu-configs have the 'feature' of not adding a space where others do add the space
|
||||||
|
|
|
@ -196,9 +196,9 @@ char *CrashLog::LogConfiguration(char *buffer, const char *last) const
|
||||||
# include <ft2build.h>
|
# include <ft2build.h>
|
||||||
# include FT_FREETYPE_H
|
# include FT_FREETYPE_H
|
||||||
#endif /* WITH_FREETYPE */
|
#endif /* WITH_FREETYPE */
|
||||||
#ifdef WITH_ICU
|
#if defined(WITH_ICU_LAYOUT) || defined(WITH_ICU_SORT)
|
||||||
# include <unicode/uversion.h>
|
# include <unicode/uversion.h>
|
||||||
#endif /* WITH_ICU */
|
#endif /* WITH_ICU_SORT || WITH_ICU_LAYOUT */
|
||||||
#ifdef WITH_LZMA
|
#ifdef WITH_LZMA
|
||||||
# include <lzma.h>
|
# include <lzma.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -241,14 +241,19 @@ char *CrashLog::LogLibraries(char *buffer, const char *last) const
|
||||||
buffer += seprintf(buffer, last, " FreeType: %d.%d.%d\n", major, minor, patch);
|
buffer += seprintf(buffer, last, " FreeType: %d.%d.%d\n", major, minor, patch);
|
||||||
#endif /* WITH_FREETYPE */
|
#endif /* WITH_FREETYPE */
|
||||||
|
|
||||||
#ifdef WITH_ICU
|
#if defined(WITH_ICU_LAYOUT) || defined(WITH_ICU_SORT)
|
||||||
/* 4 times 0-255, separated by dots (.) and a trailing '\0' */
|
/* 4 times 0-255, separated by dots (.) and a trailing '\0' */
|
||||||
char buf[4 * 3 + 3 + 1];
|
char buf[4 * 3 + 3 + 1];
|
||||||
UVersionInfo ver;
|
UVersionInfo ver;
|
||||||
u_getVersion(ver);
|
u_getVersion(ver);
|
||||||
u_versionToString(ver, buf);
|
u_versionToString(ver, buf);
|
||||||
buffer += seprintf(buffer, last, " ICU: %s\n", buf);
|
#ifdef WITH_ICU_SORT
|
||||||
#endif /* WITH_ICU */
|
buffer += seprintf(buffer, last, " ICU i18n: %s\n", buf);
|
||||||
|
#endif
|
||||||
|
#ifdef WITH_ICU_LAYOUT
|
||||||
|
buffer += seprintf(buffer, last, " ICU lx: %s\n", buf);
|
||||||
|
#endif
|
||||||
|
#endif /* WITH_ICU_SORT || WITH_ICU_LAYOUT */
|
||||||
|
|
||||||
#ifdef WITH_LZMA
|
#ifdef WITH_LZMA
|
||||||
buffer += seprintf(buffer, last, " LZMA: %s\n", lzma_version_string());
|
buffer += seprintf(buffer, last, " LZMA: %s\n", lzma_version_string());
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
|
|
||||||
#include "table/control_codes.h"
|
#include "table/control_codes.h"
|
||||||
|
|
||||||
#ifdef WITH_ICU
|
#ifdef WITH_ICU_LAYOUT
|
||||||
#include <unicode/ustring.h>
|
#include <unicode/ustring.h>
|
||||||
#endif /* WITH_ICU */
|
#endif /* WITH_ICU_LAYOUT */
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ Font::Font(FontSize size, TextColour colour) :
|
||||||
assert(size < FS_END);
|
assert(size < FS_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_ICU
|
#ifdef WITH_ICU_LAYOUT
|
||||||
/* Implementation details of LEFontInstance */
|
/* Implementation details of LEFontInstance */
|
||||||
|
|
||||||
le_int32 Font::getUnitsPerEM() const
|
le_int32 Font::getUnitsPerEM() const
|
||||||
|
@ -213,7 +213,7 @@ static ParagraphLayouter *GetParagraphLayout(UChar *buff, UChar *buff_end, FontM
|
||||||
return new ICUParagraphLayout(p);
|
return new ICUParagraphLayout(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* WITH_ICU */
|
#endif /* WITH_ICU_LAYOUT */
|
||||||
|
|
||||||
/*** Paragraph layout ***/
|
/*** Paragraph layout ***/
|
||||||
/**
|
/**
|
||||||
|
@ -654,7 +654,7 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
|
||||||
line.layout->Reflow();
|
line.layout->Reflow();
|
||||||
} else {
|
} else {
|
||||||
/* Line is new, layout it */
|
/* Line is new, layout it */
|
||||||
#ifdef WITH_ICU
|
#ifdef WITH_ICU_LAYOUT
|
||||||
FontState old_state = state;
|
FontState old_state = state;
|
||||||
const char *old_str = str;
|
const char *old_str = str;
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,12 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#ifdef WITH_ICU
|
#ifdef WITH_ICU_LAYOUT
|
||||||
#include "layout/ParagraphLayout.h"
|
#include "layout/ParagraphLayout.h"
|
||||||
#define ICU_FONTINSTANCE : public LEFontInstance
|
#define ICU_FONTINSTANCE : public LEFontInstance
|
||||||
#else /* WITH_ICU */
|
#else /* WITH_ICU_LAYOUT */
|
||||||
#define ICU_FONTINSTANCE
|
#define ICU_FONTINSTANCE
|
||||||
#endif /* WITH_ICU */
|
#endif /* WITH_ICU_LAYOUT */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Text drawing parameters, which can change while drawing a line, but are kept between multiple parts
|
* Text drawing parameters, which can change while drawing a line, but are kept between multiple parts
|
||||||
|
@ -75,7 +75,7 @@ public:
|
||||||
|
|
||||||
Font(FontSize size, TextColour colour);
|
Font(FontSize size, TextColour colour);
|
||||||
|
|
||||||
#ifdef WITH_ICU
|
#ifdef WITH_ICU_LAYOUT
|
||||||
/* Implementation details of LEFontInstance */
|
/* Implementation details of LEFontInstance */
|
||||||
|
|
||||||
le_int32 getUnitsPerEM() const;
|
le_int32 getUnitsPerEM() const;
|
||||||
|
@ -91,7 +91,7 @@ public:
|
||||||
LEGlyphID mapCharToGlyph(LEUnicode32 ch) const;
|
LEGlyphID mapCharToGlyph(LEUnicode32 ch) const;
|
||||||
void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
|
void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
|
||||||
le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const;
|
le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const;
|
||||||
#endif /* WITH_ICU */
|
#endif /* WITH_ICU_LAYOUT */
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Mapping from index to font. */
|
/** Mapping from index to font. */
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
#define LANGUAGE_H
|
#define LANGUAGE_H
|
||||||
|
|
||||||
#include "core/smallvec_type.hpp"
|
#include "core/smallvec_type.hpp"
|
||||||
#ifdef WITH_ICU
|
#ifdef WITH_ICU_SORT
|
||||||
#include <unicode/coll.h>
|
#include <unicode/coll.h>
|
||||||
#endif /* WITH_ICU */
|
#endif /* WITH_ICU_SORT */
|
||||||
|
|
||||||
static const uint8 CASE_GENDER_LEN = 16; ///< The (maximum) length of a case/gender string.
|
static const uint8 CASE_GENDER_LEN = 16; ///< The (maximum) length of a case/gender string.
|
||||||
static const uint8 MAX_NUM_GENDERS = 8; ///< Maximum number of supported genders.
|
static const uint8 MAX_NUM_GENDERS = 8; ///< Maximum number of supported genders.
|
||||||
|
@ -110,9 +110,9 @@ extern LanguageList _languages;
|
||||||
/** The currently loaded language. */
|
/** The currently loaded language. */
|
||||||
extern const LanguageMetadata *_current_language;
|
extern const LanguageMetadata *_current_language;
|
||||||
|
|
||||||
#ifdef WITH_ICU
|
#ifdef WITH_ICU_SORT
|
||||||
extern Collator *_current_collator;
|
extern Collator *_current_collator;
|
||||||
#endif /* WITH_ICU */
|
#endif /* WITH_ICU_SORT */
|
||||||
|
|
||||||
bool ReadLanguagePack(const LanguageMetadata *lang);
|
bool ReadLanguagePack(const LanguageMetadata *lang);
|
||||||
const LanguageMetadata *GetLanguage(byte newgrflangid);
|
const LanguageMetadata *GetLanguage(byte newgrflangid);
|
||||||
|
|
|
@ -25,12 +25,12 @@
|
||||||
#include <errno.h> // required by vsnprintf implementation for MSVC
|
#include <errno.h> // required by vsnprintf implementation for MSVC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WITH_ICU
|
#ifdef WITH_ICU_SORT
|
||||||
/* Required by strnatcmp. */
|
/* Required by strnatcmp. */
|
||||||
#include <unicode/ustring.h>
|
#include <unicode/ustring.h>
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "gfx_func.h"
|
#include "gfx_func.h"
|
||||||
#endif /* WITH_ICU */
|
#endif /* WITH_ICU_SORT */
|
||||||
|
|
||||||
/* The function vsnprintf is used internally to perform the required formatting
|
/* The function vsnprintf is used internally to perform the required formatting
|
||||||
* tasks. As such this one must be allowed, and makes sure it's terminated. */
|
* tasks. As such this one must be allowed, and makes sure it's terminated. */
|
||||||
|
@ -572,7 +572,7 @@ int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
|
||||||
s1 = SkipGarbage(s1);
|
s1 = SkipGarbage(s1);
|
||||||
s2 = SkipGarbage(s2);
|
s2 = SkipGarbage(s2);
|
||||||
}
|
}
|
||||||
#ifdef WITH_ICU
|
#ifdef WITH_ICU_SORT
|
||||||
if (_current_collator != NULL) {
|
if (_current_collator != NULL) {
|
||||||
UErrorCode status = U_ZERO_ERROR;
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
int result;
|
int result;
|
||||||
|
@ -592,13 +592,13 @@ int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
|
||||||
if (U_SUCCESS(status)) return result;
|
if (U_SUCCESS(status)) return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* WITH_ICU */
|
#endif /* WITH_ICU_SORT */
|
||||||
|
|
||||||
/* Do a normal comparison if ICU is missing or if we cannot create a collator. */
|
/* Do a normal comparison if ICU is missing or if we cannot create a collator. */
|
||||||
return strcasecmp(s1, s2);
|
return strcasecmp(s1, s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_ICU
|
#ifdef WITH_ICU_SORT
|
||||||
|
|
||||||
#include <unicode/utext.h>
|
#include <unicode/utext.h>
|
||||||
#include <unicode/brkiter.h>
|
#include <unicode/brkiter.h>
|
||||||
|
|
|
@ -49,9 +49,9 @@ const LanguageMetadata *_current_language = NULL; ///< The currently loaded lang
|
||||||
|
|
||||||
TextDirection _current_text_dir; ///< Text direction of the currently selected language.
|
TextDirection _current_text_dir; ///< Text direction of the currently selected language.
|
||||||
|
|
||||||
#ifdef WITH_ICU
|
#ifdef WITH_ICU_SORT
|
||||||
Collator *_current_collator = NULL; ///< Collator for the language currently in use.
|
Collator *_current_collator = NULL; ///< Collator for the language currently in use.
|
||||||
#endif /* WITH_ICU */
|
#endif /* WITH_ICU_SORT */
|
||||||
|
|
||||||
static uint64 _global_string_params_data[20]; ///< Global array of string parameters. To access, use #SetDParam.
|
static uint64 _global_string_params_data[20]; ///< Global array of string parameters. To access, use #SetDParam.
|
||||||
static WChar _global_string_params_type[20]; ///< Type of parameters stored in #_decode_parameters
|
static WChar _global_string_params_type[20]; ///< Type of parameters stored in #_decode_parameters
|
||||||
|
@ -1790,7 +1790,7 @@ bool ReadLanguagePack(const LanguageMetadata *lang)
|
||||||
strecpy(_config_language_file, c_file, lastof(_config_language_file));
|
strecpy(_config_language_file, c_file, lastof(_config_language_file));
|
||||||
SetCurrentGrfLangID(_current_language->newgrflangid);
|
SetCurrentGrfLangID(_current_language->newgrflangid);
|
||||||
|
|
||||||
#ifdef WITH_ICU
|
#ifdef WITH_ICU_SORT
|
||||||
/* Delete previous collator. */
|
/* Delete previous collator. */
|
||||||
if (_current_collator != NULL) {
|
if (_current_collator != NULL) {
|
||||||
delete _current_collator;
|
delete _current_collator;
|
||||||
|
@ -1807,7 +1807,7 @@ bool ReadLanguagePack(const LanguageMetadata *lang)
|
||||||
delete _current_collator;
|
delete _current_collator;
|
||||||
_current_collator = NULL;
|
_current_collator = NULL;
|
||||||
}
|
}
|
||||||
#endif /* WITH_ICU */
|
#endif /* WITH_ICU_SORT */
|
||||||
|
|
||||||
/* Some lists need to be sorted again after a language change. */
|
/* Some lists need to be sorted again after a language change. */
|
||||||
ReconsiderGameScriptLanguage();
|
ReconsiderGameScriptLanguage();
|
||||||
|
@ -2132,7 +2132,7 @@ void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
|
||||||
/* Update the font with cache */
|
/* Update the font with cache */
|
||||||
LoadStringWidthTable(searcher->Monospace());
|
LoadStringWidthTable(searcher->Monospace());
|
||||||
|
|
||||||
#if !defined(WITH_ICU)
|
#if !defined(WITH_ICU_LAYOUT)
|
||||||
/*
|
/*
|
||||||
* For right-to-left languages we need the ICU library. If
|
* For right-to-left languages we need the ICU library. If
|
||||||
* we do not have support for that library we warn the user
|
* we do not have support for that library we warn the user
|
||||||
|
@ -2152,5 +2152,5 @@ void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
|
||||||
SetDParamStr(0, err_str);
|
SetDParamStr(0, err_str);
|
||||||
ShowErrorMessage(STR_JUST_RAW_STRING, INVALID_STRING_ID, WL_ERROR);
|
ShowErrorMessage(STR_JUST_RAW_STRING, INVALID_STRING_ID, WL_ERROR);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !WITH_ICU_LAYOUT */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue