Embedded dot-matrix font compression methods, systems, font files, and embedded devices

CN122372000BActive Publication Date: 2026-08-11WUXI UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-06-05
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

这类方法能够从少量样本生成多种字体风格,但模型体积通常巨大(>10MB),推理需要依赖深度学习框架(如PyTorch、TensorFlow),无法在资源受限的嵌入式设备上部署

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122372000B_ABST
    Figure CN122372000B_ABST
Patent Text Reader

Abstract

This application discloses an embedded dot matrix font compression method, system, font file, and embedded device, comprising: constructing a lightweight decoder with at least two transposed convolutional layers and a parameter size ≤200KB; initializing independent low-dimensional latent vectors for each character to form a latent vector table; jointly optimizing and training the latent vector table and the decoder; performing 8-bit linear quantization on the trained latent vector table and 8-bit dynamic fixed-point quantization on the decoder weights, and saving it as an independent binary font file. By assigning low-dimensional latent vectors to each character and jointly training the lightweight decoder, the original dot matrix is ​​compressed into the sum of the latent vector table and the decoder parameters. This application can reduce character storage space and achieve a pixel reconstruction accuracy ≥97%. Furthermore, through 8-bit linear quantization and dynamic fixed-point quantization, the font file can be inferred on the embedded device without a deep learning framework, thus meeting the display requirements of resource-constrained devices.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of embedded devices and deep learning technology, specifically relating to an embedded dot matrix font compression method, system, font file, and embedded device. Background Technology

[0002] Dot-matrix fonts are the most common way to display Chinese characters in embedded devices (such as smartwatches, home appliance control panels, electronic price tags, and industrial instruments). Taking the GB2312 character set (6763 Chinese characters) as an example, a 16×16 dot-matrix font requires approximately 216KB of storage space, and a 24×24 dot-matrix font requires approximately 475KB of storage space. For microcontrollers with extremely limited storage resources (typically Flash capacity between 512KB and 2MB), font usage often becomes a bottleneck in system design.

[0003] Existing font compression methods are mainly divided into two categories: The first category is traditional lossless / lossy compression algorithms, such as Huffman coding, LZW, and run-length encoding (RLE). Although these methods are simple to implement, their compression ratio is limited. A 24×24 dot matrix font library often exceeds 300KB after compression, and they cannot support multiple font extensions. Each font needs to be compressed and stored independently, and the storage overhead increases exponentially in multi-font scenarios.

[0004] The second category comprises deep learning-based font generation methods, such as Generative Adversarial Networks (GANs) and Diffusion Models. These methods can generate multiple font styles from a small number of samples, but the model size is typically enormous (>10MB), and inference relies on deep learning frameworks (such as PyTorch and TensorFlow), making them unsuitable for deployment on resource-constrained embedded devices. Furthermore, existing lightweight generation models (such as variational autoencoders with fewer than 1MB of parameters) typically achieve reconstruction accuracy below 95% on 24×24 dot matrices and also do not support low-cost multi-font expansion. More importantly, these methods are geared towards the "font generation" task, not the "font library compression and storage" task, and their goals are entirely different from those of this invention.

[0005] Therefore, there is an urgent need for a bitmap font compression method designed specifically for embedded devices, which has extremely small storage and supports multiple font extensions. This method can significantly reduce the storage space of a single font library while ensuring high reconstruction quality and achieve low-cost multiple font extensions. Summary of the Invention

[0006] To achieve the above technical objectives, the first aspect of this application provides an embedded dot-matrix font compression method, the detailed technical solution of which is as follows: An embedded dot-matrix font compression method, characterized by comprising the following steps: Step 1: Construct a lightweight decoder, which is a convolutional neural network containing at least two transposed convolutional layers with a total parameter size of no more than 200KB, used to generate 24×24 dot matrix characters from low-dimensional real-valued latent vectors; Step 2: Initialize an independent low-dimensional real-valued latent vector for each character in the target character set. All latent vectors constitute a trainable latent vector table, and the dimensions of the latent vectors are 16 to 64. Step 3: Using the dot matrix data of each character in the target character set as the supervision signal for the corresponding latent vector, perform joint optimization training on the latent vector table and the decoder, so that after optimization, inputting the latent vector into the decoder can reconstruct the dot matrix of the corresponding character. Step 4: Perform 8-bit linear quantization on the optimized latent vector table, perform 8-bit dynamic fixed-point quantization on the optimized decoder network weights, and save the quantized latent vector table and decoder parameters as raw binary files independent of any deep learning framework to obtain the character library file. The character library file is configured to: when running on an embedded device, read the latent vector corresponding to the target character in the latent vector table, input it into the decoder, and generate the dot matrix of the target character.

[0007] By assigning an independent low-dimensional latent vector (16-64 dimensions) to each character and jointly training a lightweight decoder (parameter count ≤200KB), the original dot matrix (475KB per font) is compressed into the sum of the latent vector table and the decoder parameters. This application reduces the total storage space of characters while achieving a pixel reconstruction accuracy of ≥97%. Furthermore, through 8-bit linear quantization and dynamic fixed-point quantization, the font file can be directly inferred on embedded devices without a deep learning framework, fully meeting the real-time display requirements of resource-constrained devices.

[0008] A second aspect of this application provides an embedded dot-matrix font compression system, comprising: The storage unit is a non-volatile memory of the embedded device, used to store a character library file. The character library file contains an 8-bit linearly quantized latent vector table and 8-bit dynamically fixed-point quantized decoder parameters. The latent vector table contains an independent low-dimensional real-valued latent vector for each character in the target character set. The decoder is a lightweight convolutional neural network with no more than 200KB of parameters, capable of generating 24×24 dot matrix characters from the latent vectors. The processing unit, which is a microcontroller or embedded processor, is used to read the character library file, extract the latent vector corresponding to the target character from the latent vector table according to the user input, input the vector to the decoder, and perform forward inference through fixed-point arithmetic to generate the dot matrix of the target character.

[0009] By embedding the quantized latent vector table and decoder parameters into embedded non-volatile memory, the processing unit only needs to perform fixed-point arithmetic to complete forward inference, eliminating the need for floating-point arithmetic units. Compared to traditional solutions that require storing the entire dot matrix and cannot be expanded with multiple fonts, this system significantly reduces storage resources and operating memory requirements.

[0010] A third aspect of this application provides a font file generated using the embedded dot-matrix font compression method described in any of the first aspects of this application, comprising: An implicit vector table data segment is used to sequentially store N implicit vectors in byte alignment. The length of each implicit vector is 16 to 64 bytes, where the i-th implicit vector corresponds to the compressed dot matrix information of the i-th character in the target character set, and each byte is an 8-bit linear quantization value. A decoder parameter data segment is used to sequentially store all network weights of a lightweight convolutional neural network, the weights being stored in binary form as 8-bit dynamic fixed-point numbers, the organization of the network weights corresponding to a predefined decoder network structure capable of generating a 24×24 dot matrix from the latent vectors; The latent vector table data segment and the decoder parameter data segment are two independent binary data segments that can be directly read by the embedded processor without relying on any deep learning framework.

[0011] The character library file independently stores the latent vector table and decoder parameters in binary data segments. It does not rely on any deep learning framework or operating system and can be directly read by embedded processors by address. Each latent vector is 16-64 bytes long, corresponding to 6763 Chinese characters in the GB2312 standard. The total size of the latent vector table is approximately 108KB to 432KB. Combined with the decoder parameters (≤200KB), the overall character library file storage limit is approximately 632KB.

[0012] Because it employs 8-bit quantization, both the implicit vector table data segment and the decoder parameter data segment are byte-aligned. The processing unit can access these segments sequentially without parsing complex file headers, significantly reducing loading and parsing overhead. This data structure design allows the font file to be stored as an independent product on Flash or EEPROM, and it can also be directly ported between different embedded platforms without the need for retraining or format conversion.

[0013] A fourth aspect of this application provides an embedded device comprising: The font file described in any of the third aspects of this application; A microcontroller or embedded processor is used to read the font file and generate character dot matrices; The display driver unit is used to output the generated character dot matrix to the display screen.

[0014] The embedded device integrates the font library file, microcontroller (or embedded processor), and display driver unit as described in the third aspect. The microcontroller directly indexes the implicit vector table through character encoding, calls the fixed-point quantization decoder to generate the dot matrix, and outputs it to the display screen via the display driver unit. Compared to traditional devices that require external Flash storage for multiple font libraries, this device can simultaneously store a single-font compressed font library and multiple font extension parameters in its built-in Flash. Attached Figure Description

[0015] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the accompanying drawings used in the embodiments will be briefly described below. The textual descriptions of these drawings are as follows, and actual drawing can be based on these descriptions: Figure 1 This is a flowchart illustrating the execution of the embedded dot-matrix font compression method in this application embodiment; Figure 2 This is a schematic diagram of the lightweight decoder in the embodiments of this application; Figure 3 This is a comparison example between the original font library and the reconstructed dot matrix of the embodiments of this application. Detailed Implementation

[0016] It should be noted that the following detailed descriptions are exemplary and intended to provide indicative explanations of the content of this application. It should be noted that all technical and scientific terms used in this application have the same meaning as commonly understood by a person skilled in the art to which this application pertains.

[0017] The system architecture and prior art solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be noted that the described embodiments are only for explanation and illustration of this application, and not the entirety of the content. All other embodiments obtained by those skilled in the art based on the embodiments provided in this application without creative effort are within the protection scope of this application.

[0018] Before describing the embodiments of this application in detail, the relevant technical terms used in this application will be explained in a unified manner as follows: Decoder: Refers to the lightweight convolutional neural network constructed in this application, used to generate dot matrix characters of the target size from low-dimensional latent vectors. Its structure is a UNet-type or fully convolutional network containing at least two transposed convolutional layers, with a total parameter size not exceeding 200KB.

[0019] Latent vector: A trainable low-dimensional real-valued vector independently assigned to each character in the target character set, with dimensions ranging from 16 to 64. After training, the latent vector of each character uniquely corresponds to the dot matrix structure information of that character.

[0020] Latent vector table: This refers to a trainable parameter table composed of the latent vectors of all characters in the target character set. The storage order corresponds to the character encoding order. In embedded deployments, the corresponding latent vector can be directly indexed through the character encoding.

[0021] A dot-matrix font library refers to a data set that stores character glyphs in a dot-matrix format. In this embodiment, a 24×24 dot-matrix of 6763 Chinese characters from the GB2312 standard is used as an example, where each character's dot-matrix is ​​a 24×24 binary image. The font library file is the binary file obtained by compressing the dot-matrix font library using the method described in this application.

[0022] Quantization: refers to the process of converting trained floating-point parameters into low-bit integer representations. This application includes two quantization methods: the latent vector table uses 8-bit linear quantization (based on a linear mapping between the maximum and minimum values); the decoder weights use 8-bit dynamic fixed-point quantization (with a scaling factor of powers of 2, allocating 4 bits for the fractional part and 4 bits for the integer part).

[0023] Multi-font expansion refers to a method that adds a second font style (such as SimSun) on top of a pre-trained first font style (such as SimSun) with extremely low storage cost. Its core operations include: freezing the original latent vector table, extracting new font style features using a lightweight style encoder, concatenating the style features with the original latent vectors and inputting them into the decoder, and fine-tuning only the last two convolutional layers of the decoder.

[0024] Integer inference: This refers to the decoder's forward computation on embedded devices being entirely based on integer arithmetic operations, without the need for floating-point units. Specifically, it includes operations such as multiplication and accumulation of 8-bit inputs and 8-bit weights, shift scaling, biasing, and saturation output.

[0025] Example 1: like Figure 1 As shown, this embodiment provides an embedded dot-matrix font compression method, including the following steps: Step 1: Build a lightweight decoder.

[0026] Construct a lightweight decoder to generate 24×24 dot matrix characters from low-dimensional real-valued latent vectors. For example... Figure 2 As shown, this lightweight decoder first converts the latent vectors into two-dimensional feature maps, and then upsamples them through a UNet-type or fully convolutional network containing at least two transposed convolutional layers, where each transposed convolutional layer uses a 3×3 convolutional kernel with a stride of 2. The total number of parameters in the decoder does not exceed 200KB. The decoder output is a 24×24 binary probability map, which is then quantized through a preset threshold of 0.5 to obtain the binary dot matrix of the target character.

[0027] like Figure 2As shown, optionally, the lightweight decoder also includes a fully connected layer and a reconstruction layer connected sequentially before a UNet-type or fully convolutional network, wherein the fully connected layer is used to map the latent vectors to a one-dimensional feature map, and the reconstruction layer is used to reshape the one-dimensional feature map into a two-dimensional feature map.

[0028] Step 2: Initialize the implicit vector table.

[0029] An independent low-dimensional real-valued latent vector is initialized for each character in the target character set, and all latent vectors constitute a trainable latent vector table. In this embodiment, the target character set consists of 6763 Chinese characters from the GB2312 standard. The latent vectors have a dimension of 16 to 64. In this embodiment, the latent vectors are randomly initialized using a Gaussian distribution with a mean of 0 and a standard deviation of 0.01.

[0030] Step 3: Joint optimization training.

[0031] Using the dot matrix data of each character in the target character set as the supervision signal for the corresponding latent vector, the latent vector table and the decoder are jointly optimized and trained. This optimizes the latent vector so that inputting it into the decoder can reconstruct the dot matrix of the corresponding character. Training employs a full-scale training approach, with all character data participating in updates in each training epoch. In this embodiment, a binary cross-entropy loss function, the Adam optimizer, and a learning rate of 0.001 are used during training, decaying in a conventional manner.

[0032] Step 4: Quantize and save the font file.

[0033] The optimized latent vector table is subjected to 8-bit linear quantization, and the optimized decoder network weights are subjected to 8-bit dynamic fixed-point quantization, where the decimal part of the fixed-point number is allocated to 4 bits and the integer part is allocated to 4 bits.

[0034] The scaling factor and zeros for linear quantization are calculated based on the maximum and minimum values ​​of the latent vector table. Dynamic fixed-point quantization uses a scaling factor of powers of 2, meaning the quantized value is equal to the original value divided by 2 to the power of -4, then rounded to the nearest integer, with 4 decimal places. During inference, intermediate convolution results are accumulated using 32-bit integers, right-shifted by 4 bits, and then saturated to 8 bits. The quantized latent vector table and decoder parameters are saved as raw binary files independent of any deep learning framework, resulting in a character set file. This character set file is configured to, when running on an embedded device, read the latent vector corresponding to the target character from the latent vector table, input it into the decoder, and generate a dot matrix of the target character.

[0035] The embedded dot matrix font compression method provided in this embodiment compresses the original dot matrix (475KB per font) into the sum of the latent vector table and decoder parameters by assigning an independent low-dimensional latent vector (16-64 dimensions) to each character and jointly training a lightweight decoder (parameter size ≤200KB). Experiments have verified that on a 24×24 dot matrix of the GB2312 character set, the total storage can be as low as 329KB (saving 30%), and the pixel reconstruction accuracy is ≥97%, with differences imperceptible to the human eye. Furthermore, through 8-bit linear quantization and dynamic fixed-point quantization, the font file can be directly inferred on embedded devices without a deep learning framework, with a single-character inference time of <0.5ms, fully meeting the real-time display requirements of resource-constrained devices.

[0036] Example 2: Based on the above embodiment 1, this embodiment further discloses the detailed parameters and procedures for training and quantization.

[0037] Training hyperparameters: The loss function used was Binary Cross-Entropy (BCE). The optimizer was Adam, with an initial learning rate of 0.001, which decayed to 0.5 times the original rate every 200 training epochs. The batch size was 256. The latent vectors were randomly initialized using a Gaussian distribution with a mean of 0 and a standard deviation of 0.01. Training was performed for 800 epochs until the pixel accuracy on the validation set converged.

[0038] Implicit vector 8-bit linear quantization: For the implicit vector table, the minimum and maximum values ​​of each implicit vector channel are calculated. The quantized value is obtained by dividing the difference between the original value and the minimum value by the difference between the maximum value and the minimum value, multiplying by 255, and then rounding to the nearest integer. During dequantization, the quantized value, minimum value, and maximum value are used to back-calculate proportionally. This quantization process is a standard linear quantization scheme and does not require storing additional scaling factors or zeros.

[0039] Decoder weights undergo 8-bit dynamic fixed-point quantization: First, the maximum absolute value of each tensor is calculated, and the scaling factor is taken as this maximum value divided by 127 (because the range of an 8-bit signed integer is -128 to 127, 127 is used as the denominator when using symmetric quantization). The quantized weight value is the original weight divided by the scaling factor, rounded to the nearest integer, and saturated to the range [-127, 127]. During inference, convolution operations use integer multiplication and addition, and the intermediate accumulated results are stored in a 32-bit signed integer variable to prevent overflow. After completing all multiplication and addition operations within a convolution window, the accumulated result is shifted right by 4 bits (corresponding to 4 bits of the fractional part) to achieve fixed-point scaling alignment. Then, the 16-bit bias value of the convolutional layer (pre-quantized) is added, and the result is limited to the range [-128, 127] by a saturation operation, ultimately serving as the 8-bit output feature value at that position. Activation functions (such as ReLU or Sigmoid) are also implemented using integer approximations: ReLU can directly set negative values ​​to 0, while Sigmoid is implemented through a pre-computed lookup table or piecewise linear interpolation. No floating-point operations are involved in the entire forward inference process; it relies entirely on integer arithmetic operations and requires no floating-point unit (FPU) support.

[0040] The training and quantization scheme provided in this embodiment enables the entire model to run efficiently on a microcontroller without a floating-point unit. Testing shows that the peak RAM usage for the decoder's forward inference is less than 8KB, meeting the resource constraints of low-end MCUs such as Cortex M0 / M3 / M4.

[0041] Example 3: This embodiment takes the 24×24 dot matrix of the GB2312 character set (6763 Chinese characters) as the object, and gives the character library compression effect under three typical parameter configurations. The overall performance of the invention is verified through a unified experimental environment.

[0042] Hardware environment: Training uses an NVIDIA RTX 3060 graphics card; the embedded testing environment uses an STM32L4 series microcontroller (CortexM4, 128KB RAM, 512KB Flash), with a main frequency of 80MHz.

[0043] Dataset: 24×24 dot matrix of 6763 Chinese characters in the GB2312 standard, generated by rendering Song typeface.

[0044] The effects of the three parameter configurations are shown in the table below: The cost-effective decoder has approximately 90KB of parameters, 800 training epochs, a learning rate of 0.001, and uses 8-bit linear quantization of the latent vectors and 8-bit dynamic fixed-point quantization of the decoder weights (4 decimal places and 4 integer places). The balanced and high-quality decoders are based on this model, with only the latent vector dimension adjusted, while the other parameters remain the same.

[0045] Inference speed test: On STM32L4, the single-word inference time is about 0.4ms (using integer arithmetic), which meets the requirements for real-time display.

[0046] Reconstruction quality comparison: such as Figure 3 As shown, the comparison example between the original font library (or original dot matrix) and the reconstructed dot matrix of the present invention demonstrates that the human eye can hardly distinguish the difference.

[0047] Multi-font expansion experiment: Taking the expansion from Song typeface to Hei typeface as an example, the last two layers of the decoder (15KB parameters) were fine-tuned using 100 samples to generate the Hei typeface dot matrix of all 6763 Chinese characters, with a pixel accuracy of >99% and an additional storage of only about 17KB (including style encoder).

[0048] Comparative Analysis: Compared to traditional run-length encoding (RLE) compressed dot matrix (approximately 310KB but requiring complete storage for each font, resulting in high expansion costs), this invention achieves extremely low-cost multi-font expansion with similar storage requirements (less than 20KB of additional storage per font). Compared to lightweight variational autoencoders (parameter count <200KB but accuracy typically below 95%), this invention improves accuracy by more than 4 percentage points.

[0049] This embodiment demonstrates that by changing the latent vector dimension (16-64 dimensions), a smooth balance between storage and quality can be achieved to adapt to different application scenarios, reflecting the adjustability and flexibility of this invention. Meanwhile, experimental data fully demonstrates the superiority of this invention in terms of storage space, reconstruction quality, inference speed, and multi-font expansion.

[0050] Example 4: Based on the above embodiments 1-3, this embodiment provides a multi-font style extension method that can add a new font style with extremely low storage cost.

[0051] Taking the expansion from Song typeface to Hei typeface as an example, the specific steps are as follows: 1. Freeze the trained and deployed latent vector table: This latent vector table stores the structural information of the Song typeface and remains unchanged during the expansion process.

[0052] 2. Collect fine-tuning samples: Collect 24×24 dot matrix of 100 commonly used Chinese characters in the boldface font library as fine-tuning samples, covering common stroke types (such as horizontal, vertical, left-falling, right-falling, turning, etc.).

[0053] 3. Construct a style encoder: Construct a lightweight style encoder, which is a lightweight CNN structure with one convolutional layer, and outputs a 32-dimensional style feature vector to extract style features from 100 samples.

[0054] 4. Feature concatenation: The style feature vector and the SimSun latent vector are concatenated by channel and input into the decoder.

[0055] 5. Fine-tune the decoder: Fix all weights in the decoder except for the last two convolutional layers, and fine-tune only the last two convolutional layers. These two layers have approximately 15KB of parameters. Use the Adam optimizer with a learning rate of 0.0001, and train for 50 epochs.

[0056] 6. Generate a new character set file: After fine-tuning, the new decoder, in conjunction with the original latent vector table, can generate the boldface dot matrix of all 6763 Chinese characters. The additional storage is only for the fine-tuned decoder weights (approximately 15KB) and style encoder parameters (approximately 2KB), totaling approximately 17KB.

[0057] Tests showed that the generated extended black font dot matrix had a pixel accuracy of >99% compared to the original black font library, and the difference was indistinguishable to the human eye.

[0058] The multi-font expansion method provided in this embodiment only requires extracting style features from 50-200 samples and fine-tuning the last two convolutional layers of the decoder to add a new font style. The number of new parameters is extremely small (usually <20KB), and there is no need to retrain the entire model or store the entire font library. Compared with traditional solutions that require storing the entire font library (+475KB / font), the expansion cost of this invention is negligible, making it particularly suitable for embedded devices that require dynamic switching of font styles (such as electronic price tags and smart wearable devices).

[0059] Example 5: This embodiment provides an embedded dot-matrix font compression system, including: Storage Unit: The storage unit is a non-volatile memory (such as Flash or EEPROM) of the embedded device, used to store the character library file. The character library file contains an 8-bit linearly quantized latent vector table and 8-bit dynamically fixed-point quantized decoder parameters. The latent vector table contains an independent low-dimensional real-valued latent vector (16-64 dimensions) for each character in the target character set. The decoder is a lightweight convolutional neural network with no more than 200KB of parameters, capable of generating 24×24 dot matrix characters from the latent vectors.

[0060] Processing Unit: The processing unit is a microcontroller or embedded processor (such as the Cortex-M series), used to read the character library file, extract the latent vector corresponding to the target character from the latent vector table according to the user input, input it into the decoder, and perform forward inference through fixed-point arithmetic to generate the dot matrix of the target character. The forward inference of the decoder is entirely based on integer arithmetic and does not rely on floating-point arithmetic units.

[0061] Display unit: used to output the dot matrix to the display screen.

[0062] Style extension unit: used to extract the style feature vector of the second font style through the style encoder, and then concatenate the style feature vector with the latent vector of the first font style and input it into the decoder. Only the last two convolutional layers of the decoder are fine-tuned to generate new decoder parameters corresponding to the second font style.

[0063] The system provided in this embodiment stores the quantized latent vector table and decoder parameters in embedded non-volatile memory. The processing unit only needs to perform fixed-point arithmetic (32-bit accumulation, right shift, saturation) to complete forward inference, eliminating the need for a floating-point arithmetic unit. Compared to traditional solutions that require storing the entire dot matrix (475KB) and cannot be expanded with multiple fonts, this system significantly reduces storage resources (Flash) and operating memory (typical peak RAM less than 8KB). Experiments show that the system can run stably on low-end MCUs such as STM32L4, with single-character generation time of <0.5ms after font library loading and no display delay.

