Use fp as the font size unit to adapt to the system font settings.
// code-linter.json5
{
"rules": {
"@cross-device-app-dev/font-size-unit": "warn"
}
} const FONT_SIZE = 12;
@Entry
@Component
struct Index {
build() {
RelativeContainer() {
Text('message').fontSize(FONT_SIZE)
Text('message').fontSize('12fp')
}
}
} @Entry
@Component
struct Index1 {
build() {
RelativeContainer() {
Text('message').fontSize('12vp')
Text('message').fontSize('12px')
Text('message').fontSize('12lpx')
}
}
} plugin:@cross-device-app-dev/recommended plugin:@cross-device-app-dev/all
For details about how to configure Code Linter check rules, see Code Linter.