MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
legato_font.h File Reference

Font functions and definitions. More...

Include dependency graph for legato_font.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  leFontGlyph
 This struct represents a font glyph. More...
 
struct  leFont
 This struct represents a font object. More...
 
struct  leRasterFont
 This struct represents a rasterized font object. More...
 

Typedefs

typedef enum leFontBPP leFontBPP
 This enum represents a font. More...
 
typedef struct leFontGlyph leFontGlyph
 This struct represents a font glyph. More...
 
typedef enum leFontType leFontType
 This enum represents a font type. More...
 
typedef enum leFontFlags leFontFlags
 Defines font attribute flags.
 
typedef struct leFont leFont
 This struct represents a font object. More...
 
typedef struct leRasterFont leRasterFont
 This struct represents a rasterized font object. More...
 

Enumerations

enum  leFontBPP { LE_FONT_BPP_1, LE_FONT_BPP_8 }
 This enum represents a font. More...
 
enum  leFontType { LE_RASTER_FONT, LE_VECTOR_FONT }
 This enum represents a font type. More...
 
enum  leFontFlags { LE_FONT_RIGHTTOLEFT = 0x1 }
 Defines font attribute flags.
 

Functions

leResult leFont_GetGlyphInfo (const leFont *fnt, uint32_t codepoint, leFontGlyph *glyph)
 Get glyph info. More...
 
leResult leFont_GetGlyphRect (const leFontGlyph *glyph, leRect *rect)
 Get glyph rectangle. More...
 
leResult leFont_DrawGlyph (const leFont *fnt, const leFontGlyph *glyph, int32_t x, int32_t y, leColor clr, uint32_t a)
 Draws a glyph. More...
 
leResult leFont_DrawGlyph_Lookup (const leFont *fnt, const leFontGlyph *glyph, int32_t x, int32_t y, const leBlendLookupTable *tbl)
 Draws a glyph using a provided font and color lookup table. More...
 
leResult leFont_DrawGlyphData (const leFont *fnt, const leFontGlyph *glyph, const uint8_t *data, int32_t x, int32_t y, leColor clr, uint32_t a)
 Draws a glyph. More...
 
leResult leFont_DrawGlyphData_Lookup (const leFont *fnt, const leFontGlyph *glyph, const uint8_t *data, int32_t x, int32_t y, const leBlendLookupTable *tbl)
 Draws a glyph using a provided font and color lookup table. More...
 

Detailed Description

Font functions and definitions.

Describes font assets and type definitions.

Typedef Documentation

◆ leFont

typedef struct leFont leFont

This struct represents a font object.

All fonts have a header and font type.

◆ leFontBPP

typedef enum leFontBPP leFontBPP

This enum represents a font.

This is used to provide possible font types either standard or antialized.

◆ leFontGlyph

typedef struct leFontGlyph leFontGlyph

This struct represents a font glyph.

This is used describe a individual character of a font. Each glyph contains kerning data and options unique to itself. This data is used for proper glyph positioning when rendering text.

◆ leFontType

typedef enum leFontType leFontType

This enum represents a font type.

Currently only raster fonts are supported but this differentiation will allow for future expansion into vector font support.

◆ leRasterFont

typedef struct leRasterFont leRasterFont

This struct represents a rasterized font object.

A raster font asset is a series of raster images that represent linguistic characters. These characters are referenced by an index called a 'code point'. This code point is 1-2 bytes in length. Code points may be encoded to save space. Fonts also contain general kerning data that describes character positioning data.

Enumeration Type Documentation

◆ leFontBPP

enum leFontBPP

This enum represents a font.

This is used to provide possible font types either standard or antialized.

Enumerator
LE_FONT_BPP_1 

standard

LE_FONT_BPP_8 

antialiased

◆ leFontType

enum leFontType

This enum represents a font type.

Currently only raster fonts are supported but this differentiation will allow for future expansion into vector font support.

