An embedded device font library dynamic replacement system and method based on Unicode and GB2312 encoding mapping
By building a lightweight bidirectional index mapping and dynamic expansion mechanism in embedded devices, the problem of storage capacity limitation in embedded devices is solved, on-demand loading and mixed rendering of Unicode characters are realized, storage efficiency and update speed are improved, and multi-language compatibility is supported.
Patent Information
- Application Number
- CN202511567060.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-30
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2045-10-30
AI Technical Summary
Embedded devices are limited by Flash capacity and cannot store the full Unicode font library. The traditional GB2312 font library cannot cover Unicode characters, resulting in garbled characters. Furthermore, the traditional full font library replacement solution is time-consuming and cannot meet real-time requirements, and cannot support the simultaneous rendering of GB2312 and Unicode characters.
While retaining the original GB2312 character set, a lightweight bidirectional index mapping and dynamic expansion mechanism is built. On-demand loading and mixed rendering of Unicode characters are achieved through hash tables, virtual expansion tables and status flags. The hash table stores the Unicode-GB2312 mapping relationship, the virtual expansion table defines the virtual zone code, the dynamic expansion area stores the glyph data of newly added characters, and supports external character set interfaces.
It achieves on-demand loading and mixed rendering of Unicode characters, reduces storage usage by more than 95%, improves font update efficiency by 100 times, supports progressive adaptation of the full Unicode character set, and meets the real-time requirements of multilingual compatibility and resource-constrained devices.
Smart Images

Figure CN121030050B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of embedded system character encoding and font management technology, specifically relating to an embedded device font dynamic replacement system and method based on Unicode and GB2312 encoding mapping. Background Technology
[0002] Embedded devices, limited by Flash memory capacity (typically 1-8MB), cannot store a full Unicode character set (10MB+), while the traditional GB2312 character set (500KB) cannot cover Unicode characters (such as extended Chinese characters, symbols, and multilingual text). For example, a smart meter needs to display the Unicode temperature symbol "℃" (U+2103), but the missing character set results in garbled text. Traditional full character set replacement solutions require rewriting the entire Flash block (e.g., 500KB character set takes 5 seconds), which cannot meet real-time requirements. Existing solutions do not support simultaneous rendering of GB2312 and Unicode characters (e.g., Chinese menus + Emoji prompts). Summary of the Invention
[0003] To address the problems existing in the prior art, this invention proposes a dynamic replacement system and method for embedded device font libraries based on Unicode and GB2312 encoding mapping. While retaining the original GB2312 font library, a lightweight bidirectional index mapping and dynamic expansion mechanism is constructed to achieve Unicode character compatibility and on-demand replacement. This method is suitable for resource-constrained IoT devices, industrial terminals, and consumer electronics products.
[0004] To achieve the above objectives, the technical solution adopted by the present invention is as follows:
[0005] An embedded device font library dynamic replacement system based on Unicode and GB2312 encoding mapping includes:
[0006] The original font library layer retains the original GB2312 font library data;
[0007] The index management layer includes a hash table, a virtual extension table, and status flags; the hash table stores Unicode-GB2312 mapping relationships, the virtual extension table assigns virtual zone codes to characters not covered by GB2312, and the status flags are used to mark the character status.
[0008] The dynamic extension area is used to store newly added Unicode character glyph data.
[0009] Preferably, the hash table defines 256 hash buckets, and each hash bucket stores conflicting Unicode-GB2312 mapping entries through a linked list;
[0010] In the hash calculation, the hash function is the CRC32 algorithm, truncated to the last 8 bits.
[0011] The Unicode-GB2312 mapping formula is:
[0012] Hash bucket index = CRC32 (Unicode code point) % 256.
[0013] Preferably, the virtual extension table defines mapping rules between virtual zone codes and Unicode extended characters, including:
[0014] Extract the IDS description sequence of the target character from the pre-set rule base;
[0015] Recursively decompose components and read glyph data, then concatenate them according to operator rules to generate the final glyph;
[0016] The final glyph generated by splicing is cached in the dynamic extension area and assigned a virtual zone code, which includes zones 95-99.
[0017] Preferably, the status flag is implemented using a bitmap, with each character occupying 2 bits, as shown below:
[0018] Unreplaced: 00, Replaced: 01, Virtually generated: 10, External references: 11, Total usage: 1KB.
[0019] Preferably, the dynamic expansion area is independently partitioned in Flash and stores newly added Unicode character glyph data as needed;
[0020] The dynamic expansion area includes a glyph database, an external font library interface, and virtual character generation;
[0021] The glyph database is used to store bitmap data of newly added Unicode characters and supports incremental updates;
[0022] The external font library interface is used to support loading third-party font library patches via HTTP, SD card, or Bluetooth.
[0023] The virtual character generation is used to generate new special characters by concatenating them according to the mapping rules defined in the virtual extension table and using operator rules.
[0024] The stored data packet format is:
[0025] [Opcode: 1B][Unicode code point: 4B][Data length: 2B][Glyph data: NB].
[0026] To achieve the above objectives, the present invention also provides a method for dynamic replacement of font libraries in embedded devices based on Unicode and GB2312 encoding mapping, implemented based on the aforementioned system for dynamic replacement of font libraries in embedded devices based on Unicode and GB2312 encoding mapping, the method comprising:
[0027] A pre-built bidirectional index table of Unicode code points and GB2312 zone codes is provided, wherein the bidirectional index table includes a hash table, a virtual extended table, and status flag bits;
[0028] A dynamic extension area is allocated in the storage medium to store newly added or replaced Unicode character glyph data;
[0029] The system receives the Unicode encoding of the input character, queries the corresponding GB2312 zone code or mapping rule through the bidirectional index table, and reads the character data.
[0030] The final glyph data will be rendered and output.
[0031] Preferably, the Unicode encoding of the received input character is used to look up the corresponding GB2312 zone code or mapping rule through the bidirectional index table to read the glyph data, including:
[0032] If the bidirectional index table is hit and the status flag is replaced, then read the glyph data from the dynamic extension area;
[0033] If the bidirectional index table is hit and the status flag is not replaced, then the character data is read from the original GB2312 character set;
[0034] If the bidirectional index table is not found, the glyphs are dynamically synthesized according to the mapping rules defined in the virtual extended table, or the external font library loading process is triggered.
[0035] Preferably, the final glyph data is rendered and output, supporting simultaneous display of GB2312 and Unicode characters on the same screen.
[0036] Preferably, the rendering and output of the final glyph data is optimized in the following ways:
[0037] High-frequency character indexes reside in RAM, while low-frequency characters are loaded from Flash on demand.
[0038] Anti-aliasing is applied to the synthesized glyphs, and bilinear interpolation is used to smooth the edges.
[0039] Atomic updates of status flags are achieved through bit-banding techniques.
[0040] To achieve the above objectives, the present invention also provides an embedded device, including a processor, a memory, and a display module. The memory stores a computer program, and when the processor executes the program, it implements the above-described method for dynamic replacement of embedded device font libraries based on Unicode and GB2312 encoding mapping.
[0041] The beneficial effects achieved by this invention are as follows:
[0042] This invention proposes a dynamic font replacement system and method for embedded devices based on Unicode and GB2312 encoding mapping. While retaining the original GB2312 font library, it constructs a lightweight Unicode-GB2312 bidirectional index mapping table to achieve on-demand loading and mixed rendering of Unicode characters. Employing hash tables to accelerate lookups, virtual location code expansion, and incremental update mechanisms, it reduces storage usage by over 95%, improves font update efficiency by 100 times, and supports progressive adaptation to the full Unicode character set. This invention can be widely applied in smart terminals, industrial equipment, and other scenarios, resolving the contradiction between multilingual compatibility and resource constraints. Attached Figure Description
[0043] Figure 1 A schematic diagram of the character library dynamic replacement system architecture based on Unicode and GB2312 encoding mapping provided by the present invention;
[0044] Figure 2 A schematic diagram illustrating the dynamic replacement process of a character library based on Unicode and GB2312 encoding mapping provided by this invention;
[0045] Figure 3 A schematic diagram illustrating the workflow of the inspection status flag bit provided by this invention;
[0046] Figure 4 This is a schematic diagram of the virtual character generation process provided by the present invention. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the embodiments and accompanying drawings. Here, the illustrative embodiments and descriptions of this invention are used to explain the invention, but are not intended to limit the invention.
[0048] It should also be noted that, in order to avoid obscuring the invention with unnecessary details, only the structures and / or processing steps closely related to the solution according to the invention are shown in the accompanying drawings, while other details that are not closely related to the invention are omitted.
[0049] It should be emphasized that the term "including / comprises" as used herein refers to the presence of a feature, element, step, or component, but does not exclude the presence or addition of one or more other features, elements, steps, or components.
[0050] It should also be noted that, unless otherwise specified, the term "connection" in this article can refer not only to a direct connection, but also to an indirect connection involving an intermediary.
[0051] In the following description, embodiments of the invention will be illustrated with reference to the accompanying drawings. In the drawings, the same reference numerals represent the same or similar parts, or the same or similar steps.
[0052] It should be emphasized here that the step markers mentioned below are not a limitation on the order of the steps, but should be understood as meaning that the steps can be executed in the order mentioned in the embodiments, or in a different order than in the embodiments, or several steps can be executed simultaneously.
[0053] As embedded devices are increasingly exported, more and more require multilingual support. Multilingual solutions require the interface to display multiple foreign language characters correctly. However, existing devices are based on the GB2312 character set, which only supports Chinese characters and some symbols, necessitating a multilingual character set upgrade. Traditional solutions involve replacing the entire character set from GB2312 to Unicode, requiring character remapping and resulting in incompatibility with existing devices. Furthermore, traditional solutions require excessive memory (10MB+), placing high demands on device memory. To address these issues, this invention proposes a lightweight bidirectional index mapping and dynamic expansion mechanism while maintaining the existing GB2312 character set. This mechanism achieves efficient compatibility and on-demand expansion through a three-level architecture, such as... Figure 1 As shown, a three-tier architecture for a dynamic font replacement system for embedded devices based on Unicode and GB2312 encoding mapping includes:
[0054] The original font library layer prohibits direct modification of the original data to ensure that the functionality of existing devices is not affected. The original font library layer retains the original GB2312 font library data, which is stored sequentially in GB2312 zone code (94 zones × 94 bits). Each character occupies a fixed number of bytes, with a total size of approximately 500KB.
[0055] The index management layer includes hash tables, virtual extended tables, and status flags.
[0056] In this invention, the hash table stores the Unicode→GB2312 mapping relationship, and each hash bucket contains a linked list to handle collisions.
[0057] The Virtual Extension Table assigns virtual zone codes (zones 95-99) to characters not covered by GB2312. The Virtual Extension Table defines the mapping rules between virtual zones (zones 95-99) and Unicode extended characters, and supports compound glyph rules (such as IDS descriptors) or external font references.
[0058] The status flag is used to mark the character status, including unreplaced, replaced, virtual generated, and external reference. It is 1 bit / character and occupies a total of 1KB.
[0059] The dynamic expansion area is a storage area independently allocated in Flash (e.g., 0x100000-0x110000) to store newly added Unicode character glyph data as needed, and supports incremental updates (smallest granularity single character).
[0060] In this invention, the dynamic extension area includes a glyph database, an external font library interface, and virtual character generation. The glyph database stores bitmap data (such as RGB565 format) of newly added Unicode characters; the external font library interface supports loading third-party font patches via HTTP, SD card, or Bluetooth; and virtual character generation is used to generate characters according to the mapping rules defined in the virtual extension table, using operators (…). By combining rules, new special characters can be generated.
[0061] Based on the same inventive concept, this invention provides a method for dynamic font replacement in embedded devices based on Unicode and GB2312 encoding mapping, comprising the following steps:
[0062] S1. A pre-built bidirectional index table of Unicode code points and GB2312 zone codes, which includes a hash table, a virtual extended table, and status flag bits;
[0063] S2. Divide the storage medium into a dynamic extension area to store newly added or replaced Unicode character glyph data;
[0064] S3. Receive the Unicode encoding of the input character and look up the corresponding GB2312 zone code or mapping rule through the bidirectional index table mentioned above.
[0065] If the bidirectional index table is hit and the status is replaced, then read the glyph data from the dynamic extension area;
[0066] If the bidirectional index table is hit and the status is not replaced, then the character data is read from the original GB2312 character set;
[0067] If the bidirectional index table is not hit, the glyphs are dynamically synthesized according to the mapping rules defined in the virtual extended table, or the external font library loading process is triggered.
[0068] S4. Render and output the final glyph data, supporting simultaneous display of GB2312 and Unicode characters on the same screen.
[0069] In this invention, the hash table in the bidirectional index table includes:
[0070] Define 256 hash buckets, each of which stores conflicting Unicode-GB2312 mapping entries via a linked list;
[0071] The hash function is a CRC32 algorithm truncated to the last 8 bits, and the mapping formula is:
[0072] Hash bucket index = CRC32 (Unicode code point) % 256.
[0073] In this invention, the virtual extension table in the bidirectional index table defines the mapping rules between virtual zone codes and Unicode extended characters, realizing parsing and glyph synthesis, including:
[0074] S11. Extract the IDS description sequences of the target characters from the pre-set rule base, such as... ;
[0075] S12, recursively decompose components and read glyph data, pressing the operator ( The final glyph is generated by combining the rules.
[0076] S13. Cache the final glyph generated by splicing to the dynamic extension area and allocate virtual zone code (zones 95-99).
[0077] In this invention, the status flag bits in the bidirectional index table are implemented using a bitmap, specifically including:
[0078] Each character occupies 2 bits, and the encoding status is unreplaced (00), replaced (01), virtual generation (10), and external reference (11).
[0079] The formula for calculating bitmap indexes is:
[0080] bit_index = (zone code - 1) * 94 + (bit code - 1);
[0081] byte_offset = bit_index / 4;
[0082] bit_shift = (bit_index % 4) * 2.
[0083] Where bit_index is the global index, byte_offset is the byte offset, and bit_shift is the starting bit offset in the target byte.
[0084] In this invention, the dynamically expanded area stores newly added or replaced Unicode character glyph data, including:
[0085] A1. Header information definition: Magic Number, Total number of characters, Free offset, Version number;
[0086] B1. Incremental updates use SPI Flash page programming mode, with a single write granularity of 256 bytes.
[0087] C1. Supports LRU (Least Recently Used) cache eviction policy to free up space occupied by infrequent characters.
[0088] In this invention, the external font loading process supports multi-source adaptation, including:
[0089] A2. Download the incremental font patch from the remote server via the HTTP protocol;
[0090] B2. Load third-party font files from local storage devices (SD card, USB flash drive);
[0091] C2. The data packet format is defined as follows:
[0092] [Opcode: 1B][Unicode code point: 4B][Data length: 2B][Glyph data: NB].
[0093] In this invention, hybrid rendering output optimizes performance in the following ways:
[0094] A3. High-frequency character indexes reside in RAM, while low-frequency characters are loaded from Flash on demand;
[0095] B3. Anti-aliasing is applied to the synthesized glyphs, and the edges are smoothed using a bilinear interpolation algorithm;
[0096] C3. Achieve atomic updates of the state bitmap through bit-banding technology.
[0097] like Figure 2 As shown, the dynamic replacement process based on Unicode and GB2312 character set indexes is as follows:
[0098] First, input a Unicode character and calculate its CRC32 hash value;
[0099] Traverse the bidirectional index table to match Unicode code points;
[0100] If a hit occurs, check the status flag; if the status is "replaced", read data from the glyph database in the dynamic expansion area, and if the status is "not replaced", read the corresponding GB2312 character data from the original GB2312 font library;
[0101] If no hit occurs, determine whether it is a composite rule; if it is a composite rule, dynamically synthesize a virtual glyph according to the mapping rule defined in the virtual expansion table, and if it is not a composite rule, trigger the external font library loading process;
[0102] Finally, render and output.
[0103] In this invention, calculate the CRC32 hash value, that is, calculate through a hash function to convert the Unicode code point of a character into a hash value of a fixed size. For example, calculate the hash value for the Unicode code point U+4E2D of the character "中", and get an integer 0x3D. The hash table contains 256 buckets (corresponding to the last 8 bits of the hash value), find the 0x3D bucket according to the hash value, traverse the linked list to find the node with Unicode=U+4E2D, and obtain the corresponding GB2312 area code 5448.
[0104] In this invention, the working process of checking the status flag is as Figure 3 shown
[0105] The status bitmap uses binary bits (bit) to track the current status of each character. The status bitmap has four status values: 00 means not replaced, and read data from the original GB2312 font library; 01 means replaced, and read the replaced Unicode glyph from the dynamic expansion area; 10 means virtual generation, and synthesize the glyph dynamically according to the mapping rule; 11 means external reference, and load the external font library from the SD card or network.
[0106] The bitmap query will calculate its position in the bitmap according to the GB2312 area code (1-94) and bit code (1-94) of the character. For example, the character "中" (Unicode=U+4E2D) is dynamically replaced: in the initial state, the status bitmap is 00, and read data from the original font library GB2312. After that, the user uploads an artistic word, which will update the dynamic expansion area, write the glyph data of "中" to the offset address 0x1000. At the same time, the status bitmap will also be updated, and the status will be changed to 01 (replaced), and then read the glyph data from the dynamic expansion area 0x1000.
[0107] In this invention, dynamically synthesizing a virtual glyph according to the mapping rule defined in the virtual expansion table means parsing and combining through IDS rules to generate characters. The IDS rule is a method defined in the Unicode standard to describe the structure of complex Chinese characters (especially rare characters or unencoded characters) in a symbolic way. It clarifies the composition method of characters by combining basic components and structure operators. See Figure 4 The virtual character generation steps are as follows: First, query the IDS description of the character from the preset rule base (e.g., Then, split the operators and components to extract the basic characters ( , ), read component bitmaps from the original font library, and concatenate them according to operator rules (such as left-right arrangement). The generated bitmap is then temporarily stored in the dynamic expansion area and read directly when needed later.
[0108] In this invention, triggering the external font loading process refers to loading a pre-built font file through a designated partition of an SD card, USB flash drive, or Flash memory. The external font is packaged according to a specific format and its integrity is verified upon receipt. For example, if the device needs to display a Russian alarm message... Download only the necessary characters via USB drive. The characters are saved to the dynamic extension area. Russian characters are read from the dynamic extension area, and Chinese characters are read from the original character set and displayed on the same screen.
[0109] Based on the above inventive concept, the present invention also provides an embedded device, including a processor, a memory and a display module. The memory stores a computer program, and when the processor executes the program, it implements the above-mentioned embedded device font library dynamic replacement method based on Unicode and GB2312 encoding mapping.
[0110] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. An embedded device font library dynamic replacement system based on Unicode and GB2312 encoding mapping, characterized in that, include: The original font library layer retains the original GB2312 font library data; The index management layer includes hash tables, virtual extended tables, and status flags; The hash table stores Unicode-GB2312 mapping relationships. Specifically, the hash table defines 256 hash buckets, and each hash bucket stores conflicting Unicode-GB2312 mapping entries through a linked list. In the hash calculation, the hash function is the CRC32 algorithm truncated to the last 8 bits. The formula for the Unicode-GB2312 mapping relationship is: Hash bucket index = CRC32(Unicode code point) % 256. The virtual extended table is a virtual zone code assigned to characters not covered by GB2312. The status flag is used to mark the character status; The dynamic extension area is used to store newly added Unicode character glyph data.
2. The embedded device font library dynamic replacement system based on Unicode and GB2312 encoding mapping according to claim 1, characterized in that, The virtual extension table defines the mapping rules between virtual zone codes and Unicode extended characters, including: Extract the IDS description sequence of the target character from the pre-set rule base; Recursively decompose components and read glyph data, then concatenate them according to operator rules to generate the final glyph; The final glyph generated by splicing is cached in the dynamic extension area and assigned a virtual zone code, which includes zones 95-99.
3. The embedded device font library dynamic replacement system based on Unicode and GB2312 encoding mapping according to claim 1, characterized in that, The status flags are implemented using a bitmap, with each character occupying 2 bits, represented as follows: Unreplaced: 00, Replaced: 01, Virtually generated: 10, External references: 11, Total usage: 1KB.
4. The embedded device font library dynamic replacement system based on Unicode and GB2312 encoding mapping according to claim 2, characterized in that, The dynamic expansion area is independently divided into storage areas in Flash, and new Unicode character glyph data is stored as needed. The dynamic expansion area includes a glyph database, an external font library interface, and virtual character generation; The glyph database is used to store bitmap data of newly added Unicode characters and supports incremental updates; The external font library interface is used to support loading third-party font library patches via HTTP, SD card, or Bluetooth. The virtual character generation is used to generate new special characters by concatenating them according to the mapping rules defined in the virtual extension table and using operator rules. The stored data packet format is: [Opcode: 1B][Unicode code point: 4B][Data length: 2B][Glyph data: NB].
5. A method for dynamic font replacement in embedded devices based on Unicode and GB2312 encoding mapping, characterized in that, The embedded device font library dynamic replacement system based on Unicode and GB2312 encoding mapping as described in claim 1 is implemented, and the method includes: A pre-built bidirectional index table of Unicode code points and GB2312 zone codes is provided, wherein the bidirectional index table includes a hash table, a virtual extended table, and status flag bits; A dynamic extension area is allocated in the storage medium to store newly added or replaced Unicode character glyph data; The system receives the Unicode encoding of the input character, queries the corresponding GB2312 zone code or mapping rule through the bidirectional index table, and reads the character data. The final glyph data will be rendered and output.
6. The embedded device font library dynamic replacement method based on Unicode and GB2312 encoding mapping according to claim 5, characterized in that, The method of receiving the Unicode encoding of the input character, and reading the glyph data by querying the corresponding GB2312 zone code or mapping rule through the bidirectional index table, includes: If the bidirectional index table is hit and the status flag is replaced, then read the glyph data from the dynamic extension area; If the bidirectional index table is hit and the status flag is not replaced, then the character data is read from the original GB2312 character set; If the bidirectional index table is not found, the glyphs are dynamically synthesized according to the mapping rules defined in the virtual extended table, or the external font library loading process is triggered.
7. The embedded device font library dynamic replacement method based on Unicode and GB2312 encoding mapping according to claim 5, characterized in that, The final character data is rendered and output, supporting simultaneous display of GB2312 and Unicode characters on the same screen.
8. The embedded device font library dynamic replacement method based on Unicode and GB2312 encoding mapping according to claim 7, characterized in that, The final glyph data rendering output is optimized in the following ways: High-frequency character indexes reside in RAM, while low-frequency characters are loaded from Flash on demand. Anti-aliasing is applied to the synthesized glyphs, and bilinear interpolation is used to smooth the edges. Atomic updates of status flags are achieved through bit-banding techniques.
9. An embedded device, characterized in that, The device includes a processor, a memory, and a display module. The memory stores a computer program, and when the processor executes the program, it implements the embedded device font library dynamic replacement method based on Unicode and GB2312 encoding mapping as described in any one of claims 5-8.
Citation Information
Patent Citations
Coding lookup method and device
CN101216847A
Data processing method and device, electronic equipment and readable storage medium
CN118277379A