[0064] Example 6: This embodiment provides a font file generated using the embedded dot-matrix font compression method described in any one of embodiments 1 to 4. The font file is stored in its raw binary format, does not rely on any deep learning framework, and includes the following data segments: An implicit vector table data segment is used to sequentially store N implicit vectors in byte-aligned format. Each implicit vector is 16 to 64 bytes long, where the i-th implicit vector corresponds to the compressed dot matrix information of the i-th character in the target character set, and each byte is an 8-bit linear quantization value. Taking the GB2312 character set (6763 Chinese characters) as an example, the size of the implicit vector table data segment is approximately 108KB (16 dimensions) to 432KB (64 dimensions).

[0065] A decoder parameter data segment: This segment sequentially stores all the network weights of a lightweight convolutional neural network. The weights are stored in binary form as 8-bit dynamic fixed-point numbers. The organization of the network weights corresponds to a predefined decoder network structure capable of generating a 24×24 dot matrix from the latent vectors. This data segment is no larger than 200KB.

[0066] The latent vector table data segment and the decoder parameter data segment are two independent binary data segments that can be directly read by the embedded processor without relying on any deep learning framework. The processing unit only needs to calculate the offset through character encoding to directly access the latent vector of the corresponding character, without parsing complex file headers or performing hash lookups.

[0067] The font file provided in this embodiment independently stores the latent vector table and decoder parameters in binary data segments. It does not rely on any deep learning framework or operating system and can be directly read by embedded processors at addresses. Due to the use of 8-bit quantization and alignment of all data bytes, the processing unit can access the font file sequentially without parsing a complex file header, significantly reducing loading and parsing overhead. This data structure design allows the font file to be stored as an independent product in Flash / EEPROM, and it can also be directly ported between different embedded platforms without retraining or format conversion.

[0068] Example 7: This embodiment provides an embedded device, including: The font file described in Example 6; A microcontroller or embedded processor is used to read the character library file and generate character dot matrices; when performing decoder forward inference, the microcontroller or embedded processor is based entirely on integer operations and does not use floating-point units. The display driver unit is used to output the generated character dot matrix to the display screen.

[0069] This embedded device can be a resource-constrained device such as a smartwatch, home appliance control panel, electronic shelf label, or industrial instrument. The microcontroller directly indexes the implicit vector table through character encoding (constant time complexity), calls a fixed-point quantization decoder to generate a dot matrix, and outputs it to the display screen via the display driver unit. Compared to traditional devices that require external Flash storage for multiple font libraries (each font + 475KB), this device can simultaneously store a single-font compressed font library and multiple font extension parameters in the built-in Flash (each new font only requires an additional 15KB to 20KB of fine-tuning weights).

[0070] Experiments show that, with a typical embedded configuration of 128KB RAM and 512KB Flash, this device can smoothly display the GB2312 full Chinese character set and supports dynamic font switching. The display quality meets the requirements of scenarios such as industrial instruments and smart home panels.

[0071] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. An embedded dot matrix font library compression method, characterized by, Includes the following steps: Step 1: Construct a lightweight decoder, which is a convolutional neural network containing at least two transposed convolutional layers with a total parameter size of no more than 200KB, used to generate 24×24 dot matrix characters from low-dimensional real-valued latent vectors; Step 2: Initialize an independent low-dimensional real-valued latent vector for each character in the target character set. All latent vectors constitute a trainable latent vector table, and the dimensions of the latent vectors are 16 to 64. Step 3: Using the dot matrix data of each character in the target character set as the supervision signal for the corresponding latent vector, perform joint optimization training on the latent vector table and the decoder, so that after optimization, inputting the latent vector into the decoder can reconstruct the dot matrix of the corresponding character. Step 4: Perform 8-bit linear quantization on the optimized latent vector table, perform 8-bit dynamic fixed-point quantization on the optimized decoder network weights, and save the quantized latent vector table and decoder parameters as raw binary files independent of any deep learning framework to obtain the character library file. The character library file is configured to: when running on an embedded device, read the latent vector corresponding to the target character in the latent vector table, input it into the decoder, and generate the dot matrix of the target character.

