BIOS (Basic Input / Output System) word stock updating method and host equipment
By traversing the .uni file, obtaining Chinese characters in BIOS Setup, and using the lv_font_conv tool to generate a .c-format font library file, solving the problem of unfriendly display of LVGL in Chinese, realizing the automatic update of the BIOS Setup Chinese font library and reducing the file size Small.
Patent Information
- Application Number
- CN202411536085.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-30
- Publication Date
- 2025-02-18
AI Technical Summary
The Chinese display of LVGL is not friendly because its own CJK font library only contains a small number of Chinese fonts, and is mainly traditional, which cannot meet the needs of Chinese characters that are widely used in the BIOS Setup interface.
Iterate through the .uni file through the script, get the Chinese characters used in the BIOS Setup, and use the lv_font_conv tool to generate the font library file in the .c format, replacing the font library file in the LVGL source code.
The LVGL Chinese font library file size is reduced, the program operation efficiency and storage space utilization is improved, and the BIOS Setup Chinese font library is automatically updated.
Smart Images

Figure CN119473413A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and more particularly to a method for updating a BIOS font library and a host device. Background Art
[0002] LVGL: Light and Versatile Graphics Library, lightweight general graphics library;
[0003] BIOS: Basic Input Output System, basic input output system;
[0004] UEFI: Unified Extensible Firmware Interface, unified extensible firmware interface;
[0005] HII: Human Interface Infrastructure, human-computer interface.
[0006] BIOS (Basic Input Output System) is a set of programs fixed on a ROM (Read-Only Memory) chip on the computer's motherboard. It stores the most important basic input and output programs of the computer, the self-test program after powering on, and the system self-starting program. It can read and write specific information of system settings from CMOS (Complementary Metal Oxide Semiconductor). Its main function is to provide the most basic and direct hardware settings and control for the computer.
[0007] The BIOS Setup interface is a user interface provided by the firmware program embedded on the computer motherboard, which is used to manage and configure the computer's hardware settings. Usually, you can enter the BIOS Setup interface by pressing a specific key combination (such as the Delete key, the Esc key, etc.) when the computer starts. Its appearance can be a text-based menu structure or a modern graphical interface that displays various setting options in the form of graphics or text.
[0008] LVGL (Light and Versatile Graphics Library) is a new GUI system framework with the advantages of small code size and easy user interface development. As an open source embedded graphics library, LVGL is known for its lightweight, feature-rich, flexible, and portable features, which can help developers quickly and easily create beautiful and feature-rich graphical user interfaces.
[0009] When developing the BIOS Setup interface based on LVGL, we found that the Chinese display of LVGL is not friendly. Because the CJK font library that comes with LVGL only contains a small number of Chinese fonts, and mainly traditional Chinese characters. The BIOS Setup interface usually uses a large number of Chinese characters, so the CJK font library that comes with LVGL cannot meet our needs. In order for LVGL to better support Chinese display, we need to add a Chinese font library.
[0010] LVGL currently officially supports two font libraries, one is a font library in the form of .c source files, and the other is a font library in .bin format.
[0011] .c format font libraries can be directly compiled into the program and read and displayed using the LVGL native interface. In the .c format font library, all data is defined using the LVGL standard data structure, so the program can directly read these font libraries by addressing, without any other operations, and the overhead is low.
[0012] The .bin format font library uses a data structure that is different from the LVGL standard structure definition for storage. Although this can reduce the file size, LVGL cannot directly read the .bin format font library. LVGL uses the loading function to convert the .bin format file into a data structure in the same format as .c in memory, and uses the .c format interface for reading and displaying. This method adds the operations of loading .bin files and converting data structures, which has a high overhead.
[0013] Based on the characteristics of the above two font libraries and taking into account the program's running performance, the BIOS Setup program chooses to use the .c format font library.
[0014] However, there are many Chinese characters, and there are 6773 commonly used Chinese characters. The character library generated in .c format usually has a data size of several M, which will not only greatly reduce the running efficiency of the program, but also increase the storage space occupied by the program. Summary of the invention
[0015] In order to overcome the problems existing in the related art, this specification provides a BIOS font library update method and a host device.
[0016] According to a first aspect of an embodiment of this specification, a method for updating a BIOS font library is provided, the method comprising:
[0017] Use scripts to traverse .uni files and obtain Chinese characters used in BIOS Setup;
[0018] Generate a font library file in .c format according to the obtained Chinese characters;
[0019] Use the generated .c format font library file to replace the font library file in the LVGL source code.
[0020] The method of traversing the .uni file through a script to obtain Chinese characters used in BIOS Setup includes:
[0021] Use Python script to traverse the .uni file and obtain the Chinese characters used in BIOS Setup.
[0022] The method of traversing the .uni file through a Python script to obtain Chinese characters used in BIOS Setup includes:
[0023] Use Python script to traverse the .uni file and write the Chinese characters obtained after traversal into chinese_chars.txt.
[0024] The step of writing the Chinese characters obtained after traversal into chinese_chars.txt includes:
[0025] Use the regular expression [\u4e00-\u9fff] to extract Chinese characters and write the collected Chinese characters into the file chinese_chars.txt.
[0026] The step of generating a font library file in .c format according to the acquired Chinese characters includes:
[0027] Generate a font library file in .c format using the lv_font_conv tool.
[0028] It can be seen from this method that by traversing the .uni file, the Chinese characters used by BIOS Setup are obtained, thereby reducing the file size of the LVGL Chinese font library. At the same time, a Python script is also implemented to automatically update the BIOS Setup Chinese font library based on LVGL.
[0029] According to a second aspect of an embodiment of this specification, a host device is provided, wherein the host device runs a BIOS, and the host device includes:
[0030] The acquisition module is used to traverse the .uni file through the script and obtain the Chinese characters used in BIOS Setup;
[0031] The first processing module is used to generate a font library file in .c format according to the acquired Chinese characters;
[0032] The second processing module is used to replace the font library file in the LVGL source code with the generated .c format font library file.
[0033] The acquisition module is specifically used to traverse the .uni file through a Python script to obtain the Chinese characters used in BIOS Setup.
[0034] The acquisition module is specifically used to use a Python script to traverse the .uni file and write the Chinese characters obtained after the traversal into chinese_chars.txt.
[0035] The acquisition module is specifically used to extract Chinese characters using the regular expression [\u4e00-\u9fff] and write the collected Chinese characters into the file chinese_chars.txt.
[0036] The first processing module is specifically used to generate a font library file in .c format through the lv_font_conv tool.
[0037] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present specification. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the specification and, together with the description, serve to explain the principles of the specification.
[0039] Figure 1 This is a flowchart of a method for updating a BIOS font library according to an exemplary embodiment of this specification.
[0040] Figure 2 It is a schematic diagram of a user interface framework shown in this specification according to an exemplary embodiment.
[0041] Figure 3 This is a schematic diagram of an interface for generating a font library in .c format by using the lv_font_conv tool according to an exemplary embodiment of this specification. DETAILED DESCRIPTION
[0042] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with this specification. Instead, they are merely examples of devices and methods consistent with some aspects of this specification as detailed in the appended claims.
[0043] The terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit this specification. The singular forms "a", "the" and "the" used in this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0044] It should be understood that although the terms first, second, third, etc. may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0045] In order to solve the technical problems existing in the prior art, the present disclosure provides a method for updating a BIOS font library, such as Figure 1 As shown, the method includes:
[0046] S101 uses a script to traverse the .uni file and obtain the Chinese characters used in BIOS Setup;
[0047] S102 generates a font library file in .c format according to the acquired Chinese characters;
[0048] S103 uses the generated .c format font library file to replace the font library file in the LVGL source code.
[0049] In this embodiment, UEFI (Unified Extensible Firmware Interface) HII (Human Interface Infrastructure) defines a basic framework for managing user interfaces. The HII database mainly provides interfaces for users to install, uninstall, and use various resources such as strings, fonts, and images.
[0050] like Figure 2 As shown, the strings are described in the .uni file. The strings store all characters in UCS-2 encoding for use by HII. And the strings support multiple languages.
[0051] In step S101, the Chinese characters used in the BIOS Setup (i.e., the Chinese characters required for configuring the BIOS Setup) can be obtained by traversing the.uni files through a Python script. Specifically, a Python script can be used to automatically collect Chinese characters. The Python script is named CollectChinese.py. This script recursively traverses all.uni files in the folder, uses the regular expression [\u4e00-\u9fff] to extract Chinese characters, and writes the collected Chinese characters into the file chinese_chars.txt. Python will automatically remove duplicate characters.
[0052] In step S102, a font library file in.c format can be generated through the lv_font_conv tool.
[0053] As Figure 3 shown, the --bpp parameter specifies how many font pixels are used for 1 display pixel in the generated font. When this parameter is greater than 1, it means grayscale anti-aliasing is enabled, and the edges of the font will be clearer, but it will occupy more space.
[0054] The --size parameter specifies the height of the generated font, which can be selected according to needs.
[0055] The --format parameter specifies the format of the generated font. There are two formats available: lvgl and bin, corresponding to generating fonts in.c format and.bin format respectively.
[0056] The --font parameter is used to specify the font file to be used. All subsequent --range parameters and --symbols parameters only take effect for this font until the next --font parameter appears.
[0057] The --range parameter is used to specify the Unicode character range to be added to the font, and it can be reused to specify multiple ranges.
[0058] The --symbols parameter is used to directly specify the characters to be added, such as "一二三四五".
[0059] The lv_font_conv tool supports fonts in.TTF and.WOFF formats.
[0060] Taking the Song typeface as an example, assume the name of the font file is songti.ttf, the size of the font to be generated is 12, the name of the font file to be generated is lv_font_songti_12.c, and the characters to be generated are 一二三四五.
[0061] Then, executing the following command in the terminal can generate a font library file in.c format:
[0062] lv_font_conv --bpp 4 --size 12 -o lv_font_songti_12.c --format lvgl --fontsongti.ttf --symbols one two three four five.
[0063] Use Python script to automatically generate font library files. The Python script is named GenerateFontFile.py. The script reads Chinese characters in the file chinese_chars.txt, and then constructs the lv_font_conv command with these Chinese characters as the parameter of —symbols. Finally, the lv_font_conv command is executed in the terminal to generate the lv_font_songti_12.c file.
[0064] In step S103, the path where the LVGL Chinese font library file is located is: Library\LVGL\src\font\lv_font_songti_12.c.
[0065] Use the Python script to automatically replace the lv_font_songti_12.c file in the LVGL code. The Python script is named ReplaceFontFile.py. This script will replace the file in the above path with the Chinese font library file lv_font_songti_12.c generated in the previous step.
[0066] When compiling the BIOS version, execute the above three Python scripts in sequence to automatically update the LVGL-based BIOS Setup Chinese font library.
[0067] It can be seen from the above embodiments that by traversing the .uni file, the Chinese characters used by BIOS Setup are obtained, thereby reducing the file size of the LVGL Chinese font library. At the same time, the Python script is also implemented to realize the automatic update of the BIOS Setup Chinese font library based on LVGL.
[0068] Based on the above method embodiments, the present disclosure also provides a host device, wherein the host device runs a BIOS, and the host device includes:
[0069] The acquisition module is used to traverse the .uni file through the script and obtain the Chinese characters used in BIOS Setup;
[0070] The first processing module is used to generate a font library file in .c format according to the acquired Chinese characters;
[0071] The second processing module is used to replace the font library file in the LVGL source code with the generated .c format font library file.
[0072] The acquisition module is specifically used to traverse the .uni file through a Python script to obtain the Chinese characters used in BIOS Setup.
[0073] The acquisition module is specifically used to use a Python script to traverse the .uni file and write the Chinese characters obtained after the traversal into chinese_chars.txt.
[0074] The acquisition module is specifically used to extract Chinese characters using the regular expression [\u4e00-\u9fff] and write the collected Chinese characters into the file chinese_chars.txt.
[0075] The first processing module is specifically used to generate a font library file in .c format through the lv_font_conv tool.
[0076] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this specification. A person of ordinary skill in the art can understand and implement it without paying creative labor.
[0077] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0078] Those skilled in the art will readily appreciate other embodiments of the specification after considering the specification and practicing the invention claimed herein. The specification is intended to cover any variations, uses or adaptations of the specification that follow the general principles of the specification and include common knowledge or customary techniques in the art that are not claimed in the specification. The specification and examples are to be considered exemplary only, and the true scope and spirit of the specification are indicated by the following claims.
[0079] It should be understood that the present description is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.
[0080] The above description is only a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification should be included in the scope of protection of this specification.
Claims
1. A method for updating a BIOS font library, characterized in that: The method comprises: Use scripts to traverse .uni files and obtain Chinese characters used in BIOS Setup; Generate a font library file in .c format according to the obtained Chinese characters; Use the generated .c format font library file to replace the font library file in the LVGL source code.
2. The method according to claim 1, characterized in that: The script traverses the .uni file to obtain the Chinese characters used in BIOSSetup, including: Use Python script to traverse the .uni file and obtain the Chinese characters used in BIOS Setup.
3. The method according to claim 2, characterized in that The Python script is used to traverse the .uni file to obtain the Chinese characters used in BIOS Setup, including: Use Python script to traverse the .uni file and write the Chinese characters obtained after traversal into chinese_chars.txt.
4. The method according to claim 3, characterized in that The Chinese characters obtained after traversal are written into chinese_chars.txt, including: Use the regular expression [\u4e00-\u9fff] to extract Chinese characters and write the collected Chinese characters into the file chinese_chars.txt.
5. The method according to claim 1, characterized in that: The step of generating a font library file in .c format according to the obtained Chinese characters includes: Generate a font library file in .c format using the lv_font_conv tool.
6. A host device, characterized in that: The host device runs a BIOS, and the host device includes: The acquisition module is used to traverse the .uni file through the script and obtain the Chinese characters used in BIOS Setup; The first processing module is used to generate a font library file in .c format according to the acquired Chinese characters; The second processing module is used to replace the font library file in the LVGL source code with the generated .c format font library file.
7. The host device according to claim 6, characterized in that: The acquisition module is specifically used to traverse the .uni file through a Python script to obtain the Chinese characters used in BIOS Setup.
8. The host device according to claim 7, characterized in that: The acquisition module is specifically used to use a Python script to traverse the .uni file and write the Chinese characters obtained after the traversal into chinese_chars.txt.
9. The host device according to claim 7, characterized in that: The acquisition module is specifically used to extract Chinese characters using the regular expression [\u4e00-\u9fff] and write the collected Chinese characters into the file chinese_chars.txt.
10. The host device according to claim 6, characterized in that: The first processing module is specifically used to generate a font library file in .c format through the lv_font_conv tool.