Fixed a bug where the characters size was sometimes wrong in sf::Text
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1532 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
1f906c0643
commit
dcbc7f29a4
@ -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<Uint8> 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
|
||||
|
@ -40,8 +40,7 @@ namespace sf
|
||||
Font::Font() :
|
||||
myLibrary (NULL),
|
||||
myFace (NULL),
|
||||
myRefCount (NULL),
|
||||
myCurrentSize(0)
|
||||
myRefCount(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
@ -54,8 +53,7 @@ myLibrary (copy.myLibrary),
|
||||
myFace (copy.myFace),
|
||||
myRefCount (copy.myRefCount),
|
||||
myPages (copy.myPages),
|
||||
myPixelBuffer (copy.myPixelBuffer),
|
||||
myCurrentSize (copy.myCurrentSize)
|
||||
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;
|
||||
@ -297,7 +297,6 @@ void Font::Cleanup()
|
||||
myLibrary = NULL;
|
||||
myFace = NULL;
|
||||
myRefCount = NULL;
|
||||
myCurrentSize = 0;
|
||||
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<FT_Face>(myFace);
|
||||
FT_UShort currentSize = face->size->metrics.x_ppem;
|
||||
|
||||
if (currentSize != characterSize)
|
||||
{
|
||||
myCurrentSize = characterSize;
|
||||
return FT_Set_Pixel_Sizes(static_cast<FT_Face>(myFace), 0, characterSize) == 0;
|
||||
return FT_Set_Pixel_Sizes(face, 0, characterSize) == 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user