0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2025-01-03 05:10:13 -05:00
penpot-exporter-figma-plugin/plugin-src/translators/translateStyledTextSegments.ts
Alex Sánchez e2b5b4a7ea
Solid Fills (#39)
* structure for fills

* structure for fills in text and improvements

* fixes

* improvements
2024-04-17 15:27:53 +02:00

33 lines
810 B
TypeScript

import { transformTextStyle } from '@plugin/transformers/partials';
import { translateFills } from '@plugin/translators/translateFills';
import { TextNode } from '@ui/lib/types/text/textContent';
export const translateStyledTextSegments = (
segments: Pick<
StyledTextSegment,
| 'characters'
| 'start'
| 'end'
| 'fontName'
| 'fontSize'
| 'fontWeight'
| 'lineHeight'
| 'letterSpacing'
| 'textCase'
| 'textDecoration'
| 'fills'
>[],
width: number,
height: number
): TextNode[] => {
return segments.map(segment => {
figma.ui.postMessage({ type: 'FONT_NAME', data: segment.fontName.family });
return {
fills: translateFills(segment.fills, width, height),
text: segment.characters,
...transformTextStyle(segment)
};
});
};