Text rendering method and device, vehicle and electronic equipment

By dynamically calculating the actual width of the text node in the KANZI engine and passed it to the rendering module, the ActualWidth attribute calculated inaccurate in complex scenes, and improved the accuracy and user experience of the UI layout.

CN119336435AActive Publication Date: 2025-01-21CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411461167.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-18
Publication Date
2025-01-21
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, and inaccurate control of UI elements and UI performance, which affects the user's visual experience.

Method used

By rendering the vehicle display page, the content of the text resource to be displayed is obtained according to the preset classical mapping table according to the presence of the alarm logo and the language. Rendering.

Benefits of technology

It avoids the problem of inaccurate calculation of the ActualWidth property in complex scenarios, improves the accuracy of UI layout and user visual experience, simplifies the development process and reduces development costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119336435A_ABST
    Figure CN119336435A_ABST
Patent Text Reader

Abstract

The embodiment of the invention relates to the technical field of vehicles, and provides a text rendering method and device, a vehicle and electronic device.According to the method, before display content rendering is conducted on a vehicle display page, according to a to-be-displayed alarm identifier and a to-be-displayed alarm language, a to-be-displayed text resource content is obtained through matching from a preset literal mapping table; the layout calculation module is used for carrying out layout calculation on the to-be-displayed text resource content to obtain to-be-displayed layout data of the to-be-displayed text resource content, determining the current actual width of the to-be-displayed text resource content based on the to-be-displayed layout data, and transmitting the current actual width to the vehicle display page rendering module; the actual width of a text node is dynamically calculated in a code generated based on the method, and a calculation result is transmitted to a data context of the vehicle display page rendering module, such as a Kanzi engine, so that the vehicle display page rendering module renders the to-be-displayed text resource content on the basis of the current actual width. And the UI layout accuracy and the user visual experience are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of vehicle technology, and in particular to a text rendering method, device, vehicle and electronic device. Background Art

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

[0003] In the Kanzi development process, the layout and rendering of text nodes is an important part. The Kanzi engine provides a variety of layout methods and properties to control the display of text, such as the ActualWidth property, which is used to dynamically obtain the actual width of the text node. This property 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 property can theoretically return the actual width value of the 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 property in the Kanzi engine often cannot accurately reflect the actual width of the text. This inaccuracy can lead to problems such as layout failure, slow dynamic response, inability to accurately control UI elements, and inconsistent UI performance, affecting the user's visual experience. Summary of the invention

[0005] The embodiments of the present application provide a text rendering method, device, vehicle and electronic device to solve the technical problem that the ActualWidth attribute in the Kanzi engine in the related art often fails to accurately reflect the actual width of the text, resulting in layout failure, slow dynamic response, inability to accurately control UI elements, inconsistent UI performance and other problems, affecting the user's visual experience.

[0006] An embodiment of the present application provides a text rendering method, which includes: before rendering display content on a vehicle display page, matching the text resource content to be displayed from a preset classical Chinese mapping table according to the alarm identification to be displayed and the alarm language to be displayed; performing layout calculation on the text resource content to be displayed to obtain 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 a 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 one embodiment of the present application, the text resource content to be displayed is obtained by matching from a preset classical Chinese mapping table according to the alarm identifier to be displayed and the alarm language to be displayed, including: matching the alarm identifier to be displayed with a preset alarm identifier 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 including multiple preset alarm identifiers and 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 one embodiment of the present application, before performing layout calculation on the text resource content to be displayed and obtaining the layout data to be displayed of the text resource content to be displayed, the method also includes: presetting text attributes, and the text attributes include at least one of font, font size, line spacing, and vertical padding.

[0009] In one embodiment of the present application, a layout calculation is performed on the text resource content to be displayed to obtain the layout data to be displayed of the text resource content to be displayed, including: comparing the text resource content to be displayed with the previous displayed text resource content that was displayed last time; if the number of bytes of the text resource content to be displayed and the previous displayed text resource content are the same, and the text attributes and the language of the alarm to be displayed have not changed, the historical layout data corresponding to the previous displayed text resource content is used as the layout data to be displayed.

