A method for fast text rendering in an embedded system
By generating vector bitmaps and updating texture caches in embedded systems, the problem of low text rendering efficiency in embedded systems is solved, and the effect of rapid rendering and resource saving is achieved.
Patent Information
- Application Number
- CN202111648874.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-29
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2041-12-29
AI Technical Summary
In embedded systems, due to limited computing power and storage space, the prior art has low text rendering efficiency in display interfaces, which cannot meet the real-time requirements and the needs of large-scale text data drawing.
Generate vector bitmaps by initializing the text in the font library file and establishing an initial texture cache, updating the texture cache according to the display interface needs, reducing the rereading and rendering process, and improving rendering efficiency.
It realizes fast text rendering, saves operation and storage space, and ensures the safe and reliable operation of the embedded system.
Smart Images

Figure CN114445536B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of embedded system application software, relates to the field of image processing technology, and specifically provides a method for rapid text rendering in an embedded system. Background Art
[0002] Embedded systems, such as electronic devices like computers, mobile phones, and tablets, are becoming increasingly widely used, and the requirements for text display and rendering efficiency on the display interfaces of embedded systems are also constantly increasing. Currently, when there are high requirements for real-time performance or when a large amount of text data needs to be drawn, due to the limitations of the system's processing performance and storage space, the text display and rendering efficiency on the display interface is not high. Moreover, during text rendering, since there is no update process for texture caching in the system, when text needs to be re-rendered on the display interface, or when new text is displayed and rendered, all the text on the display interface needs to be re-rendered, resulting in low text rendering efficiency and slow rendering speed on the display interface, and it cannot meet the operation efficiency requirements of the system. Summary of the Invention
[0003] The purpose of the present invention is to solve the problem that under the limited computing power and storage space of an embedded system, a method for rapid text rendering in an embedded system is provided. The designed method for rapid text rendering in the present invention can rapidly render and display the text on the display interface, and can greatly improve the operation efficiency of the system.
[0004] The technical solution for achieving the invention purpose is as follows: A method for rapid text rendering in an embedded system, comprising the following steps:
[0005] S1. Initialize each character in the font library file, generate a vector bitmap corresponding to each character based on the character information of the character, and load it into the memory of the target machine;
[0006] S2. Select the text to be rendered according to the requirements of the initial display interface, read the vector bitmap of the text to be rendered from the memory of the target machine, and create an initial texture cache based on the character information and character usage frequency of the text to be rendered, wherein the initial texture cache includes at least 1 texture cache partition, and each texture cache partition stores the vector bitmaps of characters of the same font and the same font size;
[0007] S3. When the display interface changes, update the texture cache of the previous display interface based on the text to be rendered in the new display interface to form a new texture cache, and render and display the text to be rendered in the new display interface.
[0008] The text rapid rendering method of the present invention is as follows. First, by initializing the text in the font library file, a vector bitmap of each text is generated according to the text information of the text. Secondly, according to the requirements of the initial display interface, an initial texture cache is established. Secondly, in the subsequent display interface (i.e., the new display interface), a new texture cache is continuously updated on the basis of the texture cache of the previous display interface, and the text to be rendered in the new display interface is rendered and displayed. Through the above text rendering method, it can be quickly called and rendered, reducing the process of rereading and rendering the text of the display interface from the font library file, improving the rendering efficiency, saving the running and storage space at the same time, and ensuring the safe and reliable operation of the embedded system.
[0009] In an embodiment of the present invention, in the above step S1, the establishment of the font vector bitmap includes the following steps:
[0010] S101. Store the font library file in the hard disk of the target machine;
[0011] S102. After the program starts, the CPU of the target machine reads the text of the font library file in the hard disk of the target machine;
[0012] S103. Use the text engine to generate the corresponding vector bitmap of each text, add it to the memory of the target machine, and complete the establishment of the font vector bitmap.
[0013] Furthermore, the text information of the above text includes font information and font size information, and the vector bitmap of the text includes the font vector bitmap.
[0014] Furthermore, in the above step S103, the text engine is the FreeType font engine.
[0015] In another embodiment of the present invention, in the above step S3, the method for updating the texture cache includes the following steps:
[0016] S301. Compare the text to be rendered in the new display interface with the text in the texture cache of the previous display interface to determine whether there is new text added;
[0017] S302. If there is no new text added in the new display interface, on the basis of the texture cache of the previous display interface, adjust the order of the vector bitmaps of the text in the corresponding texture cache partition according to the text information of the text in the new display interface, and generate a new texture cache partition to complete the update of the texture cache;
[0018] If there is new text added in the new display interface, jump to step S303 to execute;
[0019] S303. Determine whether there is free space in the texture cache partition corresponding to the text information of the new text in the texture cache of the previous display interface. If there is free space, jump to step S304 for execution; if there is no free space, jump to step S305 for execution;
[0020] S304. Add the vector bitmap of the new text after the vector bitmap of the text at the end of the sort in the texture cache partition corresponding to the previous display interface to generate a new texture cache partition to complete the update of the texture cache;
[0021] S305. Replace the vector bitmap of the text at the end of the sort in the texture cache partition corresponding to the previous display interface with the vector bitmap of the new text to generate a new texture cache partition to complete the update of the texture cache.
[0022] Compared with the prior art, the beneficial effects of the present invention are as follows: In the text fast rendering method of the present invention, first, by initializing the text in the font library file, vector bitmaps of each text are generated according to the text information of the text; second, an initial texture cache is established according to the requirements of the initial display interface; second, in the subsequent display interface (i.e., the new display interface), a new texture cache is continuously updated on the basis of the texture cache of the previous display interface, and the text to be rendered in the new display interface is rendered and displayed. Through the above text rendering method, it can be quickly called and rendered, reducing the process of re-reading and rendering the text of the display interface from the font library file, improving the rendering efficiency, saving operation and storage space at the same time, and ensuring the safe and reliable operation of the embedded system. Description of the Drawings
[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only for the present invention to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without creative efforts.
[0024] Figure 1 It is a flowchart of the text fast rendering method of the embedded system in the specific implementation manner;
[0025] Figure 2 It is a schematic diagram of the texture cache partition in the specific implementation manner;
[0026] Figure 3 It is a schematic diagram of the texture cache update in the specific implementation manner. Specific Embodiment
[0027] The present invention will be further described below in conjunction with specific embodiments, and the advantages and features of the present invention will become clearer as the description progresses. However, these embodiments are merely exemplary and do not impose any limitation on the scope of the present invention. Those skilled in the art should understand that without departing from the spirit and scope of the present invention, modifications or substitutions can be made to the details and forms of the technical solutions of the present invention, but such modifications and substitutions all fall within the protection scope of the present invention.
[0028] In the description of this embodiment, it should be understood that the orientation or positional relationship indicated by the terms "center", "longitudinal", "transverse", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc. is based on the orientation or positional relationship shown in the drawings. It is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and thus should not be construed as a limitation to the present invention.
[0029] In addition, the terms "first", "second", "third", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first", "second", etc. may explicitly or implicitly include one or more of such features. In the description of the present invention, unless otherwise specified, the meaning of "a plurality" is two or more.
[0030] This specific embodiment provides a method for rapid text rendering in an embedded system. As shown in Figure 1 the following steps are included:
[0031] S1. Initialize each character in the font library file, generate a vector bitmap corresponding to each character based on the character information of the character, and load it into the memory of the target machine.
[0032] Specifically, the establishment of the above-mentioned font vector bitmap includes the following steps:
[0033] S101. Store the font library file in the hard disk of the target machine;
[0034] In this step, the characters in the font library file include the characters that need to be rendered and displayed in the following display interface, and the number of characters is greater than the number of characters that need to be rendered and displayed in the display interface. The format of the above-mentioned font library file can be selected as a TrueType font file of simhei.ttf, and the font library file includes multiple characters, and each character contains its own character information, including the font information of the character, such as boldface, regular script, Song typeface, etc.; it can also include the font size information of the character.
[0035] S102. After the program starts, the target machine CPU reads the text in the font library file on the target machine's hard disk.
[0036] S103. Use a text engine to generate vector bitmaps corresponding to each text, and add them to the target machine's memory to complete the establishment of font vector bitmaps.
[0037] Specifically, in this step, the FreeType font engine can be selected to generate vector bitmaps for each text. When the text information of the above text includes font information and font size information, the generated vector bitmap of the text is a font vector bitmap.
[0038] S2. Select the text to be rendered according to the requirements of the initial display interface, read the vector bitmap of the text to be rendered from the target machine's memory, and create an initial texture cache based on the text information and text usage frequency of the text to be rendered, where the initial texture cache includes at least 1 texture cache partition, and each texture cache partition stores vector bitmaps of text with the same font and the same font size.
[0039] In a structure of the established initial texture cache, when rendering text of a certain font in the initial display interface, the vector bitmaps of the text of that font are stored in the formed initial texture cache. In the established initial texture cache, according to the usage frequency (i.e., the appearance frequency, or the number of appearances) of the text that needs to be rendered and displayed in the initial display interface, each text is sorted. For example, when the initial display interface renders and displays words such as bold navigation, route, longitude and latitude, and angle coordinates, an initial texture cache is established according to the number of appearances of each text (as Figure 2 shown).
[0040] It should be noted here that for the rendering of different font sizes, it can be achieved by scaling the font vector bitmap, or new texture caches can be generated and rendered according to this method, and the overall process is the same as the rendering method of text with different fonts in this specific embodiment.
[0041] S3. When the display interface changes, update the texture cache of the previous display interface based on the text to be rendered in the new display interface to form a new texture cache, and render and display the text to be rendered in the new display interface.
[0042] When the display interface changes, the text, the number of texts, and the font of the text in the new display interface may all change compared with the text in the initial display interface or the previous display interface. At this time, in order to facilitate the rendering and display of the text in the new display interface, it is necessary to update it in a timely manner based on the texture cache of the initial display interface or the previous display interface.
[0043] Specifically, in step S3 above, see Figure 3As shown in the figure, a method for updating a texture cache includes the following steps:
[0044] S301. Compare the text to be rendered on the new display interface with the text in the texture cache of the previous display interface to determine whether new text is added.
[0045] S302. If no new text is added to the new display interface, based on the text information of the text in the new display interface, adjust the order of the vector bitmaps of the text in the corresponding texture cache partition on the basis of the texture cache of the previous display interface, and generate a new texture cache partition to complete the update of the texture cache.
[0046] If new text is added to the new display interface, jump to step S303 for execution.
[0047] S303. Determine whether there is free space in the texture cache partition corresponding to the text information of the new text in the texture cache of the previous display interface. If there is free space, jump to step S304 for execution; if there is no free space, jump to step S305 for execution.
[0048] S304. Add the vector bitmap of the new text after the vector bitmap of the text at the end of the sorting in the texture cache partition corresponding to the previous display interface to generate a new texture cache partition to complete the update of the texture cache.
[0049] S305. Replace the vector bitmap of the text at the end of the sorting in the texture cache partition corresponding to the previous display interface with the vector bitmap of the new text to generate a new texture cache partition to complete the update of the texture cache.
[0050] In the text fast rendering method in this specific embodiment, first, initialize the text in the font library file, and generate vector bitmaps for each text according to the text information of the text; secondly, establish an initial texture cache according to the requirements of the initial display interface; secondly, in subsequent display interfaces (i.e., new display interfaces), continuously update on the basis of the texture cache of the previous display interface to form a new texture cache, and render and display the text to be rendered on the new display interface. Through the above text rendering method, it can be quickly called and rendered, reducing the process of rereading and rendering the text of the display interface from the font library file, improving the rendering efficiency, saving operation and storage space at the same time, and ensuring the safe and reliable operation of the embedded system.
[0051] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
[0052] In addition, it should be understood that although this specification is described according to embodiments, not every embodiment only contains an independent technical solution. This narrative way of the specification is only for clarity. Those skilled in the art should regard the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.
Claims
1. A method for fast text rendering of an embedded system, characterized in that: It includes the following steps: S1. Initialize each character in the font library file, generate a vector bitmap corresponding to each character based on the character information of the character, and load it into the memory of the target machine; S2. Select the characters to be rendered according to the requirements of the initial display interface, read the vector bitmaps of the characters to be rendered from the memory of the target machine, and create an initial texture cache based on the character information and character usage frequency of the characters to be rendered. The initial texture cache includes at least 1 texture cache partition, and each texture cache partition stores the vector bitmaps of characters of the same font and the same font size; S3. When the display interface changes, update the texture cache of the previous display interface to form a new texture cache based on the characters to be rendered in the new display interface, and render and display the characters to be rendered in the new display interface, including: S301. Compare the characters to be rendered in the new display interface with the characters in the texture cache of the previous display interface to determine whether there are new characters added; S302. If there are no new characters added in the new display interface, based on the character information of the characters in the new display interface, adjust the order of the vector bitmaps of the characters in the corresponding texture cache partition on the basis of the texture cache of the previous display interface, and generate a new texture cache partition to complete the update of the texture cache; If there are new characters added in the new display interface, jump to step S303 to execute; S303. Determine whether there is free space in the texture cache partition corresponding to the character information of the new character in the texture cache of the previous display interface. If there is free space, jump to step S304 to execute. If there is no free space, jump to step S305 to execute; S304. Add the vector bitmap of the new character after the vector bitmap of the character at the end of the sort in the texture cache partition corresponding to the previous display interface to generate a new texture cache partition to complete the update of the texture cache; S305. Replace the vector bitmap of the character at the end of the sort in the texture cache partition corresponding to the previous display interface with the vector bitmap of the new character to generate a new texture cache partition to complete the update of the texture cache.
2. The text rapid rendering method according to claim 1, characterized in that: In step S1, the establishment of the font vector bitmap includes the following steps: S101. Store the font library file in the hard disk of the target machine; S102. After the program starts, the CPU of the target machine reads the characters in the font library file in the hard disk of the target machine; S103. Use a character engine to generate the corresponding vector bitmaps of each character, add them to the memory of the target machine, and complete the establishment of the font vector bitmap.
3. The text rapid rendering method according to claim 1 or 2, characterized in that: The character information of the character includes font information and font size information, and the vector bitmap of the character includes a font vector bitmap.
4. The method for rapid text rendering according to claim 2, characterized in that: In step S103, the character engine is a FreeType font engine.
Citation Information
Patent Citations
Method and device for rendering characters
CN103186919A
Method for achieving font rendering based on FreeType font engine
CN104298504A