Font: rename Driver stuff to Engine and move subdirectory
This commit is contained in:
parent
8b96338e24
commit
5c4eea4ae1
11 changed files with 57 additions and 57 deletions
6
bam.lua
6
bam.lua
|
|
@ -154,9 +154,9 @@ local graphics_module = Module("source/Graphics", {
|
||||||
"Texture.cpp",
|
"Texture.cpp",
|
||||||
|
|
||||||
-- Text
|
-- Text
|
||||||
"Font/FontDriver.cpp",
|
"Font/Engine/FontEngine.cpp",
|
||||||
"Font/FreeTypeDriver.cpp",
|
"Font/Engine/FreeTypeEngine.cpp",
|
||||||
"Font/FreeTypeError.cpp",
|
"Font/Engine/FreeTypeError.cpp",
|
||||||
"Font.cpp",
|
"Font.cpp",
|
||||||
"Text.cpp",
|
"Text.cpp",
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
namespace sp {
|
namespace sp {
|
||||||
|
|
||||||
class FontDriver;
|
class FontEngine;
|
||||||
|
|
||||||
// TODO: Fixup this api :)
|
// TODO: Fixup this api :)
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ protected :
|
||||||
Texture texture;
|
Texture texture;
|
||||||
};
|
};
|
||||||
|
|
||||||
FontDriver *m_driver;
|
FontEngine *m_engine;
|
||||||
|
|
||||||
mutable std::map<unsigned char, Glyph> m_charset;
|
mutable std::map<unsigned char, Glyph> m_charset;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,27 +5,27 @@
|
||||||
#include <Spectre/Graphics/Image.h>
|
#include <Spectre/Graphics/Image.h>
|
||||||
#include <Spectre/Graphics/Texture.h>
|
#include <Spectre/Graphics/Texture.h>
|
||||||
#include <Spectre/Math/Math.h>
|
#include <Spectre/Math/Math.h>
|
||||||
#include "Font/FreeTypeDriver.h"
|
#include "Font/Engine/FreeTypeEngine.h"
|
||||||
|
|
||||||
namespace sp {
|
namespace sp {
|
||||||
|
|
||||||
Font::Font() :
|
Font::Font() :
|
||||||
m_driver (new FreeTypeDriver())
|
m_engine (new FreeTypeEngine())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Font::~Font()
|
Font::~Font()
|
||||||
{
|
{
|
||||||
delete m_driver;
|
delete m_engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Font::loadFromFile(const std::string& filename)
|
bool Font::loadFromFile(const std::string& filename)
|
||||||
{
|
{
|
||||||
if (!m_driver->loadFromFile(filename)) {
|
if (!m_engine->loadFromFile(filename)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_driver->setCharacterSize(22)) {
|
if (!m_engine->setCharacterSize(22)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,11 +56,11 @@ void Font::loadChar(unsigned char code) const
|
||||||
Image img;
|
Image img;
|
||||||
Font::Glyph glyph;
|
Font::Glyph glyph;
|
||||||
|
|
||||||
if (!m_driver) {
|
if (!m_engine) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
glyph = m_driver->loadGlyph(code, img);
|
glyph = m_engine->loadGlyph(code, img);
|
||||||
|
|
||||||
if (glyph.size > vec2b(0, 0)) {
|
if (glyph.size > vec2b(0, 0)) {
|
||||||
|
|
||||||
|
|
|
||||||
16
source/Graphics/Font/Engine/FontEngine.cpp
Normal file
16
source/Graphics/Font/Engine/FontEngine.cpp
Normal 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
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
#ifndef SPECTRE_GRAPHICS_FONT_FONTDRIVER_H
|
#ifndef SPECTRE_GRAPHICS_FONT_ENGINE_FONTENGINE_H
|
||||||
#define SPECTRE_GRAPHICS_FONT_FONTDRIVER_H
|
#define SPECTRE_GRAPHICS_FONT_ENGINE_FONTENGINE_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <Spectre/Graphics/Image.h>
|
#include <Spectre/Graphics/Image.h>
|
||||||
|
|
@ -8,11 +8,11 @@
|
||||||
|
|
||||||
namespace sp {
|
namespace sp {
|
||||||
|
|
||||||
class FontDriver
|
class FontEngine
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
|
|
||||||
FontDriver();
|
FontEngine();
|
||||||
|
|
||||||
void setHinting(bool value);
|
void setHinting(bool value);
|
||||||
|
|
||||||
|
|
@ -32,4 +32,4 @@ protected :
|
||||||
|
|
||||||
} // namespace sp
|
} // namespace sp
|
||||||
|
|
||||||
#endif /* SPECTRE_GRAPHICS_FONT_FONTDRIVER_H */
|
#endif /* SPECTRE_GRAPHICS_FONT_ENGINE_FONTENGINE_H */
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include <Spectre/System/Log.h>
|
#include <Spectre/System/Log.h>
|
||||||
#include "FreeTypeError.h"
|
#include "FreeTypeError.h"
|
||||||
#include "FreeTypeDriver.h"
|
#include "FreeTypeEngine.h"
|
||||||
|
|
||||||
namespace sp {
|
namespace sp {
|
||||||
|
|
||||||
|
|
@ -58,19 +58,19 @@ LibWrapper::~LibWrapper()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeTypeDriver::FreeTypeDriver() :
|
FreeTypeEngine::FreeTypeEngine() :
|
||||||
m_face (NULL)
|
m_face (NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeTypeDriver::~FreeTypeDriver()
|
FreeTypeEngine::~FreeTypeEngine()
|
||||||
{
|
{
|
||||||
if (m_face) {
|
if (m_face) {
|
||||||
FT_Done_Face(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);
|
FT_Error error = FT_Set_Pixel_Sizes(m_face, 0, size);
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|
@ -80,7 +80,7 @@ bool FreeTypeDriver::setCharacterSize(unsigned int size)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FreeTypeDriver::loadFromFile(const std::string& filename)
|
bool FreeTypeEngine::loadFromFile(const std::string& filename)
|
||||||
{
|
{
|
||||||
FT_Face face;
|
FT_Face face;
|
||||||
FT_Error error;
|
FT_Error error;
|
||||||
|
|
@ -103,7 +103,7 @@ bool FreeTypeDriver::loadFromFile(const std::string& filename)
|
||||||
return true;
|
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;
|
Font::Glyph glyph;
|
||||||
FT_Glyph glyph_info;
|
FT_Glyph glyph_info;
|
||||||
|
|
@ -163,7 +163,7 @@ Font::Glyph FreeTypeDriver::loadGlyph(unsigned int codepoint, Image& img, unsign
|
||||||
return glyph;
|
return glyph;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FreeTypeDriver::getName()
|
std::string FreeTypeEngine::getName()
|
||||||
{
|
{
|
||||||
return m_face->family_name;
|
return m_face->family_name;
|
||||||
}
|
}
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
|
|
||||||
#ifndef SPECTRE_GRAPHICS_FONT_FREETYPEDRIVER_H
|
#ifndef SPECTRE_GRAPHICS_FONT_ENGINE_FREETYPEENGINE_H
|
||||||
#define SPECTRE_GRAPHICS_FONT_FREETYPEDRIVER_H
|
#define SPECTRE_GRAPHICS_FONT_ENGINE_FREETYPEENGINE_H
|
||||||
|
|
||||||
#include <ft2build.h>
|
#include <ft2build.h>
|
||||||
#include FT_FREETYPE_H
|
#include FT_FREETYPE_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "FontDriver.h"
|
#include "FontEngine.h"
|
||||||
|
|
||||||
namespace sp {
|
namespace sp {
|
||||||
|
|
||||||
class FreeTypeDriver : public FontDriver
|
class FreeTypeEngine : public FontEngine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FreeTypeDriver();
|
FreeTypeEngine();
|
||||||
~FreeTypeDriver();
|
~FreeTypeEngine();
|
||||||
|
|
||||||
virtual bool setCharacterSize(unsigned int size);
|
virtual bool setCharacterSize(unsigned int size);
|
||||||
|
|
||||||
|
|
@ -31,4 +31,4 @@ private :
|
||||||
|
|
||||||
} // namespace sp
|
} // namespace sp
|
||||||
|
|
||||||
#endif /* SPECTRE_GRAPHICS_FONT_FREETYPEDRIVER_H */
|
#endif /* SPECTRE_GRAPHICS_FONT_ENGINE_FREETYPEENGINE_H */
|
||||||
10
source/Graphics/Font/Engine/FreeTypeError.h
Normal file
10
source/Graphics/Font/Engine/FreeTypeError.h
Normal 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 */
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
|
|
||||||
#include "FontDriver.h"
|
|
||||||
|
|
||||||
namespace sp {
|
|
||||||
|
|
||||||
FontDriver::FontDriver() :
|
|
||||||
m_hinting (true)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void FontDriver::setHinting(bool value)
|
|
||||||
{
|
|
||||||
m_hinting = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace sp
|
|
||||||
|
|
@ -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 */
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue