mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix memory leaks in font selection for Linux
Add some logging too, in particular warning when no font was found.
This commit is contained in:
parent
eda733165e
commit
c0830ae02e
|
@ -3,6 +3,7 @@
|
||||||
- Feature: Add displaying of frames per second (FPS).
|
- Feature: Add displaying of frames per second (FPS).
|
||||||
- Feature: Changing the number of trains no longer requires retesting.
|
- Feature: Changing the number of trains no longer requires retesting.
|
||||||
- Feature: Add SI units as a new measurement system for distance / speed.
|
- 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
|
- Fix: [#2126] Ferris Wheels set to "backward rotation" stop working (original
|
||||||
bug)
|
bug)
|
||||||
- Fix: [#2449] Turning off Day/Night Circle while it is night doesn't reset back to day
|
- Fix: [#2449] Turning off Day/Night Circle while it is night doesn't reset back to day
|
||||||
|
|
|
@ -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)
|
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();
|
FcConfig* config = FcInitLoadConfigAndFonts();
|
||||||
|
if (!config)
|
||||||
|
{
|
||||||
|
log_error("Failed to initialize FontConfig library");
|
||||||
|
FcFini();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
FcPattern* pat = FcNameParse((const FcChar8*) font->font_name);
|
FcPattern* pat = FcNameParse((const FcChar8*) font->font_name);
|
||||||
|
|
||||||
FcConfigSubstitute(config, pat, FcMatchPattern);
|
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)
|
if (FcPatternGetString(match, FC_FILE, 0, &filename) == FcResultMatch)
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
strcpy(buffer, (utf8*) filename);
|
safe_strncpy(buffer, (utf8*) filename, MAX_PATH);
|
||||||
|
log_verbose("FontConfig provided font %s", filename);
|
||||||
}
|
}
|
||||||
FcPatternDestroy(match);
|
FcPatternDestroy(match);
|
||||||
|
} else {
|
||||||
|
log_warning("Failed to find required font.");
|
||||||
}
|
}
|
||||||
|
|
||||||
FcPatternDestroy(pat);
|
FcPatternDestroy(pat);
|
||||||
|
FcConfigDestroy(config);
|
||||||
|
FcFini();
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue