SVG character cutting contour bending method, device and system and medium

By analyzing SVG text data and calculating the bending angle, and generating text bending profile data, the problem of insufficient flexibility of text bending paths in traditional technology is solved, and the precise bending and efficient processing of text is achieved.

CN119250019APending Publication Date: 2025-01-03环盛智能(深圳)有限公司
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411107140.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-13
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

Traditional SVG text processing methods are difficult to bend text along curved paths, unable to adapt to complex design or manufacturing needs, especially in order to handle text arranged in a straight line flexibly.

Method used

By obtaining SVG text data, analyzing text outline data, calculating text length, number of characters and character spacing, calculating text bending angle based on the input bending radius and text length, and then calculating the new path data of each character to generate text bending outline data.

Benefits of technology

The precise bending effect of the text is achieved, the flexibility and diversity of the design is improved, the need for manual operation is reduced, efficiency is improved, and the quality and accuracy of the output is ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119250019A_ABST
    Figure CN119250019A_ABST
Patent Text Reader

Abstract

The invention discloses an SVG character cutting contour bending method, device and system and a medium, and the method comprises the following steps: obtaining SVG text data, and extracting text contour data from the SVG text data; analyzing the text contour data to obtain path data of each character; calculating a character number, a character pitch and a text length based on the path data; calculating a text bending angle according to the input bending radius and the text length; calculating a character deflection angle based on the text bending angle and the character number; and calculating new path data of each character based on the character deflection angle so as to obtain text curved contour data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of engraving machines, and in particular to a method, device, system and medium for bending an outline of SVG text cutting. Background Art

[0002] Traditional text bending is to set a bending path for a section of text content to achieve the effect. However, for the cutting industry, traditional text data cannot be cut and needs to be converted into contour information.

[0003] In the field of modern digital design and manufacturing, the SVG format has become the mainstream standard for describing vector graphics due to its scalability and clarity. SVG is widely used in web design, printing industry, advertising production, and various scenarios that require precise graphic control.

[0004] However, traditional SVG text processing methods have some limitations. SVG text refers to text content with only outline data. That is, the source file is a bunch of outline data, not recognizable text content in the traditional sense. When text needs to be bent at a specific arc to meet complex design or manufacturing requirements. Existing technologies are usually difficult to adapt to such needs because they can only process text arranged in a straight line, but cannot flexibly bend text along a curved path. Summary of the invention

[0005] The object of the present invention is to provide a method, device, system and medium for bending the outline of SVG text cutting, which are used to recalculate the outline information based on a specified radius to achieve the purpose of bending the SVG format text string.

[0006] The technical solution adopted by the present invention to solve the above technical problems is as follows:

[0007] A method for bending an outline of an SVG text cut includes the following steps:

[0008] Acquire SVG text data, and extract text outline data from the SVG text data;

[0009] Parsing the text outline data to obtain path data of each character;

[0010] Calculate the number of characters, character spacing, and text length based on the path data;

[0011] Calculate the text bending angle based on the input bending radius and text length;

[0012] Calculating a character deflection angle based on the text bending angle and the number of characters;

[0013] New path data of each character is calculated based on the character deflection angle, thereby obtaining text bending contour data.

[0014] Furthermore, the parsing of the text outline data to obtain the path data of each character includes the following sub-steps:

[0015] Extract string path elements;

[0016] Parse string path commands and arguments;

[0017] Get the starting and ending coordinates of the character according to the path command, and get the extreme values ​​of the character contour coordinates based on the parameters.

[0018] Further, the calculating of text length, number of characters and character spacing based on the path data comprises the following sub-steps:

[0019] Count the path data of the characters to get the number of characters;

[0020] Compare the coordinates of all characters in the path data and calculate the extreme value difference to get the text length;

[0021] The character border is obtained based on the coordinate extreme value difference in each character path data, and the character spacing is obtained by calculating the distance of the character border.

[0022] Furthermore, the step of calculating the text bending angle according to the input bending radius and text length includes the following sub-steps:

[0023] Scale the text length to the arc length;

[0024] Calculate the central angle value corresponding to the arc length based on the input bending radius;

[0025] The center angle value is calibrated as the text bending angle required for the text to be bent.

[0026] Furthermore, the calculating of the character deflection angle based on the text bending angle and the number of characters comprises the following sub-steps:

[0027] Determine the coordinates of the center of the circle according to the bending radius;

[0028] Calculate the text starting point angle based on the circle center coordinates and the text bending angle;

[0029] The rotation angle and direction of each character are calculated according to the text starting point angle and the number of characters.

[0030] Furthermore, the step of calculating the rotation angle and direction of each character according to the text starting point angle and the number of characters specifically includes the following steps:

[0031] Based on the number of characters, character spacing, and text length;

[0032] Calculate the sum of the width of each character and the width of the spacing between adjacent characters;

[0033] The rotation angle of each character is calculated based on the ratio of the sum of the widths to the length of the text.

[0034] Furthermore, the step of calculating the new path data of each character based on the character deflection angle to obtain the text bending contour data specifically includes the following steps:

[0035] Get the path data of each character and extract all coordinate parameters in the path data.

[0036] Calculate the new coordinate parameters after rotation according to the center coordinates of the circle and the rotation angle and direction of each character;

[0037] The new coordinate parameters constitute the new path data of the rotated characters, and the new path data of each character constitutes the number of curved contours of the text.