[0010] In one embodiment of the present application, the method also includes: if the number of bytes of the text resource content to be displayed is different from that of the previously displayed text resource content, or at least one of the text attributes and the language of the alarm 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 one embodiment of the present application, 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 a 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.

[0012] In one embodiment of the present application, before performing layout calculation on the text resource content to be displayed, the method also includes: comparing the text resource content to be displayed with all historical display text resource contents that have been displayed in history; if there is a historical display text resource content that is identical to the text resource content to be displayed, using the historical actual width of the cache corresponding to the same historical display 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 historical display 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 also provides a text rendering device, which includes a matching module, which is used to match the text resource content to be displayed from a preset classical Chinese mapping table according to the alarm identification to be displayed and the alarm language to be displayed before rendering the display content on the vehicle display page; a layout calculation module, which is used to 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; an actual width determination module, which is used to determine the current actual width of the text resource content to be displayed based on the layout data to be displayed; and a rendering module, which is used 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 also provides a vehicle, comprising the text rendering device and the display device described in any one of the above embodiments, wherein the display device is used to display a 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, wherein the processor implements the method described in any one of the above embodiments when executing the computer program.

[0016] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the method described in any one of the above embodiments is implemented.

[0017] In the scheme implemented by the text rendering method, device, vehicle and electronic device provided above, the text rendering method obtains the text resource content to be displayed from the preset classical Chinese mapping table according to the alarm mark to be displayed and the alarm language to be displayed before rendering the display content on the vehicle display page, performs layout calculation on the text resource content to be displayed, obtains the layout data to be displayed of 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, and no longer relies on the ActualWidth attribute in the Kanzi engine to calculate the current actual width of the text resource content to be displayed, thereby 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 the method, and the calculation result can be passed to the data context of the vehicle display page rendering module such as the Kanzi engine, thereby improving the accuracy of the UI layout and the user's visual experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0019] Figure 1 A flowchart of a text rendering method provided in an embodiment of the present application;

[0020] Figure 2 A schematic diagram of a preset classical Chinese mapping table provided in an embodiment of the present application;

[0021] Figure 3 A schematic diagram of adding a binding to a Release binding of Kanzi provided in an embodiment of the present application;

[0022] Figure 4 A schematic diagram of an alias binding provided in an embodiment of the present application;

[0023] Figure 5 A schematic diagram of alias binding logic in Kanzi provided in an embodiment of the present application;

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

[0025] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0027] There are one or more display screens in the vehicle, and at least some of the display screens will display vehicle warning text prompts, such as "Assisted driving, full-screen map cannot be switched" and "Please take over". These vehicle warning text prompts can change with the changes in the vehicle's driving status and working status. When changes occur, the display content of the vehicle display page on the display screen needs to be re-rendered. In related technologies, the ActualWidth attribute in a preset rendering engine such as the Kanzi engine is often used to calculate the text node width and then render the text. However, due to factors such as dynamic changes in text content or complex styles of text nodes, the ActualWidth attribute cannot obtain the actual text node width, which leads to problems including but not limited to the following:

[0028] Layout failure: When the length of the text content exceeds expectations and the ActualWidth property cannot be correctly reflected, the UI layout may flicker, overflow, overlap or other display errors, seriously affecting the user's visual experience.

[0029] Slow dynamic response: Since the ActualWidth property needs to be determined during the rendering phase in some cases, the interface response speed is slowed down in complex scenarios, increasing the delay of user interaction.

[0030] Unable to precisely control UI elements: When developers are dealing with some scenarios that require precise control of text width, they cannot rely solely on the ActualWidth property to achieve this. This means that when adjusting text width in layout or animation, developers must write additional code for manual calculations, which increases the difficulty of development.

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

