Search Results for

    Show / Hide Table of Contents

    Class WebFont

    Inheritance
    System.Object
    Font
    WebFont
    Namespace: PdfToSvg
    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
    Type Description
    LocalFont

    FontFamily

    Declaration
    public override string FontFamily { get; }
    Property Value
    Type Description
    System.String
    Overrides
    Font.FontFamily

    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
    Font.GetHashCode()

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String
    Overrides
    Font.ToString()
    ☀
    ☾
    Downloads
    • Download with Nuget
    • Start for Free
    In This Article
    Back to top
    Install with Nuget
    IronPDF_for_dotnet_log2o
    Blue key in circleGet started for FREE
    No credit card required
    Test in a live environment

    Test in production without watermarks.
    Works wherever you need it to.

    Fully-functional product

    Get 30 days of fully functional product.
    Have it up and running in minutes.

    24/5 technical support

    Full access to our support engineering team during your product trial

    Grey key in circleGet started for FREE
    The trial form was submitted successfully.
    Calendar in circleBook Free Live Demo
    No contact, no card details, no commitments Book a 30-minute, personal demo.
    Here's what to expect:

    A live demo of our product and its key features

    Get project specific feature recommendations

    All your questions are answered to make sure you have all the information you need. (No commitment whatsoever.)

    Grey key in circleBook Free Live Demo
    Your booking has been completed Check your e-mail for confirmation
    Support Team Member 6 related to The C# PDF Library Support Team Member 14 related to The C# PDF Library Support Team Member 4 related to The C# PDF Library Support Team Member 2 related to The C# PDF Library
    Online 24/5
    Need help? Our sales team would be glad to help you.
    Try the Enterprise Trial
    ironpdf_for_dotnet_log2o
    Key in blue circle
    Get your free 30-day Trial Key instantly.
    bullet_checkedNo credit card or account creation required
    Key in blue circle
    Get your free 30-day Trial Key instantly.
    Blue key in circleNo credit card or account creation required
    Green Check in orange circle
    The trial form was submitted successfully.
    badge_greencheck_in_yellowcircle
    Thank you for starting a trial

    Please check your email for the trial license key.

    If you don’t receive an email, please start a live chat or email support@ironsoftware.com

    Install with NuGet
    View Licensing
    • Logo Aetna
    • Logo NASA
    • Logo GE
    • Logo Porsche
    • Logo USDA
    • Logo Qatar
    Join Millions of Engineers who’ve tried IronPDF