[]
        
(Showing Draft Content)

GrapeCity.Documents.Text.Font

Class Font

Namespace
GrapeCity.Documents.Text
Assembly
GcDocs.Imaging.dll

Represents a TrueType or OpenType font.

public class Font
Inheritance
object
Font
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()

Properties

AvgCharWidth

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; }

Property Value

int

CanEmbed

Gets a value indicating whether this font can be embedded.

public bool CanEmbed { get; }

Property Value

bool

CanSubset

Gets a value indicating whether this font can be serialized as a subset of the source font data.

public bool CanSubset { get; }

Property Value

bool

CapHeight

Gets the metric specifying the distance between the baseline and the approximate height of uppercase letters measured in FUnits.

public int CapHeight { get; }

Property Value

int

Collection

Gets a value indicating if the font was loaded from .ttc or .otc font collection.

public bool Collection { get; }

Property Value

bool

Compressed

Gets a value indicating if the font is in WOFF format.

public bool Compressed { get; }

Property Value

bool

EnableHinting

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; }

Property Value

bool

FamilyClass

Get the value classifying the font-family design.

public FontFamilyClass FamilyClass { get; }

Property Value

FontFamilyClass

FirstCharCode

Gets the minimum Unicode index (character code) in this font.

public int FirstCharCode { get; }

Property Value

int

Flags

Gets the set of flags describing the font.

public FontFlags Flags { get; }

Property Value

FontFlags

FontBold

Gets the value of the Bold flag from the OS/2 table data.

public bool FontBold { get; }

Property Value

bool

FontData

Gets the source font data (null, if the font loaded from file).

public byte[] FontData { get; }

Property Value

byte[]

FontFamilyName

Get the font family name. Up to four faces can share the same font family name.

public string FontFamilyName { get; }

Property Value

string

FontFileName

Gets the name of the associated font file.

public string FontFileName { get; }

Property Value

string

FontItalic

Gets the value of the Italic flag from the OS/2 table data.

public bool FontItalic { get; }

Property Value

bool

FontOblique

Gets the value of the Oblique flag from the OS/2 table data.

public bool FontOblique { get; }

Property Value

bool

FontPath

Gets the path to the font file.

public string FontPath { get; }

Property Value

string

FontRevision

Gets the revision number set by font manufacturer.

public int FontRevision { get; }

Property Value

int

FullFontName

Gets the full font name that reflects all family and relevant subfamily descriptors.

public string FullFontName { get; }

Property Value

string

HangingBaseline

Gets the hanging baseline, which is used in scripts like Devanagari, in design units relative to the Roman baseline.

public short HangingBaseline { get; }

Property Value

short

Hollow

Gets a value indicating if characters are hollow (outlined), otherwise they are solid.

public bool Hollow { get; }

Property Value

bool

HorizontalAscender

Gets the typographic or legacy ascender for this font.

public int HorizontalAscender { get; }

Property Value

int

HorizontalDescender

Gets the typographic or legacy descender for this font.

public int HorizontalDescender { get; }

Property Value

int

HorizontalHeight

public int HorizontalHeight { get; }

Property Value

int

HorizontalLineGap

Gets the typographic or legacy line gap for this font.

public int HorizontalLineGap { get; }

Property Value

int

HorizontalLineSpacing

Gets the recommended line spacing for single-spaced horizontal text.

public int HorizontalLineSpacing { get; }

Property Value

int

IdeographicCenteredBaseline

Gets the ideographic centered baseline, in design units relative to the Roman baseline.

public short IdeographicCenteredBaseline { get; }

Property Value

short

IdeographicLowBaseline

Gets the ideographic low baseline, in design units relative to the Roman baseline.

public short IdeographicLowBaseline { get; }

Property Value

short

IsColorFont

Gets a value indicating if this font contains color glyphs.

public bool IsColorFont { get; }

Property Value

bool

IsFixedPitch

False if the font is proportionally spaced, True if the font is not proportionally spaced (i.e. monospaced).

public bool IsFixedPitch { get; }

Property Value

