You.i Engine
CYITextLayout Class Referenceabstract

Detailed Description

Base class for abstracting the layout for text.

Concrete classes implement specific layout engines.

#include <graphics/YiTextLayout.h>

Public Types

enum  TextDirection {
  TextDirection::LeftToRight = 0,
  TextDirection::RightToLeft = 1,
  TextDirection::Mixed = 2,
  TextDirection::Undefined = 3
}
 Enumeration for direction types used in text layout. More...
 

Public Member Functions

 CYITextLayout ()
 
virtual ~CYITextLayout ()
 
virtual bool LayoutText (const CYITextEngine::RenderInfo &TextRenderInfo, const CYITextRenderer *pTextRenderer)=0
 
virtual size_t GetLineCount () const =0
 
virtual const CYITextLayoutLine * GetTextLine (size_t index) const =0
 
virtual CYITextLayout::TextDirection GetTextDirection () const =0
 
virtual bool IsComplex () const =0
 
virtual int32_t GetAscent () const =0
 
virtual int32_t GetDescent () const =0
 
virtual int32_t GetLeading () const =0
 
virtual float GetGlyphBoxVerticalOffset () const =0
 
virtual float GetFirstBaselineVerticalOffset () const =0
 
virtual void Clear ()=0
 
virtual CYITextEngine::PositionInString GetIndexOfPosition (float x, float y, float horizontalPixelRatio, float verticalPixelRatio) const =0
 
virtual CYITextEngine::PositionInString GetOffsetPosition (CYITextEngine::PositionInString initialPosition, int8_t offset) const =0
 
virtual YI_FLOAT_RECT GetRectForTextRange (size_t startIndex, size_t endIndex, float horizontalPixelRatio, float verticalPixelRatio) const =0
 
virtual float GetAdjustedFontSizeScale () const =0
 
virtual bool IsCharacterRightToLeft (size_t characterIndex) const =0
 
virtual TextDirection GetCharacterTextDirection (size_t characterIndex) const =0
 
virtual TextDirection GetBaseTextDirection () const =0
 
virtual bool HasEllipsis () const
 

Member Enumeration Documentation

◆ TextDirection

Enumeration for direction types used in text layout.

Enumerator
LeftToRight 
RightToLeft 
Mixed 
Undefined 

Constructor & Destructor Documentation

◆ CYITextLayout()

CYITextLayout::CYITextLayout ( )
inline

◆ ~CYITextLayout()

virtual CYITextLayout::~CYITextLayout ( )
inlinevirtual

Member Function Documentation

◆ Clear()

virtual void CYITextLayout::Clear ( )
pure virtual

Method to clear all of the stored layout information.

◆ GetAdjustedFontSizeScale()

virtual float CYITextLayout::GetAdjustedFontSizeScale ( ) const
pure virtual

Returns the ratio of the font size after adjusting to fit to the text node, to the original font size. Returns 1 if the font size did not get scaled.

◆ GetAscent()

virtual int32_t CYITextLayout::GetAscent ( ) const
pure virtual

Returns the maximum ascent value for all the fonts in the text.

◆ GetBaseTextDirection()

virtual TextDirection CYITextLayout::GetBaseTextDirection ( ) const
pure virtual

Returns the base text direction of the text being laid out.

◆ GetCharacterTextDirection()

virtual TextDirection CYITextLayout::GetCharacterTextDirection ( size_t  characterIndex) const
pure virtual

Returns the text direction of the character at index characterIndex. Returns TextDirection::Undefined if characterIndex is greater-than or equal to the number of characters.

◆ GetDescent()

virtual int32_t CYITextLayout::GetDescent ( ) const
pure virtual

Returns the maximum descent value for all the fonts in the text.

◆ GetFirstBaselineVerticalOffset()

virtual float CYITextLayout::GetFirstBaselineVerticalOffset ( ) const
pure virtual

Returns the offset applied to all glyphs so that the top of the first line aligns to the top of the text rect. Subtract this value from all glyph positions in order to get the baseline of the first line aligned to the top of the text rect (e.g. to get the 'point text' behaviour)

◆ GetGlyphBoxVerticalOffset()

virtual float CYITextLayout::GetGlyphBoxVerticalOffset ( ) const
pure virtual

Returns the vertical offset needed to get a glyph box that is vertically 'centered' on the text. The centering here isn't actual centering, but takes the ascender of the first line and the descender of the last line into account.

◆ GetIndexOfPosition()

virtual CYITextEngine::PositionInString CYITextLayout::GetIndexOfPosition ( float  x,
float  y,
float  horizontalPixelRatio,
float  verticalPixelRatio 
) const
pure virtual

Returns the index of the space between two characters in the text closest to the specified local coordinate position, relative to the top left corner of the node containing the text. The return value is an instance of CYITextEngine::PositionInString, which contains information about the logical position in the string, and where it should be visually represented.

Note
The horizontal pixel ratio horizontalPixelRatio and vertical pixel ratio verticalPixelRatio can be obtained from the camera and are based on the scaling type used to load the After Effects composition.
Currently this is only supported for single line text but the y position y and vertical pixel ratio verticalPixelRatio are added for future multiline support.
See also
CYITextEngine::PositionInString

◆ GetLeading()

virtual int32_t CYITextLayout::GetLeading ( ) const
pure virtual

Returns the maximum leading value for all the fonts in the text.

◆ GetLineCount()

virtual size_t CYITextLayout::GetLineCount ( ) const
pure virtual

Returns the number of lines the text was split up into when the LayoutText() method was called.

◆ GetOffsetPosition()

virtual CYITextEngine::PositionInString CYITextLayout::GetOffsetPosition ( CYITextEngine::PositionInString  initialPosition,
int8_t  offset 
) const
pure virtual

Given a position within a string initialPosition, which describes the logical position between characters and where it's represented visually, this function returns the position visually offset from that position by a number of characters described by offset. The return value is an instance of CYITextEngine::PositionInString, which contains information about the logical position in the string, and where it should be visually represented.

Note
If offset is negative, the output position will be offset from the input position to the left, and if positive, it will be offset to the right. In both cases, the magnitude of offset is the number of characters that the output position will be offset from the input position.
See also
GetIndexOfPosition
CYITextEngine::PositionInString

◆ GetRectForTextRange()

virtual YI_FLOAT_RECT CYITextLayout::GetRectForTextRange ( size_t  startIndex,
size_t  endIndex,
float  horizontalPixelRatio,
float  verticalPixelRatio 
) const
pure virtual

Get the rect surrounding characters from startIndex to endIndex for the cached layout of text that has been rendered.

Note
For bidirectional text, the resulting rect will span the leftmost character, to the rightmost character, potentially also surrounding characters outside of the range of character indices.
If no text has been rendered, by calling RenderText previously, or invalid index values are passed then the rect will be set to 0 for all values.

◆ GetTextDirection()

virtual CYITextLayout::TextDirection CYITextLayout::GetTextDirection ( ) const
pure virtual

Returns the directions of the text: left to right, right to left, mixed, or undefined if no text has been laid out yet or the text contains not LTR or RTL characters.

◆ GetTextLine()

virtual const CYITextLayoutLine* CYITextLayout::GetTextLine ( size_t  index) const
pure virtual

Returns a specific line of text specified by the index parameter.

◆ HasEllipsis()

virtual bool CYITextLayout::HasEllipsis ( ) const
inlinevirtual

◆ IsCharacterRightToLeft()

virtual bool CYITextLayout::IsCharacterRightToLeft ( size_t  characterIndex) const
pure virtual

Returns true if the chracter at index characterIndex is in a right-to-left run of characters. Returns false otherwise or if characterIndex is greater than or equal to the number of characters.

◆ IsComplex()

virtual bool CYITextLayout::IsComplex ( ) const
pure virtual

Returns true if the text contains characters in any script which require complex processing to be rendered correctly.

◆ LayoutText()

virtual bool CYITextLayout::LayoutText ( const CYITextEngine::RenderInfo TextRenderInfo,
const CYITextRenderer *  pTextRenderer 
)
pure virtual

Layout the specified text in the text parameter using the font specified in the fontID parameter. The layout breaks the text into multiple lines depending on the width specified in the width parameter. The lines can be accessed by calling the method GetTextLine(). The pTextRenderer is a pointer to a text renderer so that the layout can get at font information required to perform the layout. true is returned if the layout was successful.


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