2024-04-30 08:00:11 +02:00
|
|
|
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)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-05-03 13:43:07 +02:00
|
|
|
export const isLocalFont = (fontName: FontName): boolean => {
|
|
|
|
return getLocalFont(fontName) !== undefined;
|
|
|
|
};
|
|
|
|
|
2024-04-30 08:00:11 +02:00
|
|
|
const getLocalFont = (fontName: FontName): LocalFont | undefined => {
|
|
|
|
return localFonts.find(localFont => localFont.name === fontName.family);
|
|
|
|
};
|