From ba8fae6b9701903ce2a481b5030ffacb1ee22347 Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Thu, 13 Mar 2014 23:49:34 +0200 Subject: [PATCH] Support for Chinese fonts in OpenTTD --- .../openttd/AndroidAppSettings.cfg | 2 +- .../jni/application/openttd/AndroidBuild.sh | 2 +- .../application/openttd/findversion.sh.patch | 10 --- .../openttd/openttd-trunk-android.patch | 88 +++++++++++++++++++ 4 files changed, 90 insertions(+), 12 deletions(-) delete mode 100644 project/jni/application/openttd/findversion.sh.patch diff --git a/project/jni/application/openttd/AndroidAppSettings.cfg b/project/jni/application/openttd/AndroidAppSettings.cfg index 810f2550a..189a9b74b 100644 --- a/project/jni/application/openttd/AndroidAppSettings.cfg +++ b/project/jni/application/openttd/AndroidAppSettings.cfg @@ -230,7 +230,7 @@ AppSubdirsBuild='' AppBuildExclude='' # Application command line parameters, including app name as 0-th param -AppCmdline='openttd' +AppCmdline='openttd -d 1' # Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens # Minimum screen size that application supports: (s)mall / (m)edium / (l)arge diff --git a/project/jni/application/openttd/AndroidBuild.sh b/project/jni/application/openttd/AndroidBuild.sh index 9e4e7d461..6c68fcc14 100755 --- a/project/jni/application/openttd/AndroidBuild.sh +++ b/project/jni/application/openttd/AndroidBuild.sh @@ -9,7 +9,7 @@ if [ \! -d openttd-$VER-$1 ] ; then tar xvzf openttd-$VER-source.tar.gz cp -a -f openttd-$VER openttd-$VER-orig mv -f openttd-$VER openttd-$VER-$1 - patch -p 0 -d openttd-$VER-$1 < openttd-trunk-android.patch && patch -p 0 -d openttd-$VER-$1 < findversion.sh.patch || exit 1 + patch -p 0 -d openttd-$VER-$1 < openttd-trunk-android.patch || exit 1 fi if [ \! -f openttd-$VER-$1/objs/lang/english.lng ] ; then diff --git a/project/jni/application/openttd/findversion.sh.patch b/project/jni/application/openttd/findversion.sh.patch deleted file mode 100644 index 5e1d49e8a..000000000 --- a/project/jni/application/openttd/findversion.sh.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- findversion.sh (revision 24501) -+++ findversion.sh (working copy) -@@ -134,6 +134,7 @@ - REV_NR="" - fi - -+MODIFIED="0" # This prevents Andorid build from connecting to a public servers - if [ "$MODIFIED" -eq "2" ]; then - REV="${REV}M" - fi diff --git a/project/jni/application/openttd/openttd-trunk-android.patch b/project/jni/application/openttd/openttd-trunk-android.patch index 8954b530d..53bf2c9cb 100644 --- a/project/jni/application/openttd/openttd-trunk-android.patch +++ b/project/jni/application/openttd/openttd-trunk-android.patch @@ -30,6 +30,50 @@ #if defined(ENABLE_NETWORK) if (_debug_socket != INVALID_SOCKET) { char buf2[1024 + 32]; +--- src/fontdetection.cpp 2014-02-25 11:17:24.000000000 +0200 ++++ src/fontdetection.cpp 2014-03-13 23:49:24.456780663 +0200 +@@ -626,7 +626,7 @@ + if (split != NULL) *split = '\0'; + + /* First create a pattern to match the wanted language. */ +- FcPattern *pat = FcNameParse((FcChar8*)lang); ++ FcPattern *pat = FcNameParse((FcChar8*)"" /*lang*/); + /* We only want to know the filename. */ + FcObjectSet *os = FcObjectSetBuild(FC_FILE, FC_SPACING, FC_SLANT, FC_WEIGHT, NULL); + /* Get the list of filenames matching the wanted language. */ +@@ -639,6 +639,7 @@ + if (fs != NULL) { + int best_weight = -1; + const char *best_font = NULL; ++ int best_missing_glypths = 65536; + + for (int i = 0; i < fs->nfont; i++) { + FcPattern *font = fs->fonts[i]; +@@ -664,12 +665,13 @@ + + callback->SetFontNames(settings, (const char*)file); + +- bool missing = callback->FindMissingGlyphs(NULL); +- DEBUG(freetype, 1, "Font \"%s\" misses%s glyphs", file, missing ? "" : " no"); ++ int missing = callback->FindMissingGlyphs(NULL); ++ DEBUG(freetype, 1, "Font \"%s\" misses %d glyphs for lang %s", file, missing, lang); + +- if (!missing) { ++ if (missing < best_missing_glypths) { + best_weight = value; + best_font = (const char *)file; ++ best_missing_glypths = missing; + } + } + +@@ -677,6 +679,7 @@ + ret = true; + callback->SetFontNames(settings, best_font); + InitFreeType(callback->Monospace()); ++ DEBUG(freetype, 1, "Selected font %s for lang %s", best_font, lang); + } + + /* Clean up the list of filenames. */ --- src/music/libtimidity.cpp 2014-02-25 11:17:00.000000000 +0200 +++ src/music/libtimidity.cpp 2014-03-13 22:51:41.711016587 +0200 @@ -13,6 +13,7 @@ @@ -235,6 +279,50 @@ } const char *SoundDriver_SDL::Start(const char * const *parm) +--- src/strings.cpp 2014-02-25 11:17:24.000000000 +0200 ++++ src/strings.cpp 2014-03-13 23:44:07.197919943 +0200 +@@ -2005,7 +2005,7 @@ + * @return If glyphs are missing, return \c true, else return \c false. + * @post If \c true is returned and str is not NULL, *str points to a string that is found to contain at least one missing glyph. + */ +-bool MissingGlyphSearcher::FindMissingGlyphs(const char **str) ++int MissingGlyphSearcher::FindMissingGlyphs(const char **str) + { + InitFreeType(this->Monospace()); + const Sprite *question_mark[FS_END]; +@@ -2015,6 +2015,7 @@ + } + + this->Reset(); ++ int missing = 0; + for (const char *text = this->NextString(); text != NULL; text = this->NextString()) { + FontSize size = this->DefaultSize(); + if (str != NULL) *str = text; +@@ -2025,11 +2026,11 @@ + size = FS_LARGE; + } else if (!IsInsideMM(c, SCC_SPRITE_START, SCC_SPRITE_END) && IsPrintable(c) && !IsTextDirectionChar(c) && c != '?' && GetGlyph(size, c) == question_mark[size]) { + /* The character is printable, but not in the normal font. This is the case we were testing for. */ +- return true; ++ missing++; + } + } + } +- return false; ++ return missing; + } + + /** Helper for searching through the language pack. */ +--- src/strings_func.h 2014-02-25 11:17:24.000000000 +0200 ++++ src/strings_func.h 2014-03-13 23:44:13.558298069 +0200 +@@ -235,7 +235,7 @@ + */ + virtual void SetFontNames(struct FreeTypeSettings *settings, const char *font_name) = 0; + +- bool FindMissingGlyphs(const char **str); ++ int FindMissingGlyphs(const char **str); + }; + + void CheckForMissingGlyphs(bool base_font = true, MissingGlyphSearcher *search = NULL); --- src/video/sdl_v.cpp 2014-02-25 11:16:44.000000000 +0200 +++ src/video/sdl_v.cpp 2014-03-13 22:51:42.431059430 +0200 @@ -25,6 +25,9 @@