node.js - Node.js - 获取字体属性描述
问题描述
是否可以访问Description
字体属性的一部分,如右键单击文件时显示的那样?
例如,在这里,我对Title
属性感兴趣。
我已经使用了Node JS - read file propertiesget-file-properties
中描述的包,但它似乎无法访问它(它在幕后使用,它也不会返回它)。例如不存在,返回wmic
Title
Description
C:\\Windows\\Fonts\\Alegreya-Bold.ttf
还有其他方法可以访问此信息吗?
谢谢
解决方案
正如@RobinMackenzie 提到的,有 ttfinfo 包(https://github.com/trevordixon/ttfinfo),它将以这种形式为您提供有关特定字体的信息:
{
tables: {
name: {
'0': 'Copyright 2011 The Alegreya Project Authors (https://github.com/huertatipografica/Alegreya)',
'1': 'Alegreya',
'2': 'Bold',
'3': '2.003;HT ;Alegreya-Bold',
'4': 'Alegreya Bold',
'5': 'Version 2.003; ttfautohint (v1.6)',
'6': 'Alegreya-Bold',
'8': 'Huerta Tipografica',
'9': 'Juan Pablo del Peral',
'11': 'http://www.huertatipografica.com',
'12': 'http://www.huertatipografica.com',
'13': 'This Font Software is licensed under the SIL Open Font License, Version 1.1. This license is available with a FAQ at: http://scripts.sil.org/OFL',
'14': 'http://scripts.sil.org/OFL',
'256': 'Roman numerals',
'257': 'Arrows, triangles and circles',
'258': 'Foundry icon',
'259': 'Dynamic arrows and triangles'
},
post: {
format: 2,
italicAngle: 0,
underlinePosition: 0,
underlineThickness: 0,
minMemType42: 16734720,
maxMemType42: 1509968640,
minMemType1: 1258291200,
maxMemType1: 0
},
'OS/2': { version: 4, weightClass: 700 }
}
}
可以在此处找到完整的名称列表 ( 0
, 1
, ,...): https ://docs.microsoft.com/en-us/typography/opentype/spec/name#name-ids2
还有 node-system-fonts ( https://github.com/jgilsaa/node-system-fonts ),它需要一个构建步骤,因为它是一个 C++ 模块,但从好的方面来说,它为您提供了很多相同的信息, 对于每个安装的字体:
[
{
path: 'C:\\WINDOWS\\FONTS\\ARIAL.TTF',
postscriptName: 'ArialMT',
family: 'Arial',
style: 'Regular',
weight: 400,
width: 5,
italic: false,
monospace: false
},
{
path: 'C:\\WINDOWS\\FONTS\\ARIALN.TTF',
postscriptName: 'ArialNarrow',
family: 'Arial Narrow',
style: 'Regular',
weight: 400,
width: 3,
italic: false,
monospace: false
},
{
path: 'C:\\WINDOWS\\FONTS\\ARIALI.TTF',
postscriptName: 'Arial-ItalicMT',
family: 'Arial',
style: 'Italic',
weight: 400,
width: 5,
italic: true,
monospace: false
},
...
]
推荐阅读
- python - pd.dataframe 错误我无法合并两个数据框
- reactjs - 谁能帮我把我所有的数据从firestore提取到我的data.js
- ios - iOS 开发中心错误:输入所选国家/地区的有效电话号码
- reactjs - 为什么在 useEffect 中使用空数组不起作用 - React?
- php - 从模板文件向 wp_head 添加内容
- django - 使用现有 MSSQL 数据库时迁移期间图形错误中的循环依赖
- python - 安装flask和flask mysqldb问题
- sql - 有没有办法在选择查询中递归地连接 2 个不同的 SQL 表?
- bash - 通过 ssh 打开新终端的 Bash 脚本
- java - 具有约束的 Spring Boot 弹性搜索查询