Font generation method, device, electronic device and storage medium

By obtaining the node coordinate information in the initial image file of the mini-program font, generating the first font file and adding it to the mini-program code library, the problem of low generation efficiency is solved, and fast, network-free font component generation is achieved, thereby improving processing efficiency.

CN114254585BActive Publication Date: 2025-09-09BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111572686.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-21
Publication Date
2025-09-09
Estimated Expiration
2041-12-21

AI Technical Summary

Technical Problem

The efficiency of generating mini-program fonts in the existing technology is low, and it needs to interact with the network-side server, which affects the processing efficiency.

Method used

By obtaining the coordinate information of the nodes in the initial image file of the target font, a first font file is generated and added to the code library of the target applet to avoid interaction with the network side.

Benefits of technology

It improves the efficiency of generating target font components, reduces network interactions, reserves more processing resources for its own operations, and improves overall processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114254585B_ABST
    Figure CN114254585B_ABST
Patent Text Reader

Abstract

The present disclosure provides a font generation method, device, electronic device and storage medium, which relate to the field of computer technology, and in particular to fields such as information processing. The specific implementation scheme is: obtaining coordinate information corresponding to at least one node contained in the initial image file of the target font; generating a first font file based on the coordinate information corresponding to the at least one node; generating a component of the target font based on the first font file, and adding the component of the target font to the code library of the target applet; wherein the target applet is used to reference the component of the target font in the code library in the target page for icon display. The above method can ensure the efficiency of generating the component of the target font and ensure that the target applet can efficiently add the target font.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to the field of information processing technology. Background Art

[0002] With the development of computer technology, more and more applications are released and used, and more and more small programs are also released and used. However, how to generate the fonts used by the icons in the small programs more quickly has become a problem that needs to be solved. Summary of the Invention

[0003] The present disclosure provides a font generation method, device, electronic device, and storage medium.

[0004] According to a first aspect of the present disclosure, there is provided a font generation method, comprising:

[0005] Obtaining coordinate information corresponding to at least one node contained in the initial image file of the target font;

[0006] generating a first font file based on the coordinate information respectively corresponding to the at least one node;

[0007] Generate the target font component based on the first font file, and add the target font component to the code library of the target applet; wherein the target applet is used to reference the target font component in the code library for icon display in the target page.

[0008] According to a second aspect of the present disclosure, there is provided a font generation device, comprising:

[0009] A parsing module, configured to obtain coordinate information corresponding to at least one node contained in an initial image file of a target font;

[0010] A first generating module, configured to generate a first font file based on the coordinate information corresponding to the at least one node;

[0011] The second generation module is used to generate the component of the target font based on the first font file, and add the component of the target font to the code library of the target applet; wherein, the target applet is used to reference the component of the target font in the code library for icon display in the target page.

[0012] According to a third aspect of the present disclosure, there is provided an electronic device, including:

[0013] at least one processor; and

[0014] a memory communicatively connected to the at least one processor; wherein,

[0015] The memory stores instructions that can be executed by the at least one processor. The instructions are executed by the at least one processor to enable the at least one processor to perform the font generation method of the first aspect.

[0016] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the aforementioned method.

[0017] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising a computer program, which implements the aforementioned method when executed by a processor.

[0018] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description.

[0019] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description.

[0020] The solution provided in this embodiment can obtain the target font that can be directly referenced by the target applet by automatically processing the initial image file of the target font, thereby ensuring the efficiency of generating the component of the target font and ensuring that the target applet can quickly add the target font; and since there is no need to interact with the server on the network side, more processing resources can be used for its own processing operations, which can further ensure processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The accompanying drawings are provided to facilitate a better understanding of the present invention and do not constitute a limitation of the present disclosure.

[0022] Figure 1 This is a flow diagram of a font generation method according to the first embodiment of the present disclosure. Figure 1 ;

[0023] Figure 2 This is a flow diagram of a font generation method according to the first embodiment of the present disclosure. Figure 2 ;

[0024] Figure 3 This is a flow diagram of a font generation method according to the first embodiment of the present disclosure. Figure 3 ;

[0025] Figure 4 is a structural diagram of a font generation device according to an embodiment of the second aspect of the present disclosure;

[0026] Figure 5 It is a block diagram of an electronic device for implementing the font generation method according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0027] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0028] The first aspect of the present disclosure provides a font generation method, such as Figure 1 As shown, including:

