TrueType Textures are now loading properly.
This commit is contained in:
@ -9,17 +9,21 @@
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
TrueTypeTexture::TrueTypeTexture(FT_Face face, uint32_t fontSize) :
|
||||
face(face),
|
||||
TrueTypeTexture::TrueTypeTexture(const uint32_t fontSize) :
|
||||
fontSize(fontSize)
|
||||
{
|
||||
assertTrue(fontSize > 0, "Font size cannot be zero");
|
||||
texture = std::make_shared<Texture>();
|
||||
}
|
||||
|
||||
void TrueTypeTexture::setFace(const FT_Face face) {
|
||||
this->face = face;
|
||||
assertTrue(fontSize < 256, "Font size cannot be greater than 256");
|
||||
|
||||
texture = std::make_shared<Texture>();
|
||||
|
||||
// Set freetype font size prior to baking.
|
||||
if(FT_Set_Pixel_Sizes(face, 0, fontSize)) {
|
||||
assertUnreachable("Failed to set font size");
|
||||
auto ret = FT_Set_Pixel_Sizes(face, 0, fontSize);
|
||||
if(ret != 0) {
|
||||
assertUnreachable("Failed to set font size %i", ret);
|
||||
}
|
||||
|
||||
// Set the texture size
|
||||
@ -126,5 +130,4 @@ struct TrueTypeCharacter TrueTypeTexture::getCharacterData(wchar_t c) {
|
||||
}
|
||||
|
||||
TrueTypeTexture::~TrueTypeTexture() {
|
||||
FT_Done_Face(this->face);
|
||||
}
|
@ -11,19 +11,27 @@
|
||||
|
||||
namespace Dawn {
|
||||
class TrueTypeTexture final {
|
||||
public:
|
||||
private:
|
||||
FT_Face face;
|
||||
std::shared_ptr<Texture> texture;
|
||||
uint32_t fontSize;
|
||||
|
||||
public:
|
||||
std::shared_ptr<Texture> texture;
|
||||
std::unordered_map<wchar_t, struct TrueTypeCharacter> characterData;
|
||||
|
||||
/**
|
||||
* Construct a new New True Type Face Texture object
|
||||
*
|
||||
* @param face The freetype face object.
|
||||
* @param fontSize The font size to render at.
|
||||
* @param fontSize Size of the font.
|
||||
*/
|
||||
TrueTypeTexture(FT_Face face, uint32_t fontSize);
|
||||
TrueTypeTexture(const uint32_t fontSize);
|
||||
|
||||
/**
|
||||
* Sets the face for this texture.
|
||||
*
|
||||
* @param face Face to set.
|
||||
*/
|
||||
void setFace(const FT_Face face);
|
||||
|
||||
/**
|
||||
* Returns the character data for the given character.
|
||||
|
Reference in New Issue
Block a user