A dynamically adjustable raster font drawing method

By generating binary configuration files for raster fonts and compressing bitmap data, the issues of flexibility and space occupation when displaying text of different sizes with raster fonts are resolved, achieving efficient drawing and display effects for various font sizes.

CN119759477BActive Publication Date: 2025-12-02CHINESE AERONAUTICAL RADIO ELECTRONICS RES INST
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411936842.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-12-02
Estimated Expiration
2044-12-26

AI Technical Summary

Technical Problem

Raster fonts lack flexibility and take up a lot of space when displaying text of different sizes, and cannot meet the needs of various text sizes.

Method used

By generating a binary configuration file for the raster font, combining it with a vector font file, generating and compressing bitmap data, and extracting similar or identical glyph data according to the actual font size used for drawing, it supports flexible adjustment of multiple font sizes and scaling during display.

Benefits of technology

It achieves flexibility and efficient rendering of raster fonts when displaying text of different sizes, reduces the space occupied by configuration files, and maintains high rendering speed and clarity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119759477B_ABST
    Figure CN119759477B_ABST
Patent Text Reader

Abstract

This invention belongs to the field of aviation display software development, and specifically relates to a dynamically adjustable raster font drawing method. It includes: generating a binary configuration file for the raster font based on the application scenario; the raster font has fewer font sizes than the actual usable font sizes; loading the binary configuration file; extracting glyph data of the same or closest font sizes according to the actual font sizes used; and drawing the fonts.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of aviation display software development, and specifically relates to a method for dynamically adjustable raster font drawing. Background Technology

[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 display best at that resolution. If you try to enlarge or shrink these fonts to a size different from their original design, the characters may become blurry or have rough edges because they are defined based on a fixed pixel grid. Their main advantages are:

[0003] 1. Rendering is simple because characters are stored in pixels, so the rendering speed is relatively fast;

[0004] 2. Clarity: At the design resolution, the font is very clear because each pixel is precisely defined.

[0005] The main drawbacks are:

[0006] 1. Lacks flexibility and does not support scaling well; different font files are required for different text sizes.

[0007] 2. Space usage: Although a single character does not take up much space, if multiple font sizes are required, the overall space usage will increase. Summary of the Invention

[0008] The objective of this invention is to provide a dynamically adjustable raster font drawing method to solve the problems of raster fonts being inflexible and occupying a large amount of space.

[0009] Technical solution:

[0010] A method for dynamically adjustable raster font drawing is provided, including:

[0011] Generate a binary configuration file for the raster font based on the application scenario; the raster font has fewer font sizes than the actual usable font sizes.

[0012] Load the binary configuration file, extract the glyph data of the same or similar font sizes according to the actual font size used, and draw them.

[0013] Furthermore, the method also includes:

[0014] The file format of a vector font file that determines the font format;

[0015] Determine the minimum and maximum font sizes for using this font format, as well as the encoding range of the characters used;

[0016] The font size sequence is determined based on the minimum and maximum font sizes used. The font size sequence includes the maximum font size, several intermediate font sizes, and the maximum font size again.

[0017] The font rendering engine generates two types of dot matrix data for each character within the character's encoding range, namely fill and outline, according to all font sizes and various font styles in the character sequence. Each dot matrix data is then compressed using a 3-bit compression method. All the compressed dot matrix data font styles are then packaged according to the arrangement structure of font style and font size, and combined with the corresponding description information to generate a raster font binary configuration file.

[0018] Furthermore, the font size sequence is trimmed according to the actual range.

[0019] Furthermore, the font sizes in the intermediate transition are arranged in a 1.4x ratio.

[0020] Furthermore, the optimal font size sequence for different screen resolutions is shown in Table 1:

[0021] Table 1

[0022]

[0023] Furthermore, the binary configuration file is loaded, and glyph data of the same or similar font sizes are extracted and drawn according to the actual font size used, including:

[0024] Specify the binary raster font configuration file to use, the corresponding font size, style, and character encoding;

[0025] The system checks if a matching style exists. If a matching style is found, it selects the corresponding style; otherwise, it uses the default style, i.e., the regular style. It selects the loaded character dot matrix data based on the input font size. Specifically, when the input font size is not in the font size sequence of the binary raster font configuration file, the font size sequence is sorted, and the first data larger than the input font size is selected. If no match is found, the data corresponding to the largest font size in the sequence is used. After obtaining the compressed dot matrix data of the character from the binary raster font configuration file, a 3-bit compression algorithm is used to restore the data to dot matrix data. Finally, the scaling ratio is calculated based on the input font size and the actual font size used, and the dot matrix data is scaled as a whole before being rendered 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, select the data corresponding to the input font size;

[0028] The beneficial effects of this invention are:

[0029] 1. By merging raster data of multiple font sizes, only the configuration file needs to be loaded once to obtain dot matrix data of multiple different font sizes, making it more flexible to use;

[0030] 2. The font size series is adopted, which maintains the efficiency of raster fonts while taking into account the display effect when scaling.

[0031] 3. The dot matrix data has been compressed, which solves the problem of excessive space occupied by configuration files when using multiple font sizes. Attached Figure Description

[0032] Figure 1 A diagram illustrating the process of 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, which is a method for dynamically adjusting raster font rendering.

[0034] Figure 3 This is a flowchart illustrating a dynamically adjustable raster font drawing method. Detailed Implementation

[0035] This invention provides a dynamically adjustable raster font drawing method, such as... Figure 3 As shown, it includes:

[0036] Step 1: Generate a raster font binary configuration file according to 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] In step 1, generating a raster font binary configuration file based on the application scenario specifically includes:

[0039] Users determine the required vector font file format based on the application scenario. Typical vector font file formats include *.ttf, *.ttc, and *.otf. Each font usually has four different styles, including regular, italic, bold, and bold italic. When determining the font, the font style must also be determined, at least one style must be determined. Then, the minimum and maximum font sizes to be used, as well as the encoding range of the characters to be used, need to be determined. Typical encoding ranges include GB1 and GB2 character sets.

[0040] The font size sequence is determined based on the minimum and maximum font sizes used. To ensure smooth font scaling, it is recommended that the font size sequences be arranged in a 1.4x ratio. For example, when the minimum font size is 9 and the maximum font size is 48, the font size sequence would be: 9, 12, 18, 24, 36, 48. This sequence is the optimal sequence, ensuring the best effect for all font sizes within the range [9, 48]. Of course, the font size sequence can also be cropped 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 optimal 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, a font rendering engine (such as FreeType) generates two types of bitmap data—fill and outline—for each character within the character encoding range, based on all font sizes and styles within the character sequence. Each bitmap data is then compressed using a 3-bit compression method. All the compressed bitmap data are then packaged according to the font style and size arrangement, combined with corresponding description information, to generate a raster font binary configuration file. The generation process is as follows: Figure 1 As shown, an example of the format inside the raster font binary configuration file is as follows: Figure 2 As shown.

[0044] In step 2, the binary configuration file is loaded, and the corresponding glyph data is extracted and drawn according to the font size. This 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 as follows: First, it is determined whether the binary raster font configuration file has been loaded. If not, the binary raster font configuration file is loaded. After successful loading, it is determined whether there is a matching style. If a matching style is found, the corresponding style is selected; otherwise, the default style, i.e., the regular style, is used. The character bitmap data to be loaded is selected based on the input font size. The specific logic is as follows: 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; when the input font size is not in the font size sequence of the binary raster font configuration file, the font size sequence is sorted, and the first data greater than the input font size is selected. If not found, the data corresponding to the largest font size in the font size sequence is used. After obtaining the compressed bitmap data of the character from the binary raster font configuration file, a 3-bit compression algorithm is used to restore the data to bitmap data. Finally, the scaling ratio is calculated based on the input font size and the actual font size used, and the bitmap data is scaled as a whole and rendered to the display screen.

Claims

1. A method for dynamically adjustable raster font drawing, characterized in that, include: A binary configuration file for the raster font is generated based on the application scenario; the raster font has fewer font sizes than the actual usable font sizes, specifically: The file format of a vector font file that determines the font format; Determine the minimum and maximum font sizes for using this font format, as well as the encoding range of the characters used; The font size sequence is determined based on the minimum and maximum font sizes used. The font size sequence includes the maximum font size, several intermediate font sizes, and the maximum font size again. The font rendering engine generates two types of dot matrix data for each character within the character encoding range, namely fill and outline, according to all font sizes and various font styles in the character sequence. Each dot matrix data is compressed using a 3-bit compression method. All the font styles of the compressed dot matrix data are packaged according to the arrangement structure of font style and font size, and then combined with the corresponding description information to generate a raster font binary configuration file. Load the binary configuration file, extract the glyph data of the same or closest font size according to the actual font size used, and draw them. Specifically: Specify the binary raster font configuration file to use, the corresponding font size, style, and character encoding; Determine if there is a matching style; if so, select the corresponding style. If no matching style is found, the default style, i.e., the regular style, will be used. The logic for selecting the loaded character dot matrix data based on the input font size includes: when the input font size is not in the font size sequence of the binary raster font configuration file, the font size sequence is sorted and the first data larger than the input font size is selected; if not found, the data corresponding to the largest font size in the font size sequence is used. After obtaining the compressed dot matrix data of the characters from the binary raster font configuration file, a 3-bit compression algorithm is used to restore the data to dot matrix data; finally, the scaling ratio is calculated based on the input font size and the actual font size used, and the dot matrix data is scaled as a whole and rendered to the display screen.

2. The method according to claim 1, characterized in that, The font size sequence is trimmed according to the actual range.

3. The method according to claim 1, characterized in that, The font sizes in the middle transition are arranged in a 1.4x ratio.

4. The method according to claim 1, characterized in that, The optimal font size sequence for different screen resolutions is as follows: When the screen resolution is 72 ppi, the optimal font size sequence is: 18, 24, 36, 72, 48, 96; When the screen resolution is 96 ppi, the optimal font size sequence is: 9, 12, 18, 24, 36, 48; When the screen resolution is 144 ppi, the optimal font size sequence is: 7, 9, 14, 19, 28, 38; When the screen resolution is 192 ppi, the optimal font size sequence is: 6, 8, 11, 14, 22, 28.

5. The method according to claim 1, 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, select the data corresponding to the input font size.

6. 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 as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Character display method and device, equipment and storage medium

    CN114791843A

  • Method and device for font rendering, embedded equipment and storage medium

    CN117707669A