All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
kzu_text_renderer.h File Reference

Text Renderer. More...

Namespaces

 kanzi
 

Typedefs

typedef shared_ptr< KzuTextFormatkanzi::TextFormatSharedPtr
 TextFormat shared pointer. More...
 
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

KANZI_API kzsError kzuTextRendererCreate (const KzcMemoryManager *memoryManager, kanzi::ResourceManager *resourceManager, KzuTextRenderer **out_textRenderer)
 Creates a text renderer. More...
 
KANZI_API kzsError kzuTextRendererDelete (struct KzuTextRenderer *textRenderer)
 Deletes a text renderer. More...
 
KANZI_API void kzuTextRendererClearResources (struct KzuTextRenderer *textRenderer)
 Clears all resources that the text renderer holds. More...
 
KANZI_API void kzuTextRendererSetDefaultFontMaterial (struct KzuTextRenderer *textRenderer, kanzi::MaterialSharedPtr material)
 Sets the default font material and acquires the material. More...
 
KANZI_API kanzi::MaterialkzuTextRendererGetValidFontMaterial (const struct KzuTextRenderer *textRenderer, kanzi::Renderer3D *renderer, kanzi::Material *material)
 Returns a valid font material. More...
 
KANZI_API struct KzuTextManagerkzuTextRendererGetTextManager (const struct KzuTextRenderer *textRenderer)
 Returns the text manager of the text renderer. More...
 
KANZI_API
kanzi::TextFormatSharedPtr 
kzuTextRendererCreateTextFormat (const struct KzuTextRenderer *textRenderer, struct KzuFont *font, kzFloat fontSize, kzFloat width, kzFloat height)
 Creates a text layout. More...
 
KANZI_API void kzuTextFormatSetTextHorizontalAlignment (struct KzuTextFormat *textFormat, TextConcept::TextHorizontalAlignment alignment)
 Sets the horizontal alignment of the text. More...
 
KANZI_API void kzuTextFormatSetTextVerticalAlignment (struct KzuTextFormat *textFormat, TextConcept::TextVerticalAlignment alignment)
 Sets the vertical alignment of the text. More...
 
KANZI_API void kzuTextFormatSetLineSpacing (const struct KzuTextFormat *textFormat, kzFloat lineSpacing)
 Sets the line spacing of the text. More...
 
KANZI_API void kzuTextFormatSetCharacterSpacing (const struct KzuTextFormat *textFormat, kzFloat characterSpacing)
 Sets the character spacing of the text. More...
 
KANZI_API void kzuTextFormatSetFixedCharacterWidth (const struct KzuTextFormat *textFormat, kzFloat fixedCharacterWidth)
 Sets the fixed character width of the text. More...
 
KANZI_API 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...
 
KANZI_API void kzuTextFormatSetBidiShapingEnabled (const struct KzuTextFormat *textFormat, kzBool bidiShapingEnabled)
 Sets whether support for complex scripts is enabled. More...
 
KANZI_API kzsError kzuTextFormatCalculateLayout (struct KzuTextFormat *textFormat, kzString text)
 Calculates the text layout. More...
 
KANZI_API kzFloat kzuTextFormatGetWidth (const struct KzuTextFormat *textFormat)
 Gets the width of the area that the text layout actually used. More...
 
KANZI_API kzFloat kzuTextFormatGetHeight (const struct KzuTextFormat *textFormat)
 Gets the height of the area that the text layout actually used. More...
 
KANZI_API const
KzuCharacterLayout
kzuTextFormatGetCharacterLayout (const struct KzuTextFormat *textFormat, kzUint index)
 Gets the layout structure of the given character. More...
 
KANZI_API kzUint kzuTextFormatGetCharacterCount (const struct KzuTextFormat *textFormat)
 Gets the count of characters. More...
 
KANZI_API kzBool kzuTextFormatIsTruncated (const struct KzuTextFormat *textFormat)
 Check if layouted text got truncated, i.e. More...
 
KANZI_API void 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...
 
KANZI_API void 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...
 
KANZI_API void 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...
 
KANZI_API kzsError kzuTextFormatCalculateClipping (struct KzuTextFormat *textFormat, const struct KzcRectangle *clippingArea)
 Calculates clipped vertex coordinates from the bounding coordinates generated in the preparation function. More...
 
KANZI_API KzcRectangle kzuTextFormatGetBoundingRectangle (const struct KzuTextFormat *textFormat)
 Get clipped bounding rectangle for text format. More...
 
KANZI_API kanzi::TextureSharedPtr kzuTextRendererGetGlyphTexture (const struct KzuTextRenderer *textRenderer, const struct KzuTextFormat *textFormat)
 Acquire texture for rendering text format. More...
 
KANZI_API kzsError kzuTextRendererDrawTextFormatBrush (const struct KzuTextRenderer *textRenderer, kanzi::Renderer3D *renderer, const struct KzuTextFormat *textFormat)
 Renders text format. More...
 
KANZI_API kzsError kzuTextRendererDrawTextFormat (const struct KzuTextRenderer *textRenderer, kanzi::Renderer3D *renderer, const struct KzuTextFormat *textFormat, kanzi::Material *material)
 Renders a text format. More...
 
KANZI_API kzsError kzuTextRendererDrawTextFormatTwoPass (const struct KzuTextRenderer *textRenderer, kanzi::Renderer3D *renderer, const struct KzuTextFormat *textFormat, kanzi::Material *material)
 Renders a text format. More...
 
KANZI_API kzsError kzuTextRendererGetBitmapFontSystem (struct KzuTextRenderer *textRenderer, struct KzuBitmapFontSystem **out_bitmapFontSystem)
 Gets a bitmap font system. More...
 
KANZI_API kzsError kzuTextRendererGetTruetypeSystem (struct KzuTextRenderer *textRenderer, struct KzuTruetypeSystem **out_truetypeSystem)
 Gets a TrueType font system. More...
 
KANZI_API kzsError kzuTextRendererSetTruetypeSystem (struct KzuTextRenderer *textRenderer, struct KzuTruetypeSystem *truetypeSystem)
 Sets a TrueType font system, which overrides the default TrueType system. More...
 
KANZI_API kzsError kzuTextRendererSetTextLayouterCreator (struct KzuTextRenderer *textRenderer, kzuTextRendererCreateTextLayouterFunction createFunction, void *userData)
 Sets a creator function for creating text layouters. More...
 

Detailed Description

Text Renderer.

Copyright 2008-2020 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

KANZI_API kzsError kzuTextRendererCreate ( const KzcMemoryManager memoryManager,
kanzi::ResourceManager resourceManager,
KzuTextRenderer **  out_textRenderer 
)

Creates a text renderer.

KANZI_API kzsError kzuTextRendererDelete ( struct KzuTextRenderer textRenderer)

Deletes a text renderer.

KANZI_API void kzuTextRendererClearResources ( struct KzuTextRenderer textRenderer)

Clears all resources that the text renderer holds.

KANZI_API void kzuTextRendererSetDefaultFontMaterial ( struct KzuTextRenderer textRenderer,
kanzi::MaterialSharedPtr  material 
)

Sets the default font material and acquires the material.

KANZI_API kanzi::Material* kzuTextRendererGetValidFontMaterial ( const struct KzuTextRenderer textRenderer,
kanzi::Renderer3D renderer,
kanzi::Material material 
)

Returns a valid font material.

KANZI_API struct KzuTextManager* kzuTextRendererGetTextManager ( const struct KzuTextRenderer textRenderer)

Returns the text manager of the text renderer.

KANZI_API kanzi::TextFormatSharedPtr kzuTextRendererCreateTextFormat ( const struct KzuTextRenderer textRenderer,
struct KzuFont font,
kzFloat  fontSize,
kzFloat  width,
kzFloat  height 
)

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.

KANZI_API void kzuTextFormatSetTextHorizontalAlignment ( struct KzuTextFormat textFormat,
TextConcept::TextHorizontalAlignment  alignment 
)

Sets the horizontal alignment of the text.

KANZI_API void kzuTextFormatSetTextVerticalAlignment ( struct KzuTextFormat textFormat,
TextConcept::TextVerticalAlignment  alignment 
)

Sets the vertical alignment of the text.

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

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

KANZI_API void kzuTextFormatSetFixedCharacterWidth ( const struct KzuTextFormat textFormat,
kzFloat  fixedCharacterWidth 
)

Sets the fixed character width of the text.

The character width is specified in pixels.

KANZI_API kzsError kzuTextFormatSetOverflow ( const struct KzuTextFormat textFormat,
kzString  overflowText 
)

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

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

KANZI_API kzsError kzuTextFormatCalculateLayout ( struct KzuTextFormat textFormat,
kzString  text 
)

Calculates the text layout.

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

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

KANZI_API const KzuCharacterLayout* kzuTextFormatGetCharacterLayout ( const struct KzuTextFormat textFormat,
kzUint  index 
)

Gets the layout structure of the given character.

The text layout must be calculated before calling this function.

KANZI_API kzUint kzuTextFormatGetCharacterCount ( const struct KzuTextFormat textFormat)

Gets the count of characters.

The text layout must be calculated before calling this function.

KANZI_API kzBool kzuTextFormatIsTruncated ( const struct KzuTextFormat textFormat)

Check if layouted text got truncated, i.e.

it did not fit. The text layout must be calculated before calling this function.

KANZI_API void 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 to calculate proper horizontal aligning. They should be set to half of the width and height of the whole text format.

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

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

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

KANZI_API KzcRectangle kzuTextFormatGetBoundingRectangle ( const struct KzuTextFormat textFormat)

Get clipped bounding rectangle for text format.

Parameters
textFormatText format to query.
Returns
Rectangle.
KANZI_API kanzi::TextureSharedPtr kzuTextRendererGetGlyphTexture ( const struct KzuTextRenderer textRenderer,
const struct KzuTextFormat textFormat 
)

Acquire texture for rendering text format.

Parameters
textRendererText renderer to use.
textFormatText format to render.
Returns
Glyph texture.
KANZI_API kzsError kzuTextRendererDrawTextFormatBrush ( const struct KzuTextRenderer textRenderer,
kanzi::Renderer3D renderer,
const struct KzuTextFormat textFormat 
)

Renders text format.

Used for rendering with a brush, shader, etc. is already assumed to be bound by the brush.

Parameters
textRendererText renderer to use.
rendererRenderer to use.
textFormatText format to draw.
KANZI_API kzsError kzuTextRendererDrawTextFormat ( const struct KzuTextRenderer textRenderer,
kanzi::Renderer3D renderer,
const struct KzuTextFormat textFormat,
kanzi::Material 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.

KANZI_API kzsError kzuTextRendererDrawTextFormatTwoPass ( const struct KzuTextRenderer textRenderer,
kanzi::Renderer3D renderer,
const struct KzuTextFormat textFormat,
kanzi::Material 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.

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

Gets a bitmap font system.

It is created and deleted automatically if necessary.

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

Gets a TrueType font system.

It is created and deleted automatically if necessary.

KANZI_API kzsError kzuTextRendererSetTruetypeSystem ( struct KzuTextRenderer textRenderer,
struct KzuTruetypeSystem truetypeSystem 
)

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

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