bool

IsOrnamentalFont

Gets a value indicating whether the font-family design reflects the ISO Ornamental Class and the ISO Blackletter Class.

public bool IsOrnamentalFont { get; }

Property Value

bool

IsSansSerif

Gets a value indicating whether the font-family design reflects the ISO Sans Serif Class.

public bool IsSansSerif { get; }

Property Value

bool

IsScriptFont

Gets a value indicating whether the font-family design reflects the ISO Script Class and Uncial Class.

public bool IsScriptFont { get; }

Property Value

bool

IsSerifFont

Gets a value indicating whether the font-family design reflects any of the Serif classes, except Sans Serif.

public bool IsSerifFont { get; }

Property Value

bool

IsSymbolicFont

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; }

Property Value

bool

IsVerticalFont

Gets a value indicating if this is a vertical font.

public bool IsVerticalFont { get; }

Property Value

bool

ItalicAngle

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; }

Property Value

float

LastCharCode

Gets the maximum Unicode index (character code) in this font.

public int LastCharCode { get; }

Property Value

int

LastResort

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; }

Property Value

bool

LocalFamilyNames

Gets the array of localized font family names with associated language IDs.

public Font.LocalFamilyName[] LocalFamilyNames { get; }

Property Value

LocalFamilyName[]

LocalFullFontNames

Gets the array of localized font names reflecting all family and relevant subfamily descriptors, with associated language IDs.

public Font.LocalFamilyName[] LocalFullFontNames { get; }

Property Value

LocalFamilyName[]

LocalTypographicFamilyNames

Gets the array of localized names for the typographic family group, with associated language IDs.

public Font.LocalFamilyName[] LocalTypographicFamilyNames { get; }

Property Value

LocalFamilyName[]

MathBaseline

Gets the math baseline, in design units relative to the Roman baseline.

public short MathBaseline { get; }

Property Value

short

Negative

Gets a value indicating if characters have their foreground and background reversed.

public bool Negative { get; }

Property Value

bool

NumGlyphs

Gets the number of glyphs in the Font.

public int NumGlyphs { get; }

Property Value

int

Panose

Gets the 10-byte series of numbers that is used to describe the visual characteristics of a typeface.

public byte[] Panose { get; }

Property Value

byte[]

PermissionToEmbedGranted

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; }

Property Value

bool

PostScript

Gets a value indicating if the current font contains PostScript outlines.

public bool PostScript { get; }

Property Value

bool

PostScriptName

Gets the PostScript name for the font.

public string PostScriptName { get; }

Property Value

string

SmallXHeight

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; }

Property Value

int

Strikeout

Gets a value indicating if characters are overstruck.

public bool Strikeout { get; }

Property Value

bool

StrikethroughPosition

Gets the position of the top of the strikethrough stroke relative to the baseline in font design units.

public short StrikethroughPosition { get; }

Property Value

short

StrikethroughThickness

Gets the thickness of the strikethrough stroke in font design units.

public short StrikethroughThickness { get; }

Property Value

short

SubscriptYOffset

Gets the recommended vertical offset in font design units from the baseline for subscripts for this font.

public int SubscriptYOffset { get; }

Property Value

int

SubscriptYSize

Gets the recommended vertical size in font design units for subscripts for this font.

public int SubscriptYSize { get; }

Property Value

int

SuperscriptYOffset

Gets the recommended vertical offset in font design units from the baseline for superscripts for this font.

public int SuperscriptYOffset { get; }

Property Value

int

SuperscriptYSize

The recommended vertical size in font design units for superscripts for this font.

public int SuperscriptYSize { get; }

Property Value

int

Tag

Gets or sets the custom data associated with the Font.

public object Tag { get; set; }

Property Value

object

TypographicFamilyName

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; }

Property Value

string

UnderlinePosition

Gets the suggested distance of the top of the underline from the baseline (negative values indicate below baseline).

public short UnderlinePosition { get; }

Property Value

short

UnderlineThickness

Gets the suggested value for the underline thickness.

public short UnderlineThickness { get; }

Property Value

short

Underscore

Gets a value indicating if characters are underscored.

public bool Underscore { get; }

Property Value

bool

UnitsPerEm

Gets the design units per Em, valid range is from 16 to 16384.

public int UnitsPerEm { get; }

Property Value

int

UseBitmapCache

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; }

Property Value

bool

Version

Gets the version set by font manufacturer.

public string Version { get; }

Property Value

string

VerticalAscender

Gets the vertical typographic ascender for this font.

public int VerticalAscender { get; }

Property Value

int

VerticalDescender

Gets the vertical typographic descender for this font.

public int VerticalDescender { get; }

Property Value

int

VerticalLineGap

Gets the vertical typographic gap for this font.

public int VerticalLineGap { get; }

Property Value

int

VerticalLineSpacing

Gets the recommended line spacing for single-spaced vertical text.

public int VerticalLineSpacing { get; }

Property Value

int

VerticalWidth

Gets the sum of VerticalAscender and VerticalDescender.

public int VerticalWidth { get; }

Property Value

int

WeightClass

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; }

Property Value

int

WidthClass

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; }

Property Value

int

Methods

AddEudcFont(Font, float?)

Associates user-defined characters from the specified EUDC Font to the current font.

public bool AddEudcFont(Font eudcFont, float? scaleFactor = null)

Parameters

eudcFont Font

The 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.

Returns

bool

True if the font was successfully associated, False if the same font is already in the list of linked EUDC fonts.

AddLinkedFont(Font, float?)

Adds a link to the specified Font.

public bool AddLinkedFont(Font linkedFont, float? scaleFactor = null)

Parameters

linkedFont Font

The 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.

Returns

bool

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)

Parameters

codePoint int

The code point (in UTF-32 format) missing in the current font.

embeddable bool

Specifies whether the searched font should support embedding.

Returns

FontLink

EUDC font's FontLink or null.

ChooseLinkedFont(int, bool)

Searches for a linked Font containing the given code point.

public FontLink ChooseLinkedFont(int codePoint, bool embeddable)

Parameters

codePoint int

The code point (in UTF-32 format) missing in the current font.

embeddable bool

Specifies whether the searched font should support embedding.

Returns

FontLink

Linked font's FontLink or null.

Clears the list of the associated EUDC Fonts.

public void ClearEudcFontLinks()

ClearLinkedFonts()

Clears the list of the linked Fonts.

public void ClearLinkedFonts()

CollectionFromArray(byte[], List<Font>, bool)

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)

Parameters

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 bool

Set this parameter to True if you're planning to add the loaded fonts to the fallback font collection.

Returns

int

The number of loaded fonts.

CollectionFromFile(string, List<Font>, bool)

Loads all Fonts from a specified font file.

public static int CollectionFromFile(string path, List<Font> fonts, bool initCodeMap = false)

Parameters

path string

The 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 bool

Set this parameter to True if you're planning to add the loaded fonts to the fallback font collection.

Returns

int

The number of loaded fonts.

CollectionFromStream(Stream, List<Font>, int, bool)

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)

Parameters

stream System.IO.Stream

The stream containing the font data.

fonts System.Collections.Generic.List<T><Font>

The destination list of fonts. It must be initialized beforehand.

bytesToRead int

The number of bytes to read from the stream; -1 causes reading till the end of stream.

initCodeMap bool

Set this parameter to True if you're planning to add the loaded fonts to the fallback font collection.

Returns

int

The number of loaded fonts.

ContainsCodePoint(int)

Returns a value indicating whether the font can map the specified code point to a glyph.

public bool ContainsCodePoint(int codePoint)

Parameters

codePoint int

Returns

bool

CreateFontTables(params TableTag[])

Creates 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)

Parameters

tags TableTag[]

Returns

FontTables

FromArray(byte[], bool)

Loads the first Font from a byte array.

public static Font FromArray(byte[] fontData, bool initCodeMap = false)

Parameters

fontData byte[]

The byte array with the font data.

initCodeMap bool

Set this parameter to True if you're planning to add the font to the fallback font collection.

Returns

Font

The newly created font, or null if the file did not contain any fonts.

FromArray(byte[], string)

Loads a Font with given full font name from a byte array.

public static Font FromArray(byte[] fontData, string fullFontName)

Parameters

fontData byte[]

The byte array with the font data.

fullFontName string

The full font name to be loaded.

Returns

Font

The newly created font.

FromFile(string, bool)

Loads the first Font from a specified file.

public static Font FromFile(string path, bool initCodeMap = false)

Parameters

path string

The path to the file containing the font data.

initCodeMap bool

Set this parameter to True if you're planning to add the font to the fallback font collection.

Returns

Font

The newly created font, or null if the file did not contain any fonts.

FromFile(string, string)

Loads a Font with given full font name from a specified file.

public static Font FromFile(string path, string fullFontName)

Parameters

path string

The path to the file containing the font data.

fullFontName string

The full font name to be loaded.

Returns

Font

The newly created font.

FromStream(Stream, int, bool)

Loads a Font from the specified stream.

public static Font FromStream(Stream stream, int bytesToRead = -1, bool initCodeMap = false)

Parameters

stream System.IO.Stream

The stream containing the font data.

bytesToRead int

The number of bytes to read from the stream; -1 causes reading till the end of stream.

initCodeMap bool

Set this parameter to True if you're planning to add the font to the fallback font collection.

Returns

Font

The newly created font, or null if the stream did not contain any fonts.

FromStream(Stream, string, int)

Loads a Font with given full font name from a specified stream.

public static Font FromStream(Stream stream, string fullFontName, int bytesToRead = -1)

Parameters

stream System.IO.Stream

The stream containing the font data.

fullFontName string

The full font name to be loaded.

bytesToRead int

The number of bytes to read from the stream; -1 causes reading till the end of stream.

Returns

Font

The newly created font.

Gets a snapshot of the internal list of links to the associated EUDC fonts.

public FontLink[] GetEudcFontLinks()

Returns

FontLink[]

GetLinkedFonts()

Gets a snapshot of the internal list of linked fonts.

public FontLink[] GetLinkedFonts()

Returns

FontLink[]

GetLocalFamilyName(int)

Returns the localized version of font family name for the specified language ID.

public string GetLocalFamilyName(int languageID)

Parameters

languageID int

The language ID to search for.

Returns

string

Gets a value indicating whether the font has the associated EUDC Fonts.

public bool HasEudcFontLinks()

Returns

bool

HasLinkedFonts()

Gets a value indicating whether the font has linked Fonts.

public bool HasLinkedFonts()

Returns

bool

MatchFontFamilyName(string)

Returns True if the specified string matches the font family name or its local equivalent.

public bool MatchFontFamilyName(string fontFamilyName)

Parameters

fontFamilyName string

Returns

bool

RemoveEudcFont(Font)

Removes association to the specified EUDC Font from the current font.

public bool RemoveEudcFont(Font eudcFont)

Parameters

eudcFont Font

The EUDC Font with missing user-defined characters.

Returns

bool

True if the association was successfully removed, False if it was not found.

RemoveLinkedFont(Font)

Removes a link to the specified Font.

public bool RemoveLinkedFont(Font linkedFont)

Parameters

linkedFont Font

The Font to be removed from the list of linked fonts.

Returns

bool

True if the link was successfully removed, False if it was not found.

TestCodePageRange(int)

Checks whether the specified code page character range is considered functional (see Os2CodePageRange).

public bool TestCodePageRange(int codePageRangeIndex)

Parameters

codePageRangeIndex int

Index of the range (between 0 and 63).

Returns

bool

TestUnicodeRange(int)

Checks whether the specified Unicode range is considered functional (see Os2UnicodeRange).

public bool TestUnicodeRange(int unicodeRangeIndex)

Parameters

unicodeRangeIndex int

Index of the range (between 0 and 127).

Returns

bool

ToString()

Returns a string that represents the Font.

public override string ToString()

Returns

string