@keymanapp/kmc-keyboard-info
Version:
Keyman Developer .keyboard_info compiler
30 lines (28 loc) • 1.16 kB
JavaScript
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ef6caa7f-da4c-5313-ab64-f886f539c16c")}catch(e){}}();
import ttfMeta from './ttfmeta/lib/index.js';
/**
* Extracts the font-family from an in-memory TTF or WOFF blob in `source`
* parameter.
*
* @param source In-memory TTF or WOFF font blob
*
* @throws Uncaught exceptions from ttfMeta.promise if the font file is invalid.
*
* @returns If the file is invalid or cannot be parsed, returns `null`,
* otherwise returns the font family as a string.
*/
export async function getFontFamily(source) {
/* c8 ignore next 3 */
if (!source) {
return null;
}
const buffer = Buffer.from(source);
const font = await ttfMeta.promise(buffer);
/* c8 ignore next 3 */
if (!font) {
return null;
}
return font.meta.property.find(prop => prop.name == 'font-family')?.text ?? null;
}
//# sourceMappingURL=font-family.js.map
//# debugId=ef6caa7f-da4c-5313-ab64-f886f539c16c