Removed the built-in default font

This commit is contained in:
Laurent Gomila 2012-08-03 23:50:34 +02:00
parent a3357d9c10
commit a0c1f5f50f
9 changed files with 53 additions and 14752 deletions

File diff suppressed because it is too large Load diff

View file

@ -326,28 +326,6 @@ Font& Font::operator =(const Font& right)
}
////////////////////////////////////////////////////////////
const Font& Font::getDefaultFont()
{
static Font font;
static bool loaded = false;
// Load the default font on first call
if (!loaded)
{
static const signed char data[] =
{
#include <SFML/Graphics/Arial.hpp>
};
font.loadFromMemory(data, sizeof(data));
loaded = true;
}
return font;
}
////////////////////////////////////////////////////////////
void Font::cleanup()
{

View file

@ -36,7 +36,7 @@ namespace sf
////////////////////////////////////////////////////////////
Text::Text() :
m_string (),
m_font (&Font::getDefaultFont()),
m_font (NULL),
m_characterSize(30),
m_style (Regular),
m_color (255, 255, 255),
@ -122,10 +122,9 @@ const String& Text::getString() const
////////////////////////////////////////////////////////////
const Font& Text::getFont() const
const Font* Text::getFont() const
{
assert(m_font != NULL); // can never be NULL, always &Font::getDefaultFont() by default
return *m_font;
return m_font;
}
@ -153,7 +152,9 @@ const Color& Text::getColor() const
////////////////////////////////////////////////////////////
Vector2f Text::findCharacterPos(std::size_t index) const
{
assert(m_font != NULL);
// Make sure that we have a valid font
if (!m_font)
return Vector2f();
// Adjust the index if it's out of range
if (index > m_string.getSize())
@ -212,23 +213,26 @@ FloatRect Text::getGlobalBounds() const
////////////////////////////////////////////////////////////
void Text::draw(RenderTarget& target, RenderStates states) const
{
assert(m_font != NULL);
states.transform *= getTransform();
states.blendMode = BlendAlpha; // alpha blending is mandatory for proper text rendering
states.texture = &m_font->getTexture(m_characterSize);
target.draw(m_vertices, states);
if (m_font)
{
states.transform *= getTransform();
states.blendMode = BlendAlpha; // alpha blending is mandatory for proper text rendering
states.texture = &m_font->getTexture(m_characterSize);
target.draw(m_vertices, states);
}
}
////////////////////////////////////////////////////////////
void Text::updateGeometry()
{
assert(m_font != NULL);
// Clear the previous geometry
m_vertices.clear();
// No font: nothing to draw
if (!m_font)
return;
// No text: nothing to draw
if (m_string.isEmpty())
return;