Method for recording dot matrix font information and method for generating dot matrix characters

By storing the basic information of the dot matrix font and the coding area information in the file header area to generate dot matrix characters, the problem of font files occupying a large amount of resources in the prior art is solved, and efficient resource utilization and information integrity are achieved.

CN112395828BActive Publication Date: 2024-09-27SHEN ZHEN GENITOP RES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011506729.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-18
Publication Date
2024-09-27
Estimated Expiration
2040-12-18

AI Technical Summary

Technical Problem

Existing font file formats (such as TTF, TTC and BDF) occupy a large amount of system resources in embedded microcontroller systems with limited resources, resulting in reduced hardware performance. In addition, existing technology compresses files by omitting information, resulting in uneven font formats and information. Incomplete question.

Method used

The file header area is used to store the width, height, pixel arrangement and coding area information of the dot matrix font. It records more font information with less data, generates dot matrix characters, reduces storage space occupation and quickly locates character data.

Benefits of technology

It effectively compresses the storage space of font files, reduces system resource overhead, ensures the integrity of font information, and improves hardware performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112395828B
    Figure CN112395828B
Patent Text Reader

Abstract

The present invention discloses a method for recording dot matrix font information and a method for generating dot matrix characters. The method for recording dot matrix font information comprises the steps of: setting a file header area and a dot matrix data area for a dot matrix font file; storing the width, height and pixel arrangement of the dot matrix characters contained in the dot matrix font in the file header area. The present invention greatly reduces the data volume of the font file while describing each character.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a character library file, and in particular to a method for recording more character library information by using a small amount of data. Background Art

[0002] There are many types of existing fonts. For example, fonts for computers and mobile terminals usually use font file formats such as TTF and TTC jointly launched by Microsoft and Apple. These font file formats are rich in content, but require more system resources. If TTF or TTC format font files are forcibly run in an embedded single-chip system with few resources and no graphics card hardware acceleration, it will cause problems such as excessive resource overhead and reduced hardware performance of the device.

[0003] In order to solve this problem, there is also a font file based on the BDF format in the prior art. The BDF format file is now widely used in various embedded systems. Although the BDF format font provides a lot of convenience to many users in certain situations, the BDF format is for marking text information. Each character has data such as the width, height, and encoding of the character. When there are a large number of characters, the BDF format file will be bloated and lengthy. For example, the marking information in the conventional BDF format is mainly divided into two areas, and each character needs to contain the following two areas:

[0004] 1) Character header area: mainly marks the BDF file version number, basic file information, character structure position information (including width, height, x / y starting position, etc.), and the total number of characters in the file;

[0005] 2) Character area: records the hexadecimal and decimal character codes of the current character, the unit value of the pixel of the printer device, the range of values ​​used to display the pixel in the x and y directions, and finally stores the current character dot matrix array to record pixel information such as the character shape.

[0006] Because BDF records various information of each character in detail, the amount of data of the attached characters will increase as the number of characters in the file increases. For a microcontroller system with limited hardware and software resources, this data format not only consumes a lot of resources to read the font file, but also significantly occupies the MCU working time.

[0007] In order to avoid this situation, the existing dot matrix font information does not mark the characteristic information of the text such as encoding, size, etc. to avoid the bloated and lengthy font files, but at the same time it will cause problems such as uneven font formats and incomplete information.

[0008] Therefore, how to further reduce the usage of font resources and reduce the cost of equipment hardware while ensuring that the font information is relatively comprehensive is a technical problem that needs to be solved urgently in the industry. Summary of the invention

[0009] In order to solve the technical problem in the prior art that more system resources are occupied while ensuring that the character library information is relatively comprehensive, the present invention proposes a method for recording dot matrix character library information and a method for generating dot matrix characters.

[0010] The method for recording dot matrix font information proposed by the present invention comprises the steps of:

[0011] Set a file header area and a dot matrix data area for the dot matrix font file;

[0012] The width, height and pixel arrangement of the dot matrix characters contained in the dot matrix font library are stored in the file header area.

[0013] Furthermore, the file header area uses 5 bytes to store whether the width and height of the dot matrix character are equal, width information, height information, pixel arrangement method, and character set.

[0014] Furthermore, the width information and height information store the bytes occupied by the character width and height, and are converted into multiples of 8. When the occupied bytes are less than a multiple of 8, they are rounded to a multiple of 8.

[0015] Furthermore, the file header area also stores the starting address of the dot matrix characters contained in the dot matrix font library, the number of coding areas and coding area information.

[0016] Furthermore, the file header area uses at least 2 bytes to store the number of the encoding areas.

[0017] Furthermore, the file header area uses at least 5 bytes to record the coding area information of each coding area, and the 5 bytes respectively store the high byte value of the coding area, the low byte starting byte of the coding area, the low byte ending byte of the coding area, and the number of characters in the coding area.

[0018] The method for generating dot matrix characters proposed by the present invention adopts the method for recording dot matrix character library information described in the above technical solution to store dot matrix characters;

[0019] By reading the file header area of ​​the dot matrix font file, the description information of each dot matrix character and the number and information of the coding area are obtained;

