SDOM - Simple SDL Document Object Model
A lightweight, extensible Document Object Model for SDL-based applications.
Loading...
Searching...
No Matches
SDOM::TruetypeFont Class Reference

#include <SDOM_TruetypeFont.hpp>

Inheritance diagram for SDOM::TruetypeFont:
SDOM::IFontObject SDOM::IAssetObject SDOM::IDataObject SDOM::IUnitTest

Classes

struct  InitStruct
 

Public Types

enum class  FontType { Bitmap , Truetype }
 

Public Member Functions

virtual ~TruetypeFont () override
 
virtual bool onInit () override
 
virtual void onQuit () override
 
virtual void onLoad () override
 
virtual void onUnload () override
 
virtual void create (const sol::table &config) override
 
virtual void drawGlyph (Uint32 ch, int x, int y, const FontStyle &style) override
 
virtual void drawPhrase (const std::string &str, int x, int y, const FontStyle &style) override
 
virtual void drawPhraseOutline (const std::string &str, int x, int y, const FontStyle &style) override
 
virtual void drawPhraseDropshadow (const std::string &str, int x, int y, const FontStyle &style) override
 
virtual bool getGlyphMetrics (Uint32 ch, int *minx, int *maxx, int *miny, int *maxy, int *advance) const override
 
virtual int getGlyphHeight (Uint32 ch) const override
 
virtual int getGlyphWidth (Uint32 ch) const override
 
virtual int getFontAscent () override
 
virtual int getFontSize () override
 
virtual void setFontSize (int p_size) override
 
virtual void setFontStyle (const FontStyle &style) override
 
virtual FontStyle getFontStyle () override
 
AssetHandle getResourceHandle () const
 
int getFontSize () const
 
int getWordWidth (const std::string &word) const
 
int getWordHeight (const std::string &word) const
 
FontType getFontType () const
 
virtual bool onUnitTest () override
 Runs unit tests for this object.
 
const std::string & getType () const
 
const std::string & getName () const
 
const std::string & getFilename () const
 
bool isInternal () const
 
bool isLoaded () const
 
void setType (const std::string &type)
 
void setName (const std::string &name)
 
void setFilename (const std::string &filename)
 
template<typename T >
T * as ()
 
void registerLuaBindings (const std::string &typeName, sol::state_view lua)
 

Static Public Member Functions

static std::unique_ptr< IAssetObjectCreateFromLua (const sol::table &config)
 
static std::unique_ptr< IAssetObjectCreateFromInitStruct (const IAssetObject::InitStruct &baseInit)
 
static void applyBitmapFontDefaults (class Factory &factory, const std::string &fontResourceName, int &outFontSize, int &outFontWidth, int &outFontHeight)
 
template<typename T >
static T lua_value_case_insensitive (const sol::table &tbl, const std::string &key, const T &default_value)
 

Static Public Attributes

static constexpr const char * TypeName = "truetype"
 
static std::unordered_map< FontType, std::string > FontTypeToString
 
static std::unordered_map< std::string, FontTypeStringToFontType
 

Protected Member Functions

 TruetypeFont (const InitStruct &init)
 
 TruetypeFont (const sol::table &config)
 
TTF_Font * _getValidTTFFontPtr () const
 
void initializeOutlineGlyph (Uint32 ch, int x, int y)
 
void drawForegroundGlyph (Uint32 ch, int x, int y, const FontStyle &style)
 
void drawOutlineGlyph (Uint32 ch, int x, int y, const FontStyle &style)
 
void drawDropShadowGlyph (Uint32 ch, int x, int y, const FontStyle &style)
 
virtual void _registerLuaBindings (const std::string &typeName, sol::state_view lua)
 

Protected Attributes

AssetHandle ttf_font_handle_
 
int last_size_ = 0
 
int activeFontWidth_ = -1
 
int activeFontHeight_ = -1
 
friend Factory
 
friend Core
 
int fontSize_ = 8
 
FontType fontType_ = FontType::Bitmap
 
std::string name_
 
std::string type_
 
std::string filename_
 
bool isInternal_
 
bool isLoaded_ = false
 
sol::usertype< IAssetObjectobjHandleType_
 

Member Enumeration Documentation

◆ FontType

enum class SDOM::IFontObject::FontType
stronginherited
Enumerator
Bitmap 
Truetype 

Constructor & Destructor Documentation

◆ TruetypeFont() [1/2]

SDOM::TruetypeFont::TruetypeFont ( const InitStruct init)
protected

◆ TruetypeFont() [2/2]

SDOM::TruetypeFont::TruetypeFont ( const sol::table &  config)
protected

