Text rendering method, device, vehicle and electronic device

By dynamically calculating and passing the actual width of text nodes in the Kanzi engine, the inaccuracy problem of ActualWidth attribute in complex scenarios is solved, the accuracy of UI layout and user experience is improved, the stability and real-time of the system are enhanced, and the development process is simplified.

CN119336435BActive Publication Date: 2025-07-22CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411461167.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-18
Publication Date
2025-07-22
Estimated Expiration
2044-10-18

AI Technical Summary

Technical Problem

The ActualWidth attribute in the Kanzi engine cannot accurately reflect the true width of the text when the text content changes dynamically or the style is complex, resulting in invalid layout, slow dynamic response, inaccurate UI element control and inconsistent performance, affecting the user's visual experience.

Method used

Before rendering the vehicle display page, the text resource content is matched from the preset classical language mapping table based on the alarm identifier and language to be displayed, and the layout calculation is performed, the current actual width is determined, and it is transmitted to the vehicle display page rendering module, avoiding relying on the ActualWidth attribute, dynamically compute and pass the actual width of the text node.

Benefits of technology

It improves the accuracy of UI layout and user visual experience, enhances the compatibility and stability of the system, simplifies the development process, reduces development costs, and improves real-time and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119336435B_ABST
    Figure CN119336435B_ABST
Patent Text Reader

Abstract

Embodiments of the present application relate to the field of vehicle technologies, and propose a text rendering method, apparatus, vehicle, and electronic device. Before rendering the display content of the vehicle display page, the method matches the text resource content to be displayed from a preset classical Chinese mapping table according to the alarm identifier to be displayed and the alarm language to be displayed, performs layout calculation on it to obtain the layout data to be displayed for the text resource content to be displayed, determines the current actual width of the text resource content to be displayed based on the layout data to be displayed, and transmits the current actual width to the vehicle display page rendering module, so that the vehicle display page rendering module renders the text resource content to be displayed based on the current actual width. By dynamically calculating the actual width of text nodes in the code generated based on this method and passing the calculation result to the data context of the vehicle display page rendering module such as the Kanzi engine, the accuracy of UI layout and the user's visual experience are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of vehicles, and in particular, to a text rendering method, apparatus, vehicle, and electronic device. Background Art

[0002] With the development of Human Machine Interface (HMI) technology, the Kanzi engine has gradually become a widely used graphical user interface development tool in fields such as automotive and consumer electronics. The Kanzi engine supports cross-platform high-performance real-time rendering, enabling developers to quickly create complex user interfaces and easily integrate them into embedded systems. In the Kanzi engine, developers usually control the dynamic display of UI (User Interface) elements through data binding and style application to achieve rich interaction effects.

[0003] In the process of Kanzi development, the layout and rendering of text nodes are an important link. The Kanzi engine provides various layout methods and attributes to control the display of text. For example, the ActualWidth attribute is used to dynamically obtain the actual width of a text node. This attribute is used in many scenarios to adjust the UI layout in real time according to the length of the text content, thereby improving the user experience.

[0004] However, although the ActualWidth attribute can theoretically return the actual width value of a text node in real time, in practice, especially when the text content changes dynamically or the style of the text node is complex, the ActualWidth attribute in the Kanzi engine often fails to accurately reflect the true width of the text. This inaccuracy can lead to problems such as layout failure, slow dynamic response, inability to precisely control UI elements, and inconsistent UI performance, affecting the user's visual experience. Summary of the Invention

[0005] Embodiments of this application provide a text rendering method, apparatus, vehicle, and electronic device to solve the technical problem that the ActualWidth attribute in the Kanzi engine in related technologies often fails to accurately reflect the true width of the text, which can lead to problems such as layout failure, slow dynamic response, inability to precisely control UI elements, and inconsistent UI performance, affecting the user's visual experience.

[0006] An embodiment of the present application provides a text rendering method, which includes: before rendering the display content of the vehicle display page, matching the text resource content to be displayed from a preset classical Chinese mapping table according to the alarm identifier to be displayed and the alarm language to be displayed; performing layout calculation on the text resource content to be displayed to obtain the layout data to be displayed of the text resource content to be displayed; determining the current actual width of the text resource content to be displayed based on the layout data to be displayed; and transmitting the current actual width to the vehicle display page rendering module, so that the vehicle display page rendering module renders the text resource content to be displayed based on the current actual width.

[0007] In an embodiment of the present application, matching the text resource content to be displayed from a preset classical Chinese mapping table according to the alarm identifier to be displayed and the alarm language to be displayed includes: matching the alarm identifier to be displayed with the preset alarm identifiers in the preset classical Chinese mapping table, and determining the successfully matched preset alarm identifier as the target alarm identifier, where the preset classical Chinese mapping table includes a plurality of preset alarm identifiers and the classical Chinese of one or more languages corresponding to each preset alarm identifier; determining the target classical Chinese from the classical Chinese of each language corresponding to the target alarm identifier according to the alarm language to be displayed, and using the target classical Chinese as the text resource content to be displayed.

[0008] In an embodiment of the present application, before performing layout calculation on the text resource content to be displayed to obtain the layout data to be displayed of the text resource content to be displayed, the method further includes: presetting text attributes, where the text attributes include at least one of font, font size, line spacing, and vertical padding.

[0009] In an embodiment of the present application, performing layout calculation on the text resource content to be displayed to obtain the layout data to be displayed of the text resource content to be displayed includes: comparing the text resource content to be displayed with the previous displayed text resource content; if the number of bytes of the text resource content to be displayed is the same as that of the previous displayed text resource content, and the text attributes and the alarm language to be displayed have not changed, using the historical layout data corresponding to the previous displayed text resource content as the layout data to be displayed.

[0010] In an embodiment of the present application, the method further includes: if the number of bytes of the text resource content to be displayed is different from that of the previous displayed text resource content, or at least one of the text attributes and the alarm language to be displayed changes, performing layout calculation on the text resource content to be displayed to obtain the layout data to be displayed of the text resource content to be displayed.

[0011] In an embodiment of the present application, transmitting the current actual width to the vehicle display page rendering module includes: transmitting the current actual width to the data context of the vehicle display page rendering module; obtaining the current actual width from the data context through a preset attribute in the human-computer interaction interface element, where the preset attribute is pre-bound to a preset main project variable in the data context; if a preset text variable in several target sub-projects in the vehicle display page rendering module is bound to the preset main project variable, when the preset main project variable obtains the current actual width, the preset text variable is automatically updated accordingly.

[0012] In an embodiment of the present application, before performing layout calculation on the text resource content to be displayed, the method further includes: comparing the text resource content to be displayed with all the historical displayed text resource contents that have been displayed; if there is a historical displayed text resource content that is the same as the text resource content to be displayed, using the historical actual width cached corresponding to the same historical displayed text resource content as the current actual width, and triggering the step of transmitting the current actual width to the vehicle display page rendering module; if all the historical displayed text resource contents are different from the text resource content to be displayed, triggering the step of performing layout calculation on the text resource content to be displayed.

[0013] An embodiment of the present application further provides a text rendering device, where the text rendering device includes a matching module, configured to match and obtain the text resource content to be displayed from a preset classical Chinese mapping table according to the alarm identifier to be displayed and the alarm language to be displayed before rendering the display content of the vehicle display page; a layout calculation module, configured to perform layout calculation on the text resource content to be displayed to obtain the to-be-displayed layout data of the text resource content to be displayed; an actual width determination module, configured to determine the current actual width of the text resource content to be displayed based on the to-be-displayed layout data; and a rendering module, configured to transmit the current actual width to the vehicle display page rendering module, so that the vehicle display page rendering module renders the text resource content to be displayed based on the current actual width.

[0014] An embodiment of the present application further provides a vehicle, including the text rendering device according to any one of the above embodiments and a display device, where the display device is configured to display the vehicle display page rendered by the text rendering device.

[0015] An embodiment of the present application further provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where when the processor executes the computer program, the method according to any one of the above embodiments is implemented.

[0016] The embodiments of the present application also provide a computer-readable storage medium storing a computer program, which when executed by a processor implements the method described in any of the above embodiments.

[0017] In the solution implemented by the above-provided text rendering method, device, vehicle, and electronic device, before rendering the display content of the vehicle display page, the text rendering method matches the to-be-displayed text resource content from a preset classical Chinese mapping table according to the to-be-displayed alarm identifier and the to-be-displayed alarm language, performs layout calculation on the to-be-displayed text resource content to obtain the to-be-displayed layout data of the to-be-displayed text resource content, determines the current actual width of the to-be-displayed text resource content based on the to-be-displayed layout data, and transmits the current actual width to the vehicle display page rendering module, so that the vehicle display page rendering module renders the to-be-displayed text resource content based on the current actual width, and no longer relies on the ActualWidth attribute in the Kanzi engine to calculate the current actual width of the to-be-displayed text resource content, avoiding the problem of inaccurate calculation of the ActualWidth attribute in some complex scenarios. The actual width of the text node can be dynamically calculated in the code generated based on this method, and the calculation result can be passed to the data context of the vehicle display page rendering module such as the Kanzi engine, improving the accuracy of the UI layout and the user's visual experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] To more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for the description of the embodiments of the present application. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0019] Figure 1 It is a flowchart of the text rendering method provided by the embodiments of the present application;

[0020] Figure 2 It is a schematic diagram of a preset classical Chinese mapping table provided by the embodiments of the present application;

[0021] Figure 3 It is a schematic diagram of adding a binding in the Release binding of Kanzi provided by the embodiments of the present application;

[0022] Figure 4 It is a schematic diagram of an alias binding provided by the embodiments of the present application;

[0023] Figure 5 It is a schematic diagram of the alias binding logic in Kanzi provided by the embodiments of the present application;

[0024] Figure 6 A structural schematic diagram of the text rendering device provided by an embodiment of the present application;

[0025] Figure 7 A structural schematic diagram of the electronic device provided by an embodiment of the present application. Detailed implementation manners

[0026] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0027] There is one or more display screens in a vehicle, and at least some of the display screens will display vehicle alarm text prompts, such as "During assisted driving, the full-screen map cannot be switched" and "Please note to take over", etc. These vehicle alarm text prompts can change with the changes in the driving state and working state of the vehicle. When changes occur, it is necessary to re-render the display content of the vehicle display page on the display screen. In the related art, the width of the text node is often calculated through a preset rendering engine, such as the ActualWidth attribute in the Kanzi engine, and then text rendering is performed. However, due to factors such as the dynamic change of the text content or the complex style of the text node, the ActualWidth attribute cannot obtain the real width of the text node, resulting in the occurrence of problems including but not limited to the following:

[0028] Layout failure: When the length of the text content exceeds the expectation and the ActualWidth attribute cannot correctly reflect it, the UI layout may experience flickering, overflow, overlap, or other display errors, seriously affecting the user's visual experience.

[0029] Slow dynamic response: Since the ActualWidth attribute needs to be determined in the rendering stage in some cases, the interface response speed becomes slow in complex scenarios, increasing the delay of user interaction.

[0030] Unable to precisely control UI elements: When developers handle some scenarios that require precise control of the text width, they cannot rely solely on the ActualWidth attribute to achieve it. This makes it necessary for developers to write additional code for manual calculation when adjusting the text width in layout or animation, increasing the development difficulty.

[0031] Inconsistent performance: The rendering results may vary on different platforms or devices. Especially in the scenario of multi-language support, the calculation results of the text width for different fonts or styles are inconsistent, resulting in inconsistent UI performance.