[0029] S101: Obtaining coordinate information corresponding to at least one node contained in an initial image file of a target font;

[0030] S102: Generate a first font file based on the coordinate information corresponding to the at least one node;

[0031] S103: Generate a component of the target font based on the first font file, and add the component of the target font to a code library of a target applet; wherein the target applet is used to reference the component of the target font in the code library for icon display in a target page.

[0032] The solution provided by this embodiment can be applied to electronic devices.

[0033] The format of the initial image file of the target file may be Scalable Vector Graphics (SVG).

[0034] The method for obtaining the initial image file of the target font may include:

[0035] The initial image file of the target font is selected from the initial image files corresponding to at least one font stored in the hard disk of the electronic device; and the initial image file of the target font is stored in the memory of the electronic device.

[0036] Among them, the method for obtaining the initial image file of the at least one font saved in the hard disk of the electronic device can be: downloading the initial image file of the at least one font from the server side and saving it in the hard disk of the electronic device; or, the electronic device can locally generate the initial image file of the at least one font and save it in the hard disk of the electronic device.

[0037] It should be understood that the initial image file of the target font can be any one of the initial image files of all fonts, that is, any one of the initial image files corresponding to all fonts can be processed using the solution provided in this embodiment, but this embodiment does not go into details one by one.

[0038] In this way, by adopting the method of reading the initial image file of the target font individually from the initial image files corresponding to all the fonts, the initial image file of the target font can be obtained. This can avoid the concurrent requests and conversion processing caused by reading the initial image files corresponding to multiple fonts at the same time, the resulting jamming or data loss problems, and can also avoid problems affecting the efficiency of subsequent processing.

[0039] Each of the at least one node may be a node representing a shape in the path attribute; and the coordinate information corresponding to each node may include one or more groups.

[0040] The format of the first font file may be a Web Open Font Format (WOFF) format.

[0041] The target font component may specifically refer to a presentation template of a page of the target applet, and the type of the target font component may be “.swan”.

[0042] The code library of the target applet may store one or more font components, and the component of the target font is one of them.

[0043] Furthermore, when it is necessary to display the target font on the target page of the target applet, the target applet can reference the component of the target font stored in the code library on the target page, and the icon corresponding to the target font can be displayed on the target page of the target applet.

[0044] It can be seen that by adopting the above solution, the initial image file of the target font can be parsed to obtain the coordinate information corresponding to at least one node, a first font file can be generated based on the coordinate information corresponding to at least one node, and a component of the target font can be generated based on the first font file. The component of the target font can be directly referenced by the target applet for icon display. In this way, by automatically processing the initial image file of the target font, a component that can be directly referenced by the target applet can be obtained, thereby ensuring the efficiency of generating the component of the target font and ensuring that the target applet can quickly add the target font; and since there is no need to interact with the server on the network side, more processing resources can be used for its own processing operations, which can further ensure processing efficiency.

[0045] In one embodiment, obtaining coordinate information corresponding to at least one node contained in the initial image file of the target font may include:

[0046] Parsing the content of the initial image file of the target font to obtain character string information;

[0047] Obtaining path attribute information from the character string information;

[0048] The path attribute information is parsed to obtain the coordinate information corresponding to the at least one node.

[0049] The parsing of the initial image file of the target font to obtain character string information may include: parsing the initial image file of the target font to obtain initial character string information; and deleting information of a preset type from the initial character string information to obtain the character string information.

[0050] The information of the preset type may be useless information, for example, it may include information contained in a tag of the preset type and / or attribute information of the preset type.

[0051] The preset type of tag may refer to an Extensible Markup Language (xml) tag; the preset type of attribute information may refer to identification (ID) attribute information of group information.

[0052] It should be understood that the above-mentioned preset types of labels are only exemplary descriptions, and more preset types of labels may be included in actual processing, but this embodiment does not list them all; similarly, the preset types of attribute information are only exemplary descriptions, and more preset types of attribute information may be included in actual processing, but this embodiment does not list them all.

[0053] After deleting the preset type of label and / or the preset type of attribute information from the initial character string information, the obtained character string information may include multiple labels and / or multiple attribute information.

[0054] The multiple tags contained in the above-mentioned string information may include at least some of the following: path tag, fill tag (such as g tag), image tag, svg tag, line tag, rectangle tag, polygon tag, circle tag and ellipse tag.

