0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2025-01-18 13:32:28 -05:00
penpot-exporter-figma-plugin/plugin-src/translators/text/font/local/translateLocalFont.ts
Jordi Sala Morales 2920ac297b
Implement unordered and ordered lists (#88)
* 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>
2024-05-07 12:18:15 +02:00

24 lines
773 B
TypeScript

import { LocalFont, translateFontVariantId } from '@plugin/translators/text/font/local';
import { FontId } from '@ui/lib/types/shapes/textShape';
import { items as localFonts } from './localFonts.json';
export const translateLocalFont = (fontName: FontName, fontWeight: number): FontId | undefined => {
const localFont = getLocalFont(fontName);
if (localFont === undefined) return;
return {
fontId: localFont.id,
fontVariantId: translateFontVariantId(localFont, fontName, fontWeight)
};
};
export const isLocalFont = (fontName: FontName): boolean => {
return getLocalFont(fontName) !== undefined;
};
const getLocalFont = (fontName: FontName): LocalFont | undefined => {
return localFonts.find(localFont => localFont.name === fontName.family);
};