优化组件/更新

This commit is contained in:
gyq
2025-12-03 10:13:55 +08:00
parent 92f9776a35
commit 09b6e36a52
261 changed files with 22080 additions and 7238 deletions

View File

@@ -0,0 +1,30 @@
import { FontSize } from './interface';
export function getLineHeight(fontSize : number) : number {
return (fontSize + 8) / fontSize;
}
// https://zhuanlan.zhihu.com/p/32746810
export function getFontSizes(base : number) : FontSize[] {
const length = 11 // 10
const offset = 2 // 1
// #ifdef APP-ANDROID
const arr = Array.fromNative(new IntArray(length.toInt()));
// #endif
// #ifndef APP-ANDROID
const arr = Array.from({ length });
// #endif
const fontSizes = arr.map((_, index) : number => {
const i = index - offset;
const baseSize = base * Math.pow(Math.E, i / 5);
const intSize = index > 1 ? Math.floor(baseSize) : Math.ceil(baseSize);
// Convert to even
return Math.floor(intSize / 2) * 2;
});
fontSizes[offset] = base;
return fontSizes.map((size) : FontSize => ({
size,
lineHeight: getLineHeight(size),
} as FontSize));
}