Skia
2D Graphics Library
SkFontMetrics Class Reference

The metrics of an SkFont. More...

#include <SkFontMetrics.h>

Public Types

enum  FontMetricsFlags {
  kUnderlineThicknessIsValid_Flag = 1 << 0 , kUnderlinePositionIsValid_Flag = 1 << 1 , kStrikeoutThicknessIsValid_Flag = 1 << 2 , kStrikeoutPositionIsValid_Flag = 1 << 3 ,
  kBoundsInvalid_Flag = 1 << 4
}
 FontMetricsFlags indicate when certain metrics are valid; the underline or strikeout metrics may be valid and zero. More...
 

Public Member Functions

bool operator== (const SkFontMetrics &that)
 
bool hasUnderlineThickness (SkScalar *thickness) const
 Returns true if SkFontMetrics has a valid underline thickness, and sets thickness to that value. More...
 
bool hasUnderlinePosition (SkScalar *position) const
 Returns true if SkFontMetrics has a valid underline position, and sets position to that value. More...
 
bool hasStrikeoutThickness (SkScalar *thickness) const
 Returns true if SkFontMetrics has a valid strikeout thickness, and sets thickness to that value. More...
 
bool hasStrikeoutPosition (SkScalar *position) const
 Returns true if SkFontMetrics has a valid strikeout position, and sets position to that value. More...
 
bool hasBounds () const
 Returns true if SkFontMetrics has a valid fTop, fBottom, fXMin, and fXMax. More...
 

Public Attributes

uint32_t fFlags
 FontMetricsFlags indicating which metrics are valid. More...
 
SkScalar fTop
 greatest extent above origin of any glyph bounding box, typically negative; deprecated with variable fonts More...
 
SkScalar fAscent
 distance to reserve above baseline, typically negative More...
 
SkScalar fDescent
 distance to reserve below baseline, typically positive More...
 
SkScalar fBottom
 greatest extent below origin of any glyph bounding box, typically positive; deprecated with variable fonts More...
 
SkScalar fLeading
 distance to add between lines, typically positive or zero More...
 
SkScalar fAvgCharWidth
 average character width, zero if unknown More...
 
SkScalar fMaxCharWidth
 maximum character width, zero if unknown More...
 
SkScalar fXMin
 greatest extent to left of origin of any glyph bounding box, typically negative; deprecated with variable fonts More...
 
SkScalar fXMax
 greatest extent to right of origin of any glyph bounding box, typically positive; deprecated with variable fonts More...
 
SkScalar fXHeight
 height of lower-case 'x', zero if unknown, typically negative More...
 
SkScalar fCapHeight
 height of an upper-case letter, zero if unknown, typically negative More...
 
SkScalar fUnderlineThickness
 underline thickness More...
 
SkScalar fUnderlinePosition
 distance from baseline to top of stroke, typically positive More...
 
SkScalar fStrikeoutThickness
 strikeout thickness More...
 
SkScalar fStrikeoutPosition
 distance from baseline to bottom of stroke, typically negative More...
 

Detailed Description

The metrics of an SkFont.

The metric values are consistent with the Skia y-down coordinate system.

Member Enumeration Documentation

◆ FontMetricsFlags

FontMetricsFlags indicate when certain metrics are valid; the underline or strikeout metrics may be valid and zero.

Fonts with embedded bitmaps may not have valid underline or strikeout metrics.

Enumerator
kUnderlineThicknessIsValid_Flag 

set if fUnderlineThickness is valid

kUnderlinePositionIsValid_Flag 

set if fUnderlinePosition is valid

kStrikeoutThicknessIsValid_Flag 

set if fStrikeoutThickness is valid

kStrikeoutPositionIsValid_Flag 

set if fStrikeoutPosition is valid

kBoundsInvalid_Flag 

set if fTop, fBottom, fXMin, fXMax invalid

Member Function Documentation

◆ hasBounds()

