mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2025-01-03 05:10:13 -05:00
e2b5b4a7ea
* structure for fills * structure for fills in text and improvements * fixes * improvements
33 lines
810 B
TypeScript
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)
|
|
};
|
|
});
|
|
};
|