[0032] Therefore, in order to solve the problem that the ActualWidth attribute in the related technology has great limitations and instability in some key application scenarios, it is difficult to meet the needs of high-precision and high-real-time text width calculation. Therefore, it is urgent to develop a method that can accurately calculate and transmit the actual width of text nodes in vehicle display page rendering modules such as Kanzi engine. To solve the above problems, an embodiment of the present application provides a text rendering method. Before rendering the display content on the vehicle display page, the text resource content to be displayed is matched from a preset classical Chinese mapping table according to the alarm identification to be displayed and the alarm language to be displayed, and the layout calculation is performed on the text resource content to be displayed to obtain the layout data to be displayed of the text resource content to be displayed, and the current actual width of the text resource content to be displayed is determined based on the layout data to be displayed, and the current actual width is transmitted 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, and no longer relies on the ActualWidth attribute in the Kanzi engine to calculate the current actual width of the text resource content to be displayed, thereby 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 the method, and the calculation result can be passed to the data context of the vehicle display page rendering module such as the Kanzi engine, thereby improving the accuracy of the UI layout and the user's visual experience.

[0033] See also Figure 1 As shown, Figure 1 A flowchart of a text rendering method provided in an embodiment of the present application, the method comprises the following steps:

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

[0035] The vehicle display page may be a display page on a display screen of the vehicle. Before rendering and updating the page, the width of the text node needs to be accurately calculated for accurate rendering.

[0036] The warning mark to be displayed can be a warning mark that needs to be displayed according to the current state of the vehicle. The specific generation method can be implemented by referring to the existing technology and is not limited here. The warning mark to be displayed can be pre-configured by those skilled in the art.

[0037] The preset classical Chinese mapping table is pre-set by a person skilled in the art, and includes a plurality of preset alarm identifiers and classical Chinese of one or more languages ​​corresponding to each preset alarm identifier. Figure 2 , Figure 2 A schematic diagram of a preset classical Chinese mapping table provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, part of the preset classical Chinese mapping table is shown. In order to adapt to the multi-language environment, multiple mapping tables are defined to manage text resources corresponding to different languages ​​and alarm IDs. First, the LOCALURL variable is defined to point to the basic path of text resources in Kanzi: const std::string LOCALURL = "kzb: / / warningmsg / Locales / "; path names starting with kzb directly correspond to certain resources in Kanzi, in this example, they correspond to the classical Chinese table resources in Kanzi.

[0038] Then, use the mMapLanguage map variable 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 (languages) with their corresponding string values, which are used to construct resource paths to load text resources in the corresponding languages.

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

[0052] mMapIdContent[1] = "001"; / / 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 to come...

[0064] The en, ru, de, etc. in the first row are the values ​​stored in mMapLanguage. The resourceID (preset alarm identifier, also known as alarm ID) in the first column corresponds to ADAS_TEXT_001, and the following three digits also correspond to the value stored in mMapIdContent.

[0065] In one embodiment, the text resource content to be displayed is obtained by matching from a preset classical Chinese mapping table according to the alarm identifier to be displayed and the alarm language to be displayed, including: matching the alarm identifier to be displayed with a preset alarm identifier in the preset classical Chinese mapping table, determining the successfully matched preset alarm identifier as the target alarm identifier, the preset classical Chinese mapping table including multiple preset alarm identifiers and 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.

[0066] Continue to see Figure 2 Taking the alarm ID to be displayed as ADAS_TEXT_001 as an example, the classical Chinese of multiple languages ​​in the first row can be matched in the preset classical Chinese mapping table, and then a classical Chinese is selected from them as the target classical Chinese according to the language of the alarm to be displayed, that is, the text resource content to be displayed.

[0067] As an example implementation, mMapIdContent stores the three digits following ADAS_TEXT_001. To obtain the specific text, you need to concatenate the strings first to obtain the correct Resource ID name of the specific resource. The specific code of an example is as follows:

[0068] const std::string LOCALURL = "kzb: / / warningmsg / Locales / "; / / Get the kzb address of the Kanzi Chinese language table:

