• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# ArkGraphics2D Changelog
2
3## cl.arkgraphics2d.1 Added ohos.graphics2d.text.adapter_text_height to the metadata Tag of the Main Module to Enable a New Line Height Calculation Rule Globally
4
5**Access Level**
6
7Public API
8
9**Reason for Change**
10
11To further improve text rendering, a field is introduced to enable applications to adopt a new line height calculation rule across the entire application.
12
13**Change Impact**
14
15This change is a compatible change.
16
17The **ohos.graphics2d.text.adapter_text_height** field is added to the [**metadata** tag in the module.json5 file](../../../application-dev/quick-start/module-configuration-file.md#metadata) of the main module to enable the new line height calculation rule for the application.
18
19```json
20{
21    "module": {
22        "name": "test",
23        "type": "entry",
24        "metadata": [
25            {
26                "name": "ohos.graphics2d.text.adapter_text_height",
27            }
28        ]
29    }
30}
31```
32If **ohos.graphics2d.text.adapter_text_height** is not configured, the default line height calculation rule is used. The default rule is calculated as follows:
33
34For a font size of **fontSize** (px), the rule is (|descender| + |ascender|)/unitsPerEm * fontSize.
35
36If **ohos.graphics2d.text.adapter_text_height** is configured in the main module, the default line height calculation rule is enabled for the entire application. The new rule is as follows:
37
381. For custom fonts: For a font size of **fontSize** (px), the rule is (|yMin| + |yMax|) /unitsPerEm * fontSize.
392. For system fonts: For a font size of **fontSize** (px), the rule is (|yMin| + |yMax|) /unitsPerEm * fontSize. For system fonts, the line height calculation is based on the **HarmonyOS_Sans.ttf** file.
40
41You can use the [font inspector](https://opentype.js.org/font-inspector.html) to view the parameters in a font file and learn about the line height and effect of the font.
42
43The following uses the **HarmonyOS_Sans.ttf** file as an example to describe the default and new rules for calculating the line height.
44
45| Parameters in the HarmonyOS_Sans.ttf font file                       |
46| ----------------------------------------------------- |
47| ![HarmonyOS_Sans.ttf](figures/HarmonyOS_Sans.ttf.png) |
48
49The figure shows that at a 1000 px font size for HarmonyOS_Sans, yMin is -271, yMax is 1056, ascender is 928, and descender is -244.
501. According to the default rule, the line height for 50 px HaromonyOS_Sans is (|-244| + |928|)/1000 * 50 = 58.6 px.
512. According to the new rule, the line height for 50 px HaromonyOS_Sans is (|-271| + |1056|)/1000 * 50 = 66.35 px.
52
53**Start API Level**
54
5513
56
57**Change Since**
58
59OpenHarmony SDK 5.0.0.46
60
61**Key API/Component Changes**
62
63N/A
64
65**Adaptation Guide**
66
67The new line height calculation rule will be used as the default rule in later versions. For compatibility and UI display, you are advised to use this rule during application development.
68
69After the setting of **ohos.graphics2d.text.adapter_text_height** in the main module, the application UI might display unexpected issues like text being cut off, elements overlapping, or shifts in the relative positioning of content. You need to adjust the layouts of the affected pages.
70