[0032] Therefore, to address the significant limitations and instability of the ActualWidth property in certain key application scenarios in related technologies, it is difficult to meet the requirements for high-precision and high-real-time text width calculation. Thus, it is particularly necessary to develop a method that can accurately calculate and transfer the actual width of text nodes in vehicle display page rendering modules such as the Kanzi engine. To solve the above problems, the embodiments of this application provide a text rendering method. Before rendering the display content of the vehicle display page, the content of the text resource to be displayed is obtained by matching from a preset classical Chinese mapping table according to the alarm identifier to be displayed and the language of the alarm to be displayed. Layout calculation is performed on the content of the text resource to be displayed to obtain the layout data to be displayed for the content of the text resource to be displayed. Based on the layout data to be displayed, the current actual width of the content of the text resource to be displayed is determined, and the current actual width is transmitted to the vehicle display page rendering module, so that the vehicle display page rendering module renders the content of the text resource to be displayed based on the current actual width, no longer relying on the ActualWidth property in the Kanzi engine to calculate the current actual width of the content of the text resource to be displayed, avoiding the problem of inaccurate calculation of the ActualWidth property in some complex scenarios. The actual width of the text node can be dynamically calculated in the code generated based on this method, and the calculation result is passed to the data context of the vehicle display page rendering module such as the Kanzi engine, improving the accuracy of the UI layout and the user's visual experience.

[0033] Please refer to Figure 1 as shown in Figure 1 a flowchart of the text rendering method provided by the embodiments of this application. The method includes the following steps:

[0034] Step S110, before rendering the display content of the vehicle display page, obtain the content of the text resource to be displayed by matching from a preset classical Chinese mapping table according to the alarm identifier to be displayed and the language of the alarm to be displayed.

[0035] The vehicle display page can be the display page on the display screen of the vehicle. Before it needs to be rendered and updated, the width of the text node needs to be accurately calculated for accurate rendering.

[0036] The alarm identifier to be displayed can be the alarm identifier that needs to be displayed for the current state of the vehicle. The specific generation method and the like can be implemented by referring to the methods in the prior art and are not limited here. The alarm identifier to be displayed can be pre-configured by those skilled in the art.

[0037] The preset classical Chinese mapping table is pre-set by those skilled in the art and includes multiple preset alarm identifiers and the classical Chinese of one or more languages corresponding to each preset alarm identifier. Please refer toFigure 2 , Figure 2 This is a schematic diagram of a preset classical Chinese mapping table provided by an embodiment of the present application. As Figure 2 shown, a part of the content of the preset classical Chinese mapping table is displayed. To adapt to a multilingual environment, multiple mapping tables are defined to manage text resources corresponding to different languages and alarm IDs. First, the LOCALURL variable is defined, pointing to the basic path of the Kanzi Chinese text resources: const std::string LOCALURL = "kzb: / / warningmsg / Locales / "; Any path name starting with kzb directly corresponds to certain resources in Kanzi. In this example, it corresponds to the classical Chinese table resources in Kanzi.

[0038] Then, the mMapLanguage map variable is used to manage different languages:

[0039] mMapLanguage[0] = "zh";

[0040] mMapLanguage[1] = "en";

[0041] mMapLanguage[2] = "ar";

[0042] mMapLanguage[3] = "fa";

[0043] mMapLanguage[4] = "ru";

[0044] mMapLanguage[5] = "he";

[0045] mMapLanguage[6] = "de";

[0046] mMapLanguage[7] = "nl";

[0047] mMapLanguage[8] = "nb";

[0048] mMapLanguage[9] = "es";

[0049] mMapLanguage

[10] = "hu";

[0050] The above mapping associates different language codes (language species) with their corresponding string values. These strings are used to construct resource paths to load text resources in the corresponding languages.

[0051] Next, manage the correspondence between the alarm ID and the specific text resource ID through the mMapIdContent mapping table (preset classical Chinese mapping table):

[0052] mMapIdContent[1] = "001"; / / The id corresponds to ADAS_TEXT_001,

[0053] mMapIdContent[2] = "002";

[0054] mMapIdContent[3] = "003";

[0055] mMapIdContent[4] = "004";

[0056] mMapIdContent[5] = "004";

[0057] mMapIdContent[6] = "005";

[0058] mMapIdContent[7] = "006";

[0059] mMapIdContent[8] = "007";

[0060] mMapIdContent[9] = "007";

[0061] mMapIdContent

[10] = "007";

[0062] mMapIdContent

[11] = "007";

[0063] mMapIdContent

[12] = "008"; / / More mappings follow...

[0064] The en, ru, de, etc. in the first row are the values stored in mMapLanguage. The ADAS_TEXT_001 corresponding to the resourceID (preset alarm identifier, i.e., alarm ID) in the first column, and the three - digit numbers following also correspond to the values stored in mMapIdContent.

[0065] In one embodiment, obtaining the content of the text resource to be displayed by matching from a preset classical Chinese mapping table according to the alarm identifier to be displayed and the alarm language to be displayed includes: matching the alarm identifier to be displayed with the preset alarm identifiers in the preset classical Chinese mapping table, and determining the successfully matched preset alarm identifier as the target alarm identifier. The preset classical Chinese mapping table includes multiple preset alarm identifiers and the classical Chinese in one or more languages corresponding to each preset alarm identifier; determining the target classical Chinese from the classical Chinese in each language corresponding to the target alarm identifier according to the alarm language to be displayed, and using the target classical Chinese as the content of the text resource to be displayed.

[0066] Continue to refer to Figure 2 , taking the alarm identifier to be displayed as ADAS_TEXT_001 as an example, various languages of classical Chinese in the first row can be obtained by matching in the preset classical Chinese mapping table, and then a classical Chinese is selected from them as the target classical Chinese according to the alarm language to be displayed, that is, the content of the text resource to be displayed.

[0067] As an example implementation method, what is stored in mMapIdContent is the three digits after ADAS_TEXT_001. To obtain the specific classical Chinese, it is necessary to first splice the string into the correct Resource ID name of the specific resource that can be obtained. The specific code of an example is as follows:

[0068] const std::string LOCALURL = "kzb: / / warningmsg / Locales / "; / / Obtain the kzb address of the classical Chinese table in kanzi:

[0069] string localeUrl = LOCALURL + it->second; / / Specifically obtain the classical Chinese table of each language. For example, for the classical Chinese table in English, a complete address is kzb: / / warningmsg / Locales / en;

[0070] ResourceDictionarySharedPtr resDic =

[0071] LogicAdapterIns->getResourceManager()->tryAcquireResource <resourcedictionary>(localeUrl); Load the entire classical Chinese table and obtain the entire classical Chinese table resources;

[0072] std::string con = "ADAS_TEXT_" + itc->second; / / Based on the found alarm ID, construct the ResourceID name in the specific classical Chinese table, such as ADAS_TEXT_001, to find the corresponding text content in the classical Chinese table;

[0073] TextResourceSharedPtr textRes = resDic->acquire <textresource>(ResourceID(con)); Obtain one of the specific classical Chinese texts;

[0074] mCalcuWidth->setText(textRes->getText()); / / Set the text resource content obtained (through textRes->getText()) into the mCalcuWidth object for layout and width calculation.

[0075] In the above way, the specific text content to be displayed currently can be determined.

[0076] Step S120, perform layout calculation on the text resource content to be displayed to obtain the to-be-displayed layout data of the text resource content to be displayed.

[0077] In one embodiment, before performing layout calculation on the text resource content to be displayed to obtain the to-be-displayed layout data of the text resource content to be displayed, the method further includes: presetting text attributes, where the text attributes include at least one of font, font size, line spacing, and vertical padding.

[0078] As an example, the setting of text attributes can be implemented in the following code manner. Define a TextBlock2D object in the code to be responsible for the width calculation of the text content. TextBlock2D is a UI element in the Kanzi engine for displaying text and supporting various layout and style configurations.

[0079] mCalcuWidth = TextBlock2D::create(LogicAdapterIns->getDomain(), "adasCal cu");

[0080] mCalcuWidth->setFontSize(28);

[0081] mCalcuWidth->setLineSpacing(0.7);

[0082] mCalcuWidth->setVerticalPadding(Vector2(10, 26));

[0083] mCalcuWidth->setVisible(false);

[0084] LogicAdapterIns->getScreenPtr()->addChild(mCalcuWidth);

[0085] In the above code, similar to Kanzi, the property values of the text are first set. A TextBlock2D object is created, and properties such as font size, line spacing, and vertical padding are set. Through the above code, some properties such as font size and line spacing of the text whose width is to be calculated are set well.

[0086] LogicAdapterIns->getDomain() will return the logical domain of the current application, which is a core concept of Kanzi and represents the logical context where the UI element is located. By obtaining this domain, the TextBlock2D object can be created and managed in this logical domain.

[0087] LogicAdapterIns->getScreenPtr()->addChild(mCalcuWidth) adds the created TextBlock2D object to the child nodes of the current screen, making it part of the display interface. Although this object is visually invisible (setVisible(false)), it will participate in the layout calculation to obtain the actual text width.

[0088] In one embodiment, layout calculation is performed on the content of the text resource to be displayed to obtain the layout data to be displayed for the content of the text resource to be displayed, including: comparing the content of the text resource to be displayed with the content of the previous displayed text resource; if the number of bytes of the content of the text resource to be displayed is the same as that of the previous displayed text resource, and the text attributes and the language of the alarm to be displayed have not changed, using the historical layout data corresponding to the previous displayed text resource as the layout data to be displayed.

[0089] Continuing with the above embodiment, the method further includes: if the number of bytes of the content of the text resource to be displayed is different from that of the previous displayed text resource, or at least one of the text attributes and the language of the alarm to be displayed changes, performing layout calculation on the content of the text resource to be displayed to obtain the layout data to be displayed for the content of the text resource to be displayed.

[0090] It can be understood that if only the replacement of the text itself is involved, and the language, text attributes, and number of characters do not change, for example, replacing "Please note" with "Please wait a moment" and other similar situations, there is no need to repeat the layout calculation, and the original historical layout data can be used as the layout data to be displayed, which can reduce the consumption of computing resources. Of course, those skilled in the art can also stipulate that every time there is new content to be refreshed, regardless of whether it is the above situation that requires re-layout calculation, re-layout calculation is performed.

[0091] As an example, the code implementation of this layout calculation is as follows: mCalcuWidth->setText(textRes->getText()); / / Set the text resource content obtained (obtained through textRes->getText()) into the mCalcuWidth object to prepare for layout and width calculation.

[0092] mCalcuWidth->layout(); / / The layout method calculates the actual size of the text based on the text content, font, line spacing, padding, and other styles. When the text content is dynamically updated, calling layout() can recalculate the width and height of the text.

[0093] In one embodiment, before performing layout calculation on the text resource content to be displayed, the method further includes: comparing the text resource content to be displayed with all the historical displayed text resource contents that have been displayed; if there is a historical displayed text resource content that is the same as the text resource content to be displayed, using the historical actual width corresponding to the same historical displayed text resource content as the current actual width, and triggering the step of transmitting the current actual width to the vehicle display page rendering module; if all the historical displayed text resource contents are different from the text resource content to be displayed, triggering the step of performing layout calculation on the text resource content to be displayed.

[0094] It can be understood that since the alarm content of the vehicle is actually limited and it is possible that the content has been displayed before, if it is recalculated every time, it will cause waste of computing power. Therefore, the actual width obtained each time a new content is calculated can be cached, and the actual width can be directly retrieved from the cache next time without repeated calculation. If the content has not been displayed before, the actual width needs to be recalculated.

[0095] Step S130, determining the current actual width of the text resource content to be displayed based on the layout data to be displayed.

[0096] As an example, the code implementation of the method for determining the current actual width is as follows:

[0097] int width = mCalcuWidth->getActualWidth(); / / Obtain the actual width of the text.

[0098] LogicAdapterIns->getResourceManager()->tryAcquireResource <resourcedictionary>(localeUrl) is responsible for loading the ResourceDictionary from the specified path (localeUrl). The ResourceManager is one of the core modules in the Kanzi engine and is responsible for managing resources in the application, such as text, images, styles, etc. The tryAcquireResource method is used to attempt to load or acquire the specified resource. If the resource already exists in the cache, it is returned directly.

[0099] Via resDic->acquire <textresource>(ResourceID(con)) gets the specific text resource from the classical Chinese table and sets it to the TextBlock2D object. Then, layout is performed using the layout() method, and finally the actual width of the text is obtained using getActualWidth().

[0100] The above method can be used to calculate the text node width without relying on Kanzi's own ActualWidth attribute. However, the actual width of the text node obtained by the above method, that is, the current actual width, is actually not known by the vehicle display page rendering module. Therefore, this method also involves the transmission strategy of the current actual width.

[0101] Step S140: transmitting the current actual width to the vehicle display page rendering module, so that the vehicle display page rendering module renders the text resource content to be displayed based on the current actual width.

[0102] In one embodiment, the current actual width is transmitted to the vehicle display page rendering module, including: transmitting the current actual width to the data context of the vehicle display page rendering module; obtaining the current actual width from the data context through a preset attribute in the human-computer interaction interface element, and the preset attribute is pre-bound to a preset main project variable in the data context; if the preset text variables in several target sub-projects in the vehicle display page rendering module are bound to the preset main project variable, when the preset main project variable obtains the current actual width, the preset text variable is automatically updated accordingly.

[0103] In one embodiment, after completing the rendering of the to-be-displayed text resource content and completing the rendering of the display content of the vehicle display page, the method further includes displaying the rendered vehicle display page.

[0104] In one embodiment, after determining the current actual width of the text resource content to be displayed based on the layout data to be displayed, the method further includes: storing the text resource content to be displayed in association with the current actual width for future query, and when the same text resource content to be displayed needs to be displayed again, directly obtaining the cached current actual width without recalculation.

[0105] As an example, taking the vehicle display page rendering module implemented by Kanzi as an example, the code implementation method of transmitting the current actual width to the vehicle display page rendering module is as follows:

[0106] After calculating the text width, pass it to Kanzi's DataContext through m_dataProxy for subsequent use in Kanzi:

[0107] m_dataProxy->setIntDataValue("ADAS.ActWidth", width, true);

[0108] m_dataProxy is a data proxy object. Its main responsibility is to synchronize data between the code and the Kanzi user interface (UI) through the data binding mechanism. In Kanzi, the data model (DataContext) is the bridge connecting the business logic and the UI, and m_dataProxy acts as an intermediary for data access and operation.

[0109] In Kanzi, DataContext refers to a context environment for storing and managing data, and ActWidth in the XML file mentioned below is a specific variable in the DataContext. It can be understood that DataContext is a container or scope, and ActWidth is a data item in this container.

[0110] This operation stores the width value width calculated by the code in the ADAS.ActWidth variable and synchronizes it to the data model of Kanzi, enabling the UI to obtain this width value (the current actual width) in real time.

[0111] Then, bind to the application width variable in the Kanzi project.

[0112] 1) Define the variable in the XML file

[0113] In the XML file of the Kanzi project, the ActWidth variable needs to be predefined to ensure that the variable can be correctly recognized and used and can interact with the UI through the data binding mechanism. The purpose of defining this variable is to provide an entry for storing and accessing the text width dynamically passed by the code later. The specific code added to the XML is as follows:

[0114] <ActWidth type="int">0 / / This XML code defines an integer variable named ActWidth (the preset main project variable) and initializes it to 0. This variable will be used to store the actual width value of the text (the current actual width). ActWidth is part of the data model (DataContext) of Kanzi. When the width value is updated, the bound elements in the UI can respond dynamically and adjust.

[0115] 2) Add the binding in the Release binding of Kanzi.

[0116] In the Release state of the Kanzi main project, a binding can be added. The property (preset property) of the binding is named ActWidth, and the binding is performed in the example manner as shown in Figure 3 shown, Figure 3 FIG. 4 is a schematic diagram of adding a binding in the Release binding of Kanzi provided by an embodiment of the present application. As shown in FIG. 3, {DataContext.ADAS.ActWidth} means extracting the ActWidth variable from the data context (DataContext) and binding its value to a certain property of the current UI element. Through this binding, the UI element can dynamically reference the value of ADAS.ActWidth.

[0117] The function of the binding is that once the ActWidth in the data model changes, the elements on the interface will be automatically updated. For example, when the actual width of the text is recalculated in the code and the value of ActWidth is updated through m_dataProxy, the interface will immediately adjust according to this new width value. This data binding ensures that the interface can reflect the actual width of the text in real time without manual refreshing or re-rendering.

[0118] Through the above binding, it can be ensured that the value of ActWidth can be dynamically referenced during interface rendering, and the actual width of the text content is reflected in real time.

[0119] At the specific place of use, the width value is directly referenced in the manner as shown in Figure 4 and Figure 5 shown to ensure that the text layout or other UI elements dependent on the width can be correctly displayed. Figure 4 FIG. 5 is a schematic diagram of an alias binding provided by an embodiment of the present application. As shown in Figure 4 shown, in the content variable where this variable is to be used currently, an alias binding is added to pass the value of ActWidth in the main project to the sub-project to be used currently. In this way, the Kanzi engine will use the actual width we passed to layout the UI elements, thus avoiding the inaccuracy problem that may be caused by the ActualWidth property.

[0120] The significance of the binding is that here, through the data binding mechanism, the previously calculated value of ActWidth (i.e., the actual width of the text) is passed to the current UI element (content variable, preset text variable) for application. #ADAS / ADASWarning.ActWidth means that the currently used project obtains the width value of ActWidth from the ADAS namespace.

[0121] The meaning of alias binding is that through this alias binding (#ADAS), the value of the ActWidth variable defined in the main project is passed to the current sub-project. This means that when the value of ActWidth in the main project changes (for example, the text width is recalculated in the code), the content variable in this sub-project will automatically update its width value.

[0122] Please refer to Figure 5 , Figure 5 which is a schematic diagram of the alias binding logic in Kanzi provided by an embodiment of this application. As Figure 5 shown, ADAS is shown on the left. This is an alias defined in the sub-project, which points to a certain data layer or variable in the main project. The right side, Prefabs / RootPage / RootPage / DataLayer / ADAS, is the specific path to be bound, which points to the ADAS namespace in the main project. ADAS is an alias defined in the sub-project. Through it, variables in the main project can be referenced without redefining the data source in the sub-project. In this way, when ActWidth in the main project changes, the content text variable in the sub-project will be automatically updated to ensure that the width adapts to the change.

[0123] Before rendering the display content of the vehicle display page, the text rendering method matches the to-be-displayed text resource content from a preset classical Chinese mapping table according to the to-be-displayed alarm identifier and the to-be-displayed alarm language, performs layout calculation on the to-be-displayed text resource content to obtain the to-be-displayed layout data of the to-be-displayed text resource content, determines the current actual width of the to-be-displayed text resource content based on the to-be-displayed layout data, and transmits the current actual width to the vehicle display page rendering module, so that the vehicle display page rendering module renders the to-be-displayed text resource content based on the current actual width. It no longer depends on the ActualWidth property in the Kanzi engine to calculate the current actual width of the to-be-displayed text resource content, avoiding the problem that the ActualWidth property is inaccurate in some complex scenarios. The actual width of the text node can be dynamically calculated in the code generated based on this method, and the calculation result is passed to the data context of the vehicle display page rendering module such as the Kanzi engine, improving the accuracy of the UI layout and the user's visual experience.

[0124] In addition, this method also improves the accuracy of UI layout. By dynamically calculating the actual width of text nodes (the current actual width) in the code and passing the calculation result to the data model (data context) of Kanzi, the problem of inaccurate calculation of the ActualWidth property in some complex scenarios is avoided. This method ensures that UI elements can be accurately laid out according to the actual text width, avoiding display errors such as text content overflow, overlap, or misalignment, thus significantly improving the accuracy of the interface layout and the visual experience.

[0125] This method also enhances the compatibility and stability of the system. Through the combination of a mapping table and a resource dictionary (a preset classical Chinese mapping table), it supports accurate width calculation and dynamic text display in a multilingual environment, with strong adaptability. Especially when dealing with multilingual and multi-style UI scenarios, the system can ensure the consistency of text widths in different languages (using the same calculation strategy for width calculation), avoiding layout problems caused by font and style differences, and improving the compatibility and stability of the system.

[0126] This method also improves real-time performance and the user experience. By calculating the text width in advance and caching it (determining the current actual width before rendering the display content of the vehicle display page), the overhead of the Kanzi engine repeatedly calculating the width during the rendering stage is avoided, thus accelerating the interface response speed. Users can obtain a smoother experience when operating and switching interfaces, reducing the phenomenon of interface lag or delay, and greatly improving the real-time performance of the user experience.

[0127] This method also simplifies the development process and reduces development costs. When implementing this method, a plugin can be used to automatically manage the association of alarm IDs, text resources, and icons, greatly simplifying the configuration work of developers. For those UI elements that do not require dynamic width calculation, the resources can be directly merged and displayed through the plugin, reducing the risk of manual configuration errors and the development complexity and labor costs.

[0128] This method also enhances the maintainability of the system. Since resources are managed through a mapping table (a preset classical Chinese mapping table) and a plugin, the extension and update of resources become simpler. When new languages or new warning messages need to be added, only the mapping table and the plugin expressions need to be updated, without having to rewrite complex code logic. This modular management method greatly improves the maintainability and scalability of the system.

[0129] This method also saves system resources and optimizes performance. By pre-calculating and caching the text width in the application, the calculation overhead of the Kanzi engine during runtime is reduced, saving system resources. At the same time, the unified management of resources using a plugin reduces the loading of redundant data, optimizing the overall performance of the system.

[0130] In summary, by introducing a method that combines code dynamic calculation with the Kanzi data model, not only the problem of inaccurate text width calculation in the related technology is solved, but also the accuracy, stability, and real-time performance of the system are significantly improved. Moreover, the development process is simplified, the development cost is reduced, and the maintainability and scalability of the system are enhanced.

[0131] The implementation of the above method can be understood as follows: 1. Dynamically calculate the text width; 2. Data transfer and binding. By accurately calculating the actual width of the text node through code, the limitation of the ActualWidth property in the Kanzi engine is avoided. The calculation result is transferred to the Kanzi data model and applied in real time in the UI to ensure the accuracy of the layout.

[0132] In addition, plugins can be developed specifically. Resources are managed through the plugins, and the plugins are used to automatically associate alarm IDs, text resources, and icons, simplifying the development process and supporting the automatic display of resources.

[0133] In one embodiment, a text rendering device is provided. The text rendering device is used to execute the steps in the text rendering method provided in any one of the above embodiments. Please refer to Figure 6 , Figure 6 which is a schematic structural diagram of the text rendering device provided in the embodiment of the present application. As Figure 6 shown, the text rendering device 600 includes a matching module 601, a layout calculation module 602, an actual width determination module 603, and a rendering module 604, where: The matching module 601 is configured to, before rendering the display content on the vehicle display page, match the to-be-displayed text resource content from a preset classical Chinese mapping table according to the to-be-displayed alarm identifier and the to-be-displayed alarm language; The layout calculation module 602 is configured to perform layout calculation on the to-be-displayed text resource content to obtain the to-be-displayed layout data of the to-be-displayed text resource content; The actual width determination module 603 is configured to determine the current actual width of the to-be-displayed text resource content based on the to-be-displayed layout data; The rendering module 604 is configured to transmit the current actual width to the vehicle display page rendering module, so that the vehicle display page rendering module renders the to-be-displayed text resource content based on the current actual width.

[0134] In one embodiment, the matching module is configured to: match the to-be-displayed alarm identifier with the preset alarm identifiers in the preset classical Chinese mapping table, and determine the successfully matched preset alarm identifier as the target alarm identifier. The preset classical Chinese mapping table includes multiple preset alarm identifiers and the classical Chinese of one or more languages corresponding to each preset alarm identifier; Determine the target classical Chinese from the classical Chinese of each language corresponding to the target alarm identifier according to the to-be-displayed alarm language, and use the target classical Chinese as the to-be-displayed text resource content.

[0135] In one embodiment, the device further includes a setting module, configured to preset text attributes including at least one of font, font size, line spacing, and vertical padding before performing layout calculation on the text resource content to be displayed to obtain the layout data to be displayed of the text resource content to be displayed.

[0136] In one embodiment, the layout calculation module is configured to: compare the text resource content to be displayed with the previous displayed text resource content; if the number of bytes of the text resource content to be displayed is the same as that of the previous displayed text resource content, and the text attributes and the alarm language to be displayed remain unchanged, use the historical layout data corresponding to the previous displayed text resource content as the layout data to be displayed.

[0137] In one embodiment, the layout calculation module is further configured to: if the number of bytes of the text resource content to be displayed is different from that of the previous displayed text resource content, or at least one of the text attributes and the alarm language to be displayed changes, perform layout calculation on the text resource content to be displayed to obtain the layout data to be displayed of the text resource content to be displayed.

[0138] In one embodiment, the rendering module is configured to: transmit the current actual width to the data context of the vehicle display page rendering module; obtain the current actual width from the data context through a preset attribute in the human-machine interaction interface element, and the preset attribute is bound to a preset main project variable in the data context in advance; if a preset text variable in a plurality of target sub-projects in the vehicle display page rendering module is bound to the preset main project variable, when the preset main project variable obtains the current actual width, the preset text variable is automatically updated accordingly (with the update of the current actual width).

[0139] In one embodiment, the device further includes a comparison module, configured to: before performing layout calculation on the text resource content to be displayed, compare the text resource content to be displayed with all the historical displayed text resource content that has been displayed; if there is a historical displayed text resource content that is the same as the text resource content to be displayed, use the historical actual width cached corresponding to the same historical displayed text resource content as the current actual width, and trigger the rendering module to execute the step of transmitting the current actual width to the vehicle display page rendering module; if all the historical displayed text resource content is different from the text resource content to be displayed, trigger the layout calculation module to execute the step of performing layout calculation on the text resource content to be displayed.

[0140] For the specific limitations of the text rendering device, reference may be made to the limitations on the text rendering method in the foregoing text, which will not be elaborated herein. Each module in the foregoing text rendering device may be implemented in whole or in part by software, hardware, or a combination thereof. The foregoing modules may be embedded in the processor in the electronic device in hardware form or independent thereof, or stored in the memory in the electronic device in software form, so as to facilitate the processor to call and execute the operations corresponding to the foregoing modules.

[0141] In this embodiment, the text rendering device essentially sets multiple modules to execute the steps in the text rendering method in any of the foregoing embodiments. For the specific functions and technical effects, reference may be made to the foregoing embodiments, which will not be elaborated herein.

[0142] In one embodiment, a vehicle is provided, which includes the text rendering device provided in any of the foregoing embodiments and a display device. The display device is used to display the vehicle display page rendered by the text rendering device. The number of display devices is not limited. For the specific functions and technical effects of the vehicle, reference may be made to the foregoing embodiments, which will not be elaborated herein.

[0143] See Figure 7 , an embodiment of the present invention further provides an electronic device 800, including a processor 801, a memory 802, and a communication bus 803; the communication bus 803 is used to connect the processor 801 and the memory 802; the processor 801 is used to execute the computer program stored in the memory 802 to implement the method provided in any of the foregoing embodiments.

[0144] As an example, the electronic device may be a device such as a vehicle or a car computer.

[0145] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and the computer program is used to cause a computer to execute the method provided in any of the foregoing embodiments.

[0146] An embodiment of the present application further provides a non-volatile readable storage medium, in which one or more modules (programs) are stored. When the one or more modules are applied to a device, the device can be caused to execute the instructions (instructions) included in the first embodiment of the embodiments of the present application.

[0147] An embodiment of the present application further provides a computer program product, including a computer program, and when the computer program is executed by a processor, the steps and corresponding contents of the foregoing method embodiments can be implemented.

[0148] It should be noted that the computer-readable medium described above can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of a computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium can be any tangible medium that contains or stores a program, which can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present disclosure, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on a computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0149] The above computer-readable medium can be included in the above electronic device; or it can exist separately without being assembled into the electronic device.

[0150] Computer program code for performing the operations of the present disclosure can be written in one or more programming languages or combinations thereof. The above programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, executed as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (for example, by using an Internet service provider to connect through the Internet).

[0151] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a part of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, as well as combinations of blocks in the block diagram and / or flowchart, may be implemented by a dedicated hardware-based system that performs the specified functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.

[0152] It should be understood that if the present application mentions terms such as "first" and "second", they are used to distinguish similar objects and do not necessarily represent a specific order or sequence. The technical features where these terms are located can be interchanged under appropriate circumstances so that the embodiments of the present application described herein can be implemented in an order other than the illustrated or textually described order.

[0153] It should be understood that although the flowcharts provided in the embodiments of the present application indicate the various steps by arrows, the order indicated by the arrows does not necessarily limit the order of implementation of these steps. Those skilled in the art can execute these steps in other orders according to the requirements for different implementation scenarios.

[0154] The above embodiments are only illustrative of the principles and effects of the present invention and are not intended to limit the present invention. Any person familiar with this technology can modify or change the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or changes made by those of ordinary skill in the art in the technical field without departing from the spirit and technical ideas disclosed by the present invention should still be covered by the claims of the present invention.< / textresource> < / resourcedictionary> < / textresource> < / resourcedictionary>

Claims

