FontMetrics

class FontMetrics

The metrics of an Font.

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

Classes

FontMetricsFlags

FontMetricsFlags indicate when certain metrics are valid; the underline or

Methods

__init__

__init__(self: skia.FontMetrics) -> None

hasStrikeoutPosition

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

hasStrikeoutThickness

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

hasUnderlinePosition

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

hasUnderlineThickness

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

Attributes

fAscent

distance to reserve above baseline, typically negative

fAvgCharWidth

average character width, zero if unknown

fBottom

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

fCapHeight

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

fDescent

distance to reserve below baseline, typically positive

fFlags

FontMetricsFlags indicating which metrics are valid.

fLeading

distance to add between lines, typically positive or zero

fMaxCharWidth

maximum character width, zero if unknown

fStrikeoutPosition

distance from baseline to bottom of stroke, typically negative

fStrikeoutThickness

strikeout thickness

fTop

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

fUnderlinePosition

distance from baseline to top of stroke, typically positive

fUnderlineThickness

underline thickness

fXHeight

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

fXMax

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

fXMin

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

kStrikeoutPositionIsValid_Flag

kStrikeoutThicknessIsValid_Flag

kUnderlinePositionIsValid_Flag

kUnderlineThicknessIsValid_Flag

Methods

FontMetrics.__init__(self: skia.FontMetrics) None

__init__(self: skia.FontMetrics) -> None

FontMetrics.hasStrikeoutPosition(self: skia.FontMetrics, position: float) bool

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

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

Parameters

position (float) – storage for strikeout position

Returns

true if font specifies strikeout position

FontMetrics.hasStrikeoutThickness(self: skia.FontMetrics, thickness: float) bool

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

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

Parameters

thickness (float) – storage for strikeout width

Returns

true if font specifies strikeout width

FontMetrics.hasUnderlinePosition(self: skia.FontMetrics, position: float) bool

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

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

Parameters

position (float) – storage for underline position

Returns

true if font specifies underline position

FontMetrics.hasUnderlineThickness(self: skia.FontMetrics, thickness: float) bool

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

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

Parameters

thickness – storage for underline width

Returns

true if font specifies underline width

Attributes

FontMetrics.fAscent

distance to reserve above baseline, typically negative

FontMetrics.fAvgCharWidth

average character width, zero if unknown

FontMetrics.fBottom

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

FontMetrics.fCapHeight

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

FontMetrics.fDescent

distance to reserve below baseline, typically positive

FontMetrics.fFlags

FontMetricsFlags indicating which metrics are valid.

FontMetrics.fLeading

distance to add between lines, typically positive or zero

FontMetrics.fMaxCharWidth

maximum character width, zero if unknown

FontMetrics.fStrikeoutPosition

distance from baseline to bottom of stroke, typically negative

FontMetrics.fStrikeoutThickness

strikeout thickness

FontMetrics.fTop

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

FontMetrics.fUnderlinePosition

distance from baseline to top of stroke, typically positive

FontMetrics.fUnderlineThickness

underline thickness

FontMetrics.fXHeight

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

FontMetrics.fXMax

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

FontMetrics.fXMin

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

FontMetrics.kStrikeoutPositionIsValid_Flag = <FontMetricsFlags.kStrikeoutPositionIsValid_Flag: 8>
FontMetrics.kStrikeoutThicknessIsValid_Flag = <FontMetricsFlags.kStrikeoutThicknessIsValid_Flag: 4>
FontMetrics.kUnderlinePositionIsValid_Flag = <FontMetricsFlags.kUnderlinePositionIsValid_Flag: 2>
FontMetrics.kUnderlineThicknessIsValid_Flag = <FontMetricsFlags.kUnderlineThicknessIsValid_Flag: 1>