[0038] Another embodiment of the present invention further provides a device for bending an outline of an SVG text cut, the device comprising:

[0039] An outline data extraction module is used to obtain SVG text data and extract text outline data from the SVG text data;

[0040] A path data parsing module, used for parsing the text outline data to obtain path data of each character;

[0041] A text information calculation module, used to calculate the text length, the number of characters and the character spacing based on the path data;

[0042] A text radius input module is used to calculate the text bending angle according to the input bending radius and text length;

[0043] A character angle calculation module, used for calculating a character deflection angle based on the text bending angle and the number of characters;

[0044] The curved path generation module is used to calculate new path data of each character based on the character deflection angle, so as to obtain text curved contour data.

[0045] Another embodiment of the present invention further provides a bending system for SVG text cutting contour, the system comprising at least one processor; and

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

[0047] 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 so that the at least one processor can execute the above-mentioned method for bending the SVG text cutting contour.

[0048] Another embodiment of the present invention further provides a non-volatile computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are executed by one or more processors, the one or more processors can execute the above-mentioned SVG text cutting contour bending method.

[0049] Beneficial effects: The present invention discloses a method, device, system and medium for bending the outline of SVG text cutting. Compared with the prior art, the embodiment of the present invention can accurately control the bending effect of the text and ensure the quality and accuracy of the output by analyzing the path data of each character in detail and calculating the text length, the number of characters and the character spacing. By recalculating the outline information based on the specified radius, the method allows the text to be bent along a curved path, improving the flexibility and diversity of the design. The method reduces the need for manual operation and improves efficiency through automated steps, such as automatically extracting outline data, parsing path commands, calculating bending angles, etc.

[0050] Other features and advantages of the invention will be described in the following description, and partly become apparent from the description, or understood by practicing the invention. The purpose and other advantages of the invention can be realized and obtained by the structures particularly pointed out in the written description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] The present invention is described in detail below in conjunction with the accompanying drawings to make the above advantages of the present invention more clear.

[0052] Figure 1 It is a flow chart of a method for bending an SVG text cutting contour of the present invention;

[0053] Figure 2 It is a flow chart of path data parsing in a bending method of SVG text cutting contour of the present invention;

[0054] Figure 3 It is a flowchart of text information calculation in a bending method of SVG text cutting contour of the present invention;

[0055] Figure 4 It is a flow chart of text radius input in a bending method of SVG text cutting contour of the present invention;

[0056] Figure 5 It is a character angle calculation flow chart in a bending method of SVG text cutting contour of the present invention;

[0057] Figure 6 It is a character rotation angle flow chart in a bending method of an SVG text cutting contour of the present invention;

[0058] Figure 7 It is a flow chart of generating a bending path in a bending method of an SVG text cutting contour of the present invention;

[0059] Figure 8 It is a text string schematic diagram of a bending method of an SVG text cutting contour of the present invention;

[0060] Fig. 9 It is a bending schematic diagram of a bending method of an SVG text cutting contour of the present invention;

[0061] Fig.10 It is a functional module schematic diagram of an embodiment of a bending device for cutting contour of SVG text according to the present invention;

[0062] Fig.11 It is a hardware structure diagram of an embodiment of a bending device for cutting contours of SVG texts according to the present invention. DETAILED DESCRIPTION

[0063] In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail below. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0064] Technical explanation: In the field of lettering, each character path data in an SVG file is usually represented as a series of SVG path commands and parameters that define the shape of the character outline. Character path data is usually nested in <path>element, and each character may consist of one or more <path>Element representation.

[0065] SVG path commands include but are not limited to the following:

[0066] M / m: Move to the specified coordinate point (capital M represents absolute coordinates, lowercase m represents relative coordinates).

[0067] L / l: Draw a straight line to the specified coordinate point (similarly, uppercase L represents absolute coordinates, lowercase l represents relative coordinates).

[0068] H / h: Move horizontally to the specified x-coordinate (uppercase H indicates absolute coordinates, lowercase h indicates relative coordinates).

[0069] V / v: Move vertically to the specified y coordinate (uppercase V indicates absolute coordinate, lowercase v indicates relative coordinate).

[0070] C / c: Draw a cubic Bezier curve to the specified end point and specify two control points (uppercase C represents absolute coordinates, lowercase c represents relative coordinates).

[0071] S / s: Draw a cubic Bezier curve whose first control point is calculated by the control point of the previous command and the current point (uppercase S indicates absolute coordinates, lowercase s indicates relative coordinates).

[0072] Q / q: Draw a quadratic Bezier curve to the specified end point and specify a control point (uppercase Q indicates absolute coordinates, lowercase q indicates relative coordinates).

[0073] T / t: Draw a quadratic Bezier curve whose control points are calculated by the control points of the previous command and the current point (uppercase T represents absolute coordinates, lowercase t represents relative coordinates).

[0074] A / a: Draw an elliptical arc (capital A represents absolute coordinates, lowercase a represents relative coordinates).

[0075] Z / z: Close the path and return to the starting point (uppercase or lowercase indicates absolute operation).

[0076] Example: Let's say we have a simple SVG glyph path representing part of the character "A". It might look like this:

[0077] <path d="M10 10H 90V 190H 10L 50 70Z" / >

[0078] In this example:

[0079] M10 10 moves the drawing cursor to the absolute coordinates (10,10).

[0080] H 90 moves horizontally to the position x=90 to form a horizontal line segment.

[0081] V 190 moves vertically to the position y=190 to form a vertical line segment.

[0082] H 10 moves horizontally back to the position x=10 again, completing one side of the rectangle.

[0083] L 50 70 draws a line to the point (50,70); this could be a diagonal line or part of another shape.

[0084] Z closes the path and returns to the starting point (10,10).

[0085] like Figure 1 As shown, a method for bending an SVG text cutting contour includes the following steps:

[0086] S100, obtaining SVG text data, extracting text outline data from the SVG text data; reading the SVG file, locating <text>element and extract the outline information of the text.

[0087] S200, parsing the text outline data to obtain path data of each character; parsing the SVG path data of each character to identify each basic graphic element (such as lines, curves, etc.) constituting the character and its parameters.

[0088] S300, calculating the number of characters, character spacing, and text length based on the path data; counting the number of characters by analyzing the path data; measuring the horizontal distance between characters to determine the character spacing; and calculating the total length of the text by adding up the widths of all characters. Implement an algorithm to traverse the path data, calculate the bounding box of each character, and use these bounding boxes to determine the number, spacing, and total length.

[0089] S400, calculate the text bending angle according to the input bending radius and text length; use geometric relationship to associate the text length with the bending radius, and calculate the center angle of the entire text that needs to be bent. According to the circumference formula of a circle C = 2πr, match the text length with the arc length, and solve for the center angle θ = L × 360 / 2πr, where L is the text length and r is the bending radius.

[0090] S500, calculating the character deflection angle based on the text bending angle and the number of characters; evenly distributing the total bending angle to each character, thereby obtaining the deflection angle of each character relative to its neighbor. The bending angle is evenly distributed according to the number of characters, or according to the ratio of the width of the character to the text length L.

[0091] S600, calculate the new path data of each character based on the character deflection angle, so as to obtain the text bending contour data. For each character, first obtain its original path data. Then, calculate the position of the character after bending according to the deflection angle and bending radius of the character. Specifically, the new position coordinates of the character can be calculated according to the deflection angle and bending radius of the character using the rotation transformation formula. Assume that the path data of the character "A" is: "M100,100L150,200L200,100Z". For each character, extract the coordinate parameters in its path data, namely (100,100), (150,200) and (200,100). Then, according to the deflection angle and bending radius of the character, calculate the new position coordinates of the character after bending by the rotation transformation formula. Finally, the calculated new coordinate parameters constitute the new path data of the character. By combining the new path data of each character together, the bending contour data of the text can be obtained.

[0092] By analyzing the path data of each character in detail and calculating the text length, number of characters, and character spacing, this method can accurately control the bending effect of the text and ensure the quality and accuracy of the output. By recalculating the contour information based on the specified radius, this method allows the text to bend along the curved path, improving the flexibility and diversity of the design. This method reduces the need for manual operation and improves efficiency through automated steps such as automatically extracting contour data, parsing path commands, and calculating bending angles.

[0093] like Figure 2 As shown, in this implementation case, the S200 parses the text outline data to obtain the path data of each character, including the following sub-steps:

[0094] S210, extracting character path elements: In this step, it is necessary to extract the path elements of the characters from the text outline data. The path element is the basic unit for describing graphics in SVG and is used to define the outline shape of the character. By parsing the SVG text data, the element where the text is located is located, such as <text>element and extract the path element from it.

[0095] S220, parsing the path command and parameters of the character; parsing the path element of each character to obtain the path command and parameters of the character. The path command is used to indicate the way to draw the path, such as moving to a specified point, drawing a straight line, drawing a quadratic Bezier curve, etc. The parameters are the coordinate values ​​or other parameters required by the path command. By parsing the commands and parameters in the path elements, the detailed information of the character path can be obtained.

[0096] S230, obtaining the coordinates of the starting point and the ending point of the character according to the path command, and obtaining the extreme value of the character contour coordinates based on the parameters. According to the path command and the parameters, the coordinates of the starting point and the ending point of the character can be obtained. The movement command (such as M or m) in the path command is used to specify the coordinates of the starting point of the character, and the termination command (such as Z or z) in the path command is used to specify the coordinates of the ending point of the character. By parsing the path command and the parameters, the coordinates of the starting point and the ending point of the character can be obtained, and the extreme values ​​of the character contour, such as the minimum coordinate and the maximum coordinate, can be calculated based on these coordinates.

[0097] Through the analysis and calculation of the above steps, the path data of each character can be obtained, including the starting point, end point, path command and parameters and other information. These path data can be used for subsequent calculations and processing, such as calculating the text length, the number of characters, and the character spacing. The analysis process of S210 and S220 can be explained by giving an example. For example, for the path data "M100,100L150,200L200,100Z" of the character "A", the path commands and parameters such as "M", "100,100", "L", "150,200", "L", "200,100", and "Z" can be extracted. Then, according to the path command and parameters, the starting point and end point coordinates of the character can be obtained, and the extreme values ​​of the character contour can be calculated.

[0098] By parsing the path data of characters, characters of different shapes and complexities can be flexibly processed, making the processing applicable to various types of text. By extracting the path elements of characters and parsing the path commands and parameters, the starting point, end point and outline information of the characters can be accurately obtained to maintain the clarity and accuracy of the text. This method can be applied to different text data, including texts of various fonts, sizes and styles, and has strong adaptability and scalability.

[0099] like Figure 3 As shown, in this implementation case, the S300, calculating the text length, the number of characters and the character spacing based on the path data, includes the following sub-steps:

[0100] S310, counting the number of path data of the characters to obtain the number of characters; in this step, it is necessary to count the number of path data of the characters, that is, the number of path data. Each path data corresponds to one character. By counting the number of path data, the number of characters can be obtained.

[0101] S320, comparing the coordinates in the path data of all characters, calculating the extreme value difference to obtain the text length; it is necessary to compare the coordinates in the path data of all characters, calculate the extreme value difference of the character path data coordinates, that is, the distance between the maximum coordinate and the minimum coordinate, so as to obtain the length of the text. The coordinates in the path data of each character can be compared by traversing the path data, and the maximum coordinate and the minimum coordinate can be calculated. Then, by calculating the difference between the maximum coordinate and the minimum coordinate, the length of the text can be obtained.

[0102] S330, according to the coordinate extreme value difference in each character path data, the character frame is obtained, and the distance of the character frame is calculated to obtain the character spacing. In this step, according to the coordinate extreme value difference in each character path data, the character frame range can be calculated. By comparing the starting point and end point coordinates of the character, the character frame can be determined. Then, by calculating the distance of the character frame, that is, the width of the character, the character spacing is calculated. The character width can be compared with the distance between the characters to obtain the character spacing.

[0103] Through the above steps, the number of characters, character spacing and text length can be calculated. These calculation results can be used for the subsequent calculation of text bending angle and character deflection angle. For example, for an SVG text data containing path data of characters "A" and "B", the number of path data can be counted to get the number of characters, the coordinates in the character path data can be compared to get the text length, and the distance of the character border can be calculated to get the character spacing.

[0104] By comparing the coordinates in the path data and calculating the extreme value difference, the length and character spacing of the text can be accurately calculated, ensuring the accuracy of the text bending effect. This method is suitable for texts of different fonts, sizes and styles, and has strong adaptability and scalability. Through automated steps, such as counting the number of path data, calculating text length and character spacing, the need for manual operation is reduced and the efficiency of calculation is improved.

[0105] like Figure 4 As shown, in this implementation case, S400, the calculation of the text bending angle according to the input bending radius and text length includes the following sub-steps:

[0106] S410, calibrating the text length as the arc length; treating the input text length as the length of the arc to be bent. Using the text length as the calibration of the arc length.

[0107] S420, calculate the center angle value corresponding to the arc length according to the input bending radius; calculate the center angle value corresponding to the arc length according to the input bending radius and text length through geometric relationship. The relationship between the arc length and the radius can be used for calculation. For example, arc length = bending angle × π / 180 × bending radius. By taking the text length as the arc length, the center angle value can be obtained.

[0108] S430: The center angle value is calibrated as the text bending angle required for the text to be bent. The calculated center angle value is used as the text bending angle. The center angle value is used as the text bending angle required for subsequent text bending processing.

[0109] Through the above steps, the bending angle of the text can be calculated according to the input bending radius and text length. For example, if the input bending radius is 100 and the text length is 200, the text length can be calibrated as the arc length of 200. Then, according to the relationship between the bending radius and the arc length, the corresponding center angle value is calculated. Finally, the calculated center angle value is used as the bending angle of the text.

[0110] By associating the text length with the arc length, the text bending angle can be flexibly calculated based on the input bending radius to meet the bending effects of different requirements. By accurately calculating the center angle value to determine the text bending angle, the accuracy and consistency of the text bending can be guaranteed. By inputting the bending radius and text length, the text bending effect can be precisely controlled to meet the needs of design and manufacturing.

[0111] like Figure 5 As shown, in this implementation case, we assume that the center of the circle is located on the central axis of the text string, and S500, the calculation of the character deflection angle based on the text bending angle and the number of characters includes the following sub-steps:

[0112] S510, determine the center coordinates according to the bending radius; in this step, the center coordinates can be determined based on the coordinate extreme values ​​of the text string and the bending radius. Assume that the coordinate extreme values ​​of the text string are (x_min, y_min) and (x_max, y_max), and the bending radius is r. The center coordinates can be calculated as follows: the x coordinate of the center is (x_min+x_max) / 2, and the y coordinate of the center is y_min+r.

[0113] S520, calculate the text starting angle based on the center coordinates and the text bending angle; if the text needs to be symmetrically bent relative to the center, divide the text bending angle by 2 to get the starting angle. If the center angle is 90 degrees, the text will be divided into two parts, each 45 degrees.

[0114] S530. Calculate the rotation angle and direction of each character based on the text starting angle and the number of characters. The rotation angle of each character determines its position in the curved text. The rotation angle is assigned to each character based on the text starting angle and the text bending angle. The total text bending angle is evenly distributed to each character. If the text bending angle cannot be divided by the number of characters, it can be adjusted appropriately. For each character, starting from the starting angle, add the rotation angle of each character in turn. Determine the rotation direction of each character, which is usually consistent with the bending direction.

[0115] Assume we have the following conditions:

[0116] Number of characters: 5

[0117] Center angle: 90 degrees

[0118] Starting point angle: 45 degrees (half of the center angle of the circle)

[0119] Calculation process:

[0120] The rotation angle of each character: 90°5=18°590°=18°

[0121] For each character, start from the starting point angle and add the rotation angle of each character in turn.

[0122] For example, if our text is "HELLO", the calculation process is as follows:

[0123] 'H': 45° (starting point angle)

[0124] 'E': 45°+18°=63°

[0125] 'L': 63°+18°=81°

[0126] 'L':81°+18°=99°

[0127] 'O':99°+18°=117°

[0128] In this way, we can ensure that the text is curved symmetrically around the center of the circle and that each character is positioned correctly along the curved path.

[0129] By accurately calculating the rotation angle and position of each character, it is possible to ensure that the text remains evenly distributed and in the correct shape when it is bent. The text is bent symmetrically around the center of the circle, providing visual balance and symmetry, which is very important for design and display. This method allows the rotation angle of the characters to be adjusted according to different bending radii and text lengths, making it suitable for different design requirements and bending scenarios. The automated calculation process reduces manual intervention, improves efficiency, and reduces errors caused by manual adjustments. The solution can adapt to different numbers of characters and different text lengths, and has good adaptability and scalability.

[0130] like Figure 6 As shown, in this implementation case, the S530, calculating the rotation angle and direction of each character according to the text starting point angle and the number of characters, specifically includes the steps of:

[0131] S531, based on the number of characters, character spacing, and text length; the number of characters determines how many independent elements in the text need to be positioned. Character spacing refers to the space between adjacent characters, which is important for determining the rotation angle of each character. The text length is the sum of all character widths and the sum of character spacing, which provides the horizontal space occupied by the entire text string.

[0132] Count the total number of characters in the text to get the character count. Measure or calculate the spacing between characters, which can be a fixed value or a dynamic value based on a specific font and size. Add up the width of all characters and the spacing between characters to get the length of the entire text.

[0133] S532, calculating the sum of the width of each character and the width of the adjacent character spacing; the width of each character refers to the space occupied by the character itself. The width of the adjacent character spacing refers to the space between characters, which is important for maintaining visual balance between characters when the text is curved.

[0134] For each character, measure its width. Determine the width of the space after (or before) each character. Add the width of each character to the width of the space between its neighbors to get the total width of each character.

[0135] S533. The rotation angle of each character is obtained based on the ratio of the sum of the widths to the length of the text. The rotation angle of each character is calculated based on its proportion in the total length of the text. This method ensures that when the text is bent, each character is properly rotated according to its relative position in the text. Calculate the total length of the text, that is, the sum of all character widths and character spacing. For each character, calculate the sum of its width and the width of the spacing between adjacent characters. Divide the sum of the widths of each character by the total length of the text to obtain the proportion of the character in the text. Multiply the text bending angle (center angle) by the proportion of each character to obtain the rotation angle of each character.

[0136] Assume we have the following conditions:

[0137] Character: "HELLO"

[0138] Number of characters: 5

[0139] Character width (assuming unit width): H = 10, E = 8, L = 7, O = 10

[0140] Character spacing (assuming unit spacing): 3

[0141] Center angle: 90 degrees

[0142] Calculation process:

[0143] Calculate the total length of the text: Total length = (H + spacing) + (E + spacing) + (L + spacing) + (L + spacing) + (O + spacing) - no spacing after the last character Total length = (H + spacing) + (E + spacing) + (L + spacing) + (L + spacing) + (O + spacing), no spacing after the last character

[0144] Total length = (10+3)+(8+3)+(7+3)+(7+3)+10 = 58

[0145] Calculate the sum of the width of each character and the width of the space between adjacent characters:

[0146] H: 10 (width) + 3 (pitch) = 13

[0147] E:8+3=11

[0148] L:7+3=10

[0149] L:7+3=10

[0150] O:10 (no subsequent spacing)

[0151] Calculate the rotation angle of each character:

[0152] H:1358×90°≈20.69°5813×90°≈20.69°

[0153] E:1158×90°≈16.67°5811×90°≈16.67°

[0154] L:1058×90°≈15.52°5810×90°≈15.52°

[0155] L:1058×90°≈15.52°5810×90°≈15.52°

[0156] O:1058×90°≈15.52°5810×90°≈15.52°

[0157] Each character gets a corresponding bending angle according to the space it actually occupies, making the bent text more natural and harmonious visually. Simply bisecting the angles of characters of different widths may lead to visual imbalance, especially when the widths of the characters vary greatly. Allocating angles by width can avoid this problem. The text may contain characters of different widths, and allocating angles according to the space actually occupied by the characters can adapt to the changes in various fonts and text content. Bisecting the angles may cause some characters to be too crowded and others to be too sparse. Allocating angles according to character width can make more reasonable use of space. The effect of text bending is more harmonious, enhancing the overall beauty and artistry.

[0158] like Figure 7 As shown, in this implementation case, S600, the step of calculating the new path data of each character based on the character deflection angle to obtain the text bending contour data specifically includes the following steps:

[0159] S610, obtain the path data of each character and extract all coordinate parameters in the path data; the SVG path is defined by a series of path commands and coordinate parameters, which together describe the outline of the character. The path data of each character is extracted in order to be able to transform them to adapt to the bending effect of the text. To locate the characters in the SVG file, the path data of each character is usually wrapped in <path>element. Read each <path>The "d" attribute of the element contains the path data of the character. Analyze the content of the "d" attribute and extract all the coordinate parameters.

[0160] S620. Calculate the new coordinate parameters after rotation based on the coordinates of the center of the circle and the rotation angle and direction of each character; rotating a point around the center of the circle can be achieved by changing the coordinates of the point, and this process is called the rotation transformation of the point. The Pythagorean theorem is used here to calculate the coordinates after the rotation transformation to ensure that the point remains on the correct curved path after rotation. Determine the rotation angle of each character, which is usually calculated based on the position of the character in the text and the total curvature angle of the text. For each coordinate point of each character, use the rotation angle and the coordinates of the center of the circle to calculate the new coordinates:

[0161] x′=x*cos(θ)-y*sin(θ)+H

[0162] y′=x*sin(θ)+y*cos(θ)+V, where x, y are the original coordinates, θ is the rotation angle, and H, V are the coordinates of the center of the circle.

[0163] Use the Pythagorean theorem to calculate the new coordinates, ensuring that the rotated points lie on the curved path.

[0164] S630, the new coordinate parameters constitute the new path data of the rotated characters, and the new path data of each character constitutes the number of curved contours of the text. The calculated new coordinates are reassembled into the format of SVG path commands for use in SVG graphics. The new path data defines the contour of the character after bending. The path data of each character is updated using the calculated new coordinates. According to the syntax of the SVG path command, the path data of each character is reconstructed. All the rotated character path data are combined to form the curved contour of the entire text.

[0165] Examples demonstrate calculation process and results

[0166] Assume we have the following conditions:

[0167] Character: "A"

[0168] Part of the original path data (simplified representation): "M10 10L20 20L30 10"

[0169] Center coordinates: (H, V) = (25, 15)

[0170] Rotation angle: 45 degrees (clockwise rotation based on the center of the circle)

[0171] Bending radius: r = 10

[0172] Calculation process:

[0173] Extract the coordinate parameters from the original path data of "A": (10,10), (20,20), (30,10).

[0174] Apply a rotation angle of 45 degrees to each coordinate point to calculate the new coordinates:

[0175] For the point (10,10), calculate the new coordinates:

[0176] x′=10*cos(45°)-10*sin(45°)+25

[0177] y′=10*sin(45°)+10*cos(45°)+15

[0178] The new coordinates are calculated, for example: (10,10) may become (x',y') after rotation.

[0179] Repeat the above steps to calculate the new coordinates of all points.

[0180] Update the SVG path data with the new coordinates, forming a new path command:

[0181] The new path data may be: "M x'y'L x"y"L x"'y"'"

[0182] Sample result: If the original path is "M10 10L20 20L30 10", and after the above calculation process, we may get new path data, for example: "M15 19L22.5 27.5L30 20". Here, the coordinates after each "M" and "L" command are new coordinates calculated through rotation transformation.

[0183] By calculating the rotation angle of each character and the rotation transformation based on the center coordinates of the circle, it is possible to ensure that the contour of the text after bending is consistent with the expectation. The rotation transformation is based on the Pythagorean theorem, which ensures that the points after rotation are on the correct bending path, thereby maintaining the accuracy and precision of the text. This solution can adapt to texts of different sizes and shapes and is suitable for texts of various fonts and styles. By using the calculated rotation angle and center coordinates, the position and angle of each character after bending can be flexibly adjusted to meet different design requirements and bending effects. By automatically extracting the path data of the characters and calculating the rotation angle, the solution reduces the need for manual operation and improves efficiency. Through automatic calculation and processing, the bending contour data of the text can be generated quickly and accurately, reducing the errors and time costs of manual intervention.

[0184] like Figure 8-9 As shown, the above technical solution can accurately obtain the contour information of each character, including the starting point, end point and extreme coordinates of the contour, by parsing the SVG path commands and parameters. This provides an accurate data basis for subsequent bending processing. The automated steps in the solution reduce the need for manual operation. From extracting contour data, parsing path commands to calculating bending angles, the entire process does not require manual intervention, which improves efficiency. By recalculating contour information based on the specified bending radius, the text can be bent along any curved path, improving the flexibility and diversity of the design. This method is suitable for texts of different fonts, sizes and styles, has strong adaptability and scalability, and can handle characters of various shapes and complexities. By allocating the rotation angle according to the actual space occupied by the character, the visual naturalness and coordination of the text is ensured, enhancing the overall beauty and artistry.

[0185] It should be noted that there is not necessarily a certain order between the above-mentioned steps. A person skilled in the art can understand, based on the description of the embodiments of the present invention, that in different embodiments, the above-mentioned steps may have different execution orders, that is, they may be executed in parallel, may be executed interchangeably, and so on. For specific implementation methods, please refer to the above-mentioned corresponding product embodiments, which will not be repeated here.

[0186] like Fig.10 As shown, another embodiment of the present invention further provides a device for bending an SVG text cutting contour, the device comprising:

[0187] The outline data extraction module 10 is used to obtain SVG text data and extract text outline data from the SVG text data;

[0188] A path data parsing module 20, used to parse the text outline data to obtain path data of each character;

[0189] A text information calculation module 30, for calculating text length, number of characters and character spacing based on the path data;

[0190] A text radius input module 40, used to calculate the text bending angle according to the input bending radius and text length;

[0191] A character angle calculation module 50, used for calculating a character deflection angle based on the text bending angle and the number of characters;

[0192] The curved path generating module 60 is used to calculate the new path data of each character based on the character deflection angle, so as to obtain the text curved contour data.

[0193] Work process analysis:

[0194] Contour data extraction module: First, this module is responsible for obtaining text data from the SVG file and extracting the text contour information from it. This is the starting point for the bending process, ensuring that the subsequent steps have accurate data for processing.

[0195] Path data parsing module: This module further parses the extracted text outline data to obtain detailed path data for each character. These data include SVG path commands and parameters, which define the shape of the character outline.

[0196] Text information calculation module: Based on the parsed path data, this module calculates the total length of the text, the number of characters, and the spacing between characters. This information is crucial to determine how the text is distributed on the curved path.

[0197] Text radius input module: This module allows users to input the bending radius, and then calculates the center angle required for text bending based on the text length and the input bending radius.

[0198] Character Angle Calculation Module: Using the text's bending angle and the number of characters, this module calculates the angle each character should be deflected to ensure that characters are evenly distributed when the text is bent.

[0199] Curved path generation module: Finally, this module calculates new path data according to the deflection angle of each character and generates curved text contour data, which can be used for actual cutting or display.

[0200] Another embodiment of the present invention provides a bending system for SVG text cutting contour, such as Fig.11 As shown, the system 70 includes:

[0201] One or more processors 710 and memory 720, Figure 5 A processor 710 is used as an example for description. The processor 710 and the memory 720 may be connected via a bus or other means. Fig.11 The example of connecting through bus is taken in the following.

[0202] Processor 710 is used to complete various control logics of system 50, which can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), a single-chip microcomputer, an ARM (Acorn RISC Machine) or other programmable logic device, a discrete gate or transistor logic, a discrete hardware component or any combination of these components. In addition, processor 710 can also be any traditional processor, microprocessor or state machine. Processor 710 can also be implemented as a combination of computing devices, for example, a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors combined with a DSP and / or any other such configuration.

[0203] The memory 720 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions corresponding to the method for bending the contour of SVG text cutting in the embodiment of the present invention. The processor 710 executes various functional applications and data processing of the system 50 by running the non-volatile software programs, instructions and units stored in the memory 720, that is, implements the method for bending the contour of SVG text cutting in the above method embodiment.

[0204] The memory 720 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required by at least one function; the data storage area may store data created according to the use of the system 50, etc. In addition, the memory 720 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 720 may optionally include a memory remotely arranged relative to the processor 710, and these remote memories may be connected to the system 50 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0205] like Fig.11 As shown, one or more units are stored in the memory 720, and when executed by one or more processors 710, the bending method of the SVG text cutting contour in any of the above method embodiments is executed, for example, the above described Figure 1 The method comprises steps S100 to S600.

[0206] An embodiment of the present invention provides a non-volatile computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by one or more processors, for example, to execute the above-described Figure 1 The method comprises steps S100 to S600.

[0207] As an example, the non-volatile storage medium can include a read-only memory (ROM), a programmable ROM (PROM), an electrically programmable ROM (EPROM), an electrically erasable ROM (EEPROM), or a flash memory. Volatile memory can include a random access memory (RAM) as an external cache memory. By way of illustration and not limitation, RAM can be obtained in many forms such as synchronous RAM (SRAM), dynamic RAM, (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), and direct Rambus RAM (DRRAM). The disclosed memory components or memories of the operating environment described herein are intended to include one or more of these and / or any other suitable types of memory.

[0208] Another embodiment of the present invention provides a computer program product, the computer program product includes a computer program stored in a non-volatile computer-readable storage medium, the computer program includes program instructions, when the program instructions are executed by a processor, the processor executes the method for bending the SVG text cutting contour of the above method embodiment. For example, executing the above described Figure 1 The method comprises steps S100 to S600.

[0209] In summary, the present invention discloses a method, device, system and medium for bending the outline of SVG text cutting, and provides a complete set of solutions, aiming to achieve efficient, accurate and automatic processing of SVG format text data, so as to apply these text data to various design and manufacturing scenarios. The following are the main features and advantages of the present invention:

[0210] Comprehensiveness: The invention not only includes the bending method, but also covers the devices, systems and storage media required to implement the method, providing users with a complete solution.

[0211] Innovation: By automatically extracting and parsing SVG text data, and calculating text bending angles and character deflection angles, the present invention provides a novel method for processing text data to adapt to different design requirements.

[0212] Efficiency: The automated process significantly reduces manual intervention, thereby improving work efficiency and shortening the cycle from design to production.

[0213] Precision: Exact calculation methods ensure that the bent text meets high quality standards both visually and functionally.

[0214] Flexibility and adaptability: The method and apparatus of the present invention can adapt to different design requirements, including different fonts, sizes, styles and bending radii, and have good versatility.

[0215] User-friendly: With simplified operation process and input module, users can easily input parameters and get the desired curved text results.

[0216] Easy to integrate: The modular design allows the present invention to be easily integrated into existing design and manufacturing systems without the need for large-scale system modifications.

[0217] Reduced Errors: Automated data processing reduces human errors and improves product consistency and reliability.

[0218] Improve design flexibility: Designers can explore different text bending effects more freely to create more creative and attractive designs.

[0219] Promoting technological development: The present invention promotes the development of SVG text processing technology and provides new possibilities for technological innovation and application in related fields.

[0220] In summary, the present invention not only improves the efficiency and quality of design and production by providing an innovative bending method for SVG text cutting contours and corresponding devices, systems and media, but also provides designers with greater creative freedom, which helps to promote technological progress and innovative development in related industries.

[0221] The embodiments described above are merely illustrative, in which the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0222] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a general hardware platform, and of course can also be implemented by hardware. Based on such an understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can exist in a computer-readable storage medium, such as ROM / RAM, a base disk, an optical disk, etc., including several instructions for enabling a computer electronic device (which can be a personal computer, a server, or a network electronic device, etc.) to execute various embodiments or certain parts of the embodiments.

[0223] Conditional language such as "can," "can," "might," or "may," among other things, unless specifically stated otherwise or otherwise understood within the context as used, is generally intended to convey that a particular embodiment can include (while other embodiments do not) a particular feature, element, and / or operation. Thus, such conditional language is also generally intended to imply that a feature, element, and / or operation is required for one or more embodiments anyway or that one or more embodiments must include logic for determining whether such features, elements, and / or operations are included or will be performed in any particular embodiment, with or without input or prompting.

[0224] What has been described herein in this specification and the accompanying drawings includes examples of bending methods, devices, systems and media that can provide an SVG text cutting profile. Of course, it is not possible to describe every conceivable combination of elements and / or methods for the purpose of describing the various features of the present disclosure, but it can be recognized that many other combinations and permutations of the disclosed features are possible. Therefore, it is obvious that various modifications can be made to the present disclosure without departing from the scope or spirit of the present disclosure. In addition, or in the alternative, other embodiments of the present disclosure may be apparent from consideration of the present specification and the accompanying drawings and from the practice of the present disclosure as presented herein. It is intended that the examples set forth in this specification and the accompanying drawings are considered to be illustrative and not restrictive in all respects. Although specific terms are employed herein, they are used in a general and descriptive sense and are not used for limiting purposes.< / path> < / path> < / text> < / text> < / path> < / path>

Claims

1. A method for bending an SVG text cutting contour, characterized in that: The following steps are involved: Acquire SVG text data, and extract text outline data from the SVG text data; Parsing the text outline data to obtain path data of each character; Calculate the number of characters, character spacing, and text length based on the path data; Calculate the text bending angle based on the input bending radius and text length; Calculating a character deflection angle based on the text bending angle and the number of characters; New path data of each character is calculated based on the character deflection angle, thereby obtaining text bending contour data.

2. The bending method according to claim 1, characterized in that: The step of parsing the text outline data to obtain the path data of each character comprises the following sub-steps: Extract string path elements; Parse string path commands and arguments; Get the starting and ending coordinates of the character according to the path command, and get the extreme values ​​of the character contour coordinates based on the parameters.

3. The bending method according to claim 1, characterized in that: The calculating of text length, number of characters and character spacing based on the path data comprises the following sub-steps: Count the path data of the characters to get the number of characters; Compare the coordinates of all characters in the path data and calculate the extreme value difference to get the text length; The character border is obtained based on the coordinate extreme value difference in each character path data, and the character spacing is obtained by calculating the distance of the character border.

4. The bending method according to claim 1, characterized in that: The method of calculating the text bending angle according to the input bending radius and text length includes the following sub-steps: Scale the text length to the arc length; Calculate the central angle value corresponding to the arc length based on the input bending radius; The center angle value is calibrated as the text bending angle required for the text to be bent.

5. The bending method according to claim 1, characterized in that: The step of calculating the character deflection angle based on the text bending angle and the number of characters comprises the following sub-steps: Determine the coordinates of the center of the circle according to the bending radius; Calculate the text starting point angle based on the circle center coordinates and the text bending angle; The rotation angle and direction of each character are calculated according to the text starting point angle and the number of characters.

6. The bending method according to claim 5, characterized in that: The step of calculating the rotation angle and direction of each character according to the text starting point angle and the number of characters specifically includes the following steps: Based on the number of characters, character spacing, and text length; Calculate the sum of the width of each character and the width of the spacing between adjacent characters; The rotation angle of each character is calculated based on the ratio of the sum of the widths to the length of the text.

7. The bending method according to claim 5, characterized in that: The step of calculating the new path data of each character based on the character deflection angle to obtain the text bending contour data specifically includes the following steps: Get the path data of each character and extract all coordinate parameters in the path data. Calculate the new coordinate parameters after rotation according to the center coordinates of the circle and the rotation angle and direction of each character; The new coordinate parameters constitute the new path data of the rotated characters, and the new path data of each character constitutes the number of curved contours of the text.

8. A bending device for cutting contours of SVG text, characterized in that: The device comprises: An outline data extraction module is used to obtain SVG text data and extract text outline data from the SVG text data; A path data parsing module, used for parsing the text outline data to obtain path data of each character; A text information calculation module, used to calculate the text length, the number of characters and the character spacing based on the path data; A text radius input module is used to calculate the text bending angle according to the input bending radius and text length; A character angle calculation module, used for calculating a character deflection angle based on the text bending angle and the number of characters; The curved path generation module is used to calculate new path data of each character based on the character deflection angle, so as to obtain text curved contour data.

9. A bending system for SVG text cutting contour, characterized in that: The system includes at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method for bending the SVG text cutting contour described in any one of claims 1-7.

10. A non-volatile computer-readable storage medium, characterized in that: The non-volatile computer-readable storage medium stores computer-executable instructions, which, when executed by one or more processors, enable the one or more processors to execute the method for bending the SVG text cutting contour as described in any one of claims 1-7.

Citation Information

Cited By

  • Deformed character typesetting rendering method, device and equipment based on path

    CN121236228A