openNURBS SDK Help  6.0
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
ON_Font Class Reference

An ON_Font is a face in a font family. It corresponds to a Windows LOGFONT, a .NET System.Drawing.Font or a FreeType FT_Face. More...

#include <opennurbs_font.h>

Public Types

enum  Constants : int { AnnotationFontCellHeight = 256, MetricsGlyphCodePoint = 'I' }
 miscellaneous constants use to initialize Windows LOGFONT fields More...
 
typedef void(* ON_GetFontMetricsFuncType) (const ON_Font *font, ON_FontMetrics &font_unit_font_metrics)
 
typedef ON__UINT_PTR(* ON_GetGlyphMetricsFuncType) (const class ON_Font *font, ON__UINT32 unicode_code_point, class ON_TextBox &font_unit_glyph_box)
 
enum  Stretch : unsigned char {
  Stretch::Unset = 0, Stretch::Ultracondensed = 1, Stretch::Extracondensed = 2, Stretch::Condensed = 3,
  Stretch::Semicondensed = 4, Stretch::Medium = 5, Stretch::Semiexpanded = 6, Stretch::Expanded = 7,
  Stretch::Extraexpanded = 8, Stretch::Ultraexpanded = 9
}
 Horizontal expansion or contraction of font More...
 
enum  Style : unsigned char { Style::Unset = 0, Style::Upright = 1, Style::Italic = 2, Style::Oblique = 3 }
 Vertical angle of font Upright, Italic, or Oblique More...
 
enum  Weight : unsigned char {
  Weight::Unset = 0, Weight::Thin = 1, Weight::Ultralight = 2, Weight::Light = 3,
  Weight::Normal = 4, Weight::Medium = 5, Weight::Semibold = 6, Weight::Bold = 7,
  Weight::Ultrabold = 8, Weight::Heavy = 9
}
 Weight enum values Avoid casting these values to int. Use ON_Font::WindowsLogfontWeightFromWeight() or ON_Font::AppleWeightOfFontFromWeight() or add another converter. More...
 
enum  WindowsConstants : unsigned char {
  logfont_ansi_charset = 0, logfont_default_charset = 1, logfont_symbol_charset = 2, logfont_out_precis = 7,
  logfont_quality = 4, logfont_pitch_and_family = 0
}
 

Public Member Functions

 ON_Font ()
 
 ON_Font (const ON_Font &src)
 
 ~ON_Font ()=default
 
const ON_wStringAppleFontName () const
 
const wchar_t * AppleFontNameAsPointer () const
 
double AppleFontWeightTrait () const
 
int AppleWeightOfFont () const
 
const class ON_FontGlyphCodePointGlyph (ON__UINT32 unicode_code_point) const
 
ON__UINT32 CRC32 (bool bIgnoreFaceNameOrdinalCase) const
 
void Dump (ON_TextLog &) const
 for debugging More...
 
void DumpFreeType (ON_TextLog &text_log) const
 
unsigned int FontCharacteristicsAsUnsigned () const
 
const class ON_SHA1_HashFontCharacteristicsHash () const
 
const ON_wStringFontDescription () const
 
const wchar_t * FontDescriptionAsPointer () const
 
const wchar_t * FontFaceName () const
 
const ON_FontMetricsFontMetrics () const
 
ON_Font::Stretch FontStretch () const
 
ON_Font::Style FontStyle () const
 
const ON_FontMetricsFontUnitFontMetrics () const
 
double FontUnitToNormalizedScale () const
 
ON_Font::Weight FontWeight () const
 
bool IsBold () const
 
bool IsItalic () const
 
bool IsLight () const
 
bool IsManagedFont () const
 
bool IsNormalWeight () const
 
bool IsOblique ()
 
bool IsStrikethrough () const
 
bool IsUnderlined () const
 
bool IsUpright () const
 
bool IsValid (ON_TextLog *text_log=nullptr) const
 
double LinefeedRatio () const
 
unsigned char LogfontCharSet () const
 
const ON_FontManagedFont () const
 
unsigned int ManagedFontSerialNumber () const
 
double NormalizedToFontUnitScale () const
 
 ON_DEPRECATED_MSG ("Use FontMetrics().AscentOfI()") int HeightOfI() const
 
 ON_DEPRECATED_MSG ("Use FontMetrics().LineSpace()") int HeightOfLinefeed() const
 
 ON_DEPRECATED_MSG ("Use FontMetrics().GlyphScale()") double HeightScale(double text_height) const
 
 ON_DEPRECATED_MSG ("Use FontMetrics().StrikeoutThickness()") int GetStrikeoutSize() const
 
 ON_DEPRECATED_MSG ("Use FontMetrics().StrikeoutPosition()") int GetStrikeoutPosition() const
 
 ON_DEPRECATED_MSG ("Use FontMetrics().UnderscoreThickness()") int GetUnderscoreSize() const
 
 ON_DEPRECATED_MSG ("Use FontMetrics().UnderscorePosition()") int GetUnderscorePosition() const
 
ON_Fontoperator= (const ON_Font &src)
 
double PointSize () const
 
bool Read (ON_BinaryArchive &)
 restore definition from binary archive More...
 
bool ReadV5 (ON_BinaryArchive &, int *V5_font_index, ON_UUID *V5_font_id)
 V6 separated the V5 ON_Font into ON_TextStyle and ON_Font. More...
 
unsigned int RuntimeSerialNumber () const
 
bool SetAppleFontWeightTrait (double apple_font_weight_trait)
 
bool SetAppleWeightOfFont (int apple_weight_of_font)
 
bool SetFontCharacteristics (const wchar_t *face_name, bool bBold, bool bItalic, bool bUnderlined, bool bStrikethrough)
 
bool SetFontCharacteristics (double point_size, const wchar_t *face_name, bool bBold, bool bItalic, bool bUnderlined, bool bStrikethrough)
 
bool SetFontCharacteristics (const wchar_t *face_name, ON_Font::Weight font_weight, ON_Font::Style font_style, ON_Font::Stretch font_stretch, bool bUnderlined, bool bStrikethrough)
 
bool SetFontCharacteristics (double point_size, const wchar_t *face_name, ON_Font::Weight font_weight, ON_Font::Style font_style, ON_Font::Stretch font_stretch, bool bUnderlined, bool bStrikethrough)
 
bool SetFontCharacteristics (const wchar_t *face_name, ON_Font::Weight font_weight, ON_Font::Style font_style, ON_Font::Stretch font_stretch, bool bUnderlined, bool bStrikethrough, double linefeed_ratio, unsigned int logfont_charset)
 
bool SetFontCharacteristics (double point_size, const wchar_t *face_name, ON_Font::Weight font_weight, ON_Font::Style font_style, ON_Font::Stretch font_stretch, bool bUnderlined, bool bStrikethrough, double linefeed_ratio, unsigned int logfont_charset)
 
bool SetFontFaceName (const wchar_t *face_name)
 
bool SetFontStretch (ON_Font::Stretch font_stretch)
 
bool SetFontStyle (ON_Font::Style font_style)
 
bool SetFontWeight (ON_Font::Weight font_weight)
 
bool SetFromAppleFontName (const wchar_t *apple_font_name)
 
bool SetFromFontDescription (const wchar_t *font_description)
 
bool SetFromFontDescription (const wchar_t *font_description, const wchar_t *apple_font_name)
 
bool SetLogfontCharSet (unsigned char logfont_charset)
 
bool SetPointSize (double point_size)
 
bool SetStrikethrough (bool bStrikethrough)
 
bool SetUnderlined (bool bUnderlined)
 
bool SetWindowsLogfontWeight (int windows_logfont_weight)
 
int WindowsLogfontWeight () const
 
bool Write (ON_BinaryArchive &) const
 serialize definition to binary archive More...
 
bool WriteV5 (int V5_font_index, ON_UUID V5_font_id, ON_BinaryArchive &) const
 V6 separated the V5 ON_Font into ON_TextStyle and ON_Font. More...
 

Static Public Member Functions

static double AppleFontWeightTraitFromWeight (ON_Font::Weight font_weight)
 
static int AppleWeightOfFontFromWeight (ON_Font::Weight font_weight)
 
static int CompareFontCharacteristics (const ON_Font &a, const ON_Font &b)
 
static int CompareWeight (ON_Font::Weight weight_a, ON_Font::Weight weight_b)
 
static void DumpFreeTypeFace (ON__UINT_PTR free_type_face_ptr, ON_TextLog &text_log)
 
static bool EqualFontCharacteristics (const ON_Font &a, const ON_Font &b)
 
static ON_Font::Stretch FontStretchFromUnsigned (unsigned int unsigned_font_stretch)
 
static ON_Font::Style FontStyleFromUnsigned (unsigned int unsigned_font_style)
 
static ON_Font::Weight FontWeightFromUnsigned (unsigned int unsigned_font_weight)
 
static ON__UINT_PTR FreeTypeFace (const ON_Font *font)
 
static const ON_FontGetManagedFont (const wchar_t *face_name)
 
static const ON_FontGetManagedFont (double point_size, const wchar_t *face_name)
 
static const ON_FontGetManagedFont (const wchar_t *face_name, bool bBold)
 
static const ON_FontGetManagedFont (double point_size, const wchar_t *face_name, bool bBold)
 
static const ON_FontGetManagedFont (const wchar_t *face_name, bool bBold, bool bItalic)
 
static const ON_FontGetManagedFont (double point_size, const wchar_t *face_name, bool bBold, bool bItalic)
 
static const ON_FontGetManagedFont (const wchar_t *face_name, ON_Font::Weight font_weight, ON_Font::Style font_style)
 
static const ON_FontGetManagedFont (double point_size, const wchar_t *face_name, ON_Font::Weight font_weight, ON_Font::Style font_style)
 
static const ON_FontGetManagedFont (const wchar_t *face_name, ON_Font::Weight font_weight, ON_Font::Style font_style, ON_Font::Stretch font_stretch, bool bUnderlined, bool bStrikethrough, double linefeed_ratio, unsigned int logfont_charset)
 
static const ON_FontGetManagedFont (double point_size, const wchar_t *face_name, ON_Font::Weight font_weight, ON_Font::Style font_style, ON_Font::Stretch font_stretch, bool bUnderlined, bool bStrikethrough, double linefeed_ratio, unsigned int logfont_charset)
 
static const ON_FontGetManagedFont (const ON_Font &font_characteristics, bool bCreateIfNotFound)
 
static const ON_FontGetManagedFontFromAppleFontName (const wchar_t *apple_font_name)
 
static const ON_FontGetManagedFontFromFontDescription (const wchar_t *font_description)
 
static const ON_FontGetManagedFontFromSerialNumber (unsigned int managed_font_runtime_serial_number)
 
static unsigned int GetManagedFontList (ON_SimpleArray< const ON_Font * > &managed_fonts)
 
static void GetRunBounds (const ON_Font &font, const wchar_t *text, double fontSizePixels, ON::TextHorizontalAlignment horizontalAlignment, ON::TextVerticalAlignment verticalAlignment, ON_2dPoint &boundsMin, ON_2dPoint &boundsMax, int &lineCount)
 
static bool IsNotAppleFontName (const wchar_t *font_description)
 
static bool IsValidFaceName (const wchar_t *face_name)
 
static void SetCustomMeasurementFunctions (ON_GetGlyphMetricsFuncType measureGlyphFunc, ON_GetFontMetricsFuncType metricsFunction)
 
static const wchar_t * StyleToWideString (ON_Font::Style font_style)
 
static ON_Font::Weight WeightFromAppleFontWeightTrait (double apple_font_weight_trait)
 
static ON_Font::Weight WeightFromAppleWeightOfFont (int apple_weight_of_font)
 
static ON_Font::Weight WeightFromWindowsLogfontWeight (int windows_logfont_weight)
 
static const wchar_t * WeightToWideString (ON_Font::Weight font_weight)
 
static unsigned char WindowsLogfontCharSetFromFaceName (const wchar_t *face_name)
 
static int WindowsLogfontWeightFromWeight (ON_Font::Weight font_weight)
 

Static Public Attributes

static const ON_Font Default
 

Friends

class ON_FontGlyph
 
class ON_ManagedFonts
 

Detailed Description

An ON_Font is a face in a font family. It corresponds to a Windows LOGFONT, a .NET System.Drawing.Font or a FreeType FT_Face.

Member Typedef Documentation

◆ ON_GetFontMetricsFuncType

typedef void(* ON_Font::ON_GetFontMetricsFuncType) (const ON_Font *font, ON_FontMetrics &font_unit_font_metrics)

◆ ON_GetGlyphMetricsFuncType

typedef ON__UINT_PTR(* ON_Font::ON_GetGlyphMetricsFuncType) (const class ON_Font *font, ON__UINT32 unicode_code_point, class ON_TextBox &font_unit_glyph_box)

Returns free type glyph index (or nonzero equivalent) if glyph is defined fo the glyph.CodePoint() in glyph.Font() and glyph_box is set.

Member Enumeration Documentation

◆ Constants

enum ON_Font::Constants : int

miscellaneous constants use to initialize Windows LOGFONT fields

Enumerator
AnnotationFontCellHeight 

LOGFONT.lfHeight value.

1995 - 2015: Windows fonts have variations in glyph size, design and kerning for different point sizes. Text in Rhino is generally placed around geometry and the relative spatial relationships between the text and the geometry must remain constant on all devices and at all "zoom" levels. We have to choose a point size and then apply appropriate scaling during display, printing, and in other rendering calculations. After many experiments and 20 years of commercial use, (1995-2015) we have found 256 works best. This value is used on all platforms because the calculations it is used in occur on all platforms. These calculations must return consistent results so models exchanged between platforms maintain spatial relationships between text and geometry.

2017: (switching to freetype) The value ON_Font::Constants::AnnotationFontCellHeight is used to define "opennurbs normalized font coordinates". The scale ((double)ON_Font::Constants::AnnotationFontCellHeight)/(font definition grid height) is used to convert bounding information and outlines from a native font definition to opennurbs normalized font coordinates. Many TrueType fonts have font definition grid height = 2048. Many PostScript fonts have font definition grid height = 1000.

MetricsGlyphCodePoint 

ON_Font::Constants::metric_char is the unicode code point value for the glpyh used to calculate critical glyph metrics. It must be an 'I' or 'H', but we have not tested 'H'. There are problems with any other upper case latin letter in common fonts. In particular, the standard 'M' does not work. We have used 'I' for 22 years (1995 - 2017). This value is used on all platforms because the calculations it is used in occur on all platforms. These calculations must return consistent results so models exchanged between platforms maintain spatial relationships between text and geometry.

◆ Stretch

enum ON_Font::Stretch : unsigned char
strong

Horizontal expansion or contraction of font

Enumerator
Unset 

Not set.

Ultracondensed 
Extracondensed 
Condensed 
Semicondensed 
Medium 

Default font stretch.

Semiexpanded 

Normal = 5,.

Expanded 
Extraexpanded 
Ultraexpanded 

◆ Style

enum ON_Font::Style : unsigned char
strong

Vertical angle of font Upright, Italic, or Oblique

Enumerator
Unset 

Not set.

Upright 

Default font style.

Italic 

Normal = 1, Roman = 1,

Oblique 

◆ Weight

enum ON_Font::Weight : unsigned char
strong

Weight enum values Avoid casting these values to int. Use ON_Font::WindowsLogfontWeightFromWeight() or ON_Font::AppleWeightOfFontFromWeight() or add another converter.

Enumerator
Unset 

Not set.

Thin 

IsLight = true

Ultralight 

IsLight = true

Light 

ExtraLight = 2,.

IsLight = true

Normal 

Default font weight. IsNormalWeight = true Also called Regular.

Medium 

Regular = 4,.

IsNormalWeight = true

Semibold 

IsBold = true

Bold 

IsBold = true

Demibold = 6, Demi = 6, Semi = 6,

Ultrabold 

IsBold = true

Heavy 

ExtraBold = 8,.

IsBold = true Also called Black

◆ WindowsConstants

enum ON_Font::WindowsConstants : unsigned char

Interface

Enumerator
logfont_ansi_charset 

Values used to set Windows LOGFONT fields.

The values below are identical to the ones above and are used to insure code compiles for Apple and other platforms.

logfont_default_charset 
logfont_symbol_charset 
logfont_out_precis 
logfont_quality 
logfont_pitch_and_family 

Constructor & Destructor Documentation

◆ ON_Font() [1/2]

ON_Font::ON_Font ( )

◆ ~ON_Font()

ON_Font::~ON_Font ( )
default

◆ ON_Font() [2/2]

ON_Font::ON_Font ( const ON_Font src)

Member Function Documentation

◆ AppleFontName()

const ON_wString& ON_Font::AppleFontName ( ) const

◆ AppleFontNameAsPointer()

const wchar_t* ON_Font::AppleFontNameAsPointer ( ) const

◆ AppleFontWeightTrait()

double ON_Font::AppleFontWeightTrait ( ) const

◆ AppleFontWeightTraitFromWeight()

static double ON_Font::AppleFontWeightTraitFromWeight ( ON_Font::Weight  font_weight)
static

Description: The correspondence between Apple "font weight trait" values and ON_Font::Weight enum values is ON_Font::Weight::Thin = -0.4 Apple font weight trait ON_Font::Weight::Ultralight = -0.2667 Apple font weight trait ON_Font::Weight::Light = -0.1333 Apple font weight trait ON_Font::Weight::Normal = 0.0 Apple font weight trait ON_Font::Weight::Medium = 0.1333 Apple font weight trait ON_Font::Weight::Semibold = 0.2667 Apple font weight trait ON_Font::Weight::Bold = 0.4 Apple font weight trait ON_Font::Weight::Ultrabold = 0.5333 Apple font weight trait ON_Font::Weight::Heavy = 0.6667 Apple font weight trait Returns: The Apple "NSFontWeightTrait" value that corresponds to the ON_Font::Weight enum value.

◆ AppleWeightOfFont()

int ON_Font::AppleWeightOfFont ( ) const

◆ AppleWeightOfFontFromWeight()

static int ON_Font::AppleWeightOfFontFromWeight ( ON_Font::Weight  font_weight)
static

Description: The correspondence between Apple "weight of font" values and ON_Font::Weight enum values is ON_Font::Weight::Thin = 1 ON_Font::Weight::Ultralight = 2 ON_Font::Weight::Light = 3 ON_Font::Weight::Normal = 4 ON_Font::Weight::Medium = 5 ON_Font::Weight::Semibold = 6 ON_Font::Weight::Bold = 7 ON_Font::Weight::Ultrabold = 8 ON_Font::Weight::Heavy = 9 Returns: The Apple "weight of font" value that corresponds to the ON_Font::Weight enum value.

◆ CodePointGlyph()

const class ON_FontGlyph* ON_Font::CodePointGlyph ( ON__UINT32  unicode_code_point) const

Description: Returns the glpyh informationh for used to render a specific code point Parameters: unicode_code_point UNICODE code point value Returns: Glyph rendering information.

Remarks: Typically the returned glpyh uses is a single glpyh in this->ManagedFont(). In this case, glyph->SubstitueCount() is 0.

In some cases one or more glyphs from one or more substitute fonts are required to render the code point. In this case, glyph->SubstitueCount() is 0.

Example: ON_Font* font = ...; unsigned int code_point = ...; const ON_FontGlyph* g = font->CodePointGlyph(code_point); if (nullptr != g ) { if ( g->SubstituteCount() > 0 ) { / complicate case - one of more substitutes must be rendered to render g for ( const ON_FontGlyph* gsub = g.NextSubstitute(); nullptr != gsub; gsub = gsub->NextSubstitute() ) { ... } } else { / simple case - this computer can directly render g ... } }

◆ CompareFontCharacteristics()

static int ON_Font::CompareFontCharacteristics ( const ON_Font a,
const ON_Font b 
)
static

Description: Compares the font weight, style, stretch, underline, strikethrough, linefeed_ratio and facename characteristics. Returns: -1: a characteristics < b characteristics 0: a characteristics = b characteristics +1: a characteristics > b characteristics Remarks: This is a legacy function and to preserve past behavior, some platform specific characteristics are not checked. Use FontCharacteristicsHash() when every characteristic needs to be compared.

◆ CompareWeight()

static int ON_Font::CompareWeight ( ON_Font::Weight  weight_a,
ON_Font::Weight  weight_b 
)
static

Returns: -1: weight_a is lighter, weight_b is heavier +1: weight_a is heavier, weight_b is lighter 0: weight_a = weight_b

◆ CRC32()

ON__UINT32 ON_Font::CRC32 ( bool  bIgnoreFaceNameOrdinalCase) const

Description: Returns a 32-bit crc of the font weight, style, stretch, underline, strikethrough, and facename characteristics.

Parameters: bIgnoreFaceNameOrdinalCase - [in] If true, ON_wString::MapStringOrdinal() is applied to the face name and the returned CRC is ordinal case independent.

◆ Dump()

void ON_Font::Dump ( ON_TextLog ) const

for debugging

◆ DumpFreeType()

void ON_Font::DumpFreeType ( ON_TextLog text_log) const

◆ DumpFreeTypeFace()

static void ON_Font::DumpFreeTypeFace ( ON__UINT_PTR  free_type_face_ptr,
ON_TextLog text_log 
)
static

◆ EqualFontCharacteristics()

static bool ON_Font::EqualFontCharacteristics ( const ON_Font a,
const ON_Font b 
)
static

Description: Compares the font weight, style, stretch, underline, strikethrough, linefeed_ratio and facename characteristics. Returns: 0 == ON_Font::CompareFontCharacteristics(a,b). Remarks: This is a legacy function and to preserve past behavior, some platform specific characteristics are not checked. Use FontCharacteristicsHash() when every characteristic needs to be compared.

◆ FontCharacteristicsAsUnsigned()

unsigned int ON_Font::FontCharacteristicsAsUnsigned ( ) const

Description: The font properties weight, style, stretch, underlined, and strikethrough are encoded in the returned value. Remarks: This is a legacy value used in 3dm archive reading/writing and some sorting operations.

◆ FontCharacteristicsHash()

const class ON_SHA1_Hash& ON_Font::FontCharacteristicsHash ( ) const

Returns: A SHA-1 hash of all font characteristics, including platform specific settings. Two fonts have identical font characteristics, if and only if they have identical FontCharacteristicsHash() values.

Example: ON_Font f1 = ... ON_Font f2 = ... if ( f1.FontCharacteristicsHash() == f2.FontCharacteristicsHash() ) { / f1 and f2 have identical font characteristics } else { / f1 and f2 have different font characteristics }

◆ FontDescription()

const ON_wString& ON_Font::FontDescription ( ) const

Description: Get a text description of the font. Parameters: font_description - [out] Returns: A pointer to the font description string stored in the font_description parameter.

◆ FontDescriptionAsPointer()

const wchar_t* ON_Font::FontDescriptionAsPointer ( ) const

Description: Get a text description of the font. Parameters: font_description - [out] Returns: A pointer to the font description string stored in the font_description parameter.

◆ FontFaceName()

const wchar_t* ON_Font::FontFaceName ( ) const

◆ FontMetrics()

const ON_FontMetrics& ON_Font::FontMetrics ( ) const

Returns: Normalized font metrics.

Remarks: Font metric "normalized" units are comparable between different fonts. Normalized font metrics exist so that code that positions glyphs from multiple fonts does not have to take the unit system and resolution used in the design of each font. In opennurbs, much of this code that positions glyphs is located in ON_Annotation, ON_TextContent, and ON_TextRun member functions and is used when rendering annotation objects.

Fonts can be designed and defined at different resolutions and relative scaling is necessary when text contains glyphs from fonts desinged at different grid resolutions. For example, TrueType font grid with and height is often 1024x1024 or 2048x2014, OpenType grids are often 1000x1000, and PostScript grids are often 1000x1000. Opennurbs "font units" are the units the font was designed in.

Long ago, opennurbs and Rhino used only Windows TrueType fonts and ran only in Microsoft Windows. During this era, the "normalized units" were for a Windows LOGFONT created with lfHeight = ON_Font::Constants::AnnotationFontCellHeight.

Currently opennurbs and Rhino work on Microsoft Windows and Apple platforms and use FreeType to access font information. When a font is not "tricky", the "font design" units are the the units FreeType uses when a font is loaded with FT_LOAD_NO_SCALE.

When working with fonts and glyhphs in opennurbs and Rhino, SDK users almost always want to use normalized font and glyph metrics.

◆ FontStretch()

ON_Font::Stretch ON_Font::FontStretch ( ) const

◆ FontStretchFromUnsigned()

static ON_Font::Stretch ON_Font::FontStretchFromUnsigned ( unsigned int  unsigned_font_stretch)
static

Description: In the rare cases when an ON_Font::Stretch value must be passed as an unsigned int, use ON_Font::FontStretchFromUnsigned() to convert the unsigned value to an ON_Font::Stretch value. Parameters: unsigned_font_stretch - [in]

◆ FontStyle()

ON_Font::Style ON_Font::FontStyle ( ) const

◆ FontStyleFromUnsigned()

static ON_Font::Style ON_Font::FontStyleFromUnsigned ( unsigned int  unsigned_font_style)
static

Description: In the rare cases when an ON_Font::Style value must be passed as an unsigned int, use ON_Font::FontStyleFromUnsigned() to convert the unsigned value to an ON_Font::Style value. Parameters: unsigned_font_style - [in]

◆ FontUnitFontMetrics()

const ON_FontMetrics& ON_Font::FontUnitFontMetrics ( ) const

Description: This function is for expert users doing something complicated. Returns: Font metrics read directly from the font definition with no or minimal scaling. Remarks: See ON_Font.FontMetrics() documentation for important information about the differnce bewteen normalized and font unit metrics.

◆ FontUnitToNormalizedScale()

double ON_Font::FontUnitToNormalizedScale ( ) const

Returns: scale to apply when converting from a FT_LOAD_NO_SCALE FreeType glyph metric or outline to normalized opennurbs font coordinates.

◆ FontWeight()

ON_Font::Weight ON_Font::FontWeight ( ) const

◆ FontWeightFromUnsigned()

static ON_Font::Weight ON_Font::FontWeightFromUnsigned ( unsigned int  unsigned_font_weight)
static

Description: In the rare cases when an ON_Font::Weight value must be passed as an unsigned int, use ON_Font::FontWeightFromUnsigned() to convert the unsigned value to an ON_Font::Weight value. Parameters: unsigned_font_weight - [in]

◆ FreeTypeFace()

static ON__UINT_PTR ON_Font::FreeTypeFace ( const ON_Font font)
static

Description: If opennurbs is built with FreeType support then FT_Face freetype_face = (FT_Face)ON_Font::FreeTypeFace(font) will return a FreeType face that can be used to render the font. Parameters: font - [in] Returns: A value that can be cast as a FreeType FT_Face. Example const ON_Font* font = ...; FT_Face freetype_face = (FT_Face)ON_Font::FreeTypeFace(font); Remarks: Many fonts do not have a glyph for a every UNICODE codepoint and font substitution is required. If you want to get the freetype face used for a specfic UNICODE codepoint, call ON_Font::CodepointFreeTypeFace().

◆ GetManagedFont() [1/11]

static const ON_Font* ON_Font::GetManagedFont ( const wchar_t *  face_name)
static

Description: Get a font managed by the application from the font characteristics. Never delete a font returned by GetManagedFont(). Parameters: face_name - [in] font_weight - [in] default = ON_Font::Default.FontWeight() font_style - [in] default = ON_Font::Default.FontStyle() font_stretch - [in] default = ON_Font::Default.FontStretch() bUnderlined - [in] default = ON_Font::Default.Underlined() = false bStrikethrough - [in] default = ON_Font::Default.Strikethrough() = false linefeed_ratio - [in] default = ON_Font::Default.LinefeedRatio() windows_charset - [in] default = ON_Font::WindowsCharSet::DefaultCharSet

◆ GetManagedFont() [2/11]

static const ON_Font* ON_Font::GetManagedFont ( double  point_size,
const wchar_t *  face_name 
)
static

◆ GetManagedFont() [3/11]

static const ON_Font* ON_Font::GetManagedFont ( const wchar_t *  face_name,
bool  bBold 
)
static

◆ GetManagedFont() [4/11]

static const ON_Font* ON_Font::GetManagedFont ( double  point_size,
const wchar_t *  face_name,
bool  bBold 
)
static

◆ GetManagedFont() [5/11]

static const ON_Font* ON_Font::GetManagedFont ( const wchar_t *  face_name,
bool  bBold,
bool  bItalic 
)
static

◆ GetManagedFont() [6/11]

static const ON_Font* ON_Font::GetManagedFont ( double  point_size,
const wchar_t *  face_name,
bool  bBold,
bool  bItalic 
)
static

◆ GetManagedFont() [7/11]

static const ON_Font* ON_Font::GetManagedFont ( const wchar_t *  face_name,
ON_Font::Weight  font_weight,
ON_Font::Style  font_style 
)
static

◆ GetManagedFont() [8/11]

static const ON_Font* ON_Font::GetManagedFont ( double  point_size,
const wchar_t *  face_name,
ON_Font::Weight  font_weight,
ON_Font::Style  font_style 
)
static

◆ GetManagedFont() [9/11]