[0055] The following are the descriptions of the various tags mentioned above:

[0056] The path tag is used to draw a path, for example, it can be used to create various shapes such as lines, curves, arcs, circles, etc.; the path tag can have d attribute information.

[0057] The g tag is used to bundle multiple shapes into a group. The properties defined on the g tag will be inherited by all its child elements, and the transformation added to the g element will also be applied to all its child elements.

[0058] The image tag is used to insert a picture, which may include width attribute information and height attribute information.

[0059] The line tag is used to draw a straight line.

[0060] The rectangle (rect) tag is used to draw a rectangle.

[0061] The polygon tag is used to draw a polygon (must have three or more vertices).

[0062] The circle tag is used to draw a circle.

[0063] The ellipse tag is used to draw an ellipse.

[0064] The multiple attribute information contained in the above-mentioned string information may include at least part of the following: path attribute information, stroke color attribute information, stroke width attribute information, stroke transparency attribute information, fill color attribute information, fill transparency attribute information, transformation attribute information, width attribute information and height attribute information.

[0065] The path attribute information may specifically be d attribute information, which is used to specify at least one drawing command and includes corresponding coordinates after the at least one drawing command. The at least one drawing command may include at least one of the following: M (move the drawing point to a certain coordinate), L (draw a straight line), H (draw a horizontal line), V (draw a vertical line), Q (draw a quadratic Bezier curve), C (draw a cubic Bezier curve), or Z (close).

[0066] The width and height attributes are used to specify the image size.

[0067] The stroke color attribute information is used to define the stroke color, such as the stroke color of lines and text;

[0068] The stroke width attribute information is used to define the stroke width;

[0069] The stroke transparency attribute information is used to define the stroke transparency;

[0070] The fill color attribute information may be referred to as a fill attribute, and is used to define the fill color;

[0071] The fill transparency attribute information may be referred to as a fill-opacity attribute, and is used to define fill transparency;

[0072] The transformation attribute information may be referred to as a transform attribute, and is used to define the transformation of an SVG element, including movement, rotation, scaling, and the like.

[0073] In this embodiment, acquiring the path attribute information from the character string information may specifically refer to: acquiring the d attribute information from the character string information.

[0074] The parsing of the path attribute information to obtain the coordinate information corresponding to the at least one node may specifically include: parsing the d attribute information to obtain one or more sets of coordinate information corresponding to each node. For example, a node representing a rectangle contains the following content: "d = MX0, Y0 LX1, Y0 LX1, Y1 LX0, Y1 Z", which contains 4 sets of coordinate information, namely (X0, Y0), (X1, Y0), (X1, Y1) and (X0, Y1). That is, the node representing the rectangle contains 4 sets of coordinate information.

[0075] It can be seen that by adopting the above scheme, it is possible to extract string information from the initial image file of the target font, obtain path attribute information from the string information, and then perform parsing based on the path attribute information to obtain the coordinate information corresponding to the at least one node. In this way, the coordinate information of the nodes in the initial image file of the target font can be obtained more accurately, thereby providing accurate information for the subsequent generation processing of the components of the target font, ensuring the accuracy and efficiency of subsequent processing.

[0076] In one embodiment, after parsing the initial image file of the target font to obtain character string information, the method further includes: obtaining at least one fill attribute information from the character string information;

[0077] The generating of the first font file based on the coordinate information respectively corresponding to the at least one node includes: obtaining fill node rendering information respectively corresponding to the at least one node based on the at least one fill attribute information and the coordinate information respectively corresponding to the at least one node; and writing the fill node rendering information respectively corresponding to the at least one node into the first font file.

[0078] It should also be noted that, after parsing the initial image file of the target font to obtain the string information, the process further includes: obtaining all tags from the string information, and all tags contained in the string information can be divided into tag groups.

[0079] The entire set of tags may include at least a path tag and a fill tag. The path tag and the fill tag have been described in the aforementioned embodiment and will not be described in detail here.

[0080] The at least one fill attribute information includes at least one of the following: fill attribute information, coordinate (x, y) attribute information, width information, and height attribute information. Each of the above attribute information has been described in detail in the above embodiments and will not be repeated here.

[0081] After obtaining the coordinate information corresponding to the at least one node, the method may further include: saving the coordinate information corresponding to the at least one node as a node position array. Here, the node position array may be referred to as a d array, or an array of d attributes.

[0082] The obtaining of fill node rendering information corresponding to the at least one node based on the at least one fill attribute information and the coordinate information corresponding to the at least one node may specifically include: using the position information of each node in the node position array and the at least one fill attribute information corresponding to each node in the at least one node as the fill rendering information of each node.

[0083] For example, the node position array is called a d array, which includes coordinate information corresponding to four nodes respectively, and the at least one fill attribute information includes fill attribute information; accordingly, the fill node rendering information corresponding to the at least one node is obtained based on the at least one fill attribute information and the coordinate information corresponding to the at least one node, which can be: reading the coordinate information of each node from the d array, and obtaining the fill node rendering information corresponding to each node based on the coordinate information of each node and the fill attribute information corresponding to each node.

[0084] Correspondingly, writing the filling node rendering information corresponding to the at least one node into the first font file may specifically be: writing the filling node rendering information corresponding to the at least one node into the tag group, and writing the tag group into the first font file.

[0085] The format of the first font file of the target font may be a Web Open Font Format (WOFF) format.

[0086] With respect to the above scheme, the initial image file of the target font is specifically an SVG image of the target font; the preset type tag is an xml tag, the preset type attribute information is an id attribute; the path attribute information is d attribute information; the at least one fill attribute information includes at least fill attribute information, width attribute information, and height attribute information; and the first font file is a WOFF file of the target font as an example, the above scheme is explained:

[0087] Reading the SVG image of the target font and storing it in memory; parsing the SVG image of the target font to extract initial string information; discarding a preset type of tag and / or a preset type of attribute information from the initial string information to obtain string information, for example, deleting the XML tag and the ID attribute of the grouping information from the initial string information;

[0088] Obtain at least one tag and at least one attribute information from the string information; divide all tags contained in the string information into tag groups, for example, the g tag and the path tag may be divided into a tag group, and further divide the at least one attribute information into an attribute group, for example, the d attribute information, the fill attribute information, the width attribute information, and the height attribute information into an attribute group;

[0089] Parsing the d attribute information to obtain the coordinate information corresponding to the at least one node, and storing the coordinate information as a d array;

[0090] Create a WOFF empty file of the target font, read the coordinate information of each node from the d array, and obtain the fill node rendering information corresponding to each node based on the coordinate information of each node and the at least one fill attribute information corresponding to each node; write the fill node rendering information corresponding to each node into the tag group, and write the tag group into the WOFF empty file of the target font to obtain the WOFF file of the target font.

[0091] It can be seen that by adopting the above solution, the position information of at least one node can be obtained from the path attribute information, and then the position information of at least one node and at least one fill attribute information can be used to generate the first font file of the target font. In this way, in the process of generating the first font file of the target font, the key feature information in the initial image file can be retained, and a part of the tags and attributes that do not need to be retained can be reduced, thereby reducing the content redundancy of the generated first font file, reducing the package size, and making the subsequent conversion process more efficient, thereby improving the overall processing efficiency.

[0092] After obtaining the first font file, the first font file of the target font can also be saved in a third font file. Specifically, the above processing is performed by extracting the initial image file of the target font from the hard disk to the memory; after completing the conversion of the initial file of the target font to the first font file, the first font file can be saved in the third font file and stored on the hard disk. In this way, after the file format conversion is completed, the memory space is no longer occupied, reducing the memory space usage.

[0093] The format of the third font file may specifically be a FONT file.

[0094] In one embodiment, the component for generating the target font based on the first font file is as follows: Figure 2 As shown, this may include:

[0095] S201: Encode the first font file to obtain an encoded first font file;

[0096] S202: Writing the encoded first font file as font attributes into a second font file;

[0097] S203: Generate components of the target font based on the second font file.

[0098] The encoding of the first font file to obtain the encoded first font file may include: extracting the third font file from the hard disk, encoding the content of the first font file contained in the third font file to obtain the encoded first font file.

[0099] The encoding method used in the encoding process can be set according to actual conditions, for example, Base 64 encoding can be used. The Base 64 encoding method is a method of representing binary data based on 64 printable characters.

[0100] For example, the encoding process of the first font file to obtain the encoded first font file may include: using the Base 64 encoding method to convert each 4 8-bit bytes in the first font file into 4 6-bit bytes (3*8=4*6=24) in sequence, adding 0 to the most significant two bits of each 6-bit byte to obtain each 8-bit byte; and using the obtained 4 8-bit bytes as the encoded first font file.

