openTRI 0.1
Font Library

Data Structures

struct  Glyph
 A Glyph struct. More...
struct  triFont
 A Font struct. More...

Typedefs

typedef struct Glyph Glyph
 A Glyph struct.

Enumerations

enum  triFontLocation { TRI_FONT_RAM = 0 , TRI_FONT_VRAM }
enum  triFontSizeType { TRI_FONT_SIZE_PIXELS = 0 , TRI_FONT_SIZE_POINTS }
enum  triFontAlignMode {
  TRI_FONT_ALIGN_LEFT = 0x0 , TRI_FONT_ALIGN_CENTER = 0x1 , TRI_FONT_ALIGN_RIGHT = 0x2 , TRI_FONT_ALIGN_JUSTIFY = 0x3 ,
  TRI_FONT_HALIGN = 0xF , TRI_FONT_ALIGN_TOP = 0x00 , TRI_FONT_ALIGN_MIDDLE = 0x10 , TRI_FONT_ALIGN_BOTTOM = 0x20 ,
  TRI_FONT_VALIGN = 0xF0
}

Functions

triBool triFontInit (void)
 Initialise the Font library.
triVoid triFontShutdown (void)
 Shutdown the Font library.
triVoid triFontUnload (triFont *font)
 Free the specified font.
triFonttriFontLoadTRF (const triChar *filename)
 Load a TRF (triFont) font.
triVoid triFontSaveTRF (triFont *font, triChar *filename)
 Save the specified font to a triFont file.
triVoid triFontSetMono (triFont *font, triS32 width)
 Set a font mono spaced or not (default).
triVoid triFontSetSpacing (triFont *font, triS32 letter, triS32 word)
 Set a spacing values.
triVoid triFontSetLineheight (triFont *font, triS32 height)
 Set line height.
triVoid triFontActivate (triFont *font)
 Activate the specified font.
triSInt triFontPrint (triFloat x, triFloat y, triUInt color, const triChar *text)
 Draw text along the baseline starting at x, y.
triSInt triFontPrintf (triFloat x, triFloat y, triUInt color, const triChar *text,...)
 Draw text along the baseline starting at x, y (with formatting).
triSInt triFontPrintAlign (triFloat x, triFloat y, triSInt width, triSInt height, triUInt color, enum triFontAlignMode align, const triChar *text)
 Draw text along the baseline aligned within the box starting at x, y.
triSInt triFontPrintAlignf (triFloat x, triFloat y, triSInt width, triSInt height, triUInt color, enum triFontAlignMode align, const triChar *text,...)
 Draw text along the baseline aligned within the box starting at x, y (with formatting).
triSInt triFontMeasureTextHeight (const triChar *text)
 Measure height of a text if it were to be drawn.
triSInt triFontMeasureText (const triChar *text)
 Measure a length of text if it were to be drawn.
triSInt triFontMeasureLine (const triChar *text)
 Measure a length of the current line of text if it were to be drawn.

Detailed Description

Typedef Documentation

◆ Glyph

typedef struct Glyph Glyph

A Glyph struct.

Note
This is used internally by triFont and has no other relevance.

Function Documentation

◆ triFontInit()

triBool triFontInit ( void )

Initialise the Font library.

Returns
true on success.

◆ triFontUnload()

triVoid triFontUnload ( triFont * font)

Free the specified font.

Parameters
font- A valid triFont

◆ triFontLoadTRF()

triFont * triFontLoadTRF ( const triChar * filename)

Load a TRF (triFont) font.

Parameters
filename- Path to the font
Returns
A triFont struct

◆ triFontSaveTRF()

triVoid triFontSaveTRF ( triFont * font,
triChar * filename )

Save the specified font to a triFont file.

Parameters
font- A valid triFont
filename- The file to save to

◆ triFontSetMono()

triVoid triFontSetMono ( triFont * font,
triS32 width )

Set a font mono spaced or not (default).

Parameters
font- A valid triFont or 0 for inbuilt debug font
width- Width to make all glyphs, 0 to make proportional width or < 0 to offset autowidth by that amount+1

◆ triFontSetSpacing()

triVoid triFontSetSpacing ( triFont * font,
triS32 letter,
triS32 word )

Set a spacing values.

Parameters
font- A valid triFont or 0 for inbuilt debug font
letter- Spacing to apply to all glyphs: < 0 for tighter spacing, > 0 for wider spacing, 0 for normal spacing (default)
word- Spacing to apply to all whitespace glyphs in addition to letterspacing: < 0 for tighter spacing, > 0 for wider spacing, 0 for normal spacing (default)

◆ triFontSetLineheight()

triVoid triFontSetLineheight ( triFont * font,
triS32 height )

Set line height.

Parameters
font- A valid triFont or 0 for inbuilt debug font
height- Height of each line in pixels. 0 for default height.

◆ triFontActivate()

triVoid triFontActivate ( triFont * font)

Activate the specified font.

Parameters
font- A valid triFont or 0 to activate inbuilt debug font

◆ triFontPrint()

triSInt triFontPrint ( triFloat x,
triFloat y,
triUInt color,
const triChar * text )

Draw text along the baseline starting at x, y.

Parameters
x- X position on screen
y- Y position on screen
color- Text color
text- Text to draw
Returns
The total width of the largest line in the text drawn.

◆ triFontPrintf()

triSInt triFontPrintf ( triFloat x,
triFloat y,
triUInt color,
const triChar * text,
... )

Draw text along the baseline starting at x, y (with formatting).

Parameters
x- X position on screen
y- Y position on screen
color- Text color
text- Text to draw
Returns
The total width of the largest line in the text drawn.

◆ triFontPrintAlign()

triSInt triFontPrintAlign ( triFloat x,
triFloat y,
triSInt width,
triSInt height,
triUInt color,
enum triFontAlignMode align,
const triChar * text )

Draw text along the baseline aligned within the box starting at x, y.

Parameters
x- X position on screen
y- Y position on screen
width- The width of the box to align within
height- The height of the box to align within
color- Text color
align- The align method to apply (see triFontAlignMode)
text- Text to draw
Returns
The total width of the largest line in the text drawn.

◆ triFontPrintAlignf()

triSInt triFontPrintAlignf ( triFloat x,
triFloat y,
triSInt width,
triSInt height,
triUInt color,
enum triFontAlignMode align,
const triChar * text,
... )

Draw text along the baseline aligned within the box starting at x, y (with formatting).

Parameters
x- X position on screen
y- Y position on screen
width- The width of the box to align within
height- The height of the box to align within
color- Text color
align- The align method to apply (see triFontAlignMode)
text- Text to draw
Returns
The total width of the largest line in the text drawn.

◆ triFontMeasureTextHeight()

triSInt triFontMeasureTextHeight ( const triChar * text)

Measure height of a text if it were to be drawn.

Parameters
text- Text to measure
Returns
The total height of the text.

◆ triFontMeasureText()

triSInt triFontMeasureText ( const triChar * text)

Measure a length of text if it were to be drawn.

Parameters
text- Text to measure
Returns
The total width of the largest line in the text.

◆ triFontMeasureLine()

triSInt triFontMeasureLine ( const triChar * text)

Measure a length of the current line of text if it were to be drawn.

Parameters
text- Text to measure
Returns
The total width of the current line in the text.