mercredi 24 juillet 2019

Is there a way to read available font feature settings of a typeface with Javascript?

How can I read the existing fontFeatureSettings / fontVariationSettings of a font file (for example 'ss01', 'liga', 'WGHT' etc.) and also their range and value? I know how to access and change the features with javascript, but I would like to render Faders dynamically based on the settings that are provided by each font. I am pretty sure it is possible, but maybe I am looking for the wrong keywords? I am also happy with a server-side solution with node.js if not possible other wise.

Thank you!

I tried to dynamically import the font file with javascript but I can't find the information that I need in documents.fonts:

async function loadFonts() {
    const font = new FontFace('Variable', 'url(NobotoFlex-VF.ttf)');

    await font.load();

    document.fonts.add(font);

    // I can't find the information I am looking for:
    console.log(document.fonts);
}
loadFonts()




Aucun commentaire:

Enregistrer un commentaire