Vector font library cutting method, device, computer equipment and readable storage medium

By processing the cropping precision bits of the character glyph contour point data in the original vector font library, the cropped vector font library is generated, and the problem of low efficiency of traditional cutting methods is solved and more efficient vector font library cropping is achieved.

CN119272723BActive Publication Date: 2025-03-04ZHUHAI JIELI TECH +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411825553.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-12
Publication Date
2025-03-04
Estimated Expiration
2044-12-12

AI Technical Summary

Technical Problem

The traditional vector font library cutting method is inefficient and requires a lot of manual processing time, resulting in low cutting efficiency.

Method used

By obtaining the character glyph contour point data in the original vector font library, performing bit-number processing of cropping accuracy, cropping coordinate data and updating the flag data, generating the cropped glyph contour point data, and finally generating the cropped vector font library.

Benefits of technology

On the premise of maintaining the basic characteristics of the glyph contour, the number of stored bits at each contour point is reduced, the storage space occupied by the vector font library is reduced, and the efficiency of vector font library cropping is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119272723B_ABST
    Figure CN119272723B_ABST
Patent Text Reader

Abstract

The present application relates to a vector font clipping method, device, computer equipment, computer-readable storage medium and computer program product, which can be used in the field of computer technology. The method includes: obtaining the original glyph outline point data of the character from the original vector font; the original glyph outline point data includes original coordinate data and original mark data; according to the preset clipping accuracy, the original coordinate data is clipped to obtain the clipped coordinate data, and according to the clipping accuracy, the original mark data is updated to obtain the updated mark data; the clipped coordinate data and the updated mark data are combined to obtain the clipped glyph outline point data corresponding to the original glyph outline point data; according to the clipped glyph outline point data, a clipped vector font corresponding to the original vector font is generated. The use of this method can improve the efficiency of vector font clipping.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a vector font clipping method, device, computer equipment, computer-readable storage medium and computer program product. Background Art

[0002] With the development of digital technology, font display technology in electronic devices is becoming increasingly important. In font display technology, vector fonts are widely used due to their scalability and clarity. However, with the diversification of application scenarios, higher requirements are placed on the storage space and processing efficiency of vector fonts. Therefore, how to efficiently cut vector fonts has become an important research direction.

[0003] Traditional technology usually performs vector font cropping by manually adjusting the glyph outline points; however, this method requires a lot of manual processing time, resulting in low efficiency of vector font cropping. Summary of the invention

[0004] Based on this, it is necessary to provide a vector font clipping method, apparatus, computer equipment, computer-readable storage medium and computer program product that can improve the efficiency of vector font clipping in order to address the above technical problems.

[0005] In a first aspect, the present application provides a method for clipping a vector font library. The method comprises:

[0006] Acquire original font outline point data of the character from the original vector font library; the original font outline point data includes original coordinate data and original mark data;

[0007] According to a preset clipping precision, the original coordinate data is subjected to a bit clipping process to obtain clipped coordinate data, and according to the clipping precision, the original mark data is subjected to a bit function updating process to obtain updated mark data;

[0008] Combining the clipped coordinate data and the updated mark data to obtain clipped glyph outline point data corresponding to the original glyph outline point data;

[0009] A cropped vector font library corresponding to the original vector font library is generated according to the cropped glyph outline point data.

[0010] In one embodiment, performing bit function update processing on the original mark data according to the cropping accuracy to obtain updated mark data includes:

[0011] According to the clipping precision, the original logo data is processed for bit updating to obtain logo data after bit updating;

[0012] According to the clipping precision, performing a bit function update process on a preset bit in the flag data after the bit number is updated, to obtain the flag data after the bit function is updated;

[0013] According to the clipped coordinate data, data updating processing is performed on the flag data after the bit function is updated to obtain the updated flag data.

[0014] In one embodiment, performing bit updating processing on the original logo data according to the cropping precision to obtain the logo data after bit updating includes:

[0015] According to the cropping precision, determining the to-be-cropped position corresponding to the original mark data;

[0016] According to the to-be-cropped bits, the original flag data is subjected to a bit-cropping process to obtain the flag data after the bit-number is updated.

[0017] In one embodiment, the method further comprises:

[0018] Detecting overlapping contour points in the clipped coordinate data; the overlapping contour points include completely overlapping contour points and partially overlapping contour points; the partial overlap includes overlapping of the first coordinate data or overlapping of the second coordinate data;

[0019] For each group of completely overlapping contour points, retain the mark data and coordinate data of one contour point in each group of completely overlapping contour points, and delete the mark data and coordinate data of the remaining contour points in each group of completely overlapping contour points;

[0020] For each group of partially overlapping contour points, the coordinate compression attribute bit in the mark data of each group of partially overlapping contour points is updated, and the mark data of each group of partially overlapping contour points is compressed according to the updated coordinate compression attribute bit.

[0021] In one embodiment, the step of performing bit clipping on the original coordinate data according to a preset clipping precision to obtain clipped coordinate data includes:

[0022] Determine the number of displacement operation bits corresponding to the original coordinate data according to the clipping precision;

[0023] The original coordinate data is subjected to a right shift operation corresponding to the number of bits of the shift operation to obtain the clipped coordinate data.

[0024] In one embodiment, generating a cropped vector font library corresponding to the original vector font library according to the cropped glyph outline point data includes:

[0025] Compressing the clipped glyph outline point data to obtain compressed glyph outline point data;

[0026] Generate a corresponding new font data table according to the compressed font outline point data;

[0027] Generate a corresponding new glyph index mapping table according to the new glyph data table;

[0028] The cropped vector font library is generated according to the new font data table and the new font index mapping table.

[0029] In one embodiment, generating the clipped vector font library according to the new font data table and the new font index mapping table includes:

[0030] According to the clipping precision, the original measurement information of the original vector character library is updated to obtain updated measurement information corresponding to the original vector character library;

[0031] The new glyph data table, the new glyph index mapping table, the updated metric information and the character mapping table of the original vector font library are combined and processed to obtain the cropped vector font library.

[0032] In one embodiment, the step of obtaining original glyph contour point data of a character from an original vector character library includes:

[0033] Searching for glyph index information corresponding to the character code of the character from the character mapping table of the original vector character library;

[0034] Obtaining an offset address corresponding to the glyph index information from a glyph index mapping table of the original vector font library;

[0035] Acquire the glyph path compression information corresponding to the offset address from the glyph data table of the original vector font library;

[0036] The glyph path compression information is decompressed to obtain original glyph outline point data of the character.

[0037] In a second aspect, the present application also provides a vector font library clipping device. The device comprises:

[0038] A data acquisition module, used to acquire original font outline point data of a character from an original vector font library; the original font outline point data includes original coordinate data and original mark data;

[0039] A data clipping module, configured to perform a bit clipping process on the original coordinate data according to a preset clipping precision to obtain clipped coordinate data, and perform a bit function update process on the original mark data according to the clipping precision to obtain updated mark data;

[0040] A data combination module, used for combining the clipped coordinate data and the updated mark data to obtain clipped glyph outline point data corresponding to the original glyph outline point data;

[0041] The character library generation module is used to generate a cropped vector character library corresponding to the original vector character library according to the cropped character outline point data.

[0042] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:

[0043] Acquire original font outline point data of the character from the original vector font library; the original font outline point data includes original coordinate data and original mark data;

[0044] According to a preset clipping precision, the original coordinate data is subjected to a bit clipping process to obtain clipped coordinate data, and according to the clipping precision, the original mark data is subjected to a bit function updating process to obtain updated mark data;

[0045] Combining the clipped coordinate data and the updated mark data to obtain clipped glyph outline point data corresponding to the original glyph outline point data;

[0046] A cropped vector font library corresponding to the original vector font library is generated according to the cropped glyph outline point data.

[0047] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:

[0048] Acquire original font outline point data of the character from the original vector font library; the original font outline point data includes original coordinate data and original mark data;

[0049] According to a preset clipping precision, the original coordinate data is subjected to a bit clipping process to obtain clipped coordinate data, and according to the clipping precision, the original mark data is subjected to a bit function updating process to obtain updated mark data;

[0050] Combining the clipped coordinate data and the updated mark data to obtain clipped glyph outline point data corresponding to the original glyph outline point data;

[0051] A cropped vector font library corresponding to the original vector font library is generated according to the cropped glyph outline point data.

[0052] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:

[0053] Acquire original font outline point data of the character from the original vector font library; the original font outline point data includes original coordinate data and original mark data;

[0054] According to a preset clipping precision, the original coordinate data is subjected to a bit clipping process to obtain clipped coordinate data, and according to the clipping precision, the original mark data is subjected to a bit function updating process to obtain updated mark data;

[0055] Combining the clipped coordinate data and the updated mark data to obtain clipped glyph outline point data corresponding to the original glyph outline point data;

[0056] A cropped vector font library corresponding to the original vector font library is generated according to the cropped glyph outline point data.

[0057] The above-mentioned vector font clipping method, device, computer equipment, computer-readable storage medium and computer program product obtain the original glyph contour point data of the character from the original vector font; the original glyph contour point data includes original coordinate data and original mark data; according to the preset clipping accuracy, the original coordinate data is clipped to obtain clipped coordinate data, and according to the clipping accuracy, the original mark data is updated to obtain updated mark data; the clipped coordinate data and the updated mark data are combined to obtain clipped glyph contour point data corresponding to the original glyph contour point data; according to the clipped glyph contour point data, a clipped vector font corresponding to the original vector font is generated. This scheme is conducive to reducing the storage bit number of each contour point while maintaining the basic characteristics of the glyph contour by clipping the original coordinate data in the original glyph contour point data and updating the original mark data, and automatically combining the clipped and updated data, thereby reducing the storage space occupied by the vector font and improving the efficiency of vector font clipping. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0059] Figure 1 is a schematic diagram of a process of a vector font library cutting method in one embodiment;

[0060] Figure 2 is a schematic diagram of the structure of font data in one embodiment;

[0061] Figure 3 is a schematic flow chart of a vector font library clipping method in another embodiment;

[0062] Figure 4 A schematic flow chart of the steps of parsing an original character library in one embodiment;

[0063] Figure 5 A schematic diagram of a storage structure when 8-bit precision clipping is performed in one embodiment;

[0064] Figure 6 A schematic diagram of a storage structure when 10-bit precision clipping is performed in one embodiment;

[0065] Figure 7 A schematic diagram of a storage structure when 6-bit precision clipping is performed in one embodiment;

[0066] Figure 8 is a structural block diagram of a vector font library cutting device in one embodiment;

[0067] Fig. 9 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0068] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application 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 application and are not used to limit the present application.

[0069] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0070] In an exemplary embodiment, Figure 1 As shown, a vector font clipping method is provided. This embodiment uses the method applied to a terminal as an example for illustration; it is understandable that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. Among them, the terminal can be but is not limited to various personal computers, laptops, smart phones, tablet computers, etc.; the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services. In this embodiment, the method includes the following steps:

[0071] Step S101, obtaining original glyph outline point data of a character from an original vector character library; the original glyph outline point data includes original coordinate data and original mark data.

[0072] Step S102, according to the preset clipping precision, the original coordinate data is subjected to bit clipping processing to obtain clipped coordinate data, and according to the clipping precision, the original mark data is subjected to bit function update processing to obtain updated mark data.

[0073] Step S103, combining the clipped coordinate data and the updated mark data to obtain clipped glyph outline point data corresponding to the original glyph outline point data.

[0074] Step S104, generating a cropped vector font library corresponding to the original vector font library according to the cropped glyph outline point data.

[0075] The vector font library may be a font file that uses a mathematical formula to define each character outline. For example, the vector font library may be a font file that is composed of a series of points, lines, and curves and is used to define character outlines.

[0076] The original glyph outline point data may be the outline point information of the character glyph, for example, the original glyph outline point data may be the character outline point information including original coordinate data and original mark data.

[0077] The original coordinate data may be a coordinate value indicating the position of a contour point, for example, the original coordinate data may be a 16-bit signed xy coordinate value (x represents the horizontal coordinate, and y represents the vertical coordinate).

[0078] The original mark data may be mark information used to describe the features of the contour point. For example, the original mark data may be 8-bit flag data, which includes information indicating whether the contour point is on the curve, coordinate compression attributes, and the like.

[0079] The clipping precision may be a precision standard for clipping the number of bits of the original coordinate data, for example, the clipping precision may be 10-bit signed number precision, 8-bit signed number precision or 6-bit signed number precision.

[0080] The bit number clipping process may be a process of reducing the number of bits of the original coordinate data. For example, the bit number clipping process may be a process of clipping 16-bit signed coordinate data into 8-bit signed data.

[0081] The bit function update process may be a process of updating the function bits of the original flag data according to the clipping accuracy. For example, the bit function update process may be a process of updating 8-bit flag data to 4-bit and updating the function definition of each bit.

[0082] The combining process may be a process of reorganizing the cropped coordinate data and the updated mark data. For example, the combining process may be a process of recompressing the cropped coordinate data and the updated mark data and forming a new glyf (font) table.

[0083] The cropped vector font may be a new font file obtained after cropping, for example, the cropped vector font may be a new font file composed of a regenerated glyf (glyph) table, a loca (position) table, a retained cmap (character map) table, and the like.

[0084] Optionally, the terminal reads original glyph contour point data of the character from the original vector font library, the original glyph contour point data including original coordinate data for indicating the position of the contour point and original mark data for describing the features of the contour point; the terminal performs a clipping process on the number of numerical digits of each coordinate point in the original coordinate data according to a preset clipping precision to obtain clipped coordinate data, and at the same time, the terminal performs a bit function update process on the original mark data according to the clipping precision to obtain updated mark data; the terminal performs a data combination process on the clipped coordinate data and the updated mark data to generate clipped glyph contour point data corresponding to the original glyph contour point data; the terminal generates a data compressed clipped vector font library corresponding to the original vector font library based on the clipped glyph contour point data.

[0085] For example, when the terminal obtains the original glyph outline point data of a character from the original vector font library, it first obtains the entry addresses of the cmap (character mapping) table, glyf (font) table, and loca (position) table in the font file, and then finds the corresponding glyph index in the cmap (character mapping) table according to the Unicode (Unicode) encoding of the character, and then finds the offset address of the glyph path information in the glyf (font) table from the loca (position) table according to the glyph index, and finally decompresses to obtain the original glyph outline point data containing 16-bit signed xy coordinate data and 8-bit flag data; when the terminal performs bit clipping on the original coordinate data according to the preset clipping precision, if the clipping precision is 8bit (signed) number, the 16-bit signed xy coordinates are right-shifted by arithmetic to obtain 8-bit signed coordinates, and the 8-bit flag data is clipped to 4 bits, where bit0 indicates whether it is on the curve, bit1 indicates the compression attribute of the flag, and bit2 and bit3 respectively indicate the compression attributes of the xy coordinates, thereby obtaining updated flag data; the terminal compresses and combines the clipped coordinate data and the updated flag data to obtain clipped glyph outline point data; the terminal regenerates the glyf (glyph) table and the loca (position) table according to the clipped glyph outline point data, and generates a clipped vector font library according to the regenerated glyf (glyph) table, the loca (position) table and the retained cmap (character mapping) table.

[0086] In the above-mentioned vector font library clipping method, the original glyph contour point data of the character is obtained from the original vector font library; the original glyph contour point data includes original coordinate data and original mark data; according to the preset clipping accuracy, the original coordinate data is clipped to obtain clipped coordinate data, and according to the clipping accuracy, the original mark data is updated with a bit function to obtain updated mark data; the clipped coordinate data and the updated mark data are combined to obtain clipped glyph contour point data corresponding to the original glyph contour point data; according to the clipped glyph contour point data, a clipped vector font library corresponding to the original vector font library is generated. This scheme performs a bit clipping process on the original coordinate data in the original glyph contour point data and a bit function update process on the original mark data, and automatically combines the clipped and updated data, which is conducive to reducing the storage bit number of each contour point while maintaining the basic characteristics of the glyph contour, thereby helping to reduce the storage space occupied by the vector font library and improve the efficiency of vector font library clipping.

[0087] In an exemplary embodiment, according to the cropping accuracy, the original logo data is subjected to a bit function update process to obtain the updated logo data, which specifically includes the following contents: according to the cropping accuracy, the original logo data is subjected to a bit function update process to obtain the logo data after the bit number is updated; according to the cropping accuracy, the preset bits in the logo data after the bit number is updated are subjected to a bit function update process to obtain the logo data after the bit number is updated; according to the coordinate data after the cropping, the logo data after the bit number is updated is subjected to a data update process to obtain the updated logo data.

[0088] The bit number update process may be a process of adjusting the bit number of the original flag data according to the cropping accuracy. For example, the bit number update process may be a process of cropping 8-bit flag data to 4 bits or keeping 8 bits.

[0089] The preset bit may be a bit with a specific function in the original flag data, for example, the preset bit may be bit0 (indicating whether the contour point is on the curve), bit1 to bit3 (indicating compression attributes) and other bits with specific functions in the flag data.

[0090] The data update process may be a process of adjusting the flag data accordingly according to the change of the coordinate data. For example, the data update process may be a process of updating the corresponding compression attribute flag in the flag when the coordinate data becomes compressible after clipping.

[0091] Optionally, when the terminal performs bit update processing on the original flag data according to the cropping precision, if the cropping precision is an 8-bit signed number, the 8-bit flag data is cropped to 4 bits, and if the cropping precision is a 10-bit or 6-bit signed number, the 8-bit flag data is maintained; when the terminal performs bit function update processing on the preset bits in the flag data after the bit number is updated, if the cropping precision is an 8-bit signed number, bit0 is defined as indicating whether the contour point is on the curve, bit1 is defined as indicating the compression attribute of the flag, bit2 and bit3 are defined as indicating the compression attributes of the xy coordinates respectively, and if the cropping precision is a 10-bit or 6-bit signed number precision, bit4 to bit7 are defined as the high-order data for storing the coordinates. ; When the terminal updates the flag data after the bit function is updated according to the cropped coordinate data, if the cropping precision is an 8-bit signed number, it detects whether the coordinate data becomes compressible after cropping. If it can be compressed, the corresponding compression attribute flag in the flag is updated. At the same time, it detects whether the consecutive contour points are the same. If they are the same, only the flag data of one contour point is retained; if the cropping precision is a 10-bit signed number, the upper two bits of the 10-bit coordinate are stored in bit4-bit5 and bit6-bit7 of the flag respectively; if the cropping precision is a 6-bit signed number, the upper two bits of the 6-bit coordinate are stored in bit4-bit5 and bit6-bit7 of the flag respectively.

[0092] The technical solution provided in this embodiment, through the triple processing of bit update processing, bit function update processing and data update processing on the original logo data, is beneficial to reducing the number of storage bits of the logo data while maintaining the functional integrity of the logo data, thereby helping to reduce the storage space occupied by the logo data in the vector font library and realize efficient compression of the logo data.

[0093] In an exemplary embodiment, the original mark data is updated in number according to the cropping accuracy to obtain the mark data after the number of bits is updated, which specifically includes the following contents: according to the cropping accuracy, the to-be-cropped bits corresponding to the original mark data are determined; according to the to-be-cropped bits, the original mark data is cropped in number according to the to-be-cropped bits to obtain the mark data after the number of bits is updated.

[0094] Among them, the bits to be cropped can be the bits that need to be cropped from the original flag data according to the cropping precision. For example, the bits to be cropped can be the last 4 bits that need to be cropped from the 8-bit flag data when the cropping precision is an 8-bit signed number, or the bits that do not need to be cropped when the cropping precision is a 10-bit or 6-bit signed number.

[0095] The bit number clipping process may be a process of deleting the bits to be clipped in the original flag data. For example, the bit number clipping process may be a process of clipping 8-bit flag data to 4-bit.

[0096] Optionally, when the terminal determines the to-be-cropped bits corresponding to the original flag data according to the cropping precision, if the cropping precision is an 8-bit signed number, bit4 to bit7 of the original flag data are determined to be the to-be-cropped bits; if the cropping precision is a 10-bit signed number or a 6-bit signed number, bit4 to bit7 of the original flag data are determined to be bits whose functions need to be redefined; when the terminal performs bit number cropping on the original flag data according to the to-be-cropped bits, if the cropping precision is an 8-bit signed number, bit4 to bit7 of the original flag data are directly cropped, and only four bits of data from bit0 to bit3 are retained; if the cropping precision is a 10-bit signed number, bit4 and bit5 of the original flag data are redefined to store the upper two bits of the 10-bit signed x coordinate, and bit6 and bit7 are redefined to store the upper two bits of the 10-bit signed y coordinate; if the cropping precision is a 6-bit signed number, bit4 and bit5 of the original flag data are redefined to store the upper two bits of the 6-bit signed x coordinate, and bit6 and bit7 are redefined to store the upper two bits of the 6-bit signed y coordinate.

[0097] The technical solution provided in this embodiment is conducive to accurate and targeted bit number cropping of original logo data by determining the bits to be cropped according to the cropping accuracy and performing corresponding bit number cropping processing, thereby facilitating minimizing the number of stored bits of logo data while ensuring the functional integrity of the logo data.

[0098] In an exemplary embodiment, the following contents are also included: detecting overlapping contour points in the cropped coordinate data; overlapping contour points include completely overlapping contour points and partially overlapping contour points; partial overlap includes overlapping of first coordinate data or overlapping of second coordinate data; for each group of completely overlapping contour points, retaining the marker data and coordinate data of one contour point in each group of completely overlapping contour points, and deleting the marker data and coordinate data of the remaining contour points in each group of completely overlapping contour points; for each group of partially overlapping contour points, updating the coordinate compression attribute bits in the marker data of each group of partially overlapping contour points, and compressing the marker data of each group of partially overlapping contour points according to the updated coordinate compression attribute bits.

[0099] The overlapping contour points may be points where coordinate data overlap in the glyph contour data.

[0100] The first coordinate data may be an x-coordinate, and the second coordinate data may be a y-coordinate.

[0101] The complete overlap may be a situation where the first coordinate data and the second coordinate data of the contour points are the same. For example, the complete overlap may be a situation where the x-coordinates and y-coordinates of consecutive contour points are exactly the same.

[0102] Partial overlap may be a situation where one of the first coordinate data or the second coordinate data of the contour point is the same. For example, partial overlap may be a situation where consecutive contour points have the same x coordinate but different y coordinates, or the same y coordinate but different x coordinates.

[0103] The coordinate compression attribute bit may be a bit in the flag data used to indicate whether the coordinate data can be compressed. For example, the coordinate compression attribute bit may be bit 2 and bit 3 in the flag data, indicating the compression attributes of the x coordinate and the y coordinate respectively.

[0104] Optionally, the terminal detects overlapping contour points in the cropped coordinate data, classifies contour points with the same x-coordinate and y-coordinate as completely overlapping contour points, and classifies contour points with the same x-coordinate or the same y-coordinate as partially overlapping contour points; for each group of completely overlapping contour points, the terminal retains the flag data and coordinate data of one contour point in each group of completely overlapping contour points, and deletes the flag data and coordinate data of the remaining contour points in each group of completely overlapping contour points; for each group of partially overlapping contour points, the terminal updates bit2 and bit3 in the flag data to indicate that the x-coordinate or the y-coordinate is compressible, and compresses the flag data of each group of partially overlapping contour points according to the updated compression attribute bit.

[0105] The technical solution provided in this embodiment detects overlapping contour points in the coordinate data after cropping, deletes completely overlapping contour points, and updates compression attributes of partially overlapping contour points. This is beneficial for removing redundant contour point data while maintaining the integrity of the glyph, thereby helping to further reduce the storage space occupied by the vector font library.

[0106] In an exemplary embodiment, the original coordinate data is subjected to bit clipping according to a preset clipping precision to obtain the clipped coordinate data, which specifically includes the following contents: according to the clipping precision, the number of displacement operation bits corresponding to the original coordinate data is determined; and the original coordinate data is subjected to a right shift operation corresponding to the number of displacement operation bits to obtain the clipped coordinate data.

[0107] The number of bits for the shift operation may be the number of bits for the right shift obtained by subtracting a specific value from the number of bits of the unit of measurement unitsPerEm (units per character frame) of the font library. For example, the number of bits for the shift operation may be 3 bits obtained by subtracting 7 from the corresponding number of bits when unitsPerEm is 1024.

[0108] The right shift operation may be an operation of performing an arithmetic right shift on the original coordinate data to reduce the data precision. For example, the right shift operation may be to shift the 16-bit signed coordinate data right by 3 bits to obtain an 8-bit signed number, or to shift more bits right to obtain a 6-bit signed number.

[0109] Optionally, the terminal obtains the number of bits of the measurement unit unitsPerEm (number of units per character frame) of the font library according to a preset cropping accuracy, and the terminal subtracts 7 from the number of bits of the measurement unit unitsPerEm (number of units per character frame) to obtain the number of bits for the shift operation; the terminal performs an arithmetic right shift operation on the original coordinate data corresponding to the number of bits for the shift operation to obtain the cropped coordinate data.

[0110] The technical solution provided in this embodiment, by determining the number of shift operation bits according to the clipping accuracy and performing a corresponding right shift operation on the original coordinate data, is conducive to realizing precise bit clipping of the coordinate data by arithmetic right shift, thereby facilitating reducing the number of storage bits of the coordinate data while maintaining the validity of the coordinate data.

[0111] In an exemplary embodiment, a cropped vector font library corresponding to the original vector font library is generated based on the cropped glyph contour point data, which specifically includes the following contents: compressing the cropped glyph contour point data to obtain compressed glyph contour point data; generating a corresponding new glyph data table based on the compressed glyph contour point data; generating a corresponding new glyph index mapping table based on the new glyph data table; generating a cropped vector font library based on the new glyph data table and the new glyph index mapping table.

[0112] The new glyph data table may be a glyf table for storing compressed glyph path information. For example, the new glyph data table may be a glyf table for storing flag data and coordinate data after clipping and compression.

[0113] The new glyph index mapping table may be a loca (position) table for storing position information of glyphs in the new glyph data table. For example, the new glyph index mapping table may be a loca (position) table for storing the offset address of each glyph in the glyf (glyph) table.

[0114] The compression process may be a process of compressing the glyph outline point data. For example, the compression process may be a process of merging and compressing consecutive identical flag data, or marking identical coordinate values ​​with compression attribute bits.

[0115] Optionally, the terminal compresses the cropped glyph outline point data, merges and compresses consecutive identical flag data, marks identical coordinate values ​​with compression attribute bits, and obtains compressed glyph outline point data; the terminal stores the compressed flag data and coordinate data in the glyf table according to the glyph path information, and generates a corresponding new glyph data table; the terminal generates a new loca table according to the offset address of each glyph in the glyf table; the terminal combines the new glyf table and loca table with other necessary tables to generate a cropped vector font library.

[0116] The technical solution provided in this embodiment, by compressing the cropped glyph outline point data and generating a new glyph data table and a glyph index mapping table, is conducive to achieving compressed storage of glyph data while maintaining the integrity and accessibility of the glyph data, thereby helping to reduce the storage space occupied by the vector font library.

[0117] In an exemplary embodiment, a cropped vector font library is generated based on a new glyph data table and a new glyph index mapping table, which specifically includes the following contents: according to the cropping accuracy, the original measurement information of the original vector font library is updated to obtain the updated measurement information corresponding to the original vector font library; the new glyph data table, the new glyph index mapping table, the updated measurement information and the character mapping table of the original vector font library are combined to obtain the cropped vector font library.

[0118] The original measurement information may be information in the original vector font library for describing the measurement characteristics of the glyphs. For example, the original measurement information may be information including measurement parameters such as the measurement unit unitsPerEm and horizontal alignment parameters of the font library.

[0119] The updated measurement information may be information obtained by clipping the original measurement information to the same number of bits as the contour point coordinates. For example, the updated measurement information may be information in which the measurement unit unitsPerEm is updated to 32, 128 or 512 according to the clipping accuracy.

[0120] The character mapping table may be a cmap (character mapping) table storing a mapping relationship between character encoding and glyph index. For example, the character mapping table may be a cmap (character mapping) table used to search for a corresponding glyph index according to a Unicode (unicode) character encoding.

