Skip to content

Correct PostScript Name Resolution #255

@aamirsdev

Description

@aamirsdev

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions