@@ -332,32 +332,70 @@ void FontEngine::initFont(unsigned int basesize, FontMode mode)
332
332
font_path.c_str (), size, true , true , font_shadow,
333
333
font_shadow_alpha);
334
334
335
- if (font != NULL ) {
335
+ if (font) {
336
336
m_font_cache[mode][basesize] = font;
337
337
return ;
338
338
}
339
339
340
- // try fallback font
341
- errorstream << " FontEngine: failed to load: " << font_path << " , trying to fall back "
342
- " to fallback font" << std::endl;
340
+ if (font_config_prefix == " mono_" ) {
341
+ const std::string &mono_font_path = m_settings->getDefault (" mono_font_path" );
343
342
344
- font_path = g_settings->get (font_config_prefix + " fallback_font_path" );
343
+ if (font_path != mono_font_path) {
344
+ // try original mono font
345
+ errorstream << " FontEngine: failed to load custom mono "
346
+ " font: " << font_path << " , trying to fall back to "
347
+ " original mono font" << std::endl;
345
348
346
- font = gui::CGUITTFont::createTTFont (m_env,
347
- font_path .c_str (), size, true , true , font_shadow ,
348
- font_shadow_alpha);
349
+ font = gui::CGUITTFont::createTTFont (m_env,
350
+ mono_font_path .c_str (), size, true , true ,
351
+ font_shadow, font_shadow_alpha);
349
352
350
- if (font != NULL ) {
351
- m_font_cache[mode][basesize] = font;
352
- return ;
353
+ if (font) {
354
+ m_font_cache[mode][basesize] = font;
355
+ return ;
356
+ }
357
+ }
358
+ } else {
359
+ // try fallback font
360
+ errorstream << " FontEngine: failed to load: " << font_path <<
361
+ " , trying to fall back to fallback font" << std::endl;
362
+
363
+ font_path = g_settings->get (font_config_prefix + " fallback_font_path" );
364
+
365
+ font = gui::CGUITTFont::createTTFont (m_env,
366
+ font_path.c_str (), size, true , true , font_shadow,
367
+ font_shadow_alpha);
368
+
369
+ if (font) {
370
+ m_font_cache[mode][basesize] = font;
371
+ return ;
372
+ }
373
+
374
+ const std::string &fallback_font_path = m_settings->getDefault (" fallback_font_path" );
375
+
376
+ if (font_path != fallback_font_path) {
377
+ // try original fallback font
378
+ errorstream << " FontEngine: failed to load custom fallback "
379
+ " font: " << font_path << " , trying to fall back to "
380
+ " original fallback font" << std::endl;
381
+
382
+ font = gui::CGUITTFont::createTTFont (m_env,
383
+ fallback_font_path.c_str (), size, true , true ,
384
+ font_shadow, font_shadow_alpha);
385
+
386
+ if (font) {
387
+ m_font_cache[mode][basesize] = font;
388
+ return ;
389
+ }
390
+ }
353
391
}
354
392
355
393
// give up
356
394
errorstream << " FontEngine: failed to load freetype font: "
357
395
<< font_path << std::endl;
358
- errorstream << " minetest can not continue without a valid font. Please correct "
359
- " the 'font_path' setting or install the font file in the proper "
360
- " location" << std::endl;
396
+ errorstream << " minetest can not continue without a valid font. "
397
+ " Please correct the 'font_path' setting or install the font "
398
+ " file in the proper location" << std::endl;
361
399
abort ();
362
400
}
363
401
#endif
@@ -459,7 +497,7 @@ void FontEngine::initSimpleFont(unsigned int basesize, FontMode mode)
459
497
}
460
498
}
461
499
462
- if (font != NULL ) {
500
+ if (font) {
463
501
font->grab ();
464
502
m_font_cache[mode][basesize] = font;
465
503
}
0 commit comments