Open CASCADE Technology
7.5.0
|
This class is intended to prepare formatted text by using:
More...
#include <Font_TextFormatter.hxx>
Data Structures | |
class | Iterator |
Iterator through formatted symbols. It's possible to filter returned symbols to have only significant ones. More... | |
Public Types | |
enum | IterationFilter { IterationFilter_None = 0x0000, IterationFilter_ExcludeInvisible = 0x0002 } |
Iteration filter flags. Command symbols are skipped with any filter. More... | |
Public Types inherited from Standard_Transient | |
typedef void | base_type |
Returns a type descriptor about this object. More... | |
Public Member Functions | |
Font_TextFormatter () | |
Default constructor. More... | |
void | SetupAlignment (const Graphic3d_HorizontalTextAlignment theAlignX, const Graphic3d_VerticalTextAlignment theAlignY) |
Setup alignment style. More... | |
void | Reset () |
Reset current progress. More... | |
void | Append (const NCollection_String &theString, Font_FTFont &theFont) |
Render specified text to inner buffer. More... | |
void | Format () |
Perform formatting on the buffered text. Should not be called more than once after initialization! More... | |
const NCollection_Vec2< Standard_ShortReal > & | TopLeft (const Standard_Integer theIndex) const |
const NCollection_Vec2< Standard_ShortReal > & | BottomLeft (const Standard_Integer theIndex) const |
Returns specific glyph rectangle. More... | |
const NCollection_String & | String () const |
Returns current rendering string. More... | |
Standard_Boolean | GlyphBoundingBox (const Standard_Integer theIndex, Font_Rect &theBndBox) const |
Returns symbol bounding box. More... | |
Standard_ShortReal | LineHeight (const Standard_Integer theIndex) const |
Returns the line height. More... | |
Standard_ShortReal | LineWidth (const Standard_Integer theIndex) const |
Returns width of a line. More... | |
Standard_Boolean | IsLFSymbol (const Standard_Integer theIndex) const |
Returns true if the symbol by the index is ' '. The width of the symbol is zero. More... | |
Standard_ShortReal | FirstPosition () const |
Returns position of the first symbol in a line using alignment. More... | |
Standard_Integer | LinePositionIndex (const Standard_Integer theIndex) const |
Returns column index of the corner index in the current line. More... | |
Standard_Integer | LineIndex (const Standard_Integer theIndex) const |
Returns row index of the corner index among text lines. More... | |
Standard_Integer | TabSize () const |
Returns tab size. More... | |
Graphic3d_HorizontalTextAlignment | HorizontalTextAlignment () const |
Returns horizontal alignment style. More... | |
Graphic3d_VerticalTextAlignment | VerticalTextAlignment () const |
Returns vertical alignment style. More... | |
void | SetWrapping (const Standard_ShortReal theWidth) |
Sets text wrapping width, zero means that the text is not bounded by width. More... | |
Standard_Boolean | HasWrapping () const |
Returns text maximum width, zero means that the text is not bounded by width. More... | |
Standard_ShortReal | Wrapping () const |
Returns text maximum width, zero means that the text is not bounded by width. More... | |
Standard_ShortReal | ResultWidth () const |
Standard_ShortReal | ResultHeight () const |
Standard_ShortReal | MaximumSymbolWidth () const |
void | BndBox (Font_Rect &theBndBox) const |
const NCollection_Vector< NCollection_Vec2< Standard_ShortReal > > & | Corners () const |
Returns internal container of the top left corners of a formatted rectangles. More... | |
const NCollection_Vector< Standard_ShortReal > & | NewLines () const |
Returns container of each line position at LF in formatted text. More... | |
Public Member Functions inherited from Standard_Transient | |
Standard_Transient () | |
Empty constructor. More... | |
Standard_Transient (const Standard_Transient &) | |
Copy constructor – does nothing. More... | |
Standard_Transient & | operator= (const Standard_Transient &) |
Assignment operator, needed to avoid copying reference counter. More... | |
virtual | ~Standard_Transient () |
Destructor must be virtual. More... | |
virtual void | Delete () const |
Memory deallocator for transient classes. More... | |
virtual const opencascade::handle< Standard_Type > & | DynamicType () const |
Returns a type descriptor about this object. More... | |
Standard_Boolean | IsInstance (const opencascade::handle< Standard_Type > &theType) const |
Returns a true value if this is an instance of Type. More... | |
Standard_Boolean | IsInstance (const Standard_CString theTypeName) const |
Returns a true value if this is an instance of TypeName. More... | |
Standard_Boolean | IsKind (const opencascade::handle< Standard_Type > &theType) const |
Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More... | |
Standard_Boolean | IsKind (const Standard_CString theTypeName) const |
Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More... | |
Standard_Transient * | This () const |
Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero. More... | |
Standard_Integer | GetRefCount () const |
Get the reference counter of this object. More... | |
void | IncrementRefCounter () const |
Increments the reference counter of this object. More... | |
Standard_Integer | DecrementRefCounter () const |
Decrements the reference counter of this object; returns the decremented value. More... | |
Static Public Member Functions | |
static Standard_Boolean | IsCommandSymbol (const Standard_Utf32Char &theSymbol) |
Returns true if the symbol is CR, BEL, FF, NP, BS or VT. More... | |
Static Public Member Functions inherited from Standard_Transient | |
static const char * | get_type_name () |
Returns a type descriptor about this object. More... | |
static const opencascade::handle< Standard_Type > & | get_type_descriptor () |
Returns type descriptor of Standard_Transient class. More... | |
Protected Member Functions | |
class auxiliary methods | |
void | newLine (const Standard_Integer theLastRect, const Standard_ShortReal theMaxLineWidth) |
Move glyphs on the current line to correct position. More... | |
Protected Attributes | |
configuration | |
Graphic3d_HorizontalTextAlignment | myAlignX |
horizontal alignment style More... | |
Graphic3d_VerticalTextAlignment | myAlignY |
vertical alignment style More... | |
Standard_Integer | myTabSize |
horizontal tabulation width (number of space symbols) More... | |
Standard_ShortReal | myWrappingWidth |
text is wrapped by the width if defined (more 0) More... | |
Standard_ShortReal | myLastSymbolWidth |
width of the last symbol More... | |
Standard_ShortReal | myMaxSymbolWidth |
maximum symbol width of the formatter string More... | |
input data | |
NCollection_String | myString |
currently rendered text More... | |
NCollection_Vec2< Standard_ShortReal > | myPen |
current pen position More... | |
NCollection_Vector< NCollection_Vec2< Standard_ShortReal > > | myCorners |
The bottom left corners of a formatted rectangles. More... | |
NCollection_Vector< Standard_ShortReal > | myNewLines |
position at LF More... | |
Standard_ShortReal | myLineSpacing |
line spacing (computed as maximum of all fonts involved in text formatting) More... | |
Standard_ShortReal | myAscender |
line spacing for the first line More... | |
bool | myIsFormatted |
formatting state More... | |
temporary variables for formatting routines | |
Standard_Integer | myLinesNb |
overall (new)lines number (including splitting by width limit) More... | |
Standard_Integer | myRectLineStart |
id of first rectangle on the current line More... | |
Standard_Integer | myNewLineNb |
overall (new)lines number (including splitting by width limit) More... | |
Standard_ShortReal | myPenCurrLine |
current baseline position More... | |
Standard_ShortReal | myBndTop |
overall (new)lines number (including splitting by width limit) More... | |
Standard_ShortReal | myBndWidth |
overall (new)lines number (including splitting by width limit) More... | |
NCollection_Vec2< Standard_ShortReal > | myMoveVec |
local variable More... | |
This class is intended to prepare formatted text by using:
After text formatting, each symbol of formatted text is placed in some position. Further work with the formatter is using an iterator. The iterator gives an access to each symbol inside the initial row. Also it's possible to get only significant/writable symbols of the text.
Formatter gives an access to geometrical position of a symbol by the symbol index in the text.
Example of correspondence of some text symbol to an index in "row_1\n\nrow_2\n":
"row_1\n" - 0-5 indices;
"\n" - 6 index;
"\n" - 7 index;
"row_2\n" - 8-13 indices.
Pay attention that fonts should have the same LineSpacing value for correct formatting.
Example of the formatter using:
Font_TextFormatter::Font_TextFormatter | ( | ) |
Default constructor.
void Font_TextFormatter::Append | ( | const NCollection_String & | theString, |
Font_FTFont & | theFont | ||
) |
Render specified text to inner buffer.
|
inline |
bounding | box. |
|
inline |
Returns specific glyph rectangle.
|
inline |
Returns internal container of the top left corners of a formatted rectangles.
Standard_ShortReal Font_TextFormatter::FirstPosition | ( | ) | const |
Returns position of the first symbol in a line using alignment.
void Font_TextFormatter::Format | ( | ) |
Perform formatting on the buffered text. Should not be called more than once after initialization!
Standard_Boolean Font_TextFormatter::GlyphBoundingBox | ( | const Standard_Integer | theIndex, |
Font_Rect & | theBndBox | ||
) | const |
Returns symbol bounding box.
bounding | box. |
|
inline |
Returns text maximum width, zero means that the text is not bounded by width.
|
inline |
Returns horizontal alignment style.
|
inlinestatic |
Returns true if the symbol is CR, BEL, FF, NP, BS or VT.
Standard_Boolean Font_TextFormatter::IsLFSymbol | ( | const Standard_Integer | theIndex | ) | const |
Returns true if the symbol by the index is '
'. The width of the symbol is zero.
|
inline |
Returns the line height.
theIndex | a line index, obtained by LineIndex() |
Standard_Integer Font_TextFormatter::LineIndex | ( | const Standard_Integer | theIndex | ) | const |
Returns row index of the corner index among text lines.
Standard_Integer Font_TextFormatter::LinePositionIndex | ( | const Standard_Integer | theIndex | ) | const |
Returns column index of the corner index in the current line.
Standard_ShortReal Font_TextFormatter::LineWidth | ( | const Standard_Integer | theIndex | ) | const |
Returns width of a line.
|
inline |
|
protected |
Move glyphs on the current line to correct position.
|
inline |
Returns container of each line position at LF in formatted text.
void Font_TextFormatter::Reset | ( | ) |
Reset current progress.
|
inline |
|
inline |
void Font_TextFormatter::SetupAlignment | ( | const Graphic3d_HorizontalTextAlignment | theAlignX, |
const Graphic3d_VerticalTextAlignment | theAlignY | ||
) |
Setup alignment style.
|
inline |
Sets text wrapping width, zero means that the text is not bounded by width.
|
inline |
Returns current rendering string.
|
inline |
Returns tab size.
|
inline |
|
inline |
Returns vertical alignment style.
|
inline |
Returns text maximum width, zero means that the text is not bounded by width.
|
protected |
horizontal alignment style
|
protected |
vertical alignment style
|
protected |
line spacing for the first line
|
protected |
overall (new)lines number (including splitting by width limit)
|
protected |
overall (new)lines number (including splitting by width limit)
|
protected |
The bottom left corners of a formatted rectangles.
|
protected |
formatting state
|
protected |
width of the last symbol
|
protected |
overall (new)lines number (including splitting by width limit)
|
protected |
line spacing (computed as maximum of all fonts involved in text formatting)
|
protected |
maximum symbol width of the formatter string
|
protected |
local variable
|
protected |
overall (new)lines number (including splitting by width limit)
|
protected |
position at LF
|
protected |
current pen position
|
protected |
current baseline position
|
protected |
id of first rectangle on the current line
|
protected |
currently rendered text
|
protected |
horizontal tabulation width (number of space symbols)
|
protected |
text is wrapped by the width if defined (more 0)