Skip to content

Commit 6de16bb

Browse files
author
Ilya Zhuravlev
committedSep 8, 2013
Add fallback font support for some languages.
1 parent 6291fd1 commit 6de16bb

5 files changed

+47
-5
lines changed
 

‎README.txt

+17-3
Original file line numberDiff line numberDiff line change
@@ -382,17 +382,31 @@ DejaVu Sans Mono:
382382
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
383383
Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below)
384384

385-
Bitstream Vera Fonts Copyright:
385+
Bitstream Vera Fonts Copyright:
386386

387387
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
388388
a trademark of Bitstream, Inc.
389389

390-
Arev Fonts Copyright:
390+
Arev Fonts Copyright:
391391

392392
Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved.
393393

394-
Liberation Fonts Copyright:
394+
Liberation Fonts Copyright:
395395

396396
Copyright (c) 2007 Red Hat, Inc. All rights reserved. LIBERATION is a trademark of Red Hat, Inc.
397397

398+
DroidSansFallback:
398399

400+
Copyright (C) 2008 The Android Open Source Project
401+
402+
Licensed under the Apache License, Version 2.0 (the "License");
403+
you may not use this file except in compliance with the License.
404+
You may obtain a copy of the License at
405+
406+
http://www.apache.org/licenses/LICENSE-2.0
407+
408+
Unless required by applicable law or agreed to in writing, software
409+
distributed under the License is distributed on an "AS IS" BASIS,
410+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
411+
See the License for the specific language governing permissions and
412+
limitations under the License.

‎fonts/DroidSansFallbackFull.ttf

4.32 MB
Binary file not shown.

‎minetest.conf.example

+8
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@
191191
#mono_font_path = fonts/liberationmono.ttf
192192
#mono_font_size = 13
193193

194+
# This font will be used for certain languages
195+
#fallback_font_path = fonts/DroidSansFallbackFull.ttf
196+
#fallback_font_size = 13
197+
194198
#
195199
# Server stuff
196200
#
@@ -390,3 +394,7 @@
390394

391395
# Makes DirectX work with LuaJIT. Disable if it causes troubles.
392396
#high_precision_fpu = true
397+
398+
# Override language. When no value is provided (default) system language is used.
399+
# Check "locale" directory for the list of available translations.
400+
#language =

‎src/defaultsettings.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ void set_default_settings(Settings *settings)
147147
settings->setDefault("font_size", "13");
148148
settings->setDefault("mono_font_path", porting::getDataPath("fonts" DIR_DELIM "liberationmono.ttf"));
149149
settings->setDefault("mono_font_size", "13");
150+
settings->setDefault("fallback_font_path", porting::getDataPath("fonts" DIR_DELIM "DroidSansFallbackFull.ttf"));
151+
settings->setDefault("fallback_font_size", "13");
150152
#else
151153
settings->setDefault("freetype", "false");
152154
settings->setDefault("font_path", porting::getDataPath("fonts" DIR_DELIM "fontlucida.png"));
@@ -281,6 +283,8 @@ void set_default_settings(Settings *settings)
281283
settings->setDefault("modstore_details_url", "https://forum.minetest.net/mmdb/mod/*/");
282284

283285
settings->setDefault("high_precision_fpu", "true");
286+
287+
settings->setDefault("language", "");
284288
}
285289

286290
void override_default_settings(Settings *settings, Settings *from)

‎src/main.cpp

+18-2
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,19 @@ int main(int argc, char *argv[])
995995
{
996996
run_tests();
997997
}
998-
998+
999+
std::string language = g_settings->get("language");
1000+
if (language.length()) {
1001+
#ifndef _WIN32
1002+
setenv("LANGUAGE", language.c_str(), 1);
1003+
#else
1004+
char *lang_str = (char*)calloc(10 + language.length(), sizeof(char));
1005+
strcat(lang_str, "LANGUAGE=");
1006+
strcat(lang_str, language.c_str());
1007+
putenv(lang_str);
1008+
#endif
1009+
}
1010+
9991011
/*
10001012
Game parameters
10011013
*/
@@ -1396,7 +1408,11 @@ int main(int argc, char *argv[])
13961408
bool use_freetype = g_settings->getBool("freetype");
13971409
#if USE_FREETYPE
13981410
if (use_freetype) {
1399-
u16 font_size = g_settings->getU16("font_size");
1411+
std::string fallback;
1412+
if (is_yes(gettext("needs_fallback_font")))
1413+
fallback = "fallback_";
1414+
u16 font_size = g_settings->getU16(fallback + "font_size");
1415+
font_path = g_settings->get(fallback + "font_path");
14001416
font = gui::CGUITTFont::createTTFont(guienv, font_path.c_str(), font_size);
14011417
} else {
14021418
font = guienv->getFont(font_path.c_str());

0 commit comments

Comments
 (0)
Please sign in to comment.