diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 9e01dd71f8..b5d1f453c7 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -3,6 +3,7 @@ - Feature: Add displaying of frames per second (FPS). - Feature: Changing the number of trains no longer requires retesting. - Feature: Add SI units as a new measurement system for distance / speed. +- Feature: Update alternative font selection mechanism for all platforms. - Fix: [#2126] Ferris Wheels set to "backward rotation" stop working (original bug) - Fix: [#2449] Turning off Day/Night Circle while it is night doesn't reset back to day diff --git a/src/platform/linux.c b/src/platform/linux.c index 13d5244c61..22e3245fcb 100644 --- a/src/platform/linux.c +++ b/src/platform/linux.c @@ -166,7 +166,17 @@ int platform_open_common_file_dialog(int type, utf8 *title, utf8 *filename, utf8 bool platform_get_font_path(TTFFontDescriptor *font, utf8 *buffer) { + assert(buffer != NULL); + assert(font != NULL); + + log_verbose("Looking for font %s with FontConfig.", font->font_name); FcConfig* config = FcInitLoadConfigAndFonts(); + if (!config) + { + log_error("Failed to initialize FontConfig library"); + FcFini(); + return false; + } FcPattern* pat = FcNameParse((const FcChar8*) font->font_name); FcConfigSubstitute(config, pat, FcMatchPattern); @@ -182,12 +192,17 @@ bool platform_get_font_path(TTFFontDescriptor *font, utf8 *buffer) if (FcPatternGetString(match, FC_FILE, 0, &filename) == FcResultMatch) { found = true; - strcpy(buffer, (utf8*) filename); + safe_strncpy(buffer, (utf8*) filename, MAX_PATH); + log_verbose("FontConfig provided font %s", filename); } FcPatternDestroy(match); + } else { + log_warning("Failed to find required font."); } FcPatternDestroy(pat); + FcConfigDestroy(config); + FcFini(); return found; }