@figma-export/core
Advanced tools
Comparing version 4.8.0-alpha.0 to 4.8.0-alpha.1
@@ -49,4 +49,26 @@ "use strict"; | ||
}; | ||
const translateLineHeight = ({ lineHeightPx, lineHeightPercentFontSize, lineHeightUnit, }) => { | ||
if (lineHeightUnit === 'FONT_SIZE_%') { | ||
// Figma API doesn't return `lineHeightPercentFontSize` | ||
// if lineHeightPercent is 100 | ||
return lineHeightPercentFontSize | ||
? Math.fround(lineHeightPercentFontSize / 100).toString() | ||
: '1'; | ||
} | ||
// this unit is deprecated and will be | ||
// removed in future version of Figma API | ||
// https://www.figma.com/developers/api#files-types | ||
if (lineHeightUnit === 'INTRINSIC_%') { | ||
// this looks wrong at first | ||
// but Pixels in this if-branch are intentional | ||
// https://github.com/marcomontalbano/figma-export/pull/156#issuecomment-1931415352 | ||
return `${lineHeightPx}px`; | ||
} | ||
if (lineHeightUnit === 'PIXELS') { | ||
return `${lineHeightPx}px`; | ||
} | ||
throw new Error(`Unknown lineHeightUnit: ${lineHeightUnit}`); | ||
}; | ||
const createTextStyle = (textNode) => { | ||
const { fontFamily, fontWeight, fontSize, lineHeightPx, letterSpacing, italic, textCase, textDecoration, textAlignHorizontal, textAlignVertical, } = textNode.style; | ||
const { fontFamily, fontWeight, fontSize, letterSpacing, italic, textCase, textDecoration, textAlignHorizontal, textAlignVertical, } = textNode.style; | ||
return { | ||
@@ -57,3 +79,3 @@ fontFamily, | ||
letterSpacing, | ||
lineHeight: lineHeightPx, | ||
lineHeight: translateLineHeight(textNode.style), | ||
fontStyle: italic ? 'italic' : 'normal', | ||
@@ -60,0 +82,0 @@ fontVariant: translateFontVariant(textCase), |
{ | ||
"name": "@figma-export/core", | ||
"version": "4.8.0-alpha.0", | ||
"version": "4.8.0-alpha.1", | ||
"description": "@figma-export core functionalities", | ||
@@ -26,3 +26,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@figma-export/types": "^4.8.0-alpha.0", | ||
"@figma-export/types": "^4.8.0-alpha.1", | ||
"axios": "~0.27.2", | ||
@@ -36,3 +36,3 @@ "figma-js": "~1.16.0", | ||
}, | ||
"gitHead": "8f56e7aee0de8b05a22807c99c3f4088dce0c0e2" | ||
"gitHead": "d8bd475ff1861e04a72b5630e1b133c933226ac0" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
63824
778