Font: Font Scaling Ratio
The font
module provides an interface for applications to obtain font scaling ratio.
Developers can determine whether this interfaces work in the EdgerOS mobile App environment through the following code:
edger.env().then(data => {
if (data.env === 'edgerapp') {
// We work in EdgerOS mobile App environment.
}
}).catch(error => {
console.error(error);
});
Functions
edger.font.getFontScale()
Obtain font scaling ratios.
The font scaling ratio can be set in the mobile system, ranging from 0.9
to 1.2
, Default: 1
. You can also obtain it through the CSS variable --edger-font-scale
.
- Returns: {Promise<{scale: number}>} Promise object.
Example
edger.font.getFontScale().then((res) => {
console.log("font scale: " + res.scale);
}).catch((error) => {
console.error(error);
});
async / await
async function getFontScale() {
try {
const { scale } = await edger.font.getFontScale();
console.log(`font scale: ${scale}`);
} catch (error) {
console.error(error);
}
}