[0101] The above encoding of the first font using the Base64 encoding method to obtain the encoded first font file is a process from binary to character, which is more suitable for transmitting longer identification information in the Hypertext Transfer Protocol (HTTP) environment; in addition, the encoded content obtained using the Base64 encoding method is unreadable and needs to be decoded before it can be read, thereby ensuring security.

[0102] The format of the second font file may specifically be Cascading Style Sheets (CSS); the font attribute may be the “src” attribute under the “@font-face” attribute in the second font file.

[0103] That is to say, assuming that the encoded first font file is a string "rbp 2", writing the encoded first font file as a font attribute into the second font file can be: directly writing the string "rbp 2" into the "src" attribute under the "@font-face attribute" of the second font file.

[0104] Through the above processing, the content of the first font file can be encoded to obtain the encoded first font file, and then the second font file can be generated based on the first font file; since the encoded first font file can be used to transmit longer identification information in the HTTP environment, and the encoded first font file needs to be decoded before it can be read, it can be ensured that the second font file generated according to the encoded first font file, and then the component of the target font generated based on the second font file is more suitable for use in the target applet in the client, and security can also be guaranteed.

[0105] In one embodiment, the component of generating the target font based on the second font file may include:

[0106] Generate a class name corresponding to the target font in the second font file;

[0107] The class name corresponding to the target font in the second font file is introduced into the display element of the component of the target font, and the name of the target font is set in the name configuration of the component of the target font.

[0108] The class name corresponding to the target font can be set according to actual conditions. When the type of the second font file is a CSS file, the class name corresponding to the target font can be expressed as a CSS class name of ".bk-icon-{name of the target font}", wherein the name of the target font can be the file name of the initial image file of the target font.

[0109] The display element can be represented as a "view" element, and the class name corresponding to the target font in the second font file introduced into the display element of the component of the target font can refer to: setting the class name corresponding to the target font in the display element of the component to be the same as the class name in the second font file.

[0110] For example, the name of the target font, that is, the file name of the initial image file of the target font is "Font A". When the second font file is a CSS file, the class name corresponding to the target font can be expressed as ".bk-icon-{Font A}"; accordingly, the class name is set to ".bk-icon-{Font A}" in the display element of the component of the target font.

[0111] The name of the target font may also be the file name of the initial image file of the target font, such as “Font A”.

[0112] After setting the name of the target font in the name configuration of the component of the target font, when the target applet needs to introduce the target font in the page component later, it is only necessary to specify the name of the target font in the name field in the page component of the target applet to display the icon corresponding to the target font.

[0113] Exemplarily, the first font file is referred to as a WOFF file of a target font, the second font file is referred to as a CSS file of a target font, the encoding process is specifically a Base64 encoding method, the font attribute is the src attribute in the @font-face attribute, the class name corresponding to the target font is represented as ".bk-icon-{font A}", the name of the target font is "font A", and the component of the target font is the swan component of the target font. The above process is explained as follows:

[0114] Encode the WOFF file of the target font using Base64 encoding to obtain an encoded WOFF file;

[0115] Writing the encoded WOFF file of the target font into the src attribute of the @font-face attribute of the CSS file of the target font;

[0116] The CSS class name .bk-icon-{font A} will be generated in the CSS file of the target font;

[0117] Create a swan component of the target font and use an empty view (display) element to take up space. Set the class name of the view (display) element to .bk-icon-{font A} to introduce the CSS file dependency of the target font. In this way, the CSS file of the target font and the swan component of the target font can be linked. Due to the characteristics of the view element, it is not suitable for displaying icons. Therefore, the swan of the target font will set corresponding attributes so that the view can coexist and be displayed on the same line with external elements, which is more suitable for the usage scenario of this component.

[0118] In addition, a name configuration is added to the swan component of the target font. When the name of the target font is written in the name configuration of the swan component of the target font, when the page component of the target applet references it, the swan component of the target font can be referenced by specifying the name field to control the display of the icon corresponding to the target font in the target page of the target applet.

[0119] The above is only an exemplary description. In actual use, the CSS file of the target font may be represented as the iconfont.css file, and the swan component of the target font may be represented as the hyIcon.swan component. Exhaustive examples are not given here.

[0120] It can be seen that by adopting the above solution, the initial image file of the target font can be directly converted into the component of the target font. By introducing the component of the target font into the target applet, the target applet can directly call the target font for icon display. In this way, the problem of low efficiency caused by the need to manually generate the image of the target font can be avoided. In addition, since the second font file introduced in the component of the target font is a file obtained after coordinate information extraction and encoding, the component package body content of the target font can be made more streamlined, reducing the storage space occupied; and since only one component needs to be introduced in the target applet to complete the font addition process, there is no need to interact with the server on the network side, so that more processing resources can be used for its own processing operations, which can further ensure processing efficiency.

[0121] Finally, taking the initial image file of the target font as the SVG image of the target font, the first font file as the WOFF file of the target font, and the second font file as the CSS file of the target font as an example, combined with Figure 3 The font generation method provided in this embodiment is exemplarily described, including:

[0122] S301: Reading the SVG image of the target font.

[0123] S302: Obtain coordinate information corresponding to at least one node contained in the SVG image of the target font.

[0124] S303: Generate a WOFF file of the target font based on the coordinate information corresponding to the at least one node.

[0125] S304: Encode the WOFF file of the target font to obtain an encoded WOFF file of the target font.

[0126] S305: Writing the encoded WOFF file of the target font as font attributes into the CSS file of the target font, and generating a class name of the target font in the CSS file of the target font.

[0127] The font attribute may specifically be the src attribute in the @font-face attribute.

[0128] S306: Writing the CSS file of the target font into the component of the target font.

[0129] After completing the above S306, the component of the target font can be introduced into the code library of the target applet; when the page component of the target applet specifies the name field of the target font, the icon of the target font can be controlled to be displayed on the target page of the target applet.

[0130] By adopting the above solution, the initial image file of the target font can be directly converted into the component of the target font. By introducing the component of the target font into the target applet, the target applet can directly call the target font for icon display. In this way, the problem of low efficiency caused by the need to manually generate the image of the target font can be avoided. In addition, since the second font file introduced in the component of the target font is a file obtained after coordinate information extraction and encoding, the component package body of the target font can be made more concise, reducing the storage space occupied; and since only one component needs to be introduced in the applet to complete the font addition process, there is no need to obtain the image processing by sending multiple requests, thereby reducing the risk of parallel network requests and retaining more processing resources for processing, thereby ensuring processing efficiency.

[0131] The second aspect of the present disclosure provides a font generation device, such as Figure 4 As shown, including:

[0132] The parsing module 401 is used to obtain coordinate information corresponding to at least one node contained in the initial image file of the target font;

[0133] A first generating module 402 is configured to generate a first font file based on the coordinate information corresponding to the at least one node;

[0134] The second generation module 403 is used to generate the component of the target font based on the first font file, and add the component of the target font to the code library of the target applet; wherein, the target applet is used to reference the component of the target font in the code library for icon display in the target page.

[0135] The parsing module 401 is configured to parse the initial image file of the target font to obtain character string information; obtain path attribute information from the character string information; and parse the path attribute information to obtain the coordinate information corresponding to the at least one node.

[0136] The parsing module 401 is configured to obtain at least one fill attribute information from the character string information;

[0137] The first generation module 402 is used to obtain fill node rendering information corresponding to the at least one node based on the at least one fill attribute information and the coordinate information corresponding to the at least one node; and write the fill node rendering information corresponding to the at least one node into the first font file.

[0138] The second generating module 403 is configured to encode the first font file to obtain an encoded first font file; write the encoded first font file as font attributes into a second font file; and generate components of the target font based on the second font file.

[0139] The second generation module 403 is used to generate the class name corresponding to the target font in the second font file; introduce the class name corresponding to the target font in the second font file into the display element of the component of the target font, and set the name of the target font in the name configuration of the component of the target font.

[0140] By adopting the above solution, the initial image file of the target font can be parsed to obtain the coordinate information corresponding to at least one node, a first font file can be generated based on the coordinate information corresponding to at least one node, and a component of the target font can be generated based on the first font file. The component of the target font can be directly referenced by the target applet for icon display. In this way, by automatically processing the initial image file of the target font, a component that can be directly referenced by the target applet can be obtained, thereby ensuring the efficiency of generating the component of the target font and ensuring that the target applet can quickly add the target font; and since there is no need to interact with the server on the network side, more processing resources can be used for its own processing operations, which can further ensure processing efficiency.

[0141] In the technical solutions disclosed herein, the acquisition, storage, and application of user personal information involved comply with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0142] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0143] Figure 5 A schematic block diagram of an example electronic device 500 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are provided as examples only and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0144] like Figure 5 As shown, the electronic device 500 includes a computing unit 501, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 502 or a computer program loaded from a storage unit 508 into a random access memory (RAM) 503. Various programs and data required for the operation of the electronic device 500 can also be stored in the RAM 503. The computing unit 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0145] Multiple components in the electronic device 500 are connected to the I / O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a magnetic disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the electronic device 500 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0146] The computing unit 501 can be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 501 performs the various methods and processes described above. For example, in some embodiments, the various methods described above can be implemented as a computer software program that is tangibly contained in a machine-readable medium, such as a storage unit 508. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the computing unit 501, one or more steps of the various methods described above can be performed. Alternatively, in other embodiments, the computing unit 501 can be configured to perform the various methods described above by any other appropriate means (e.g., by means of firmware).

[0147] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0148] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0149] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0150] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0151] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.

[0152] A computer system may include a client and a server. The client and server are generally remote from each other and typically interact through a communication network. The client-server relationship arises through computer programs running on the respective computers and having a client-server relationship with each other. The server may be a cloud server, a server in a distributed system, or a server integrated with a blockchain.

[0153] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. This is not limited herein.

[0154] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the scope of protection of this disclosure.

Claims

1. A font generation method, comprising: Obtaining coordinate information corresponding to at least one node contained in the initial image file of the target font; generating a first font file based on the coordinate information respectively corresponding to the at least one node; Generating a component of the target font based on the first font file, and adding the component of the target font to a code library of a target applet; wherein the target applet is used to reference the component of the target font in the code library for icon display in a target page; The step of obtaining coordinate information corresponding to at least one node contained in the initial image file of the target font comprises: parsing the initial image file of the target font to obtain character string information; obtaining path attribute information from the character string information; and parsing the path attribute information to obtain coordinate information corresponding to the at least one node. After parsing the initial image file of the target font to obtain the string information, it also includes: obtaining at least one fill attribute information from the string information; generating a first font file based on the coordinate information corresponding to the at least one node, including: obtaining fill node rendering information corresponding to the at least one node based on the at least one fill attribute information and the coordinate information corresponding to the at least one node; writing the fill node rendering information corresponding to the at least one node into the first font file.

2. The method according to claim 1, wherein The component for generating the target font based on the first font file includes: performing encoding processing on the first font file to obtain an encoded first font file; Writing the encoded first font file into a second font file as font attributes; Based on the second font file, components of the target font are generated.

3. The method according to claim 2, wherein: The component for generating the target font based on the second font file includes: Generate a class name corresponding to the target font in the second font file; The class name corresponding to the target font in the second font file is introduced into the display element of the component of the target font, and the name of the target font is set in the name configuration of the component of the target font.

4. A font generation device, comprising: A parsing module, configured to obtain coordinate information corresponding to at least one node contained in an initial image file of a target font; A first generating module, configured to generate a first font file based on the coordinate information corresponding to the at least one node; a second generating module, configured to generate a component of the target font based on the first font file, and add the component of the target font to a code library of a target mini-program; wherein the target mini-program is configured to reference the component of the target font in the code library for icon display on a target page; The parsing module is configured to parse the initial image file of the target font to obtain character string information; obtain path attribute information from the character string information; and parse the path attribute information to obtain the coordinate information corresponding to the at least one node. The parsing module is configured to obtain at least one fill attribute information from the character string information; The first generation module is used to obtain fill node rendering information corresponding to the at least one node based on the at least one fill attribute information and the coordinate information corresponding to the at least one node; and write the fill node rendering information corresponding to the at least one node into the first font file.

5. The device according to claim 4, wherein The second generating module is configured to encode the first font file to obtain an encoded first font file; and write the encoded first font file as a font attribute into a second font file; Based on the second font file, components of the target font are generated.

6. The device according to claim 5, wherein The second generating module is used to generate a class name corresponding to the target font in the second font file; The class name corresponding to the target font in the second font file is introduced into the display element of the component of the target font, and the name of the target font is set in the name configuration of the component of the target font.

7. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 3.

8. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-3.

9. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Method for user-defined character font

    CN101639846A

  • Method and system for rendering fonts

    CN102509329A