1. A text rendering method based on Kanzi, characterized in that, The described text rendering method includes: Before rendering the display content of the vehicle display page, match the text resource content to be displayed from a preset classical Chinese mapping table according to the alarm identifier to be displayed and the alarm language to be displayed; Perform layout calculation on the text resource content to be displayed to obtain the layout data to be displayed for the text resource content to be displayed; Determine the current actual width of the text resource content to be displayed based on the layout data to be displayed; Transmit the current actual width to the data context of Kanzi, and bind it to a preset main engineering variable in the data context through a preset attribute in the human-machine interaction interface element, and obtain the current actual width from the data context; and, add an alias binding in the context data, and transfer the preset main engineering variable to the sub-project according to the alias binding result, so that Kanzi renders the text resource content to be displayed based on the current actual width; wherein, the data context is used to store and manage the context environment of data.

2. The Kanzi-based text rendering method according to claim 1, wherein Matching the text resource content to be displayed from a preset classical Chinese mapping table according to the alarm identifier to be displayed and the alarm language to be displayed includes: Match the alarm identifier to be displayed with the preset alarm identifiers in the preset classical Chinese mapping table, and determine the successfully matched preset alarm identifier as the target alarm identifier. The preset classical Chinese mapping table includes multiple preset alarm identifiers and the classical Chinese of one or more languages corresponding to each preset alarm identifier; Determine the target classical Chinese from the classical Chinese of each language corresponding to the target alarm identifier according to the alarm language to be displayed, and use the target classical Chinese as the text resource content to be displayed.

3. The Kanzi-based text rendering method according to claim 1, wherein Before performing layout calculation on the text resource content to be displayed to obtain the layout data to be displayed for the text resource content to be displayed, the method further includes: Preset text attributes, where the text attributes include at least one of font, font size, line spacing, and vertical padding.

4. The Kanzi-based text rendering method according to claim 3, wherein Performing layout calculation on the text resource content to be displayed to obtain the layout data to be displayed for the text resource content to be displayed includes: Compare the text resource content to be displayed with the previous display text resource content that has been previously displayed; If the number of bytes of the text resource content to be displayed is the same as that of the previous display text resource content, and the text attributes and the alarm language to be displayed have not changed, use the historical layout data corresponding to the previous display text resource content as the layout data to be displayed.

5. The Kanzi-based text rendering method according to claim 4, wherein The method further includes: If the number of bytes of the text resource content to be displayed is different from that of the previous display text resource content, or at least one of the text attributes and the alarm language to be displayed changes, perform layout calculation on the text resource content to be displayed to obtain the layout data to be displayed for the text resource content to be displayed.

6. The Kanzi-based text rendering method according to any one of claims 1-5, characterized in that, Before performing layout calculation on the text resource content to be displayed, the method further includes: Compare the text resource content to be displayed with all the historical display text resource content that has been historically displayed; If there exists a historical display text resource content that is the same as the content of the to-be-displayed text resource, use the historical actual width cached corresponding to the same historical display text resource content as the current actual width, and trigger the step of transmitting the current actual width to Kanzi; If all historical display text resource contents are different from the content of the to-be-displayed text resource, trigger the step of performing layout calculation on the content of the to-be-displayed text resource.

7. A text rendering device based on Kanzi, characterized in that, The text rendering device includes: A matching module, configured to, before rendering the display content of the vehicle display page, obtain the content of the to-be-displayed text resource by matching from a preset classical Chinese mapping table according to the to-be-displayed alarm identifier and the to-be-displayed alarm language; A layout calculation module, configured to perform layout calculation on the content of the to-be-displayed text resource to obtain the to-be-displayed layout data of the content of the to-be-displayed text resource; An actual width determination module, configured to determine the current actual width of the content of the to-be-displayed text resource based on the to-be-displayed layout data; A rendering module, configured to transmit the current actual width to the data context of Kanzi, bind through a preset attribute in the human-computer interaction interface element to a preset main project variable in the data context, and obtain the current actual width from the data context; and add an alias binding in the context data, and transfer the preset main project variable to a sub-project according to the alias binding result, so that Kanzi renders the content of the to-be-displayed text resource based on the current actual width; wherein, the data context is a context environment for storing and managing data.

8. A vehicle, characterized in that, The vehicle includes a display device and the Kanzi-based text rendering device according to claim 7, and the display device is configured to display the vehicle display page rendered by the text rendering device.

9. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Page display method and device, electronic equipment and storage medium

    CN114579230A

  • Page text pop-up box processing method and device, electric vehicle and storage medium

    CN118708177A