mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Fix for broken text when the font is reloaded.
This commit is contained in:
parent
b6c1acab3c
commit
c24de5fcaf
@ -393,6 +393,7 @@ private:
|
|||||||
mutable VertexArray m_outlineVertices; ///< Vertex array containing the outline geometry
|
mutable VertexArray m_outlineVertices; ///< Vertex array containing the outline geometry
|
||||||
mutable FloatRect m_bounds; ///< Bounding rectangle of the text (in local coordinates)
|
mutable FloatRect m_bounds; ///< Bounding rectangle of the text (in local coordinates)
|
||||||
mutable bool m_geometryNeedUpdate; ///< Does the geometry need to be recomputed?
|
mutable bool m_geometryNeedUpdate; ///< Does the geometry need to be recomputed?
|
||||||
|
mutable Uint64 m_fontTextureId; ///< The font texture id
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sf
|
} // namespace sf
|
||||||
|
@ -35,10 +35,11 @@
|
|||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
{
|
{
|
||||||
class Window;
|
class InputStream;
|
||||||
class RenderTarget;
|
class RenderTarget;
|
||||||
class RenderTexture;
|
class RenderTexture;
|
||||||
class InputStream;
|
class Text;
|
||||||
|
class Window;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Image living on the graphics card that can be used for drawing
|
/// \brief Image living on the graphics card that can be used for drawing
|
||||||
@ -584,6 +585,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
friend class Text;
|
||||||
friend class RenderTexture;
|
friend class RenderTexture;
|
||||||
friend class RenderTarget;
|
friend class RenderTarget;
|
||||||
|
|
||||||
|
@ -84,7 +84,8 @@ m_outlineThickness (0),
|
|||||||
m_vertices (Triangles),
|
m_vertices (Triangles),
|
||||||
m_outlineVertices (Triangles),
|
m_outlineVertices (Triangles),
|
||||||
m_bounds (),
|
m_bounds (),
|
||||||
m_geometryNeedUpdate(false)
|
m_geometryNeedUpdate(false),
|
||||||
|
m_fontTextureId (0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -102,7 +103,8 @@ m_outlineThickness (0),
|
|||||||
m_vertices (Triangles),
|
m_vertices (Triangles),
|
||||||
m_outlineVertices (Triangles),
|
m_outlineVertices (Triangles),
|
||||||
m_bounds (),
|
m_bounds (),
|
||||||
m_geometryNeedUpdate(true)
|
m_geometryNeedUpdate(true),
|
||||||
|
m_fontTextureId (0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -346,10 +348,16 @@ void Text::draw(RenderTarget& target, RenderStates states) const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Text::ensureGeometryUpdate() const
|
void Text::ensureGeometryUpdate() const
|
||||||
{
|
{
|
||||||
// Do nothing, if geometry has not changed
|
if (!m_font)
|
||||||
if (!m_geometryNeedUpdate)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Do nothing, if geometry has not changed and the font texture has not changed
|
||||||
|
if (!m_geometryNeedUpdate && m_font->getTexture(m_characterSize).m_cacheId == m_fontTextureId)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Save the current fonts texture id
|
||||||
|
m_fontTextureId = m_font->getTexture(m_characterSize).m_cacheId;
|
||||||
|
|
||||||
// Mark geometry as updated
|
// Mark geometry as updated
|
||||||
m_geometryNeedUpdate = false;
|
m_geometryNeedUpdate = false;
|
||||||
|
|
||||||
@ -358,8 +366,8 @@ void Text::ensureGeometryUpdate() const
|
|||||||
m_outlineVertices.clear();
|
m_outlineVertices.clear();
|
||||||
m_bounds = FloatRect();
|
m_bounds = FloatRect();
|
||||||
|
|
||||||
// No font or text: nothing to draw
|
// No text: nothing to draw
|
||||||
if (!m_font || m_string.isEmpty())
|
if (m_string.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Compute values related to the text style
|
// Compute values related to the text style
|
||||||
|
Loading…
Reference in New Issue
Block a user