Font: Font Scaling Ratio

更新时间:
2024-07-05
下载文档

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);
  }
}
文档内容是否对您有所帮助?
有帮助
没帮助