Potential fix for issue #1128
parent
92d2de5325
commit
be97167994
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include "math/func.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <SDL.h>
|
||||
#include <SDL_ttf.h>
|
||||
|
||||
|
@ -1252,13 +1253,13 @@ FontTexture CText::CreateFontTexture(Math::IntPoint tileSize)
|
|||
|
||||
Math::IntPoint CText::GetNextTilePos(const FontTexture& fontTexture)
|
||||
{
|
||||
int horizontalTiles = FONT_TEXTURE_SIZE.x / fontTexture.tileSize.x;
|
||||
int verticalTiles = FONT_TEXTURE_SIZE.y / fontTexture.tileSize.y;
|
||||
int horizontalTiles = FONT_TEXTURE_SIZE.x / std::max(1, fontTexture.tileSize.x); //this should prevent crashes in some combinations of resolution and font size, see issue #1128
|
||||
int verticalTiles = FONT_TEXTURE_SIZE.y / std::max(1, fontTexture.tileSize.y);
|
||||
|
||||
int totalTiles = horizontalTiles * verticalTiles;
|
||||
int tileNumber = totalTiles - fontTexture.freeSlots;
|
||||
|
||||
int verticalTileIndex = tileNumber / horizontalTiles;
|
||||
int verticalTileIndex = tileNumber / std::max(1, horizontalTiles);
|
||||
int horizontalTileIndex = tileNumber % horizontalTiles;
|
||||
|
||||
return Math::IntPoint(horizontalTileIndex * fontTexture.tileSize.x,
|
||||
|
|
Loading…
Reference in New Issue