Rhino C++ API  8.6
Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
ON_FontGlyph Class Reference

#include <opennurbs_font.h>

Public Member Functions

 ON_FontGlyph ()=default
 
 ON_FontGlyph (const class ON_Font *font, ON__UINT32 code_point)
 
 ON_FontGlyph (const ON_FontGlyph &src)
 
 ~ON_FontGlyph ()=default
 
const ON__UINT32 CodePoint () const
 
bool CodePointIsSet () const
 
void Dump (bool bIncludeCharMaps, ON_TextLog &text_log) const
 
void Dump (bool bIncludeFont, bool bIncludeCharMaps, bool bIncludeSubstitute, bool bIncludeFontUnitTextBox, ON_TextLog &text_log) const
 
const class ON_FontFont () const
 
const ON__UINT_PTR FontGlyphId () const
 
bool FontGlyphIdIsSet () const
 
unsigned int FontGlyphIndex () const
 
bool FontGlyphIndexIsSet () const
 
const ON_TextBoxFontUnitGlyphBox () const
 
bool GetGlyphContours (bool bSingleStrokeFont, double height_of_capital, ON_ClassArray< ON_SimpleArray< ON_Curve * > > &glyph_contours, ON_BoundingBox *glyph_bbox, ON_3dVector *glyph_advance) const
 
bool GetOutline (bool bSingleStrokeFont, class ON_Outline &outline) const
 
const ON_TextBoxGlyphBox () const
 
bool IsEndOfLineCodePoint () const
 
bool IsManaged () const
 
const ON_FontGlyphManagedGlyph () const
 
ON_FontGlyphoperator= (const ON_FontGlyph &src)
 
const ON_FontGlyphRenderGlyph (bool bUseReplacementCharacter) const
 
bool SetCodePoint (const class ON_Font *font, ON__UINT32 code_point)
 
const ON_FontGlyphSubstituteGlyph () const
 

Static Public Member Functions

static int CompareCodePointAndFont (const ON_FontGlyph &lhs, const ON_FontGlyph &rhs)
 
static int GetGlyphList (const wchar_t *text, const class ON_Font *font, ON__UINT32 unicode_CRLF_code_point, ON_SimpleArray< const ON_FontGlyph * > &glyph_list, ON_TextBox &text_box)
 
static int GetGlyphList (size_t code_point_count, ON__UINT32 *code_points, const class ON_Font *font, ON__UINT32 unicode_CRLF_code_point, ON_SimpleArray< const ON_FontGlyph * > &glyph_list, ON_TextBox &text_box)
 
static int GetGlyphListBoundingBox (const wchar_t *text, const class ON_Font *font, ON_TextBox &text_box)
 
static int GetGlyphListBoundingBox (size_t code_point_count, ON__UINT32 *code_points, const class ON_Font *font, ON_TextBox &text_box)
 
static bool GetStringContours (const wchar_t *text_string, const class ON_Font *font, bool bSingleStrokeFont, double height_of_capital, double small_caps_scale, ON_ClassArray< ON_ClassArray< ON_SimpleArray< ON_Curve * > > > &string_contours)
 
static bool IsCarriageReturnAndLineFeed (ON__UINT32 unicode_code_point, ON__UINT32 next_unicode_code_point)
 
static bool IsEndOfLineCodePoint (ON__UINT32 unicode_code_point)
 

Static Public Attributes

static const ON_FontGlyph Unset
 

Friends

class ON_Font
 
class ON_GlyphMap
 

Detailed Description

The best way to get a useful ON_FontGlyph is to call ON_Font.CodePointGlyph(unicode_code_point)

Constructor & Destructor Documentation

◆ ON_FontGlyph() [1/3]

ON_FontGlyph::ON_FontGlyph ( )
default

The best way to get a useful ON_FontGlyph is to call ON_Font.CodePointGlyph(unicode_code_point)

◆ ~ON_FontGlyph()

ON_FontGlyph::~ON_FontGlyph ( )
default

◆ ON_FontGlyph() [2/3]

ON_FontGlyph::ON_FontGlyph ( const ON_FontGlyph src)

◆ ON_FontGlyph() [3/3]

ON_FontGlyph::ON_FontGlyph ( const class ON_Font font,
ON__UINT32  code_point 
)

If the font and code point are valid, constructs an unmanaged glyph with the specified font and code point. The glyph box is not set.

Member Function Documentation

◆ CodePoint()

const ON__UINT32 ON_FontGlyph::CodePoint ( ) const

◆ CodePointIsSet()

bool ON_FontGlyph::CodePointIsSet ( ) const

Returns: True if the unicode code point and font are set

◆ CompareCodePointAndFont()

static int ON_FontGlyph::CompareCodePointAndFont ( const ON_FontGlyph lhs,
const ON_FontGlyph rhs 
)
static

◆ Dump() [1/2]

void ON_FontGlyph::Dump ( bool  bIncludeCharMaps,
ON_TextLog text_log 
) const

Parameters: bIncludeCharMaps - [in] If true, then char information is printed.

◆ Dump() [2/2]

void ON_FontGlyph::Dump ( bool  bIncludeFont,
bool  bIncludeCharMaps,
bool  bIncludeSubstitute,
bool  bIncludeFontUnitTextBox,
ON_TextLog text_log 
) const

◆ Font()

const class ON_Font* ON_FontGlyph::Font ( ) const

◆ FontGlyphId()

const ON__UINT_PTR ON_FontGlyph::FontGlyphId ( ) const

◆ FontGlyphIdIsSet()

bool ON_FontGlyph::FontGlyphIdIsSet ( ) const

◆ FontGlyphIndex()

unsigned int ON_FontGlyph::FontGlyphIndex ( ) const

Returns: Font glyph id. Remarks: The glyph id depends on the font and is assigned by the font designer. In particular the font glyph id for the same Unicode code point often varies from font to font. In a font, it is often the case that multiple Unicode code points map to the same glyph. For example, space an non-breaking space typically map to the same font glyph id.

◆ FontGlyphIndexIsSet()

bool ON_FontGlyph::FontGlyphIndexIsSet ( ) const

◆ FontUnitGlyphBox()

const ON_TextBox& ON_FontGlyph::FontUnitGlyphBox ( ) const

Returns: Font unit glyph box. Remarks: Must be used with ON_Font::FontUnitFontMetrics() and a single font to obtain useful results. You are probably better of using normalized font coordinates in a ON_FontGlyph.GlyphBox().

◆ GetGlyphContours()

bool ON_FontGlyph::GetGlyphContours ( bool  bSingleStrokeFont,
double  height_of_capital,
ON_ClassArray< ON_SimpleArray< ON_Curve * > > &  glyph_contours,
ON_BoundingBox glyph_bbox,
ON_3dVector glyph_advance 
) const

Description: Get glyph contours as NURBS curves. Parameters: bSingleStrokeFont - [in] If true, open contours will not be closed by adding a line segment. height_of_capital - [in] If > 0, output curves, bounding box, and advance vector are scaled by height_of_capital/(font design capital height). For fonts like Arial, Helvetica, Times Roman, and Courier this means the height of H and I will be height_of_capital. Otherwise, no scaling is applied to the output curves, bounding box, and advance vector. Pass 0.0 or in this->Font()->HeightOfI() to get the contours to be in opennurbs normalized font coordinates. All other values < 0 are treated as 0.0. glyph_contours - [out] glyph_bbox - [out] glyph bounding box. glyph_advance - [out] glyph_advance->x = horizontal advance to apply when rendering glyphs horizontally. A positive horizontal advance indicates advance to the right. glyph_advance->y = vertical advance to apply when rendering glyphs vertically. A positive vertical advance indicates advance downwards.

◆ GetGlyphList() [1/2]

static int ON_FontGlyph::GetGlyphList ( const wchar_t *  text,
const class ON_Font font,
ON__UINT32  unicode_CRLF_code_point,
ON_SimpleArray< const ON_FontGlyph * > &  glyph_list,
ON_TextBox text_box 
)
static

Parameters: text - [in] Null terminated wchar_t string. font - [in] The font used to render the glyphs. unicode_CRLF_code_point - [in] If unicode_CRLF_code_point is a valid unicode code point, then consecutive carriage return line feed pairs are converted to a single glyph with code point = unicode_CRLF_code_point.

ON_UnicodeCodePoint::ON_LineSeparator is a good choice when you want to
condense carriage return line feed pairs to a single unambiguous code point.

ON_UnicodeCodePoint::ON_InvalidCodePoint is a good choice when you want to preserve carriage return line feed pairs as two separate glyphs.

glyph_list - [out] Note that glyph_list.Count() is often different than the length of the text string or the number of unicode codepoints in the decoded text. Adjacent carriage return and line feed codepoints are converted to single a hard end of line. All trailing end of line code points are removed from text. Invalid unicode encoding sequences are replaced with ON_UnicodeCodePoint::ReplacementCharacter glyphs.

text_box - [out] tight bounding boxt of text extents. text_box.m_advance.i = maximum of all line horizontal advance values.. text_box.m_advance.j = vertical advance to baseline of last line If if the font height is ON_Font::Constants::AnnotationFontCellHeight. If you will render the font at a different height from ON_Font::Constants::AnnotationFontCellHeight, then use ON_TextBox::Scale as follows: ON_TextBox scaled_box = ON_TextBox::Scale( text_box, (font render height)/((double)ON_Font::Constants::AnnotationFontCellHeight) ); Return: number of lines of text or 0 if input is not valid or text is empty.

◆ GetGlyphList() [2/2]

