mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-22 21:53:27 -05:00
58f7b0ab2c
* moved validate font logic * google fonts working * fixes * minor improvements * fix linter * local fonts * fixes * Changeset * changeset * refactor * refactor * update branch * minor fix * move files around * try to refactor * refactor * add todo * refactor * refactor * refactor * refactor * refactor * refactor * refactor move files to their concrete location --------- Co-authored-by: Jordi Sala Morales <jordism91@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;
|
|
};
|