#include <opennurbs_font.h>

Public Member Functions

 ON_FontGlyph ()=default
 
 ON_FontGlyph (const ON_FontGlyph &src)
 
 ON_FontGlyph (const ON_Font *font, ON__UINT32 code_point)
 
 ~ON_FontGlyph ()=default
 
const ON__UINT32 CodePoint () const
 
bool CodePointIsSet () const
 
void Dump (bool bIncludeCharMaps, ON_TextLog &text_log) const
 
const ON_FontFont () const
 
const ON__UINT_PTR FontGlyphId () const
 
const ON_TextBoxFontUnitGlyphBox () const
 
const ON__UINT_PTR FreeTypeFace () const
 
bool GetGlyphContours (bool bSingleStrokeFont, double text_height, ON_ClassArray< ON_SimpleArray< ON_Curve * > > &glyph_contours, ON_BoundingBox *glyph_bbox, ON_3dVector *glyph_advance) const
 Get glyph contours as NURBS curves. More...
 
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 ON_Font *font, ON__UINT32 code_point)
 Sets the font and code point and unsets every other property including the glyph box and substitute information. More...
 
const ON_FontGlyphSubstituteGlyph () const
 
bool TestFaceCharMaps (ON_TextLog *text_log) const
 This is a debugging tool to test the code that starts with a font and Unicode code point and and finds a glyph in the font definition for that code point. More...
 

Static Public Member Functions

static int CompareCodePointAndFont (ON_FontGlyph &lhs, ON_FontGlyph &rhs)
 
static int GetGlyphList (const wchar_t *text, const 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 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 ON_Font *font, ON_TextBox &text_box)
 
static int GetGlyphListBoundingBox (size_t code_point_count, ON__UINT32 *code_points, const ON_Font *font, ON_TextBox &text_box)
 
static bool GetStringContours (const wchar_t *text_string, const ON_Font *font, bool bSingleStrokeFont, double text_height, 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
 

Constructor & Destructor Documentation

◆ ON_FontGlyph() [1/3]

ON_FontGlyph::ON_FontGlyph ( )
default

◆ ~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 ON_Font font,
ON__UINT32  code_point 
)

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 ( ON_FontGlyph lhs,
ON_FontGlyph rhs 
)
static

◆ Dump()

void ON_FontGlyph::Dump ( bool  bIncludeCharMaps,
ON_TextLog text_log 
) const
Parameters
bIncludeCharMaps[in] If true, then char information is printed.

◆ Font()

const ON_Font* ON_FontGlyph::Font ( ) const

◆ FontGlyphId()

const ON__UINT_PTR ON_FontGlyph::FontGlyphId ( ) const
Returns
Font glyph id.

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.

◆ FontUnitGlyphBox()

const ON_TextBox& ON_FontGlyph::FontUnitGlyphBox ( ) const
Returns
Font unit glyph box.

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().

◆ FreeTypeFace()

const ON__UINT_PTR ON_FontGlyph::FreeTypeFace ( ) const

◆ GetGlyphContours()

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

Get glyph contours as NURBS curves.

Parameters
bSingleStrokeFont[in] If true, open contours will not be closed by adding a line segment.
text_height[in] If > 0, ouptut curves, bounding box, and advance vector are scaled so that a capital latin letter I would have a height of text_height. 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. Pass ON_UNSET_VALUE to get the contours to be in native font definition units. 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 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.

Parameters
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 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 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 ON_Font font,
ON_TextBox text_box 
)
static

◆ GetStringContours()

static bool ON_FontGlyph::GetStringContours ( const wchar_t *  text_string,
const ON_Font font,
bool  bSingleStrokeFont,
double  text_height,
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 ON_Font font,
ON__UINT32  code_point 
)

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 substitue is returned. In all other cases, nullptr is returned.
See also
ON_FontGlyph.RenderGlyph().

◆ TestFaceCharMaps()

bool ON_FontGlyph::TestFaceCharMaps ( ON_TextLog text_log) const

This is a debugging tool to test the code that starts with a font and Unicode code point and and finds a glyph in the font definition for that code point.

Parameters
text_log[in] If text_log is not nullptr, then diagnostic messages are sent to this log.
Returns
True: No errors were found. Every available charmap either returned the same glyph id that FontGlyphId() function returns or had no glyph id for this code point. False: Inconsistent results were returned from different charmaps.

If a font or charmap is known to contain a bug and that bug is handled by opennurbs, then true is returned and a message is printed to the log.

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