kzu_font.h File Reference

Font handling interface. More...

Namespaces

 kanzi
 

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 kzuFontLoadFromKZB (struct KzuFont *font, struct KzcInputStream *inputStream, const struct KzuBinaryFileInfo *file)
 Loads font from KZB. More...
 
KANZI_API kzsError kzuFontSetSize (struct KzuFont *font, kzFloat size)
 Sets the size of the font. More...
 
KANZI_API kzsError kzuFontGetSize (struct KzuFont *font, kzFloat *out_size)
 Returns the height of the font. More...
 
KANZI_API kzsError kzuFontSetColor (struct KzuFont *font, kanzi::ColorRGBA color)
 Sets the color of the font. More...
 
KANZI_API kzsError kzuFontGetColor (struct KzuFont *font, kanzi::ColorRGBA &out_color)
 Gets the color of the font. More...
 
KANZI_API kzsError kzuFontGetLineHeight (struct KzuFont *font, kzFloat *out_lineHeight)
 Returns the fonts preferred line height. More...
 
KANZI_API kzsError kzuFontGetAscender (struct KzuFont *font, kzFloat *out_ascender)
 Returns the fonts ascender. More...
 
KANZI_API kzsError kzuFontGetDescender (struct KzuFont *font, kzFloat *out_descender)
 Returns the fonts descender. More...
 
KANZI_API kzsError kzuFontGetGlyphIndex (struct KzuFont *font, kzUnicodeChar character, kzUint *out_glyphIndex)
 Returns the glyph index in the font for the given unicode code point. More...
 
KANZI_API 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...
 
KANZI_API kzsError kzuFontGetKerning (struct KzuFont *font, kzUint previousGlyphIndex, kzUint glyphIndex, kzFloat *out_kerning)
 Gets the kerning between two given character glyph indices. More...
 
KANZI_API kzsError kzuFontLoadCharacterGlyph (struct KzuFont *font, kzUint glyphIndex, kzUint *out_width, kzUint *out_height, const kanzi::byte **out_bitmapData, void **out_characterGlyph)
 Loads the bitmap data for a single character glyph. More...
 
KANZI_API kzsError kzuFontReleaseCharacterGlyph (struct KzuFont *font, void *characterGlyph)
 Releases a loaded character glyph. More...
 
kzsError kzuFontPrepareTextLayout (struct KzuTextLayout *textLayout, kanzi::Renderer *renderer)
 Prepares the given text layout for rendering. More...
 
KANZI_API kzsError kzuFontDrawTextLayout (struct KzuTextLayout *textLayout, kanzi::Renderer *renderer, kzFloat x, kzFloat y)
 Draws the given text layout to given 2D position on the screen. More...
 
kzsError kzuFontDrawTextLayout3D (struct KzuTextLayout *textLayout, kanzi::Renderer *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...
 
KANZI_API KzuFontType kzuFontGetType (const struct KzuFont *font)
 Returns font's type. 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-2017 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 kzuFontLoadFromKZB ( struct KzuFont font,
struct KzcInputStream inputStream,
const struct KzuBinaryFileInfo file 
)

Loads font from KZB.

KANZI_API kzsError kzuFontSetSize ( struct KzuFont font,
kzFloat  size 
)

Sets the size of the font.

KANZI_API kzsError kzuFontGetSize ( struct KzuFont font,
kzFloat out_size 
)

Returns the height of the font.

KANZI_API kzsError kzuFontSetColor ( struct KzuFont font,
kanzi::ColorRGBA  color 
)

Sets the color of the font.

KANZI_API kzsError kzuFontGetColor ( struct KzuFont font,
kanzi::ColorRGBA out_color 
)

Gets the color of the font.

KANZI_API kzsError kzuFontGetLineHeight ( struct KzuFont font,
kzFloat out_lineHeight 
)

Returns the fonts preferred line height.

KANZI_API kzsError kzuFontGetAscender ( struct KzuFont font,
kzFloat out_ascender 
)

Returns the fonts ascender.

This is how much the font ascends below the baseline.

KANZI_API kzsError kzuFontGetDescender ( struct KzuFont font,
kzFloat out_descender 
)

Returns the fonts descender.

This is how much the font descends below the baseline. This is typically a positive value.

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

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

KANZI_API 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.

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

Gets the kerning between two given character glyph indices.

KANZI_API kzsError kzuFontLoadCharacterGlyph ( struct KzuFont font,
kzUint  glyphIndex,
kzUint out_width,
kzUint out_height,
const kanzi::byte **  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.

KANZI_API kzsError kzuFontReleaseCharacterGlyph ( struct KzuFont font,
void *  characterGlyph 
)

Releases a loaded character glyph.

kzsError kzuFontPrepareTextLayout ( struct KzuTextLayout textLayout,
kanzi::Renderer renderer 
)

Prepares the given text layout for rendering.

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

KANZI_API kzsError kzuFontDrawTextLayout ( struct KzuTextLayout textLayout,
kanzi::Renderer renderer,
kzFloat  x,
kzFloat  y 
)

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

kzsError kzuFontDrawTextLayout3D ( struct KzuTextLayout textLayout,
kanzi::Renderer 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.

KANZI_API KzuFontType kzuFontGetType ( const struct KzuFont font)

Returns font's type.