diff --git a/include/SFML/Graphics/Font.hpp b/include/SFML/Graphics/Font.hpp index 3bae2b0d8..c7b13a279 100644 --- a/include/SFML/Graphics/Font.hpp +++ b/include/SFML/Graphics/Font.hpp @@ -281,7 +281,6 @@ private : int* myRefCount; ///< Reference counter used by implicit sharing mutable PageTable myPages; ///< Table containing the glyphs pages by character size mutable std::vector myPixelBuffer; ///< Pixel buffer holding a glyph's pixels before being written to the texture - mutable unsigned int myCurrentSize; ///< Current character size in use }; } // namespace sf diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index 1ed9441d2..b10ffec66 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -38,10 +38,9 @@ namespace sf { //////////////////////////////////////////////////////////// Font::Font() : -myLibrary (NULL), -myFace (NULL), -myRefCount (NULL), -myCurrentSize(0) +myLibrary (NULL), +myFace (NULL), +myRefCount(NULL) { } @@ -50,12 +49,11 @@ myCurrentSize(0) //////////////////////////////////////////////////////////// Font::Font(const Font& copy) : Resource(), -myLibrary (copy.myLibrary), -myFace (copy.myFace), -myRefCount (copy.myRefCount), -myPages (copy.myPages), -myPixelBuffer (copy.myPixelBuffer), -myCurrentSize (copy.myCurrentSize) +myLibrary (copy.myLibrary), +myFace (copy.myFace), +myRefCount (copy.myRefCount), +myPages (copy.myPages), +myPixelBuffer(copy.myPixelBuffer) { // Note: as FreeType doesn't provide functions for copying/cloning, // we must share all the FreeType pointers @@ -155,6 +153,9 @@ bool Font::LoadFromMemory(const void* data, std::size_t sizeInBytes) //////////////////////////////////////////////////////////// const Glyph& Font::GetGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) const { + if (codePoint == 100) + codePoint = codePoint; + // Get the page corresponding to the character size GlyphTable& glyphs = myPages[characterSize].Glyphs; @@ -239,7 +240,6 @@ Font& Font::operator =(const Font& right) std::swap(myFace, temp.myFace); std::swap(myPages, temp.myPages); std::swap(myPixelBuffer, temp.myPixelBuffer); - std::swap(myCurrentSize, temp.myCurrentSize); std::swap(myRefCount, temp.myRefCount); return *this; @@ -294,10 +294,9 @@ void Font::Cleanup() } // Reset members - myLibrary = NULL; - myFace = NULL; - myRefCount = NULL; - myCurrentSize = 0; + myLibrary = NULL; + myFace = NULL; + myRefCount = NULL; myPages.clear(); myPixelBuffer.clear(); } @@ -496,10 +495,12 @@ bool Font::SetCurrentSize(unsigned int characterSize) const // FT_Set_Pixel_Sizes is an expensive function, so we must call it // only when necessary to avoid killing performances - if (myCurrentSize != characterSize) + FT_Face face = static_cast(myFace); + FT_UShort currentSize = face->size->metrics.x_ppem; + + if (currentSize != characterSize) { - myCurrentSize = characterSize; - return FT_Set_Pixel_Sizes(static_cast(myFace), 0, characterSize) == 0; + return FT_Set_Pixel_Sizes(face, 0, characterSize) == 0; } else {