Font Metrics
Adds font to FontRegistry from file and shows its metrics.
Сode Snippet
using (var fontRegistry = new CustomFontRegistry())
{
var fontSize = 30f;
var dpi = 150f;
// Load custom OpenType font
var postscriptName = fontRegistry.Add("Amburegul.otf");
var font = fontRegistry.CreateFont(postscriptName, fontSize, dpi, dpi);
// Font metrics
Console.WriteLine("Font: {0} {1}", font.Family, font.Style);
Console.WriteLine(" DPI (X,Y): {0},{0}", dpi);
Console.WriteLine(" Size: {0}pt", fontSize);
Console.WriteLine(" Ascender: {0}px", font.Metrics.Ascender);
Console.WriteLine(" Descender: {0}px", font.Metrics.Descender);
Console.WriteLine(" Height: {0}px", font.Metrics.Height);
Console.WriteLine(" Underline position: {0}px", font.Metrics.UnderlinePosition);
Console.WriteLine(" Underline thickness: {0}px", font.Metrics.UnderlineThickness);
Console.WriteLine();
}
Input
Amburegul.otf
DownloadOutput
FontMetrics.txt
Font: Amburegul Regular
DPI (X,Y): 150,150
Size: 30pt
Ascender: 50px
Descender: -13px
Height: 68px
Underline position: -9.375px
Underline thickness: 3.125px
For AI-assisted development: Download Graphics Mill Code Samples XML Catalog