A font generation method and device, an electronic device, and a readable storage medium

CN116681581BActive Publication Date: 2026-10-30NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310571302.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-17
Publication Date
2026-10-30
Estimated Expiration
2043-05-17

AI Technical Summary

Technical Problem

[0004]但是,上述方式在提取风格特征时主要从参考字图像的整体中提取风格特征,这样提取到的风格特征主要体现在字符的全局风格,对于字符部件的细节的风格特征表现力不足,即,生成目标字符的效果较差

Benefits of technology

[0024]与现有技术相比,本申请具有以下优点:通过本申请提供的字体生成方法,可以将待生成为目标字体风格的源字符拆分为源部件,并将所述源部件在所述源字符中的位置确定为源位置,然后,可以从具有目标字体风格的多个参考字中,确定包括源部件的内容参考字,并将源部件在内容参考字中的位置确定为参考位置。在确定出上述源位置和参考位置之后,可以从多个参考字中确定同时包含有相同的目标部件且该相同的目标部件分别位于源位置和参考位置的形变参考字对。即,形变参考字对中的字符拥有相同的目标部件,且该目标部件位于形变参考字对中一个字符的参考位置,另一个字符的源位置。进一步的,可以确定第一部件从参考位置变换到源位置所对应的形变映射关系,第一部件可以是源部件或者目标部件。该形变映射关系可以实现将第一部件位于参考位置的风格特征映射到其位于源位置时的风格特征。可以理解的是,对于拥有相同目标字体风格的不同部件,其在不同的字符中处于相同的位置时具有相似的风格特征,由此可知,第一部件从参考位置变换到源位置过程中的形变映射关系与源部件从参考位置变换到源位置过程中的形变映射关系相似。因此,通过提取源部件在内容参考字中的第一风格特征,并将上述形变映射关系作用于第一风格特征,可以将源部件在内容参考字中的第一风格特征映射为源部件在源位置对应的形变后风格特征;接下来,根据源字符的内容特征与源部件对应的形变后风格特征,生成具有目标字体风格的源字符。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116681581B_ABST
    Figure CN116681581B_ABST
Patent Text Reader

Abstract

The application discloses a font generation method and device and electronic equipment. The method comprises the following steps: splitting a source character to be generated into a source component and determining a source position; determining a content reference character comprising the source component from a plurality of reference characters with a target font style and determining a reference position; determining a deformation reference character pair from the plurality of reference characters, wherein the deformation reference character pair simultaneously contains the same target component, and the same target component is located at the source position and the reference position respectively; determining a deformation mapping relationship corresponding to the transformation of a first component from the reference position to the source position; extracting a first style feature of the source component in the content reference character and applying the deformation mapping relationship to the first style feature to obtain a deformed style feature corresponding to the source component; and generating the source character with the target font style according to the content feature of the source character and the deformed style feature corresponding to the source component. The method improves the target font style expressiveness of the character component and optimizes the target font style generation effect of the source character.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular, to a font generation method, apparatus, electronic device and computer-readable storage medium. Background Art

[0002] Text is ubiquitous in every part of modern life. People need to read a large amount of information disseminated through different media via text, and stylized text can often capture people's attention at the first moment, which has a wide range of applications in many visual creation tasks, such as posters, advertisements, virtual games and any other places where fonts need to be presented. Therefore, the stylized font design of text is of great importance.

[0003] At present, there are some strategies for font generation based on deep learning networks. For example, a style encoder is used to extract the style feature of a reference character from the entirety of the reference character image, a content encoder is used to extract the content feature of a source character from the source character image, and finally the style feature and the content feature are combined to generate the final target character that conforms to the style of the reference character and the content of the source character.

[0004] However, when extracting style features in the above manner, the style features are mainly extracted from the entirety of the reference character image, such that the extracted style features are mainly reflected in the global style of the character, and the expressiveness of the style features for the details of character components is insufficient, that is, the effect of generating the target character is poor. For example, if the source character is the regular script "ci", and the reference character is the boldface "jing", after the global style feature of the reference character "jing" is extracted in the above manner and combined with the content feature of the source character "ci", it is possible that the boldface style of the component "bei" in the boldface target character "ci" is not obvious or still in regular script, resulting in poor overall expressiveness of the boldface target character "ci". Summary of the Invention

[0005] The present application provides a font generation method, apparatus, electronic device and computer-readable storage medium. The method improves the expressiveness of the target font style of character components, and optimizes the generation effect of the target font style of the source character.

[0006] In a first aspect, an embodiment of the present application provides a font generation method, the method comprising:

[0007] splitting a source character to be generated into a target font style into source components, and determining the position of the source component in the source character as a source position;

[0008] determining a content reference character comprising the source component from a plurality of reference characters having the target font style, and determining the position of the source component in the content reference character as a reference position;

[0009] Determine from the plurality of reference words pairs that simultaneously contain the same target component, and the same target component is located at the source position and the reference position respectively;

[0010] Determine the deformation mapping relationship of the first component from the reference position to the source position; wherein the first component is the source component or the target component;

[0011] Extract the first style feature of the source component in the content reference word, and apply the deformation mapping relationship to the first style feature to obtain the deformed style feature corresponding to the source component;

[0012] Based on the content features of the source character and the deformed style features corresponding to the source component, the source character with the target font style is generated.

[0013] Secondly, embodiments of this application provide a font generation apparatus, which includes: a determining unit, a style feature mapping unit, and a generation unit;

[0014] The determining unit is used to split the source character to be generated as the target font style into source components, and determine the position of the source component in the source character as the source position;

[0015] The determining unit is further configured to determine, from a plurality of reference characters having the target font style, a content reference character including the source component, and to determine the position of the source component in the content reference character as a reference position;

[0016] The determining unit is further configured to determine from the plurality of reference words a pair of deformed reference words that simultaneously contain the same target component, and the same target component is located at the source position and the reference position respectively;

[0017] The determining unit is further configured to determine the deformation mapping relationship corresponding to the transformation of the first component from the reference position to the source position; wherein the first component is the source component or the target component;

[0018] The style feature mapping unit is used to extract the first style feature of the source component in the content reference word, and apply the deformation mapping relationship to the first style feature to obtain the deformed style feature corresponding to the source component.

[0019] The generation unit is used to generate the source character with the target font style based on the content features of the source character and the deformed style features corresponding to the source component.

[0020] Thirdly, embodiments of this application provide an electronic device, including:

[0021] Processor; and

[0022] The memory is used to store data processing programs, which, when the electronic device is powered on and run by the processor, execute the method as described in the first aspect.

[0023] Fourthly, embodiments of this application provide a computer-readable storage medium storing a data processing program that is executed by a processor to perform the method as described in the first aspect.

[0024] Compared with existing technologies, this application has the following advantages: The font generation method provided in this application can split source characters to be generated as the target font style into source components, and determine the position of the source component within the source character as the source position. Then, from multiple reference characters with the target font style, a content reference character including the source component can be determined, and the position of the source component within the content reference character can be determined as the reference position. After determining the source position and reference position, a deformable reference character pair can be determined from multiple reference characters that simultaneously contain the same target component, and the same target component is located at both the source position and the reference position. That is, the characters in the deformable reference character pair have the same target component, and the target component is located at the reference position of one character and the source position of another character in the deformable reference character pair. Furthermore, the deformable mapping relationship corresponding to the transformation of the first component from the reference position to the source position can be determined. The first component can be either a source component or a target component. This deformable mapping relationship can map the style features of the first component at the reference position to its style features at the source position. It is understandable that different components with the same target font style will have similar style features when they are in the same position in different characters. Therefore, the deformation mapping relationship of the first component transforming from the reference position to the source position is similar to that of the source component transforming from the reference position to the source position. Thus, by extracting the first style feature of the source component in the content reference character and applying the aforementioned deformation mapping relationship to the first style feature, the first style feature of the source component in the content reference character can be mapped to the deformed style feature of the source component at the source position. Next, based on the content features of the source character and the deformed style features of the corresponding source component, a source character with the target font style is generated.

[0025] As can be seen, the font generation method provided in this application can split the source character into source components and perform component-level style transfer on the source character. It can obtain the deformed style features corresponding to each source component, improve the expressiveness of the target font style of the character component, that is, improve the detail expression of the source character with the target font style, and optimize the generation effect of the source character with the target font style. Attached Figure Description

