Files
ppsspp/Common/Render/Text/draw_text_sdl.h
T
Henrik RydgårdandClaude Opus 5.5 4c7dd44351 TextDrawer: Remove the current font and scale
Drawing now takes the style and scale too, like measuring, so the text
drawers have no font state left. UIContext keeps its current style and
passes it, and fills it in from the theme if nothing has set one yet.
PPGe passes its one font.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 11:54:10 +01:00

49 lines
1.3 KiB
C++

#pragma once
#include "ppsspp_config.h"
#include <map>
#include "Common/Render/Text/draw_text.h"
#if defined(USE_SDL3_TTF)
#include <SDL3/SDL.h>
#include <SDL3_ttf/SDL_ttf.h>
#if defined(USE_SDL3_TTF_FONTCONFIG)
#include <fontconfig/fontconfig.h>
#endif
class TextDrawerSDL : public TextDrawer {
public:
TextDrawerSDL(Draw::DrawContext *draw);
~TextDrawerSDL();
protected:
void EnsureFont(const FontStyle &style) override;
void MeasureStringInternal(const FontStyle &style, std::string_view str, float *w, float *h) override;
bool DrawStringBitmap(const FontStyle &style, std::vector<uint8_t> &bitmapData, TextStringEntry &entry, Draw::DataFormat texFormat, std::string_view str, int align, bool fullColor) override;
bool SupportsColorEmoji() const override { return false; }
void ClearFonts() override;
private:
void PrepareFallbackFonts(std::string_view locale);
uint32_t CheckMissingGlyph(TTF_Font *font, std::string_view text);
int FindFallbackFonts(uint32_t missingGlyph, int ptSize);
std::map<FontStyle, std::pair<TTF_Font *, uint8_t *>> fontMap_;
std::vector<TTF_Font *> fallbackFonts_;
std::vector<std::pair<std::string, int>> fallbackFontPaths_; // path and font face index
std::map<int, int> glyphFallbackFontIndex_;
#if defined(USE_SDL3_TTF_FONTCONFIG)
FcConfig *config;
#endif
};
#endif