static const ON_Font* ON_Font::GetManagedFont ( const wchar_t *  face_name,
ON_Font::Weight  font_weight,
ON_Font::Style  font_style,
ON_Font::Stretch  font_stretch,
bool  bUnderlined,
bool  bStrikethrough,
double  linefeed_ratio,
unsigned int  logfont_charset 
)
static

◆ GetManagedFont() [10/11]

static const ON_Font* ON_Font::GetManagedFont ( double  point_size,
const wchar_t *  face_name,
ON_Font::Weight  font_weight,
ON_Font::Style  font_style,
ON_Font::Stretch  font_stretch,
bool  bUnderlined,
bool  bStrikethrough,
double  linefeed_ratio,
unsigned int  logfont_charset 
)
static

◆ GetManagedFont() [11/11]

static const ON_Font* ON_Font::GetManagedFont ( const ON_Font font_characteristics,
bool  bCreateIfNotFound 
)
static

◆ GetManagedFontFromAppleFontName()

static const ON_Font* ON_Font::GetManagedFontFromAppleFontName ( const wchar_t *  apple_font_name)
static

◆ GetManagedFontFromFontDescription()

static const ON_Font* ON_Font::GetManagedFontFromFontDescription ( const wchar_t *  font_description)
static

◆ GetManagedFontFromSerialNumber()

static const ON_Font* ON_Font::GetManagedFontFromSerialNumber ( unsigned int  managed_font_runtime_serial_number)
static

◆ GetManagedFontList()

static unsigned int ON_Font::GetManagedFontList ( ON_SimpleArray< const ON_Font * > &  managed_fonts)
static

◆ GetRunBounds()

static void ON_Font::GetRunBounds ( const ON_Font font,
const wchar_t *  text,
double  fontSizePixels,
ON::TextHorizontalAlignment  horizontalAlignment,
ON::TextVerticalAlignment  verticalAlignment,
ON_2dPoint boundsMin,
ON_2dPoint boundsMax,
int &  lineCount 
)
static

◆ IsBold()

bool ON_Font::IsBold ( ) const

Description: User interfaces that want to behave as if there are 3 font weights, light < normal < < bold, can use the functions ON_Font.IsLight(), ON_Font.IsNormalWeight(), ON_Font.IsBold(), to query font weight ranges. Returns: True if heavier than ON_Font::Weight::Medium.

◆ IsItalic()

bool ON_Font::IsItalic ( ) const

◆ IsLight()

bool ON_Font::IsLight ( ) const

Description: User interfaces that want to behave as if there are 3 font weights, light < normal < < bold, can use the functions ON_Font.IsLight(), ON_Font.IsNormalWeight(), ON_Font.IsBold(), to query font weight ranges. Returns: True if FontWeight() is lighter than ON_Font::Weight::Normal

◆ IsManagedFont()

bool ON_Font::IsManagedFont ( ) const

Returns: True if this font is a managed font returned by one of the static ON_Font::GetManagedFont(...) functions. Remarks: ON_Font::Default is managed.

◆ IsNormalWeight()

bool ON_Font::IsNormalWeight ( ) const

Description: User interfaces that want to behave as if there are 3 font weights, light < normal < < bold, can use the functions ON_Font.IsLight(), ON_Font.IsNormalWeight(), ON_Font.IsBold(), to query font weight ranges. Returns: True if FontWeight() is ON_Font::Normal or ON_Font::Weight::Medium

◆ IsNotAppleFontName()

static bool ON_Font::IsNotAppleFontName ( const wchar_t *  font_description)
static

Description: When reading version 5 3dm achives, the font description can be a generic font description or an Apple font name. This function rejects certain descriptions like "Default" and "Arial" for use as Apple font names.

◆ IsOblique()

bool ON_Font::IsOblique ( )

◆ IsStrikethrough()

bool ON_Font::IsStrikethrough ( ) const

◆ IsUnderlined()

bool ON_Font::IsUnderlined ( ) const

◆ IsUpright()

bool ON_Font::IsUpright ( ) const

◆ IsValid()

bool ON_Font::IsValid ( ON_TextLog text_log = nullptr) const

Description: Tests an object to see if its data members are correctly initialized. Parameters: text_log - [in] if the object is not valid and text_log is not nullptr, then a brief englis description of the reason the object is not valid is appened to the log. The information appended to text_log is suitable for low-level debugging purposes by programmers and is not intended to be useful as a high level user interface tool. Returns: table true object is valid false object is invalid, uninitialized, etc.

◆ IsValidFaceName()

static bool ON_Font::IsValidFaceName ( const wchar_t *  face_name)
static

◆ LinefeedRatio()

double ON_Font::LinefeedRatio ( ) const

◆ LogfontCharSet()

unsigned char ON_Font::LogfontCharSet ( ) const

◆ ManagedFont()

const ON_Font* ON_Font::ManagedFont ( ) const

Returns: The managed font for this font. Remarks: If this->IsManagedFont() is true, then "this" is returned.

◆ ManagedFontSerialNumber()

unsigned int ON_Font::ManagedFontSerialNumber ( ) const

Description: Two ON_Font classes reference the same platform font and create identical glyphs if and only if the have the same ManagedFontSerialNumber(). Returns: 0: This font is unset. >= 1: Serial number of the managed font with the same characteristics. Remark: For managed fonts other than ON_Font::Default, the value of ManagedFontSerialNumber() typically varies between instances of the same application. Different platforms and application versions may use different font faces for ON_Font::Default. If an ON_Font is a managed font, then RuntimeSerialNumber() and ManagedFontSerialNumber() are identical. If an ON_Font is not a managed font, then RuntimeSerialNumber() is zero.

◆ NormalizedToFontUnitScale()

double ON_Font::NormalizedToFontUnitScale ( ) const

Returns: scale to apply when converting from a FT_LOAD_NO_SCALE FreeType glyph metric or outline to normalized opennurbs font coordinates.

◆ ON_DEPRECATED_MSG() [1/7]

ON_Font::ON_DEPRECATED_MSG ( "Use FontMetrics().AscentOfI()"  ) const

◆ ON_DEPRECATED_MSG() [2/7]

ON_Font::ON_DEPRECATED_MSG ( "Use FontMetrics().LineSpace()"  ) const

◆ ON_DEPRECATED_MSG() [3/7]

ON_Font::ON_DEPRECATED_MSG ( "Use FontMetrics().GlyphScale()"  ) const

◆ ON_DEPRECATED_MSG() [4/7]

ON_Font::ON_DEPRECATED_MSG ( "Use FontMetrics().StrikeoutThickness()"  ) const

◆ ON_DEPRECATED_MSG() [5/7]

ON_Font::ON_DEPRECATED_MSG ( "Use FontMetrics().StrikeoutPosition()"  ) const

◆ ON_DEPRECATED_MSG() [6/7]

ON_Font::ON_DEPRECATED_MSG ( "Use FontMetrics().UnderscoreThickness()"  ) const

◆ ON_DEPRECATED_MSG() [7/7]

ON_Font::ON_DEPRECATED_MSG ( "Use FontMetrics().UnderscorePosition()"  ) const

◆ operator=()

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

◆ PointSize()

double ON_Font::PointSize ( ) const

Returns: Font character height in points (1 point = 1/72 inch).

See the remarks for a defintion of "character height".

Remarks: A "point" is a length unit system. 1 point = 1/72 inch = 25.4/72 millimeters.

Typically, fonts are designed for maximum clarity when the rendered character height is close to PointSize().

font cell height = font ascent + font descent.

font character height = font cell height - font internal leading.

For fonts designed for languages that use latin letters, it is common for the character height to be equal to or a little larger than the distance from the bottom of a lower case g to the top of an upper case M. The character height is also called the "em hieght".

Font internal leading is the space above typical capital latin letters that is reseved for diacritical marks like the ring above the A in the UNICODE "LATIN LETTER A WITH RING" U+00C5 glyph (Angstrom symbol).

◆ Read()

bool ON_Font::Read ( ON_BinaryArchive )

restore definition from binary archive

◆ ReadV5()

bool ON_Font::ReadV5 ( ON_BinaryArchive ,
int *  V5_font_index,
ON_UUID V5_font_id 
)

V6 separated the V5 ON_Font into ON_TextStyle and ON_Font.

◆ RuntimeSerialNumber()

unsigned int ON_Font::RuntimeSerialNumber ( ) const

Returns: 0: This is not a managed font. 1: This is the managed font ON_Font::Default. >= 2: This is a managed font other than ON_Font::Default. Remark: For managed fonts other than ON_Font::Default, the value of RuntimeSerialNumber() typically varies between instances of the same application. Different platforms and application versions may use different font faces for ON_Font::Default. If an ON_Font is a managed font, then RuntimeSerialNumber() and ManagedFontSerialNumber() are identical. If an ON_Font is not a managed font, then RuntimeSerialNumber() is zero.

◆ SetAppleFontWeightTrait()

bool ON_Font::SetAppleFontWeightTrait ( double  apple_font_weight_trait)

◆ SetAppleWeightOfFont()

bool ON_Font::SetAppleWeightOfFont ( int  apple_weight_of_font)

◆ SetCustomMeasurementFunctions()

static void ON_Font::SetCustomMeasurementFunctions ( ON_GetGlyphMetricsFuncType  measureGlyphFunc,
ON_GetFontMetricsFuncType  metricsFunction 
)
static

◆ SetFontCharacteristics() [1/6]

bool ON_Font::SetFontCharacteristics ( const wchar_t *  face_name,
bool  bBold,
bool  bItalic,
bool  bUnderlined,
bool  bStrikethrough 
)

Description: Create a font with a specified facename and properties. Parameters: face_name - [in] nullptr is treated as ON_Font::Default.FaceName(). bBold - [in] True for a bold version of the font. bItalic - [in] True for an italic version of the font. Returns: True if the font characteristics were valid and set on the font.

◆ SetFontCharacteristics() [2/6]

bool ON_Font::SetFontCharacteristics ( double  point_size,
const wchar_t *  face_name,
bool  bBold,
bool  bItalic,
bool  bUnderlined,
bool  bStrikethrough 
)

Description: Create a font with a specified facename and properties. Parameters: point_size - [in] If point_size > 0.0, then it specifies which size of font definition should be used. Otherwise the font size used for annotation text is used. For high quality fonts it is generally the case that different point sizes of the same font face have subtle differences in glyph design and are not simply scaled versions of a base glyph. face_name - [in] nullptr is treated as ON_Font::Default.FaceName(). bBold - [in] True for a bold version of the font. bItalic - [in] True for an italic version of the font. Returns: True if the font characteristics were valid and set on the font.

◆ SetFontCharacteristics() [3/6]

bool ON_Font::SetFontCharacteristics ( const wchar_t *  face_name,
ON_Font::Weight  font_weight,
ON_Font::Style  font_style,
ON_Font::Stretch  font_stretch,
bool  bUnderlined,
bool  bStrikethrough 
)

Description: Set the font's face name and characteristics. Parameters: face_name - [in] nullptr is not permitted. Pass ON_Font::Default.FaceName() if you don't have a face name. Returns: True if the font characteristics were valid and set on the font.

◆ SetFontCharacteristics() [4/6]

bool ON_Font::SetFontCharacteristics ( double  point_size,
const wchar_t *  face_name,
ON_Font::Weight  font_weight,
ON_Font::Style  font_style,
ON_Font::Stretch  font_stretch,
bool  bUnderlined,
bool  bStrikethrough 
)

◆ SetFontCharacteristics() [5/6]

bool ON_Font::SetFontCharacteristics ( const wchar_t *  face_name,
ON_Font::Weight  font_weight,
ON_Font::Style  font_style,
ON_Font::Stretch  font_stretch,
bool  bUnderlined,
bool  bStrikethrough,
double  linefeed_ratio,
unsigned int  logfont_charset 
)

◆ SetFontCharacteristics() [6/6]

bool ON_Font::SetFontCharacteristics ( double  point_size,
const wchar_t *  face_name,
ON_Font::Weight  font_weight,
ON_Font::Style  font_style,
ON_Font::Stretch  font_stretch,
bool  bUnderlined,
bool  bStrikethrough,
double  linefeed_ratio,
unsigned int  logfont_charset 
)

◆ SetFontFaceName()

bool ON_Font::SetFontFaceName ( const wchar_t *  face_name)

◆ SetFontStretch()

bool ON_Font::SetFontStretch ( ON_Font::Stretch  font_stretch)

◆ SetFontStyle()

bool ON_Font::SetFontStyle ( ON_Font::Style  font_style)

◆ SetFontWeight()

bool ON_Font::SetFontWeight ( ON_Font::Weight  font_weight)

◆ SetFromAppleFontName()

bool ON_Font::SetFromAppleFontName ( const wchar_t *  apple_font_name)

◆ SetFromFontDescription() [1/2]

bool ON_Font::SetFromFontDescription ( const wchar_t *  font_description)

◆ SetFromFontDescription() [2/2]

bool ON_Font::SetFromFontDescription ( const wchar_t *  font_description,
const wchar_t *  apple_font_name 
)

◆ SetLogfontCharSet()

bool ON_Font::SetLogfontCharSet ( unsigned char  logfont_charset)

◆ SetPointSize()

bool ON_Font::SetPointSize ( double  point_size)

Parameters: point_size - [in] font character height in point units.

Remarks: See the remarks section ON_Font::PointSize() for more information about point units and character height.

◆ SetStrikethrough()

bool ON_Font::SetStrikethrough ( bool  bStrikethrough)

◆ SetUnderlined()

bool ON_Font::SetUnderlined ( bool  bUnderlined)

◆ SetWindowsLogfontWeight()

bool ON_Font::SetWindowsLogfontWeight ( int  windows_logfont_weight)

◆ StyleToWideString()

static const wchar_t* ON_Font::StyleToWideString ( ON_Font::Style  font_style)
static

◆ WeightFromAppleFontWeightTrait()

static ON_Font::Weight ON_Font::WeightFromAppleFontWeightTrait ( double  apple_font_weight_trait)
static

Parameters: apple_font_weight_trait - [in] Apple NSFontWeightTrait The valid value range is from -1.0 to 1.0. The value of 0.0 corresponds to the regular or medium font weight.

◆ WeightFromAppleWeightOfFont()

static ON_Font::Weight ON_Font::WeightFromAppleWeightOfFont ( int  apple_weight_of_font)
static

Description: The correspondence between Apple "weight of font" values and ON_Font::Weight enum values is ON_Font::Weight::Thin = 1 ON_Font::Weight::Ultralight = 2 ON_Font::Weight::Light = 3 ON_Font::Weight::Normal = 4 ON_Font::Weight::Medium = 5 ON_Font::Weight::Semibold = 6 ON_Font::Weight::Bold = 7 ON_Font::Weight::Ultrabold = 8 ON_Font::Weight::Heavy = 9 Returns: The best ON_Font::Weight enum value for the Apple weight of font.

◆ WeightFromWindowsLogfontWeight()

static ON_Font::Weight ON_Font::WeightFromWindowsLogfontWeight ( int  windows_logfont_weight)
static

Description: The correspondence between Windows LOGFONT lfWeight values and ON_Font::Weight enum values is

ON_Font::Weight::Thin = 100 ON_Font::Weight::Ultralight = 200 ON_Font::Weight::Light = 300 ON_Font::Weight::Normal = 400 ON_Font::Weight::Medium = 500 ON_Font::Weight::Semibold = 600 ON_Font::Weight::Bold = 700 ON_Font::Weight::Ultrabold = 800 ON_Font::Weight::Heavy = 900 Returns: The best ON_Font::Weight enum value for the Windows LOGFONT weight.

◆ WeightToWideString()

static const wchar_t* ON_Font::WeightToWideString ( ON_Font::Weight  font_weight)
static

◆ WindowsLogfontCharSetFromFaceName()

static unsigned char ON_Font::WindowsLogfontCharSetFromFaceName ( const wchar_t *  face_name)
static

Parameters: face_name - [in] Returns: If the code is running on Windows: The appropriate value of LOGFONT.lfCharSet for the input facename. If the code is not running on Windows: ON_Font::WindowsConstants::logfont_default_charset.

◆ WindowsLogfontWeight()

int ON_Font::WindowsLogfontWeight ( ) const

◆ WindowsLogfontWeightFromWeight()

static int ON_Font::WindowsLogfontWeightFromWeight ( ON_Font::Weight  font_weight)
static

Description: The correspondence between Windows LOGFONT lfWeight values and ON_Font::Weight enum values is ON_Font::Weight::Thin = 100 LOGFONT lfWeight ON_Font::Weight::Ultralight = 200 LOGFONT lfWeight ON_Font::Weight::Light = 300 LOGFONT lfWeight ON_Font::Weight::Normal = 400 LOGFONT lfWeight ON_Font::Weight::Medium = 500 LOGFONT lfWeight ON_Font::Weight::Semibold = 600 LOGFONT lfWeight ON_Font::Weight::Bold = 700 LOGFONT lfWeight ON_Font::Weight::Ultrabold = 800 LOGFONT lfWeight ON_Font::Weight::Heavy = 900 LOGFONT lfWeight Returns: The Windows LOGFONT lfWeight value that corresponds to the ON_Font::Weight enum value.

◆ Write()

bool ON_Font::Write ( ON_BinaryArchive ) const

serialize definition to binary archive

◆ WriteV5()

bool ON_Font::WriteV5 ( int  V5_font_index,
ON_UUID  V5_font_id,
ON_BinaryArchive  
) const

V6 separated the V5 ON_Font into ON_TextStyle and ON_Font.

Friends And Related Function Documentation

◆ ON_FontGlyph

friend class ON_FontGlyph
friend

◆ ON_ManagedFonts

friend class ON_ManagedFonts
friend

Member Data Documentation

◆ Default

const ON_Font ON_Font::Default
static