static int ON_FontGlyph::GetGlyphList ( size_t  code_point_count,
ON__UINT32 code_points,
const class ON_Font font,
ON__UINT32  unicode_CRLF_code_point,
ON_SimpleArray< const ON_FontGlyph * > &  glyph_list,
ON_TextBox text_box 
)
static

◆ GetGlyphListBoundingBox() [1/2]

static int ON_FontGlyph::GetGlyphListBoundingBox ( const wchar_t *  text,
const class ON_Font font,
ON_TextBox text_box 
)
static

Parameters: font - [in] The font used to render the glyphs. text_box - [out] tight bounding boxt of text extents. text_box.m_advance.i = maximum of all line horizontal advance values.. text_box.m_advance.j = vertical advance to baseline of last line If if the font height is ON_Font::Constants::AnnotationFontCellHeight. If you will render the font at a different height from ON_Font::Constants::AnnotationFontCellHeight, then use ON_TextBox::Scale as follows: ON_TextBox scaled_box = ON_TextBox::Scale( text_box, (font render height)/((double)ON_Font::Constants::AnnotationFontCellHeight) ); Return: number of lines of text or 0 if input is not valid or text is empty.

◆ GetGlyphListBoundingBox() [2/2]

static int ON_FontGlyph::GetGlyphListBoundingBox ( size_t  code_point_count,
ON__UINT32 code_points,
const class ON_Font font,
ON_TextBox text_box 
)
static

◆ GetOutline()

bool ON_FontGlyph::GetOutline ( bool  bSingleStrokeFont,
class ON_Outline outline 
) const

◆ GetStringContours()

static bool ON_FontGlyph::GetStringContours ( const wchar_t *  text_string,
const class ON_Font font,
bool  bSingleStrokeFont,
double  height_of_capital,
double  small_caps_scale,
ON_ClassArray< ON_ClassArray< ON_SimpleArray< ON_Curve * > > > &  string_contours 
)
static

◆ GlyphBox()

const ON_TextBox& ON_FontGlyph::GlyphBox ( ) const

Returns: Glyph box in opennurbs normalized font coordinates.

◆ IsCarriageReturnAndLineFeed()

static bool ON_FontGlyph::IsCarriageReturnAndLineFeed ( ON__UINT32  unicode_code_point,
ON__UINT32  next_unicode_code_point 
)
static

◆ IsEndOfLineCodePoint() [1/2]

bool ON_FontGlyph::IsEndOfLineCodePoint ( ) const

◆ IsEndOfLineCodePoint() [2/2]

static bool ON_FontGlyph::IsEndOfLineCodePoint ( ON__UINT32  unicode_code_point)
static

◆ IsManaged()

bool ON_FontGlyph::IsManaged ( ) const

Returns: true if this is a managed instance. Managed instances persist for the lifetime of the application and the pointer can be safely saved and referenced at any time.

◆ ManagedGlyph()

const ON_FontGlyph* ON_FontGlyph::ManagedGlyph ( ) const

Returns: If this->CodePointIsSet() is true, then a persistent pointer to a managed glyph with the same code point and font is returned. Otherwise nullptr is returned.

◆ operator=()

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

◆ RenderGlyph()

const ON_FontGlyph* ON_FontGlyph::RenderGlyph ( bool  bUseReplacementCharacter) const

Parameters: bUseReplacementCharacter - [in] When this->CodePointIsSet() is true, and bUseReplacementCharacter is true, and no reasonable glyph definition exists, and no substitued is available, then the replacement character glyph for UNICODE code point ON_UnicodeCodePoint::ON_ReplacementCharacter (U+FFFD) will be returned.

Returns: A managed glyph that can be used to render "this". If this->CodePointIsSet() is false, nullptr is returned. If this->CodePointIsSet() is true, the returned glyph may have a different font and code point when the current computer requires font or glyph substitution to draw the glyph. When the current platform cannot render this, nullptr or the replacement glyph is returned depending on the value of bUseReplacementCharacter.

See Also: ON_FontGlyph.SubstituteGlyph().

◆ SetCodePoint()

bool ON_FontGlyph::SetCodePoint ( const class ON_Font font,
ON__UINT32  code_point 
)

Description: Sets the font and code point and unsets every other property including the glyph box and substitute information. Parameters: font - [in] code_point - [in]

◆ SubstituteGlyph()

const ON_FontGlyph* ON_FontGlyph::SubstituteGlyph ( ) const

Returns: If this is a managed glyph or a copy of a managed glyph, and a substitute font or code point is used to render the glyph, then the substitute is returned. In all other cases, nullptr is returned. See Also: ON_FontGlyph.RenderGlyph().

Friends And Related Function Documentation

◆ ON_Font

friend class ON_Font
friend

◆ ON_GlyphMap

friend class ON_GlyphMap
friend

Member Data Documentation

◆ Unset

const ON_FontGlyph ON_FontGlyph::Unset
static