Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from penpot:main #20

Open
wants to merge 108 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
8021da2
Google Fonts (#80)
Cenadros Apr 29, 2024
58f7b0a
Local Fonts (#81)
Cenadros Apr 30, 2024
4ded73e
Paragraph Spacing & Indent (#84)
Cenadros May 3, 2024
c013e80
Custom Fonts (#82)
Cenadros May 3, 2024
afa47af
Refactor and simplify code (#85)
jordisala1991 May 6, 2024
2920ac2
Implement unordered and ordered lists (#88)
jordisala1991 May 7, 2024
a18f981
fixed lists (#91)
Cenadros May 8, 2024
3ee244d
New UI for the plugin (#90)
jordisala1991 May 9, 2024
32e5d23
temporary hide url with further instructions (#92)
jordisala1991 May 9, 2024
ca540d0
fix url (#93)
jordisala1991 May 9, 2024
dddc457
Images (#89)
Cenadros May 9, 2024
f5a8b9c
Version Packages (#79)
github-actions[bot] May 9, 2024
9355f28
Fixed line nodes (#96)
Cenadros May 10, 2024
7cae184
Version Packages (#97)
github-actions[bot] May 10, 2024
8d5c5c1
Dynamic plugin size calculation, and cap the height to a safe value (…
Cenadros May 13, 2024
bff2157
Minor improvements (#100)
jordisala1991 May 13, 2024
887f0b9
fix styles (#101)
jordisala1991 May 13, 2024
2557cbd
Implement flatten (#105)
jordisala1991 May 13, 2024
c71eb8e
Layer Blur (#103)
Cenadros May 13, 2024
54df5ea
Fix Text Image Fills (#102)
Cenadros May 13, 2024
538c076
Fix types (#107)
jordisala1991 May 13, 2024
23e97fb
Gradients (#108)
Cenadros May 13, 2024
3118d36
Fills Refactor (#109)
Cenadros May 13, 2024
a734c8a
decide to transform to path or group based on regions (#110)
jordisala1991 May 14, 2024
cc5553c
Refactor Strokes (#112)
Cenadros May 21, 2024
aafb9cf
updated copies for custom fonts help (#116)
Cenadros May 27, 2024
36afc6d
Boolean Groups (#115)
Cenadros May 27, 2024
7610935
Masked Groups (#114)
Cenadros May 27, 2024
4772917
Version Packages (#99)
github-actions[bot] May 27, 2024
35d9d47
fix frames fills and blendModes (#118)
Cenadros May 27, 2024
044b092
Fix empty text layers (#120)
jordisala1991 May 27, 2024
fa1d25a
Version Packages (#119)
github-actions[bot] May 27, 2024
5d7263b
Allow rotation for Ellipses and Rectangles (#122)
jordisala1991 May 29, 2024
32aafbc
Implement components (#106)
jordisala1991 May 29, 2024
5d4ace3
Components Library (#125)
Cenadros May 29, 2024
7b31929
Component Instances (#124)
Cenadros May 30, 2024
88b3e5f
Implement progress bar (#126)
jordisala1991 May 31, 2024
79f6ce8
Fix interface when exporting (#127)
jordisala1991 May 31, 2024
f8e6b6e
component set (#128)
Cenadros May 31, 2024
92167ac
Fix masks in components (#129)
Cenadros Jun 3, 2024
3f9189c
Filtering design system nodes (#130)
Cenadros Jun 3, 2024
90d6dfd
Filter missing component set (#131)
Cenadros Jun 3, 2024
a411338
Little refactor (#132)
jordisala1991 Jun 3, 2024
f726dc9
Add image library to optimize performance (#133)
jordisala1991 Jun 3, 2024
fd14e54
Ensure translation of symbols is consistent when using components (#134)
jordisala1991 Jun 3, 2024
8a86304
Improve performance of image processing (#135)
jordisala1991 Jun 4, 2024
7895daa
Improve UX for larger files, when the download also takes time to pro…
jordisala1991 Jun 4, 2024
df30dfd
Refactor UI code so it does not fail when exporting (#137)
jordisala1991 Jun 4, 2024
4b711b3
Refactor context (#139)
jordisala1991 Jun 4, 2024
3094f05
Optimize images before generating zip file (#141)
jordisala1991 Jun 5, 2024
be5ff3b
Remote components (External design systems) (#140)
Cenadros Jun 6, 2024
12be821
:bug: Fix component exports (#143)
hirunatan Jun 6, 2024
02fa336
Constraints translation (#142)
Cenadros Jun 6, 2024
7868898
Remove loader when downloading the file (#144)
jordisala1991 Jun 6, 2024
1f8f4bf
Add more loaders so we can track the progress better (#145)
jordisala1991 Jun 6, 2024
872eb6c
Version Packages (#123)
github-actions[bot] Jun 6, 2024
e2d7a31
Change plugin ID (#147)
jordisala1991 Jun 7, 2024
14bcad1
Version Packages (#148)
github-actions[bot] Jun 7, 2024
559a758
Respect nodes visibility and opacity (#152)
jordisala1991 Jun 11, 2024
e9fe86c
Version Packages (#153)
github-actions[bot] Jun 11, 2024
342ab90
Translate line endings done with shift+Enter in Figma (#154)
jordisala1991 Jun 13, 2024
6fc812a
Avoid adding indentation for texts with no indent (#156)
jordisala1991 Jun 13, 2024
d92b200
Send ry on corner-radius (#157)
jordisala1991 Jun 13, 2024
8d35f58
Update package.json (#159)
jordisala1991 Jun 13, 2024
b85a4f7
Autolayout (#151)
Cenadros Jun 14, 2024
af81fc7
Implement rotation for vector lines (#160)
jordisala1991 Jun 14, 2024
e5f2943
Implement rotation for frames and sections (#163)
jordisala1991 Jun 14, 2024
2f11c5f
Fix bugs: opacity on frames and svg fill rules (#164)
jordisala1991 Jun 14, 2024
4591369
Instances Overrides (#166)
Cenadros Jun 17, 2024
202e7f4
Apply rotations to any figure (#168)
jordisala1991 Jun 17, 2024
14c9d02
Text Variables Overrides (#167)
Cenadros Jun 17, 2024
5f88498
fix get component property definitions (#169)
Cenadros Jun 17, 2024
ebad146
Find missing fonts in all the document (#170)
jordisala1991 Jun 17, 2024
199984d
added min-max height-width (#171)
Cenadros Jun 17, 2024
8697902
Add loaders when the file is being built so we can track the progress…
jordisala1991 Jun 18, 2024
738ebfe
Remove symbols when possible (#173)
jordisala1991 Jun 18, 2024
beb3caa
Fix hug in frames (#174)
Cenadros Jun 18, 2024
33d2502
Improve speed at recolect fonts and improve treating modifications (#…
jordisala1991 Jun 18, 2024
4edb964
Cache google fonts traversal (#176)
jordisala1991 Jun 18, 2024
8eb2b1a
fixes (#177)
Cenadros Jun 18, 2024
4e5d01a
remove base rotation and calculate it instead (#178)
jordisala1991 Jun 19, 2024
6725676
Use Fill Styles to generate fills more efficiently (#180)
Cenadros Jun 19, 2024
551d00e
Version Packages (#155)
github-actions[bot] Jun 19, 2024
bc33c0e
Fix plugin scrollbar (#181)
jordisala1991 Jun 19, 2024
b652af1
Version Packages (#182)
github-actions[bot] Jun 19, 2024
a58f9e9
Color libraries (#183)
Cenadros Jun 25, 2024
d3c144e
Text libraries (#185)
Cenadros Jun 25, 2024
e8270cf
Refactor (#188)
Cenadros Jun 25, 2024
aee78de
Refactor libraries (#189)
jordisala1991 Jun 26, 2024
511b842
Additional layout properties (#190)
Cenadros Jun 26, 2024
b003704
Improve paragraph indent (#191)
jordisala1991 Jun 26, 2024
1ebdf3e
Fix components (#193)
jordisala1991 Jun 26, 2024
60cfa4e
Update penpot library (#192)
jordisala1991 Jun 26, 2024
8d185c9
Version Packages (#187)
github-actions[bot] Jun 27, 2024
53672d8
Fix style paths (#194)
jordisala1991 Jun 28, 2024
b0670b8
more fixes (#196)
jordisala1991 Jun 28, 2024
6a5ec1b
Version Packages (#195)
github-actions[bot] Jun 28, 2024
c5dd5d0
Reworked remote components (#197)
Cenadros Jun 28, 2024
303cc83
Fix component overrides (#200)
Cenadros Jun 28, 2024
7a11ba9
Update README.md (#199)
KarinDahlstedt Jun 28, 2024
bd36496
Improve registering component properties (#201)
Cenadros Jun 28, 2024
925e1e4
Version Packages (#198)
github-actions[bot] Jun 28, 2024
dbbbbd7
Update README.md (#202)
jordisala1991 Jun 28, 2024
2b310ee
fix (#203)
Cenadros Jun 28, 2024
07d7b49
Update penpot lib (#204)
Cenadros Jun 28, 2024
e5c3769
Version Packages (#205)
github-actions[bot] Jun 28, 2024
e5c2886
rollback to previous version to prevent issues (#207)
Cenadros Jul 1, 2024
f910653
Version Packages (#208)
github-actions[bot] Jul 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Text libraries (penpot#185)
* color library

* fixes

* wip

* wip

* wip

* wip

* working

* improvements

* changeset

* changeset

* changeset & cleaning

* changeset & cleaning

* improvements

* fixes

* rebase
  • Loading branch information
Cenadros committed Jun 25, 2024
commit d3c144e5e99777bc54635ad3f0067c6927041a90
5 changes: 5 additions & 0 deletions .changeset/heavy-timers-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"penpot-exporter": minor
---

Add support for typographies
5 changes: 5 additions & 0 deletions .changeset/mean-clouds-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"penpot-exporter": patch
---

Improve font weight translation
5 changes: 5 additions & 0 deletions .changeset/selfish-spies-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"penpot-exporter": patch
---

Fix letter spacing
21 changes: 21 additions & 0 deletions plugin-src/TextLibrary.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class TextLibrary {
private styles: Map<string, TextStyle | undefined> = new Map();

public register(id: string, styles?: TextStyle | undefined) {
this.styles.set(id, styles);
}

public get(id: string): TextStyle | undefined {
return this.styles.get(id);
}

public has(id: string): boolean {
return this.styles.has(id);
}

public all(): Record<string, TextStyle | undefined> {
return Object.fromEntries(this.styles.entries());
}
}

export const textLibrary = new TextLibrary();
14 changes: 3 additions & 11 deletions plugin-src/transformers/partials/transformFills.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { translateFillStyleId, translateFills } from '@plugin/translators/fills';
import { StyleTextSegment } from '@plugin/translators/text/paragraph';
import { TextSegment } from '@plugin/translators/text/paragraph';

import { ShapeAttributes } from '@ui/lib/types/shapes/shape';
import { TextStyle } from '@ui/lib/types/shapes/textShape';

export const transformFills = (
node:
| (MinimalFillsMixin & DimensionAndPositionMixin)
| VectorRegion
| VectorNode
| StyleTextSegment
node: (MinimalFillsMixin & DimensionAndPositionMixin) | VectorRegion | VectorNode | TextSegment
): Pick<ShapeAttributes, 'fills' | 'fillStyleId'> | Pick<TextStyle, 'fills' | 'fillStyleId'> => {
if (hasFillStyle(node)) {
return {
Expand Down Expand Up @@ -39,11 +35,7 @@ export const transformVectorFills = (
};

const hasFillStyle = (
node:
| (MinimalFillsMixin & DimensionAndPositionMixin)
| VectorRegion
| VectorNode
| StyleTextSegment
node: (MinimalFillsMixin & DimensionAndPositionMixin) | VectorRegion | VectorNode | TextSegment
): boolean => {
return (
node.fillStyleId !== figma.mixed &&
Expand Down
7 changes: 4 additions & 3 deletions plugin-src/transformers/partials/transformText.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { transformFills } from '@plugin/transformers/partials';
import { transformTextStyle, translateStyleTextSegments } from '@plugin/translators/text';
import { transformTextStyle, translateTextSegments } from '@plugin/translators/text';
import { translateGrowType, translateVerticalAlign } from '@plugin/translators/text/properties';

import { TextAttributes, TextShape } from '@ui/lib/types/shapes/textShape';
Expand All @@ -16,7 +16,8 @@ export const transformText = (node: TextNode): TextAttributes & Pick<TextShape,
'indentation',
'listOptions',
'fills',
'fillStyleId'
'fillStyleId',
'textStyleId'
]);

return {
Expand All @@ -30,7 +31,7 @@ export const transformText = (node: TextNode): TextAttributes & Pick<TextShape,
children: [
{
type: 'paragraph',
children: translateStyleTextSegments(node, styledTextSegments),
children: translateTextSegments(node, styledTextSegments),
...transformTextStyle(node, styledTextSegments[0]),
...transformFills(node)
}
Expand Down
61 changes: 56 additions & 5 deletions plugin-src/transformers/transformDocumentNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@ import { componentsLibrary } from '@plugin/ComponentLibrary';
import { imagesLibrary } from '@plugin/ImageLibrary';
import { remoteComponentLibrary } from '@plugin/RemoteComponentLibrary';
import { styleLibrary } from '@plugin/StyleLibrary';
import { textLibrary } from '@plugin/TextLibrary';
import { translateRemoteChildren } from '@plugin/translators';
import { translatePaintStyles } from '@plugin/translators/fills';
import { translatePaintStyle, translateTextStyle } from '@plugin/translators/styles';
import { sleep } from '@plugin/utils';

import { PenpotPage } from '@ui/lib/types/penpotPage';
import { TypographyStyle } from '@ui/lib/types/shapes/textShape';
import { FillStyle } from '@ui/lib/types/utils/fill';
import { PenpotDocument } from '@ui/types';

import { transformPageNode } from '.';

const isPaintStyle = (style: BaseStyle): style is PaintStyle => {
return style.type === 'PAINT';
};

const isTextStyle = (style: BaseStyle): style is TextStyle => {
return style.type === 'TEXT';
};

const downloadImages = async (): Promise<Record<string, Uint8Array>> => {
const imageToDownload = Object.entries(imagesLibrary.all());
const images: Record<string, Uint8Array> = {};
Expand Down Expand Up @@ -71,7 +81,7 @@ const getFillStyles = async (): Promise<Record<string, FillStyle>> => {
for (const [styleId, paintStyle] of stylesToFetch) {
const figmaStyle = paintStyle ?? (await figma.getStyleByIdAsync(styleId));
if (figmaStyle && isPaintStyle(figmaStyle)) {
styles[styleId] = translatePaintStyles(figmaStyle);
styles[styleId] = translatePaintStyle(figmaStyle);
}

figma.ui.postMessage({
Expand All @@ -87,8 +97,41 @@ const getFillStyles = async (): Promise<Record<string, FillStyle>> => {
return styles;
};

const isPaintStyle = (style: BaseStyle): style is PaintStyle => {
return style.type === 'PAINT';
const getTextStyles = async (): Promise<Record<string, TypographyStyle>> => {
const stylesToFetch = Object.entries(textLibrary.all());
const styles: Record<string, TypographyStyle> = {};

if (stylesToFetch.length === 0) return styles;

let currentStyle = 1;

figma.ui.postMessage({
type: 'PROGRESS_TOTAL_ITEMS',
data: stylesToFetch.length
});

figma.ui.postMessage({
type: 'PROGRESS_STEP',
data: 'typographies'
});

for (const [styleId, style] of stylesToFetch) {
const figmaStyle = style ?? (await figma.getStyleByIdAsync(styleId));
if (figmaStyle && isTextStyle(figmaStyle)) {
styles[styleId] = translateTextStyle(figmaStyle);
}

figma.ui.postMessage({
type: 'PROGRESS_PROCESSED_ITEMS',
data: currentStyle++
});

await sleep(0);
}

await sleep(20);

return styles;
};

const processPages = async (node: DocumentNode): Promise<PenpotPage[]> => {
Expand Down Expand Up @@ -122,6 +165,11 @@ export const transformDocumentNode = async (node: DocumentNode): Promise<PenpotD
styleLibrary.register(style.id, style);
});

const localTextStyles = await figma.getLocalTextStylesAsync();
localTextStyles.forEach(style => {
textLibrary.register(style.id, style);
});

const children = await processPages(node);

if (remoteComponentLibrary.remaining() > 0) {
Expand All @@ -135,11 +183,14 @@ export const transformDocumentNode = async (node: DocumentNode): Promise<PenpotD

const images = await downloadImages();

const typographies = await getTextStyles();

return {
name: node.name,
children,
components: componentsLibrary.all(),
images,
styles
styles,
typographies
};
};
1 change: 0 additions & 1 deletion plugin-src/translators/fills/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './translateFills';
export * from './translateImageFill';
export * from './translatePaintStyles';
export * from './translateSolidFill';
2 changes: 2 additions & 0 deletions plugin-src/translators/styles/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './translatePaintStyle';
export * from './translateTextStyle';
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import { translateFill } from '@plugin/translators/fills/translateFills';

import { FillStyle } from '@ui/lib/types/utils/fill';

export const translatePaintStyles = (figmaStyle: PaintStyle): FillStyle => {
export const translatePaintStyle = (figmaStyle: PaintStyle): FillStyle => {
const fillStyle: FillStyle = {
name: figmaStyle.name,
fills: [],
colors: []
};

const colorName = (figmaStyle: PaintStyle, index: number): string => {
// @TODO: Think something better
return figmaStyle.paints.length > 1 ? `Color ${index + 1}` : figmaStyle.name;
};

Expand Down
32 changes: 32 additions & 0 deletions plugin-src/translators/styles/translateTextStyle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { translateFontName } from '@plugin/translators/text/font';
import {
translateFontStyle,
translateLetterSpacing,
translateLineHeight,
translateTextDecoration,
translateTextTransform
} from '@plugin/translators/text/properties';

import { TypographyStyle } from '@ui/lib/types/shapes/textShape';

export const translateTextStyle = (figmaStyle: TextStyle): TypographyStyle => {
const path = figmaStyle.remote ? 'Remote / ' : '';

return {
name: figmaStyle.name,
textStyle: {
...translateFontName(figmaStyle.fontName),
fontFamily: figmaStyle.fontName.family,
fontSize: figmaStyle.fontSize.toString(),
fontStyle: translateFontStyle(figmaStyle.fontName.style),
textDecoration: translateTextDecoration(figmaStyle),
letterSpacing: translateLetterSpacing(figmaStyle),
textTransform: translateTextTransform(figmaStyle),
lineHeight: translateLineHeight(figmaStyle)
},
typography: {
path,
name: figmaStyle.name
}
};
};
13 changes: 9 additions & 4 deletions plugin-src/translators/text/font/custom/translateCustomFont.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { getCustomFontId, translateFontVariantId } from '@plugin/translators/text/font/custom';

import { FontId } from '@ui/lib/types/shapes/textShape';
import { TextTypography } from '@ui/lib/types/shapes/textShape';

export const translateCustomFont = (fontName: FontName, fontWeight: number): FontId | undefined => {
export const translateCustomFont = (
fontName: FontName,
fontWeight: string
): Pick<TextTypography, 'fontId' | 'fontVariantId' | 'fontWeight'> | undefined => {
const customFontId = getCustomFontId(fontName);
return {
fontId: `custom-${getCustomFontId(fontName)}`,
fontVariantId: translateFontVariantId(fontName, fontWeight)
fontId: customFontId ? `custom-${customFontId}` : '',
fontVariantId: translateFontVariantId(fontName, fontWeight),
fontWeight
};
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const translateFontVariantId = (fontName: FontName, fontWeight: number) => {
export const translateFontVariantId = (fontName: FontName, fontWeight: string) => {
const style = fontName.style.toLowerCase().includes('italic') ? 'italic' : 'normal';

return `${style}-${fontWeight.toString()}`;
return `${style}-${fontWeight}`;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GoogleFont } from './googleFont';
export const translateFontVariantId = (
googleFont: GoogleFont,
fontName: FontName,
fontWeight: number
fontWeight: string
) => {
// check match directly by style
const variant = googleFont.variants?.find(variant => variant === fontName.style.toLowerCase());
Expand All @@ -13,7 +13,7 @@ export const translateFontVariantId = (
// check match by style and weight
const italic = fontName.style.toLowerCase().includes('italic') ? 'italic' : '';
const variantWithWeight = googleFont.variants?.find(
variant => variant === `${fontWeight.toString()}${italic}`
variant => variant === `${fontWeight}${italic}`
);

if (variantWithWeight !== undefined) return variantWithWeight;
Expand Down
10 changes: 7 additions & 3 deletions plugin-src/translators/text/font/gfonts/translateGoogleFont.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@ import slugify from 'slugify';
import { Cache } from '@plugin/Cache';
import { translateFontVariantId } from '@plugin/translators/text/font/gfonts';

import { FontId } from '@ui/lib/types/shapes/textShape';
import { TextTypography } from '@ui/lib/types/shapes/textShape';

import { items as gfonts } from './gfonts.json';
import { GoogleFont } from './googleFont';

const fontsCache = new Cache<string, GoogleFont>({ max: 30 });

export const translateGoogleFont = (fontName: FontName, fontWeight: number): FontId | undefined => {
export const translateGoogleFont = (
fontName: FontName,
fontWeight: string
): Pick<TextTypography, 'fontId' | 'fontVariantId' | 'fontWeight'> | undefined => {
const googleFont = getGoogleFont(fontName);

if (googleFont === undefined) return;

return {
fontId: `gfont-${slugify(fontName.family.toLowerCase())}`,
fontVariantId: translateFontVariantId(googleFont, fontName, fontWeight)
fontVariantId: translateFontVariantId(googleFont, fontName, fontWeight),
fontWeight
};
};

Expand Down
2 changes: 1 addition & 1 deletion plugin-src/translators/text/font/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './translateFontId';
export * from './translateFontName';
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import { LocalFont } from './localFont';
export const translateFontVariantId = (
localFont: LocalFont,
fontName: FontName,
fontWeight: number
fontWeight: string
): string | undefined => {
// check match by style and weight
const italic = fontName.style.toLowerCase().includes('italic');
const variantWithStyleWeight = localFont.variants?.find(
variant =>
variant.weight === fontWeight.toString() && variant.style === (italic ? 'italic' : 'normal')
variant => variant.weight === fontWeight && variant.style === (italic ? 'italic' : 'normal')
);

if (variantWithStyleWeight !== undefined) return variantWithStyleWeight.id;
Expand Down
10 changes: 7 additions & 3 deletions plugin-src/translators/text/font/local/translateLocalFont.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { LocalFont, translateFontVariantId } from '@plugin/translators/text/font/local';

import { FontId } from '@ui/lib/types/shapes/textShape';
import { TextTypography } from '@ui/lib/types/shapes/textShape';

import { items as localFonts } from './localFonts.json';

export const translateLocalFont = (fontName: FontName, fontWeight: number): FontId | undefined => {
export const translateLocalFont = (
fontName: FontName,
fontWeight: string
): Pick<TextTypography, 'fontId' | 'fontVariantId' | 'fontWeight'> | undefined => {
const localFont = getLocalFont(fontName);

if (localFont === undefined) return;

return {
fontId: localFont.id,
fontVariantId: translateFontVariantId(localFont, fontName, fontWeight)
fontVariantId: translateFontVariantId(localFont, fontName, fontWeight),
fontWeight
};
};

Expand Down
13 changes: 0 additions & 13 deletions plugin-src/translators/text/font/translateFontId.ts

This file was deleted.

Loading