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

Text Renderer. More...

Typedefs

typedef kzsError(* kzuTextRendererCreateTextLayouterFunction )(const struct KzcMemoryManager *memoryManager, struct KzuFont *font, void *userData, struct KzuTextLayouter **out_textLayouter)
 Pointer to a function that creates a text layouter. More...
 

Functions

kzsError kzuTextRendererCreate (const struct KzcMemoryManager *memoryManager, struct KzuResourceManager *resourceManager, struct KzuTextRenderer **out_textRenderer)
 Creates a text renderer. More...
 
kzsError kzuTextRendererDelete (struct KzuTextRenderer *textRenderer)
 Deletes a text renderer. More...
 
kzsError kzuTextRendererSetDefaultFontMaterial (struct KzuTextRenderer *textRenderer, struct KzuMaterial *material)
 Sets the default font material and acquires the material. More...
 
struct KzuMaterialkzuTextRendererGetValidFontMaterial (const struct KzuTextRenderer *textRenderer, const struct KzuRenderer *renderer, struct KzuMaterial *material)
 Returns a valid font material. More...
 
struct KzuTextManagerkzuTextRendererGetTextManager (const struct KzuTextRenderer *textRenderer)
 Returns the text manager of the text renderer. More...
 
kzsError kzuTextRendererCreateTextFormat (const struct KzuTextRenderer *textRenderer, struct KzuFont *font, kzFloat fontSize, kzFloat width, kzFloat height, struct KzuTextFormat **out_textFormat)
 Creates a text layout. More...
 
kzsError kzuTextRendererDeleteTextFormat (struct KzuTextFormat *textFormat)
 Deletes a text layout. More...
 
void kzuTextFormatSetTextHorizontalAlignment (struct KzuTextFormat *textFormat, enum KzuTextHorizontalAlignment alignment)
 Sets the horizontal alignment of the text. More...
 
void kzuTextFormatSetTextVerticalAlignment (struct KzuTextFormat *textFormat, enum KzuTextVerticalAlignment alignment)
 Sets the vertical alignment of the text. More...
 
void kzuTextFormatSetLineSpacing (const struct KzuTextFormat *textFormat, kzFloat lineSpacing)
 Sets the line spacing of the text. More...
 
void kzuTextFormatSetCharacterSpacing (const struct KzuTextFormat *textFormat, kzFloat characterSpacing)
 Sets the character spacing of the text. More...
 
void kzuTextFormatSetFixedCharacterWidth (const struct KzuTextFormat *textFormat, kzFloat fixedCharacterWidth)
 Sets the fixed character width of the text. More...
 
kzsError kzuTextFormatSetOverflow (const struct KzuTextFormat *textFormat, kzString overflowText)
 Sets the overflow text that is displayed when the text doesn't fit to the layout. More...
 
void kzuTextFormatSetBidiShapingEnabled (const struct KzuTextFormat *textFormat, kzBool bidiShapingEnabled)
 Sets whether support for complex scripts is enabled. More...
 
kzsError kzuTextFormatCalculateLayout (struct KzuTextFormat *textFormat, kzString text)
 Calculates the text layout. More...
 
kzFloat kzuTextFormatGetWidth (const struct KzuTextFormat *textFormat)
 Gets the width of the area that the text layout actually used. More...
 
kzFloat kzuTextFormatGetHeight (const struct KzuTextFormat *textFormat)
 Gets the height of the area that the text layout actually used. More...
 
kzsError kzuTextFormatPrepareForRendering3D (struct KzuTextFormat *textFormat, kzFloat unitScale, kzFloat offsetX, kzFloat offsetY)
 Prepares a text layout for rendering in 3d space, where x-coordinates increase to the right and y-coordinates increase going upward. More...
 
kzsError kzuTextFormatPrepareForRendering2D (struct KzuTextFormat *textFormat, kzFloat unitScale, kzFloat offsetX, kzFloat offsetY)
 Prepares a text layout for rendering in 2d space, where x-coordinates increase to the right and y-coordinates increase going downward. More...
 
kzsError kzuTextFormatPrepareForRendering2DWithClipping (struct KzuTextFormat *textFormat, kzFloat unitScale, const struct KzcRectangle *clippingArea, kzFloat offsetX, kzFloat offsetY)
 Prepares a text layout for rendering in a bounded 2d space. More...
 
kzsError kzuTextFormatCalculateClipping (struct KzuTextFormat *textFormat, const struct KzcRectangle *clippingArea)
 Calculates clipped vertex coordinates from the bounding coordinates generated in the preparation function. More...
 
