diff --git a/bam.lua b/bam.lua index e165506..8379d00 100644 --- a/bam.lua +++ b/bam.lua @@ -154,9 +154,9 @@ local graphics_module = Module("source/Graphics", { "Texture.cpp", -- Text - "Font/FontDriver.cpp", - "Font/FreeTypeDriver.cpp", - "Font/FreeTypeError.cpp", + "Font/Engine/FontEngine.cpp", + "Font/Engine/FreeTypeEngine.cpp", + "Font/Engine/FreeTypeError.cpp", "Font.cpp", "Text.cpp", diff --git a/include/Spectre/Graphics/Font.h b/include/Spectre/Graphics/Font.h index 5caba40..8a33b50 100644 --- a/include/Spectre/Graphics/Font.h +++ b/include/Spectre/Graphics/Font.h @@ -12,7 +12,7 @@ namespace sp { -class FontDriver; +class FontEngine; // TODO: Fixup this api :) @@ -65,7 +65,7 @@ protected : Texture texture; }; - FontDriver *m_driver; + FontEngine *m_engine; mutable std::map m_charset; diff --git a/source/Graphics/Font.cpp b/source/Graphics/Font.cpp index 2f76461..a2ca857 100644 --- a/source/Graphics/Font.cpp +++ b/source/Graphics/Font.cpp @@ -5,27 +5,27 @@ #include #include #include -#include "Font/FreeTypeDriver.h" +#include "Font/Engine/FreeTypeEngine.h" namespace sp { Font::Font() : -m_driver (new FreeTypeDriver()) +m_engine (new FreeTypeEngine()) { } Font::~Font() { - delete m_driver; + delete m_engine; } bool Font::loadFromFile(const std::string& filename) { - if (!m_driver->loadFromFile(filename)) { + if (!m_engine->loadFromFile(filename)) { return false; } - if (!m_driver->setCharacterSize(22)) { + if (!m_engine->setCharacterSize(22)) { return false; } @@ -56,11 +56,11 @@ void Font::loadChar(unsigned char code) const Image img; Font::Glyph glyph; - if (!m_driver) { + if (!m_engine) { return; } - glyph = m_driver->loadGlyph(code, img); + glyph = m_engine->loadGlyph(code, img); if (glyph.size > vec2b(0, 0)) { diff --git a/source/Graphics/Font/Engine/FontEngine.cpp b/source/Graphics/Font/Engine/FontEngine.cpp new file mode 100644 index 0000000..f672f7e --- /dev/null +++ b/source/Graphics/Font/Engine/FontEngine.cpp @@ -0,0 +1,16 @@ + +#include "FontEngine.h" + +namespace sp { + +FontEngine::FontEngine() : +m_hinting (true) +{ +} + +void FontEngine::setHinting(bool value) +{ + m_hinting = value; +} + +} // namespace sp diff --git a/source/Graphics/Font/FontDriver.h b/source/Graphics/Font/Engine/FontEngine.h similarity index 73% rename from source/Graphics/Font/FontDriver.h rename to source/Graphics/Font/Engine/FontEngine.h index d222fed..c17773c 100644 --- a/source/Graphics/Font/FontDriver.h +++ b/source/Graphics/Font/Engine/FontEngine.h @@ -1,6 +1,6 @@ -#ifndef SPECTRE_GRAPHICS_FONT_FONTDRIVER_H -#define SPECTRE_GRAPHICS_FONT_FONTDRIVER_H +#ifndef SPECTRE_GRAPHICS_FONT_ENGINE_FONTENGINE_H +#define SPECTRE_GRAPHICS_FONT_ENGINE_FONTENGINE_H #include #include @@ -8,11 +8,11 @@ namespace sp { -class FontDriver +class FontEngine { public : - FontDriver(); + FontEngine(); void setHinting(bool value); @@ -32,4 +32,4 @@ protected : } // namespace sp -#endif /* SPECTRE_GRAPHICS_FONT_FONTDRIVER_H */ +#endif /* SPECTRE_GRAPHICS_FONT_ENGINE_FONTENGINE_H */ diff --git a/source/Graphics/Font/FreeTypeDriver.cpp b/source/Graphics/Font/Engine/FreeTypeEngine.cpp similarity index 91% rename from source/Graphics/Font/FreeTypeDriver.cpp rename to source/Graphics/Font/Engine/FreeTypeEngine.cpp index aa953c4..f5b857e 100644 --- a/source/Graphics/Font/FreeTypeDriver.cpp +++ b/source/Graphics/Font/Engine/FreeTypeEngine.cpp @@ -7,7 +7,7 @@ #include #include "FreeTypeError.h" -#include "FreeTypeDriver.h" +#include "FreeTypeEngine.h" namespace sp { @@ -58,19 +58,19 @@ LibWrapper::~LibWrapper() } } -FreeTypeDriver::FreeTypeDriver() : +FreeTypeEngine::FreeTypeEngine() : m_face (NULL) { } -FreeTypeDriver::~FreeTypeDriver() +FreeTypeEngine::~FreeTypeEngine() { if (m_face) { FT_Done_Face(m_face); } } -bool FreeTypeDriver::setCharacterSize(unsigned int size) +bool FreeTypeEngine::setCharacterSize(unsigned int size) { FT_Error error = FT_Set_Pixel_Sizes(m_face, 0, size); if (error) { @@ -80,7 +80,7 @@ bool FreeTypeDriver::setCharacterSize(unsigned int size) return true; } -bool FreeTypeDriver::loadFromFile(const std::string& filename) +bool FreeTypeEngine::loadFromFile(const std::string& filename) { FT_Face face; FT_Error error; @@ -103,7 +103,7 @@ bool FreeTypeDriver::loadFromFile(const std::string& filename) return true; } -Font::Glyph FreeTypeDriver::loadGlyph(unsigned int codepoint, Image& img, unsigned int outlineSize) +Font::Glyph FreeTypeEngine::loadGlyph(unsigned int codepoint, Image& img, unsigned int outlineSize) { Font::Glyph glyph; FT_Glyph glyph_info; @@ -163,7 +163,7 @@ Font::Glyph FreeTypeDriver::loadGlyph(unsigned int codepoint, Image& img, unsign return glyph; } -std::string FreeTypeDriver::getName() +std::string FreeTypeEngine::getName() { return m_face->family_name; } diff --git a/source/Graphics/Font/FreeTypeDriver.h b/source/Graphics/Font/Engine/FreeTypeEngine.h similarity index 58% rename from source/Graphics/Font/FreeTypeDriver.h rename to source/Graphics/Font/Engine/FreeTypeEngine.h index 669cfb8..fa90b26 100644 --- a/source/Graphics/Font/FreeTypeDriver.h +++ b/source/Graphics/Font/Engine/FreeTypeEngine.h @@ -1,20 +1,20 @@ -#ifndef SPECTRE_GRAPHICS_FONT_FREETYPEDRIVER_H -#define SPECTRE_GRAPHICS_FONT_FREETYPEDRIVER_H +#ifndef SPECTRE_GRAPHICS_FONT_ENGINE_FREETYPEENGINE_H +#define SPECTRE_GRAPHICS_FONT_ENGINE_FREETYPEENGINE_H #include #include FT_FREETYPE_H #include -#include "FontDriver.h" +#include "FontEngine.h" namespace sp { -class FreeTypeDriver : public FontDriver +class FreeTypeEngine : public FontEngine { public: - FreeTypeDriver(); - ~FreeTypeDriver(); + FreeTypeEngine(); + ~FreeTypeEngine(); virtual bool setCharacterSize(unsigned int size); @@ -31,4 +31,4 @@ private : } // namespace sp -#endif /* SPECTRE_GRAPHICS_FONT_FREETYPEDRIVER_H */ +#endif /* SPECTRE_GRAPHICS_FONT_ENGINE_FREETYPEENGINE_H */ diff --git a/source/Graphics/Font/FreeTypeError.cpp b/source/Graphics/Font/Engine/FreeTypeError.cpp similarity index 100% rename from source/Graphics/Font/FreeTypeError.cpp rename to source/Graphics/Font/Engine/FreeTypeError.cpp diff --git a/source/Graphics/Font/Engine/FreeTypeError.h b/source/Graphics/Font/Engine/FreeTypeError.h new file mode 100644 index 0000000..bbe4ec6 --- /dev/null +++ b/source/Graphics/Font/Engine/FreeTypeError.h @@ -0,0 +1,10 @@ + +#ifndef SPECTRE_GRAPHICS_FONT_ENGINE_FREETYPE_ERROR_H +#define SPECTRE_GRAPHICS_FONT_ENGINE_FREETYPE_ERROR_H + +#include +#include FT_FREETYPE_H + +const char* FT_GetErrorString(FT_Error error); + +#endif /* SPECTRE_GRAPHICS_FONT_ENGINE_FREETYPE_ERROR_H */ diff --git a/source/Graphics/Font/FontDriver.cpp b/source/Graphics/Font/FontDriver.cpp deleted file mode 100644 index e64e54d..0000000 --- a/source/Graphics/Font/FontDriver.cpp +++ /dev/null @@ -1,16 +0,0 @@ - -#include "FontDriver.h" - -namespace sp { - -FontDriver::FontDriver() : -m_hinting (true) -{ -} - -void FontDriver::setHinting(bool value) -{ - m_hinting = value; -} - -} // namespace sp diff --git a/source/Graphics/Font/FreeTypeError.h b/source/Graphics/Font/FreeTypeError.h deleted file mode 100644 index 47d76e3..0000000 --- a/source/Graphics/Font/FreeTypeError.h +++ /dev/null @@ -1,10 +0,0 @@ - -#ifndef SPECTRE_GRAPHICS_FONT_FREETYPE_ERROR_H -#define SPECTRE_GRAPHICS_FONT_FREETYPE_ERROR_H - -#include -#include FT_FREETYPE_H - -const char* FT_GetErrorString(FT_Error error); - -#endif /* SPECTRE_GRAPHICS_FONT_FREETYPE_ERROR_H */