Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Public Attributes | List of all members
SkFontMetrics Class Reference

#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
}
 

Public Member Functions

bool operator== (const SkFontMetrics &that) const
 
bool hasUnderlineThickness (SkScalar *thickness) const
 
bool hasUnderlinePosition (SkScalar *position) const
 
bool hasStrikeoutThickness (SkScalar *thickness) const
 
bool hasStrikeoutPosition (SkScalar *position) const
 
bool hasBounds () const
 

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.

Definition at line 18 of file SkFontMetrics.h.

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

Definition at line 44 of file SkFontMetrics.h.

44 {
45 kUnderlineThicknessIsValid_Flag = 1 << 0, //!< set if fUnderlineThickness is valid
46 kUnderlinePositionIsValid_Flag = 1 << 1, //!< set if fUnderlinePosition is valid
47 kStrikeoutThicknessIsValid_Flag = 1 << 2, //!< set if fStrikeoutThickness is valid
48 kStrikeoutPositionIsValid_Flag = 1 << 3, //!< set if fStrikeoutPosition is valid
49 kBoundsInvalid_Flag = 1 << 4, //!< set if fTop, fBottom, fXMin, fXMax invalid
50 };
@ kStrikeoutPositionIsValid_Flag
set if fStrikeoutPosition is valid
Definition: SkFontMetrics.h:48
@ kStrikeoutThicknessIsValid_Flag
set if fStrikeoutThickness is valid
Definition: SkFontMetrics.h:47
@ kUnderlinePositionIsValid_Flag
set if fUnderlinePosition is valid
Definition: SkFontMetrics.h:46
@ kUnderlineThicknessIsValid_Flag
set if fUnderlineThickness is valid
Definition: SkFontMetrics.h:45
@ kBoundsInvalid_Flag
set if fTop, fBottom, fXMin, fXMax invalid
Definition: SkFontMetrics.h:49

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

Definition at line 134 of file SkFontMetrics.h.

134 {
136 }
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
uint32_t fFlags
FontMetricsFlags indicating which metrics are valid.
Definition: SkFontMetrics.h:52

◆ 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

Definition at line 121 of file SkFontMetrics.h.

121 {
123 *position = fStrikeoutPosition;
124 return true;
125 }
126 return false;
127 }
SkScalar fStrikeoutPosition
distance from baseline to bottom of stroke, typically negative
Definition: SkFontMetrics.h:67

◆ 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

Definition at line 106 of file SkFontMetrics.h.

106 {
108 *thickness = fStrikeoutThickness;
109 return true;
110 }
111 return false;
112 }
SkScalar fStrikeoutThickness
strikeout thickness
Definition: SkFontMetrics.h:66

◆ 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

Definition at line 91 of file SkFontMetrics.h.

91 {
93 *position = fUnderlinePosition;
94 return true;
95 }
96 return false;
97 }
SkScalar fUnderlinePosition
distance from baseline to top of stroke, typically positive
Definition: SkFontMetrics.h:65

◆ 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

Definition at line 76 of file SkFontMetrics.h.

76 {
78 *thickness = fUnderlineThickness;
79 return true;
80 }
81 return false;
82 }
SkScalar fUnderlineThickness
underline thickness
Definition: SkFontMetrics.h:64

◆ operator==()

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

Definition at line 19 of file SkFontMetrics.h.

19 {
20 return
21 this->fFlags == that.fFlags &&
22 this->fTop == that.fTop &&
23 this->fAscent == that.fAscent &&
24 this->fDescent == that.fDescent &&
25 this->fBottom == that.fBottom &&
26 this->fLeading == that.fLeading &&
27 this->fAvgCharWidth == that.fAvgCharWidth &&
28 this->fMaxCharWidth == that.fMaxCharWidth &&
29 this->fXMin == that.fXMin &&
30 this->fXMax == that.fXMax &&
31 this->fXHeight == that.fXHeight &&
32 this->fCapHeight == that.fCapHeight &&
37 }
SkScalar fTop
greatest extent above origin of any glyph bounding box, typically negative; deprecated with variable ...
Definition: SkFontMetrics.h:53
SkScalar fLeading
distance to add between lines, typically positive or zero
Definition: SkFontMetrics.h:57
SkScalar fAvgCharWidth
average character width, zero if unknown
Definition: SkFontMetrics.h:58
SkScalar fMaxCharWidth
maximum character width, zero if unknown
Definition: SkFontMetrics.h:59
SkScalar fBottom
greatest extent below origin of any glyph bounding box, typically positive; deprecated with variable ...
Definition: SkFontMetrics.h:56
SkScalar fAscent
distance to reserve above baseline, typically negative
Definition: SkFontMetrics.h:54
SkScalar fXHeight
height of lower-case 'x', zero if unknown, typically negative
Definition: SkFontMetrics.h:62
SkScalar fDescent
distance to reserve below baseline, typically positive
Definition: SkFontMetrics.h:55
SkScalar fCapHeight
height of an upper-case letter, zero if unknown, typically negative
Definition: SkFontMetrics.h:63
SkScalar fXMin
greatest extent to left of origin of any glyph bounding box, typically negative; deprecated with vari...
Definition: SkFontMetrics.h:60
SkScalar fXMax
greatest extent to right of origin of any glyph bounding box, typically positive; deprecated with var...
Definition: SkFontMetrics.h:61

Member Data Documentation

◆ fAscent

SkScalar SkFontMetrics::fAscent

distance to reserve above baseline, typically negative

Definition at line 54 of file SkFontMetrics.h.

◆ fAvgCharWidth

SkScalar SkFontMetrics::fAvgCharWidth

average character width, zero if unknown

Definition at line 58 of file SkFontMetrics.h.

◆ fBottom

SkScalar SkFontMetrics::fBottom

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

Definition at line 56 of file SkFontMetrics.h.

◆ fCapHeight

SkScalar SkFontMetrics::fCapHeight

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

Definition at line 63 of file SkFontMetrics.h.

◆ fDescent

SkScalar SkFontMetrics::fDescent

distance to reserve below baseline, typically positive

Definition at line 55 of file SkFontMetrics.h.

◆ fFlags

uint32_t SkFontMetrics::fFlags

FontMetricsFlags indicating which metrics are valid.

Definition at line 52 of file SkFontMetrics.h.

◆ fLeading

SkScalar SkFontMetrics::fLeading

distance to add between lines, typically positive or zero

Definition at line 57 of file SkFontMetrics.h.

◆ fMaxCharWidth

SkScalar SkFontMetrics::fMaxCharWidth

maximum character width, zero if unknown

Definition at line 59 of file SkFontMetrics.h.

◆ fStrikeoutPosition

SkScalar SkFontMetrics::fStrikeoutPosition

distance from baseline to bottom of stroke, typically negative

Definition at line 67 of file SkFontMetrics.h.

◆ fStrikeoutThickness

SkScalar SkFontMetrics::fStrikeoutThickness

strikeout thickness

Definition at line 66 of file SkFontMetrics.h.

◆ fTop

SkScalar SkFontMetrics::fTop

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

Definition at line 53 of file SkFontMetrics.h.

◆ fUnderlinePosition

SkScalar SkFontMetrics::fUnderlinePosition

distance from baseline to top of stroke, typically positive

Definition at line 65 of file SkFontMetrics.h.

◆ fUnderlineThickness

SkScalar SkFontMetrics::fUnderlineThickness

underline thickness

Definition at line 64 of file SkFontMetrics.h.

◆ fXHeight

SkScalar SkFontMetrics::fXHeight

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

Definition at line 62 of file SkFontMetrics.h.

◆ fXMax

SkScalar SkFontMetrics::fXMax

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

Definition at line 61 of file SkFontMetrics.h.

◆ fXMin

SkScalar SkFontMetrics::fXMin

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

Definition at line 60 of file SkFontMetrics.h.


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