Kanzi Graphics Engine
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
kzu_font.h File Reference

Font handling interface. More...

Macros

#define KZ_TRUETYPE_SYSTEM_FREETYPE
 Truetype support with Freetype. More...
 
#define KZ_TRUETYPE_SYSTEM_ITYPE
 Truetype support with iType. More...
 
#define KZ_TRUETYPE_SYSTEM_DUMMY
 No Truetype support. More...
 
#define KZ_TRUETYPE_SYSTEM_DEFAULT
 Default truetype font system. More...
 

Functions

kzsError kzuFontDelete (struct KzuFont *font)
 Frees memory allocated for given font. More...
 
kzsError kzuFontLoadFromKZB (struct KzuFont *font, struct KzcInputStream *inputStream, const struct KzuBinaryFileInfo *file)
 Loads font from KZB. More...
 
kzsError kzuFontSetSize (struct KzuFont *font, kzFloat size)
 Sets the size of the font. More...
 
kzsError kzuFontGetSize (struct KzuFont *font, kzFloat *out_size)
 Returns the height of the font. More...
 
kzsError kzuFontSetColor (struct KzuFont *font, struct KzcColorRGBA color)
 Sets the color of the font. More...
 
kzsError kzuFontGetColor (struct KzuFont *font, struct KzcColorRGBA *out_color)
 Gets the color of the font. More...
 
kzsError kzuFontGetLineHeight (struct KzuFont *font, kzFloat *out_lineHeight)
 Returns the fonts preferred line height. More...
 
kzsError kzuFontGetAscender (struct KzuFont *font, kzFloat *out_baseline)
 Returns the fonts ascender. More...
 
kzsError kzuFontGetGlyphIndex (struct KzuFont *font, kzUnicodeChar character, kzUint *out_glyphIndex)
 Returns the glyph index in the font for the given unicode code point. More...
 
kzsError kzuFontGetCharacterMetrics (struct KzuFont *font, kzUint glyphIndex, kzFloat *out_advance, struct KzcRectangle *out_boundingBox)
 Gets the number of units that the cursor should move after given character glyph index. More...
 
kzsError kzuFontGetKerning (struct KzuFont *font, kzUint previousGlyphIndex, kzUint glyphIndex, kzFloat *out_kerning)
 Gets the kerning between two given character glyph indices. More...
 
kzsError kzuFontLoadCharacterGlyph (struct KzuFont *font, kzUint glyphIndex, kzUint *out_width, kzUint *out_height, const kzByte **out_bitmapData, void **out_characterGlyph)
 Loads the bitmap data for a single character glyph. More...
 
kzsError kzuFontReleaseCharacterGlyph (struct KzuFont *font, void *characterGlyph)
 Releases a loaded character glyph. More...
 
kzsError kzuFontPrepareTextLayout (struct KzuTextLayout *textLayout, struct KzcRenderer *renderer)
 Prepares the given text layout for rendering. More...
 
kzsError kzuFontDrawTextLayout (struct KzuTextLayout *textLayout, struct KzcRenderer *renderer, kzFloat x, kzFloat y)
 Draws the given text layout to given 2D position on the screen. More...
 
kzsError kzuFontDrawTextLayout3D (struct KzuTextLayout *textLayout, struct KzcRenderer *renderer)
 Draws the given text layout to 3D world with the current transformation. More...
 
kzsError kzuFontFreeTextLayoutData (struct KzuTextLayout *textLayout)
 Frees the data allocated in the prepare. More...
 
KzuFontType kzuFontGetType (const struct KzuFont *font)
 Returns font's type. More...
 
struct KzuResourcekzuFontToResource (const struct KzuFont *font)
 Converts font to resource. More...
 
struct KzuFontkzuFontFromResource (const struct KzuResource *resource)
 Converts font from resource. More...
 
struct KzuFontkzuFontCastFromResource (const struct KzuResource *resource)
 Casts font from resource, KZ_NULL if invalid type. More...
 

Variables

const KzuResourceType KZU_RESOURCE_TYPE_FONT
 Resource type identifier for font. More...
 

Detailed Description

Font handling interface.

This interface provides functionality for measuring font related information and for drawing pre-layeted text. To draw arbitrary strings with this interface, the text must be first layed out with kzu_text_layouter.h.

Copyright 2008-2019 by Rightware. All rights reserved.

Macro Definition Documentation

#define KZ_TRUETYPE_SYSTEM_FREETYPE

Truetype support with Freetype.

#define KZ_TRUETYPE_SYSTEM_ITYPE

Truetype support with iType.

#define KZ_TRUETYPE_SYSTEM_DUMMY

No Truetype support.

#define KZ_TRUETYPE_SYSTEM_DEFAULT

Default truetype font system.

Function Documentation

kzsError kzuFontDelete ( struct KzuFont font)

Frees memory allocated for given font.

kzsError kzuFontLoadFromKZB ( struct KzuFont font,
struct KzcInputStream inputStream,
const struct KzuBinaryFileInfo file 
)

Loads font from KZB.

kzsError kzuFontSetSize ( struct KzuFont font,
kzFloat  size 
)

Sets the size of the font.

kzsError kzuFontGetSize ( struct KzuFont font,
kzFloat out_size 
)

Returns the height of the font.

kzsError kzuFontSetColor ( struct KzuFont font,
struct KzcColorRGBA  color 
)

Sets the color of the font.

kzsError kzuFontGetColor ( struct KzuFont font,
struct KzcColorRGBA out_color 
)

Gets the color of the font.

kzsError kzuFontGetLineHeight ( struct KzuFont font,
kzFloat out_lineHeight 
)

Returns the fonts preferred line height.

kzsError kzuFontGetAscender ( struct KzuFont font,
kzFloat out_baseline 
)

Returns the fonts ascender.

This is how much the font ascends below the baseline.

kzsError kzuFontGetGlyphIndex ( struct KzuFont font,
kzUnicodeChar  character,
kzUint out_glyphIndex 
)

Returns the glyph index in the font for the given unicode code point.

kzsError kzuFontGetCharacterMetrics ( struct KzuFont font,
kzUint  glyphIndex,
kzFloat out_advance,
struct KzcRectangle out_boundingBox 
)

Gets the number of units that the cursor should move after given character glyph index.

kzsError kzuFontGetKerning ( struct KzuFont font,
kzUint  previousGlyphIndex,
kzUint  glyphIndex,
kzFloat out_kerning 
)

Gets the kerning between two given character glyph indices.

kzsError kzuFontLoadCharacterGlyph ( struct KzuFont font,
kzUint  glyphIndex,
kzUint out_width,
kzUint out_height,
const kzByte **  out_bitmapData,
void **  out_characterGlyph 
)

Loads the bitmap data for a single character glyph.

The returned character glyph needs to be released with a call to release, and the next glyph can't be loaded before the previous glyph has been released. The bitmap data is returned as a greyscale image with 8 bits per pixel.

kzsError kzuFontReleaseCharacterGlyph ( struct KzuFont font,
void characterGlyph 
)

Releases a loaded character glyph.

kzsError kzuFontPrepareTextLayout ( struct KzuTextLayout textLayout,
struct KzcRenderer renderer 
)

Prepares the given text layout for rendering.

This step is automatically done when drawing for the first time if not already prepared before.

kzsError kzuFontDrawTextLayout ( struct KzuTextLayout textLayout,
struct KzcRenderer renderer,
kzFloat  x,
kzFloat  y 
)

Draws the given text layout to given 2D position on the screen.

kzsError kzuFontDrawTextLayout3D ( struct KzuTextLayout textLayout,
struct KzcRenderer renderer 
)

Draws the given text layout to 3D world with the current transformation.

kzsError kzuFontFreeTextLayoutData ( struct KzuTextLayout textLayout)

Frees the data allocated in the prepare.

This is automatically done when deleting the text layout if needed.

KzuFontType kzuFontGetType ( const struct KzuFont font)

Returns font's type.

struct KzuResource* kzuFontToResource ( const struct KzuFont font)

Converts font to resource.

struct KzuFont* kzuFontFromResource ( const struct KzuResource resource)

Converts font from resource.

struct KzuFont* kzuFontCastFromResource ( const struct KzuResource resource)

Casts font from resource, KZ_NULL if invalid type.

Variable Documentation

const KzuResourceType KZU_RESOURCE_TYPE_FONT

Resource type identifier for font.