Dynamically adjustable grating font drawing method
By generating binary configuration files of raster fonts and extracting glyph data of similar font sizes, the problem of raster fonts lacks flexibility and large space occupancy is solved, and the effect of flexible scaling and efficient rendering is achieved.
Patent Information
- Application Number
- CN202411936842.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-12-26
AI Technical Summary
Due to the fixed pixel lattice definition, raster fonts lack flexibility, cannot support scaling well, and take up a lot of space.
By generating binary configuration files for raster fonts, fence data of similar font sizes is extracted according to application scenarios and actual use of font sizes, and draw them. Font size series and 3-bit compression methods are used to improve flexibility and reduce space consumption.
It realizes flexible scaling and efficient rendering of raster fonts, reduces the space occupied by configuration files and improves the effect of text display.
Smart Images

Figure CN119759477A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of aviation display software development, and in particular relates to a dynamically adjustable raster font drawing method. Background Art
[0002] Raster fonts, also known as bitmap fonts, are fixed-size character sets composed of pixels. Each character is defined as a pixel grid at a specific resolution, so raster fonts work best when displayed at that resolution. If you try to enlarge or reduce these fonts to a size different from their original design, the characters may become blurred or have rough edges because they are defined based on a fixed pixel matrix. Its main advantages are:
[0003] 1. Simple rendering. Since characters are stored in the form of pixels, the rendering speed is fast;
[0004] 2. Clarity. At the designed resolution, the fonts are very clear because each pixel is precisely defined.
[0005] The main disadvantages are:
[0006] 1. Lack of flexibility, cannot support scaling well, and different font files are required for texts of different sizes;
[0007] 2. Space occupied. Although a single character does not occupy much space, if multiple font sizes are required, the overall space occupied will increase. Summary of the invention
[0008] The purpose of the invention is to provide a dynamically adjustable raster font drawing method to solve the problem that raster fonts are not flexible enough and occupy a large space.
[0009] Technical solution:
[0010] A dynamically adjustable raster font drawing method is provided, comprising:
[0011] Generate a binary configuration file of a raster font according to the application scenario; the font size types of the raster font are smaller than the font size types that can actually be used;
[0012] Load the binary configuration file, extract the glyph data of the same or similar font size according to the actual font size used, and draw it.
[0013] Furthermore, the method further comprises:
[0014] Determine the file format of the vector font file for the font format;
[0015] Determine the minimum and maximum font sizes of the font format, as well as the encoding range of the characters used;
[0016] Determine a font size sequence according to the minimum font size and the maximum font size used, wherein the font size sequence includes the maximum font size, several intermediate font sizes, and the maximum font size;
[0017] The font rendering engine generates corresponding fill and outline dot matrix data for each character within the character encoding range according to all font sizes and various font styles in the character sequence, and compresses each dot matrix data using a 3-bit compression method. All compressed dot matrix data font styles are packaged according to the arrangement structure of font style and font size, combined with corresponding description information to generate a raster font binary configuration file.
[0018] Furthermore, the font size sequence is clipped according to the actual range.
[0019] Furthermore, the font sizes in the middle transition are arranged in 1.4 times manner.
[0020] Furthermore, the optimal font size sequences for different screen resolutions are shown in Table 1:
[0021] Table 1
[0022]
[0023] Furthermore, the binary configuration file is loaded, and the glyph data of the same or similar font size is extracted and drawn according to the actual font size, including:
[0024] Specify the binary raster font configuration file to be used, the corresponding font size, style and character encoding;
[0025] Determine whether there is a matching style. If there is a matching style, select the corresponding style; if there is no matching style, use the default style, that is, the regular style; select the loaded character dot matrix data according to the input font size, and the specific logic includes: when the input font size is not in the font size sequence of the binary raster font configuration file, sort the font size sequence, and select the first data larger than the input font size. If not found, use the data corresponding to the largest font size in the font size sequence; after obtaining the compressed dot matrix data of the character from the binary raster font configuration file, use a 3-bit compression algorithm to restore the data to dot matrix data; finally, calculate the scaling ratio according to the input font size and the actual font size used, and scale the dot matrix data as a whole and render it to the display screen.
[0026] Furthermore, the specific logic also includes:
[0027] When the input font size is in the font size sequence of the binary raster font configuration file, the data corresponding to the input font size is selected;
[0028] Beneficial effects of the present invention:
[0029] 1. Merge raster data of multiple font sizes. You only need to load the configuration file once to obtain dot matrix data of multiple font sizes, which is more flexible to use;
[0030] 2. Use font size series, which not only maintains the high efficiency of raster fonts but also takes into account the display effect when zooming;
[0031] 3. The dot matrix data is compressed to solve the problem of the configuration file taking up too much space when using multiple font sizes. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 A process diagram for generating a raster font binary configuration file for a dynamically adjustable raster font rendering method;
[0033] Figure 2 An example diagram of the internal format of a raster font binary configuration file for a dynamically adjustable raster font drawing method;
[0034] Figure 3 A raster font drawing flow chart for a dynamically adjustable raster font drawing method. DETAILED DESCRIPTION
[0035] The present invention provides a method for drawing a raster font that can be adjusted dynamically. Figure 3 As shown, including:
[0036] Step 1: Generate a raster font binary configuration file based on the application scenario;
[0037] Step 2: Load the binary configuration file, extract the corresponding glyph data according to the font size and draw it;
[0038] Among them, in step 1, a raster font binary configuration file is generated according to the application scenario, specifically including:
[0039] The user determines the vector font file of the required font format according to the application scenario. Typical vector font file formats are *.ttf, *.ttc, *.otf. Each font usually has 4 different styles, including regular, italic, bold, and bold italic. When determining the font, you also need to determine the font style, at least one style; then you need to determine the minimum and maximum font sizes of the font, as well as the encoding range of the characters used. Typical encoding ranges include the national standard first-level font library and the national standard second-level font library.
[0040] Determine the font size sequence based on the minimum and maximum font sizes used. To ensure smooth font scaling, it is recommended that the font size sequence be arranged in 1.4 times order. For example, when the minimum font size used is 9 and the maximum font size is 48, the font size sequence is: 9, 12, 18, 24, 36, 48. This sequence is the best sequence, which can ensure that all font sizes in the range of [9, 48] have the best effect. Of course, the font size sequence can also be tailored according to the actual range. The actual display effect will be related to the screen resolution of the display screen. The following table provides the best font size sequence for different screen resolutions as shown in Table 1:
[0041] Table 1
[0042]
[0043] After determining the font, font style, character encoding range and font size sequence to be used, the font rendering engine (such as FreeType) generates corresponding fill and outline dot matrix data for each character in the character encoding range according to all font sizes and various font styles in the character sequence, and uses a 3-bit compression method to compress each dot matrix data. All the compressed dot matrix data font styles are packaged according to the arrangement structure of font style and font size, combined with the corresponding description information to generate a raster font binary configuration file. The generation process is as follows: Figure 1 As shown in the figure, the format of the raster font binary configuration file is as follows Figure 2 shown.
[0044] Among them, in step 2, the binary configuration file is loaded, and the corresponding glyph data is extracted and drawn according to the font size, which specifically includes:
[0045] When drawing specific raster characters, it is necessary to specify the binary raster font configuration file used, the corresponding font size, style and character encoding. The specific process is to first determine whether the binary raster font configuration file has been loaded. If not, load the binary raster font configuration file. After successful loading, determine whether there is a matching style. If there is a matching style, select the corresponding style; if there is no matching style, use the default style, that is, the regular style; select the loaded character dot matrix data according to the input font size. The specific logic is: when the input font size is in the font size sequence of the binary raster font configuration file, select the data corresponding to the input font size; when the input font size is not in the font size sequence of the binary raster font configuration file, sort the font size sequence and select the first data larger than the input font size. If not found, use the data corresponding to the largest font size in the font size sequence; after obtaining the compressed dot matrix data of the character from the binary raster font configuration file, use a 3-bit compression algorithm to restore the data to dot matrix data; finally, calculate the scaling ratio according to the input font size and the actual font size used, and scale the dot matrix data as a whole and render it to the display screen.
Claims
1. A dynamically adjustable raster font drawing method, characterized in that: include: Generate binary configuration files of raster fonts according to application scenarios; The font size range of raster fonts is smaller than the actual font size range that can be used; Load the binary configuration file, extract the glyph data of the same or closest font size according to the actual font size, and draw it.
2. The method according to claim 1, characterized in that The method further comprises: Determine the file format of the vector font file for the font format; Determine the minimum and maximum font sizes of the font format, as well as the encoding range of the characters used; Determine a font size sequence according to the minimum font size and the maximum font size used, wherein the font size sequence includes the maximum font size, several intermediate font sizes, and the maximum font size; The font rendering engine generates corresponding fill and outline dot matrix data for each character within the character encoding range according to all font sizes and various font styles in the character sequence, and compresses each dot matrix data using a 3-bit compression method. All compressed dot matrix data font styles are packaged according to the arrangement structure of font style and font size, combined with corresponding description information to generate a raster font binary configuration file.
3. The method according to claim 2, characterized in that The font size sequence is clipped according to the actual range.
4. The method according to claim 2, characterized in that: The font sizes in the middle transition are arranged in 1.4 times manner.
5. The method according to claim 2, characterized in that: The optimal font size sequence for different screen resolutions is shown in Table 1: Table 1 6. The method according to claim 5, characterized in that Load the binary configuration file, extract the glyph data of the same or closest font size according to the actual font size, and draw it, including: Specify the binary raster font configuration file to be used, the corresponding font size, style and character encoding; Determine whether there is a matching style. If there is a matching style, select the corresponding style; if there is no matching style, use the default style, that is, the regular style; select the loaded character dot matrix data according to the input font size, and the specific logic includes: when the input font size is not in the font size sequence of the binary raster font configuration file, sort the font size sequence, and select the first data larger than the input font size. If not found, use the data corresponding to the largest font size in the font size sequence; after obtaining the compressed dot matrix data of the character from the binary raster font configuration file, use a 3-bit compression algorithm to restore the data to dot matrix data; finally, calculate the scaling ratio according to the input font size and the actual font size used, and scale the dot matrix data as a whole and render it to the display screen.
7. The method according to claim 6, characterized in that The specific logic also includes: When the input font size is in the font size sequence of the binary raster font configuration file, the data corresponding to the input font size is selected.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer program is executed by a processor to implement the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
A three-dimensional character stroking drawing method
CN108986193A
Character display method and device, equipment and storage medium
CN114791843A
Method and device for font rendering, embedded equipment and storage medium
CN117707669A
Handwritten character font library
US20130181995A1