[0026] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0027] Figure 1 A flowchart illustrating an example of a font generation method provided in this application;

[0028] Figure 2 A schematic diagram of a reference character for the font generation method provided in the embodiments of this application;

[0029] Figure 3 A schematic diagram illustrating the positional mapping relationship between a reference position and a source position in a font generation method provided in an embodiment of this application;

[0030] Figure 4 This is a schematic diagram illustrating the component splitting and position encoding of a source character as an example of the font generation method provided in this application embodiment;

[0031] Figure 5 This is a schematic flowchart of an example of a font generation method provided in an embodiment of this application;

[0032] Figure 6 A schematic representation of an inverted index for a font generation method provided in an embodiment of this application;

[0033] Figure 7 This is a schematic diagram of the structure of the font generation method apparatus provided in the embodiments of this application;

[0034] Figure 8 This application provides a structural block diagram of an electronic device for generating fonts. Detailed Implementation

[0035] Many specific details are set forth in the following description to provide a full understanding of this application. However, this application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this application; therefore, this application is not limited to the specific embodiments disclosed below.

[0036] It should be noted that the terms "first", "second", "third" and the like in the claims, description and accompanying drawings of the present application are used to distinguish similar objects, and are not used to describe a specific sequence or order. The data used in this way are interchangeable under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than the content illustrated or described herein. In addition, the terms "comprising", "having" and their variants are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such process, method, product or device. It should be understood that in the embodiments of the present application, "at least one" refers to one or more, and "a plurality" refers to two or more than two. "And / or" only describes the association relationship between associated objects, indicating that there may be three relationships. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "Comprising A, B and / or C" means comprising any one, any two or all three of A, B and C.

[0037] It should be understood that in the embodiments of the present application, "B corresponding to A", "B that corresponds to A", "A corresponds to B" or "B corresponds to A" indicates that B is associated with A, and B can be determined according to A. Determining B according to A does not mean that B is determined only according to A, and B may also be determined according to A and / or other information.

[0038] Before describing the embodiments of the present application in detail, related technologies are first further introduced.

[0039] In related technologies, a content encoder is usually used to encode the character content in a source character image, and a style encoder is used to extract style features in a reference character image. Finally, the content encoding and the style encoding are combined to generate the final target character image. However, in the above method, when extracting style features, the style features are mainly extracted from the whole reference character image, so that the extracted style features are mainly reflected in the global style of the character, and the expressive force for the style features of the details of character components is insufficient, that is, the effect of generating the target character is poor. For example, the source character is the regular script "Ci", and the reference character is the boldface "Jing". The above method extracts the global style feature of the reference character "Jing", and after combining the global style feature with the content feature of the source character "Ci", for each component of the target boldface character "Ci", there may be a case where the boldface style of the component is not obvious or is still in regular script, resulting in poor overall expressive force of the target boldface character "Ci".

[0040] In addition, the related art further includes a method for performing mapping learning from a source domain image to a target domain image using an Image-to-image (I2I)-based method. This method uses an encoder-decoder structure to generate a target character image from a source character image. The encoder-decoder structure ensures that the content in the source character image remains unchanged (i.e., the character remains unchanged), and at the same time makes the character in the generated character image consistent in style with the reference character image. However, the I2I-based method is mainly designed for a single font generation task. That is, for each style of reference character, it is necessary to retrain the deep network to realize the transformation from the source font to the style of the reference font, which limits the efficiency of this method in practical use.

[0041] In view of the above existing problems, embodiments of the present application provide a font generation method, apparatus, electronic device, and computer-readable storage medium.

[0042] The font generation method provided in the embodiments of the present application may be executed by an electronic device, which may be a terminal, a server, or other equipment. The terminal may be a terminal device such as a smartphone, a tablet computer, or a laptop computer. The server may be an independent physical server, a server cluster or distributed system composed of a plurality of physical servers, or a cloud server that provides basic cloud computing services such as cloud service, cloud database, cloud computing, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN, and big data and artificial intelligence platforms. It is understandable that the present application does not specifically limit the execution subject that executes the font generation method.

[0043] Before introducing the font generation method provided by the present application in detail, related concepts of font generation are first introduced.

[0044] Character: In this embodiment, it refers to an individual text, which may include English letters, Chinese characters, Korean characters, and the like. This embodiment describes the method by taking Chinese characters as an example. For example, "Ci" can be regarded as a character.

[0045] Component: The basic structure constituting a character, which is a character-forming unit that can be independently written and is composed of more than one stroke. Components may include single components and combined components. A single component is a component that cannot be further split, and a combined component refers to a component composed of two or more single components. For example, "Ci" can be regarded as including three single components, namely "Bei", "Ri" and "Wu", or can be regarded as including one single component and one combined component, namely "Bei" and "Yi".

[0046] Single-component character: A character composed of a single single component is referred to as a single-component character, such as "Yue", "Mu" or "Er".

[0047] Combined character: A Chinese character formed by combining two or more single components is called a combined character. For example, "Ci" is composed of "Bei", "Ri" and "Wu"; "Yang" is composed of "He" and "Yang".

[0048] Character component structure: that is, the position structure of each single component of a character. Common position structures may include left-right structure, up-down structure, top-middle-bottom structure, left-middle-right structure, semi-enclosed structure, fully enclosed structure or special structure. For example, "Ta" is a left-right structure, "Hu" is a left-middle-right structure, "Li" or "Jia" is an up-down structure, "Si" or "Ting" is a semi-enclosed structure, "Hui" is a fully enclosed structure, and the special structure includes, for example, "Zuo", "Cheng", etc.

[0049] The so-called index is a structure that sorts the values of one or more columns in a database table. Using an index can quickly access specific information in the database table; the file that records the index information is an index file. For search engines, due to the huge search space, index files are very important. Generally, search engines will create indexes for all documents obtained by searching.

[0050] Inverted Index is a specific storage form for implementing the "word-document matrix". Through the inverted index, the list of documents containing a certain word can be quickly obtained according to the word. The inverted index is mainly composed of two parts: "word dictionary" and "inverted file".

[0051] Lexicon: The index unit of a search engine is usually a word. The word dictionary is a string set composed of all words that have appeared in the document collection. Each index entry in the word dictionary records some information of the word itself and a pointer pointing to the "posting list".

[0052] Posting List: The posting list records the document list of all documents in which a certain word has appeared and the position information of the word in the document. Each record is called a Posting. According to the posting list, it is possible to know which documents contain a certain word.

[0053] Inverted File: The posting lists of all words are often stored sequentially in a certain file on the disk, and this file is called an inverted file. The inverted file is a physical file that stores the inverted index.

[0054] Affine Transform is a transformation from an affine plane to itself, which can preserve the collinearity of points (Parallelism, that is, the relative positional relationship between two-dimensional graphics remains unchanged, parallel lines remain parallel, and the intersection angle of intersecting lines remains unchanged) and the parallelism of straight lines (Straightness, that is, arcs remain arcs and straight lines remain straight lines after transformation).

[0055] The technical solutions of the present application will be described in detail below through specific embodiments. It should be noted that the following several specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.

[0056] It can be understood that the characters or components involved in the embodiments of the present application all exist in the form of images. For example, a source character can be understood as a source character image, a source component can be understood as a source component image, and a reference character can be understood as a reference character image, etc.

[0057] First Embodiment

[0058] As Figure 1 shown in the figure, Figure 1 is an example flowchart of a font generation method provided by an embodiment of the present application. It should be noted that the illustrated steps may be executed in a logical order different from that shown in the method flowchart. The method may include the following steps S110 to S160.

[0059] Step S110: Split a source character to be generated into a target font style into source components, and determine the position of the source component in the source character as a source position.

[0060] This step S110 is used to obtain the source components and the source position, so as to prepare for the subsequent font style migration of the source components.

[0061] The above-mentioned source components are the component content obtained by splitting the source character. For example, if the source character is "Ci", 3 source components can be obtained after splitting, which are "Bei", "Ri" and "Wu" respectively.

[0062] It can be understood that in this embodiment, the source font style of the source character is not specifically limited, and it can be any style of font. The target font style can be any set font style. In the specific implementation process, it is only required that the source font style of the source character is inconsistent with the target font style. This embodiment takes the example that the source font style of the source character is GB regular script and the target font style is official script, that is, the font style of the source character is changed from GB regular script to official script.

[0063] In this embodiment, the above-mentioned source components may be all source components obtained by splitting the source character, or may be source components that are randomly screened from all the split source components and meet a preset quantity. The quantity of source components for executing the font generation method in this embodiment is not specifically limited. For example, if the source character is "Ci", three source components can be obtained after splitting, which are respectively "Bei", "Ri" and "Wu". In a specific implementation process, the above-mentioned source components may be the three source components, or when the preset quantity is 2, two source components may be randomly selected from the three source components to perform subsequent operations.

[0064] The position of the above-mentioned source component in the source character can be understood as the relative position of the source component in the source character. The relative position of the source component in the source character is determined as the source position. For example, for the source component "Bei" of the source character "Ci", the relative position of the source component "Bei" in the source character "Ci" is the left side of the left-right structure character, then the relative position of the left side of the left-right structure character can be determined as the source position.

[0065] In this embodiment, the above-mentioned source position may be a position code obtained by encoding the relative position of the source component in the source character. For a detailed introduction to the position code, reference may be made to subsequent specific embodiments. It can be understood that for different characters with the same character component structure, there is a case where the relative positions of different components in different characters are all source positions. For example, the character component structure of the character "Ci" is a left-right structure, the position of the component "Bei" in the character "Ci" is the left side of the left-right structure character, the character component structure of the character "Yang" is a left-right structure, and the position of the component "He" in the character "Yang" is the left side of the left-right structure character. Both the relative position of the component "He" in the character "Yang" and the relative position of the component "Bei" in the character "Ci" can be regarded as source positions. For the same component, its relative positions in characters with different character component structures may be different. For example, for the character "Jia" with an up-down structure, the relative position of the component "Bei" in the character "Jia" is the lower side, then the relative positions of the component "Bei" in the character "Ci" and the character "Jia" are different, "Bei" is located at the source position in "Ci", and is located at another position in "Jia".

[0066] When encoding the relative positions of components in characters, in view of the above situation, for different characters with the same character component structure, the position codes of different components included therein may be the same. For example, the position code of the above-mentioned component "Bei" in the character "Ci" is the same as the position code of the component "He" in the character "Yang", which indicates that the component "Bei" and the component "He" are located on the left side of the left-right structure character.

[0067] After obtaining the source component and the source position of the source character, a corresponding content reference character may be acquired from a given reference character set according to the source component. That is, the following step S120 is executed.

[0068] Step S120: From a plurality of reference characters having a target font style, determine a content reference character that includes a source component, and determine the position of the source component in the content reference character as a reference position.

[0069] The above-mentioned reference characters may be pre-set reference characters having the target font style. For example, in this embodiment, the font style of the reference characters is clerical script.

[0070] In this embodiment, the number of characters of the reference characters is not limited, which may include a small number of reference characters, or may include all different characters contained in a writing system. For example, the reference characters may include more than 6000 commonly used Chinese characters. Alternatively, with reference to Figure 2 , the reference characters with the clerical script font style include a small number of reference characters such as "Yang, Ca, Duo, Wu, Hu, Chuo, Jing". It can be understood that this is only an example, and is not a limitation on this embodiment.

[0071] The content reference character including the source component, for example, when the source components of the source character "Ci" include "Bei", "Ri" and "Wu", that is, the content reference character may include any reference character having components such as "Bei", "Ri" or "Wu", for example, the content reference characters corresponding to the source character "Ci" may include "Jia", "Yang" and "Hu".

[0072] It can be understood that one source component may correspond to at least one content reference character, and the number of content reference characters is not specifically limited in this embodiment. In the subsequent description of the method, description is made by taking that one source component corresponds to one content reference character as an example. Therefore, in this embodiment, the number of content reference characters corresponding to the source character depends on the number of the obtained source components.

[0073] It can be understood that the font style corresponding to the source component in the content reference character is the target font style. For example, the source character "Ci" is in GB regular script, and the target style font is clerical script, then the content reference characters corresponding to the source character are "Jia", "Yang" and "Hu" in clerical script.

[0074] After the content reference character is obtained, the position of the source component in the content reference character may be determined as the reference position, and the manner for determining the reference position may refer to the manner for determining the source position of the source component in the source character. For example, for the content reference character "Jia" corresponding to the source character "Ci", the position of the source component "Bei" in the content reference character "Jia" is the lower part of the character with an upper-lower structure, that is, the position of the lower part of the character with an upper-lower structure may be determined as the reference position.

[0075] In an optional embodiment, after the source position and the reference position are determined, it is further necessary to match the source position and the reference position, and different manners may be adopted to perform font style transformation of the source component according to different matching results. The matching result may include two cases: the source position is different from the reference position, or the source position is the same as the reference position. For example, the source component "bei" (shell) is located on the left side of the character "ci" (bestow). When the content reference character is "jia" (surname Jia), "bei" is located below the content reference character "jia", that is, the source position is different from the reference position. When the content reference character is "zeng" (present as a gift), "bei" is located on the left side of the content reference character "zeng", that is, the source position is the same as the reference position.

[0076] It should be noted that whether the reference position is the same as the source position does not affect the implementation of the method in this embodiment, which is only for illustrating different situations occurring when acquiring the content reference character, and is not a limitation to the present application. The process of performing font style transformation of the source component in these two cases is described below.

[0077] The first type: the source position is the same as the reference position.

[0078] When the electronic device detects that the source position where the source component is located is the same as the reference position, the style feature of the source component located at the reference position may be directly determined as the deformed style feature corresponding to the source component, and then step S160 is executed. For example, the source character is the character "ci" in GB regular script font, the source component is "bei", the source position is the left side of a left-right structured character, the content reference character is "zeng" in official script font, and the reference position of the source component "bei" in the character "zeng" is the left side of a left-right structured character, that is, the reference position is the same as the source position. Since components located at the same position have similar style features, the style feature corresponding to the source component "bei" located at the reference position in the content reference character "zeng" may be directly determined as the deformed style feature corresponding to the source component "bei" in the source character "ci". Certainly, in this embodiment, even if the source position is the same as the reference position, the deformed style feature corresponding to the source component may also be determined according to subsequent steps S130 to S150, so that the expression effect of the deformed style feature of the source component is better.

[0079] The second type: the source position is different from the reference position.

[0080] When the electronic device detects that the source position where the source component is located is different from the reference position, it may be understood that no content reference character with the source component at the source position is retrieved from the given reference characters. For example, the source character is "赐", and no content reference character that is a left-right structured character including the source component "贝" with the source component "贝" located on the left side of the left-right structured character is retrieved from the reference characters, that is, no content reference character that is a left-right structured character such as "赠" with "贝" on the left side is retrieved. In this case, the style feature of the source component in the content reference character cannot be directly used as the deformed style feature corresponding to the source component, and a certain deformation is required, that is, subsequent steps S130 to S160 need to be executed, which will be specifically described later and will not be repeated here.

[0081] Step S130: Determine a deformed reference character pair that both contains the same target component, and the same target component is located at the source position and the reference position respectively, from a plurality of reference characters.

[0082] This step S130 is used to determine the deformed reference character pair for subsequently learning the deformation mapping relationship.

[0083] In this embodiment, the aforementioned deformed reference character pair may include two deformed reference characters, the two deformed reference characters contain the same target component, and the target component is located at the source position and the reference position respectively. It should be noted that the target component is different from the source component, that is, it can be understood that the deformed reference character pair is determined from the remaining reference characters other than the reference characters containing the source component.

