-
Notifications
You must be signed in to change notification settings - Fork 82
Description
Photoshop requires precise PostScript names (e.g., "ArialMT" instead of "Arial") to correctly map font family, weight, and style properties. Existing font libraries or methods I have tried either return incomplete or incorrect PostScript names that do not match Photoshop’s expectations. I need a reliable way or library that can determine the exact PostScript name Photoshop requires based on font family, weight, and style.
What I tried:
Used the font-list Node.js library to retrieve font metadata, including PostScript names.
Attempted this lookup:
expects.const { getFonts2 } = require('font-list');
async function getPostScriptName(family, fontWeight, fontStyle) {
const normalizedFamily = family.trim().toLowerCase();
const canvasFontStyle = fontStyle.toLowerCase();
const normalizedWeight = fontWeight.toLowerCase();
const fonts = await getFonts2();
const foundFont = fonts.find(font =>
font.familyName.toLowerCase().includes(normalizedFamily) &&
font.weight.toLowerCase() === normalizedWeight &&
font.style.toLowerCase() === canvasFontStyle
);
return foundFont?.postScriptName;
}
However, this returns generic PostScript names like "Arial" rather than the Photoshop-required "ArialMT", causing font mapping issues.
Manual mapping functions are error-prone and hard to maintain at scale.