2. The method of claim 1, wherein the embedded dot matrix font compression method is characterized by, In step 3, the training process uses a binary cross-entropy loss function, the Adam optimizer, and a learning rate of 0.

001. The latent vectors are randomly initialized using a Gaussian distribution with a mean of 0 and a standard deviation of 0.

01.

3. The method of claim 1, wherein the embedded dot matrix font compression method is characterized by, In step 4, the fractional digits of the dynamic fixed-point quantization are allocated to 4 bits and the integer digits are allocated to 4 bits; the scaling factor and zero point of the linear quantization are calculated based on the maximum and minimum values ​​of the latent vector table; the dynamic fixed-point quantization adopts a scaling factor of powers of 2; during inference, the intermediate convolution results are accumulated using 32-bit integers, shifted right by 4 bits, and then saturated to 8 bits.

4. The method of claim 1, wherein the embedded dot matrix font compression method is characterized by, The embedded dot matrix font compression method also includes a multi-font style expansion step: Freeze the latent vector table corresponding to the first font style that has been trained; A style encoder is constructed, which is a lightweight CNN structure containing 1-2 convolutional layers, for extracting style feature vectors from 50-200 character dot matrix samples of a second font style; The style feature vector is concatenated with the latent vector of the first font style, and input into the decoder. Only the last two convolutional layers of the decoder are fine-tuned to generate new decoder parameters corresponding to the second font style. The latent vector table of the first font style is combined with the new decoder parameters of the second font style to form the second font file.

5. An embedded dot matrix font compression system, characterized by, include: The storage unit is a non-volatile memory of the embedded device, used to store a character library file. The character library file contains an 8-bit linearly quantized latent vector table and 8-bit dynamically fixed-point quantized decoder parameters. The latent vector table contains an independent low-dimensional real-valued latent vector for each character in the target character set. The decoder is a lightweight convolutional neural network with no more than 200KB of parameters, capable of generating 24×24 dot matrix characters from the latent vectors. The processing unit, which is a microcontroller or embedded processor, is used to read the character library file, extract the latent vector corresponding to the target character from the latent vector table according to the user input, input the vector to the decoder, and perform forward inference through fixed-point arithmetic to generate the dot matrix of the target character.

6. The embedded bitmap font compression system of claim 5, wherein, The embedded dot-matrix font compression system also includes: A display unit is used to output the dot matrix; And a style extension unit, used to extract the style feature vector of the second font style through a style encoder, and input the style feature vector and the latent vector of the first font style into the decoder after channel concatenation. Only the last two convolutional layers of the decoder are fine-tuned to generate new decoder parameters corresponding to the second font style.

7. The embedded dot-matrix font compression system as described in claim 5, characterized in that, The forward inference of the decoder is based entirely on integer operations and does not rely on floating-point units.

8. A font file, characterized in that, The method described in any one of claims 1 to 4 is used to generate the product, comprising: An implicit vector table data segment is used to sequentially store N implicit vectors in byte alignment. The length of each implicit vector is 16 to 64 bytes, where the i-th implicit vector corresponds to the compressed dot matrix information of the i-th character in the target character set, and each byte is an 8-bit linear quantization value. A decoder parameter data segment is used to sequentially store all network weights of a lightweight convolutional neural network, the weights being stored in binary form as 8-bit dynamic fixed-point numbers, the organization of the network weights corresponding to a predefined decoder network structure capable of generating a 24×24 dot matrix from the latent vectors; The latent vector table data segment and the decoder parameter data segment are two independent binary data segments that can be directly read by the embedded processor without relying on any deep learning framework.

9. An embedded device, characterized in that, It includes: The font file as described in claim 8; A microcontroller or embedded processor is used to read the character library file and generate character dot matrices; The display driver unit is used to output the generated character dot matrix to the display screen.

10. The embedded device as claimed in claim 9, characterized in that, When performing forward inference of the decoder, the microcontroller or embedded processor is based entirely on integer operations and does not use floating-point units.

Citation Information

Patent Citations

  • Chinese character skeleton automatic synthesis method and large-scale Chinese character library automatic generation method

    CN110427989A

  • Chinese character font generation method based on compressed and excited GAN network

    CN112163401A