Function Documentation

◆ leFont_DrawGlyph()

leResult leFont_DrawGlyph ( const leFont fnt,
const leFontGlyph glyph,
int32_t  x,
int32_t  y,
leColor  clr,
uint32_t  a 
)

Draws a glyph.

Draws a glyph glyph to location x, y with color clr and alpha a.

leResult res = leFont_DrawGlyph(x, y, glyph, clr, a);
Parameters
xthe screen x location to draw
ythe screen y location to draw
glyphthe glyph kerning information
clrthe glyph render color
aglobal alpha value to apply
Returns
LE_SUCCESS if set, otherwise LE_FAILURE.

◆ leFont_DrawGlyph_Lookup()

leResult leFont_DrawGlyph_Lookup ( const leFont fnt,
const leFontGlyph glyph,
int32_t  x,
int32_t  y,
const leBlendLookupTable tbl 
)

Draws a glyph using a provided font and color lookup table.

Uses a font fnt to draw a glyph glyph to location x, y. This function uses the alpha value of each glyph pixel as an index into a color lookup table tbl.

leResult res = leFont_DrawGlyph_Lookup(fnt, glyph, x, y, tbl);
Parameters
fntthe font to use
glyphthe glyph to draw
xthe screen x location to draw at
ythe screen y location to draw at
tblthe color lookup table to reference
Returns
LE_SUCCESS if set, otherwise LE_FAILURE.

◆ leFont_DrawGlyphData()

leResult leFont_DrawGlyphData ( const leFont fnt,
const leFontGlyph glyph,
const uint8_t *  data,
int32_t  x,
int32_t  y,
leColor  clr,
uint32_t  a 
)

Draws a glyph.

Draws a glyph glyph from data to location x, y with color clr and alpha a.

leResult res = leFont_DrawGlyphData(fnt, glyph, data, x, y, clr, a);
Parameters
xthe screen x location to draw
ythe screen y location to draw
glyphthe glyph kerning information
clrthe glyph render color
aglobal alpha value to apply
Returns
LE_SUCCESS if set, otherwise LE_FAILURE.

◆ leFont_DrawGlyphData_Lookup()

leResult leFont_DrawGlyphData_Lookup ( const leFont fnt,
const leFontGlyph glyph,
const uint8_t *  data,
int32_t  x,
int32_t  y,
const leBlendLookupTable tbl 
)

Draws a glyph using a provided font and color lookup table.

Uses a font fnt to draw a glyph glyph from a raw data pointer data to location x, y. This function uses the alpha value of each glyph pixel as an index into a color lookup table tbl.

leResult res = leFont_DrawGlyphData_Lookup(fnt, glyph, data, x, y, tbl);
Parameters
fntthe font to use
glyphthe glyph to draw
xthe screen x location to draw at
ythe screen y location to draw at
tblthe color lookup table to reference
Returns
LE_SUCCESS if set, otherwise LE_FAILURE.

◆ leFont_GetGlyphInfo()

leResult leFont_GetGlyphInfo ( const leFont fnt,
uint32_t  codepoint,
leFontGlyph glyph 
)

Get glyph info.

Get glyph info glyph by fnt and codepoint.

uint32_t lessor = leFont_GetGlyphInfo(fnt, codepoint, glyph);
Parameters
fntthe font to query
codepointthe codepoint to lookup
glyphthe glyph data that was retrieved.
Returns
LE_SUCCESS if set, otherwise LE_FAILURE.

◆ leFont_GetGlyphRect()

leResult leFont_GetGlyphRect ( const leFontGlyph glyph,
leRect rect 
)

Get glyph rectangle.

Gets a glyph rectangle rect by glyph.

leFontGlyph* glyph;
leRect* rect;
leResult res = leFont_GetGlyphRect(glyph, rect);
Parameters
glyphis an integer.
rectis an integer.
Returns
LE_SUCCESS if set, otherwise LE_FAILURE.