Font resource

Font resource functions.

Namespace: dmGameSystem
Include: #include <dmsdk/gamesys/resources/res_font.h>
CONSTANTS
SDF_EDGE_VALUE The edge value of an sdf glyph bitmap
ENUMS
FontGlyphCompression Describes what compression is used for the glyph i...
STRUCTS
struct FontGlyph Represents a glyph
struct FontInfo Used to retrieve the information of a font.
struct FontResource Handle to font resource
FUNCTIONS
bool IsWhiteSpace(uint32_t c) Checks if a codepoint is a whitespace
dmResource::Result ResFontAddGlyph(FontResource* font, uint32_t codepoint, FontGlyph* glyph, void* imagedata)
dmResource::Result ResFontAddGlyphSource(dmResource::HFactory factory, dmhash_t fontc_hash, dmhash_t ttf_hash, uint32_t codepoint_min, uint32_t codepoint_max) add a new glyph range
dmRender::HFont ResFontGetHandle(FontResource* font)
dmResource::Result ResFontGetInfo(FontResource* font, FontInfo* info)
TTFResource* ResFontGetTTFResourceFromCodepoint(FontResource* font, uint32_t codepoint)
dmResource::Result ResFontRemoveGlyph(FontResource* font, uint32_t codepoint)
dmResource::Result ResFontRemoveGlyphSource(dmResource::HFactory factory, dmhash_t fontc_hash, dmhash_t ttf_hash) removes all glyph ranges associated with a ttfresource

Functions

IsWhiteSpace

bool IsWhiteSpace(uint32_t c)

Checks if a codepoint is a whitespace

PARAMETERS

uint32_t c the codepoint

RETURNS

bool true if it's a whitespace

ResFontAddGlyph

dmResource::Result ResFontAddGlyph(FontResource* font, uint32_t codepoint, FontGlyph* glyph, void* imagedata)

PARAMETERS

FontResource* font The font resource to modify
uint32_t codepoint The glyph codepoint
FontGlyph* glyph The glyph meta data
void* imagedata The bitmap or sdf data. May be null for e.g. white space characters. The font will now own this data.

RETURNS

dmResource::Result RESULT_OK if successful

ResFontAddGlyphSource

dmResource::Result ResFontAddGlyphSource(dmResource::HFactory factory, dmhash_t fontc_hash, dmhash_t ttf_hash, uint32_t codepoint_min, uint32_t codepoint_max)

Add a new glyph range

PARAMETERS

dmResource::HFactory factory The factory
dmhash_t fontc_hash The font path hash (.fontc)
dmhash_t ttf_hash The ttf path hash (.ttf)
uint32_t codepoint_min The glyph minimum codepoint (inclusive)
uint32_t codepoint_max The glyph maximum codepoint (inclusive)

RETURNS

dmResource::Result RESULT_OK if successful

ResFontGetHandle

dmRender::HFont ResFontGetHandle(FontResource* font)

PARAMETERS

FontResource* font The font resource

RETURNS

dmRender::HFont Handle to a font if successful. 0 otherwise.

ResFontGetInfo

dmResource::Result ResFontGetInfo(FontResource* font, FontInfo* info)

PARAMETERS

FontResource* font The font resource to modify
FontInfo* info The output info

RETURNS

dmResource::Result RESULT_OK if successful

ResFontGetTTFResourceFromCodepoint

TTFResource* ResFontGetTTFResourceFromCodepoint(FontResource* font, uint32_t codepoint)

PARAMETERS

FontResource* font The font resource
uint32_t codepoint The codepoint to query

RETURNS

TTFResource* The ttfresource if successful. 0 otherwise.

ResFontRemoveGlyph

dmResource::Result ResFontRemoveGlyph(FontResource* font, uint32_t codepoint)

PARAMETERS

FontResource* font The font resource
uint32_t codepoint The glyph codepoint

RETURNS

dmResource::Result RESULT_OK if successful

ResFontRemoveGlyphSource

dmResource::Result ResFontRemoveGlyphSource(dmResource::HFactory factory, dmhash_t fontc_hash, dmhash_t ttf_hash)

Removes all glyph ranges associated with a ttfresource

PARAMETERS

dmResource::HFactory factory The factory
dmhash_t fontc_hash The font path hash (.fontc)
dmhash_t ttf_hash The ttf path hash (.ttf)

RETURNS

dmResource::Result RESULT_OK if successful

Structs

FontGlyph

TYPE

struct FontGlyph

Represents a glyph. If there's an associated image, it is of size width * height * channels.

MEMBERS

float m_Width The glyph bounding width
float m_Height The glyph bounding height
int16_t m_ImageWidth The glyph image width
int16_t m_ImageHeight The glyph image height
int16_t m_Channels The glyph image height
float m_Advance The advance step of the glyph (in pixels)
float m_LeftBearing The left bearing of the glyph (in pixels)
float m_Ascent The ascent of the glyph. (in pixels)
float m_Descent The descent of the glyph. Positive! (in pixels)


FontInfo

TYPE

struct FontInfo

Used 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


FontResource

TYPE

struct FontResource

Handle to font resource


Constants

SDF_EDGE_VALUE

The edge value of an sdf glyph bitmap


Enums

FontGlyphCompression

Describes what compression is used for the glyph image

FONT_GLYPH_COMPRESSION_NONE No compression
FONT_GLYPH_COMPRESSION_DEFLATE Data is compressed using the deflate() algorithm