#include <opennurbs_font.h>
Public Member Functions | |
ON_FontMetrics ()=default | |
ON_FontMetrics (const ON_FontMetrics &)=default | |
~ON_FontMetrics ()=default | |
int | Ascent () const |
int | AscentOfI () const |
int | Descent () const |
double | GlyphScale (double text_height) const |
Get the scale to apply to normalized glyph boxes and outlines to render the 'I' in the glyph's font at a height of text_height. More... | |
bool | HeightsAreValid () const |
int | LineSpace () const |
ON_FontMetrics & | operator= (const ON_FontMetrics &)=default |
void | SetAscentOfI (int ascent_of_I) |
void | SetHeights (int ascent, int descent, int UPM, int line_space) |
void | SetStrikeout (int strikeout_position, int strikeout_thickness) |
void | SetUnderscore (int underscore_position, int underscore_thickness) |
int | StrikeoutPosition () const |
int | StrikeoutThickness () const |
int | UnderscorePosition () const |
int | UnderscoreThickness () const |
int | UPM () const |
Static Public Member Functions | |
static const ON_FontMetrics | Scale (const ON_FontMetrics &font_metrics, double scale) |
Static Public Attributes | |
static const double | DefaultLineFeedRatio |
static const ON__UINT32 | HeightOfCapitalCodePoint |
static const ON_FontMetrics | Unset |
All properties are zero. More... |
|
default |
|
default |
|
default |
int ON_FontMetrics::Ascent | ( | ) | const |
If every glyph outline in the font has (0,0) on the basline, then Ascent() is the maximum glyph bounding box Y.
int ON_FontMetrics::AscentOfI | ( | ) | const |
The primary uses of AscentOfI() are: 1) Calculate a scale factor to produce text with a user specified "text height". 2) To calculate insertion location for ON::TextVerticalAlignment::Middle and ON::TextVerticalAlignment::Top.
Since 2005, opennurbs has used (user specified text height)/AscentOfI() as the scale factor to render glyphs when user interface has provided a "text height" value. Users are more satisfied with this approach than when the scaling is base on line space or maximum font glyph ascent values. Experiments have ruled out the use of any other capital latin letter glyph except 'H' for this use. When a font does not contain an 'I' glyph, a suitable value is returned that can be used for text height scaling and vertical alignment.
int ON_FontMetrics::Descent | ( | ) | const |
This value is typically negative because glyphs for letters like 'j' typically have a portion of their outline below the baseline. However, some fonts have positive descent. If every glyph outline in the font has (0,0) on the basline, then Ascent() is the maximum glyph bounding box Y.
double ON_FontMetrics::GlyphScale | ( | double | text_height | ) | const |
Get the scale to apply to normalized glyph boxes and outlines to render the 'I' in the glyph's font at a height of text_height.
text_height | [in] The desired height of typical capital latin letter glyphs. |
bool ON_FontMetrics::HeightsAreValid | ( | ) | const |
int ON_FontMetrics::LineSpace | ( | ) | const |
The postive distance to move a base line when moving to a new line of text.
For almost every font used to render text, LineSpace() > (Ascent() - Descent()).
This metric is sometimes called "height", but that term is often confused with (Ascent() - Descent()).
For fonts designed to render horizontal lines of text, LineSpace() is a vertical distance. For fonts desingned to render vertical lines of text, LineSpace() is a horizontal distance. Depending on the context, the direction to move can be up, down, left or right.
|
default |
|
static |
void ON_FontMetrics::SetAscentOfI | ( | int | ascent_of_I | ) |
void ON_FontMetrics::SetHeights | ( | int | ascent, |
int | descent, | ||
int | UPM, | ||
int | line_space | ||
) |
void ON_FontMetrics::SetStrikeout | ( | int | strikeout_position, |
int | strikeout_thickness | ||
) |
void ON_FontMetrics::SetUnderscore | ( | int | underscore_position, |
int | underscore_thickness | ||
) |
int ON_FontMetrics::StrikeoutPosition | ( | ) | const |
The signed distance from the baseline to the bottom of the strikeout is StrikeoutPosition() - StrikeoutThickness()/2.
int ON_FontMetrics::StrikeoutThickness | ( | ) | const |
The signed distance from the baseline to the bottom of the strikeout is StrikeoutPosition() - StrikeoutThickness()/2.
int ON_FontMetrics::UnderscorePosition | ( | ) | const |
The signed distance from the baseline to the bottom of the underscore is UnderscorePosition() - UnderscoreThickness()/2.
int ON_FontMetrics::UnderscoreThickness | ( | ) | const |
The signed distance from the baseline to the bottom of the underscore is UnderscorePosition() - UnderscoreThickness()/2.
int ON_FontMetrics::UPM | ( | ) | const |
The width of the 'M' glyph in a font can be different from UPM. The height of the 'M' glyph in a font is typically less than UPM. In TrueType fonts, UPM is often a power of two and generally 1024 or 2048. In OpenType fonts, UPM is often 1000. In PostScript fonts, UPM is often 1000.
|
static |
|
static |
|
static |
All properties are zero.