TrueType
1.0.0
当前版本:0.2.0
来自TrueType字体的TrueType解析器,用于阅读,草甘膦,名称,描述和KERNING信息。支持.NetStandard 2.0 , .Net 4.6.1及更高。
您可以使用Nuget将此库直接添加到您的项目中:
Install-Package RoyT.TrueType
有关更多信息,请访问我的博客http://roy-t.nl。
要了解有关此处使用的TRUETYPE字体格式和术语的更多信息,请参阅“开放类型”规范。
它可以读取标准Windows 10安装中存在的所有字体的以下表:
它既揭示了易于使用API来直接从这些表中获取有用的信息
它通过目标.Net standard 1.6在.Net Core 1.0和.Net 4.6.1及更高版本上工作
参考
| 款项格式 | 支持/不支持 | 评论 |
|---|---|---|
| 分段映射到增量值 | 支持 | 最常见 |
| 修剪表映射 | 支持 | |
| 分段覆盖范围 | 支持 | |
| 字节编码表 | 支持 | 最不常见的 |
| 高字节映射桌子 | 不支持 | 我还没有看到使用此字体的字体,欢迎样本 |
| 混合16位和32位覆盖范围 | 不支持 | 我还没有看到使用此字体的字体,欢迎样本 |
| 修剪阵列 | 不支持 | 我还没有看到使用此字体的字体,欢迎样本 |
| 多对一的范围映射 | 不支持 | 我还没有看到使用此字体的字体,欢迎样本 |
| Unicode变化序列 | 不支持 | 指定单字形的变化 |
var font = TrueTypeFont . FromFile ( @"C:WindowsFontsarial.ttf" ) ;
// Using the helper functions
var glyphIndex = GlyphHelper . GetGlyphIndex ( 'A' , font ) ; // 36
var horizontalKerning = KerningHelper . GetHorizontalKerning ( 'A' , 'W' , 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
}
}
}
}