Skylicht Engine
Loading...
Searching...
No Matches
Skylicht::CFontSource Class Reference

This is the object class that describes .font file information. More...

#include <Graphics2D/SpriteFrame/CFontSource.h>

Inheritance diagram for Skylicht::CFontSource:
Skylicht::CAssetResource Skylicht::CObjectSerializable Skylicht::CValueProperty

Public Types

enum  EFontType { GlyphFreeType = 0 , SpriteFont }

Public Member Functions

IFontinitFont ()
IFontgetFont ()
const void setPath (const char *path)
const char * getPath ()
int getChangeRevision ()
Public Member Functions inherited from Skylicht::CAssetResource
 CAssetResource (const char *name)
const char * getGUID ()
virtual void deserialize (io::IAttributes *io)
virtual bool save (const char *file)
Public Member Functions inherited from Skylicht::CObjectSerializable
void addProperty (CValueProperty *p)
void autoRelease (CValueProperty *p)
 CObjectSerializable (const char *name)
 CObjectSerializable (const char *name, CObjectSerializable *parent)
void remove (CValueProperty *value)
u32 getNumProperty ()
CValueProperty * getPropertyID (int i)
CValueProperty * getProperty (const char *name)
template<class T>
T * getProperty (const char *name)
template<class T>
get (const char *name, T defaultValue)
template<class T>
get (CValueProperty *p, T defaultValue)
virtual void serialize (io::IAttributes *io)
virtual bool saveToFile ()
virtual bool load (const char *file)
virtual void save (io::IXMLWriter *writer)
virtual void load (io::IXMLReader *reader)
virtual void parseSerializable (io::IXMLReader *reader)
virtual CObjectSerializable * clone ()
virtual void copyTo (CObjectSerializable *object)
void setSavePath (const char *path)
Public Member Functions inherited from Skylicht::CValueProperty
 CValueProperty (CObjectSerializable *owner, EPropertyDataType dataType, const char *name)
void setOwner (CObjectSerializable *owner)
EPropertyDataType getType ()
EPropertyObjectType getObjectType ()
void setUIHeader (const char *header)
const std::string & getUIHeader ()
void setUISpace (float space)
float getUISpace ()
void setHidden (bool b)
bool isHidden ()

Public Attributes

CEnumProperty< EFontType > FontType
CFilePathProperty Source
CFloatProperty FontSizePt
Public Attributes inherited from Skylicht::CAssetResource
CStringProperty GUID
bool GenerateNewId
Public Attributes inherited from Skylicht::CValueProperty
std::function< void(bool)> OnSetHidden
std::function< void()> OnChanged
std::string Name
std::vector< std::string > OtherName

Protected Attributes

IFontm_font
std::string m_path
std::string m_source
float m_sizePt
int m_revision
Protected Attributes inherited from Skylicht::CObjectSerializable
std::vector< CValueProperty * > m_value
std::vector< CValueProperty * > m_autoRelease
std::string m_savePath
Protected Attributes inherited from Skylicht::CValueProperty
EPropertyDataType m_dataType
EPropertyObjectType m_objectType
CObjectSerializablem_owner
std::string m_uiHeader
float m_uiSpace
bool m_hidden

Detailed Description

This is the object class that describes .font file information.

A .font file, generated by the Editor, can represent a FreeType-style font (like .ttf or .otf) or an image sprite-style font (.fnt).

Skylicht-Editor

You can create a .font from the Asset/Create/Font menu.


Set properties for the .font file.

Drag the font file (.ttf, .otf, .fnt) to the Source field and configure the font size.

Finally, you'll drag this .font file into the CGUIText's Font field to display the text

Use the CFontManager object class to support loading .font files.

// in load font function
CFontSource* fontSource = CFontManager::getInstance()->loadFontSource("SampleGUI/Fonts/Roboto.font");
IFont* font = NULL;
if (fontSource)
{
fontSource->initFont();
font = fontSource->getFont();
}
// in draw function
CGraphics2D *g = CGraphics2D::getInstance();
core::rectf rect(10.0f, 10.0f, 400.0f, 50.0f);
int shaderId = CShaderManager::getInstance()->getShaderIDByName("TextureColorAlpha");
g->beginRenderGUI(projection, view);
g->drawText(rect, font, SColor(255, 255, 255, 255), "Text", shaderId);
g->endRenderGUI();
The object class supports 2D drawing on the screen.
Definition CGraphics2D.h:61
Definition IFont.h:32
See also
CGUIText

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