Class FontMetrics
Concrete, mutable implementation of IFontMetrics. Table parsers set the properties directly; glyph-width queries are delegated to a resolver function supplied at construction time.
Implements
Inherited Members
Namespace: DRIT.Drawing.Font.Core
Assembly: DRIT.Drawing.dll
Syntax
public sealed class FontMetrics : IFontMetrics
Constructors
FontMetrics(Func<GlyphId, double>)
Concrete, mutable implementation of IFontMetrics. Table parsers set the properties directly; glyph-width queries are delegated to a resolver function supplied at construction time.
Declaration
public FontMetrics(Func<GlyphId, double> glyphWidthResolver)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<GlyphId, double> | glyphWidthResolver | A function that, given a GlyphId, returns the advance width of that glyph in design units. Called once per unique glyph; callers are responsible for caching if needed. |
Properties
Ascender
Maximum ascender value above the baseline, in design units (from hhea.Ascender).
Declaration
public double Ascender { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Descender
Maximum descender value below the baseline, in design units (from hhea.Descender, typically negative).
Declaration
public double Descender { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
LineGap
Line gap (leading) recommended by the font, in design units (from hhea.LineGap).
Declaration
public double LineGap { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
StrikeoutPosition
Distance from the baseline to the top of the strikeout stroke, in design units (from OS/2 yStrikeoutPosition). Positive values are above the baseline.
Declaration
public double StrikeoutPosition { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
StrikeoutSize
Thickness of the strikeout stroke, in design units (from OS/2 yStrikeoutSize).
Declaration
public double StrikeoutSize { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
TypoAscender
Typographic ascender from the OS/2 sTypoAscender field, in design units.
Declaration
public double TypoAscender { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
TypoDescender
Typographic descender from the OS/2 sTypoDescender field, in design units (typically negative).
Declaration
public double TypoDescender { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
UnderlinePosition
Offset of the top of the underline stroke from the baseline, in design units (from the 'post' table). Negative values place the underline below the baseline.
Declaration
public double UnderlinePosition { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
UnderlineThickness
Thickness of the underline stroke, in design units (from the 'post' table).
Declaration
public double UnderlineThickness { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
UnitsPerEM
Number of design units that make up one em square.
Declaration
public double UnitsPerEM { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Methods
GetGlyphWidth(GlyphId)
Returns the horizontal advance width of the glyph identified by
glyphId, in design units.
Declaration
public double GetGlyphWidth(GlyphId glyphId)
Parameters
| Type | Name | Description |
|---|---|---|
| GlyphId | glyphId |
Returns
| Type | Description |
|---|---|
| double |