[0121] Optionally, the terminal updates the original measurement information of the original vector font library according to the cropping accuracy. When the cropping accuracy is a 10-bit signed number, the terminal updates the measurement unit unitsPerEm of the font library to 512; when the cropping accuracy is an 8-bit signed number, the terminal updates the measurement unit unitsPerEm (unit per EM) of the font library to 128; when the cropping accuracy is a 6-bit signed number, the terminal updates the measurement unit unitsPerEm (unit per EM) of the font library to 32; the terminal performs an arithmetic right shift operation of the same length as the contour point coordinates on other measurement information in the original vector font library, to obtain the updated measurement information corresponding to the original vector font library; the terminal writes the new glyph data table g The lyf (glyph) table, the new glyph index mapping table loca (position) table, the updated metric information and the character mapping table cmap (character mapping) table of the original vector font are combined and processed. For example, a mapping relationship is established between the compressed glyph path information stored in the new glyph data table glyf (glyph) table and the glyph offset address stored in the new glyph index mapping table loca (position) table, the mapping relationship between the character encoding and the glyph index stored in the character mapping table cmap (character mapping) table remains unchanged, and these tables are combined with necessary tables such as the head (head) table, the hhea (horizontal head) table, the hmtx (horizontal metric) table, the maxp (maximum outline) table, etc. to generate a cropped vector font.

[0122] The technical solution provided in this embodiment is beneficial to maintaining the accuracy consistency of each component of the font file by updating the original measurement information according to the cropping accuracy, and combining the new glyph data table, the new glyph index mapping table, the updated measurement information and the character mapping table, thereby facilitating the generation of a structurally complete cropped vector font library.

[0123] In an exemplary embodiment, original glyph contour point data of a character is obtained from an original vector font library, specifically including the following contents: searching for glyph index information corresponding to the character encoding of the character from a character mapping table of the original vector font library; obtaining an offset address corresponding to the glyph index information from a glyph index mapping table of the original vector font library; obtaining glyph path compression information corresponding to the offset address from a glyph data table of the original vector font library; and decompressing the glyph path compression information to obtain the original glyph contour point data of the character.

[0124] The character encoding may be an encoding value used to represent a character, for example, the character encoding may be Unicode (Unicode) encoding.

[0125] The glyph index information may be index data used to locate the position of the glyph in the glyph index mapping table. For example, the glyph index information may be a glyph index value obtained by searching in a cmap (character mapping) table according to the Unicode (unicode) encoding of the character.

[0126] The offset address may be address information for locating the position of a glyph in a glyph data table. For example, the offset address may be the starting position of a glyph in a glyf (glyph) table obtained by searching in a loca (position) table according to glyph index information.

[0127] The glyph path compression information may be data obtained by compressing the glyph outline point data. For example, the glyph path compression information may be compressed data including flags data, xCoordinates data, and yCoordinates data.

[0128] Optionally, the terminal searches the cmap (character map) table of the original vector font library for the corresponding glyph index information according to the Unicode (Unicode) encoding of the character; the terminal searches the loca (position) table of the original vector font library for the offset address of the corresponding glyph in the glyf (glyph) table according to the glyph index information; the terminal obtains the glyph path compression information from the glyf (glyph) table of the original vector font library according to the offset address; the terminal decompresses the flags (flag) data, xCoordinates (x coordinates) data and yCoordinates (y coordinates) data in the glyph path compression information to obtain the original glyph contour point data of the character.

[0129] The technical solution provided in this embodiment, by establishing a multi-level mapping relationship between the character mapping table, the glyph index mapping table and the glyph data table and performing compressed information decompression processing, is conducive to orderly positioning and obtaining glyph data according to character encoding, thereby facilitating accurate acquisition of the original glyph contour point data of the character.

[0130] The following is an application example to illustrate the vector font library clipping method provided by the present application. This application example uses the method applied to a terminal as an example.

[0131] In current computer systems, software programs with interactive properties usually need to display a certain number of fonts to output information, and the font data usually needs to be saved in font files. Font files are divided into two types: bitmap fonts and vector fonts. When the software needs to display a certain character, it will find the corresponding bitmap or vector path in the font according to the character's encoding, and draw and display the font in combination with the font's metric information.

[0132] Bitmap fonts are a collection of pre-rendered images for characters of a specific size. Each character is stored as a small bitmap image. Bitmap fonts may become blurry or pixelated when enlarged because they are fixed resolution images. Bitmap fonts are mainly used in some early computer systems or low-resolution display devices. Due to the blurring characteristics of enlargement, when multiple font sizes are needed in the system, it is necessary to store the glyph bitmaps of different sizes of the same font glyph.

[0133] Vector fonts use mathematical formulas to define the outline of each character. This means that each letter, number or symbol is made up of a series of points, lines and curves. Since they are built based on vector graphics, vector fonts can be enlarged or reduced losslessly without jagged or blurry images, so vector fonts only need to store the outline of a glyph.

[0134] The advantage of vector fonts over bitmap fonts is that they can be flexibly scaled without loss, and the vector path information reduces the consumption of storage resources; however, for embedded systems with relatively limited resources, the size of vector font libraries in some languages ​​is still very large.

[0135] In lightweight embedded systems, it is usually impossible to use larger font files due to resource limitations such as RAM (random access memory) and flash (flash memory). Therefore, it is necessary to tailor the general vector font library. For embedded systems, there is no opportunity to use complete font information like PC (personal computer) desktop platforms. By tailoring the vector glyph information of each character in the font library, the necessary font information and complete font glyphs for the embedded system are retained.

[0136] The traditional technical solution is:

[0137] In traditional embedded systems, fonts are also used by cutting font files.

[0138] Traditional solution 1: Bitmap fonts only support a limited number of font sizes, such as 16, 24, 32, etc.

[0139] Traditional solution 2: vector glyphs, cutting out uncommon character glyphs, such as cutting out traditional Chinese characters;

[0140] Traditional technical solutions have the following disadvantages:

[0141] Regarding the traditional solution 1: Directly scaling bitmap fonts will cause the edges of the fonts to become blurred, because bitmap fonts themselves are high-resolution images; by providing outlines of different font sizes, you can switch to different font outlines when scaling the font, but this method has great limitations, because it can only support a few font sizes, and each font size requires the glyphs of all characters to be stored once, which consumes exponentially more space. At the same time, the space consumed by large fonts also grows exponentially. For example, a 64-point font is 64×64 bytes, and a 16-point font is 16×16 bytes, and the two font sizes differ by 16 times;

[0142] Regarding the traditional solution 2: the method of vector cutting out uncommon character glyphs has the direct disadvantage of missing glyphs. The characters used in the software are completely random for the font library, so the missing glyphs will be displayed abnormally, and this situation is usually unavoidable.

[0143] Compared with the traditional technical solution, this application example has the following improvements:

[0144] 1. Overall architecture:

[0145] Compared with the traditional font library usage method in embedded systems, this application example cuts the vector glyph information of each character in the font library and retains the glyph path of all symbols in the font library. Compared with PC (personal computer) desktop or mobile phone platforms that are not sensitive to storage resources, lightweight embedded usually refers to MUC (microcontroller) level platforms running RTOS (real-time operating system). These processors generally do not have too much flash (flash memory) and RAM (random access memory). The advantages are low power consumption and low cost. They are used in most portable products with screens and batteries, such as smart watches and bracelets. In scenarios with high requirements for screen display effects, more complete font files have to be used. Vector font files are composed of many tables. Using vector fonts in embedded systems can cut out most of the irrelevant tables in the font library and only retain the necessary tables: cmap (character mapping), glyf (glyph), head (head), hhea (horizontal head), hmtx (horizontal measurement), loca (position), maxp (maximum configuration). In the entire vector font library, the glyf (font) table occupies the largest storage space; the more complete the font file is, the larger the glyf (font) table occupies. At this time, the size of other tables can be almost ignored. Therefore, the key to trimming the vector font library while retaining the glyph data of all symbols is to trim the glyf (font) table. In the path information rule of the vector font library, the glyph path data of a symbol in the glyf (font) is also compressed. The location of the compressed data is Figure 2The flags, xCoordinates, and yCoordinates are shown. The compressed data is the contour points of the path, which include the path endpoints on the glyph curve and the control points that are not on the curve. The value of each contour point is the coordinate increment relative to the previous contour point, and the flag is used to mark whether the data of each point is an 8-bit or 16-bit increment, or the same as the previous increment. For simple glyphs, this compression method can save a lot of storage space, but for complex glyphs such as Chinese fonts, the final vector font will be very large due to the large number of contour points in the path itself.

[0146] In this application example, the idea of ​​clipping is to clip all the compressed data of the vector path contour points that are originally stored in a mixture of 8 bits and 16 bits into 8 bits for storage. This can further reduce the size of the vector font library and retain the path information of a maximum size of 128.

[0147] refer to Figure 2 , Figure 2 Shows the glyph data structure:

[0148] numberOfContours is of int16 type, which records the number of contours of the glyph. When this value is less than 0, it means that the glyph is a composite glyph.

[0149] xMin, yMin, xMax, yMax are used to represent the bounding box coordinates of the glyph;

[0150] endPtsOfContours[n] is of uint16 type, where n = numberOfContours, and is used to store the end point index of each contour. This index can be used to calculate the start and end points of each contour.

[0151] instructionLength and instructions[m], where m=instructionLength;

[0152] flags[], xCoordinates[] and yCoordinates[] are all compressed data and need to be calculated according to the calculation rules of each contour point corresponding to flags. The compressed data needs to be decompressed from top to bottom according to flags to finally get all the contour points. The number of contour points is endPtsOfContours[n-1]+1. Each contour point contains three pieces of information: flag, x, and y, where x and y are int16 types and flag is uint8 type.

[0153] Among them, numberOfContours is the number of contours; xMin is the minimum x coordinate; yMin is the minimum y coordinate; xMax is the maximum x coordinate; yMax is the maximum y coordinate; endPtsOfContours is the end point of the contour; instructionLength is the instruction length; instructions is the instruction; flags is the flag; xCoordinates is the x coordinate; yCoordinates is the y coordinate; int16 is a 16-bit integer; uint16 is a 16-bit unsigned integer; uint8 is an 8-bit unsigned integer.

[0154] 2. Implementation methods:

[0155] The overall approach of this application example includes:

[0156] This application example mainly includes three steps. Figure 3 , Figure 3 The flowchart of this application example is shown, which includes three main steps: original font parsing, font cropping and font generation.

[0157] The original font parsing step includes three sub-steps: parsing the glyph index of each character, obtaining the glyph data corresponding to the glyph index, and decompressing the glyph data. The font clipping step includes one sub-step: clipping the excess precision of each glyph outline point. The font generation step includes three sub-steps: re-compressing the glyph data, regenerating the offset table from the glyph index to the glyph data, and regenerating the glyph index table of the character encoding.

[0158] Step S1: Parsing of the original font library. The original vector font library is decompressed to obtain the contour points of the glyph paths of all symbols. First, the entry addresses of several necessary tables of the font file are obtained. Then, the software finds the glyph index corresponding to the character encoding in the cmap (character mapping) table according to the character encoding, and then finds the offset address of the glyph path information in the glyf (glyph) table from the loca (position) table according to this glyph index; other tables can obtain measurement information, such as the measurement unit unitsPerEm (number of units per character frame) of the font library, horizontal alignment parameters, etc.; each glyph path information is decompressed into the original contour point data of each glyph, and each contour point includes an 8-bit flag and 16-bit signed x-coordinate and y-coordinate data.

[0159] refer to Figure 4 , Figure 4 The three-step process of parsing the original font is shown:

[0160] The first step is to calculate the glyph index in the loca table based on the Unicode character encoding and the mapping information in the cmap table;

[0161] The second step is to calculate the offset address in the glyf (glyph) table based on the glyph index, which stores the compressed information of the character path;

[0162] The third step is to obtain the XY coordinate information (x coordinate and y coordinate) of each contour point by decompressing the compressed information of the character path.

[0163] Step S2: Cropping of the original font library. Cropping is performed based on the original outline point information of each symbol in the parsed font library file. In order to adapt to more flexible application scenarios, according to different requirements for the maximum font size, three precision cropping methods can be used, namely, 10-bit signed number, 8-bit signed number, and 6-bit signed number, as well as a font library recompression scheme.

[0164] The original valid bits of flag include bit0-bit5; bit0 indicates whether the contour point is on the curve; bit3 indicates the compression attribute of flag, which is used to express whether the following flags are the same as the current flag; the other four bits are used to parse whether the x-coordinate and y-coordinate information is stored in 8 bits or 16 bits, the sign bit when stored in 8 bits, and the compression information. After the final analysis, the contour point is a 16-bit signed x-coordinate and y-coordinate. The flags and coordinate point information of different precisions are clipped as follows:

[0165] When the clipping precision is 8-bit signed numbers, since the coordinates of the contour points will be clipped into 8-bit signed x- and y-coordinates, only 4 bits need to be reserved for the flag of each contour point, i.e. bit0 indicates whether it is on the curve, bit1 indicates the compression attribute of the flag, bit2 and bit3 indicate the compression attributes of the x- and y-coordinates respectively.

[0166] The decompressed 16-bit signed x-coordinate and y-coordinate are clipped to 8-bit signed coordinates. The discarded precision bits are the bits of the coordinate information arithmetic right shift. The discarded precision bits are obtained by subtracting 7 from the number of bits of the font unit unitsPerEm (units per character frame). For example, when unitsPerEm (units per character frame) is 1024, the corresponding number of bits is 10 bits, minus 7, which is 3 bits. The coordinates of all contour points are arithmetic right shifted 3 bits; finally, 8-bit signed x-coordinates and y-coordinates are obtained. The storage structure of flag before and after clipping is referenced in Figure 5 . And the compression attribute flag of the coordinates in flag may change, because some coordinates become compressible after arithmetic shift from incompressible, and a series of consecutive identical contour points can be directly clipped, leaving only one contour point.

[0167] refer to Figure 5 , Figure 5 The storage structure when clipping with 8-bit precision is shown. Before clipping, flag[n] is 8 bits, including the following bits: bit0 indicates On Curve, bit1 indicates x-Short Vector, bit2 indicates y-Short Vector, bit3 indicates Repeat, bit4 indicates This x is same, bit5 indicates This y is same, and bit6 and bit7 are Reserved.

[0168] After trimming, flag[n] and flag[n+1] are both 4 bits, including the following bits: bit0 indicates OnCurve, bit1 indicates Repeat, bit2 indicates This x is same, and bit3 indicates This y issame.

