mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-22 13:43:03 -05:00
🐛 Add default values for text with segments (pending support segments)
This commit is contained in:
parent
ea0df60ac8
commit
415c8084dd
1 changed files with 30 additions and 8 deletions
38
src/code.ts
38
src/code.ts
|
@ -68,17 +68,39 @@ function traverse(node): NodeData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//TODO Fix text segments with https://www.figma.com/plugin-docs/api/properties/TextNode-getstyledtextsegments
|
||||||
|
const defaultFontName = {
|
||||||
|
"family": "Inter",
|
||||||
|
"style": "Regular"
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultFontSize = 12;
|
||||||
|
|
||||||
|
const defaultFontWeight = 400
|
||||||
|
const defaultLineHeight = {
|
||||||
|
"unit": "AUTO"
|
||||||
|
};
|
||||||
|
|
||||||
|
const defaultLetterSpacing = {
|
||||||
|
"unit": "PERCENT",
|
||||||
|
"value": 0
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultTextAlignHorizontal = "LEFT";
|
||||||
|
const defaultTextAlignVertical = "TOP";
|
||||||
|
|
||||||
if (node.type == "TEXT") {
|
if (node.type == "TEXT") {
|
||||||
|
|
||||||
let font = {
|
let font = {
|
||||||
fontName: node.fontName,
|
fontName: typeof node.fontName === 'symbol'? defaultFontName: node.fontName, //TODO This means a text with several styles
|
||||||
fontSize: node.fontSize,
|
fontSize: typeof node.fontSize === 'symbol'? defaultFontSize: node.fontSize, //TODO This means a text with several styles
|
||||||
fontWeight: node.fontWeight,
|
fontWeight: typeof node.fontWeight === 'symbol'? defaultFontWeight: node.fontWeight, //TODO This means a text with several styles
|
||||||
characters: node.characters,
|
characters: typeof node.characters === 'symbol'? '': node.characters, //TODO This means a text with several styles
|
||||||
lineHeight: node.lineHeight,
|
lineHeight: typeof node.lineHeight === 'symbol'? defaultLineHeight: node.lineHeight, //TODO This means a text with several styles
|
||||||
letterSpacing: node.letterSpacing,
|
letterSpacing: typeof node.letterSpacing === 'symbol'? defaultLetterSpacing: node.letterSpacing, //TODO This means a text with several styles
|
||||||
textAlignHorizontal: node.textAlignHorizontal,
|
textAlignHorizontal: typeof node.textAlignHorizontal === 'symbol'? defaultTextAlignHorizontal: node.textAlignHorizontal, //TODO This means a text with several styles
|
||||||
textAlignVertical: node.textAlignVertical
|
textAlignVertical: typeof node.textAlignVertical === 'symbol'? defaultTextAlignVertical: node.textAlignVertical, //TODO This means a text with several styles
|
||||||
};
|
};
|
||||||
|
|
||||||
result = {...result, ...font};
|
result = {...result, ...font};
|
||||||
|
|
Loading…
Reference in a new issue