[0084] For example, the source character is "赐", the source component is "贝", and the reference characters may include "脆", "宵", "明", "芽" and "秧". As can be seen from the foregoing description, the source position is the left side of a character with a left-right structure, and the reference position is the lower part of a character with an up-down structure. Therefore, by determining the relative position of each component in the above reference characters in the corresponding reference character, and matching the relative position with the source position and the reference position, it can be judged whether each component of the above reference characters is located at the source position and the reference position, and the components located at the source position and the reference position are screened to obtain a deformation reference character pair. For example, the components located at the source position include "月", "贝", "日" and "禾", and the components located at the reference position include "月" and "牙". Since it is necessary to keep the content feature of the source component consistent when performing style feature deformation on the source component subsequently, in this step, the same component that can be located at both the source position and the reference position is determined as the target component. It can be seen that in the above example, the component that can be located at both the source position and the reference position is "月". In the above example, the character "脆", the character "宵" and the character "明" include the same component "月", the reference character corresponding to the component "月" being located at the source position is "脆", and the reference character corresponding to the component "月" being located at the reference position is "宵", so the character "脆" and the character "宵" can be determined as a deformation reference character pair. Since the position of the target component "月" in the character "明" is neither the source position nor the reference position, the character "明" cannot form a deformation reference character pair. As for the character "芽" and the character "秧", neither of them contains the same component as the characters such as "脆", "宵" and "明", so neither the character "芽" nor the character "秧" can be determined as a deformation reference character pair.

[0085] Step S140: determining a deformation mapping relationship corresponding to the transformation of the first component from the reference position to the source position.

[0086] The first component is a component with a target font style. It can be understood that the same component with the target font style has different forms at different positions, that is, when the reference position is different from the source position, the shape of the same component at the reference position is different from its shape at the source position. Therefore, the first component has a certain deformation when it is at different positions, and there is a deformation mapping relationship between the first components at different positions. For example, with reference to Figure 3 , for the character "脆" and the character "宵", when the first component "月" changes from the lower position of the character "宵" to the left position of the character "脆", the deformation mapping relationship thereof may be a mapping relationship changing from "short and plump" to "slender".

[0087] The above first component may be a source component or a target component. When the first component is a source component, this step may be expressed as determining a deformation mapping relationship corresponding to the transformation of the source component with the target font style from the reference position to the source position. For example, as in the aforementioned example, the source character is the national standard regular script "Ci", the source component is "Bei", the content reference character is the official script "Jia", the source position is the left side of the left-right structure character, and the reference position is the lower part of the top-bottom structure character, that is, the deformation mapping relationship for transforming the source component "Bei" from the lower part of the top-bottom structure character to the left side of the left-right structure character is determined. It can be understood that the top-bottom structure character and the left-right structure character herein are both characters with the target font style. For example, the top-bottom structure character is the official script "Yuan", and the left-right structure character is the official script "Zeng", then this step is used to determine the deformation mapping relationship corresponding to the transformation of the source component "Bei" from the position in the character "Yuan" to the position in the character "Zeng".

[0088] In an optional embodiment, when the first component is a source component, when it is determined that the source component "Bei" is transformed from the lower part of the top-bottom structure character with the target font style to the left side of the left-right structure character with the target font style, the style feature of the source component "Bei" on the left side of the left-right structure character with the target font style can be determined as the deformed style feature corresponding to the source component "Bei", and subsequent steps of determining the deformation mapping relationship to obtain the deformed style feature corresponding to the source component are no longer required. For example, the style feature of "Bei" in the character "Zeng" in the official script font can be determined as the deformed style feature of the source component "Bei". Of course, this embodiment is only a specific implementation manner for realizing character component style transfer when the first component is a source component, and is not a limitation on the present application.

[0089] When the first component is a target component, it may indicate that no reference character in which the source component is located at the source position is retrieved from the given reference characters, that is, the above method of directly determining the style feature of the source component in the reference character with the target font style as the deformed style feature of the source component when the source component is located at the source position in the reference character with the target font style cannot be adopted. At this time, the first component is the aforementioned target component different from the source component. For example, the source component is "Bei", and the first component may be the target component "Yue" in the above example. That is, the deformation mapping relationship corresponding to the transformation of the target component "Yue" from the reference position to the source position is determined.

[0090] In this embodiment, the number of the first components is the same as the number of the above source components, and one source component corresponds to one first component.

[0091] Step S150: Extract a first style feature of the source component in the content reference character, and apply the deformation mapping relationship to the first style feature to obtain a deformed style feature corresponding to the source component.

[0092] The above first style feature is used to represent the style feature of the source component in the content reference character. For example, the style feature may include the position, shape, line, form, etc. of the source component in the content reference character.

[0093] The above deformed style feature is used to represent the style of the source component in the source character having the target font style, and may include, for example, the position, shape, line, form, etc. of the source component in the source character having the target font style.

[0094] After the deformation mapping relationship corresponding to the transformation of the first component from the reference position to the source position is obtained in step S140, in practical applications, among characters with the same font style, different components located at the same position have similar style features, and the deformation mapping relationships corresponding to the transformation of different components from the reference position to the source position are similar. Therefore, the deformation mapping relationship corresponding to the transformation of the first component from the reference position to the source position can be similar to the deformation mapping relationship corresponding to the transformation of the source component from the reference position to the source position, and the determined deformation mapping relationship corresponding to the transformation of the first component from the reference position to the source position can be applied to the extracted style feature of the source component in the content reference character, so as to obtain the deformed style feature corresponding to the source component.

[0095] For example, referring to Figure 3 , the source character is "Ci", the source component is "Bei", the content reference character is "Jia", the reference position is the lower part of a character with a top-bottom structure, and the source position is the left part of a character with a left-right structure. The component "Yue" located at the reference position is relatively slender, for example, the "Yue" in "Cui" and the "Bei" in "Ci" are both relatively slender, while the component "Bei" located at the source position is relatively short and plump, for example, the "Bei" in "Jia" and the "Yue" in "Xiao" are both relatively short and plump. When the first component is "Yue", the first component "Yue" changes from the lower part of the character "Xiao" to the left part of the character "Cui", and "Yue" gradually becomes slender. By applying the deformation mapping relationship of the first component "Yue" changing from the lower part of the character to the left part of the character to the source component "Bei" at the reference position in the content reference character "Jia", the short and plump "Bei" located at the lower part of the content reference character can be gradually transformed into the slender "Bei" located at the source position.

[0096] Step S150: Generate a source character with the target font style according to the content feature of the source character and the deformed style feature corresponding to the source component.

[0097] In this embodiment, the source character may be input into a content encoder to determine the content feature of the source character, and then the source character with the target font style is generated according to the content feature of the source character and the deformed style feature corresponding to the source component.

[0098] In a specific embodiment, generating a source character with the target font style based on the content features of the source character and the deformed style features corresponding to the source component can include the following two cases.

[0099] Firstly, when the source component consists of all parts after the source character is split, the content features of the source character are fused with the deformed style features corresponding to the source components. The fused features are then decoded to obtain the source character with the target font style. The decoder can consist of several deep convolutional neural networks that receive the fused content features and target style features, perform convolution operations, and finally output the target character.

[0100] Secondly, when the source component is a predetermined number of components selected from all components after splitting the source character, during feature fusion, the style transfer of the remaining unselected components can be performed using the deformed style features corresponding to the obtained source components, so that the style features of each component of the source character are consistent. Then, the content features of the source character and the deformed style features corresponding to the source components are fused, and the fused features are decoded to obtain the source character with the target font style.

[0101] The font generation method provided in this application allows for the splitting of source characters to be generated as the target font style into source components. The position of each source component within the source character is determined as the source position. Then, from multiple reference characters with the target font style, a content reference character including the source component is determined, and the position of the source component within the content reference character is determined as the reference position. After determining the source and reference positions, a pair of deformable reference characters can be identified from the multiple reference characters that simultaneously contain the same target component, with the same target component located at both the source and reference positions. That is, the characters in the deformable reference character pair have the same target component, and this target component is located at the reference position of one character and the source position of the other. Furthermore, the deformable mapping relationship corresponding to the transformation of the first component from the reference position to the source position can be determined. The first component can be either a source component or a target component. This deformable mapping relationship can map the style features of the first component at the reference position to its style features at the source position. It is understandable that different components with the same target font style will have similar style features when they are in the same position in different characters. Therefore, the deformation mapping relationship of the first component transforming from the reference position to the source position is similar to that of the source component transforming from the reference position to the source position. Thus, by extracting the first style feature of the source component in the content reference character and applying the aforementioned deformation mapping relationship to the first style feature, the first style feature of the source component in the content reference character can be mapped to the deformed style feature of the source component at the source position. Next, based on the content features of the source character and the deformed style features of the corresponding source component, a source character with the target font style is generated.

[0102] As can be seen, the font generation method provided in this application can split the source character into source components and perform component-level style transfer on the source character. It can obtain the deformed style features corresponding to each source component, improve the expressiveness of the target font style of the character component, that is, improve the detail expression of the source character with the target font style, and optimize the generation effect of the source character with the target font style.

