A range of text with all the same attributes. More...

#include <opennurbs_textrun.h>

Public Types

enum  RunDirection : unsigned char { RunDirection::kLtR = 0, RunDirection::kRtL = 1 }
 
enum  RunType : unsigned char {
  RunType::kNone = 0, RunType::kText = 1, RunType::kNewline = 2, RunType::kSoftreturn = 3,
  RunType::kParagraph = 4, RunType::kColumn = 5, RunType::kField = 6, RunType::kFieldValue = 7,
  RunType::kFontdef = 8, RunType::kHeader = 9, RunType::kFonttbl = 10, RunType::kColortbl = 11
}
 
enum  Stacked : unsigned char { Stacked::kNone = 0, Stacked::kStacked = 1, Stacked::kTop = 2, Stacked::kBottom = 3 }
 

Public Member Functions

 ON_TextRun ()=default
 
 ON_TextRun (const ON_TextRun &src)
 
 ~ON_TextRun ()
 
const ON_2dVectorAdvance () const
 
const ON_BoundingBoxBoundingBox () const
 bbox is stored as ON_BoundingBox, but is always 2d. z=0 More...
 
ON_Color Color () const
 
const wchar_t * DisplayString () const
 The display string is the TextString() with formulae evaluated. More...
 
RunDirection FlowDirection () const
 
const ON_FontFont () const
 
void Get2dCorners (ON_2dPoint corners[4]) const
 
bool GetGlyphContours (const ON_Font *text_font, bool bSingleStrokeFont, const ON_Xform &text_xform, ON_ClassArray< ON_ClassArray< ON_SimpleArray< ON_Curve * > > > &run_contours) const
 
double HeightScale (const ON_Font *font) const
 
void Init (const class ON_Font *managed_font, double height, double stackscale, ON_Color color, bool bold, bool italic, bool underlined, bool strikethrough, bool deletedisplay=true)
 
bool IsActiveManagedTextRun () const
 
bool IsColumn () const
 
bool IsManagedTextRun () const
 
bool IsNewline () const
 
Stacked IsStacked () const
 
bool IsText () const
 
bool IsValid () const
 
const ON_2dVectorOffset () const
 
ON_TextRunoperator= (const ON_TextRun &src)
 
void SetAdvance (ON_2dVector advance)
 
void SetBoundingBox (ON_2dPoint pmin, ON_2dPoint pmax)
 
void SetColor (ON_Color color)
 
void SetDisplayString (const wchar_t *str)
 Returns string in m_display_string, which may be the result of parsing text fields. More...
 
void SetFont (const ON_Font *font)
 
void SetOffset (ON_2dVector offset)
 
void SetStacked (Stacked stacked)
 
void SetStackedOff ()
 
void SetStackFractionHeight (double stackscale)
 
void SetTextHeight (double h)
 
void SetType (ON_TextRun::RunType)
 
void SetUnicodeString (size_t count, const ON__UINT32 *cp)
 
double StackHeightFraction () const
 
double TextHeight () const
 
ON_SHA1_Hash TextRunContentHash () const
 
ON_SHA1_Hash TextRunContentHash (bool bEvaluateFields) const
 
const wchar_t * TextString () const
 
RunType Type () const
 
const ON__UINT32 * UnicodeString () const
 
int WrapTextRun (int call_count, int start_char_offset, double width, double &y_offset, double &currentwidth, class ON_TextRunArray &newruns) const
 Wrap text to a specified width in model space. More...
 

Static Public Member Functions

static size_t CodepointCount (const ON__UINT32 *cp)
 
static double DefaultStackFractionHeight ()
 
static ON_TextRunGetManagedTextRun ()
 ON_TextRun::NewTextRun() gets a text run from an efficiently managed pool. More...
 
static ON_TextRunGetManagedTextRun (const ON_TextRun &src)
 ON_TextRun::NewTextRun() gets a text run from an efficiently managed pool and copies src More...
 
static bool ReturnManagedTextRun (ON_TextRun *managed_text_run)
 Return a managed ON_TextRun. More...
 
static ON_TextRun::RunDirection RunDirectionFromUnsigned (unsigned int run_direction_as_unsigned)
 
static ON_TextRun::RunType RunTypeFromUnsigned (unsigned int run_type_as_unsigned)
 
static ON_TextRun::Stacked StackedFromUnsigned (unsigned int stacked_as_unsigned)
 

Public Attributes

ON_2dVector m_advance = ON_2dVector::ZeroVector
 
ON_Color m_color = ON_Color::UnsetColor
 
double m_height_scale = -1.0
 
double m_indent = 0.0
 
double m_left_margin = 0.0
 
int m_line_index = -1
 
const ON_Fontm_managed_font = nullptr
 
ON_2dVector m_offset = ON_2dVector::ZeroVector
 
double m_right_margin = 0.0
 
ON_StackedTextm_stacked_text = nullptr
 
double m_stackscale = 0.7
 

Static Public Attributes

static const ON_TextRun Empty
 

Friends

class ON_StackedText
 
class ON_TextBuilder
 

Detailed Description

A range of text with all the same attributes.

Member Enumeration Documentation

◆ RunDirection

enum ON_TextRun::RunDirection : unsigned char
strong
Enumerator
kLtR 
kRtL 

◆ RunType

enum ON_TextRun::RunType : unsigned char
strong
Enumerator
kNone 
kText 
kNewline 
kSoftreturn 
kParagraph 
kColumn 
kField 
kFieldValue 
kFontdef 
kHeader 
kFonttbl 
kColortbl 

◆ Stacked

enum ON_TextRun::Stacked : unsigned char
strong
Enumerator
kNone 
kStacked 
kTop 
kBottom 

Constructor & Destructor Documentation

◆ ON_TextRun() [1/2]

ON_TextRun::ON_TextRun ( )
default

◆ ~ON_TextRun()

ON_TextRun::~ON_TextRun ( )

◆ ON_TextRun() [2/2]

ON_TextRun::ON_TextRun ( const ON_TextRun src)

Member Function Documentation

◆ Advance()

const ON_2dVector& ON_TextRun::Advance ( ) const

◆ BoundingBox()

const ON_BoundingBox& ON_TextRun::BoundingBox ( ) const

bbox is stored as ON_BoundingBox, but is always 2d. z=0

◆ CodepointCount()

static size_t ON_TextRun::CodepointCount ( const ON__UINT32 *  cp)
static

◆ Color()

ON_Color ON_TextRun::Color ( ) const

◆ DefaultStackFractionHeight()

static double ON_TextRun::DefaultStackFractionHeight ( )
static

◆ DisplayString()

const wchar_t* ON_TextRun::DisplayString ( ) const

The display string is the TextString() with formulae evaluated.

◆ FlowDirection()

RunDirection ON_TextRun::FlowDirection ( ) const

◆ Font()

const ON_Font* ON_TextRun::Font ( ) const

◆ Get2dCorners()

void ON_TextRun::Get2dCorners ( ON_2dPoint  corners[4]) const

◆ GetGlyphContours()

bool ON_TextRun::GetGlyphContours ( const ON_Font text_font,
bool  bSingleStrokeFont,
const ON_Xform text_xform,
ON_ClassArray< ON_ClassArray< ON_SimpleArray< ON_Curve * > > > &  run_contours 
) const

◆ GetManagedTextRun() [1/2]

static ON_TextRun* ON_TextRun::GetManagedTextRun ( )
static

ON_TextRun::NewTextRun() gets a text run from an efficiently managed pool.

Returns
A pointer to a text run. (never nullptr).

◆ GetManagedTextRun() [2/2]

static ON_TextRun* ON_TextRun::GetManagedTextRun ( const ON_TextRun src)
static

ON_TextRun::NewTextRun() gets a text run from an efficiently managed pool and copies src

Returns
A pointer to a text run. (never nullptr).

◆ HeightScale()

double ON_TextRun::HeightScale ( const ON_Font font) const

◆ Init()

void ON_TextRun::Init ( const class ON_Font managed_font,
double  height,
double  stackscale,
ON_Color  color,
bool  bold,
bool  italic,
bool  underlined,
bool  strikethrough,
bool  deletedisplay = true 
)

◆ IsActiveManagedTextRun()

bool ON_TextRun::IsActiveManagedTextRun ( ) const
Returns
True if the memory for this ON_TextRun is managed and the text run is active. It was created by calling ON_TextRun::GetManagedTextRun() and should be deleted by calling ON_TextRun::ReturnManagedTextRun();

◆ IsColumn()

bool ON_TextRun::IsColumn ( ) const

◆ IsManagedTextRun()

bool ON_TextRun::IsManagedTextRun ( ) const
Returns
True if the memory for this ON_TextRun is managed. It was created by calling ON_TextRun::GetManagedTextRun(). If it is active, then is must be deleted by calling ON_TextRun::ReturnManagedTextRun();

◆ IsNewline()

bool ON_TextRun::IsNewline ( ) const

◆ IsStacked()

Stacked ON_TextRun::IsStacked ( ) const

◆ IsText()

bool ON_TextRun::IsText ( ) const

◆ IsValid()

bool ON_TextRun::IsValid ( ) const

◆ Offset()

const ON_2dVector& ON_TextRun::Offset ( ) const

◆ operator=()

ON_TextRun& ON_TextRun::operator= ( const ON_TextRun src)

◆ ReturnManagedTextRun()

static bool ON_TextRun::ReturnManagedTextRun ( ON_TextRun managed_text_run)
static

Return a managed ON_TextRun.

◆ RunDirectionFromUnsigned()

static ON_TextRun::RunDirection ON_TextRun::RunDirectionFromUnsigned ( unsigned int  run_direction_as_unsigned)
static

◆ RunTypeFromUnsigned()

static ON_TextRun::RunType ON_TextRun::RunTypeFromUnsigned ( unsigned int  run_type_as_unsigned)
static

◆ SetAdvance()

void ON_TextRun::SetAdvance ( ON_2dVector  advance)

◆ SetBoundingBox()

void ON_TextRun::SetBoundingBox ( ON_2dPoint  pmin,
ON_2dPoint  pmax 
)

◆ SetColor()

void ON_TextRun::SetColor ( ON_Color  color)

◆ SetDisplayString()

void ON_TextRun::SetDisplayString ( const wchar_t *  str)

Returns string in m_display_string, which may be the result of parsing text fields.

◆ SetFont()

void ON_TextRun::SetFont ( const ON_Font font)

◆ SetOffset()

void ON_TextRun::SetOffset ( ON_2dVector  offset)

◆ SetStacked()

void ON_TextRun::SetStacked ( Stacked  stacked)

◆ SetStackedOff()

void ON_TextRun::SetStackedOff ( )

◆ SetStackFractionHeight()

void ON_TextRun::SetStackFractionHeight ( double  stackscale)

◆ SetTextHeight()

void ON_TextRun::SetTextHeight ( double  h)

◆ SetType()

void ON_TextRun::SetType ( ON_TextRun::RunType  )

◆ SetUnicodeString()

void ON_TextRun::SetUnicodeString ( size_t  count,
const ON__UINT32 *  cp 
)

◆ StackedFromUnsigned()

static ON_TextRun::Stacked ON_TextRun::StackedFromUnsigned ( unsigned int  stacked_as_unsigned)
static

◆ StackHeightFraction()

double ON_TextRun::StackHeightFraction ( ) const

◆ TextHeight()

double ON_TextRun::TextHeight ( ) const

◆ TextRunContentHash() [1/2]

ON_SHA1_Hash ON_TextRun::TextRunContentHash ( ) const

◆ TextRunContentHash() [2/2]

ON_SHA1_Hash ON_TextRun::TextRunContentHash ( bool  bEvaluateFields) const

◆ TextString()

const wchar_t* ON_TextRun::TextString ( ) const

◆ Type()

RunType ON_TextRun::Type ( ) const

◆ UnicodeString()

const ON__UINT32* ON_TextRun::UnicodeString ( ) const

◆ WrapTextRun()

int ON_TextRun::WrapTextRun ( int  call_count,
int  start_char_offset,
double  width,
double &  y_offset,
double &  currentwidth,
class ON_TextRunArray newruns 
) const

Wrap text to a specified width in model space.

Friends And Related Function Documentation

◆ ON_StackedText

friend class ON_StackedText
friend

◆ ON_TextBuilder

friend class ON_TextBuilder
friend

Member Data Documentation

◆ Empty

const ON_TextRun ON_TextRun::Empty
static

◆ m_advance

ON_2dVector ON_TextRun::m_advance = ON_2dVector::ZeroVector

◆ m_color

ON_Color ON_TextRun::m_color = ON_Color::UnsetColor

◆ m_height_scale

double ON_TextRun::m_height_scale = -1.0

◆ m_indent

double ON_TextRun::m_indent = 0.0

◆ m_left_margin

double ON_TextRun::m_left_margin = 0.0

◆ m_line_index

int ON_TextRun::m_line_index = -1

◆ m_managed_font

const ON_Font* ON_TextRun::m_managed_font = nullptr

◆ m_offset

ON_2dVector ON_TextRun::m_offset = ON_2dVector::ZeroVector

◆ m_right_margin

double ON_TextRun::m_right_margin = 0.0

◆ m_stacked_text

ON_StackedText* ON_TextRun::m_stacked_text = nullptr

◆ m_stackscale

double ON_TextRun::m_stackscale = 0.7