Word stock generation method based on Chinese character stroke component
By disassembling and mobile Chinese strokes, the new glyphs are generated and new font libraries are formed, which solves the problem of low efficiency of hand -modified strokes in existing technologies, and realizes efficient Chinese characters.
Patent Information
- Application Number
- CN202411486667.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-23
- Publication Date
- 2025-01-21
AI Technical Summary
The existing Chinese character font library generation method relies on manual modification of strokes, resulting in high time and labor costs and low efficiency.
By selecting Chinese characters from a vector font, splitting strokes to construct stroke components, moving these components to generate new glyphs, and finally processing all Chinese characters to generate a new font.
The efficiency of the Chinese character library generated has been improved, and time and human cost are significantly reduced. At the same time, the visual effects of the new glyphs are ensured through overlapping judgment and processing.
Smart Images

Figure CN119339395A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Chinese character processing, and particularly to a font library generation method based on Chinese character stroke components. Background Art
[0002] There are relatively few existing Chinese character font library generation methods. For example, in reference [1] (Qi W F, Guo W, Zhang T, et al. Robust authentication for paper-based text documents based on text watermarking technology[J]. Mathematical Biosciences and Engineering: MBE, 2019, 16(4): 2233-2249), a manual modification method is adopted to translate a certain stroke of a Chinese character to generate a new glyph.
[0003] For example, Figure 1 for the Chinese character "qing" in, a new glyph with a slight difference from the original is generated by modifying a single stroke therein.
[0004] Due to the relatively complex structure of Chinese characters and the large scale of the font library, generating new glyphs by manually modifying strokes will consume more time and labor costs and have low efficiency. Summary of the Invention
[0005] The purpose of the present invention is to provide a font library generation method based on Chinese character stroke components.
[0006] The technical solution for achieving the purpose of the present invention is as follows:
[0007] A font library generation method based on Chinese character stroke components includes:
[0008] Step 1, select any Chinese character from a vector font library;
[0009] Step 2, split the Chinese character strokes and construct stroke components;
[0010] Step 3, move the stroke components to form a new Chinese character glyph;
[0011] Step 4, process all Chinese characters in the vector font library according to the methods of Steps 1-3 to generate a new font library.
[0012] Further, the Step 2 includes:
[0013] 2.1 Obtain the curve control points of each stroke of the Chinese character:
[0014] The i-th stroke P of the Chinese character iThere are r curve control points, and the coordinate set of r curve control points is C i =(x1,y1),(x2,y2),(x3,y3),...,(x r ,y r ), where x and y represent the horizontal and vertical coordinates of the control point respectively;
[0015] 2.2 Get the coordinate closed area of each stroke of Chinese characters:
[0016] Stroke P i The r curve control points are connected in sequence by straight lines to obtain the stroke P i The coordinates of the closed area S i ;
[0017] 2.3 For example, the stroke P i The coordinates of the closed area S i , and the coordinate closed area of each other stroke does not overlap, then the stroke P i Constructed as a stroke component; such as stroke P i The coordinates of the closed area S i , and the stroke P j The coordinates of the closed area S j If there is overlap, then stroke P i and stroke P j Composition stroke component M k , that is, M k = {P i ,P j};
[0018] 2.4 The stroke component M k The curve control points are connected by straight lines in sequence to obtain the stroke component M k The coordinates of the closed area S k ;
[0019] 2.5 Such as stroke component M k The coordinates of the closed area S k , except for the stroke P i , stroke P j The coordinate closed areas of each other stroke except k Complete the construction;
[0020] Such as stroke component M k The coordinates of the closed area S k , and the stroke P l The coordinates of the closed area S l If there is overlap, then stroke P i , stroke P j and stroke P l Composition stroke component Mk , that is, M k = {P i ,P j ,P l}; And so on, until the stroke component M k Complete the construction.
[0021] Furthermore, the set of stroke components of Chinese characters constructed in step 2 is {M k,i |i=1,2,..,m}, m represents the number of stroke components of the Chinese character; the stroke component M k,i The curve control points are connected by straight lines in sequence to obtain the stroke component M k,i The coordinates of the closed area S k,i ; Stroke component M k,i The coordinates of the closed area S k,i The number of curve control points k i =len(M k,i );
[0022] The step 3 comprises:
[0023] 3.1 Select the number of curve control points k i The smallest stroke component M k,i , as the target stroke component;
[0024] 3.2 Set the moving offset offset; move the target stroke component up, down, left or right to obtain the moved stroke component M k,i ′, whose coordinate enclosed area is S k,i '; wherein, moving upward means: increasing the vertical coordinate of the curve control point of the coordinate closed area of the target stroke component by the moving offset offset; moving downward means: decreasing the vertical coordinate of the curve control point of the coordinate closed area of the target stroke component by the moving offset offset; moving left means: decreasing the horizontal coordinate of the curve control point of the coordinate closed area of the target stroke component by the moving offset offset; moving right means: increasing the horizontal coordinate of the curve control point of the coordinate closed area of the target stroke component by the moving offset offset;
[0025] 3.3 The target stroke component M after moving k,i ′, whose coordinates enclose the area S k,i ′, and the coordinate closed area of each other stroke component does not overlap, then the new Chinese character shape composed of the moved target stroke component and all other stroke components; k,i ′, whose coordinates enclose the area S k,i ′, and any other stroke component M k,j The coordinates of the closed area S k,jIf there is overlap, reset the movement offset, and then move the target stroke component up, down, left or right again. The re-moved target stroke component and all other stroke components form a new Chinese character shape.
[0026] Furthermore, the reset movement offset offset is specifically: the reset movement offset offset′ is one quarter of offset; and also includes bolding the re-moved target stroke component, and forming a new Chinese character shape with the bolded target stroke component and all other stroke components.
[0027] Compared with the prior art, the beneficial effect of the present invention is that after splitting the strokes of Chinese characters to construct stroke components, the stroke components are moved to generate new glyphs, thereby improving the generation efficiency of the Chinese character library. The present invention also determines whether the stroke components overlap after being moved and performs corresponding processing to ensure the visual effect of the new glyph. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 An example diagram of generating new glyphs using the existing technology, where (a) is the original glyph and (b) is the new glyph.
[0029] Figure 2 It is a flow chart of the present invention.
[0030] Figure 3 These are example diagrams of Chinese character glyphs, stroke components, and strokes.
[0031] Figure 4 Examples of target stroke components and non-target stroke components.
[0032] Figure 5 This is an example of a target stroke component overlapping with other stroke components after being moved.
[0033] Figure 6 Move the example image up and down for the target stroke component.
[0034] Figure 7 Move the sample image left or right for the target stroke component.
[0035] Figure 8 The following are examples of the original glyph and the new glyph. (a) is the original glyph, and (b) is the new glyph. DETAILED DESCRIPTION
[0036] The present invention provides a method for generating a character library based on Chinese character stroke components. First, Chinese characters in an original character library are obtained from an existing vector character library as basic data. Subsequently, the strokes of the Chinese characters are split by a closed polygon common area algorithm, and independent stroke components are formed by the algorithm. After that, the stroke components are moved in a predetermined direction to generate Chinese characters with slightly different glyphs from the original character library; finally, the generated new Chinese characters are formed into a new character library file.
[0037] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments.
[0038] The process of the present invention is as follows Figure 2 shown.
[0039] The specific embodiments are as follows:
[0040] 1. Obtaining the original font file
[0041] First, obtain the original font file from an existing vector font library (such as TrueType). The font file contains standard Chinese character vector outline information, including the stroke arrangement and structure of each Chinese character. This original font file serves as the basic data source for subsequent processing.
[0042] 2. Split the glyph into stroke components based on the common area of the closed polygon
[0043] Compared with the glyphs of other languages, Chinese characters have unique morphological and structural characteristics. Each stroke is regarded as the smallest component unit of a Chinese character, and multiple strokes of a specific pattern together constitute a Chinese character. Since the strokes of a Chinese character may overlap, the present invention regards a single stroke that is not connected to other strokes, or multiple strokes that are connected to other strokes, as a stroke component. Figure 3 , showing examples of glyphs, stroke components, and individual strokes. Figure 6 In , individual strokes that are not connected to other strokes are also shown and are considered stroke components.
[0044] Each Chinese character in the TrueType font library is described by a vector outline, which is usually composed of Bezier curves and straight line segments. The first step of splitting is to extract the vector outline of the Chinese character from the font file, including determining the starting point, end point, control point of the curve, etc. of each stroke.
[0045] After extracting the outline, it is necessary to identify the outline of each stroke. The overlapping parts of the curve control points of each stroke are regarded as a set of stroke components. The steps are as follows:
[0046] Step 1. Get the curve control point set of each stroke. Suppose each stroke P of a Chinese character i The control point coordinate set is C i , its Ci =(x1,y1),(x2,y2),(x3,y3),...,(x r ,y r ). Where r represents the coordinate control point P i The number of .
[0047] Step 2. Connect the control points of each stroke with a straight line so that each stroke corresponds to a closed area S i , the area is composed of the stroke control point coordinates C i composition.
[0048] Step 3. If the stroke P i The coordinates of the closed area S i , and the coordinate closed area of each other stroke does not overlap, then this single stroke P i is considered as a stroke component; if the stroke P i The coordinates of the closed area S i , and the stroke P j The coordinates of the closed area S j There is overlap, then the stroke P i and stroke P j The stroke component M is formed k , denoted as M k = {P i ,P j}. To determine whether the strokes overlap, the following method can be used: for any stroke P i With P j , calculate the corresponding closed area S i and S j The intersection of; Determine whether the closed area intersection is empty, if Then area S i and S j There is an intersection, the intersection area S i ∩S j Indicates S i and S j Overlapping parts.
[0049] Step 4. Get M k Then perform the same intersection operation with other strokes until the intersection with other strokes is an empty set.
[0050] After performing the same processing on each stroke of a Chinese character, the Chinese character is finally split into stroke components.
[0051] 3. Filter the target stroke components that need to be moved
[0052] Step 1. For a Chinese character, split it into two parts to get a set of stroke components {M k,i|i=1,2,..,m}, m represents the number of stroke components of the Chinese character.
[0053] Step 2. For each stroke component M k,i , the number of control points k in the closed region of its coordinates i =len(M k,i ).
[0054] Step 3. Take the minimum value n of the number of coordinate control points in all stroke components, that is, n = min{ k i}.
[0055] Step 4. If the stroke component M k,i The number of coordinate control points k i >n, then M k,i No need to move; if the stroke component M k,i The number of coordinate control points k i =n, then M k,i The target stroke component that needs to be moved.
[0056] Through the above steps, the target stroke components that need to be moved can be screened out.
[0057] 4. Move stroke components to form new glyphs
[0058] First, connect each stroke component with a straight line according to the coordinates of the control points to form a closed polygon, such as Figure 4 As shown, it can be represented as a closed polygon S k,j ={S1,S2,S3,..,S k ,...,S m}. Next, set the moving direction (up, down, left, right) and the offset of the movement.
[0059] Step 1. Taking the upward movement direction of the target stroke component as an example, the coordinate control point set of the target component is:
[0060] Si={(x1,y1),(x2,y2),…,(x n ,y n )}
[0061] Step 2. According to the set offset, the movement operation of the stroke component is to increase the y coordinates of all coordinate points in the target stroke component by the offset, that is:
[0062] Si′={(x1,y1+offset),(x2,y2+offset),…,(x n ,y n +offset)}
[0063] During the movement process, in order to avoid the overlap between stroke components due to the movement and affect the visual quality of the generated new glyph, it is determined whether the closed polygon area after the movement has a common area, thereby determining whether the target stroke component after the movement overlaps with other stroke components. Figure 5 shown.
[0064] In order to solve the possible overlap problem after the strokes are moved, the following steps are proposed:
[0065] Step 3: The target stroke component M after moving k,i ′, whose coordinates enclose the area S k,i ′, and any other stroke component M k,j The coordinates of the closed area S k,j There is overlap, represented by:
[0066]
[0067] Step 4. If the target component is determined to overlap according to Step 3, move the target stroke component by offset / 4 and make the target component bold. The new move operation is:
[0068]
[0069] And the stroke component is made bolder, that is, the line width of the component outline is increased.
[0070] like Figure 6 and Figure 7 As shown, the movement is successful and the offset is reduced and they are bolded.
[0071] Figure 8 The comparison between the new glyph generated by the present invention and the original glyph is shown, wherein (a) is the original glyph and (b) is the new glyph.
[0072] The present invention can efficiently generate new Chinese character font files, significantly reducing time and labor costs.
Claims
1. A method for generating a character library based on Chinese character stroke components, characterized in that: include: Step 1, select any Chinese character from the vector character library; Step 2, split the Chinese character strokes and construct stroke components; Step 3, move the stroke components to form a new Chinese character shape; Step 4: Process all Chinese characters in the vector character library according to the method of steps 1-3 to generate a new character library.
2. The method for generating a character library based on Chinese character stroke components as claimed in claim 1, characterized in that: The step 2 comprises: 2.1 Get the curve control points of each stroke of Chinese characters: The i-th stroke P of a Chinese character i There are r curve control points, and the coordinate set of r curve control points is C i =(x1, y1), (x2, y2), (x3, y3),..., (x r ,y r ), where x and y represent the horizontal and vertical coordinates of the control point respectively; 2.2 Get the coordinate closed area of each stroke of Chinese characters: Stroke P i The r curve control points are connected in sequence by straight lines to obtain the stroke P i The coordinates of the closed area S i ; 2.3 For example, the stroke P i The coordinates of the closed area S i , and the coordinate closed area of each other stroke does not overlap, then the stroke P i Constructed as a stroke component; such as stroke P i The coordinates of the closed area S i , and the stroke P j The coordinates of the closed area S j If there is overlap, then stroke P i and stroke P j Composition stroke component M k , that is, M k = {P i , P j }; 2.4 The stroke component M k The curve control points are connected by straight lines in sequence to obtain the stroke component M k The coordinates of the closed area S k ; 2.5 Such as stroke component M k The coordinates of the closed area S k , except for the stroke P i , stroke P j The coordinate closed areas of each other stroke except k Complete the construction; Such as stroke component M k The coordinates of the closed area S k , and the stroke P l The coordinates of the closed area S l If there is overlap, then stroke P i , stroke P j and stroke P l Composition stroke component M k , that is, M k = {P i , P j , P l }; And so on, until the stroke component M k Complete the construction.
3. The method for generating a character library based on Chinese character stroke components as claimed in claim 1 or 2, characterized in that: The set of stroke components of Chinese characters constructed in step 2 is {M k,i |i=1,2,…,m}, m represents the number of stroke components of the Chinese character; k,i The curve control points are connected by straight lines in sequence to obtain the stroke component M k,i The coordinates of the closed area S k,i ; Stroke component M k,i The coordinates of the closed area S k,i The number of curve control points k i =len(M k,i ); The step 3 comprises: 3.1 Select the number of curve control points k i The smallest stroke component M k,i , as the target stroke component; 3.2 Set the moving offset offset; move the target stroke component up, down, left or right to obtain the moved stroke component M k,i ′, whose coordinate enclosed area is S k,i '; wherein, moving upward means: increasing the vertical coordinate of the curve control point of the coordinate closed area of the target stroke component by the moving offset offset; moving downward means: decreasing the vertical coordinate of the curve control point of the coordinate closed area of the target stroke component by the moving offset offset; moving left means: decreasing the horizontal coordinate of the curve control point of the coordinate closed area of the target stroke component by the moving offset offset; moving right means: increasing the horizontal coordinate of the curve control point of the coordinate closed area of the target stroke component by the moving offset offset; 3.3 The target stroke component M after moving k,i ′, whose coordinates enclose the area S k,i ′, and the coordinate closed area of each other stroke component does not overlap, then the new Chinese character shape composed of the moved target stroke component and all other stroke components; k,i ′, whose coordinates enclose the area S k,i ′, and any other stroke component M k,j The coordinates of the closed area S k,j If there is overlap, reset the movement offset, and then move the target stroke component up, down, left or right again. The re-moved target stroke component and all other stroke components form a new Chinese character shape.
4. The method for generating a character library based on Chinese character stroke components as claimed in claim 3, characterized in that: The resetting of the movement offset offset specifically includes: resetting the movement offset offset' to one quarter of offset; and also includes bolding the re-moved target stroke component, and forming a new Chinese character shape with the bolded target stroke component and all other stroke components.