0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 21:53:27 -05:00
penpot-exporter-figma-plugin/plugin-src/translators/styles/translateTextStyle.ts
Alex Sánchez d3c144e5e9
Text libraries (#185)
* color library

* fixes

* wip

* wip

* wip

* wip

* working

* improvements

* changeset

* changeset

* changeset & cleaning

* changeset & cleaning

* improvements

* fixes

* rebase
2024-06-25 16:08:59 +02:00

32 lines
1,011 B
TypeScript

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
}
};
};