0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2025-01-21 15:02:27 -05:00
penpot-exporter-figma-plugin/plugin-src/transformers/partials/transformTextStyle.ts

30 lines
722 B
TypeScript
Raw Normal View History

import { translateTextDecoration, translateTextTransform } from '@plugin/translators';
import { TextStyle } from '@ui/lib/types/text/textContent';
export const transformTextStyle = (
node: Pick<
StyledTextSegment,
| 'characters'
| 'start'
| 'end'
| 'fontName'
| 'fontSize'
| 'fontWeight'
| 'lineHeight'
| 'letterSpacing'
| 'textCase'
| 'textDecoration'
| 'fills'
>
): Partial<TextStyle> => {
return {
fontFamily: node.fontName.family,
fontSize: node.fontSize.toString(),
fontStyle: node.fontName.style,
fontWeight: node.fontWeight.toString(),
textDecoration: translateTextDecoration(node),
textTransform: translateTextTransform(node)
};
};