You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
582 B
25 lines
582 B
3 years ago
|
/* eslint-disable import/prefer-default-export */
|
||
|
|
||
|
// https://zhuanlan.zhihu.com/p/32746810
|
||
|
export function getFontSizes(base: number) {
|
||
|
const fontSizes = new Array(10).fill(null).map((_, index) => {
|
||
|
const i = index - 1;
|
||
|
const baseSize = base * 2.71828 ** (i / 5);
|
||
|
const intSize = index > 1 ? Math.floor(baseSize) : Math.ceil(baseSize);
|
||
|
|
||
|
// Convert to even
|
||
|
return Math.floor(intSize / 2) * 2;
|
||
|
});
|
||
|
|
||
|
fontSizes[1] = base;
|
||
|
|
||
|
return fontSizes.map(size => {
|
||
|
const height = size + 8;
|
||
|
|
||
|
return {
|
||
|
size,
|
||
|
lineHeight: height / size,
|
||
|
};
|
||
|
});
|
||
|
}
|