CoreComponents 3.0.0
A Modern C++ Toolkit
Loading...
Searching...
No Matches
TextRun Class Reference

Richtext typeset sequence. More...

#include <cc/TextRun>

Inheritance diagram for TextRun:

Public Member Functions

 TextRun ()
 Create an empty text run.
 
 TextRun (const String &text, const Font &font=Font{})
 Typeset text with font (text is interpreted as plain text)
 
TextRunappend (const String &text, const Font &font=Font{})
 Typeset text (plain text) with font.
 
TextRunappendHtml (const String &text, const Font &font=Font{})
 Typeset text (HTML text) with font.
 
TextRun wrap (double maxWidth, TextAlign textAlign=TextAlign::Left, double lineHeight=0, const TextWrapBehind &wrapBehind=textWrapBehindDefault) const
 Wrap this text run.
 
Point advance () const
 Advance of this text run
 
double firstLineHeight () const
 Height of the first line (in pixel)
 
Size size () const
 Size of this text run
 
double maxAscender () const
 Highest ascender.
 
double minDescender () const
 Lowest descender.
 
int lineCount () const
 Number of lines
 
int byteCount () const
 Number of bytes
 
TextCursor getTextCursor (int byteOffset=0) const
 Get a text cursor situated at byteOffset.
 
TextCursor getNearestTextCursor (Point pointerPos) const
 Get a text cursor located closest to pointerPos.
 
TextCursor getNearestTextCursorBelow (const TextCursor &cursor) const
 Get the nearest text cursor a line below the current line.
 
TextCursor getNearestTextCursorAbove (const TextCursor &cursor) const
 Get the nearest text cursor a line above the current line.
 
TextCursor getNearestLineStart (Point pointerPos) const
 Get a text cursor located at the line start closest to pointerPos.
 
TextCursor getNearestTextCursorInLine (Point pointerPos) const
 Get a text cursor located closest to pointerPos within the same line.
 
- Public Member Functions inherited from Object
 Object ()=default
 Create a null object.
 
 operator bool () const
 Check if this is a non-null object.
 
bool isNull () const
 Check if this is a null object.
 
template<class T >
bool is () const
 Check if this object is of type T.
 
template<class T >
as () const
 Cast this object to type T.
 
bool isWeak () const
 Check if the underlying object reference is weak.
 
bool operator== (const Object &other) const
 Equality operator.
 
std::strong_ordering operator<=> (const Object &other) const
 Ordering operator.
 
long useCount () const
 Reference count.
 

Static Public Member Functions

static TextRun fromHtml (const String &text, const Font &font=Font{})
 Typeset text with font (recognised HTML tags: u, b, i)
 

Protected Member Functions

 TextRun (State *newState)
 
State & me ()
 
const State & me () const
 
- Protected Member Functions inherited from Object
template<class T >
weak () const
 
template<class T >
void initOnce ()
 Create the object state when called the first time.
 
template<class T >
void initOncePerThread ()
 Create a distinct object state for each thread when called the first time in that thread.
 
 Object (State *newState)
 Initialize object with newState.
 
 Object (State *state, Alias)
 
 Object (State *state, Weak)
 
Objectoperator= (std::nullptr_t)
 

Static Protected Member Functions

static String replaceEntities (String text)
 
- Static Protected Member Functions inherited from Object
template<class T >
static T alias (const State *state)
 Create an alias object for the given state.
 
template<class T >
static T weak (const State *state)
 

Additional Inherited Members

- Protected Attributes inherited from Object
Handle< Stateme
 Internal object state
 

Detailed Description

Richtext typeset sequence.

Constructor & Destructor Documentation

◆ TextRun() [1/2]

TextRun ( )

Create an empty text run.

◆ TextRun() [2/2]

TextRun ( const String & text,
const Font & font = Font{} )

Typeset text with font (text is interpreted as plain text)

Member Function Documentation

◆ fromHtml()

TextRun fromHtml ( const String & text,
const Font & font = Font{} )
static

Typeset text with font (recognised HTML tags: u, b, i)

◆ append()

TextRun & append ( const String & text,
const Font & font = Font{} )

Typeset text (plain text) with font.

◆ appendHtml()

TextRun & appendHtml ( const String & text,
const Font & font = Font{} )

Typeset text (HTML text) with font.

◆ wrap()

TextRun wrap ( double maxWidth,
TextAlign textAlign = TextAlign::Left,
double lineHeight = 0,
const TextWrapBehind & wrapBehind = textWrapBehindDefault ) const

Wrap this text run.

Parameters
maxWidthMaximum width of the wrapped text run
textAlignAlignment of the wrapped text
lineHeightLine height
wrapBehindCheck if a text can be wrapped behind a certain text fragment.
Returns
Wrapped text run

◆ advance()

Point advance ( ) const

Advance of this text run

◆ firstLineHeight()

double firstLineHeight ( ) const

Height of the first line (in pixel)

◆ size()

Size size ( ) const

Size of this text run

◆ maxAscender()

double maxAscender ( ) const

Highest ascender.

◆ minDescender()

double minDescender ( ) const

Lowest descender.

◆ lineCount()

int lineCount ( ) const

Number of lines

◆ byteCount()

int byteCount ( ) const

Number of bytes

◆ getTextCursor()

TextCursor getTextCursor ( int byteOffset = 0) const

Get a text cursor situated at byteOffset.

◆ getNearestTextCursor()

TextCursor getNearestTextCursor ( Point pointerPos) const

Get a text cursor located closest to pointerPos.

◆ getNearestTextCursorBelow()

TextCursor getNearestTextCursorBelow ( const TextCursor & cursor) const

Get the nearest text cursor a line below the current line.

◆ getNearestTextCursorAbove()

TextCursor getNearestTextCursorAbove ( const TextCursor & cursor) const

Get the nearest text cursor a line above the current line.

◆ getNearestLineStart()

TextCursor getNearestLineStart ( Point pointerPos) const

Get a text cursor located at the line start closest to pointerPos.

◆ getNearestTextCursorInLine()

TextCursor getNearestTextCursorInLine ( Point pointerPos) const

Get a text cursor located closest to pointerPos within the same line.