Kanzi  3.9.9
Kanzi Engine C++ API
kanzi::TextShaper Class Reference

TextShaper encapsulates different shaping libraries, used by TextLayouter to perform BiDi layouting, text shaping and glyph substitution. More...

#include <kanzi/core.ui/text/text_shaper.hpp>

Inheritance diagram for kanzi::TextShaper:
[legend]

Public Member Functions

virtual void adjustPositions (TextLayouter::IntermediateLayout *layout, const TextLayouter::LineInfo &line) const
 This phase iterates through all layouted glyphs on the line and adjusts the positions based on shaping results. More...
 
virtual void appendTerminator (unsigned int newSize, const TextLayouter::IntermediateLayout *terminator, unsigned int terminatorPosition)
 Updates the internal shaper structures to accommodate a terminator string, which replaces a part of the original text. More...
 
virtual void cleanup ()
 Cleans up data used for shaping a specific text run. More...
 
uint8_t getBaseBiDiLevel () const
 Gets the base bidi-level of the text. More...
 
virtual void insertText (unsigned int location, const TextLayouter::IntermediateLayout *text)
 Updates the internal shaper structures to accommodate another string, which Kanzi inserts in the original text. More...
 
virtual vector< TextLayouter::CharacterInfomarkBidiAndShape (const vector< char32_t > &unicodeText)
 This function performs the following operations. More...
 
virtual void prepareLines (TextLayouter::IntermediateLayout *layout)
 Prepares the internal data structures after line breaking. More...
 
virtual void removeText (unsigned int location, unsigned int length)
 When Kanzi truncates a part of text, updates the internal shaper structures in accordance with the changes to the shaped text during the text layout. More...
 
virtual void reorderLine (TextLayouter::IntermediateLayout *layout, const TextLayouter::LineInfo &line)
 Reorders the text line for the text written right-to-left. More...
 
void setBaseBiDiLevel (uint8_t baseBiDiLevel)
 Sets the base bidi-level of the text. More...
 
 TextShaper (const FontRuntime &font)
 Constructor. More...
 
virtual ~TextShaper ()
 Destructor. More...
 

Protected Member Functions

FontFilegetFontFile (const FontRuntime &font) const
 Gets the font file that the passed font is currently using. More...
 

Protected Attributes

uint8_t m_baseBiDiLevel
 The base bidi-level. More...
 
const FontRuntimem_font
 Font object used for shaping. More...
 

Detailed Description

TextShaper encapsulates different shaping libraries, used by TextLayouter to perform BiDi layouting, text shaping and glyph substitution.

TextLayouter calls the shaping functions for every text being layouted in the following order:

  1. markBidiAndShape() for initial creation of layouting information
  2. appendTerminator() for adding terminator (if text is truncated)
  3. prepareLines() to prepare shaper internal data structures when line breaks are available
  4. reorderLine() for every line to apply right-to-left formatting
  5. adjustPositions() for every line to move characters to correct visual positions
  6. cleanup() to allow shaper to clean internal data structures

Constructor & Destructor Documentation

kanzi::TextShaper::TextShaper ( const FontRuntime font)
explicit

Constructor.

Parameters
fontFont object used for shaping.
virtual kanzi::TextShaper::~TextShaper ( )
virtual

Destructor.

Member Function Documentation

virtual vector<TextLayouter::CharacterInfo> kanzi::TextShaper::markBidiAndShape ( const vector< char32_t > &  unicodeText)
virtual

This function performs the following operations.

  • Creates tags to indicate which parts of the text are written left-to-right and which right-to-left.
  • Performs mirroring of specific character for the text written right-to-left.
  • Performs text shaping.
    Parameters
    unicodeTextText to shape and mirror.
    Returns
    Layouting information per character.

Reimplemented in kanzi::ItypeTextShaper, and kanzi::FreeTypeTextShaper.

virtual void kanzi::TextShaper::appendTerminator ( unsigned int  newSize,
const TextLayouter::IntermediateLayout terminator,
unsigned int  terminatorPosition 
)
virtual

Updates the internal shaper structures to accommodate a terminator string, which replaces a part of the original text.

Parameters
newSizeSize of text including terminator.
terminatorPointer to intermediate layout containing terminator.
terminatorPositionThe position in the text buffer at which the terminator would be appended. This is needed for RTL text. For LTR text, the terminator position is always at the right-end of the text.

Reimplemented in kanzi::ItypeTextShaper.

virtual void kanzi::TextShaper::insertText ( unsigned int  location,
const TextLayouter::IntermediateLayout text 
)
virtual

Updates the internal shaper structures to accommodate another string, which Kanzi inserts in the original text.

For example, a hyphen.

Parameters
locationPosition where the string is inserted.
textPointer to intermediate layout containing the text.

Reimplemented in kanzi::ItypeTextShaper.

virtual void kanzi::TextShaper::removeText ( unsigned int  location,
unsigned int  length 
)
virtual

When Kanzi truncates a part of text, updates the internal shaper structures in accordance with the changes to the shaped text during the text layout.

Parameters
locationPosition at which the text is removed.
lengthLength of the removed text.
Since
Kanzi 3.9.6

Reimplemented in kanzi::ItypeTextShaper.

virtual void kanzi::TextShaper::prepareLines ( TextLayouter::IntermediateLayout layout)
virtual

Prepares the internal data structures after line breaking.

Parameters
layoutPointer to intermediate layout containing the text.

Reimplemented in kanzi::FreeTypeTextShaper.

virtual void kanzi::TextShaper::reorderLine ( TextLayouter::IntermediateLayout layout,
const TextLayouter::LineInfo line 
)
virtual

Reorders the text line for the text written right-to-left.

Parameters
layoutPointer to intermediate layout containing the text.
lineInformation defining the currently processed line.

Reimplemented in kanzi::ItypeTextShaper, and kanzi::FreeTypeTextShaper.

virtual void kanzi::TextShaper::adjustPositions ( TextLayouter::IntermediateLayout layout,
const TextLayouter::LineInfo line 
) const
virtual

This phase iterates through all layouted glyphs on the line and adjusts the positions based on shaping results.

Parameters
layoutPointer to intermediate layout containing the text.
lineInformation defining the currently processed line.

Reimplemented in kanzi::ItypeTextShaper.

virtual void kanzi::TextShaper::cleanup ( )
virtual

Cleans up data used for shaping a specific text run.

You need to call this function at the end of every shaping run.

Reimplemented in kanzi::ItypeTextShaper, and kanzi::FreeTypeTextShaper.

void kanzi::TextShaper::setBaseBiDiLevel ( uint8_t  baseBiDiLevel)

Sets the base bidi-level of the text.

The base bidi-level is derived from the first character of strong bidirectional character type, in the provided text. For LTR or direction-neutral text set an even bidi-level, whereas for RTL text set an odd bidi-level.

Since
Kanzi 3.9.0
uint8_t kanzi::TextShaper::getBaseBiDiLevel ( ) const

Gets the base bidi-level of the text.

An even bidi-level represents LTR text direction, whereas an odd bidi-level represents RTL text direction.

Since
Kanzi 3.9.0
FontFile& kanzi::TextShaper::getFontFile ( const FontRuntime font) const
protected

Gets the font file that the passed font is currently using.

Parameters
fontFont for which you want to get the font file that the font is currently using.
Returns
Font file that the passed font is currently using.

Member Data Documentation

const FontRuntime& kanzi::TextShaper::m_font
protected

Font object used for shaping.

uint8_t kanzi::TextShaper::m_baseBiDiLevel
protected

The base bidi-level.


The documentation for this class was generated from the following file: