Emscripten: fixed fontconfig font path

This commit is contained in:
Sergii Pylypenko
2021-06-19 01:10:34 +03:00
parent 7b1902a8b0
commit dbb9fa9b6f
4 changed files with 10 additions and 8 deletions

View File

@@ -219,10 +219,11 @@ mkdir -p baseset
cp -f "icu/source/data/in/icudt68l.dat" ./ || exit 1
}
[ -e fonts ] || {
[ -e fonts/fonts.conf ] || {
wget -nc https://sourceforge.net/projects/libsdl-android/files/openttd-fonts.zip || exit 1
unzip openttd-fonts.zip || exit 1
rm openttd-fonts.zip
sed 's@/usr/share/fonts@/fonts@g' fontconfig-2.13.1/build-wasm/etc/fonts/fonts.conf > fonts/fonts.conf || exit 1
}
#[ -e TimGM6mb.sf2 ] || {

View File

@@ -728,12 +728,13 @@ int openttd_main(int argc, char *argv[])
{
#ifndef WIN32
// Configure local font path on Android
//char curdir[PATH_MAX];
//getcwd(curdir, sizeof(curdir));
//setenv("FONTCONFIG_FONTS", (std::string(curdir) + "/fonts").c_str(), 1);
// Configure local font path on Android, it uses older Fontconfig version that does not require config file
setenv("FONTCONFIG_FONTS", "fonts", 1);
DEBUG(misc, 1, "Set FONTCONFIG_FONTS to %s", getenv("FONTCONFIG_FONTS"));
#endif
#ifdef __EMSCRIPTEN__
// Fontconfig config file is required on Emscripten, and the path to fonts directory is named differently
setenv("FONTCONFIG_FILE", "/fonts/fonts.conf", 1);
#endif
}
/* enumerate language files */

View File

@@ -133,7 +133,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
if (res != FcResultMatch || file == nullptr) {
continue;
}
DEBUG(freetype, 1, "Got font %s", file);
DEBUG(freetype, 1, "Found font %s", file);
int missing = 0;
/* Get a font with the right spacing .*/

View File

@@ -2021,7 +2021,7 @@ int MissingGlyphSearcher::FindMissingGlyphs()
default: NOT_REACHED();
}
DEBUG(freetype, 1, "Font %s is missing glyphs to display char 0x%X '%s' in %s font size", font_name.c_str(), c, char_name, size_name.c_str());
//DEBUG(freetype, 1, "Font %s is missing glyphs to display char 0x%X '%s' in %s font size", font_name.c_str(), c, char_name, size_name.c_str());
missing++;
}
}
@@ -2118,7 +2118,7 @@ void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
* future, so for safety we just Utf8 Encode it into the string,
* which takes exactly three characters, so it replaces the "XXX"
* with the colour marker. */
#ifndef __ANDROID__
#if !defined(__ANDROID__) && !defined(__EMSCRIPTEN__)
static char *err_str = stredup("XXXThe current font is missing some of the characters used in the texts for this language. Using system fallback font instead.");
Utf8Encode(err_str, SCC_YELLOW);
SetDParamStr(0, err_str);