Skip to content

Commit 4d592cd

Browse files
committed
fix lineHeight on multiple font when size must be updated by fit ratio
1 parent 91ff42d commit 4d592cd

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/helpers/helpers.options.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,16 @@ export const shouldFit = (options, fitRatio) => options && options.autoFit && fi
136136
*/
137137
export function toFonts(options, fitRatio) {
138138
const optFont = options.font;
139-
let fonts = isArray(optFont) ? optFont.map(f => toFont(f)) : [toFont(optFont)];
139+
const fonts = isArray(optFont) ? optFont : [optFont];
140140
if (shouldFit(options, fitRatio)) {
141-
fonts = fonts.map(function(f) {
142-
f.size = Math.floor(f.size * fitRatio);
143-
f.lineHeight = undefined;
144-
return toFont(f);
141+
return fonts.map(function(f) {
142+
const font = toFont(f);
143+
font.size = Math.floor(f.size * fitRatio);
144+
font.lineHeight = f.lineHeight;
145+
return toFont(font);
145146
});
146147
}
147-
return fonts;
148+
return fonts.map(f => toFont(f));
148149
}
149150

150151
/**

0 commit comments

Comments
 (0)