◆ ~TruetypeFont()

SDOM::TruetypeFont::~TruetypeFont ( )
overridevirtual

Member Function Documentation

◆ _getValidTTFFontPtr()

TTF_Font * SDOM::TruetypeFont::_getValidTTFFontPtr ( ) const
protected

◆ _registerLuaBindings()

void SDOM::TruetypeFont::_registerLuaBindings ( const std::string &  typeName,
sol::state_view  lua 
)
protectedvirtual

Reimplemented from SDOM::IFontObject.

◆ applyBitmapFontDefaults()

void SDOM::IFontObject::applyBitmapFontDefaults ( class Factory factory,
const std::string &  fontResourceName,
int &  outFontSize,
int &  outFontWidth,
int &  outFontHeight 
)
staticinherited

◆ as()

template<typename T >
T * SDOM::IAssetObject::as ( )
inlineinherited

◆ create()

void SDOM::TruetypeFont::create ( const sol::table &  config)
overridevirtual

Implements SDOM::IFontObject.

◆ CreateFromInitStruct()

static std::unique_ptr< IAssetObject > SDOM::TruetypeFont::CreateFromInitStruct ( const IAssetObject::InitStruct baseInit)
inlinestatic

◆ CreateFromLua()

static std::unique_ptr< IAssetObject > SDOM::TruetypeFont::CreateFromLua ( const sol::table &  config)
inlinestatic

◆ drawDropShadowGlyph()

void SDOM::TruetypeFont::drawDropShadowGlyph ( Uint32  ch,
int  x,
int  y,
const FontStyle style 
)
protected

◆ drawForegroundGlyph()

void SDOM::TruetypeFont::drawForegroundGlyph ( Uint32  ch,
int  x,
int  y,
const FontStyle style 
)
protected

◆ drawGlyph()

void SDOM::TruetypeFont::drawGlyph ( Uint32  ch,
int  x,
int  y,
const FontStyle style 
)
overridevirtual

Implements SDOM::IFontObject.

◆ drawOutlineGlyph()

void SDOM::TruetypeFont::drawOutlineGlyph ( Uint32  ch,
int  x,
int  y,
const FontStyle style 
)
protected

◆ drawPhrase()

void SDOM::TruetypeFont::drawPhrase ( const std::string &  str,
int  x,
int  y,
const FontStyle style 
)
overridevirtual

Implements SDOM::IFontObject.

◆ drawPhraseDropshadow()

void SDOM::TruetypeFont::drawPhraseDropshadow ( const std::string &  str,
int  x,
int  y,
const FontStyle style 
)
overridevirtual

Implements SDOM::IFontObject.

◆ drawPhraseOutline()

void SDOM::TruetypeFont::drawPhraseOutline ( const std::string &  str,
int  x,
int  y,
const FontStyle style 
)
overridevirtual

Implements SDOM::IFontObject.

◆ getFilename()

const std::string & SDOM::IAssetObject::getFilename ( ) const
inlineinherited

◆ getFontAscent()

int SDOM::TruetypeFont::getFontAscent ( )
overridevirtual

Implements SDOM::IFontObject.

◆ getFontSize() [1/2]

int SDOM::IFontObject::getFontSize ( ) const
inlineinherited

◆ getFontSize() [2/2]

int SDOM::TruetypeFont::getFontSize ( )
overridevirtual

Implements SDOM::IFontObject.

◆ getFontStyle()

FontStyle SDOM::TruetypeFont::getFontStyle ( )
overridevirtual

Implements SDOM::IFontObject.

◆ getFontType()

FontType SDOM::IFontObject::getFontType ( ) const
inlineinherited

◆ getGlyphHeight()

int SDOM::TruetypeFont::getGlyphHeight ( Uint32  ch) const
overridevirtual

Implements SDOM::IFontObject.

◆ getGlyphMetrics()

bool SDOM::TruetypeFont::getGlyphMetrics ( Uint32  ch,
int *  minx,
int *  maxx,
int *  miny,
int *  maxy,
int *  advance 
) const
overridevirtual

Implements SDOM::IFontObject.

◆ getGlyphWidth()

int SDOM::TruetypeFont::getGlyphWidth ( Uint32  ch) const
overridevirtual

Implements SDOM::IFontObject.

◆ getName()

const std::string & SDOM::IAssetObject::getName ( ) const
inlineinherited

◆ getResourceHandle()

AssetHandle SDOM::TruetypeFont::getResourceHandle ( ) const
inline

◆ getType()

const std::string & SDOM::IAssetObject::getType ( ) const
inlineinherited

