Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

字体适配问题 #89

Closed
joeyczz opened this issue Jan 10, 2020 · 1 comment
Closed

字体适配问题 #89

joeyczz opened this issue Jan 10, 2020 · 1 comment

Comments

@joeyczz
Copy link

joeyczz commented Jan 10, 2020

`
/// 实际的dp与UI设计px的比例
/// The ratio of the actual dp to the design draft px
double get scaleWidth => _screenWidth / uiWidthPx;

double get scaleHeight => _screenHeight / uiHeightPx;

double get scaleText => scaleWidth > scaleHeight ? scaleWidth : scaleHeight;
`

97行这段感觉有点奇怪,假设设计图是iPhone 6(375667),UI尺寸是 7501334
iPhone 6(375667)上 scaleWidth和scaleHeight都是0.5
iPhone X(375
812)上 scaleWidth是0.5 scaleHeight是812/1334=0.6

iPhone X上最终字体是按高度计算缩放的

当然也可以把调整传入高度

ScreenUtil.init( context, width: 750, height: 2000, // 放大高度让 scaleHeight始终偏小 allowFontScaling: false, );

version 1.0.1

@lizhuoyuan
Copy link
Collaborator

我一开始想的是支持pad上的字体缩放, 看起来有点草率了
我再考虑一下怎么弄更好

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants