[]
Represents a TrueType or OpenType font.
public class Font
Gets the Average Character Width parameter specifies the arithmetic average of the escapement (width) of all non-zero width glyphs in the font.
public int AvgCharWidth { get; }
Gets a value indicating whether this font can be embedded.
public bool CanEmbed { get; }
Gets a value indicating whether this font can be serialized as a subset of the source font data.
public bool CanSubset { get; }
Gets the metric specifying the distance between the baseline and the approximate height of uppercase letters measured in FUnits.
public int CapHeight { get; }
Gets a value indicating if the font was loaded from .ttc or .otc font collection.
public bool Collection { get; }
Gets a value indicating if the font is in WOFF format.
public bool Compressed { get; }
Gets or sets a value indicating if the TrueType glyph hinting instructions can be executed.
By default hinting instructions are enabled, but note that only some TrueType fonts include such instructions. For fonts that do not include glyph instructions, this property will always return false.
Also note that this property affects text drawing on GcBitmapGraphics only.
public bool EnableHinting { get; set; }
Get the value classifying the font-family design.
public FontFamilyClass FamilyClass { get; }
Gets the minimum Unicode index (character code) in this font.
public int FirstCharCode { get; }
Gets the set of flags describing the font.
public FontFlags Flags { get; }
Gets the value of the Bold flag from the OS/2 table data.
public bool FontBold { get; }
Gets the source font data (null, if the font loaded from file).
public byte[] FontData { get; }
Get the font family name. Up to four faces can share the same font family name.
public string FontFamilyName { get; }
Gets the name of the associated font file.
public string FontFileName { get; }
Gets the value of the Italic flag from the OS/2 table data.
public bool FontItalic { get; }
Gets the value of the Oblique flag from the OS/2 table data.
public bool FontOblique { get; }
Gets the path to the font file.
public string FontPath { get; }
Gets the revision number set by font manufacturer.
public int FontRevision { get; }
Gets the full font name that reflects all family and relevant subfamily descriptors.
public string FullFontName { get; }
Gets the hanging baseline, which is used in scripts like Devanagari, in design units relative to the Roman baseline.
public short HangingBaseline { get; }
Gets a value indicating if characters are hollow (outlined), otherwise they are solid.
public bool Hollow { get; }
Gets the typographic or legacy ascender for this font.
public int HorizontalAscender { get; }
Gets the typographic or legacy descender for this font.
public int HorizontalDescender { get; }
Gets the sum of HorizontalAscender and HorizontalDescender.
public int HorizontalHeight { get; }
Gets the typographic or legacy line gap for this font.
public int HorizontalLineGap { get; }
Gets the recommended line spacing for single-spaced horizontal text.
public int HorizontalLineSpacing { get; }
Gets the ideographic centered baseline, in design units relative to the Roman baseline.
public short IdeographicCenteredBaseline { get; }
Gets the ideographic low baseline, in design units relative to the Roman baseline.
public short IdeographicLowBaseline { get; }
Gets a value indicating if this font contains color glyphs.
public bool IsColorFont { get; }
False if the font is proportionally spaced, True if the font is not proportionally spaced (i.e. monospaced).
public bool IsFixedPitch { get; }
Gets a value indicating whether the font-family design reflects the ISO Ornamental Class and the ISO Blackletter Class.
public bool IsOrnamentalFont { get; }
Gets a value indicating whether the font-family design reflects the ISO Sans Serif Class.
public bool IsSansSerif { get; }
Gets a value indicating whether the font-family design reflects the ISO Script Class and Uncial Class.
public bool IsScriptFont { get; }
Gets a value indicating whether the font-family design reflects any of the Serif classes, except Sans Serif.
public bool IsSerifFont { get; }
Gets a value indicating whether this is a symbolic font suitable for Pi and special characters (icons, dingbats, technical symbols, etc.)
public bool IsSymbolicFont { get; }
Gets a value indicating if this is a vertical font.
public bool IsVerticalFont { get; }
Gets the italic angle in counter-clockwise degrees from the vertical. Zero for upright text, negative for text that leans to the right (forward).
public float ItalicAngle { get; }
Gets the maximum Unicode index (character code) in this font.
public int LastCharCode { get; }
Gets a value indicating if the glyphs encoded in the cmap subtables are simply generic symbolic representations of code point ranges and don’t truly represent support for those code points.
public bool LastResort { get; }
Gets the array of localized font family names with associated language IDs.
public Font.LocalFamilyName[] LocalFamilyNames { get; }
Gets the array of localized font names reflecting all family and relevant subfamily descriptors, with associated language IDs.
public Font.LocalFamilyName[] LocalFullFontNames { get; }
Gets the array of localized names for the typographic family group, with associated language IDs.
public Font.LocalFamilyName[] LocalTypographicFamilyNames { get; }
Gets the math baseline, in design units relative to the Roman baseline.
public short MathBaseline { get; }
Gets a value indicating if characters have their foreground and background reversed.
public bool Negative { get; }
Gets the number of glyphs in the Font.
public int NumGlyphs { get; }
Gets the 10-byte series of numbers that is used to describe the visual characteristics of a typeface.
public byte[] Panose { get; }
Gets or sets a value indicating that the developer of the software has obtained explicit permission from the legal owner of the font to embed it in documents produced by the software.
See https://learn.microsoft.com/en-us/typography/opentype/spec/os2#fstype for details.
The default is false.
public bool PermissionToEmbedGranted { get; set; }
Gets a value indicating if the current font contains PostScript outlines.
public bool PostScript { get; }
Gets the PostScript name for the font.
public string PostScriptName { get; }
Gets the metric specifying the distance between the baseline and the approximate height of non-ascending lowercase letters measured in FUnits.
public int SmallXHeight { get; }
Gets a value indicating if characters are overstruck.
public bool Strikeout { get; }
Gets the position of the top of the strikethrough stroke relative to the baseline in font design units.
public short StrikethroughPosition { get; }
Gets the thickness of the strikethrough stroke in font design units.
public short StrikethroughThickness { get; }
Gets the recommended vertical offset in font design units from the baseline for subscripts for this font.
public int SubscriptYOffset { get; }
Gets the recommended vertical size in font design units for subscripts for this font.
public int SubscriptYSize { get; }
Gets the recommended vertical offset in font design units from the baseline for superscripts for this font.
public int SuperscriptYOffset { get; }
The recommended vertical size in font design units for superscripts for this font.
public int SuperscriptYSize { get; }
Gets or sets the custom data associated with the Font.
public object Tag { get; set; }
Gets the typographic family grouping name.
The typographic family grouping doesn't impose any constraints on the number of faces within it, in contrast with the 4-style family grouping.
public string TypographicFamilyName { get; }
Gets the suggested distance of the top of the underline from the baseline (negative values indicate below baseline).
public short UnderlinePosition { get; }
Gets the suggested value for the underline thickness.
public short UnderlineThickness { get; }
Gets a value indicating if characters are underscored.
public bool Underscore { get; }
Gets the design units per Em, valid range is from 16 to 16384.
public int UnitsPerEm { get; }
Gets or sets a value indicating if the Bitmap Glyph Cache is enabled.
This property affects text drawing on GcBitmapGraphics only.
public bool UseBitmapCache { get; set; }
Gets the version set by font manufacturer.
public string Version { get; }
Gets the vertical typographic ascender for this font.
public int VerticalAscender { get; }
Gets the vertical typographic descender for this font.
public int VerticalDescender { get; }
Gets the vertical typographic gap for this font.
public int VerticalLineGap { get; }
Gets the recommended line spacing for single-spaced vertical text.
public int VerticalLineSpacing { get; }
Gets the sum of VerticalAscender and VerticalDescender.
public int VerticalWidth { get; }
Get the value indicating the visual weight (degree of blackness or thickness of strokes) of the characters in the font.
Values from 1 to 1000 are valid.
public int WeightClass { get; }
Get the value indicating a relative change from the normal aspect ratio (width to height ratio) for the glyphs in a font.
Values from 1 (UltraCondensed) to 9 (UltraExpanded) are expected.
public int WidthClass { get; }
Associates user-defined characters from the specified EUDC Font to the current font.
public bool AddEudcFont(Font eudcFont, float? scaleFactor = null)
eudcFont
FontThe EUDC Font with missing user-defined characters.
scaleFactor
float?The scale factor applied to size of the base font when the EUDC font is used instead.
True if the font was successfully associated, False if the same font is already in the list of linked EUDC fonts.
Adds a link to the specified Font.
public bool AddLinkedFont(Font linkedFont, float? scaleFactor = null)
linkedFont
FontThe Font to be added as linked font.
scaleFactor
float?The scale factor applied to size of the base font when the linked font is used instead.
True if the link was successfully added, False if the same font is already linked.
Searches for an associated EUDC Font containing the given code point.
public FontLink ChooseEudcFontLink(int codePoint, bool embeddable)
codePoint
intThe code point (in UTF-32 format) missing in the current font.
embeddable
boolSpecifies whether the searched font should support embedding.
Searches for a linked Font containing the given code point.
public FontLink ChooseLinkedFont(int codePoint, bool embeddable)
codePoint
intThe code point (in UTF-32 format) missing in the current font.
embeddable
boolSpecifies whether the searched font should support embedding.
Clears the list of the associated EUDC Fonts.
public void ClearEudcFontLinks()
Clears the list of the linked Fonts.
public void ClearLinkedFonts()
Loads all Fonts from a byte array containing single font or a font collection.
public static int CollectionFromArray(byte[] fontData, List<Font> fonts, bool initCodeMap = false)
fontData
byte[]The byte array with the font data.
fonts
System.Collections.Generic.List<T><Font>The destination list of fonts. It must be initialized beforehand.
initCodeMap
boolSet this parameter to True if you're planning to add the loaded fonts to the fallback font collection.
The number of loaded fonts.
Loads all Fonts from a specified font file.
public static int CollectionFromFile(string path, List<Font> fonts, bool initCodeMap = false)
path
stringThe path to the file containing the font data.
fonts
System.Collections.Generic.List<T><Font>The destination list of fonts. It must be initialized beforehand.
initCodeMap
boolSet this parameter to True if you're planning to add the loaded fonts to the fallback font collection.
The number of loaded fonts.
Loads all Fonts from a specified stream containing single font or a font collection.
public static int CollectionFromStream(Stream stream, List<Font> fonts, int bytesToRead = -1, bool initCodeMap = false)
stream
System.IO.StreamThe stream containing the font data.
fonts
System.Collections.Generic.List<T><Font>The destination list of fonts. It must be initialized beforehand.
bytesToRead
intThe number of bytes to read from the stream; -1 causes reading till the end of stream.
initCodeMap
boolSet this parameter to True if you're planning to add the loaded fonts to the fallback font collection.
The number of loaded fonts.
Returns a value indicating whether the font can map the specified code point to a glyph.
public bool ContainsCodePoint(int codePoint)
codePoint
intCreates an instance of the FontTables class for this font with the specified set of OpenType tables. Used to access information contained in the font's OpenType tables.
public FontTables CreateFontTables(params TableTag[] tags)
tags
TableTag[]Loads the first Font from a byte array.
public static Font FromArray(byte[] fontData, bool initCodeMap = false)
fontData
byte[]The byte array with the font data.
initCodeMap
boolSet this parameter to True if you're planning to add the font to the fallback font collection.
The newly created font, or null if the file did not contain any fonts.
Loads a Font with given full font name from a byte array.
public static Font FromArray(byte[] fontData, string fullFontName)
fontData
byte[]The byte array with the font data.
fullFontName
stringThe full font name to be loaded.
The newly created font.
Loads the first Font from a specified file.
public static Font FromFile(string path, bool initCodeMap = false)
path
stringThe path to the file containing the font data.
initCodeMap
boolSet this parameter to True if you're planning to add the font to the fallback font collection.
The newly created font, or null if the file did not contain any fonts.
Loads a Font with given full font name from a specified file.
public static Font FromFile(string path, string fullFontName)
path
stringThe path to the file containing the font data.
fullFontName
stringThe full font name to be loaded.
The newly created font.
Loads a Font from the specified stream.
public static Font FromStream(Stream stream, int bytesToRead = -1, bool initCodeMap = false)
stream
System.IO.StreamThe stream containing the font data.
bytesToRead
intThe number of bytes to read from the stream; -1 causes reading till the end of stream.
initCodeMap
boolSet this parameter to True if you're planning to add the font to the fallback font collection.
The newly created font, or null if the stream did not contain any fonts.
Loads a Font with given full font name from a specified stream.
public static Font FromStream(Stream stream, string fullFontName, int bytesToRead = -1)
stream
System.IO.StreamThe stream containing the font data.
fullFontName
stringThe full font name to be loaded.
bytesToRead
intThe number of bytes to read from the stream; -1 causes reading till the end of stream.
The newly created font.
Gets a snapshot of the internal list of links to the associated EUDC fonts.
public FontLink[] GetEudcFontLinks()
Gets a snapshot of the internal list of linked fonts.
public FontLink[] GetLinkedFonts()
Returns the localized version of font family name for the specified language ID.
public string GetLocalFamilyName(int languageID)
languageID
intThe language ID to search for.
Gets a value indicating whether the font has the associated EUDC Fonts.
public bool HasEudcFontLinks()
Gets a value indicating whether the font has linked Fonts.
public bool HasLinkedFonts()
Returns True if the specified string matches the font family name or its local equivalent.
public bool MatchFontFamilyName(string fontFamilyName)
fontFamilyName
stringRemoves association to the specified EUDC Font from the current font.
public bool RemoveEudcFont(Font eudcFont)
True if the association was successfully removed, False if it was not found.
Removes a link to the specified Font.
public bool RemoveLinkedFont(Font linkedFont)
True if the link was successfully removed, False if it was not found.
Checks whether the specified code page character range is considered functional (see Os2CodePageRange).
public bool TestCodePageRange(int codePageRangeIndex)
codePageRangeIndex
intIndex of the range (between 0 and 63).
Checks whether the specified Unicode range is considered functional (see Os2UnicodeRange).
public bool TestUnicodeRange(int unicodeRangeIndex)
unicodeRangeIndex
intIndex of the range (between 0 and 127).
Returns a string that represents the Font.
public override string ToString()