Skip to content

Commit f44e050

Browse files
committed
Fix SDL font rendering
Fixes hrydgard#20933
1 parent a506683 commit f44e050

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Common/Render/Text/draw_text_sdl.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ void TextDrawerSDL::PrepareFallbackFonts(std::string_view locale) {
111111
// printf("trying font name %s\n", names[i]);
112112
FcPattern *name = FcNameParse((const FcChar8 *)names[i]);
113113
FcFontSet *foundFonts = FcFontList(config, name, os);
114-
114+
115115
for (int j = 0; foundFonts && j < foundFonts->nfont; ++j) {
116116
FcPattern* font = foundFonts->fonts[j];
117117
FcChar8 *path;
118118
int fontIndex;
119119

120120
if (FcPatternGetInteger(font, FC_INDEX, 0, &fontIndex) != FcResultMatch) {
121-
fontIndex = 0; // The 0th face is guaranteed to exist
121+
fontIndex = 0; // The 0th face is guaranteed to exist
122122
}
123123

124124
if (FcPatternGetString(font, FC_FILE, 0, &path) == FcResultMatch) {
@@ -178,7 +178,7 @@ void TextDrawerSDL::PrepareFallbackFonts(std::string_view locale) {
178178

179179
TTF_CloseFont(openedFont);
180180
}
181-
}
181+
}
182182
}
183183
#else
184184
// We don't have a fallback font for this platform.
@@ -287,7 +287,7 @@ void TextDrawerSDL::MeasureStringInternal(std::string_view str, float *w, float
287287
int ptSize = TTF_FontHeight(font) / 1.35;
288288

289289
uint32_t missingGlyph = CheckMissingGlyph(str);
290-
290+
291291
if (missingGlyph) {
292292
int fallbackFont = FindFallbackFonts(missingGlyph, ptSize);
293293
if (fallbackFont >= 0 && fallbackFont < (int)fallbackFonts_.size()) {
@@ -317,7 +317,7 @@ bool TextDrawerSDL::DrawStringBitmap(std::vector<uint8_t> &bitmapData, TextStrin
317317
std::string processedStr(str);
318318

319319
// If a string includes only newlines, SDL2_ttf will refuse to render it
320-
// thinking it is empty. Add a space to avoid that.
320+
// thinking it is empty. Add a space to avoid that.
321321
bool isAllNewline = processedStr.find_first_not_of('\n') == std::string::npos;
322322

323323
if (isAllNewline) {
@@ -372,7 +372,7 @@ bool TextDrawerSDL::DrawStringBitmap(std::vector<uint8_t> &bitmapData, TextStrin
372372
for (int x = 0; x < entry.bmWidth; x++) {
373373
for (int y = 0; y < entry.bmHeight; y++) {
374374
const uint64_t index = entry.bmWidth * y + x;
375-
const u16 alpha = AlphaToPremul4444(imageData[pitch * y + x]);
375+
const u16 alpha = AlphaToPremul4444(imageData[pitch * y + x] >> 24);
376376
bitmapData16[index] = alpha;
377377
}
378378
}

0 commit comments

Comments
 (0)