HarfBuzzSharp
HarfBuzzSharp is a cross-platform OpenType text shaping engine for .NET platforms.
Install
| Product | Versions |
|---|---|
| .NET | |
| .NET Standard | |
| Other |
README
HarfBuzzSharp
HarfBuzzSharp provides .NET bindings for the HarfBuzz OpenType text shaping engine. It converts Unicode text into correctly selected and positioned glyphs for complex scripts, ligatures, kerning, variable fonts, bidirectional text, and advanced typographic features.
Capabilities
- Shape text for Arabic, Indic, Southeast Asian, and other complex writing systems.
- Apply OpenType features, language, script, and direction settings.
- Inspect glyph IDs, clusters, advances, and offsets.
- Read OpenType variation axes, names, metrics, color glyph data, and layout information.
- Run on Windows, macOS, Linux, Android, iOS, Mac Catalyst, tvOS, Tizen, and WebAssembly.
- Integrate with SkiaSharp rendering through
SkiaSharp.HarfBuzz.
Get started
Install the package:
dotnet add package HarfBuzzSharp
Shape a string using an OpenType font:
using HarfBuzzSharp;
using var blob = Blob.FromFile("NotoSansArabic-Regular.ttf");
using var face = new Face(blob, 0);
using var font = new Font(face);
font.SetScale(face.UnitsPerEm, face.UnitsPerEm);
using var buffer = new HarfBuzzSharp.Buffer();
buffer.AddUtf8("Ù…Ø±ØØ¨Ø§ بالعالم");
buffer.GuessSegmentProperties();
font.Shape(buffer);
foreach (var glyph in buffer.GlyphInfos)
Console.WriteLine($"Glyph {glyph.Codepoint}, cluster {glyph.Cluster}");
For drawing shaped text with SkiaSharp, install SkiaSharp.HarfBuzz and use SKShaper:
dotnet add package SkiaSharp.HarfBuzz
Linux and WebAssembly: add the matching
HarfBuzzSharp.NativeAssets.*package directly to the application project when the target does not receive native assets transitively. See the package deployment guide.
Documentation and resources
- HarfBuzzSharp API reference on Microsoft Learn
- SkiaSharp.HarfBuzz API reference
- HarfBuzz documentation
- SkiaSharp package and deployment guide
- SkiaSharp samples
Feedback and contributing
HarfBuzzSharp is part of the open-source SkiaSharp project from Microsoft. Use GitHub Discussions for questions, file bugs and feature requests in the issue tracker, and read the contributing guide to get involved.
HarfBuzzSharp is released under the MIT license.
Changes from Previous Version
Adoption Assessment
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.