mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2025-01-06 23:00:55 -05:00
2920ac297b
* wip * implement bullet points * needs more ifs * refactor * revert * refactor * fix and refactor * refactor * refactor * refactor * add ordered class * wip * wip * fixes * package.json * little refactors * base list * fixes * abstract baselist * refactors * refactor * changeset * fix eslint issue * fix * fixes * fixes --------- Co-authored-by: Alex Sánchez <sion333@gmail.com>
20 lines
651 B
TypeScript
20 lines
651 B
TypeScript
import { GoogleFont } from './googleFont';
|
|
|
|
export const translateFontVariantId = (
|
|
googleFont: GoogleFont,
|
|
fontName: FontName,
|
|
fontWeight: number
|
|
) => {
|
|
// check match directly by style
|
|
const variant = googleFont.variants?.find(variant => variant === fontName.style.toLowerCase());
|
|
|
|
if (variant !== undefined) return variant;
|
|
|
|
// check match by style and weight
|
|
const italic = fontName.style.toLowerCase().includes('italic') ? 'italic' : '';
|
|
const variantWithWeight = googleFont.variants?.find(
|
|
variant => variant === `${fontWeight.toString()}${italic}`
|
|
);
|
|
|
|
if (variantWithWeight !== undefined) return variantWithWeight;
|
|
};
|