[0169] When the clipping precision is 10-bit signed numbers, the coordinates of the contour points will be clipped into 10-bit signed x- and y-coordinates. For each contour point, 8 bits of flag need to be reserved, that is, bit0 indicates whether it is on the curve, bit1 indicates the compression attribute of the flag, bit2 and bit3 indicate the compression attributes of the x- and y-coordinates, respectively, bit4 and bit5 indicate the upper two bits of the 10-bit signed x-coordinate, and bit6 and bit7 indicate the upper two bits of the 10-bit signed y-coordinate. For reference, the storage structure of flag and x- and y-coordinates before and after clipping Figure 6 When the x-coordinate and y-coordinate have compression attributes, the upper two bits of the x-coordinate and y-coordinate in the flag become invalid.

[0170] refer to Figure 6 , Figure 6The storage structure when clipping with 10-bit precision is shown. Flag[n] is 8 bits, including the following bits: bit0 indicates On Curve, bit1 indicates Repeat, bit2 indicates This x is same, bit3 indicates This y is same, bit4 indicates x[8], bit5 indicates x[9], bit6 indicates y[8], and bit7 indicates y[9].

[0171] x[n] is 10 bits, including the following bits: bit0: x[0], bit1: x[1], bit2: x[2], bit3: x[3], bit4: x[4], bit5: x[5], bit6: x[6], bit7: x[7], bit8: x[8], bit9: x[9].

[0172] y[n] is 10 bits, including the following bits: bit0: y[0], bit1: y[1], bit2: y[2], bit3: y[3], bit4: y[4], bit5: y[5], bit6: y[6], bit7: y[7], bit8: y[8], bit9: y[9].

[0173] When the clipping precision is a 6-bit signed number, the coordinates of the contour points will be clipped into 6-bit signed x- and y-coordinates. For each contour point, the flag also needs to retain 8 bits, but compared with the 10-bit precision, bit4 and bit5 represent the upper two bits of the 6-bit signed x-coordinate, and bit6 and bit7 represent the upper two bits of the 6-bit signed y-coordinate. The decompressed 16-bit or 8-bit signed x- and y-coordinates will be arithmetically right-shifted to a 6-bit signed number. After the upper two bits are stored in the flag of the contour point, the x- and y-coordinates only need to store the remaining lower four bits of data. For reference, see the storage structure of the flag and the x- and y-coordinates before and after clipping. Figure 7 Similarly, when the x-coordinate and y-coordinate have compression attributes, the upper two bits of the x-coordinate and y-coordinate in the flag are invalid.

[0174] refer to Figure 7 , Figure 7The storage structure when clipping with 6-bit precision is shown. Flag[n] is 8 bits, including the following bits: bit0 indicates On Curve, bit1 indicates Repeat, bit2 indicates This x is same, bit3 indicates This y is same, bit4 indicates x[4], bit5 indicates x[5], bit6 indicates y[4], and bit7 indicates y[5].

[0175] x[n] is 6 bits, including the following bits: bit0: x[0], bit1: x[1], bit2: x[2], bit3: x[3], bit4: x[4], bit5: x[5].

[0176] y[n] is 6 bits, including the following bits: bit0: y[0], bit1: y[1], bit2: y[2], bit3: y[3], bit4: y[4], bit5: y[5].

[0177] Where x represents the x-coordinate, y represents the y-coordinate, and n represents the sequence number.

[0178] Step S3: Generation of the original font library. The contour point data is compressed again, and a new glyf (font) table is recombined after compression. A new font index mapping table loca (position) table is regenerated according to the offset address of each font data in the glyf (font) table; the original cmap (character mapping) table is retained; the table storing the measurement information is also arithmetic right-shifted by the same length as the contour point coordinates, where unitsPerEm (number of units per font) corresponds to 32, 128 and 512 respectively according to the clipping accuracy.

[0179] 3. Core points:

[0180] By cropping the font library in the above way, the demand for scaling the font glyph within a certain range is guaranteed, and the appropriate cropping precision can be selected according to the scene requirements to reduce the storage resource requirements of the font library file, so that the resource-constrained embedded system can support the complete glyph font library. In this application example, different cropping precisions have different savings on storage resource consumption. Compared with the cropping precision of 8-bit signed number precision, the original 16-bit precision step value will be cropped to 8 bits, and the original 8-bit precision step value may be directly eliminated, leaving only flag information, and the original 8-bit length flag will also be cropped to 4 bits. Ideally, a contour point requires 5 bytes, and only 2.5 bytes are required after 8-bit precision cropping, and only 2 bytes and 3 bytes are required after 6-bit and 10-bit precision cropping respectively. For more complex and higher precision font files, the storage resource saving effect of this cropping method will be more obvious.

[0181] 4. Changes in thinking:

[0182] Compared with the traditional way of cropping fonts, this method can retain the paths of all glyphs to the greatest extent. For example, the measurement unit of the original font may be 2048, and after cropping, only the path of size 128 can be displayed at most. The advantage is that the characteristics of the vector font are still retained, and there is no blur problem when scaling. The limitation is that cropping reduces the original accuracy of the font. However, this limitation is acceptable in lightweight systems. Since the resolution of embedded screen devices is not high, and also because of resource constraints, the typical value of 480×800 resolution is already a relatively extreme screen situation. There is almost no chance to display a font size larger than 512, and most font sizes will be displayed below 64.

[0183] The technical solution provided in this application example retains the glyph data of all characters in the font library by cropping the extra precision of the complete vector font library, such as the differences in the glyph contours of different handwriting styles in the Chinese font library; and has the opportunity to reduce storage consumption by more than 50% for high-precision font files, ensuring the integrity requirements of font files and the flexible scaling of text in resource-limited embedded systems.

[0184] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0185] Based on the same inventive concept, the embodiment of the present application also provides a vector font library clipping device for implementing the vector font library clipping method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more vector font library clipping device embodiments provided below can refer to the limitations of the vector font library clipping method above, and will not be repeated here.

[0186] In an exemplary embodiment, Figure 8 As shown, a vector font library cutting device is provided, and the vector font library cutting device 800 may include:

[0187] The data acquisition module 801 is used to acquire the original font outline point data of the character from the original vector font library; the original font outline point data includes original coordinate data and original mark data;

[0188] The data clipping module 802 is used to perform a bit clipping process on the original coordinate data according to a preset clipping precision to obtain clipped coordinate data, and to perform a bit function update process on the original mark data according to the clipping precision to obtain updated mark data;

[0189] The data combination module 803 is used to combine the clipped coordinate data and the updated mark data to obtain clipped glyph outline point data corresponding to the original glyph outline point data;

[0190] The character library generation module 804 is used to generate a cropped vector character library corresponding to the original vector character library according to the cropped character outline point data.

[0191] In an exemplary embodiment, the data cropping module 802 is also used to perform bit update processing on the original logo data according to the cropping accuracy to obtain the logo data after the bit number is updated; perform bit function update processing on the preset bits in the logo data after the bit number is updated according to the cropping accuracy to obtain the logo data after the bit number is updated; perform data update processing on the logo data after the bit number is updated according to the coordinate data after cropping to obtain the updated logo data.

[0192] In an exemplary embodiment, the data clipping module 802 is further used to determine the to-be-clipped bits corresponding to the original mark data according to the clipping precision; and to perform bit clipping processing on the original mark data according to the to-be-clipped bits to obtain the mark data with updated bit numbers.