[0069] string localeUrl = LOCALURL + it->second; / / Get the classical Chinese table of each language. For example, the English classical Chinese table has a complete address of 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 resource;

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

[0073] TextResourceSharedPtrtextRes=resDic->acquire <textresource>(ResourceID(con)); Get a specific one of the texts;

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

[0075] The specific text content that needs to be displayed currently can be determined in the above manner.

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

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

[0078] As an example, the text attribute can be set by the following code, in which a TextBlock2D object is defined to calculate the width of the text content. TextBlock2D is a UI element in the Kanzi engine that is used to display text and supports multiple 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, the text attribute values ​​are set first, just like in Kanzi. A TextBlock2D object is created, and the font size, line spacing, vertical padding and other attributes are set. Through the above code, some font size, line spacing and other attributes of the text whose width you want to calculate are set.

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

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

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

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

[0090] It is understandable that if only the displayed text itself is replaced, and the language, text attributes, and number of characters remain unchanged, such as replacing "Please note" with "Please wait" and 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 that needs to be refreshed, regardless of whether it is the above situation that requires re-calculation of layout, the layout calculation is re-calculated.

[0091] As an example, the code implementation of the layout calculation is as follows: mCalcuWidth->setText(textRes->getText()); / / Set the obtained text resource content (obtained through textRes->getText()) to the mCalcuWidth object, preparing 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 text width and height.

[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 historical display text resource contents that have been displayed in history; if there is a historical display text resource content that is identical to the text resource content to be displayed, using the cached historical actual width corresponding to the identical historical display 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 historical display 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 is understandable that since the alarm content of the vehicle is actually limited, it is possible that the content has been displayed before. If it is recalculated every time, it will lead to a waste of computing power. Therefore, the actual width can be cached every time new content is calculated, 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(); / / Get the actual width of the text.

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

[0099] Through 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 interface (UI) through the data binding mechanism. In Kanzi, the data model (DataContext) is the bridge between business logic and UI, and m_dataProxy plays the role of an intermediary for data access and operation.

[0109] In Kanzi, DataContext refers to a context for storing and managing data, and ActWidth in the XML file mentioned below is a specific variable in 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 Kanzi's data model, so that the UI interface can obtain the width value (current actual width) in real time.

[0111] Then, bind and apply the width variable in the Kanzi project.

[0112] 1) Define variables in XML files

[0113] In the XML file of the Kanzi project, the ActWidth variable needs to be defined in advance to ensure that the variable can be correctly identified and used, and can interact with the UI through the data binding mechanism. The purpose of defining this variable is to provide a storage and access entry for the subsequent dynamic transmission of text width through code. The specific code added in XML is as follows:

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

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

[0116] In the Release state of the Kanzi main project, you can add a binding, name the bound property ActWidth, and use it as follows Figure 3 Bind as shown in the example. Figure 3 A schematic diagram of adding binding in Kanzi's Release binding is provided for an embodiment of the present application, as shown in 3, {DataContext.ADAS.ActWidth} means extracting the ActWidth variable from the data context (DataContext) and binding its value to a certain attribute of the current UI element. Through this binding, the UI element can dynamically reference the value of ADAS.ActWidth.

[0117] The role of 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 refresh or re-rendering.

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

[0119] In specific places of use, Figure 4 and Figure 5 Refer to the width value directly as shown to ensure that text layout or other UI elements that rely on width are displayed correctly. Figure 4 A schematic diagram of an alias binding provided in an embodiment of the present application, such as Figure 4 As shown, add an alias binding to the content variable that is currently using this variable, and pass the ActWidth value in the main project to the sub-project that is currently being used. In this way, the Kanzi engine will use the actual width we pass to layout UI elements, thus avoiding the inaccuracy that may be caused by the ActualWidth property.

[0120] The meaning of binding is that here, through the data binding mechanism, the previously calculated ActWidth value (that is, 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 current project obtains the width value of ActWidth from the ADAS namespace.

[0121] The meaning of alias binding is that the value of the ActWidth variable defined in the main project is passed to the current sub-project through this alias binding (#ADAS). This means that when the ActWidth value 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] See also Figure 5 , Figure 5 A schematic diagram of an alias binding logic in Kanzi provided in an embodiment of the present application, such as Figure 5 As shown, ADAS is shown on the left, which is an alias defined in the sub-project, and it points to a data layer or variable in the main project. Prefabs / RootPage / RootPage / DataLayer / ADAS on the right is the specific path to be bound, pointing to the ADAS namespace in the main project. ADAS is an alias defined in the sub-project, through which variables in the main project can be referenced without redefining the data source in the sub-project. In this way, when the ActWidth in the main project changes, the content text variable in the sub-project will be automatically updated to ensure that the width changes adaptively.

[0123] The text rendering method obtains the text resource content to be displayed from a preset classical Chinese mapping table according to the alarm identification to be displayed and the alarm language to be displayed before rendering the display content on the vehicle display page, performs layout calculation on the text resource content to be displayed, obtains the layout data to be displayed of 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, and no longer relies on the ActualWidth attribute in the Kanzi engine to calculate the current actual width of the text resource content to be displayed, thereby avoiding the problem of inaccurate calculation of the ActualWidth attribute in some complex scenarios, and can improve the accuracy of UI layout and the user's visual experience by dynamically calculating the actual width of the text node in the code generated based on the method and passing the calculation result to the data context of the vehicle display page rendering module such as the Kanzi engine.

[0124] In addition, this method also improves the accuracy of UI layout. By dynamically calculating the actual width of the text node (the current actual width) in the code and passing the calculation result to Kanzi's data model (data context), 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, thereby significantly improving the accuracy of interface layout and visual experience.

[0125] This method also enhances the compatibility and stability of the system. Through the combination of mapping tables and resource dictionaries (preset classical Chinese mapping tables), it supports accurate width calculation and dynamic text display in multi-language environments, and has strong adaptability. Especially when dealing with multi-language and multi-style UI scenarios, the system can ensure the consistency of text width 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 user experience. By calculating the text width in advance and caching it (determining the current actual width before rendering the display content on the vehicle display page), the Kanzi engine avoids the overhead of repeatedly calculating the width during the rendering phase, thereby speeding up the interface response speed. Users can get a smoother experience when operating and switching interfaces, reducing interface freezes or delays, 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, the plug-in can be used to automatically manage the association between 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 plug-in can directly complete the merging and display of resources, reducing the risk of manual configuration errors, reducing development complexity and labor costs.

[0128] This method also enhances the maintainability of the system. Since resources are managed through mapping tables (preset classical Chinese mapping tables) and plug-ins, resource expansion and updating become simpler. When a new language or new warning information needs to be added, only the mapping table and plug-in expression need to be updated without rewriting 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 text widths in the application, the Kanzi engine's computational overhead at runtime is reduced, saving system resources. At the same time, the unified management of resources using plug-ins reduces the loading of redundant data and optimizes the overall performance of the system.

[0130] In summary, by introducing a method based on code dynamic calculation combined with Kanzi data model, not only the problem of inaccurate text width calculation existing in related technologies is solved, but also the accuracy, stability and real-time performance of the system are significantly improved, 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: 1. Dynamically calculate the text width; 2. Data transfer and binding. The actual width of the text node is accurately calculated through code, avoiding the limitations of the ActualWidth property in the Kanzi engine. The calculation results are passed to Kanzi's data model and applied in real time in the UI to ensure the accuracy of the layout.

[0132] In addition, you can also develop plug-ins specifically, manage resources through plug-ins, use plug-ins to automatically associate alarm IDs, text resources and icons, simplify the development process, and support automatic display of resources.

[0133] In one embodiment, a text rendering device is provided, and the text rendering device is used to perform the steps in the text rendering method provided in any of the above embodiments. Figure 6 , Figure 6 A structural diagram of a text rendering device provided in an embodiment of the present application, such as Figure 6 As 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, wherein: the matching module 601 is used to match the text resource content to be displayed from the preset classical Chinese mapping table according to the alarm mark to be displayed and the alarm language to be displayed before rendering the display content on the vehicle display page; the layout calculation module 602 is used to 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; the actual width determination module 603 is used to determine the current actual width of the text resource content to be displayed based on the layout data to be displayed; the rendering module 604 is used 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.

[0134] In one embodiment, the matching module is configured to: match the alarm identifier to be displayed with the preset alarm identifier in the preset classical Chinese mapping table, determine the successfully matched preset alarm identifier as the target alarm identifier, the preset classical Chinese mapping table includes multiple preset alarm identifiers and 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 language of the alarm to be displayed, and use the target classical Chinese as the text resource content to be displayed.

[0135] In one embodiment, the device also includes a setting module for performing layout calculations on the text resource content to be displayed, and presetting text attributes before obtaining the layout data to be displayed of the text resource content to be displayed. The text attributes include at least one of font, font size, line spacing, and vertical padding.

[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 that was displayed last time; if the number of bytes of the text resource content to be displayed and the previous displayed text resource content are the same, and the text attributes and the language of the alarm to be displayed have not changed, the historical layout data corresponding to the previous displayed text resource content will be used as the layout data to be displayed.

[0137] In one embodiment, the layout calculation module is also configured to: if the number of bytes of the text resource content to be displayed is different from that of the previously displayed text resource content, or at least one of the text attributes and the language of the alarm 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 the preset attributes in the human-computer interaction interface element, and the preset attributes are pre-bound to the preset main project variables 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 variables, when the preset main project variable obtains the current actual width, the preset text variable is automatically updated accordingly (update of the current actual width).

[0139] In one embodiment, the device also includes a comparison module, which is configured to: before performing layout calculation on the text resource content to be displayed, compare the text resource content to be displayed with all historical display text resource contents that have been displayed in the past; if there is a historical display text resource content that is identical to the text resource content to be displayed, use the cached historical actual width corresponding to the same historical display 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 historical display text resource contents are 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 definition of the text rendering device, please refer to the definition of the text rendering method above, which will not be repeated here. The various modules in the above-mentioned text rendering device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the electronic device in the form of hardware, or can be stored in the memory of the electronic device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0141] In this embodiment, the text rendering device is substantially provided with multiple modules for executing the steps in the text rendering method in any of the above embodiments. The specific functions and technical effects can be referred to the above embodiments and will not be described in detail here.

[0142] In one embodiment, a vehicle is provided, the vehicle comprising a text rendering device and a display device provided in any of the above embodiments, the display device being used to display a vehicle display page rendered by the text rendering device. The number of display devices is not limited. The specific functions and technical effects of the vehicle can refer to the above embodiments, and will not be repeated here.

[0143] See also 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 any method provided in the above embodiments.

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

[0145] An embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. The computer program is used to enable a computer to execute a method provided in any one of the above embodiments.

[0146] The embodiment of the present application also provides a non-volatile readable storage medium, which stores one or more modules (programs). When the one or more modules are applied to a device, the device can execute instructions (instructions) of the steps included in the embodiment 1 of the embodiment of the present application.

[0147] The embodiment of the present application also provides a computer program product, including a computer program, which can implement the steps and corresponding contents of the aforementioned method embodiment when executed by a processor.

[0148] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may 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 may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may 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 the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0149] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0150] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may 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 may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0151] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of the code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0152] It should be understood that if the application mentions the terms "first", "second", etc., they are used to distinguish similar objects, and do not necessarily represent that they refer to a specific order or sequence. The technical features in which these terms are located can be interchangeable under appropriate circumstances, so that the embodiments of the application described here can be implemented in an order other than the illustrated or written description.

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

