[]
Represents a collection of Font objects.
public class FontCollection : Collection<Font>, IList, ICollection, IReadOnlyList<Font>, IReadOnlyCollection<Font>, IFontCollection, IList<Font>, ICollection<Font>, IEnumerable<Font>, IEnumerable
Initializes a new instance of the FontCollection class.
public FontCollection()
Gets or sets the default font.
public Font DefaultFont { get; set; }
Gets an object that can be used to synchronize access to the FontCollection.
public object SyncRoot { get; }
Gets the collection of system fonts.
public static SystemFontCollection SystemFonts { get; }
Appends one or more font family names to the internal list of fallback font families.
public void AppendFallbackFontFamilies(params string[] fontFamilyNames)
fontFamilyNames
string[]Appends one or more fonts to the internal fallback font list.
public void AppendFallbackFonts(params Font[] fonts)
fonts
Font[]Appends fonts from the specified list to the collection.
public void AppendFonts(IList<Font> list, bool addToFallbacks)
list
System.Collections.Generic.IList<T><Font>The list with fonts.
addToFallbacks
boolSpecifies if the fonts should be added to the fallback font collection as well.
Searches for a fallback font containing the given code point that looks similar to the source font.
public Font ChooseFallbackFont(int codePoint, Font baseFont, bool bold, bool italic, bool vertical = false, bool embeddable = false, bool allowEudc = false)
codePoint
intThe code point (in UTF-32 format) missing in the source font.
baseFont
FontThe source font to be replaced by a fallback font.
bold
boolIndicates if the font should be bold.
italic
boolIndicates if the font should contain italic characters.
vertical
boolIndicates if the font should be vertical.
embeddable
boolIndicates if the searched font should support embedding.
allowEudc
boolIndicates if the linked EUDC fonts can be searched as well.
Clears the internal list of fallback font families.
public void ClearFallbackFontFamilies()
Clears the internal list of fallback fonts.
public void ClearFallbackFonts()
Removes all elements from the FontCollection.
protected override void ClearItems()
Creates a copy of the current FontCollection.
public FontCollection Clone()
Searches for a font with the specified family name and style.
public Font FindFamilyName(string fontFamilyName, bool bold = false, bool italic = false)
fontFamilyName
stringThe font family name. Up to four fonts can share the same font family name.
bold
boolIndicates whether the font should be bold.
italic
boolIndicates whether the font should contain Italic characters.
Searches for a font from the set of allowable font family names and the specified style.
public Font FindFamilyName(string[] fontFamilyNames, bool bold = false, bool italic = false)
fontFamilyNames
string[]The array of allowable font family name.
bold
boolIndicates if the font should be bold.
italic
boolIndicates if the font should contain Italic characters.
Searches for the first font having the specified file name.
public Font FindFileName(string fontFileName)
fontFileName
stringSearches for the first font having the specified font path.
public Font FindFontPath(string fontPath)
fontPath
stringSearches for the first font with specified full name.
Full font name that reflects all family and relevant subfamily descriptors.
public Font FindFullName(string fullFontName)
fullFontName
stringGets a snapshot of the internal list of fallback font families.
public string[] GetFallbackFontFamilies()
Gets a snapshot of the internal fallback font list.
public Font[] GetFallbackFonts()
Inserts an element into the FontCollection at the specified index.
protected override void InsertItem(int index, Font item)
index
intitem
FontLoads all fonts from a specified byte array into the collection.
Use the RegisterFont(string, bool) method if there is a font file.
public int LoadFonts(byte[] fontData, bool addToFallbacks = false)
fontData
byte[]The byte array with the font data.
addToFallbacks
boolSpecifies if all the registered fonts should be added to the fallback font collection.
The number of loaded fonts.
Loads all fonts from the specified stream into the collection.
Use the RegisterFont(string, bool) method if there is a font file.
public int LoadFonts(Stream stream, int bytesToRead = -1, bool addToFallbacks = 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.
addToFallbacks
boolSpecifies if all the registered fonts should be added to the fallback font collection.
The number of loaded fonts.
Appends all fonts (*.ttf, *.otf, *.ttc files) from the specified folder to the FontCollection.
public int RegisterDirectory(string folderPath, bool addToFallbacks = false)
folderPath
stringPath to the source directory with fonts.
addToFallbacks
boolSpecifies if all the registered fonts should be added to the fallback font collection.
The number of registered fonts.
Appends all fonts from the specified font file to the collection.
public int RegisterFont(string fontPath, bool addToFallbacks = false)
fontPath
stringPath to the source font file.
addToFallbacks
boolSpecifies if all the registered fonts should be added to the fallback font collection.
The number of registered fonts.
Removes one or more font family names from the internal list of fallback font families.
public void RemoveFallbackFontFamilies(params string[] fontFamilyNames)
fontFamilyNames
string[]Removes one or more fonts from the internal fallback font list.
public void RemoveFallbackFonts(params Font[] fonts)
fonts
Font[]Removes the element at the specified index of the FontCollection.
protected override void RemoveItem(int index)
index
intCollects the fonts with the specified family name.
public void SelectByFamilyName(string fontFamilyName, List<Font> res)
fontFamilyName
stringres
System.Collections.Generic.List<T><Font>Returns the list of fonts with the specified family name.
public List<Font> SelectByFamilyName(string fontFamilyName)
fontFamilyName
stringCollects the fonts having the same specified file name.
public void SelectByFileName(string fontFileName, List<Font> res)
fontFileName
stringres
System.Collections.Generic.List<T><Font>Returns the list of fonts having the same specified file name.
public List<Font> SelectByFileName(string fontFileName)
fontFileName
stringCollects the fonts having the same specified font path.
public void SelectByFontPath(string fontPath, List<Font> res)
fontPath
stringres
System.Collections.Generic.List<T><Font>Returns the list of fonts having the same specified font path.
public List<Font> SelectByFontPath(string fontPath)
fontPath
stringCollects the fonts with the specified full name.
Full font name that reflects all family and relevant subfamily descriptors.
public void SelectByFullName(string fullFontName, List<Font> res)
fullFontName
stringres
System.Collections.Generic.List<T><Font>Returns the list of fonts with the specified full name.
Full font name that reflects all family and relevant subfamily descriptors.
public List<Font> SelectByFullName(string fullFontName)
fullFontName
stringCollects the fonts with the specified typographic family 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 void SelectByTypographicFamilyName(string typographicFamilyName, List<Font> res)
typographicFamilyName
stringres
System.Collections.Generic.List<T><Font>Returns the list of fonts with the specified typographic family 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 List<Font> SelectByTypographicFamilyName(string typographicFamilyName)
typographicFamilyName
stringReplaces the element at the specified index.
protected override void SetItem(int index, Font item)
index
intitem
Font