Skip to content

字体适配问题 #89

Closed
Closed
@joeyczz

Description

@joeyczz

`
/// 实际的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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions