mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-23 06:04:01 -05:00
21 lines
655 B
TypeScript
21 lines
655 B
TypeScript
|
import { LocalFont, translateFontVariantId } from '@plugin/translators/text/local';
|
||
|
|
||
|
import { FontId } from '@ui/lib/types/text/textContent';
|
||
|
|
||
|
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)
|
||
|
};
|
||
|
};
|
||
|
|
||
|
const getLocalFont = (fontName: FontName): LocalFont | undefined => {
|
||
|
return localFonts.find(localFont => localFont.name === fontName.family);
|
||
|
};
|