RoyT.TrueType
0.1.0
.NET Standard 1.6
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package RoyT.TrueType --version 0.1.0
NuGet\Install-Package RoyT.TrueType -Version 0.1.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="RoyT.TrueType" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RoyT.TrueType --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RoyT.TrueType, 0.1.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.
// Install RoyT.TrueType as a Cake Addin
#addin nuget:?package=RoyT.TrueType&version=0.1.0
// Install RoyT.TrueType as a Cake Tool
#tool nuget:?package=RoyT.TrueType&version=0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Roy-T.TrueType
Current version: 0.1.0
A TrueType parser for reading, glyphIds, names, descriptions, and kerning information from TrueType fonts. Supports .NetStandard 1.6
, .Net 4.6.1
and higher.
For more information please visit my blog at http://roy-t.nl.
To learn more about the TrueType font format and terminology used here see the Open Type specification.
Why choose this library?
- It can read all formats of the Cmap, Kern, and Name tables that exist in the fonts that come with a standard Windows 10 installation. This means you can use this library to read
- The glyph ids of all characters supported by the font
- (Localized) font names, font families, descriptions, and more
- It exposes both an easy to use API to directly get useful information from these tables, but also exposes the tables themselves so you add your own interpretation of the data
- It works on both
.Net Core 1.0
and.Net 4.6.1
and higher by targetting.Net standard 1.6
Limitations
- This library aims to read meta-information from .ttf files, it does not give you enough information to render glyphs yourself. For that you need OpenType and HarfBuzz.
Supported Cmap formats
Subtable format | supported/unsupported | remarks |
---|---|---|
Segmented mapping to delta values | supported | Most common |
Trimmed table mapping | supported | |
Segmented coverage | supported | |
Byte encoding table | supported | Least common |
High-byte mapping through table | unsupported | I have not seeen a font that uses this yet, samples welcome |
Mixed 16-bit and 32-bit coverage | unsupported | I have not seeen a font that uses this yet, samples welcome |
Trimmed array | unsupported | I have not seeen a font that uses this yet, samples welcome |
Many-to-one range mappings | unsupported | I have not seeen a font that uses this yet, samples welcome |
Unicode Variation Sequences | unsupported | Specifies variations of a single glyph |
Usage example
var font = TrueTypeFont.FromFile(@"C:\Windows\Fonts\arial.ttf");
// Using the helper functions
var glyphIndex = GlyphHelper.GetGlyphIndex('A', font); // 36
var horizontalKerning = KerningHelper.GetHorizontalKerning('A', 'W', 1.0f, font); // -76
var name = NameHelper.GetName(NameId.FontSubfamilyName, new CultureInfo("nl-NL"), font); // Standaard
// Diving in deep yourself to get some specific information is also possible
if (font.KernTable.SubtableCount > 0)
{
var leftCode = GlyphHelper.GetGlyphIndex(left, font);
var rightCode = GlyphHelper.GetGlyphIndex(right, font);
foreach (var subTable in font.KernTable.Subtables)
{
if (subTable.Format0 != null && subTable.Direction == Direction.Vertical
&& subTable.Values == Values.Kerning)
{
var pair = new KerningPair((ushort)leftCode, (ushort)rightCode);
if (subTable.Format0.Map.TryGetValue(pair, out var value))
{
// Do something
}
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.6 is compatible. netstandard2.0 was computed. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 1.6
- NETStandard.Library (>= 1.6.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on RoyT.TrueType:
Repository | Stars |
---|---|
riperiperi/FreeSO
Re-implementation of The Sims Online.
|