[0020] Find the dot matrix character data according to the description information, the number of coding areas and the coding area information;

[0021] A dot matrix character is generated according to the dot matrix character data.

[0022] Further, the range of the encoding area where the character is located is determined according to the high-byte value in the encoding area information, and then the specific position of the encoding area is obtained according to the low-byte start byte and end byte of the encoding area.

[0023] The present invention stores the relevant information of the characters of the font file in a file header area of ​​the font file, such as setting the font character width, height and dot matrix data arrangement mode, etc., thereby avoiding the problem that the font file needs to describe each character one by one, saving storage space; further, in this file header area, the high byte code and low byte code range values ​​in each encoding information are also stored, and the encoding value index of each character in the encoding area is established, so that the corresponding character data can be quickly found. Therefore, the present invention realizes that in addition to compressing the resource space from the information of each character to a great extent, the character data of the dot matrix area of ​​the classified character is located according to the brief encoding area information through the division of functional areas; through the current file header structure information storage method, the storage space of the font file is compressed to a great extent and the encoding value of each character under the current character set is effectively indexed or recorded. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] The present invention is described in detail below with reference to the embodiments and accompanying drawings, wherein:

[0025] Figure 1 It is a schematic diagram of the representation structure of the dot matrix font information of the present invention. DETAILED DESCRIPTION

[0026] In order to make the technical problems, technical solutions and beneficial effects to be solved by the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0027] Thus, a feature indicated in this specification will be used to illustrate one of the features of an embodiment of the present invention, rather than implying that each embodiment of the present invention must have the described feature. In addition, it should be noted that this specification describes many features. Although some features can be combined together to illustrate possible system designs, these features can also be used in other combinations that are not explicitly described. Thus, unless otherwise stated, the described combinations are not intended to be limiting.

[0028] The principle of the present invention is described in detail below with reference to the accompanying drawings and embodiments.

[0029] like Figure 1 As shown, the method for recording dot matrix font information of the present invention as a whole includes a file header area and a dot matrix data area.

[0030] The box marked as S101 in the figure represents the overall framework of the font file currently containing the character set.

[0031] The box marked as S102 in the figure represents the file header area, which is used to store basic information of the font library. By storing the width, height and pixel arrangement of the dot matrix characters contained in the dot matrix font library in the file header area of ​​the dot matrix font library file, a font library file has only one file header area to represent all the relevant information of the character set, and no additional redundant information is added due to the number of characters, thereby reducing system overhead. In addition, the file header area also stores the starting address of the dot matrix characters contained in the dot matrix font library, the number of encoding areas and encoding area information.

[0032] The box S102 also includes boxes labeled S103-S106, which indicate that the file header area stores S103 the dot matrix start address, S104 the character structure information, S105 the number of coding areas, and S106 the coding information of each coding area (coding range information and number of characters);

[0033] The box of S103 indicates that the file header area represents the starting offset address of the dot matrix data area (S107) through 4 bytes of data, and also represents the total data amount in bytes of the file header area (S102).

[0034] The box S104 indicates that the file header area records the display structure information of the dot matrix character through 5 bytes of data, and records the equal width or unequal width information of the dot matrix character, the width and height information of the character dot matrix data storage, the arrangement mode of the current font dot matrix character and the serial number corresponding to the character set, wherein:

[0035] Width storage format (occupies 1 Byte): Marks whether the characters in the font file are equal-width characters or unequal-width characters. Equal-width and unequal-width here specifically refer to whether the height of the character is equal to the width. Usually the height of the character is greater than the width of the character. Unequal-width characters add two bytes of data before each character dot matrix data to store the actual width pixel information of the current character.

[0036] Width information (occupies 1 Byte): The minimum number of pixels required to store the width of the current character in the dot matrix data, and convert it to a multiple of 8 (byte, the minimum reading and writing unit). If it is less than 8, the byte value is rounded to the integer;

[0037] Height information (occupies 1 Byte): The minimum number of pixels required to store the height of the current character in the dot matrix data is converted to a multiple of 8 (byte, the minimum read and write unit). If it is less than 8, the byte value is rounded to 8; that is, the width information and height information store the bytes occupied by the character width and height, and are converted to multiples of 8. When the occupied bytes are less than 8, they are rounded to multiples of 8.

[0038] Pixel arrangement (occupies 1 Byte): records the arrangement and storage of all character dot matrix data pixels in the current file. Currently, the two mainstream display formats in the market are horizontal and vertical, and the two arrangement modes can be marked with values ​​respectively.

[0039] Character set (occupies 1 Byte): such as ASCII character set, GB2312 character set, BIG5 character set, GB18030 character set, etc. The corresponding numerical value is also used to mark which character set the dot matrix characters of the font file use. For example, different character sets are represented by numerical values ​​between 0-265.

[0040] The data segment represented by the box marked with S105 occupies a total of 3 bytes, of which the first 2 bytes represent the total number of encoding areas of all characters in the current font library, and also reflect the data volume of box S106, that is, the corresponding calculation amount can be obtained through the formula (byte length = total number of encoding areas * 7), and the remaining 1 byte is used as a spare byte, that is, the file header area uses at least 2 bytes to store the number of encoding areas.

[0041] The box marked with S106 indicates the summary information of each coding area stored in the file header area. The number of data segments will change according to the actual number of character areas. At least 5 bytes are used to record one coding area information in the data segment. In this embodiment, 7 bytes are used, and each 7 bytes of data records one coding area information. The format of the 7-byte information of the coding area is:

[0042] High area code (occupies 1 Byte): stores the high byte value of the coding area;

[0043] Low start code (occupies 1 Byte): stores the low byte start byte of the coding area;

[0044] Low-order end code (occupies 1 Byte): stores the end byte of the low byte of the encoding area;

[0045] Number of characters in the area (occupies 2 bytes): stores the number of characters in the coding area, that is, records the number of characters in the current area, which is used to verify whether the coding range is consistent;

[0046] Spare (occupies 2 bytes): two bytes are used as spare parameters; The current character encoding determines the character area through the high-order area code, and then confirms the actual encoding value of the low-byte area through the low-byte code and offset sequence number. The area character count is used to calculate the number of all characters in the previous encoding area up to the current character encoding area.

[0047] The box marked with S107 is used to store the dot matrix data area of ​​all characters in the font. The characters are sorted according to the code. The character data contained in the specific code area is stored in the dot matrix data area. That is to say, the dot matrix data area contains at least one code area. The number of characters contained in the data segment of each code area is different. The user can quickly find the corresponding character data in S107 and generate dot matrix characters according to the code area information stored in S106. The dot matrix data volume of each character = character width * character height / 8 (bytes). For characters with different widths, the dot matrix data volume = 2 + font width * character height / 8 (bytes), where 2 represents the number of bytes used to store different width information.

[0048] Through the above-mentioned font file, the present invention uses less data to record various information of the dot matrix character in detail. When it is necessary to generate a dot matrix character, the dot matrix character is first stored using the dot matrix font information recording method of the above-mentioned technical solution, and then the description information of each dot matrix character and the number and coding area information of the coding area are obtained by reading the file header area of ​​the dot matrix font file. Then, according to the obtained description information, the number and the coding area information, the coding data of the character is found in the corresponding dot matrix data area to generate the dot matrix character.

[0049] In the dot matrix data, the dot matrix data volume of each character is width*height / 8 bytes. The fixed data volume unit value can be used to calculate the character dot matrix data offset under the actual serial number. A complete font library consists of a character set encoding format, and the dot matrix data of each character is stored in sequence according to the regular order of character encoding. For example: the character with character encoding B1A2, that is, in the high byte B1 area, because the first high byte area starts from the B0 area, the serial number of the current character is equal to the total number of characters in the previous B0 area (assuming 94 characters) plus the low byte A2 belongs to the encoding range of the starting A1, the corresponding increment is 1, and the final serial number calculation value is 95. The offset of the current character dot matrix data is calculated by the dot matrix data volume of each character * 95. The subsequent width*height / 8 bytes of data are continuously read through the offset, that is, the actual dot matrix data of the current character. According to the pre-set arrangement method, the actual character effect is parsed according to the bit information.

[0050] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for recording dot matrix font information, characterized in that: Includes steps: Set a file header area and a dot matrix data area for the dot matrix font file; The width, height and pixel arrangement of the dot matrix characters contained in the dot matrix font library are stored in the file header area; the pixel arrangement is vertical arrangement or horizontal arrangement; The file header area also stores the starting address of the dot matrix characters contained in the dot matrix font library, the number of coding areas and the coding area information; the file header area uses at least 5 bytes to record the coding area information of each coding area, and the 5 bytes respectively store the high byte value of the coding area, the low byte starting byte of the coding area, the low byte ending byte of the coding area, and the number of characters in the coding area; the high byte value is used to determine the character area of ​​the coding area where the current character code is located.

2. The method for representing dot matrix font information according to claim 1, characterized in that: The file header area uses 5 bytes to store whether the width and height of the dot matrix character are equal, width information, height information, pixel arrangement method, and character set.

3. The method for recording dot matrix font information according to claim 2, characterized in that: The width information and height information store the bytes occupied by the character width and height, and are converted into multiples of 8. When the occupied bytes are less than a multiple of 8, they are rounded to a multiple of 8.

4. The method for recording dot matrix font information according to claim 1, characterized in that: The file header area uses at least 2 bytes to store the number of the encoding areas.

5. A method for generating dot matrix characters, characterized in that: The dot matrix characters are stored by using the method for recording the dot matrix character library information as described in any one of claims 1 to 4; By reading the file header area of ​​the dot matrix font file, the description information of each dot matrix character and the number and information of the coding area are obtained; Find the dot matrix character data according to the description information, the number of coding areas and the coding area information; A dot matrix character is generated according to the dot matrix character data.

6. The method for generating dot matrix characters as claimed in claim 5, characterized in that: The range of the encoding area where the character is located is determined according to the high byte value in the encoding area information, and then the specific position of the encoding area is obtained according to the low byte start byte and end byte of the encoding area in the encoding area information.