KernSmith.Fonts.Web 0.17.0

dotnet add package KernSmith.Fonts.Web --version 0.17.0
                    
NuGet\Install-Package KernSmith.Fonts.Web -Version 0.17.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="KernSmith.Fonts.Web" Version="0.17.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="KernSmith.Fonts.Web" Version="0.17.0" />
                    
Directory.Packages.props
<PackageReference Include="KernSmith.Fonts.Web" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add KernSmith.Fonts.Web --version 0.17.0
                    
#r "nuget: KernSmith.Fonts.Web, 0.17.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package KernSmith.Fonts.Web@0.17.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=KernSmith.Fonts.Web&version=0.17.0
                    
Install as a Cake Addin
#tool nuget:?package=KernSmith.Fonts.Web&version=0.17.0
                    
Install as a Cake Tool

KernSmith.Fonts.Web

A web font source for KernSmith. Fetches WOFF fonts from CSS-based font CDNs by parsing @font-face responses.

Overview

WebFontSource implements the core KernSmith.Font.IFontSource abstraction. It fetches a stylesheet from a font CDN (Bunny Fonts, Google Fonts, or any compatible custom endpoint), parses the @font-face rules, and downloads the .woff file for the requested Unicode subset.

This is primarily useful in browser/WASM scenarios (e.g. running KernSmith in Blazor WebAssembly) where there is no filesystem and fonts must be obtained over the network.

Platform: Cross-platform (net8.0, net10.0). Uses HttpClient from the BCL.

Usage

dotnet add package KernSmith.Fonts.Web
using KernSmith;
using KernSmith.Font;
using KernSmith.Fonts.Web;

var source = new WebFontSource(WebFontProvider.BunnyFonts);
byte[] bytes = await source.GetFontAsync("Roboto", weight: 400);

BmFont.RegisterFont("Roboto", bytes);
var result = BmFont.GenerateFromSystem("Roboto", size: 32);

Providers

new WebFontSource(WebFontProvider.BunnyFonts);                 // privacy-friendly default
new WebFontSource(WebFontProvider.GoogleFonts);                // fonts.googleapis.com
new WebFontSource(WebFontProvider.Custom("https://my.cdn/css")); // any compatible endpoint

Subsets and styles

await source.GetFontAsync("Roboto", weight: 700, style: FontStyle.Italic, subset: "latin");
await source.GetFontAsync("Roboto", subset: "cyrillic");

Caching

Fetched fonts are cached in memory (keyed by family + weight + style + subset). Pass a diskCachePath to also persist across runs (leave it null on WASM):

new WebFontSource(WebFontProvider.BunnyFonts, diskCachePath: "cache/fonts");

Limitations

  • WOFF only.woff2 URLs are ignored because WOFF2 uses Brotli compression, which KernSmith does not yet decode.
  • No family listing — CSS CDNs do not expose a discovery endpoint, so ListFamiliesAsync returns an empty list.

Build

dotnet build src/KernSmith.Fonts.Web/KernSmith.Fonts.Web.csproj

See the KernSmith repository for full project documentation.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.17.0 48 7/19/2026