diff --git a/CHANGELOG.md b/CHANGELOG.md index cad8a691a..d5f25d4b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -95,6 +95,7 @@ Many bugs have been fixed, and numerous features that were only partially implem * If the user tried to enter a blank game name in the metadata editor, the application would crash upon saving * Switching to the Grid view style with a placeholder shown in the gamelist crashed the application * FileSystemUtil::getDirContent crashed when searching through directories recursively +* Large text sizes at higher resolutions (such as 4K) would crash the application as fixed-size texture buffers were used which weren't big enough to hold the larger font textures * Fixed a massive memory leak related to SVG images * Fixed an issue where SVG images would sometimes be cut off slightly on the right side (e.g. logos on the system view carousel) * The scraper didn't handle error conditions correctly diff --git a/es-app/src/views/SystemView.cpp b/es-app/src/views/SystemView.cpp index 5a414e092..5e8c28493 100644 --- a/es-app/src/views/SystemView.cpp +++ b/es-app/src/views/SystemView.cpp @@ -89,11 +89,11 @@ void SystemView::populate() if (!e.data.logo) { // No logo in theme; use text. TextComponent* text = new TextComponent( - mWindow, - (*it)->getName(), - Font::get(FONT_SIZE_LARGE), - 0x000000FF, - ALIGN_CENTER); + mWindow, + (*it)->getName(), + Font::get(FONT_SIZE_LARGE), + 0x000000FF, + ALIGN_CENTER); text->setSize(mCarousel.logoSize * mCarousel.logoScale); text->applyTheme((*it)->getTheme(), "system", "logoText", ThemeFlags::FONT_PATH | ThemeFlags::FONT_SIZE | ThemeFlags::COLOR | diff --git a/es-core/src/resources/Font.cpp b/es-core/src/resources/Font.cpp index be3f8a5ed..b09e97d29 100644 --- a/es-core/src/resources/Font.cpp +++ b/es-core/src/resources/Font.cpp @@ -128,10 +128,12 @@ void Font::unloadTextures() it->deinitTexture(); } -Font::FontTexture::FontTexture() +Font::FontTexture::FontTexture(const int mSize) { textureId = 0; - textureSize = Vector2i(2048, 512); + // I'm not entirely sure if the 16 and 4 constants are correct, but they seem to provide + // a texture buffer large enough to hold the fonts. (Otherwise the application would crash.) + textureSize = Vector2i(mSize * 16, mSize * 4); writePos = Vector2i::Zero(); rowHeight = 0; } @@ -197,9 +199,8 @@ void Font::getTextureForNewGlyph(const Vector2i& glyphSize, return; // Yes. } - // Current textures are full, - // make a new one. - mTextures.push_back(FontTexture()); + // Current textures are full, make a new one. + mTextures.push_back(FontTexture(mSize)); tex_out = &mTextures.back(); tex_out->initTexture(); @@ -607,7 +608,7 @@ TextCache* Font::buildTextCache( convertedColor }; // Round vertices. - for (int i = 1; i < 5; ++i) + for (int i = 1; i < 5; i++) vertices[i].pos.round(); // Make duplicates of first and last vertex so this can be rendered as a triangle strip. diff --git a/es-core/src/resources/Font.h b/es-core/src/resources/Font.h index 64bd803b8..fb39ee3c2 100644 --- a/es-core/src/resources/Font.h +++ b/es-core/src/resources/Font.h @@ -106,7 +106,7 @@ private: Vector2i writePos; int rowHeight; - FontTexture(); + FontTexture(const int mSize); ~FontTexture(); bool findEmpty(const Vector2i& size, Vector2i& cursor_out);