SceneFontCollection Class
The fonts of a scene: the faces of one or more families. The layout measures each text with them (FontFaceTextMeasurer), and the renderers draw it with them (Scene.Fonts), so each text is measured and drawn with the same font.
public sealed class SceneFontCollectionRemarks
The family of a text is SceneFont.Family, or the family of the scene when it is null. It is a CSS font-family value: the first family of the list the collection has is used, and SceneFontCollection.DefaultFamily when it has none of them. Within the family, the face closest to the style of the text is used: the same slant first, then the nearest weight (SceneFont.Weight).
The characters the face of the text does not have are drawn with the other families of the collection, in the order they were added: each grapheme cluster uses the first face that has all its characters.
A collection is immutable and can be used by several threads at the same time.
Constructors
| Name | Description |
|---|---|
| SceneFontCollection(IEnumerable<SceneFontFace>) | Initializes a new instance of the SceneFontCollection class. The default family is the family of the first face. |
| SceneFontCollection(IEnumerable<SceneFontFace>, string?) | Initializes a new instance of the SceneFontCollection class. |
SceneFontCollection overloads
SceneFontCollection(IEnumerable<SceneFontFace>)
SceneFontCollection.csInitializes a new instance of the SceneFontCollection class. The default family is the family of the first face.
public SceneFontCollection(params IEnumerable<SceneFontFace> faces)Parameters
facesIEnumerable<SceneFontFace>- The faces, in order of preference for the characters a family does not have.
Exceptions
ArgumentExceptionfacesis empty or containsnull.
SceneFontCollection(IEnumerable<SceneFontFace>, string?)
SceneFontCollection.csInitializes a new instance of the SceneFontCollection class.
public SceneFontCollection(IEnumerable<SceneFontFace> faces, string? defaultFamily)Parameters
facesIEnumerable<SceneFontFace>- The faces, in order of preference for the characters a family does not have.
defaultFamilystring?- The family of the texts that name no family of the collection, or
nullfor the family of the first face.
Exceptions
ArgumentExceptionfacesis empty or containsnull, or no face is ofdefaultFamily.
Properties
| Name | Description |
|---|---|
| DefaultFamily | Gets the family of the texts that name no family of the collection. |
| Faces | Gets the faces, in the order they were added. |
| Families | Gets the families of the faces, in the order they were added. |
| FontFamily | Gets the families as a CSS font-family value: SceneFontCollection.DefaultFamily, then the other families, quoted when needed. |
DefaultFamily
SceneFontCollection.csGets the faces, in the order they were added.
public IReadOnlyList<SceneFontFace> Faces { get; }Property value
Families
SceneFontCollection.csGets the families of the faces, in the order they were added.
public IReadOnlyList<string> Families { get; }Property value
FontFamily
SceneFontCollection.csGets the families as a CSS font-family value: SceneFontCollection.DefaultFamily, then the other families, quoted when needed.
public string FontFamily { get; }Property value
Remarks
The measurers that use the collection have this family (ITextMeasurer.FontFamily), so it is the family of their scenes.
Methods
| Name | Description |
|---|---|
| ContainsFamily(string) | Indicates whether the collection has a face of a family. |
| GetFace(SceneFont, string?) | Gets the face that draws a text. |
| GetFaces(SceneFont, string?) | Gets the faces that draw a text: the face of its family and style, then the faces of the other families, closest to the style, for the characters it does not have. |
| GetRuns(string, SceneFont, string?) | Splits a text into the runs that one face draws: the characters the face of its family does not have are drawn with the faces of the other families. |
| Load(IEnumerable<string>) | Loads the faces of font files into a collection. The default family is the family of the first face. |
ContainsFamily(string)
SceneFontCollection.csGetFace(SceneFont, string?)
SceneFontCollection.csGets the face that draws a text.
public SceneFontFace GetFace(SceneFont font, string? defaultFamily = null)Parameters
fontSceneFont- The font of the text.
defaultFamilystring?- The family of the text when
SceneFont.Familyisnull, usuallyScene.FontFamily, ornullforSceneFontCollection.DefaultFamily.
Returns
SceneFontFace The face.
GetFaces(SceneFont, string?)
SceneFontCollection.csGets the faces that draw a text: the face of its family and style, then the faces of the other families, closest to the style, for the characters it does not have.
public IReadOnlyList<SceneFontFace> GetFaces(SceneFont font, string? defaultFamily = null)Parameters
fontSceneFont- The font of the text.
defaultFamilystring?- The family of the text when
SceneFont.Familyisnull, usuallyScene.FontFamily, ornullforSceneFontCollection.DefaultFamily.
Returns
IReadOnlyList<SceneFontFace> The faces, by order of preference.
GetRuns(string, SceneFont, string?)
SceneFontCollection.csSplits a text into the runs that one face draws: the characters the face of its family does not have are drawn with the faces of the other families.
public IReadOnlyList<SceneFontRun> GetRuns(string text, SceneFont font, string? defaultFamily = null)Parameters
textstring- The text.
fontSceneFont- The font of the text.
defaultFamilystring?- The family of the text when
SceneFont.Familyisnull, usuallyScene.FontFamily, ornullforSceneFontCollection.DefaultFamily.
Returns
IReadOnlyList<SceneFontRun> The runs, in the order of the text: none for an empty text.
Remarks
Each grapheme cluster uses the first face of SceneFontCollection.GetFaces that has all its characters, and the first face when none has them. The adjacent clusters of a face are one run.
Load(IEnumerable<string>)
SceneFontCollection.csLoads the faces of font files into a collection. The default family is the family of the first face.
public static SceneFontCollection Load(params IEnumerable<string> paths)Parameters
pathsIEnumerable<string>- The paths of the files.
Returns
SceneFontCollection The collection.
Exceptions
ArgumentExceptionpathsis empty.FontException- A file is not a font, or a font is malformed, uses a feature that is not supported, or exceeds a limit.
IOException- An I/O error occurred.