[0193] In an exemplary embodiment, the device 800 also includes: a data updating module, which is used to detect overlapping contour points in the cropped coordinate data; overlapping contour points include completely overlapping contour points and partially overlapping contour points; partial overlap includes overlapping of first coordinate data or overlapping of second coordinate data; for each group of completely overlapping contour points, retaining the mark data and coordinate data of one contour point in each group of completely overlapping contour points, and deleting the mark data and coordinate data of the remaining contour points in each group of completely overlapping contour points; for each group of partially overlapping contour points, updating the coordinate compression attribute bit in the mark data of each group of partially overlapping contour points, and compressing the mark data of each group of partially overlapping contour points according to the updated coordinate compression attribute bit.

[0194] In an exemplary embodiment, the data clipping module 802 is further used to determine the number of displacement operation bits corresponding to the original coordinate data according to the clipping accuracy; perform a right shift operation corresponding to the number of displacement operation bits on the original coordinate data to obtain clipped coordinate data.

[0195] In an exemplary embodiment, the font generation module 804 is also used to compress the cropped glyph outline point data to obtain compressed glyph outline point data; generate a corresponding new glyph data table based on the compressed glyph outline point data; generate a corresponding new glyph index mapping table based on the new glyph data table; generate a cropped vector font based on the new glyph data table and the new glyph index mapping table.

[0196] In an exemplary embodiment, the font generation module 804 is also used to update the original measurement information of the original vector font library according to the cropping accuracy to obtain the updated measurement information corresponding to the original vector font library; the new glyph data table, the new glyph index mapping table, the updated measurement information and the character mapping table of the original vector font library are combined and processed to obtain the cropped vector font library.

[0197] In an exemplary embodiment, the data acquisition module 801 is also used to search for glyph index information corresponding to the character encoding of the character from the character mapping table of the original vector font library; obtain the offset address corresponding to the glyph index information from the glyph index mapping table of the original vector font library; obtain the glyph path compression information corresponding to the offset address from the glyph data table of the original vector font library; and decompress the glyph path compression information to obtain the original glyph contour point data of the character.

[0198] Each module in the above-mentioned vector font library cutting device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module above.

[0199] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Fig. 9 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a vector font library cutting method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.

[0200] Those skilled in the art will understand that Fig. 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0201] In an exemplary embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0202] In an exemplary embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0203] In an exemplary embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0204] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0205] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0206] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A vector font library clipping method, characterized in that: The method comprises: Acquire original glyph contour point data of the character from the original vector character library; the original glyph contour point data includes original coordinate data and original mark data; the original mark data includes information indicating whether the contour point is on a curve and coordinate compression attributes; According to a preset clipping precision, the original coordinate data is subjected to a bit clipping process to obtain clipped coordinate data, and according to the clipping precision, the original mark data is subjected to a bit function update process to obtain updated mark data; the clipping precision includes a 10-bit signed number precision, an 8-bit signed number precision or a 6-bit signed number precision; the bit clipping process means a process of reducing the number of bits of the original coordinate data; Combining the clipped coordinate data and the updated mark data to obtain clipped glyph outline point data corresponding to the original glyph outline point data; A cropped vector font library corresponding to the original vector font library is generated according to the cropped glyph outline point data.

2. The method according to claim 1, characterized in that The step of performing bit function update processing on the original mark data according to the cropping accuracy to obtain updated mark data includes: According to the clipping precision, the original logo data is processed for bit updating to obtain logo data after bit updating; According to the clipping precision, performing a bit function update process on a preset bit in the flag data after the bit number is updated, to obtain the flag data after the bit function is updated; According to the clipped coordinate data, data updating processing is performed on the flag data after the bit function is updated to obtain the updated flag data.

3. The method according to claim 2, characterized in that The step of performing a bit updating process on the original logo data according to the clipping precision to obtain the logo data after the bit is updated comprises: According to the cropping precision, determining the to-be-cropped position corresponding to the original mark data; According to the to-be-cropped bits, the original flag data is subjected to a bit-cropping process to obtain the flag data after the bit-number is updated.

4. The method according to claim 2, characterized in that: The method further comprises: Detecting overlapping contour points in the clipped coordinate data; the overlapping contour points include completely overlapping contour points and partially overlapping contour points; the partial overlap includes overlapping of the first coordinate data or overlapping of the second coordinate data; For each group of completely overlapping contour points, retain the mark data and coordinate data of one contour point in each group of completely overlapping contour points, and delete the mark data and coordinate data of the remaining contour points in each group of completely overlapping contour points; For each group of partially overlapping contour points, the coordinate compression attribute bit in the mark data of each group of partially overlapping contour points is updated, and the mark data of each group of partially overlapping contour points is compressed according to the updated coordinate compression attribute bit.

5. The method according to claim 1, characterized in that The method of performing a digit clipping process on the original coordinate data according to a preset clipping precision to obtain clipped coordinate data includes: Determine the number of displacement operation bits corresponding to the original coordinate data according to the clipping precision; The original coordinate data is subjected to a right shift operation corresponding to the number of bits of the shift operation to obtain the clipped coordinate data.

6. The method according to claim 1, characterized in that The step of generating a cropped vector font library corresponding to the original vector font library according to the cropped glyph outline point data comprises: Compressing the clipped glyph outline point data to obtain compressed glyph outline point data; Generate a corresponding new font data table according to the compressed font outline point data; Generate a corresponding new glyph index mapping table according to the new glyph data table; The cropped vector font library is generated according to the new font data table and the new font index mapping table.

7. The method according to claim 6, characterized in that The step of generating the clipped vector font library according to the new font data table and the new font index mapping table comprises: According to the clipping precision, the original measurement information of the original vector character library is updated to obtain updated measurement information corresponding to the original vector character library; The new glyph data table, the new glyph index mapping table, the updated metric information and the character mapping table of the original vector font library are combined and processed to obtain the cropped vector font library.

8. The method according to any one of claims 1 to 7, characterized in that The step of obtaining the original glyph contour point data of the character from the original vector character library includes: Searching for glyph index information corresponding to the character code of the character from the character mapping table of the original vector character library; Obtaining an offset address corresponding to the glyph index information from a glyph index mapping table of the original vector font library; Acquire the glyph path compression information corresponding to the offset address from the glyph data table of the original vector font library; The glyph path compression information is decompressed to obtain original glyph outline point data of the character.

9. A vector font library cutting device, characterized in that: The device comprises: A data acquisition module, used to acquire original glyph contour point data of a character from an original vector character library; the original glyph contour point data includes original coordinate data and original mark data; the original mark data includes information indicating whether the contour point is on a curve and coordinate compression attributes; A data clipping module, used for performing a bit clipping process on the original coordinate data according to a preset clipping precision to obtain clipped coordinate data, and performing a bit function update process on the original mark data according to the clipping precision to obtain updated mark data; the clipping precision includes 10-bit signed number precision, 8-bit signed number precision or 6-bit signed number precision; the bit clipping process means performing a bit reduction process on the original coordinate data; A data combination module, used for combining the clipped coordinate data and the updated mark data to obtain clipped glyph outline point data corresponding to the original glyph outline point data; The character library generation module is used to generate a cropped vector character library corresponding to the original vector character library according to the cropped character outline point data.

10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.

12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Method for accessing stroke vector font

    CN101957837A