Obtaining Font Information using Node.js

Is there a way to retrieve the Description section of a font's properties, as seen when you right-click on the file?

https://i.stack.imgur.com/rwnLw.png

I am specifically looking for details related to the Title attribute.

I tried using the get-file-properties package mentioned in this Node JS - read file properties link but it does not provide access to this information (it relies on wmic which also does not have this data). For instance, while Description provides only

C:\\Windows\\Fonts\\Alegreya-Bold.ttf
, Title is nowhere to be found.

Is there an alternative method to retrieve this data?

Thank you

Answer №1

In reference to @RobinMackenzie's suggestion, there is the ttfinfo package available at https://github.com/trevordixon/ttfinfo. This package provides detailed information about a specific font in this structured format:

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

You can refer to this comprehensive list of names (0, 1, 2, etc.) at: https://learn.microsoft.com/en-us/typography/opentype/spec/name#name-ids

Another useful tool is node-system-fonts accessible at https://github.com/jgilsaa/node-system-fonts. However, note that it requires a build step since it is a C++ module. On the positive side, it offers similar detailed information for every installed font like so:

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to safely store a logged-in user on the client-side?

As I delve into creating a login system for my simple social media website where users can make posts and view feeds from fellow followers, I've successfully implemented user login. Upon logging in, I'm able to retrieve the user's credential ...

Error message encountered: Missing property status in TypeScript code

An error occurs in the refetchInterval when accessing data.status, with a message saying "property status does not exist" chatwrapper.tsx const ChatWrapper = ({ fileId }: ChatWrapperProps) => { const { data, isLoading } = trpc.getFileUploadStatus.use ...

Maintaining the Execution of an ExpressJS Application Beyond Terminal Closure

When running my application on a server, I encounter the issue of it stopping as soon as I close the terminal window. How can I overcome this challenge? Is there a way to keep an application running permanently in the background? Are there any specific ...

Concatenating Arrays in nodeJS

Here's a code snippet that deals with arrays: const array = [ "apple", "banana", "cherry" ]; I'm trying to create a multiline string like this: const foo = " apple banana cherry "; Is there a way for me to begin a new line with each it ...

Having trouble installing the `<module>` package with npm due to a persistent error, possibly related to the node-gyp build process

My attempt to install jsdom looks like this: $ sudo npm install -g jsdom # OR $ sudo npm install jsdom Despite some successful commands, the installation quickly fails, with the first error message appearing after the [....]: $ sudo npm install jsdom ...

What is the correct process for authenticating requests from SSR to the Feathers JS API?

There are some examples available on how to access FeathersJS API from SSR, but the important aspect of authorizing such requests is missing. Is it feasible to create a feathers-client app for each request? Wouldn't that put too much load on the syste ...

The Node.js server delivers a different object to the client

I'm facing an issue while trying to send an object from the client to a Node.js server. Here is my Ajax call: $.ajax({ url: config.api.url, type: config.api.method, contentType: config.api.contentType, // application/x-www-form-urlencoded; cha ...

Is it possible for three.js to integrate information from REST APIs?

Currently, I am in the process of learning three.js and have successfully created basic 3D models using hardcoded values. My goal now is to retrieve these values from a database that I have set up in MSSQL Server. These x, y, and z parameters are stored ...

Retrieve the output of a function once the function has completed

I'm facing an issue where I need to wait for a function to return a value from my MySQL table before using it as a return for my const ProjektNameIntentHandler. Here is the relevant code snippet: const ProjektNameIntentHandler = { canHandle(handlerIn ...

Tips for extracting dynamically loaded content from a website using Node.js and Selenium?

I'm currently encountering some challenges when trying to scrape a website that utilizes react for certain parts of its content, and I'm unsure about the reason behind my inability to extract the data. Below is the HTML structure of the website: ...

What could be causing my node server's REST endpoints to not function properly?

Here is a snippet of my index.js file: var http = require('http'); var express = require('express'); var path = require('path'); var bodyParser = require('body-parser') var app = express(); var currentVideo = &apos ...

Is it possible for the user/website to access the express res.locals variables?

In the process of developing a Node app with Express and Passport, I have incorporated middleware in my main server.js file as shown below: // Function to protect urls function isProtected(req, res, next) { if (req.isAuthenticated()) { // User ...

Issue encountered while attempting to download videos using the ytdl-core express module

I've been working on a node express app to download videos from YouTube using ytdl-core, but I'm running into an issue where the code doesn't seem to be functioning properly. Despite trying different approaches, the app receives the request ...

retrieve data from a MongoDB collection's fields

I am currently working with nodejs and mongodb "image" : "comments" : "date" : "name" : "description" : "author" : { "id" : "username" : }, "user" "__v" } In my Blog collection, these are the spe ...

What is the best way for library creators to indicate to VSCode which suggested "import" is the correct one?

As a library creator, I have noticed that VSCode often suggests incorrect imports to users. For instance, VSCode typically suggests the following import: import useTranslation from 'next-translate/lib/esm/useTranslation' However, the correct im ...

An undefined value is encountered in a function within Node.js

To test this code snippet in node.js v6.0.0: x = 3; var foo = { x:1, bar: { x: 2, baz: function() { console.log(this.x); } } }; foo.bar.baz(); var a = foo.bar.baz; a(); An error is thrown: 2 TypeError: Cannot read property &apos ...

Locate an item based on the `Contains` criterion by utilizing Express and Mongoose

Looking to find items in my collection that have userName containing adm. Expecting 2 results based on having records with userNames like admin0 and admin2, but the search returns nothing. The query being used is: Person .find({ userName: { $in: &a ...

A regular expression route does not include req.params in the passed data

My Express router includes two routes that look like this: router.get("/v|verses", (req, res) => ... router.get("/v|verses/:book", (req, res) => .... When I try to access /verses/john, why does it match the first route and return an empty object f ...

Transfer data from Node.js to J2ee via binary upload and receive a corresponding reply

I am in need of assistance with my Node express server. The server receives a binary file (pdf) from a client and I must send this binary file as it is to a Java servlet. Currently, I am using the following code snippet to accomplish this task by utilizing ...

Steps for adding an npm dependency as a peer dependency:

Is there a way in npm to install dependencies as peer-dependencies similar to the yarn option --yarn, rather than manually adding them? For instance: "peerDependencies": { "@angular/core": "^7.0.0" } Update: Further clarifi ...