[0103] Furthermore, compared to the method in related I2I technology that requires retraining a deep network for each reference character of a font style, the font generation method provided in this application can transform the source character's font style to the reference character's font style for any given reference character of a font style without retraining the deep network, thus improving the efficiency of font generation.

[0104] The following describes specific embodiments of the technical solutions provided in this application.

[0105] When splitting the source character of the target font style to be generated into source components, it can be implemented through the following specific method, which includes the following steps S111 to S113.

[0106] Step S111: Acquire the source character to be generated into the target font style and the character component structure.

[0107] In the actual splitting process, the component splitting of the source character can be performed according to the character component standard and the character component structure in the related art. The character component standard shows each single component of the character, that is, shows the components that cannot be split further. The character component structure refers to the position structure of each single component of the character, and common position structures may include left-right structure, top-bottom structure, top-middle-bottom structure, left-middle-right structure, semi-enclosed structure, fully enclosed structure or special structure.

[0108] Step S112: Construct a layered tree structure corresponding to the source character to be generated into the target font style according to the character component structure.

[0109] In this embodiment, the layered tree structure can be constructed layer by layer through the character component structure until the character is split to the single component level. The layered tree structure can reflect the hierarchy and inclusion relationship between the character components, that is, the character is split from coarse to fine according to the character component structure. Refer to Figure 4 , the layered tree structures are respectively constructed for the characters "Yang" and "Ci".

[0110] The tree structure may be a binary tree structure. Therefore, no matter whether the layered tree structure or the layered binary tree structure is mentioned below, they mean the same thing.

[0111] Step S113: Determine the single component corresponding to the leaf node of each layer in the layered tree structure as the source component of the source character to be generated into the target font style.

[0112] In this embodiment, the layer where the source character is located, that is, the layer where the root node of the layered tree structure is located, is marked as the first layer, and the layers where each component of the source character is located, that is, the layers where the child nodes or leaf nodes of the layered tree structure are located, are respectively marked as the second layer to the N-th layer, and the components of all leaf nodes in the N-th layer are single components. A child node can be understood as a node that has nodes connected below itself except for the root node, and a leaf node is a node that no longer has nodes connected below, that is, an end node. In this embodiment, the components corresponding to the leaf nodes are all single components, that is, source components.

[0113] Such as Figure 4As shown, the character component structure of the source character "Yang" includes a left-right structure, the layered tree structure corresponding to the source character "Yang" is divided into two layers, the layer where the source character "Yang" is located is the first layer, and the components "Fu" and "Ri" are both single components, located in the second layer. That is, the source components obtained by splitting the source character "Yang" include "Fu" and "Ri".

[0114] For another example, the source character is "Ci", the character component structure of each single component of "Ci" includes a two-level structure, the first-level structure is a left-right structure, and the second-level structure is an up-down structure. Therefore, the layered tree structure constructed for the character "Ci" can be divided into three layers. The character "Ci" is located in the first layer, and is split according to the left-right structure to obtain the components "Bei" and "Yi" located in the second layer. Among them, the component "Yi" is a combined component, whose character component structure is an up-down structure, and can be further split to obtain the single components "Ri" and "Wu" in the third layer. That is, the source components obtained by splitting the source character "Ci" include "Bei", "Ri" and "Wu".

[0115] So far, the method of splitting the source character to obtain the source components has been described. The source position will be described below.

[0116] In this embodiment, the position code corresponding to the position of the source component in the source character is determined as the source position. The position code can be used to represent the relative position of the source component in the source character, and the position code corresponding to the position of the source component in the source character can be composed of the structure identifier of the character component structure and the position identifier of the component in the character.

[0117] When performing position coding on the relative position of the source component in the source character, a corresponding structure identifier can be set for the character component structure, for example, the structure identifier of the left-right structure is 0, the structure identifier of the up-down structure is 1, and the structure identifier of the left-middle-right structure is 3, etc.

[0118] A position identifier can also be set for the specific position of the source component in the source character. In this embodiment, the path identifier of the layered binary tree structure constructed for the source character is used to represent the position identifier of the specific position of the source component in the source character. Specifically, the child node corresponding to the left path of each layer of the binary tree structure is a left node, and the child node corresponding to the right path is a right node. The left node is marked as 0, and the right node is marked as 1, that is, the position identifier of the source component corresponding to the left node identifier is 0, and the position identifier of the source component corresponding to the right node identifier is 1. It can be understood that the component located at the left node of the binary tree structure is usually located on the left or upper side of the character, and the component at the right node is usually located on the right or lower side of the character.

[0119] For example, refer to Figure 4, the primary structure of the source character "Ci" is a left-right structure, and the left node at the second layer is the component "Bei". Therefore, the position encoding of the source component "Bei" in the source character "Ci" can be expressed as [(0, 0)], where the first 0 indicates that the character component structure of the source character "Ci" where the source component "Bei" is located is a left-right structure with a structure identifier of 0, and the second 0 indicates that the source component "Bei" is located on the left side of the source character "Ci". In this embodiment, to intuitively understand this encoding, in Figure 4 , the character component structure of a character is represented by boxes, two left and right boxes represent a left-right structure, and two upper and lower boxes represent an up-down structure.

[0120] In this embodiment, the position encoding can be expressed as E(c, p), where c represents the source character, and p represents any source component of the source character.

[0121] referring to Figure 4 , the position encoding is described by taking the source characters "Yang" and "Ci" as examples. In the layered binary tree structure corresponding to the source character "Yang", the left node among the leaf nodes at the second layer is "Fu", and the right node is "Ri". That is, the position encodings of the single components "Fu" and "Ri" of the source character "Yang" can be expressed as E(Yang, Fu) and E(Yang, Ri) respectively. E(Yang, Fu) = [(0, 0)], which indicates that the character component structure of the source character "Yang" where the component "Fu" is located is a left-right structure, and the component "Fu" is located on the left side of the source character "Yang"; E(Yang, Ri) = [(0, 1)], which indicates that the character component structure of the source character "Yang" where the component "Ri" is located is a left-right structure, and the component "Ri" is located on the right side of the source character "Yang".

[0122] Similarly, in the layered tree structure corresponding to the character "Ci", the leaf nodes at the second layer include the left node "Bei" and the right node "Yi", and the right node "Yi" is a combined component that can be further split to obtain the leaf nodes at the third layer including the left node "Ri" and the right node "Wu". That is, the position encodings of the single components "Bei", "Ri" and "Wu" of the character "Ci" can be expressed as E(Ci, Bei), E(Ci, Ri) and E(Ci, Wu) respectively. Wherein, E(Ci, Ri) = [(0, 1), (1, 0)], (0, 1) indicates that the component structure of the source character "Ci" where the source component "Ri" is located is a left-right structure with a structure identifier of 0 and is located on the right side, and (1, 0) indicates that the component structure of the combined component "Yi" where the source component "Ri" is located is an up-down structure with a structure identifier of 1 and the source component "Ri" is located on the upper side.

[0123] Through the above method, the source character can be split to obtain the source component, the position of the source component in the source character can be determined, and this position is defined as the source position.

[0124] In this embodiment, in step S120, determining the content reference character including the source component from the reference characters with the target font style may be specifically implemented in the following manner.

[0125] The content reference character including the source component may be determined from a pre-constructed dictionary set according to the source component. The dictionary set is configured to record a plurality of tuples corresponding to each reference component, and the reference component may be understood as a component obtained by splitting the reference character. The tuple includes the reference character that owns the reference component and the position encoding of the reference component in the reference character.

[0126] In this embodiment, the dictionary set may be constructed in the following manner.

[0127] First, each reference character is subjected to component-based splitting to obtain the reference components of each reference character. The process of splitting each reference character to obtain the reference components is consistent with the process of performing component splitting on the source character, which will not be repeated here.

[0128] Next, a tuple [γ, E(γ, u)] is formed by the reference character and the reference component obtained by splitting the reference character, where γ represents any reference character with the target font style, u is any reference component of the reference character γ, and E(γ, u) is the position encoding of the reference component in its corresponding reference character.

[0129] Then, the tuples corresponding to each reference component are stored with the reference component as an index, and the set storing the tuples may be referred to as the dictionary set. That is, the dictionary set of each reference component with the target font style is obtained. It can be understood that after splitting, each reference component corresponds to at least one reference character.

[0130] Each tuple corresponding to the source component is queried from the pre-constructed dictionary set through the source component, one tuple is randomly selected from the plurality of tuples, and the reference character in the tuple is determined as the content reference character. For example, for the source component "日", the tuples [阳, E(阳, 日)], [赐, E(赐, 日)] and [明, E(明, 日)] corresponding to the source component "日" may be queried through the dictionary set, and the reference character in any one of the three tuples may be used as the content reference character corresponding to the source component "日".

[0131] The position encoding manner of the reference component relative to the reference character in the above tuple is the same as the position encoding manner for determining the source position of the source component in the source character, which will not be repeated here.

[0132] In an optional embodiment, in step S130 "determining a deformed reference character pair that contains the same target component from a plurality of reference characters, and the same target component is located at the source position and the reference position respectively", the deformed reference character pair includes a first deformed reference character and a second deformed reference character, and the determining of the deformed reference character pair may specifically be implemented through the following steps S131 to S133.

[0133] Step S131: determining a corresponding position mapping relationship between the reference position and the source position.

[0134] In this embodiment, the above position mapping relationship is the position mapping relationship between the position code of the reference position and the position code of the source position, and the position mapping relationship may be recorded as wherein c is the source character, γ is the content reference character, and p is the source component. For example, the source character is "Ci", the content reference character is "Yang", the source component is "Ri", and the position mapping relationship corresponding to the source component "Ri" is

[0135] Step S132: query a pre-constructed inverted index table for the first deformed reference character and the second deformed reference character corresponding to the position mapping relationship; wherein the target component is located at the reference position in the first deformed reference character and the source position in the second deformed reference character respectively, and the first deformed reference character and the second deformed reference character have a target font style.

[0136] The pre-generated inverted index table is first introduced below.

[0137] In this embodiment, the inverted index table may also be referred to as an inverted table or an inverted index. The inverted index table can be understood as a file recording the inverted index, and hereinafter, no matter the inverted index table, the inverted table or the inverted index is mentioned, they all have the same meaning.

[0138] The inverted index table pre-constructed for the reference characters of the target font style in this embodiment uses the position mapping relationship as an index, and may include a position mapping relationship index file (word dictionary) and an inverted file. Reference is made to Figure 6 , Figure 6 which shows the relationship among the position mapping relationship index file, the inverted list and the inverted file.

[0139] The position mapping index file records all position mappings of each component in a given character set. It also records the address information of the inverted list corresponding to each component's position mapping in the inverted file. When retrieval is supported, based on the user-input position mapping, the index file retrieves the address information of the corresponding inverted list within the inverted file, and the inverted list is then obtained from the inverted file based on this address information. This inverted list contains a list of deformable reference characters that have appeared in the given position mapping. In other words, by using the inverted list corresponding to the given position mapping, it is possible to determine which deformable reference characters contain that position mapping.

[0140] In this embodiment, the inverted list corresponding to all the location mappings of each component is often stored sequentially in a file on the disk. This file is called the inverted file, which is a physical file that stores the inverted index.

[0141] The position mapping index file in the inverted index table above can be obtained in the following way.

[0142] The different characters contained in the reference character with the target style font can be pre-splittered based on components to obtain a component set. For example, the reference character could be more than 6,000 commonly used Chinese characters, and the component set could be obtained by splitting these 6,000 characters based on components.

[0143] For each component in the component set, two tuples containing the same component can be randomly selected from the dictionary set. The positional mapping relationship between these two tuples with respect to that component is recorded, and this mapping relationship is added to the positional mapping index file. For example, the two tuples are represented as [s, E(s, u)] and [t, E(t, u)]. The tuple [s, E(s, u)] records the positional encoding of the reference word s and component u within the reference word s, while the tuple [t, E(t, u)] records the positional encoding of the reference word t and component u within the reference word t. A positional mapping relationship exists between the tuples [s, E(s, u)] and [t, E(t, u)] with respect to component u. Location mapping relationship Add to the location mapping index file.

[0144] After recording the positional mapping relationship between any two tuples in the dictionary set M for each component to the positional mapping relationship index file, an inverted list corresponding to that positional mapping relationship is constructed. For example, the positional mapping relationship of component u... The corresponding tuple (s, t, u) is added to the position mapping relationship of component u. Corresponding inverted list in. In sequence, all tuples corresponding to different position mapping relationships of each component are respectively added to the corresponding inverted lists, so as to construct an inverted index table indexed by different position mapping relationships. The inverted index table can be used to retrieve deformation reference characters when generating a target font for a source character.

[0145] For example, referring to Figure 3 , the first component u is "yue", the reference character s in the tuple [s, E(s, u)] is "xiao", the reference character t in the tuple [t, E(t, u)] is "cui", and the position mapping relationship between the reference position of the first component "yue" and the source position is the position mapping relationship is added to the position mapping relationship index file, and the position mapping relationship corresponding tuple (xiao, cui, yue) is added to the position mapping relationship corresponding inverted list .

[0146] The above is an introduction to the process of constructing the inverted index table. The following describes querying, from the pre-generated inverted index table, a deformation reference character pair having the same position mapping relationship as the aforesaid position mapping relationship and the first deformation content of the deformation reference character pair.

[0147] after the position mapping relationship corresponding to the reference position where the source component is located and the source position where the source component is located is determined , the position mapping relationship is queried in the position mapping relationship index file to obtain the address of the corresponding inverted list , and then the inverted list is acquired in the inverted file according to the address One tuple (s, t, u) is randomly selected from the inverted list, the two characters s and t in the tuple form a deformation reference character pair (s, t), and the component u is the target component.

[0148] For example, referring to Figure 3 , description is given by taking a source character "ci", a content reference character "jia", and a source component "bei" as an example. The position mapping relationship between the reference position and the source position of the source component "bei" is When retrieving the deformation reference character, the position mapping relationship can be used to query, in the position mapping relationship index file, the position mapping relationship that is the same as the aforesaid position mapping relationship the position of the corresponding inverted list in the inverted file, and the position mapping relationship is determined through this position the corresponding inverted list, a tuple (Xiao, Cui, Yue) is randomly selected from the inverted list, that is, the deformation reference character pair is determined as (Xiao, Cui). The target component "Yue" is located below the upper-lower structure character "Xiao", which is the same as the reference position, so "Xiao" can be determined as the first deformation reference character; the target component "Yue" is located on the left side of the left-right structure character "Cui", which is the same as the source position, so "Cui" can be determined as the second deformation reference character.

[0149] In an optional embodiment, in step S150, "extracting the first style feature of the source component in the content reference character" may be performed by extracting the style feature of the content reference character and the first attention map of the content reference character with respect to the source component, then fusing the style feature of the content reference character and the first attention map, so as to obtain the first style feature of the source component in the content reference character. That is, it specifically includes the following steps S151 to S153.

[0150] Step S151: Extract the style feature of the content reference character.

[0151] The style feature of the content reference character can be extracted by a pre-trained style encoder. That is, the content reference character is input into the pre-trained style encoder, and the style encoder outputs the style feature of the content reference character. The style encoder may be any convolutional neural network in the related art that can be used for extracting image style features, which is not limited in this embodiment.

[0152] Step S152: Extract the first attention map of the content reference character with respect to the source component.

[0153] The attention map can be understood as an image obtained by distinguishing and marking the importance of each region in the content reference character image, in other words, assigning different weights to each position in the content reference character image. The first attention map can be understood as the first feature weight of the source component in the content reference character.

[0154] The first attention map of the content reference character with respect to the source component can be extracted through a pre-trained Class Activation Mapping (CAM). CAM can locate the region in the image that mainly represents the classification label based on the classification label of the image content, that is, the attention map generated by CAM can distinguish and mark the importance of the region where the source component is located in the content reference character and other components. Specifically, in this embodiment, the content reference character and the source component are input into the pre-trained CAM, and the first attention map representing the reference position of the source component in the content reference character is output.

[0155] Step S153: Extract, from the style features of the content reference character, a first style feature of the source component in the content reference character according to the first attention map.

[0156] After obtaining the style feature of the content reference character and the first attention map of the content reference character with respect to the reference component, the style feature of the content reference character is multiplied by the first attention map, so that the first style feature of the source component in the content reference character can be extracted from the style feature of the content reference character.

[0157] For example, with reference to Figure 5 , the three content reference characters in the content reference characters of the source character "Ci" are "Jia", "Yang" and "Hu" respectively. For the first content reference character "Jia", "Jia" is input into a pre-trained style encoder to obtain the style feature of the content reference character "Jia", "Jia" and the corresponding source component "Bei" are simultaneously input into a CAM to obtain the first attention map of the content reference character "Jia" with respect to the source component "Bei", and the image feature of the content reference character "Jia" is multiplied by the first attention map to obtain the first style feature image of the content reference character "Jia" with respect to the source component "Bei". Similarly, other content reference characters of the source character "Ci" are processed in sequence.

[0158] The training processes of the CAM and the style encoder are conventional techniques in the related field, and are not the focus of this embodiment, so they will not be described in detail here.

[0159] In an optional implementation manner, the first style feature of the source component in the content reference character may be visually displayed, that is, the reference position of the source component in the content reference character may be displayed in a color different from that of other positions, and the position where the color is located is the reference position. With reference to Figure 5 , after the style feature of the content reference character "Jia" is combined with the first attention map, the obtained first style feature deepens the color of the area where "Bei" is located in "Jia".

[0160] In an optional embodiment, when the first component is a target component, determining a deformation mapping relationship corresponding to the transformation of the first component from the reference position to the source position may be specifically implemented by the following steps S141 to S142.

[0161] Step S141: Extract a second style feature of the first component in the first deformation reference character and a third style feature of the first component in the second deformation reference character.

[0162] The extraction of the second style feature of the first component in the first deformed reference character and the third style feature of the first component in the second deformed reference character may both refer to the aforementioned method for extracting the first style feature of the source component in the content reference character as described later. That is, extracting the second style feature of the first component in the first deformed reference character may include: extracting the style feature of the first deformed reference character; extracting a second attention map of the first deformed reference character with respect to the first component; extracting the second style feature of the first component in the first deformed reference character from the style feature of the first deformed reference character according to the second attention map. Extracting the third style feature of the first component in the second deformed reference character includes: extracting the style feature of the second deformed reference character; extracting a third attention map of the second deformed reference character with respect to the first component; extracting the third style feature of the first component in the second deformed reference character from the style feature of the second deformed reference character according to the third attention map. For detailed description, reference may be made to the extraction of the first style feature, which will not be repeated herein.

[0163] For example, referring to Figure 5 , the same method is used to respectively extract the second style feature of the first component "yue (moon)" in the first deformed reference character "xiao (night)" and the third style feature of the first component "yue (moon)" in the second deformed reference character "cui (crisp)". Using the same method, the first style feature of the source component "ri (sun)" in the content reference character "yang (sun)", the second style feature of the corresponding first component "shan (mountain)" in the first deformed reference character "can (bright)", and the third style feature of the corresponding first component "shan (mountain)" in the second deformed reference character "chuan (to gasp)" are extracted in sequence; the first style feature of the source component "wu (do not)" in the content reference character "hu (suddenly)", the second style feature of the corresponding first component "mu (wood)" in the first deformed reference character "li (plum)", and the third style feature of the corresponding first component "mu (wood)" in the second deformed reference character "duo (flower)" are extracted.

[0164] Step S142: The mapping relationship corresponding to transforming the second style feature to the third style feature is determined as the deformation mapping relationship corresponding to transforming the first component from the reference position to the source position.

[0165] In an optional embodiment, referring to Figure 5 , the second style feature and the third style feature are input into a pre-trained deformation mapping learning model to obtain the mapping relationship corresponding to transforming the second style feature to the third style feature, and the mapping relationship corresponding to transforming the second style feature to the third style feature is determined as the deformation mapping relationship corresponding to transforming the first component from the reference position to the source position.

[0166] The aforementioned deformation mapping learning model can be an image registration model based on the vision transformer. The vision transformer is a model that applies the transformer to image classification. Through the image registration model based on this model, the affine transformation relationship between the second style feature and the first style feature can be learned. This affine transformation relationship is the aforementioned deformation mapping relationship. The affine transformation relationship or deformation mapping relationship mentioned below all mean the same thing.

[0167] Learning affine transformation relationships between images through an image registration network involves estimating an affine transformation model based on feature matching information between images. This affine transformation model can express the affine transformation relationships between images. In this embodiment, a vision transformer-based image registration network can be used to estimate the affine transformation model used to transform the second style features to the third style features through feature matching relationships between the second and third style features. The estimation of the affine transformation model using an image registration network can be found in related technical descriptions and will not be elaborated upon here.

[0168] This concludes the description of the method provided in this embodiment. By performing component-level style transfer on the source characters, the expressiveness of the target font style of the character components is improved, that is, the detail expression of the source characters with the target font style is enhanced, and the generation effect of the source characters with the target font style is optimized. Simultaneously, when there are no reference characters in the given reference characters that include the source component or whose source component is located at the source position, the source component located at the reference position can be deformed by learning the deformation mapping relationship of a first component different from the source component from the reference position to the source position, thereby achieving style transfer of the source component. In other words, the method provided in this application can be used when there are a small number of reference characters, expanding the application scenarios of font generation methods.

[0169] Furthermore, compared to the method in related I2I technology that requires retraining a deep network for each reference character of a font style, the font generation method provided in this application can transform the source character's font style to the reference character's font style for any given reference character of a font style without retraining the deep network, thus improving the efficiency of font generation.

[0170] Second Embodiment

[0171] Corresponding to the font generation method provided in the first embodiment of this application, the second embodiment of this application also provides a font generation device 700, such as... Figure 7 As shown, the device includes: a determination unit 701, a style feature mapping unit 702, and a generation unit 703;

[0172] The determining unit 701 is used to split the source character to be generated as the target font style into source components, and determine the position of the source component in the source character as the source position;

[0173] The determining unit 701 is further configured to determine, from a plurality of reference characters having the target font style, a content reference character including the source component, and to determine the position of the source component in the content reference character as a reference position;

[0174] The determining unit 701 is further configured to determine from the plurality of reference words a pair of deformed reference words that simultaneously contain the same target component, and the same target component is located at the source position and the reference position respectively;

[0175] The determining unit 701 is further configured to determine the deformation mapping relationship corresponding to the transformation of the first component from the reference position to the source position; wherein the first component is the source component or the target component;

[0176] The style feature mapping unit 702 is used to extract the first style feature of the source component in the content reference word, and apply the deformation mapping relationship to the first style feature to obtain the deformed style feature corresponding to the source component.

[0177] The generation unit 703 is used to generate the source character with the target font style based on the content features of the source character and the deformed style features corresponding to the source component.

[0178] Optionally, the determining unit 701 is specifically used to determine the deformation mapping relationship corresponding to the transformation of the first component from the reference position to the source position when the reference position is different from the source position.

[0179] Optionally, the deformable reference word pair includes a first deformable reference word and a second deformable reference word; the determining unit 701 is specifically used to determine the corresponding positional mapping relationship between the reference position and the source position; query the first deformable reference word and the second deformable reference word corresponding to the positional mapping relationship from a pre-constructed inverted index table; wherein, the target component is located at the reference position in the first deformable reference word and the source position in the second deformable reference word, respectively, and the first deformable reference word and the second deformable reference word have the target font style.

[0180] Optionally, when the first component is the target component, the style feature mapping unit 702 is further configured to extract the second style feature of the first component in the first deformed reference character and the third style feature in the second deformed reference character; transform the second style feature to the mapping relationship corresponding to the third style feature, and determine it as the deformation mapping relationship corresponding to the transformation of the first component from the reference position to the source position.

[0181] Optionally, the style feature mapping unit 702 is specifically used to extract the style features of the content reference word; extract the first attention map of the content reference word with respect to the source component; and extract the first style feature of the source component in the content reference word from the style features of the content reference word based on the first attention map.

[0182] Optionally, the style feature mapping unit 702 is specifically used to input the content reference character into a pre-trained style encoder to obtain the style features of the content reference character; and to input the content reference character and the source component into a pre-trained attention map generation network to obtain a first attention map of the content reference character with respect to the source component.

[0183] Optionally, the generation unit 703 is specifically used to fuse the content features of the source character with the deformed style features corresponding to the source component, and decode the fused features to obtain the source character with the target font style.

[0184] Optionally, the determining unit 701 is further configured to extract the style features of the first deformed reference character; extract the second attention map of the first deformed reference character with respect to the first component; and extract the second style features of the first component in the first deformed reference character from the style features of the first deformed reference character based on the second attention map.

[0185] Optionally, the determining unit 701 is further configured to extract the style features of the second deformed reference character; extract the third attention map of the second deformed reference character with respect to the first component; and extract the third style features of the first component in the second deformed reference character from the style features of the second deformed reference character based on the third attention map.

[0186] Optionally, the device further includes a mapping relationship learning unit 704;

[0187] The mapping relationship learning unit 704 is used to input the second style feature and the third style feature into a pre-trained deformation mapping learning model to obtain the mapping relationship corresponding to the transformation of the second style feature to the third style feature.

[0188] Optionally, the determining unit 701 is further configured to obtain the source character to be generated as the target font style and the character component structure; construct a hierarchical tree structure corresponding to the source character to be generated as the target font style based on the character component structure; and determine the single component corresponding to the leaf node of each layer in the hierarchical tree structure as the source component of the source character to be generated as the target font style.

[0189] Third Embodiment

[0190] Corresponding to the font generation method provided in the first embodiment of this application, the third embodiment of this application also provides an electronic device for generating fonts, such as... Figure 8 As shown, the electronic device includes: a processor 801; and a memory 802 for storing a program for a font generation method. After the device is powered on and the program for the font generation method is run by the processor, it executes the steps of the font generation method provided in the above embodiments.

[0191] Fourth embodiment

[0192] Corresponding to the font generation method provided in the first embodiment of this application, the fourth embodiment of this application also provides a computer-readable storage medium storing a program for a font generation method, which is executed by a processor to perform the steps of the font generation method provided in the above embodiments.

[0193] It should be noted that for a detailed description of the apparatus, electronic device and computer-readable storage medium provided in the second, third and fourth embodiments of this application, please refer to the relevant description of the first embodiment of this application, which will not be repeated here.

[0194] Although this application discloses preferred embodiments as described above, it is not intended to limit this application. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of this application. Therefore, the scope of protection of this application should be determined by the scope defined in the claims of this application.

[0195] In a typical configuration, the computing devices of a blockchain node include one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0196] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0197] 1. Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable operations, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include non-transitory computer-readable media, such as modulated data signals and carrier waves.

[0198] 2. Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0199] Although this application discloses preferred embodiments as described above, it is not intended to limit this application. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of this application. Therefore, the scope of protection of this application should be determined by the scope defined in the claims of this application.

Claims

1. A font generation method, characterized in that, The method includes: The source character to be generated as the target font style is split into source components, and the position of the source component in the source character is determined as the source position; From a plurality of reference characters having the target font style, determine a content reference character including the source component, and determine the position of the source component in the content reference character as a reference position; Determine from the plurality of reference words pairs that simultaneously contain the same target component, and the same target component is located at the source position and the reference position respectively; Determine the deformation mapping relationship of the first component from the reference position to the source position; wherein the first component is the source component or the target component; Extract the first style feature of the source component in the content reference word, and apply the deformation mapping relationship to the first style feature to obtain the deformed style feature corresponding to the source component; Based on the content features of the source character and the deformed style features corresponding to the source component, the source character with the target font style is generated.

2. The method according to claim 1, characterized in that, Determining, from the plurality of reference words, pairs of deformed reference words that simultaneously contain the same target component, wherein the same target component is located at the source position and the reference position respectively, includes: When the reference position is different from the source position, deformed reference word pairs that simultaneously contain the same target component are determined from the plurality of reference words, and the same target component is located at the source position and the reference position respectively.

3. The method according to claim 2, characterized in that, The deformable reference word pair includes a first deformable reference word and a second deformable reference word; determining from the plurality of reference words a deformable reference word pair that simultaneously contains the same target component, and the same target component is located at the source position and the reference position respectively, includes: Determine the positional mapping relationship between the reference position and the source position; The first deformable reference character and the second deformable reference character corresponding to the position mapping relationship are queried from the pre-constructed inverted index table; wherein the target component is located at the reference position in the first deformable reference character and the source position in the second deformable reference character, respectively, and the first deformable reference character and the second deformable reference character have the target font style.

4. The method according to claim 3, characterized in that, When the first component is the target component, determining the deformation mapping relationship corresponding to the transformation of the first component from the reference position to the source position includes: Extract the second style features of the first component in the first deformed reference character and the third style features of the first component in the second deformed reference character; The mapping relationship between the second style feature and the third style feature is determined as the deformation mapping relationship between the first component and the source position.

5. The method according to claim 1, characterized in that, The extraction of the first style feature of the source component in the content reference word includes: Extract the stylistic features of the reference characters in the content; Extract the first attention map of the content reference word with respect to the source component; Based on the first attention map, the first style feature of the source component in the content reference word is extracted from the style feature of the content reference word.

6. The method according to claim 5, characterized in that, The extraction of stylistic features from the content reference characters includes: The content reference word is input into a pre-trained style encoder to obtain the style features of the content reference word; The extraction of the first attention map of the content reference word with respect to the source component includes: The content reference word and the source component are input into a pre-trained attention map generation network to obtain a first attention map of the content reference word with respect to the source component.

7. The method according to claim 1, characterized in that, The step of generating the source character with the target font style based on the content features of the source character and the deformed style features corresponding to the source component includes: The content features of the source character are fused with the deformed style features corresponding to the source component, and the fused features are decoded to obtain the source character with the target font style.

8. The method according to claim 4, characterized in that, The extraction of the second style features of the first component in the first deformed reference character includes: Extract the stylistic features of the first deformed reference character; Extract the second attention map of the first deformed reference character with respect to the first component; Based on the second attention map, the second style feature of the first component in the first deformed reference character is extracted from the style feature of the first deformed reference character; The extraction of the third style feature of the first component in the second deformed reference character includes: Extract the stylistic features of the second deformed reference character; Extract the third attention map of the second deformed reference character with respect to the first component; Based on the third attention map, the third style feature of the first component in the second deformed reference character is extracted from the style features of the second deformed reference character.

9. The method according to claim 4, characterized in that, Before determining the mapping relationship corresponding to the transformation of the second style feature to the third style feature as the deformation mapping relationship corresponding to the transformation of the first component from the reference position to the source position, the method further includes: The second style feature and the third style feature are input into a pre-trained deformation mapping learning model to obtain the mapping relationship between the second style feature and the third style feature.

10. The method according to claim 1, characterized in that, The step of splitting the source characters to be generated into source components for the target font style includes: Obtain the source characters and character component structures to be generated as the target font style; Based on the character component structure, construct a hierarchical tree structure corresponding to the source characters to be generated as the target font style; The individual components corresponding to the leaf nodes of each layer in the hierarchical tree structure are determined as the source components of the source characters to be generated as the target font style.

11. A font generation device, characterized in that, The device includes: a determination unit, a style feature mapping unit, and a generation unit; The determining unit is used to split the source character to be generated as the target font style into source components, and determine the position of the source component in the source character as the source position; The determining unit is further configured to determine, from a plurality of reference characters having the target font style, a content reference character including the source component, and to determine the position of the source component in the content reference character as a reference position; The determining unit is further configured to determine from the plurality of reference words a pair of deformed reference words that simultaneously contain the same target component, and the same target component is located at the source position and the reference position respectively; The determining unit is further configured to determine the deformation mapping relationship corresponding to the transformation of the first component from the reference position to the source position; wherein the first component is the source component or the target component; The style feature mapping unit is used to extract the first style feature of the source component in the content reference word, and apply the deformation mapping relationship to the first style feature to obtain the deformed style feature corresponding to the source component. The generation unit is used to generate the source character with the target font style based on the content features of the source character and the deformed style features corresponding to the source component.

12. An electronic device, characterized in that, include: processor; as well as A memory for storing a data processing program, which, when powered on and run by the processor, executes the method as described in any one of claims 1 to 10.

13. A computer-readable storage medium, characterized in that, The system contains a data processing program that is executed by a processor to perform the method as described in any one of claims 1 to 10.