1
0
Fork 0

Font: rename Driver stuff to Engine and move subdirectory

This commit is contained in:
Henrik Hautakoski 2020-01-05 23:29:43 +01:00
parent 8b96338e24
commit 5c4eea4ae1
No known key found for this signature in database
GPG key ID: 96765B12FEAC4745
11 changed files with 57 additions and 57 deletions

View file

@ -5,27 +5,27 @@
#include <Spectre/Graphics/Image.h>
#include <Spectre/Graphics/Texture.h>
#include <Spectre/Math/Math.h>
#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)) {

View file

@ -0,0 +1,16 @@
#include "FontEngine.h"
namespace sp {
FontEngine::FontEngine() :
m_hinting (true)
{
}
void FontEngine::setHinting(bool value)
{
m_hinting = value;
}
} // namespace sp

View file

@ -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 <string>
#include <Spectre/Graphics/Image.h>
@ -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 */

View file

@ -7,7 +7,7 @@
#include <Spectre/System/Log.h>
#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;
}

View file

@ -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 <ft2build.h>
#include FT_FREETYPE_H
#include <string>
#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 */

View file

@ -0,0 +1,10 @@
#ifndef SPECTRE_GRAPHICS_FONT_ENGINE_FREETYPE_ERROR_H
#define SPECTRE_GRAPHICS_FONT_ENGINE_FREETYPE_ERROR_H
#include <ft2build.h>
#include FT_FREETYPE_H
const char* FT_GetErrorString(FT_Error error);
#endif /* SPECTRE_GRAPHICS_FONT_ENGINE_FREETYPE_ERROR_H */

View file

@ -1,16 +0,0 @@
#include "FontDriver.h"
namespace sp {
FontDriver::FontDriver() :
m_hinting (true)
{
}
void FontDriver::setHinting(bool value)
{
m_hinting = value;
}
} // namespace sp

View file

@ -1,10 +0,0 @@
#ifndef SPECTRE_GRAPHICS_FONT_FREETYPE_ERROR_H
#define SPECTRE_GRAPHICS_FONT_FREETYPE_ERROR_H
#include <ft2build.h>
#include FT_FREETYPE_H
const char* FT_GetErrorString(FT_Error error);
#endif /* SPECTRE_GRAPHICS_FONT_FREETYPE_ERROR_H */