Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Switch font texture U/V coordinates to unsigned int
This fixes build with freetype 2.5.4, in which FT_Bitmap::rows,
FT_Bitmap::width types were changed from int to unsigned int. Because
of that, max(int, unsigned int) failed to compile. And since U/V
coordinates are essentially unsigned, this also improves code
consistency.
  • Loading branch information
AMDmi3 committed Dec 11, 2014
1 parent e63a773 commit 78190b6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/text/TextureFont.cpp
Expand Up @@ -362,8 +362,8 @@ TextureFont::Glyph TextureFont::BakeGlyph(Uint32 chr)
const FT_BitmapGlyph bmStrokeGlyph = FT_BitmapGlyph(strokeGlyph);

//don't run off atlas borders
m_atlasVIncrement = std::max(m_atlasVIncrement, bmStrokeGlyph->bitmap.rows);
if (m_atlasU + bmStrokeGlyph->bitmap.width > ATLAS_SIZE) {
m_atlasVIncrement = std::max(m_atlasVIncrement, (unsigned int)bmStrokeGlyph->bitmap.rows);
if (m_atlasU + (unsigned int)bmStrokeGlyph->bitmap.width > ATLAS_SIZE) {
m_atlasU = 0;
m_atlasV += m_atlasVIncrement;
m_atlasVIncrement = 0;
Expand Down Expand Up @@ -427,8 +427,8 @@ TextureFont::Glyph TextureFont::BakeGlyph(Uint32 chr)
else {

//don't run off atlas borders
m_atlasVIncrement = std::max(m_atlasVIncrement, bmGlyph->bitmap.rows);
if (m_atlasU + bmGlyph->bitmap.width >= ATLAS_SIZE) {
m_atlasVIncrement = std::max(m_atlasVIncrement, (unsigned int)bmGlyph->bitmap.rows);
if (m_atlasU + (unsigned int)bmGlyph->bitmap.width >= ATLAS_SIZE) {
m_atlasU = 0;
m_atlasV += m_atlasVIncrement;
m_atlasVIncrement = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/text/TextureFont.h
Expand Up @@ -90,9 +90,9 @@ class TextureFont : public RefCounted {
std::map<Uint32,Glyph> m_glyphs;

// UV offsets for glyphs
int m_atlasU;
int m_atlasV;
int m_atlasVIncrement;
unsigned int m_atlasU;
unsigned int m_atlasV;
unsigned int m_atlasVIncrement;

RefCountedPtr<Graphics::Texture> m_texture;
Graphics::TextureFormat m_texFormat;
Expand Down

0 comments on commit 78190b6

Please sign in to comment.