KernSmith.Fonts.Web
0.26.0
See the version list below for details.
dotnet add package KernSmith.Fonts.Web --version 0.26.0
NuGet\Install-Package KernSmith.Fonts.Web -Version 0.26.0
<PackageReference Include="KernSmith.Fonts.Web" Version="0.26.0" />
<PackageVersion Include="KernSmith.Fonts.Web" Version="0.26.0" />
<PackageReference Include="KernSmith.Fonts.Web" />
paket add KernSmith.Fonts.Web --version 0.26.0
#r "nuget: KernSmith.Fonts.Web, 0.26.0"
#:package KernSmith.Fonts.Web@0.26.0
#addin nuget:?package=KernSmith.Fonts.Web&version=0.26.0
#tool nuget:?package=KernSmith.Fonts.Web&version=0.26.0
KernSmith.Fonts.Web
A web font source for KernSmith. Fetches WOFF2 (or 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 font file for the requested Unicode subset: the .woff2 when offered (smaller), otherwise the .woff. KernSmith core decodes both, WOFF2 with its own managed Brotli decoder, so it works in the browser.
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
- WOFF2 or WOFF only — a source is picked by its
format()hint, else its file extension; TTF/OTF/EOT/SVG sources are ignored, so a subset offering neither WOFF2 nor WOFF throwsInvalidOperationException. - User-Agent — outside a browser the source sends a modern Chrome User-Agent (unless your
HttpClientalready has one), because Google Fonts serves TTF to unknown agents. In the browser it sends none and the browser's own UA is used: a customUser-Agentis not CORS-safelisted, and the CDNs reject the preflight it causes in Firefox. - No family listing — CSS CDNs do not expose a discovery endpoint, so
ListFamiliesAsyncreturns an empty list.
Build
dotnet build src/KernSmith.Fonts.Web/KernSmith.Fonts.Web.csproj
See the KernSmith repository for full project documentation.
| Product | Versions 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. |
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.28.0 | 93 | 11/15/2026 |
| 0.27.0 | 114 | 11/6/2026 |
| 0.26.0 | 95 | 11/2/2026 |
| 0.25.0 | 109 | 11/1/2026 |
| 0.24.0 | 101 | 10/18/2026 |
| 0.23.1 | 105 | 10/17/2026 |
| 0.23.0 | 100 | 10/14/2026 |
| 0.22.1 | 96 | 10/13/2026 |
| 0.22.0 | 125 | 9/10/2026 |
| 0.21.0 | 123 | 8/28/2026 |
| 0.20.0 | 131 | 8/5/2026 |
| 0.19.0 | 137 | 7/31/2026 |
| 0.18.2 | 120 | 7/28/2026 |
| 0.18.1 | 130 | 7/28/2026 |
| 0.18.0 | 126 | 7/27/2026 |
| 0.17.0 | 131 | 7/19/2026 |