kzsError kzuTextRendererDrawTextFormat (const struct KzuTextRenderer *textRenderer, struct KzuRenderer *renderer, const struct KzuTextFormat *textFormat, struct KzuMaterial *material)
 Renders a text format. More...
 
kzsError kzuTextRendererDrawTextFormatTwoPass (const struct KzuTextRenderer *textRenderer, struct KzuRenderer *renderer, const struct KzuTextFormat *textFormat, struct KzuMaterial *material)
 Renders a text format. More...
 
kzsError kzuTextRendererGetBitmapFontSystem (struct KzuTextRenderer *textRenderer, struct KzuBitmapFontSystem **out_bitmapFontSystem)
 Gets a bitmap font system. More...
 
kzsError kzuTextRendererGetTruetypeSystem (struct KzuTextRenderer *textRenderer, struct KzuTruetypeSystem **out_truetypeSystem)
 Gets a TrueType font system. More...
 
kzsError kzuTextRendererSetTruetypeSystem (struct KzuTextRenderer *textRenderer, struct KzuTruetypeSystem *truetypeSystem)
 Sets a TrueType font system, which overrides the default TrueType system. More...
 
kzsError kzuTextRendererSetTextLayouterCreator (struct KzuTextRenderer *textRenderer, kzuTextRendererCreateTextLayouterFunction createFunction, void *userData)
 Sets a creator function for creating text layouters. More...
 

Detailed Description

Text Renderer.

Copyright 2008-2019 by Rightware. All rights reserved.

Typedef Documentation

typedef kzsError(* kzuTextRendererCreateTextLayouterFunction)(const struct KzcMemoryManager *memoryManager, struct KzuFont *font, void *userData, struct KzuTextLayouter **out_textLayouter)

Pointer to a function that creates a text layouter.

Function Documentation

kzsError kzuTextRendererCreate ( const struct KzcMemoryManager memoryManager,
struct KzuResourceManager resourceManager,
struct KzuTextRenderer **  out_textRenderer 
)

Creates a text renderer.

kzsError kzuTextRendererDelete ( struct KzuTextRenderer textRenderer)

Deletes a text renderer.

kzsError kzuTextRendererSetDefaultFontMaterial ( struct KzuTextRenderer textRenderer,
struct KzuMaterial material 
)

Sets the default font material and acquires the material.

struct KzuMaterial* kzuTextRendererGetValidFontMaterial ( const struct KzuTextRenderer textRenderer,
const struct KzuRenderer renderer,
struct KzuMaterial material 
)

Returns a valid font material.

struct KzuTextManager* kzuTextRendererGetTextManager ( const struct KzuTextRenderer textRenderer)

Returns the text manager of the text renderer.

kzsError kzuTextRendererCreateTextFormat ( const struct KzuTextRenderer textRenderer,
struct KzuFont font,
kzFloat  fontSize,
kzFloat  width,
kzFloat  height,
struct KzuTextFormat **  out_textFormat 
)

Creates a text layout.

The text layout specifies the maximum area which can be used to layout text. The width and height are specified in pixels and they can be KZS_INFINITY for an unbounded area.

kzsError kzuTextRendererDeleteTextFormat ( struct KzuTextFormat textFormat)

Deletes a text layout.

void kzuTextFormatSetTextHorizontalAlignment ( struct KzuTextFormat textFormat,
enum KzuTextHorizontalAlignment  alignment 
)

Sets the horizontal alignment of the text.

void kzuTextFormatSetTextVerticalAlignment ( struct KzuTextFormat textFormat,
enum KzuTextVerticalAlignment  alignment 
)

Sets the vertical alignment of the text.

void kzuTextFormatSetLineSpacing ( const struct KzuTextFormat textFormat,
kzFloat  lineSpacing 
)

Sets the line spacing of the text.

The line spacing is specified in multiples of the normal line height which is specified by the font.

void kzuTextFormatSetCharacterSpacing ( const struct KzuTextFormat textFormat,
kzFloat  characterSpacing 
)

Sets the character spacing of the text.

The character spacing is specified in multiples of the normal character spacing which is specified by the font.

void kzuTextFormatSetFixedCharacterWidth ( const struct KzuTextFormat textFormat,
kzFloat  fixedCharacterWidth 
)

Sets the fixed character width of the text.

The character width is specified in pixels.

kzsError kzuTextFormatSetOverflow ( const struct KzuTextFormat textFormat,
kzString  overflowText 
)

Sets the overflow text that is displayed when the text doesn't fit to the layout.

void kzuTextFormatSetBidiShapingEnabled ( const struct KzuTextFormat textFormat,
kzBool  bidiShapingEnabled 
)

Sets whether support for complex scripts is enabled.

This includes support for bi-directional text and languages that require ligatures.

kzsError kzuTextFormatCalculateLayout ( struct KzuTextFormat textFormat,
kzString  text 
)

Calculates the text layout.

kzFloat kzuTextFormatGetWidth ( const struct KzuTextFormat textFormat)

Gets the width of the area that the text layout actually used.

The width is returned in pixels. The text layout must be calculated before calling this function.

kzFloat kzuTextFormatGetHeight ( const struct KzuTextFormat textFormat)

Gets the height of the area that the text layout actually used.

The height is returned in pixels. The text layout must be calculated before calling this function.

kzsError kzuTextFormatPrepareForRendering3D ( struct KzuTextFormat textFormat,
kzFloat  unitScale,
kzFloat  offsetX,
kzFloat  offsetY 
)

Prepares a text layout for rendering in 3d space, where x-coordinates increase to the right and y-coordinates increase going upward.

The z-coordinate of the text is always 0.0f. The pixel size of the text font is multiplied by the scale to get the size of the text in the 3d space. The text offsets given in 3d space units are used calculate proper horizontal aligning. They should be set to half of the width and height of the whole text format.

kzsError kzuTextFormatPrepareForRendering2D ( struct KzuTextFormat textFormat,
kzFloat  unitScale,
kzFloat  offsetX,
kzFloat  offsetY 
)

Prepares a text layout for rendering in 2d space, where x-coordinates increase to the right and y-coordinates increase going downward.

The pixel size of the text font is multiplied by the scale to get the size of the text in the 2d space.

kzsError kzuTextFormatPrepareForRendering2DWithClipping ( struct KzuTextFormat textFormat,
kzFloat  unitScale,
const struct KzcRectangle clippingArea,
kzFloat  offsetX,
kzFloat  offsetY 
)

Prepares a text layout for rendering in a bounded 2d space.

Generates unclipped vertex positions and bounding box coordinates for the clipping function to use.

kzsError kzuTextFormatCalculateClipping ( struct KzuTextFormat textFormat,
const struct KzcRectangle clippingArea 
)

Calculates clipped vertex coordinates from the bounding coordinates generated in the preparation function.

Characters that are outside the bounded area are clipped completely, and characters that are on the border of area are clipped so that only part of the character is visible.

kzsError kzuTextRendererDrawTextFormat ( const struct KzuTextRenderer textRenderer,
struct KzuRenderer renderer,
const struct KzuTextFormat textFormat,
struct KzuMaterial material 
)

Renders a text format.

The text format must be calculated and prepared for rendering before calling this function. If the material is KZ_NULL, uses the default font material.

kzsError kzuTextRendererDrawTextFormatTwoPass ( const struct KzuTextRenderer textRenderer,
struct KzuRenderer renderer,
const struct KzuTextFormat textFormat,
struct KzuMaterial material 
)

Renders a text format.

The text format must be calculated and prepared for rendering before calling this function. If the material is KZ_NULL, uses the default font material. This function renders the text in two passes. First all color information is written with depth write disabled and then in the second pass depth information is written with color write disabled. This is slower than kzuTextRendererDrawTextFormat, but needed for correct rendering result when glyph bounds are overlapping.

kzsError kzuTextRendererGetBitmapFontSystem ( struct KzuTextRenderer textRenderer,
struct KzuBitmapFontSystem **  out_bitmapFontSystem 
)

Gets a bitmap font system.

It is created and deleted automatically if necessary.

kzsError kzuTextRendererGetTruetypeSystem ( struct KzuTextRenderer textRenderer,
struct KzuTruetypeSystem **  out_truetypeSystem 
)

Gets a TrueType font system.

It is created and deleted automatically if necessary.

kzsError kzuTextRendererSetTruetypeSystem ( struct KzuTextRenderer textRenderer,
struct KzuTruetypeSystem truetypeSystem 
)

Sets a TrueType font system, which overrides the default TrueType system.

kzsError kzuTextRendererSetTextLayouterCreator ( struct KzuTextRenderer textRenderer,
kzuTextRendererCreateTextLayouterFunction  createFunction,
void userData 
)

Sets a creator function for creating text layouters.

Pass KZ_NULL as the function to reset to the default implementation.