[0154] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.< / textresource> < / resourcedictionary> < / textresource> < / resourcedictionary>

Claims

1. A text rendering method, characterized in that: The text rendering method comprises: Before rendering the display content on the vehicle display page, the text resource content to be displayed is matched from the preset classical Chinese mapping table according to the alarm identification to be displayed and the alarm language to be displayed; Performing layout calculation on the text resource content to be displayed to obtain 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; The current actual width is transmitted to a 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.

2. The text rendering method according to claim 1, characterized in that: The text resource content to be displayed is obtained by matching the alarm identifier to be displayed and the alarm language to be displayed from the preset classical Chinese mapping table, including: Matching the alarm identifier to be displayed with the preset alarm identifier in the preset classical Chinese mapping table, and determining the preset alarm identifier that successfully matches as the target alarm identifier, wherein the preset classical Chinese mapping table includes multiple preset alarm identifiers and classical Chinese of one or more languages ​​corresponding to each preset alarm identifier; According to the alarm language to be displayed, a target classical Chinese is determined from the classical Chinese of each language corresponding to the target alarm identifier, and the target classical Chinese is used as the text resource content to be displayed.

3. The text rendering method according to claim 1, characterized in that: Before performing layout calculation on the text resource content to be displayed to obtain layout data to be displayed of the text resource content to be displayed, the method further includes: The text attributes are preset, wherein the text attributes include at least one of font, font size, line spacing, and vertical padding.

