8000 SDL fonts: Add "Droid Sans Fallback" to the list of fallback fonts. by hrydgard · Pull Request #18732 · hrydgard/ppsspp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

SDL fonts: Add "Droid Sans Fallback" to the list of fallback fonts. #18732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
10000
Diff view
27 changes: 17 additions & 10 deletions Common/Render/Text/draw_text_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,24 @@ void TextDrawerSDL::PrepareFallbackFonts() {
#if defined(USE_SDL2_TTF_FONTCONFIG)
FcObjectSet *os = FcObjectSetBuild (FC_FILE, FC_INDEX, (char *) 0);

FcPattern *names[] = {
FcNameParse((const FcChar8 *) "Source Han Sans Medium"),
FcNameParse((const FcChar8 *) "Droid Sans Bold"),
FcNameParse((const FcChar8 *) "DejaVu Sans Condensed"),
FcNameParse((const FcChar8 *) "Noto Sans CJK Medium"),
FcNameParse((const FcChar8 *) "Noto Sans Hebrew Medium"),
FcNameParse((const FcChar8 *) "Noto Sans Lao Medium"),
FcNameParse((const FcChar8 *) "Noto Sans Thai Medium")
// To install the fallback font in ubuntu:
// sudo apt install fonts-droid-fallback
const char *names[] = {
"Droid Sans Fallback",
"Droid Sans Medium",
"Droid Sans Bold",
"Source Han Sans Medium",
"DejaVu Sans Condensed",
"Noto Sans CJK Medium",
"Noto Sans Hebrew Medium",
"Noto Sans Lao Medium",
"Noto Sans Thai Medium",
};

for (int i = 0; i < ARRAY_SIZE(names); i++) {
FcFontSet *foundFonts = FcFontList(config, names[i], os);
// printf("trying font name %s\n", names[i]);
FcPattern *name = FcNameParse((const FcChar8 *)names[i]);
FcFontSet *foundFonts = FcFontList(config, name, os);

for (int j = 0; foundFonts && j < foundFonts->nfont; ++j) {
FcPattern* font = foundFonts->fonts[j];
Expand All @@ -72,6 +78,7 @@ void TextDrawerSDL::PrepareFallbackFonts() {

if (FcPatternGetString(font, FC_FILE, 0, &path) == FcResultMatch) {
std::string path_str((const char*)path);
// printf("fallback font: %s\n", path_str.c_str());
fallbackFontPaths_.push_back(std::make_pair(path_str, fontIndex));
}
}
Expand All @@ -80,7 +87,7 @@ void TextDrawerSDL::PrepareFallbackFonts() {
FcFontSetDestroy(foundFonts);
}

FcPatternDestroy(names[i]);
FcPatternDestroy(name);
}

if (os) {
Expand Down
0