Font resource functions.
| Namespace: | dmGameSystem |
| Include: | #include <dmsdk/gamesys/resources/res_font.h> |
| TYPES | |
|---|---|
| FPrewarmTextCallback |
| CONSTANTS | |
|---|---|
| SDF_EDGE_VALUE | The edge value of an sdf glyph bitmap |
| STRUCTS | |
|---|---|
| struct FontInfo | Used to retrieve the information of a font. |
| struct FontResource | Handle to font resource |
dmResource::Result PrewarmText(FontResource* font, const char* text, FPrewarmTextCallback cbk, void* cbk_ctx)
Make sure each glyph in the text gets rasterized and put into the glyph cache
PARAMETERS
FontResource* |
font |
The font resource |
const char* |
text |
The text (utf8) |
FPrewarmTextCallback |
cbk |
The callback is called when the last item is done |
void* |
cbk_ctx |
The callback context |
RETURNS
dmResource::Result |
RESULT_OK if successful |
dmResource::Result ResFontAddFontByPath(dmResource::HFactory factory, FontResource* font, const char* ttf_path)
add a ttf font to a font collection
PARAMETERS
dmResource::HFactory |
factory |
The factory |
FontResource* |
font |
The font collection (.fontc) |
const char* |
ttf_path |
The .ttf path |
RETURNS
dmResource::Result |
RESULT_OK if successful |
dmResource::Result ResFontAddFontByPathHash(dmResource::HFactory factory, FontResource* font, dmhash_t ttf_hash)
add a ttf font to a font collection
PARAMETERS
dmResource::HFactory |
factory |
The factory |
FontResource* |
font |
The font collection (.fontc) |
dmhash_t |
ttf_hash |
The ttf path hash (.ttf) |
RETURNS
dmResource::Result |
RESULT_OK if successful |
bool ResFontAddGlyph(FontResource* font, HFont hfont, uint32_t glyph_index)
PARAMETERS
FontResource* |
font |
The font resource |
HFont |
hfont |
The font the glyph was created from |
uint32_t |
glyph_index |
The glyph index |
RETURNS
bool |
true if the glyph already has rasterized bitmap data |
dmResource::Result ResFontAddGlyph(FontResource* font, HFont hfont, FontGlyph* glyph)
PARAMETERS
FontResource* |
font |
The font resource |
HFont |
hfont |
The font the glyph was created from |
FontGlyph* |
glyph |
The glyph |
RETURNS
dmResource::Result |
RESULT_OK if successful |
HFontCollection* ResFontGetFontCollection(FontResource* resource)
PARAMETERS
FontResource* |
resource |
The font resource |
RETURNS
HFontCollection* |
The font collection if successful. 0 otherwise. |
dmRender::HFontMap ResFontGetHandle(FontResource* font)
PARAMETERS
FontResource* |
font |
The font resource |
RETURNS
dmRender::HFontMap |
Handle to a font if successful. 0 otherwise. |
dmResource::Result ResFontGetInfo(FontResource* font, FontInfo* info)
PARAMETERS
FontResource* |
font |
The font resource to query |
FontInfo* |
info |
The output info (out) |
RETURNS
dmResource::Result |
RESULT_OK if successful |
dmhash_t ResFontGetPathHashFromFont(FontResource* resource, HFont font)
PARAMETERS
FontResource* |
resource |
The font resource |
HFont |
font |
The font |
RETURNS
dmhash_t |
The path hash to the associated TTFresource* |
TTFResource* ResFontGetTTFResourceFromFont(FontResource* resource, HFont font)
PARAMETERS
FontResource* |
resource |
The font resource |
HFont |
font |
The font |
RETURNS
TTFResource* |
The ttfresource if successful. 0 otherwise. |
dmResource::Result ResFontRemoveFont(dmResource::HFactory factory, FontResource* font, dmhash_t ttf_hash)
remove a ttf font from a font collection
PARAMETERS
dmResource::HFactory |
factory |
The factory |
FontResource* |
font |
The font collection (.fontc) |
dmhash_t |
ttf_hash |
The ttf path hash (.ttf) |
RETURNS
dmResource::Result |
RESULT_OK if successful |
TYPE
struct FontInfoUsed to retrieve the information of a font.
MEMBERS
uint32_t |
m_Size |
The size of the font (in points) |
float |
m_ShadowX |
The shadow distance in X-axis (in pixels) |
float |
m_ShadowY |
The shadow distance in Y-axis (in pixels) |
uint32_t |
m_ShadowBlur |
The shadow blur spread [0.255] (in pixels) |
float |
m_ShadowAlpha |
The shadow alpha value [0..255] |
float |
m_Alpha |
The alpha value [0..255] |
float |
m_OutlineAlpha |
The outline alpha value [0..255] |
float |
m_OutlineWidth |
The outline size (in pixels) |
dmRenderDDF::FontTextureFormat |
m_OutputFormat |
The type of font (bitmap or distance field) |
dmRenderDDF::FontRenderMode |
m_RenderMode |
Single or multi channel |