Changeset - r22187:cbf0305d3db2
[Not reviewed]
master
0 7 0
rubidium - 9 years ago 2015-08-09 12:33:27
rubidium@openttd.org
(svn r27367) -Codechange: make a distinction between the layouting part of ICU (lx) or the sorting/collation part of ICU (i18n)
7 files changed with 36 insertions and 31 deletions:
0 comments (0 inline, 0 general)
config.lib
Show inline comments
 
@@ -1754,7 +1754,7 @@ make_cflags_and_ldflags() {
 
	fi
 

	
 
	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' '  '`"
 

	
 
		# Some icu-configs have the 'feature' of not adding a space where others do add the space
src/crashlog.cpp
Show inline comments
 
@@ -196,9 +196,9 @@ char *CrashLog::LogConfiguration(char *b
 
#	include <ft2build.h>
 
#	include FT_FREETYPE_H
 
#endif /* WITH_FREETYPE */
 
#ifdef WITH_ICU
 
#if defined(WITH_ICU_LAYOUT) || defined(WITH_ICU_SORT)
 
#	include <unicode/uversion.h>
 
#endif /* WITH_ICU */
 
#endif /* WITH_ICU_SORT || WITH_ICU_LAYOUT */
 
#ifdef WITH_LZMA
 
#	include <lzma.h>
 
#endif
 
@@ -241,14 +241,19 @@ char *CrashLog::LogLibraries(char *buffe
 
	buffer += seprintf(buffer, last, " FreeType:   %d.%d.%d\n", major, minor, patch);
 
#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' */
 
	char buf[4 * 3 + 3 + 1];
 
	UVersionInfo ver;
 
	u_getVersion(ver);
 
	u_versionToString(ver, buf);
 
	buffer += seprintf(buffer, last, " ICU:        %s\n", buf);
 
#endif /* WITH_ICU */
 
#ifdef WITH_ICU_SORT
 
	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
 
	buffer += seprintf(buffer, last, " LZMA:       %s\n", lzma_version_string());
src/gfx_layout.cpp
Show inline comments
 
@@ -17,9 +17,9 @@
 

	
 
#include "table/control_codes.h"
 

	
 
#ifdef WITH_ICU
 
#ifdef WITH_ICU_LAYOUT
 
#include <unicode/ustring.h>
 
#endif /* WITH_ICU */
 
#endif /* WITH_ICU_LAYOUT */
 

	
 
#include "safeguards.h"
 

	
 
@@ -42,7 +42,7 @@ Font::Font(FontSize size, TextColour col
 
	assert(size < FS_END);
 
}
 

	
 
#ifdef WITH_ICU
 
#ifdef WITH_ICU_LAYOUT
 
/* Implementation details of LEFontInstance */
 

	
 
le_int32 Font::getUnitsPerEM() const
 
@@ -213,7 +213,7 @@ static ParagraphLayouter *GetParagraphLa
 
	return new ICUParagraphLayout(p);
 
}
 

	
 
#endif /* WITH_ICU */
 
#endif /* WITH_ICU_LAYOUT */
 

	
 
/*** Paragraph layout ***/
 
/**
 
@@ -654,7 +654,7 @@ Layouter::Layouter(const char *str, int 
 
			line.layout->Reflow();
 
		} else {
 
			/* Line is new, layout it */
 
#ifdef WITH_ICU
 
#ifdef WITH_ICU_LAYOUT
 
			FontState old_state = state;
 
			const char *old_str = str;
 

	
src/gfx_layout.h
Show inline comments
 
@@ -19,12 +19,12 @@
 
#include <map>
 
#include <string>
 

	
 
#ifdef WITH_ICU
 
#ifdef WITH_ICU_LAYOUT
 
#include "layout/ParagraphLayout.h"
 
#define ICU_FONTINSTANCE : public LEFontInstance
 
#else /* WITH_ICU */
 
#else /* WITH_ICU_LAYOUT */
 
#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
 
@@ -75,7 +75,7 @@ public:
 

	
 
	Font(FontSize size, TextColour colour);
 

	
 
#ifdef WITH_ICU
 
#ifdef WITH_ICU_LAYOUT
 
	/* Implementation details of LEFontInstance */
 

	
 
	le_int32 getUnitsPerEM() const;
 
@@ -91,7 +91,7 @@ public:
 
	LEGlyphID mapCharToGlyph(LEUnicode32 ch) const;
 
	void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
 
	le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const;
 
#endif /* WITH_ICU */
 
#endif /* WITH_ICU_LAYOUT */
 
};
 

	
 
/** Mapping from index to font. */
src/language.h
Show inline comments
 
@@ -13,9 +13,9 @@
 
#define LANGUAGE_H
 

	
 
#include "core/smallvec_type.hpp"
 
#ifdef WITH_ICU
 
#ifdef WITH_ICU_SORT
 
#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 MAX_NUM_GENDERS =  8; ///< Maximum number of supported genders.
 
@@ -110,9 +110,9 @@ extern LanguageList _languages;
 
/** The currently loaded language. */
 
extern const LanguageMetadata *_current_language;
 

	
 
#ifdef WITH_ICU
 
#ifdef WITH_ICU_SORT
 
extern Collator *_current_collator;
 
#endif /* WITH_ICU */
 
#endif /* WITH_ICU_SORT */
 

	
 
bool ReadLanguagePack(const LanguageMetadata *lang);
 
const LanguageMetadata *GetLanguage(byte newgrflangid);
src/string.cpp
Show inline comments
 
@@ -25,12 +25,12 @@
 
#include <errno.h> // required by vsnprintf implementation for MSVC
 
#endif
 

	
 
#ifdef WITH_ICU
 
#ifdef WITH_ICU_SORT
 
/* Required by strnatcmp. */
 
#include <unicode/ustring.h>
 
#include "language.h"
 
#include "gfx_func.h"
 
#endif /* WITH_ICU */
 
#endif /* WITH_ICU_SORT */
 

	
 
/* 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. */
 
@@ -572,7 +572,7 @@ int strnatcmp(const char *s1, const char
 
		s1 = SkipGarbage(s1);
 
		s2 = SkipGarbage(s2);
 
	}
 
#ifdef WITH_ICU
 
#ifdef WITH_ICU_SORT
 
	if (_current_collator != NULL) {
 
		UErrorCode status = U_ZERO_ERROR;
 
		int result;
 
@@ -592,13 +592,13 @@ int strnatcmp(const char *s1, const char
 
		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. */
 
	return strcasecmp(s1, s2);
 
}
 

	
 
#ifdef WITH_ICU
 
#ifdef WITH_ICU_SORT
 

	
 
#include <unicode/utext.h>
 
#include <unicode/brkiter.h>
src/strings.cpp
Show inline comments
 
@@ -49,9 +49,9 @@ const LanguageMetadata *_current_languag
 

	
 
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.
 
#endif /* WITH_ICU */
 
#endif /* WITH_ICU_SORT */
 

	
 
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
 
@@ -1790,7 +1790,7 @@ bool ReadLanguagePack(const LanguageMeta
 
	strecpy(_config_language_file, c_file, lastof(_config_language_file));
 
	SetCurrentGrfLangID(_current_language->newgrflangid);
 

	
 
#ifdef WITH_ICU
 
#ifdef WITH_ICU_SORT
 
	/* Delete previous collator. */
 
	if (_current_collator != NULL) {
 
		delete _current_collator;
 
@@ -1807,7 +1807,7 @@ bool ReadLanguagePack(const LanguageMeta
 
		delete _current_collator;
 
		_current_collator = NULL;
 
	}
 
#endif /* WITH_ICU */
 
#endif /* WITH_ICU_SORT */
 

	
 
	/* Some lists need to be sorted again after a language change. */
 
	ReconsiderGameScriptLanguage();
 
@@ -2132,7 +2132,7 @@ void CheckForMissingGlyphs(bool base_fon
 
	/* Update the font with cache */
 
	LoadStringWidthTable(searcher->Monospace());
 

	
 
#if !defined(WITH_ICU)
 
#if !defined(WITH_ICU_LAYOUT)
 
	/*
 
	 * For right-to-left languages we need the ICU library. If
 
	 * we do not have support for that library we warn the user
 
@@ -2152,5 +2152,5 @@ void CheckForMissingGlyphs(bool base_fon
 
		SetDParamStr(0, err_str);
 
		ShowErrorMessage(STR_JUST_RAW_STRING, INVALID_STRING_ID, WL_ERROR);
 
	}
 
#endif
 
#endif /* !WITH_ICU_LAYOUT */
 
}
0 comments (0 inline, 0 general)