Class WebFont
Inheritance
System.Object
WebFont
Assembly: IronPdf.dll
Syntax
public class WebFont : Font
Precise font rendering in SVG output becomes possible when you supply WebFont, a configuration record that tells the IronPDF SVG converter where to fetch a web-hosted typeface and which local font to use when those remote URLs are unavailable. Construct one instance per typeface and pass it wherever the conversion pipeline accepts a Font-derived object.
WebFont extends Font and holds up to four URL slots covering every common web-font format: WoffUrl for WOFF, Woff2Url for the compressed WOFF 2.0 variant, TrueTypeUrl for TTF, and OpenTypeUrl for OTF. Browsers and SVG renderers pick the first format they support, so supplying multiple URLs maximises compatibility across environments. The FontFamily property exposes the CSS font-family name derived from the configuration, ready for injection into the SVG <style> block. FallbackFont holds the LocalFont passed at construction time; when all remote URLs are unreachable or the renderer does not support web fonts, the fallback keeps text legible using a locally installed typeface.
All constructor parameters are optional. Passing only a woff2Url is enough for modern browser targets, while adding a trueTypeUrl alongside it covers legacy renderers. Passing a LocalFont as fallbackFont is recommended for any production pipeline where network access cannot be guaranteed. The Equals and GetHashCode overrides make WebFont instances safe to use as dictionary keys or in LINQ distinct operations, and ToString returns a human-readable summary useful for logging and diagnostics.
Because WebFont derives from Font, it slots into any API surface that accepts the base type, keeping font configuration uniform whether you are working with local or remote typefaces. This design means switching between a LocalFont and a WebFont requires only a constructor change, not a restructuring of the conversion call.
using PdfToSvg;
// Serve WOFF 2.0 with a WOFF fallback; use Arial locally when offline.
var webFont = new WebFont(
fallbackFont : new LocalFont("Arial"),
woff2Url : "https://example.com/fonts/opensans.woff2",
woffUrl : "https://example.com/fonts/opensans.woff"
);
Console.WriteLine(webFont.FontFamily); // CSS font-family name
Console.WriteLine(webFont.FallbackFont); // LocalFont("Arial")
For a broader look at PDF-to-SVG conversion options, see the IronPDF documentation hub, the PDF to SVG how-to guide, and the font handling examples. Getting started quickly is covered on the IronPDF get-started page.
Constructors
WebFont(LocalFont, String, String, String, String)
Declaration
public WebFont(LocalFont fallbackFont = null, string woffUrl = null, string woff2Url = null, string trueTypeUrl = null, string openTypeUrl = null)
Parameters
| Type |
Name |
Description |
| LocalFont |
fallbackFont |
|
| System.String |
woffUrl |
|
| System.String |
woff2Url |
|
| System.String |
trueTypeUrl |
|
| System.String |
openTypeUrl |
|
Properties
FallbackFont
Declaration
public LocalFont FallbackFont { get; }
Property Value
FontFamily
Declaration
public override string FontFamily { get; }
Property Value
| Type |
Description |
| System.String |
|
Overrides
OpenTypeUrl
Declaration
public string OpenTypeUrl { get; }
Property Value
| Type |
Description |
| System.String |
|
TrueTypeUrl
Declaration
public string TrueTypeUrl { get; }
Property Value
| Type |
Description |
| System.String |
|
Woff2Url
Declaration
public string Woff2Url { get; }
Property Value
| Type |
Description |
| System.String |
|
WoffUrl
Declaration
public string WoffUrl { get; }
Property Value
| Type |
Description |
| System.String |
|
Methods
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
| Type |
Name |
Description |
| System.Object |
obj |
|
Returns
| Type |
Description |
| System.Boolean |
|
GetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type |
Description |
| System.Int32 |
|
Overrides
ToString()
Declaration
public override string ToString()
Returns
| Type |
Description |
| System.String |
|
Overrides