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
    %s requires a valid license key for further deployment. Get Trial Below.
    ironsuite
    Blue key in circleGet Started for Free
    30 days full access • 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.
    Grey check in circleTrial key delivered
    Your key has been issued and sent to your email.
    Calendar in circleBook Free Live Demo
    No cards • no pitches • no commitments Pick a time for a quick, personalized demo
    Get the most out of your 30-day trial with:

    Live product and key features walk-through

    Project-specific recommendations

    All your questions answered

    Grey key in circleBook Free Live Demo
    Your booking has been completed Check your e-mail for confirmation

    Want to deploy Iron Suite
    to a live project for FREE?

    What’s included?

    • Test in production without watermarks
    • 30 days fully functional product
    • 24/5 technical support during trial
    ironpdf Logo
    ironword Logo
    ironxl Logo
    ironppt Logo
    ironocr Logo
    ironbarcode Logo
    ironqr Logo
    ironprint Logo
    ironzip Logo
    ironwebscraper Logo
    Iron Software sales team
    Online 24/5
    Have Enterprise licensing requirements?
    Request Iron Suite Enterprise trial
    Key in blue circle

    Get your free 30-day Trial Key instantly

    Your trial license will be sent to your email address

    No limitations. 100% unlocked. No credit card.

    bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
    Or
    Key in blue circle

    Complete Your Trial Key Signup

    Tell us a little more about yourself.

    Key in blue circleNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
    Key in blue circle

    Your license key has been delivered to your inbox

    Can't find it? Check your spam folder.

    What’s next?
    Install with NuGet
    Add IronPDF to your project
    Quickstart Guide
    Helpful resources to get started

    Need help getting started?

    Book a Free Live Demo

    See IronPDF in action and get your licensing questions answered, or

    Key in blue circle

    Your demo request is in.

    You'll receive an invite via email shortly.

    What’s next?
    Explore Documentation
    Review Licensing Options
    badge_greencheck_in_yellowcircle
    Thank you
    Your trial key should be in the email.
    If it is not, please contact support@ironsoftware.com
    • Logo Aetna
    • Logo NASA
    • Logo GE
    • Logo Porsche
    • Logo USDA
    • Logo Qatar
    Join Millions of Engineers who’ve tried IronPDF
    Your trial key should be in the email.
    If it is not, please contact support@ironsoftware.com