libctru  v2.4.1
Data Structures
font.h File Reference

Shared font support. More...

#include <3ds/types.h>

Go to the source code of this file.

Data Structures

struct  charWidthInfo_s
 Character width information structure. More...
 
struct  TGLP_s
 Font texture sheet information. More...
 
struct  CWDH_s
 Font character width information block structure. More...
 
struct  CMAP_s
 Font character map structure. More...
 
struct  FINF_s
 Font information structure. More...
 
struct  CFNT_s
 Font structure. More...
 
struct  fontGlyphPos_s
 Font glyph position structure. More...
 

Enumerations

Data types
enum  {
  CMAP_TYPE_DIRECT = 0 ,
  CMAP_TYPE_TABLE = 1 ,
  CMAP_TYPE_SCAN = 2
}
 Font character map methods. More...
 
enum  {
  GLYPH_POS_CALC_VTXCOORD = BIT(0) ,
  GLYPH_POS_AT_BASELINE = BIT(1) ,
  GLYPH_POS_Y_POINTS_UP = BIT(2)
}
 Flags for use with fontCalcGlyphPos. More...
 

Functions

Initialization and basic operations
Result fontEnsureMapped (void)
 Ensures the shared system font is mapped.
 
void fontFixPointers (CFNT_s *font)
 Fixes the pointers internal to a just-loaded font. More...
 
static CFNT_sfontGetSystemFont (void)
 Gets the currently loaded system font.
 
static FINF_sfontGetInfo (CFNT_s *font)
 Retrieves the font information structure of a font. More...
 
static TGLP_sfontGetGlyphInfo (CFNT_s *font)
 Retrieves the texture sheet information of a font. More...
 
static void * fontGetGlyphSheetTex (CFNT_s *font, int sheetIndex)
 Retrieves the pointer to texture data for the specified texture sheet. More...
 
int fontGlyphIndexFromCodePoint (CFNT_s *font, u32 codePoint)
 Retrieves the glyph index of the specified Unicode codepoint. More...
 
charWidthInfo_sfontGetCharWidthInfo (CFNT_s *font, int glyphIndex)
 Retrieves character width information of the specified glyph. More...
 
void fontCalcGlyphPos (fontGlyphPos_s *out, CFNT_s *font, int glyphIndex, u32 flags, float scaleX, float scaleY)
 Calculates position information for the specified glyph. More...
 

Detailed Description

Shared font support.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Font character map methods.

Enumerator
CMAP_TYPE_DIRECT 

Identity mapping.

CMAP_TYPE_TABLE 

Mapping using a table.

CMAP_TYPE_SCAN 

Mapping using a list of mapped characters.

◆ anonymous enum

anonymous enum

Flags for use with fontCalcGlyphPos.

Enumerator
GLYPH_POS_CALC_VTXCOORD 

Calculates vertex coordinates in addition to texture coordinates.

GLYPH_POS_AT_BASELINE 

Position the glyph at the baseline instead of at the top-left corner.

GLYPH_POS_Y_POINTS_UP 

Indicates that the Y axis points up instead of down.

Function Documentation

◆ fontCalcGlyphPos()

void fontCalcGlyphPos ( fontGlyphPos_s out,
CFNT_s font,
int  glyphIndex,
u32  flags,
float  scaleX,
float  scaleY 
)

Calculates position information for the specified glyph.

Parameters
outOutput structure in which to write the information.
fontPointer to font structure. If NULL, the shared system font is used.
glyphIndexIndex of the glyph.
flagsCalculation flags (see GLYPH_POS_* flags).
scaleXScale factor to apply horizontally.
scaleYScale factor to apply vertically.

◆ fontFixPointers()

void fontFixPointers ( CFNT_s font)

Fixes the pointers internal to a just-loaded font.

Parameters
fontFont to fix
Remarks
Should never be run on the system font, and only once on any other font.

◆ fontGetCharWidthInfo()

charWidthInfo_s* fontGetCharWidthInfo ( CFNT_s font,
int  glyphIndex 
)

Retrieves character width information of the specified glyph.

Parameters
fontPointer to font structure. If NULL, the shared system font is used.
glyphIndexIndex of the glyph.

◆ fontGetGlyphInfo()

static TGLP_s* fontGetGlyphInfo ( CFNT_s font)
inlinestatic

Retrieves the texture sheet information of a font.

Parameters
fontPointer to font structure. If NULL, the shared system font is used.

◆ fontGetGlyphSheetTex()

static void* fontGetGlyphSheetTex ( CFNT_s font,
int  sheetIndex 
)
inlinestatic

Retrieves the pointer to texture data for the specified texture sheet.

Parameters
fontPointer to font structure. If NULL, the shared system font is used.
sheetIndexIndex of the texture sheet.

◆ fontGetInfo()

static FINF_s* fontGetInfo ( CFNT_s font)
inlinestatic

Retrieves the font information structure of a font.

Parameters
fontPointer to font structure. If NULL, the shared system font is used.

◆ fontGlyphIndexFromCodePoint()

int fontGlyphIndexFromCodePoint ( CFNT_s font,
u32  codePoint 
)

Retrieves the glyph index of the specified Unicode codepoint.

Parameters
fontPointer to font structure. If NULL, the shared system font is used.
codePointUnicode codepoint.