mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 14:11:33 +00:00
TTF_OpenFontRW retains the SDL_RWops on success, so we must keep the font data around to back it
This commit is contained in:
@@ -9,7 +9,8 @@
|
|||||||
|
|
||||||
SdlRenderer::SdlRenderer()
|
SdlRenderer::SdlRenderer()
|
||||||
: m_Renderer(nullptr),
|
: m_Renderer(nullptr),
|
||||||
m_Texture(nullptr)
|
m_Texture(nullptr),
|
||||||
|
m_FontData(Path::readDataFile("ModeSeven.ttf"))
|
||||||
{
|
{
|
||||||
SDL_assert(TTF_WasInit() == 0);
|
SDL_assert(TTF_WasInit() == 0);
|
||||||
if (TTF_Init() != 0) {
|
if (TTF_Init() != 0) {
|
||||||
@@ -88,14 +89,14 @@ void SdlRenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
|||||||
{
|
{
|
||||||
// Construct the required font to render the overlay
|
// Construct the required font to render the overlay
|
||||||
if (m_OverlayFonts[type] == nullptr) {
|
if (m_OverlayFonts[type] == nullptr) {
|
||||||
QByteArray fontData = Path::readDataFile("ModeSeven.ttf");
|
if (m_FontData.isEmpty()) {
|
||||||
if (fontData.isEmpty()) {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Unable to load SDL overlay font");
|
"SDL overlay font failed to load");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_OverlayFonts[type] = TTF_OpenFontRW(SDL_RWFromConstMem(fontData.constData(), fontData.size()),
|
// m_FontData must stay around until the font is closed
|
||||||
|
m_OverlayFonts[type] = TTF_OpenFontRW(SDL_RWFromConstMem(m_FontData.constData(), m_FontData.size()),
|
||||||
1,
|
1,
|
||||||
Session::get()->getOverlayManager().getOverlayFontSize(type));
|
Session::get()->getOverlayManager().getOverlayFontSize(type));
|
||||||
if (m_OverlayFonts[type] == nullptr) {
|
if (m_OverlayFonts[type] == nullptr) {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ private:
|
|||||||
|
|
||||||
SDL_Renderer* m_Renderer;
|
SDL_Renderer* m_Renderer;
|
||||||
SDL_Texture* m_Texture;
|
SDL_Texture* m_Texture;
|
||||||
|
QByteArray m_FontData;
|
||||||
TTF_Font* m_OverlayFonts[Overlay::OverlayMax];
|
TTF_Font* m_OverlayFonts[Overlay::OverlayMax];
|
||||||
SDL_Surface* m_OverlaySurfaces[Overlay::OverlayMax];
|
SDL_Surface* m_OverlaySurfaces[Overlay::OverlayMax];
|
||||||
SDL_Texture* m_OverlayTextures[Overlay::OverlayMax];
|
SDL_Texture* m_OverlayTextures[Overlay::OverlayMax];
|
||||||
|
|||||||
Reference in New Issue
Block a user