4. The text rendering method according to claim 3, characterized in that: Performing layout calculation on the text resource content to be displayed to obtain layout data to be displayed of the text resource content to be displayed, including: Compare the text resource content to be displayed with the previous displayed text resource content that has been displayed last time; If the number of bytes of the text resource content to be displayed is the same as that of the text resource content to be displayed previously, and the text attributes and the language of the alarm to be displayed have not changed, the historical layout data corresponding to the text resource content to be displayed previously is used as the layout data to be displayed.

5. The text rendering method according to claim 4, characterized in that: The method further comprises: If the number of bytes of the text resource content to be displayed is different from that of the previously displayed text resource content, or at least one of the text attribute and the language of the alarm to be displayed changes, the layout calculation is performed on the text resource content to be displayed to obtain the layout data to be displayed of the text resource content to be displayed.

6. The text rendering method according to any one of claims 1 to 5, characterized in that: Transmitting the current actual width to a vehicle display page rendering module includes: Transmitting the current actual width to the data context of the vehicle display page rendering module; Acquire the current actual width from the data context through a preset attribute in a human-computer interaction interface element, wherein the preset attribute is pre-bound to a preset main engineering 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.

7. The text rendering method according to any one of claims 1 to 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 historically displayed text resource content; If there is a historical display text resource content that is identical to the text resource content to be displayed, taking the historical actual width corresponding to the cache of the same historical display 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 historically displayed text resource contents are different from the text resource contents to be displayed, a step of performing layout calculation on the text resource contents to be displayed is triggered.

8. A text rendering device, characterized in that: The text rendering device comprises: A matching module, used for matching the text resource content to be displayed from a preset classical Chinese mapping table according to the alarm identification to be displayed and the alarm language to be displayed before rendering the display content on the vehicle display page; A layout calculation module, used for performing layout calculation on the text resource content to be displayed to obtain layout data to be displayed of the text resource content to be displayed; An actual width determination module, used to determine the current actual width of the to-be-displayed text resource content based on the to-be-displayed layout data; A rendering module is used to transmit the current actual width to a 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.

9. A vehicle, characterized in that: The vehicle comprises a display device and the text rendering device as claimed in claim 8, wherein the display device is used to display a vehicle display page rendered by the text rendering device.

10. 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 7 is implemented.

Citation Information

Patent Citations

  • Automobile information management device and automobile information display method thereof

    CN103863213A

  • HMI system and HMI assembly thereof, HMI assembly development method and vehicle-mounted display equipment

    CN111722843A

  • Simulator based on KANZI engine

    CN114091229A

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

    CN114579230A

  • Alarm display method and device, TCMS and storage medium

    CN116110182A