![]() |
VOOZH | about |
dotnet add package OTFontFile2 --version 0.1.0-alpha
NuGet\Install-Package OTFontFile2 -Version 0.1.0-alpha
<PackageReference Include="OTFontFile2" Version="0.1.0-alpha" />
<PackageVersion Include="OTFontFile2" Version="0.1.0-alpha" />Directory.Packages.props
<PackageReference Include="OTFontFile2" />Project file
paket add OTFontFile2 --version 0.1.0-alpha
#r "nuget: OTFontFile2, 0.1.0-alpha"
#:package OTFontFile2@0.1.0-alpha
#addin nuget:?package=OTFontFile2&version=0.1.0-alpha&prereleaseInstall as a Cake Addin
#tool nuget:?package=OTFontFile2&version=0.1.0-alpha&prereleaseInstall as a Cake Tool
OTFontFile2 is a modern OpenType parser/writer for .NET, focused on:
It supports both single-font sfnt (.ttf/.otf) and TTC collections (.ttc).
using OTFontFile2;
using var file = SfntFile.Open("font.ttf"); // or font.ttc
var font = file.GetFont(0); // first font in file/collection
using OTFontFile2.Tables;
if (font.TryGetHead(out var head))
{
int unitsPerEm = head.UnitsPerEm;
}
if (font.TryGetMaxp(out var maxp))
{
int glyphCount = maxp.NumGlyphs;
}
if (font.TryGetName(out var name))
{
string? fullName = name.GetFullNameString();
}
cmap)using OTFontFile2;
if (CmapUnicodeMap.TryCreate(font, out var map) &&
map.TryMapCodePoint(0x4F60, out uint glyphId)) // U+4F60
{
// glyphId
}
using OTFontFile2;
using var inFile = SfntFile.Open("in.ttf");
var inFont = inFile.GetFont(0);
using var outStream = File.Create("out.ttf");
SfntWriter.Write(outStream, inFont);
SfntFile.Open(path): open from disk.SfntFile.TryOpen(path, out file, out error): non-throwing open.SfntFile.FromMemory(memory): open from in-memory bytes.FontCount: number of fonts (1 for normal sfnt, >1 for TTC).GetFont(index): get SfntFont.TableCount: number of tables in this font.TryGetTable(tag, out record): table directory lookup.TryGetTableData(tag, out data, out record): raw bytes of a table.TryGetTableSlice(tag, out slice): zero-copy table slice.TryGetHead, TryGetMaxp, TryGetName, TryGetCmap, TryGetGlyf, etc.Most table structs in OTFontFile2.Tables expose:
TryCreate(...)UnitsPerEm, NumGlyphs)using OTFontFile2;
Tag.TryParse("head", out var headTag);
Tag.TryParse("cmap", out var cmapTag);
var builder = new SfntBuilder
{
SfntVersion = 0x00010000
};
builder.SetTable(headTag, headBytes);
builder.SetTable(cmapTag, cmapBytes);
using var fs = File.Create("new.ttf");
builder.WriteTo(fs);
false instead of throwing.| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on OTFontFile2:
| Package | Downloads |
|---|---|
|
Mobsub.Font
Mobsub helper |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-alpha | 414 | 2/28/2026 |