◆ getWordHeight()

int SDOM::IFontObject::getWordHeight ( const std::string &  word) const
inherited

◆ getWordWidth()

int SDOM::IFontObject::getWordWidth ( const std::string &  word) const
inherited

◆ initializeOutlineGlyph()

void SDOM::TruetypeFont::initializeOutlineGlyph ( Uint32  ch,
int  x,
int  y 
)
protected

◆ isInternal()

bool SDOM::IAssetObject::isInternal ( ) const
inlineinherited

◆ isLoaded()

bool SDOM::IAssetObject::isLoaded ( ) const
inlineinherited

◆ lua_value_case_insensitive()

template<typename T >
static T SDOM::IDataObject::lua_value_case_insensitive ( const sol::table &  tbl,
const std::string &  key,
const T &  default_value 
)
inlinestaticinherited

◆ onInit()

bool SDOM::TruetypeFont::onInit ( )
overridevirtual

Implements SDOM::IFontObject.

◆ onLoad()

void SDOM::TruetypeFont::onLoad ( )
overridevirtual

Implements SDOM::IFontObject.

◆ onQuit()

void SDOM::TruetypeFont::onQuit ( )
overridevirtual

Implements SDOM::IFontObject.

◆ onUnitTest()

virtual bool SDOM::IAssetObject::onUnitTest ( )
inlineoverridevirtualinherited

Runs unit tests for this object.

Returns
true if all tests pass, false otherwise.

Reimplemented from SDOM::IDataObject.

Reimplemented in SDOM::SpriteSheet, SDOM::Texture, and SDOM::TTFAsset.

◆ onUnload()

void SDOM::TruetypeFont::onUnload ( )
overridevirtual

Implements SDOM::IFontObject.

◆ registerLuaBindings()

void SDOM::IDataObject::registerLuaBindings ( const std::string &  typeName,
sol::state_view  lua 
)
inlineinherited

◆ setFilename()

void SDOM::IAssetObject::setFilename ( const std::string &  filename)
inlineinherited

◆ setFontSize()

void SDOM::TruetypeFont::setFontSize ( int  p_size)
overridevirtual

Implements SDOM::IFontObject.

◆ setFontStyle()

void SDOM::TruetypeFont::setFontStyle ( const FontStyle style)
overridevirtual

Implements SDOM::IFontObject.

◆ setName()

void SDOM::IAssetObject::setName ( const std::string &  name)
inlineinherited

◆ setType()

void SDOM::IAssetObject::setType ( const std::string &  type)
inlineinherited

Member Data Documentation

◆ activeFontHeight_

int SDOM::TruetypeFont::activeFontHeight_ = -1
protected

◆ activeFontWidth_

int SDOM::TruetypeFont::activeFontWidth_ = -1
protected

◆ Core

friend SDOM::IFontObject::Core
protectedinherited

◆ Factory

friend SDOM::IFontObject::Factory
protectedinherited

◆ filename_

std::string SDOM::IAssetObject::filename_
protectedinherited

◆ fontSize_

int SDOM::IFontObject::fontSize_ = 8
protectedinherited

◆ fontType_

FontType SDOM::IFontObject::fontType_ = FontType::Bitmap
protectedinherited

◆ FontTypeToString

std::unordered_map<FontType, std::string> SDOM::IFontObject::FontTypeToString
inlinestaticinherited
Initial value:

◆ isInternal_

bool SDOM::IAssetObject::isInternal_
protectedinherited

◆ isLoaded_

bool SDOM::IAssetObject::isLoaded_ = false
protectedinherited

◆ last_size_

int SDOM::TruetypeFont::last_size_ = 0
protected

◆ name_

std::string SDOM::IAssetObject::name_
protectedinherited

◆ objHandleType_

sol::usertype<IAssetObject> SDOM::IAssetObject::objHandleType_
protectedinherited

◆ StringToFontType

std::unordered_map<std::string, FontType> SDOM::IFontObject::StringToFontType
inlinestaticinherited
Initial value:
= {
{ "bitmap", FontType::Bitmap },
{ "truetype", FontType::Truetype },
{ "bitmapfont", FontType::Bitmap },
{ "truetypefont", FontType::Truetype }
}

◆ ttf_font_handle_

AssetHandle SDOM::TruetypeFont::ttf_font_handle_
protected

◆ type_

std::string SDOM::IAssetObject::type_
protectedinherited

◆ TypeName

constexpr const char* SDOM::TruetypeFont::TypeName = "truetype"
staticconstexpr

The documentation for this class was generated from the following files: