简体   繁体   中英

Node.js - Get font properties description

Is it possible to access the Description part of a font properties, as shown when you right-click on the file?

在此处输入图像描述

Here, I'm interested in the Title attribute, for example.

I've used the get-file-properties package as described in Node JS - read file properties , but it doesn't seem to have access to it (it's using wmic behind the scenes, which doesn't return it either). For example, Title doesn't exist, and Description returns C:\\Windows\\Fonts\\Alegreya-Bold.ttf

Is there another way to access this information?

Thanks

As @RobinMackenzie mentionned, there's the ttfinfo package ( https://github.com/trevordixon/ttfinfo ), which will give you the info on a specific font in this form:

{
  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 }
  }
}

A full list of the names ( 0 , 1 , 2 ,...) can be found here: https://docs.microsoft.com/en-us/typography/opentype/spec/name#name-ids

There's also node-system-fonts ( https://github.com/jgilsaa/node-system-fonts ), which requires a build step as it's a C++ module, but on the plus side, gives you a lot of the same info, for every installed font:

[
  {
    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
  },
  ...
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM