AfmTextMeasurer Class

Measures text with the metrics of Helvetica and Helvetica-Bold, the standard fonts of PDF, without any font file or system font: the measurement is the same on every machine.

public sealed class AfmTextMeasurer : ITextMeasurer

Remarks

The characters are mapped to the glyphs of the font through the Adobe Glyph List, and the kerning pairs of the font are applied. The text is measured by grapheme cluster: a character the font lacks counts as 1 em when it is wide (East Asian width Wide or Fullwidth, such as CJK ideographs and most emoji), as nothing when it is a combining mark, and as the average width of the font otherwise.

Arial and Liberation Sans have the same widths as Helvetica, so the text the SVG draws with Helvetica, Arial, sans-serif fits the layout.

Implements

Properties

NameDescription
DefaultGets the measurer. It is thread-safe.
FontFamilyGets Helvetica, Arial, sans-serif.

Gets the measurer. It is thread-safe.

public static AfmTextMeasurer Default { get; }

Property value

AfmTextMeasurer

Gets Helvetica, Arial, sans-serif.

public string FontFamily { get; }

Property value

string

Methods

NameDescription
Measure(string, ChartFont)Measures a line of text.

Measure(string, ChartFont)

AfmTextMeasurer.cs

Measures a line of text.

public TextMetrics Measure(string text, ChartFont font)

Parameters

text string
The text, on one line.
font ChartFont
The size and the weight of the font.

Returns

TextMetrics The dimensions of the text.