bool SkFontMetrics::hasBounds ( ) const
inline

Returns true if SkFontMetrics has a valid fTop, fBottom, fXMin, and fXMax.

If the bounds are not valid, return false.

Returns
true if font specifies maximum glyph bounds

◆ hasStrikeoutPosition()

bool SkFontMetrics::hasStrikeoutPosition ( SkScalar position) const
inline

Returns true if SkFontMetrics has a valid strikeout position, and sets position to that value.

If the underline position is not valid, return false, and ignore position.

Parameters
positionstorage for strikeout position
Returns
true if font specifies strikeout position

◆ hasStrikeoutThickness()

bool SkFontMetrics::hasStrikeoutThickness ( SkScalar thickness) const
inline

Returns true if SkFontMetrics has a valid strikeout thickness, and sets thickness to that value.

If the underline thickness is not valid, return false, and ignore thickness.

Parameters
thicknessstorage for strikeout width
Returns
true if font specifies strikeout width

◆ hasUnderlinePosition()

bool SkFontMetrics::hasUnderlinePosition ( SkScalar position) const
inline

Returns true if SkFontMetrics has a valid underline position, and sets position to that value.

If the underline position is not valid, return false, and ignore position.

Parameters
positionstorage for underline position
Returns
true if font specifies underline position

◆ hasUnderlineThickness()

bool SkFontMetrics::hasUnderlineThickness ( SkScalar thickness) const
inline

Returns true if SkFontMetrics has a valid underline thickness, and sets thickness to that value.

If the underline thickness is not valid, return false, and ignore thickness.

Parameters
thicknessstorage for underline width
Returns
true if font specifies underline width

◆ operator==()

bool SkFontMetrics::operator== ( const SkFontMetrics that)
inline

Member Data Documentation

◆ fAscent

SkScalar SkFontMetrics::fAscent

distance to reserve above baseline, typically negative

◆ fAvgCharWidth

SkScalar SkFontMetrics::fAvgCharWidth

average character width, zero if unknown

◆ fBottom

SkScalar SkFontMetrics::fBottom

greatest extent below origin of any glyph bounding box, typically positive; deprecated with variable fonts

◆ fCapHeight

SkScalar SkFontMetrics::fCapHeight

height of an upper-case letter, zero if unknown, typically negative

◆ fDescent

SkScalar SkFontMetrics::fDescent

distance to reserve below baseline, typically positive

◆ fFlags

uint32_t SkFontMetrics::fFlags

FontMetricsFlags indicating which metrics are valid.

◆ fLeading

SkScalar SkFontMetrics::fLeading

distance to add between lines, typically positive or zero

◆ fMaxCharWidth

SkScalar SkFontMetrics::fMaxCharWidth

maximum character width, zero if unknown

◆ fStrikeoutPosition

SkScalar SkFontMetrics::fStrikeoutPosition

distance from baseline to bottom of stroke, typically negative

◆ fStrikeoutThickness

SkScalar SkFontMetrics::fStrikeoutThickness

strikeout thickness

◆ fTop

SkScalar SkFontMetrics::fTop

greatest extent above origin of any glyph bounding box, typically negative; deprecated with variable fonts

◆ fUnderlinePosition

SkScalar SkFontMetrics::fUnderlinePosition

distance from baseline to top of stroke, typically positive

◆ fUnderlineThickness

SkScalar SkFontMetrics::fUnderlineThickness

underline thickness

◆ fXHeight

SkScalar SkFontMetrics::fXHeight

height of lower-case 'x', zero if unknown, typically negative

◆ fXMax

SkScalar SkFontMetrics::fXMax

greatest extent to right of origin of any glyph bounding box, typically positive; deprecated with variable fonts

◆ fXMin

SkScalar SkFontMetrics::fXMin

greatest extent to left of origin of any glyph bounding box, typically negative; deprecated with variable fonts


The documentation for this class was generated from the following file: