Class SvgFont
Represents a scalar vector graphics font element defined through an XML schema.
Inherited Members
Namespace: OpenSvg.SvgNodes
Assembly: OpenSvg.dll
Syntax
public sealed class SvgFont : SvgNode
Constructors
| Edit this page View SourceSvgFont(SKTypeface)
Initializes a new instance of the SvgFont class by boxing an existing SKTypeface object.
Declaration
public SvgFont(SKTypeface font)
Parameters
Type | Name | Description |
---|---|---|
SKTypeface | font | An existing SKTypeface font-family descriptor instance. |
Properties
| Edit this page View SourceDefaultFont
Gets the default font to use in cases where no font is specified.
Declaration
public static SvgFont DefaultFont { get; }
Property Value
Type | Description |
---|---|
SvgFont |
Remarks
The default font is not defined according to the SVG 1.1 specification.
The default font is instead set in in accordance to the major browsers (Chrome, Firefox and Edge) to
Times New Roman
See Also
| Edit this page View SourceFont
Gets the actual value of the SKTypeface font instance that is used for rendering.
Declaration
public SKTypeface Font { get; }
Property Value
Type | Description |
---|---|
SKTypeface |
FontName
Gets the name of the font-family for an SVG font element property.
Declaration
public string FontName { get; }
Property Value
Type | Description |
---|---|
string |
FontSlant
Gets the style slant of a font-family SVG descriptor or CSS property.
Declaration
public SKFontStyleSlant FontSlant { get; }
Property Value
Type | Description |
---|---|
SKFontStyleSlant |
FontWeight
Gets a numerical representation of the font-weight for a font-family SVG property or a CSS property.
Declaration
public int FontWeight { get; }
Property Value
Type | Description |
---|---|
int |
FontWidth
Gets the width of the font.
Declaration
public int FontWidth { get; }
Property Value
Type | Description |
---|---|
int |
XText
Gets the declared object that represents the value of the SVG 'font-face' rule : an XML element.
Declaration
public string XText { get; }
Property Value
Type | Description |
---|---|
string |
Methods
| Edit this page View SourceGetSystemFont(string)
Creates an instance of SvgFont based on the specified font name.
Declaration
public static SvgFont GetSystemFont(string fontName)
Parameters
Type | Name | Description |
---|---|---|
string | fontName | The name of the font. |
Returns
Type | Description |
---|---|
SvgFont | An instance of SvgFont. |
Remarks
This method tries to load a system font based on the specified font name. It should be used with care as the font may not be available on all systems. Consider using embedded fonts in SVG instead, which are supported by the OpenSvg library. EmbedFont(SvgFont)
LoadFromFile(string)
Loads a new SvgFont from a file.
Declaration
public static SvgFont LoadFromFile(string fontFilePath)
Parameters
Type | Name | Description |
---|---|---|
string | fontFilePath | The file path of the SvgFont file to load. |
Returns
Type | Description |
---|---|
SvgFont | The SvgFont instance that was loaded from the file. |
SaveFontToFile(string)
Saves the SVG font to a file (e.g. .TTF, .OTF).
Declaration
public void SaveFontToFile(string fontFilePath)
Parameters
Type | Name | Description |
---|---|---|
string | fontFilePath | The path and name of the file to save. |