Rhino C++ API  7.24
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
ON_TextRun Class Reference

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__UINT32UnicodeString () 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 ()
 
static ON_TextRunGetManagedTextRun (const ON_TextRun &src)
 
static bool ReturnManagedTextRun (ON_TextRun *managed_text_run)
 
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
 (ECS) distance and direction from m_offset to start of next run More...
 
ON_Color m_color = ON_Color::UnsetColor
 
double m_height_scale = -1.0
 Font HeightOfI / text height - Converts from font units to model units or page units. More...
 
double m_indent = 0.0
 These apply to Paragraph type runs (m_type == rtParagraph) More...
 
double m_left_margin = 0.0
 left margin in formatting rect for this paragraph More...
 
int m_line_index = -1
 line position in ON_TextContent More...
 
const ON_Fontm_managed_font = nullptr
 
ON_2dVector m_offset = ON_2dVector::ZeroVector
 (ECS) offset to lower left of bounding box from ON_TextContent plane origin More...
 
double m_right_margin = 0.0
 right margin in formatting rect for this paragraph More...
 
ON_StackedTextm_stacked_text = nullptr
 pointers to runs for the top and bottom parts More...
 
double m_stackscale = 0.7
 fraction for scaling textheight in stacked text More...
 

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

bool Write( ON_BinaryArchive& ) const; bool Read( ON_BinaryArchive& );

◆ 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

Description: 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

Description: 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

This returns the scale of m_height / HeightOfI. It doesn't take into account anything about annotation scaling This is the scale for converting ON_TextRun bounding boxes and offsets to basic model units

◆ 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

Description: 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

Set or get the WCS model unit height of the text not including any annotatition scaling

◆ 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

Returns the string in m_text_string, which is a wchar_t version of the basic text for this run, and may contain unevaluated field formulae

◆ 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

(ECS) distance and direction from m_offset to start of next run

◆ m_color

ON_Color ON_TextRun::m_color = ON_Color::UnsetColor

◆ m_height_scale

double ON_TextRun::m_height_scale = -1.0

Font HeightOfI / text height - Converts from font units to model units or page units.

◆ m_indent

double ON_TextRun::m_indent = 0.0

These apply to Paragraph type runs (m_type == rtParagraph)

indent and margins are in model units or page units First line indentation for this paragraph

◆ m_left_margin

double ON_TextRun::m_left_margin = 0.0

left margin in formatting rect for this paragraph

◆ m_line_index

int ON_TextRun::m_line_index = -1

line position in ON_TextContent

◆ m_managed_font

const ON_Font* ON_TextRun::m_managed_font = nullptr

Font used to draw, pick, or otherwise evaluate this ON_TextRun. This pointer is run-time only and must be set and point to a valid ON_Font for any font related operations to work.

◆ m_offset

ON_2dVector ON_TextRun::m_offset = ON_2dVector::ZeroVector

(ECS) offset to lower left of bounding box from ON_TextContent plane origin

◆ m_right_margin

double ON_TextRun::m_right_margin = 0.0

right margin in formatting rect for this paragraph

◆ m_stacked_text

ON_StackedText* ON_TextRun::m_stacked_text = nullptr

pointers to runs for the top and bottom parts

◆ m_stackscale

double ON_TextRun::m_stackscale = 0.7

fraction for scaling textheight in stacked text