Skip to content

Commit e04e7c5

Browse files
committed
[text] Limit SpriteSheetFont sizes to its multiples
It looks like some themes were using custom (invalid?) sprite sheet font sizes. This patch removes the possibility to resize to a SpriteSheetFont to any size, anyway the resulting font was ugly that I think nobody will miss this change.
1 parent 81478c1 commit e04e7c5

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

text/sprite_sheet_font.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@
1212

1313
#include "os/sampling.h"
1414

15+
#include <algorithm>
16+
#include <cmath>
17+
1518
namespace text {
1619

1720
void SpriteSheetFont::setSize(const float size)
1821
{
1922
ASSERT(m_defaultSize > 0.0f);
2023

21-
os::Sampling sampling;
22-
if (m_antialias)
23-
sampling = os::Sampling(os::Sampling::Filter::Linear, os::Sampling::Mipmap::Nearest);
24-
25-
const float scale = size / m_defaultSize;
26-
m_sheet = m_originalSheet->applyScale(scale, sampling);
27-
m_size = size;
24+
// Limit the size of the sprite sheet font to multiples of its own
25+
// size (x1, x2, x3, etc.)
26+
const int scale = std::max<int>(1, std::floor(size / m_defaultSize));
27+
m_sheet = m_originalSheet->applyScale(scale, os::Sampling{});
28+
m_size = scale * m_defaultSize;
2829

2930
m_glyphs = m_originalGlyphs;
3031
for (auto& rc : m_glyphs)

0 commit comments

Comments
 (0)