Printing processing method and device, electronic equipment and storage medium

By obtaining and processing the coordinate point array of target glyphs in Wine, initializing and traversing the drawing start and end points, ensuring the accurate drawing of cubic Bezier curves, solving the problem of abnormal printing text curves in Wine, improving printing compatibility and user Experience.

CN119166084APending Publication Date: 2024-12-20ZHONGKE FANGDE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411403623.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-05
Publication Date
2024-12-20

AI Technical Summary

Technical Problem

Printed text based on PostScript language in Wine may have curve printing abnormalities, which will affect the compatibility of printing functions and user reading quality.

Method used

By obtaining the coordinate point array of target glyphs, initializing the drawing starting point and end point, defining the cubic Bezier curve array, and determining whether to draw a straight line or curve according to the coordinate point category, ensuring the accurate drawing of the curve and avoiding abnormal situations.

Benefits of technology

Improves the compatibility of the printing function in Wine and the user reading quality, ensures accurate drawing of curves, and avoids curve abnormalities in printed text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119166084A_ABST
    Figure CN119166084A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a printing processing method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining a first array of a target font in response to a printing task; initializing a drawing starting point and a drawing ending point based on the coordinate points in the first array; defining a second array used for drawing a cubic Bezier curve, and initializing the second array based on a drawing starting point; traversing the first array from the drawing starting point, and if the category of the next coordinate point of the traversed current coordinate point is an end point, drawing a straight line from the current drawing point; and if the category of the next coordinate point of the traversed current coordinate point is a control point, updating the second array based on the current coordinate point and the next coordinate point, and drawing the cubic Bezier curve from the current drawing point according to the updated second array. According to the method and the device, the condition that the curve in the printed character is abnormal can be avoided, and the compatibility of the printing function in the Wine is improved.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This divisional application is a divisional application of a Chinese patent application with the application number 202411064825.X, the application date of August 5, 2024, and the invention title of "Printing Processing Method, Device, Electronic Device and Storage Medium". Technical Field

[0002] This application relates to the field of computer technology, and particularly to a printing processing method, device, electronic device, and storage medium. Background Art

[0003] Wine (Wine Is Not an Emulator) is an open-source compatibility layer that can run Windows programs on Unix-like operating systems (such as Linux, macOS, etc.).

[0004] PostScript is a page description language that can be used on various operating systems and printers for printing and displaying documents. To implement the file printing function in the Wine environment, a Wine PostScript driver (i.e., wineps.drv) can be built into Wine to simulate the printer device driver in the Windows environment. When an application running in Wine receives a print task triggered by the user, it calls wineps.drv to generate print instructions based on the PostScript language, thereby executing the print task.

[0005] The outline of a glyph is defined by a series of connected straight lines and curves. When printing text based on the PostScript language in Wine, for the curves in the glyph, printing anomalies may occur. Refer to Figure 1 , which shows a schematic diagram of the effect of printing text in Wine. Figure 1 (a) shows the expected printing effect, Figure 1 (b) shows the actual printing effect. Among them, the right-falling stroke of the character "术" is a curve, and printing anomalies occur. Summary of the Invention

[0006] In view of the above problems, embodiments of the present application are proposed to provide a printing processing method that can overcome the above problems or at least partially solve the above problems, which can avoid anomalies in the curves of printed text and improve the compatibility of the printing function in Wine.

[0007] Correspondingly, embodiments of the present application also provide a printing processing device, an electronic device, and a storage medium to ensure the implementation and application of the above method.

[0008] In a first aspect, an embodiment of the present application discloses a printing processing method, the method comprising:

[0009] In response to the printing task, a first array of the target glyph is obtained; the first array includes each coordinate point of the target glyph and a category of each coordinate point, wherein the category includes an endpoint or a control point;

[0010] Initialize the drawing starting point and the drawing end point based on the coordinate points in the first array;

[0011] A second array for drawing a cubic Bezier curve is defined, and the second array is initialized based on the drawing starting point; the first element, the second element and the third element in the second array are respectively used to record the first control point, the second control point and the termination endpoint of the cubic Bezier curve to be drawn;

[0012] Traversing the first array from the drawing starting point, if the category of the next coordinate point of the traversed current coordinate point is an endpoint, drawing a straight line from the current drawing point;

[0013] If the category of the next coordinate point of the traversed current coordinate point is a control point, the second array is updated based on the current coordinate point and the next coordinate point, and a cubic Bezier curve is drawn starting from the current drawing point according to the updated second array.

[0014] In a second aspect, an embodiment of the present application discloses a printing processing device, the device comprising:

[0015] A data acquisition module, configured to acquire a first array of a target glyph in response to a printing task; the first array includes each coordinate point of the target glyph and a category of each coordinate point, wherein the category includes an endpoint or a control point;

[0016] A first initialization module, used for initializing a drawing start point and a drawing end point based on the coordinate points in the first array;

[0017] A second initialization module is used to define a second array for drawing a cubic Bezier curve, and initialize the second array based on the drawing starting point; the first element, the second element and the third element in the second array are respectively used to record the first control point, the second control point and the termination endpoint of the cubic Bezier curve to be drawn;

[0018] A traversal drawing module is used to traverse the first array from the drawing starting point, and if the category of the next coordinate point of the traversed current coordinate point is an endpoint, a straight line is drawn from the current drawing point; if the category of the next coordinate point of the traversed current coordinate point is a control point, the second array is updated based on the current coordinate point and the next coordinate point, and a cubic Bezier curve is drawn from the current drawing point according to the updated second array.

[0019] In the third aspect, an embodiment of the present application discloses an electronic device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the steps of any of the printing processing methods described above.

[0020] In a fourth aspect, an embodiment of the present application discloses a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, any printing processing method described in the embodiment of the present application can be implemented.

[0021] The printing processing method, device, electronic device and storage medium provided by the embodiments of the present application have the following advantages:

[0022] The present application provides a printing processing method that can be used to implement a printing function in Wine. The present application improves the process of executing a printing task by a PostScript driver in Wine. In the process of drawing a target glyph, each coordinate point in the first array of the target glyph is judged and processed. When initializing the second array used to draw a cubic Bezier curve, a more accurate initial value is assigned. In the process of drawing a target glyph, when drawing a curve in the target glyph, the coordinates of the accurate cubic Bezier curve can be calculated, so that the cubic Bezier curve can be accurately drawn, avoiding abnormalities in the curve in the printed text, improving the compatibility of the printing function in Wine, and improving the reading quality of the user. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 This is a diagram of the effect of printing text in Wine;

[0024] Figure 2 It is a schematic diagram of the font outline of a text;

[0025] Figure 3 is a flow chart of steps of an embodiment of a printing processing method of the present application;

[0026] Figure 4 It is a schematic diagram of the conversion from a quadratic Bezier curve to a cubic Bezier curve;

[0027] Figure 5 It is a schematic diagram of a continuous quadratic Bezier curve;

[0028] Figure 6 It is a glyph diagram that includes a quadratic Bezier curve;

[0029] Figure 7is another glyph diagram that includes a quadratic Bezier curve;

[0030] Figure 8 is a flow chart of a printing processing method in an example of the present application;

[0031] Fig. 9 is a schematic diagram of a target glyph;

[0032] Fig.10 This application is for Figure 8 Step 1 in the improved process diagram;

[0033] Fig.11 is a structural block diagram of an embodiment of a printing processing device of the present application;

[0034] Fig.12 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0035] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0036] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally a class, and the number of objects is not limited. For example, the first object can be one or more. In addition, the term "and / or" in the specification and claims is used to describe the association relationship of associated objects, indicating that three kinds of relationships can exist, for example, A and / or B can be represented: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the front and back associated objects are a kind of "or" relationship. In the embodiment of the present application, the term "multiple" refers to two or more, and other quantifiers are similar.

[0037] First, the concepts involved in this application are explained.

[0038] Wine: is an open source compatibility layer that allows running Windows programs on Unix-like operating systems (such as Linux, macOS).

[0039] PostScript: is a page description language originally developed by Adobe. It is widely used for printing and displaying documents, especially in graphic design, desktop publishing and printing industries.

[0040] Bezier curve: A mathematical curve commonly used in computer graphics, computer-aided design (CAD), image processing, etc. For example, it is used to draw curves, paths, fonts, etc. It has good mathematical properties and flexibility, and the shape of the curve can be precisely controlled by adjusting the control points.

[0041] Glyph: The appearance form of a single character.

[0042] Font: That is, the character style (such as the writing style), or called the font type, is a collection of glyphs with the same appearance style (style) and the same typesetting size (width, height, and line spacing). From the perspective of "style" (style category), it is a type; from the perspective of glyphs, it is a collection.

[0043] Reference Figure 2 , shows a schematic diagram of the font outline of a text. As Figure 2 shown, the glyph of the character "术" drawn includes two outlines, and the font of this "术" character is the "FangSong" font.

[0044] The outlines in the glyph are defined by a series of connected straight lines and curves, which form a closed path and constitute the glyph of the character. These outlines describe the shape of the character, where each outline represents a part of the character.

[0045] In font design, the description of the outline usually uses vector graphics representation, which includes the following main elements:

[0046] Line Segment: A straight line between two endpoints, used to construct the basic geometric shape of the character.

[0047] Bézier Curve: A curve description method that uses control points to define the shape of the curve. In font design, quadratic Bézier curves or cubic Bézier curves are usually used.

[0048] Control Point: A point used to define the shape of the Bézier curve. A quadratic Bézier curve has one control point, while a cubic Bézier curve has two control points.

[0049] Closed Path: The outline is a closed path composed of a series of connected straight lines and curves, making the formed area enclosed inside.

[0050] Font designers use these elements to create the outlines of glyphs, adjusting the position, length, and curvature of straight and curved lines to achieve the effect of designing glyphs. Some characters may contain multiple outlines, especially those with holes or multi-part structures.

[0051] This vector graphics representation allows characters to scale and display smoothly at different sizes and resolutions, providing the basis for the scalability and clarity of the font.

[0052] Figure 3 A flowchart of a printing processing method embodiment of the present application is shown. The method is applied to Wine and may include the following steps:

[0053] Step 101: In response to a printing task, a first array of a target glyph is obtained; the first array includes each coordinate point of the target glyph and a category of each coordinate point, wherein the category includes an endpoint or a control point;

[0054] Step 102: Initialize the drawing start point and the drawing end point based on the coordinate points in the first array;

[0055] Step 103: define a second array for drawing a cubic Bezier curve, and initialize the second array based on the drawing starting point; the first element, the second element and the third element in the second array are respectively used to record the first control point, the second control point and the termination endpoint of the cubic Bezier curve to be drawn;

[0056] Step 104, traversing the first array from the drawing starting point, if the category of the next coordinate point of the traversed current coordinate point is an endpoint, drawing a straight line from the current drawing point;

[0057] Step 105: If the category of the next coordinate point of the traversed current coordinate point is a control point, the second array is updated based on the current coordinate point and the next coordinate point, and a cubic Bezier curve is drawn starting from the current drawing point according to the updated second array.

[0058] The printing processing method of the embodiment of the present application can be applied to a computer device based on a Linux operating system, wherein the Linux operating system is configured with an intermediate layer. The computer device may include but is not limited to any of the following: a server, a smart phone, a voice recorder, a tablet computer, an e-book reader, an MP3 (Moving Picture Experts Group Audio Layer III) player, an MP4 (Moving Picture Experts Group Audio Layer IV) player, a laptop computer, a car computer, a desktop computer, a set-top box, a smart TV, a wearable device, etc.

[0059] The embodiment of the present application does not limit the type of the Linux operating system. For example, the Linux operating system may include but is not limited to any one of Debian, Ubuntu, CentOS (Community Enterprise Operating System), UOS (Unicom Desktop Operating System), Kylin Operating System, and Fangde Operating System.

[0060] In the embodiment of the present application, the middle layer refers to a compatibility layer that can translate Windows applications into Linux applications, and the middle layer can realize running Windows programs on Unix-like operating systems. The middle layer includes but is not limited to Wine and its downstream software.

[0061] In the embodiment of the present application, when the Windows program running in Wine receives a print task triggered by a user, the PostScript driver (such as wineps.drv) in Wine is called to execute the print task. wineps.drv receives and interprets the print task, generates a PostScript file, and the content of the PostScript file is a series of PostScript instructions. wineps.drv sends the PostScript file to the printer, that is, sends a series of PostScript instructions in the PostScript file to the printer, which is executed by the printer to complete the print task.

[0062] The embodiment of the present application optimizes the process of executing a printing task by a PostScript driver (such as wineps.drv) in Wine to avoid abnormal curve printing.

[0063] In one example, the printing task is to print a certain text file in Wine. For each character to be printed in the text file, the process shown in Figure 3 is executed. The target glyph refers to the appearance form of the character to be printed currently. The character to be printed currently can be any character such as Chinese characters, letters of other languages, etc.

[0064] Each character has a corresponding unicode encoding. The glyph information of the target glyph can be obtained first through the unicode encoding, and then the process shown in Figure 3 is executed. The glyph information of the target glyph can be recorded by a first array. The glyph information may include each coordinate point in the target glyph and the category of each coordinate point, and the category includes end points or control points.

[0065] In the embodiments of the present application, the process of printing the target glyph is also called the process of drawing the target glyph. After obtaining the first array of the target glyph, the drawing start point (denoted as start_pos for example) and the drawing end point (denoted as end_pt for example) of the target glyph can be initialized. In the embodiments of the present application, the coordinate point representation form is (x, y), where x represents the abscissa of the point and y represents the ordinate of the point. Exemplarily, start_pos can be initialized as the first coordinate point in the first array (also called the starting point in the first array), and end_pt can be initialized as the last coordinate point in the first array (also called the ending point in the first array). In one example, assume that 40 coordinate points are required to draw the glyph of the character "术". Then the first array of the character "术" can include these 40 coordinate points and the category of each coordinate point. Assume that the first coordinate point is initialized as the drawing start point start_pos, and the 40th coordinate point is initialized as the drawing end point end_pt.

[0066] The drawing process of the target glyph starts from the drawing start point start_pos, and the drawing operation is performed by traversing the coordinate points in the first array until the drawing end point is traversed and ends.

[0067] The first array stores consecutive coordinate points. The outline of the target glyph can be obtained by gradually drawing straight lines or curves according to the coordinate points in the first array. wineps.drv can obtain the first array of the target glyph by calling relevant functions. For example, the first array of the target glyph can be obtained by calling the append_glyph_outline function.

[0068] Referring to Figure 4 , a schematic diagram of the conversion of a quadratic Bézier curve to a cubic Bézier curve is shown. Figure 4(a) is a quadratic Bezier curve, including two endpoints (coordinate point 1 and coordinate point 3) and a control point (coordinate point 2), that is, a quadratic Bezier curve includes 3 coordinate points. Figure 4 (b) is a cubic Bezier curve, including two endpoints (coordinate point 1 and coordinate point 4) and two control points (coordinate point 2 and coordinate point 3), that is, a cubic Bezier curve includes 4 coordinate points. Figure 4 As shown in (b), assuming that the cubic Bezier curve is drawn starting from coordinate point 1, coordinate point 1 is called the starting endpoint of the cubic Bezier curve, coordinate point 4 is called the ending endpoint, coordinate point 2 is called the first control point, and coordinate point 3 is called the second control point.

[0069] In TrueType fonts, curves in glyphs are usually represented by quadratic Bezier curves, while PostScript uses cubic Bezier curves. Therefore, it is necessary to convert the quadratic Bezier curves used in TrueType fonts into cubic Bezier curves supported by PostScript.

[0070] A quadratic Bezier curve can be described as follows:

[0071] Q(t)=(1-t) 2 Q 0 +2t(1-t)Q 1 +t 2 Q 2 ,t∈[0,1](1)

[0072] Among them, Q 0 , Q 1 , Q 2 These are the coordinates of the starting endpoint, control point, and ending endpoint of the quadratic Bezier curve. t is a preset parameter.

[0073] A cubic Bezier curve can be described as follows:

[0074] C(t)=(1-t) 3 C 0 +3t(1-t) 2 C 1 +3(1-t)t 2 C 2 +t 3 C 3 ,t∈[0,1](2)

[0075] Among them, C 0 , C 1 , C 2 , C 3 These are the coordinates of the starting endpoint, the first control point, the second control point, and the ending endpoint of the cubic Bezier curve. t is a preset parameter.

[0076] Convert the quadratic Bezier curve to a cubic Bezier curve, that is, let C(t) = Q(t), and the coordinates of the two endpoints and two control points of the converted cubic Bezier curve can be calculated as follows:

[0077]

[0078] In the embodiment of the present application, the target font may be a font using a Bezier curve, such as a TrueType font or an OpenType (OTF) font. Both the TrueType font and the OpenType (OTF) font use a quadratic Bezier curve, which can be converted into a cubic Bezier curve by the above formula (3).

[0079] Furthermore, in a specific implementation, there is also a situation where a continuous curve needs to be drawn. Figure 5 , which shows a schematic diagram of a continuous quadratic Bezier curve. Figure 5 As shown, two continuous quadratic Bezier curves are formed by endpoint 1, control point 1, control point 2 and endpoint 2. Control point 1 and control point 2 are two continuous control points. In this case, the midpoint of the line connecting the two continuous control points can be calculated, and the midpoint of the line is used as the common endpoint of the two continuous quadratic Bezier curves. The midpoint of the line is the end point of the previous curve and the starting point of the next curve. Therefore, using endpoint 1, control point 1 and the midpoint, the previous quadratic Bezier curve can be converted into a cubic Bezier curve based on the above formula (3). Using the midpoint, control point 2 and endpoint 2, the next quadratic Bezier curve can be converted into a cubic Bezier curve based on the above formula (3).

[0080] The embodiment of the present application defines a second array for the target glyph. The second array is used to record the two control points (the first control point and the second control point) and the termination endpoint of the cubic Bezier curve to be drawn in the process of drawing the target glyph. In the process of drawing the target glyph, the PostScript driver can record the current drawing point. Initially, the current drawing point is the drawing starting point start_pos. Starting from the current drawing point, if a straight line is to be drawn, the current drawing point is the starting point of the straight line; starting from the current drawing point, if a cubic Bezier curve is to be drawn, the current drawing point is the starting point (also the starting endpoint) of the cubic Bezier curve. Therefore, the second array only needs to record the first control point, the second control point and the termination endpoint of the cubic Bezier curve to be drawn, without recording the starting endpoint of the cubic Bezier curve to be drawn.

[0081] It should be noted that, initially, the current point of the traversal and the current drawing point are both the drawing starting point start_pos. During the drawing process, the current point of the traversal and the current drawing point may not be the same point.

[0082] In a specific implementation, if the three elements in the second array are initialized to 0 coordinates, a problem may occur when drawing a cubic Bezier curve. Figure 1 To solve this problem, the embodiment of the present application initializes the second array based on the drawing starting point of the target glyph.

[0083] Further, the initializing the second array based on the drawing starting point may include: initializing the first element and the third element as the drawing starting point, and initializing the second element to 0.

[0084] In one example, the second array is defined as POINT curve_pts[3], and the second array includes the following three elements: curve_pts[0], curve_pts[1], and curve_pts[2]. For the cubic Bezier curve to be drawn, the first element curve_pts[0] is used to store the first control point, the second element curve_pts[1] is used to store the second control point, and the third element curve_pts[2] is used to store the end point.

[0085] When initializing the second array, the present application initializes the first element curve_pts[0] and the third element curve_pts[2] to the drawing starting point start_pos, and initializes the second element curve_pts[1] to the 0 coordinate (0,0).

[0086] The first array is traversed from the drawing starting point of the target glyph, and each coordinate point in the first array is judged and processed, and converted into a PostScript instruction, so as to complete the drawing of the target glyph. For example, a PostScript instruction is a lineto instruction, which is used to execute the operation of drawing a straight line. For another example, a PostScript instruction is a curveto instruction, which is used to execute the operation of drawing a cubic Bezier curve.

[0087] If the category of the next coordinate point of the current coordinate point is an endpoint, it means that the current drawing is a straight line segment, and a straight line is drawn from the current drawing point to the next coordinate point; if the category of the next coordinate point of the current coordinate point is a control point, it means that the current drawing is a curve, and it is necessary to perform coordinate conversion from a quadratic Bezier curve to a cubic Bezier curve. Specifically, the second array is updated based on the current coordinate point and the next coordinate point to obtain an updated second array. The coordinates recorded in the current drawing point and the updated second array are used as the coordinates of the cubic Bezier curve, and the cubic Bezier curve can be drawn.

[0088] When curve_pts[0] and curve_pts[2] are called for the first time, if the values ​​of curve_pts[0] and curve_pts[2] are both (0,0), this may cause Figure 1 Specifically, if curve_pts[0] and curve_pts[2] are initialized to (0,0), and in step 105, when the second array is updated based on the coordinates of the current point and the coordinates of the next point, when the value of curve_pts[0] needs to be updated using the value of curve_pts[2], errors may occur in the updated coordinate values, resulting in abnormalities in the drawn curve.

[0089] When initializing the second array, the application initializes the values ​​of curve_pts[0] and curve_pts[2] to the drawing starting point of the target glyph, rather than (0,0). In this way, in the subsequent drawing process, when the second array is updated based on the current coordinate point and the next coordinate point, the correct coordinate value can be calculated, thereby avoiding Figure 1 The situation shown occurs.

[0090] In an optional embodiment of the present application, updating the second array based on the current coordinate point and the next coordinate point may include:

[0091] Step S11, judging whether the previous coordinate point of the current coordinate point is on the line, and obtaining a first judgment result; according to the first judgment result, updating the first element, and obtaining a first updated value of the first element;

[0092] Step S12, judging whether the current coordinate point is the drawing end point, and obtaining a second judgment result; according to the second judgment result, updating the third element, and obtaining a first updated value of the third element;

[0093] Step S13: Based on the formula for converting a quadratic Bézier curve to a cubic Bézier curve, calculate the second update value of the first element and the first update value of the second element according to the current coordinate point, the first update value of the first element, and the first update value of the third element.

[0094] In the embodiments of the present application, determining whether a coordinate point is on a line means determining whether the coordinate point is on the line or curve to be drawn. The curve includes a quadratic Bézier curve or a cubic Bézier curve.

[0095] In specific implementation, the curve to be drawn may be a single curve, or two or more continuous curves. Continuous curves have common endpoints, that is, the termination endpoint of the previous curve is the starting endpoint of the next curve. For a single curve and continuous curves, the following two cases can be divided:

[0096] The first case is that the curve to be drawn is a single curve, and at this time, the endpoints of the curve are on the line. Refer to Figure 6 , which shows a glyph schematic diagram including a quadratic Bézier curve. As Figure 6 shown, it is the glyph outline of the upper right corner point in the character "术". In this glyph outline, there is a quadratic Bézier curve formed by coordinate point 1, coordinate point 2, and coordinate point 3. Among them, coordinate point 1 and coordinate point 3 are the two endpoints respectively, and both endpoints are on the line. Coordinate point 2 is the control point, and coordinate point 2 is not on the line. In the first case, the coordinate points for converting to a cubic Bézier curve can be directly calculated according to the above formula (3), so as to perform the conversion from a quadratic Bézier curve to a cubic Bézier curve.

[0097] The second case is that the curve to be drawn is a continuous curve, and at this time, the endpoints of the curve are not on the line. Refer to Figure 7 , which shows another glyph schematic diagram including a quadratic Bézier curve. As Figure 7 (a) shows, two continuous quadratic Bézier curves are formed by coordinate point 1, coordinate point 2, coordinate point 3, and coordinate point 4. Among them, coordinate point 1 is an endpoint of curve 1, coordinate point 2 is the control point of curve 1, coordinate point 3 is the control point of curve 2, and coordinate point 4 is an endpoint of curve 2. It can be seen that one endpoint of curve 1 is not on the line, and one endpoint of curve 2 is also not on the line. Coordinate point 2 and coordinate point 3 are two consecutive control points. In this case, the midpoint of the connection line of these two consecutive control points can be calculated, and this midpoint is the common endpoint of these two continuous quadratic Bézier curves. As Figure 7 (b) shows that endpoint 1 shown is the midpoint of the connection line of coordinate point 2 and coordinate point 3 calculated. This midpoint is the end (termination endpoint) of the previous quadratic Bézier curve (curve 1) and also the start (starting endpoint) of the next quadratic Bézier curve (curve 2).

[0098] Therefore, the coordinates of the two endpoints and one control point of curve 1 are known, and the coordinates of the two endpoints and one control point of curve 2 are known. According to formula (3), the quadratic Bezier curves of curve 1 and curve 2 can be converted to cubic Bezier curves respectively.

[0099] In the embodiment of the present application, a second array is defined to store two control points and a terminal end point of the cubic Bezier curve to be drawn. Figure 7 Taking curve 1 in (b) as an example, assuming that the current drawing point is coordinate point 1, then the current drawing point coordinate point 1 is the starting endpoint and endpoint 1 is the ending endpoint. The coordinates of the first control point and the second control point need to be calculated according to formula (3) to obtain the updated second array, and then curve 1 can be converted into a cubic Bezier curve.

[0100] It can be understood that when there are multiple (more than two) continuous curves, the calculation method is the same as that of two continuous curves, and they can be referenced to each other.

[0101] In the embodiment of the present application, the PostScript driver (i.e., wineps.drv) in Wine responds to the print task, executes step 101, obtains the first array of the target glyph, and executes step 102 to initialize the coordinates start_pos of the drawing starting point and end_pt of the drawing end point of the target glyph. Execute step 103 to define the second array POINT curve_pts[3], which is used to store the two control points and the end endpoint of the cubic Bezier curve to be drawn, and initialize the second array. Specifically, both curve_pts[0] and curve_pts[2] are initialized to start_pos, and curve_pts[1] is still initialized to 0 coordinates.

[0102] Next, step 104 is executed to traverse the first array, and judge and process each coordinate point in the first array to achieve drawing of the target glyph. For example, step 104 can be implemented by a for loop, and when the last coordinate point (drawing end point end_pt) is traversed, the for loop is ended, and the drawing of the target glyph is completed.

[0103] The process of judging and processing each coordinate point in the first array may include:

[0104] Determine the category of the next coordinate point of the traversed current coordinate point; if the category of the next coordinate point of the current coordinate point is an endpoint, draw a straight line based on the current drawing point and the next coordinate point, that is, execute the lineto instruction, and use the next coordinate point of the current coordinate point as the new current coordinate point, and return to the judgment processing flow of step 104; if the category of the next coordinate point of the current coordinate point is a control point, enter step S11 to update the first element.

[0105] Execute step S11 to determine whether the previous coordinate point of the current coordinate point is on the line, and obtain a first determination result; update the first element according to the first determination result to obtain a first updated value of the first element. Step S11 is used to calculate the first updated value of curve_pts[0] according to whether the previous coordinate point of the current coordinate point is on the line.

[0106] Further, updating the first element according to the first judgment result may include:

[0107] Step S111: if the previous coordinate point of the current coordinate point is on the line, update the first element using the previous coordinate point of the current coordinate point;

[0108] Step S112: If the previous coordinate point of the current coordinate point is not on the line, update the first element using the current value of the third element.

[0109] Specifically, the first judgment result includes: the previous coordinate point of the current coordinate point is on the line, or the previous coordinate point of the current coordinate point is not on the line.

[0110] If the previous coordinate point of the current coordinate point is on the line, execute step S111, update the value of the first element curve_pts[0] to the coordinate of the previous coordinate point of the current coordinate point, indicating that the previous coordinate point of the current coordinate point is the starting endpoint of the curve to be drawn; and enter step S12.

[0111] If the previous coordinate point of the current coordinate point is not on the line, execute step S112, update the value of the first element curve_pts[0] to the current value of curve_pts[2], indicating that the curve to be drawn is a continuous curve, curve_pts[2] is the ending endpoint of the previous curve and also the starting endpoint of the next curve; enter step S12.

[0112] After the updating process of step S111 or step S112, the value of the first element curve_pts[0] obtained is called the first updated value of the first element.

[0113] Next, enter step S12 to update the third element.

[0114] Execute step S12 to determine whether the current coordinate point is the drawing end point of the target glyph, and obtain a second determination result; update the third element according to the second determination result to obtain a first updated value of the third element. Step S12 is used to calculate the first updated value of curve_pts[2] according to whether the current coordinate point is the drawing end point of the target glyph.

[0115] Further, updating the third element according to the second judgment result may include:

[0116] Step S211: if the current coordinate point is the drawing end point, update the third element using the drawing starting point;

[0117] Step S212: if the current coordinate point is not the drawing end point, and the next coordinate point of the current coordinate point is on the line, then the third element is updated using the next coordinate point of the current coordinate point;

[0118] Step S213: If the current coordinate point is not the drawing end point, and the next coordinate point of the current coordinate point is not on the line, calculate the midpoint of the line connecting the current coordinate point and the next coordinate point of the current coordinate point, and use the midpoint of the line to update the third element.

[0119] Specifically, the second judgment result includes: the current coordinate point is the drawing end point of the target glyph, or the current coordinate point is not the drawing end point of the target glyph.

[0120] If the current coordinate point is the drawing end point of the target glyph, execute step S211, update the value of the third element curve_pts[2] to the coordinate of the drawing starting point start_pos of the target glyph, indicating that start_pos is the terminating end point of the curve to be drawn, and the glyph drawing of the target glyph is about to end, and enter step S13.

[0121] If the current coordinate point is not the drawing end point of the target glyph, it is necessary to further determine whether the next coordinate point of the current coordinate point is on the line.

[0122] If the current coordinate point is not the drawing end point of the target glyph, and the next coordinate point of the current coordinate point is on the line, execute step S212, update the value of the third element curve_pts[2] to the coordinate of the next coordinate point of the current coordinate point, indicating that the next coordinate point of the current coordinate point is the terminating end point of the curve to be drawn; and enter step S13.

[0123] If the current coordinate point is not the end point of drawing the target glyph, and the next coordinate point of the current coordinate point is not on the line, then execute step S213. This indicates that a continuous curve is to be drawn, and it is necessary to calculate the midpoint of the line connecting the current coordinate point and the next coordinate point of the current coordinate point, and update the value of the third element curve_pts[2] to the coordinate of the midpoint of the line, indicating that curve_pts[2] is the end point of the previous curve and the starting point of the next curve. The coordinates of the midpoint of the line can be calculated by the following formula:

[0124] curve_pts[2]=(outline.pts[cur_pt]+outline.pts[cur_pt+1]+1) / 2(4)

[0125] Among them, "cur_pt" represents the current coordinate point, outline.pts[cur_pt] is the coordinate of the current coordinate point, "cur_pt+1" represents the next coordinate point of the current coordinate point, and outline.pts[cur_pt+1] is the coordinate of the next coordinate point of the current coordinate point. Among them, the coordinates of the two coordinate points outline.pts[cur_pt] and outline.pts[cur_pt+1] are added together and then added with 1 because the coordinate points are defined as integers (whole numbers) in the computer program, and the part after the decimal point is automatically discarded during calculation, leaving only the integer. Therefore, adding 1 here is equivalent to rounding to ensure the accuracy of the calculation result. For example, the midpoint of the calculated coordinate points (20,20) and (31,31) should be (25.5,25.5), and the result should be (26,26) after rounding. If the calculation is not performed according to the above formula (4), the result (25.5, 25.5) will discard the part after the decimal point, that is, (25, 25), which will lead to inaccurate results. However, the midpoint of the coordinate points (20, 20) and (31, 31) calculated by the above formula (4) is ((20+31+1) / 2, (20+31+1) / 2), that is, (26, 26), which is consistent with the result after rounding. For another example, the midpoint of the coordinate points (20, 20) and (30, 30) is ((20+30+1) / 2, (20+30+1) / 2), which should be (25.5, 25.5), and the part after the decimal point is automatically discarded, that is, the final result is (25, 25), which is also consistent with the result after rounding.

[0126] After step S213 is completed, the process goes to step S13.

[0127] After the updating process of step S211, step S212 or step S213, the value of the third element curve_pts[2] obtained is called the first updated value of the third element.

[0128] After step S11 and step S12 are executed, the first updated value of the first element and the first updated value of the third element are obtained. The first updated value of the first element is the starting endpoint of the quadratic Bezier curve to be drawn, the first updated value of the third element is the ending endpoint of the quadratic Bezier curve to be drawn, and the current coordinate point is the control endpoint of the quadratic Bezier curve to be drawn. According to the three coordinate points of the quadratic Bezier curve, it can be converted to a cubic Bezier curve.

[0129] Next, the process proceeds to step S13 to calculate the coordinates of two control points of the cubic Bezier curve to be drawn, thereby realizing the conversion of the quadratic Bezier curve to the cubic Bezier curve.

[0130] Execute step S13, calculate the second update value of the first element and the first update value of the second element based on the formula for converting a quadratic Bezier curve to a cubic Bezier curve according to the current coordinate point, the first update value of the first element and the first update value of the third element.

[0131] Furthermore, the second updated value of the first element may be calculated by the following formula:

[0132] curve_pts[0] = (curve_pts[0] + 2 * outline.pts[cur_pt] + 1) / 3 (5)

[0133] In the above formula (5), curve_pts[0] on the left side of the equal sign corresponds to C in formula (3) 1 , curve_pts[0] on the right side of the equal sign corresponds to Q in formula (3) 0 , curve_pts[cur_pt] corresponds to Q in formula (3) 1 , expanding the second line of formula (3) can yield the following formulas (6-1), (6-2), and (6-3) respectively:

[0134]

[0135] C 1 =(Q 0 +2Q 1 ) / 3(6-3)

[0136] In the above formula (5), 1 is added to (curve_pts[0]+2*outline.pts[cur_pt]+1) to calculate the coordinate point, which is equivalent to rounding.

[0137] The above formula (5) indicates that the calculation result on the right is assigned to the element on the left. Wherein, curve_pts[0] on the right side of the equal sign indicates the first updated value of the first element, and outline.pts[cur_pt] is the coordinate of the current coordinate point. curve_pts[0] on the left side of the equal sign indicates the second updated value of the first element after the assignment.

[0138] It can be understood that the coordinates of a coordinate point include an x ​​coordinate and a y coordinate, and the x coordinate and the y coordinate are calculated according to the above formulas respectively.

[0139] Similarly, the first updated value of the second element can be calculated by the following formula:

[0140] curve_pts[1] = (curve_pts[2] + 2 * outline.pts[cur_pt] + 1) / 3 (7)

[0141] In the above formula (7), curve_pts[2] represents the first updated value of the third element, outline.pts[cur_pt] is the coordinate of the current coordinate point, and curve_pts[1] represents the first updated value of the second element obtained after the assignment.

[0142] In the embodiment of the present application, the second updated value of the first element and the first updated value of the second element are the coordinates of the two control points of the cubic Bezier curve to be drawn. The current drawing point is the starting end point of the cubic Bezier curve to be drawn. The first updated value of the third element is the ending end point of the cubic Bezier curve to be drawn. Thus, the four coordinate points of the cubic Bezier curve to be drawn have been obtained, and the cubic Bezier curve can be drawn according to these four coordinate points.

[0143] Furthermore, drawing a cubic Bezier curve starting from the current drawing point according to the updated second array may include:

[0144] The cubic Bezier curve is drawn by taking the current drawing point as the starting endpoint of the cubic Bezier curve to be drawn, taking the second updated value of the first element as the first control point of the cubic Bezier curve to be drawn, taking the first updated value of the second element as the second control point of the cubic Bezier curve to be drawn, and taking the first updated value of the third element as the terminating endpoint of the cubic Bezier curve to be drawn.

[0145] When the traversal of the last coordinate point in the first array is completed, a closepath instruction can be written into the PostScript file so that the printer executes the closepath instruction, which is used to close the subpath of the current path, indicating that the drawing of the target glyph is completed.

[0146] In an optional embodiment of the present application, the method may further include:

[0147] Setting a preset flag, wherein the initial value of the preset flag is a first value;

[0148] When the current coordinate point is not the drawing end point and the next coordinate point of the current coordinate point is on a line, the preset flag is set to a second value.

[0149] The preset flag is used to indicate whether the continuous curve is finished. Exemplarily, it is assumed that the preset flag is recorded as added_next, and the initial value of added_next is the first value. The present application does not limit the specific values ​​of the first value and the second value, for example, they can be Boolean values. It is assumed that the first value is FALSE and the second value is TRUE. The first value indicates that the continuous curve has not been finished, and the second value indicates that the continuous curve is finished.

[0150] In a specific implementation, the preset flag may be set to the first value before executing step S11. After entering step S213 and before step S213 is completed, the preset flag may be set to the second value.

[0151] Furthermore, after drawing a cubic Bezier curve according to the current coordinate point and the updated second array, the method may further include:

[0152] Update the current coordinate point of the traversal to the next coordinate point;

[0153] The preset flag is read; if the preset flag is a first value, the traversal operation is continued; if the preset flag is a second value, the operation of continuing to draw the next cubic Bezier curve is executed.

[0154] Specifically, after step 105 is completed, that is, after drawing the cubic Bezier curve, it is necessary to traverse the next coordinate point and use the next coordinate point as the new current coordinate point. At this time, the value of the preset flag added_next can be judged. If the value of the preset flag added_next is the first value FALSE, it means that the continuous curve has not been drawn yet, and it is necessary to execute the operation of continuing to draw the next cubic Bezier curve, then it can return to step S11 to continue drawing the next cubic Bezier curve. If the value of the preset flag added_next is the second value TRUE, it means that the continuous curve drawing is completed, and it can return to the judgment process of executing step 104 and enter the next cycle.

[0155] Reference Figure 8, shows a flow chart of a printing processing method in an example of the present application, comprising the following steps:

[0156] Step 1: Get the first array of the target glyph, and initialize start_pos and end_pt. For example, initialize start_pos to the first coordinate point in the first array, and initialize end_pt to the last coordinate point in the first array. Define the second array POINT curve_pts[3], which is used to store the two control points and the end endpoint of the cubic Bezier curve, and initialize curve_pts[0] and curve_pts[2] to start_pos, and initialize curve_pts[1] to 0 coordinate.

[0157] Step 2: Execute a for loop. Use the for loop to traverse each coordinate point in the first array, and execute steps 2-1 to 2-6 for each coordinate point to judge and process; when the traversal reaches the drawing end point (end_pt), end the for loop, execute the closepath instruction, and the target glyph drawing is completed.

[0158] The process of performing judgment and processing on each coordinate point in the first array includes:

[0159] Step 2-1: Determine the category of the next coordinate point of the current coordinate point. If the next coordinate point of the current coordinate point is an endpoint, execute the lineto instruction to draw a straight line, and use the next coordinate point of the current coordinate point as the new current coordinate point, return to step 2-1 to enter the next loop; if the next coordinate point of the current coordinate point is a control point, use the next coordinate point of the current coordinate point as the current coordinate point, execute step 2-2 to draw a Bezier curve.

[0160] To determine whether the next coordinate point of the current coordinate point is an endpoint or a control point, you can also determine whether the next coordinate point is on the drawing line. If the next coordinate point of the current coordinate point is on the line, the next coordinate point is an endpoint; if the next coordinate point of the current coordinate point is not on the line, the next coordinate point is a control point. Therefore, step 2-1 can also be as follows:

[0161] Step 2-1: Determine whether the next coordinate point of the current coordinate point is on the line; if the next coordinate point is on the line, execute the lineto instruction to draw a straight line, and use the next coordinate point of the current coordinate point as the new current coordinate point, return to step 2-1 to enter the next loop; if the next coordinate point of the current coordinate point is not on the line, use the next coordinate point of the current coordinate point as the new current coordinate point, and execute step 2-2 to draw the Bezier curve.

[0162] Step 2-2: Set added_next to FALSE; determine whether the previous coordinate point of the current coordinate point is on the line; if the previous coordinate point of the current coordinate point is on the line, update the value of curve_pts[0] to the previous coordinate point, indicating that the previous coordinate point is the starting endpoint of the Bezier curve to be drawn, and execute step 2-3; if the previous coordinate point of the current coordinate point is not on the line, update the value of curve_pts[0] to the current value of curve_pts[2], indicating that the Bezier curve to be drawn is a continuous Bezier curve, and the current value of curve_pts[2] is the ending endpoint of the previous Bezier curve, which is also the starting endpoint of the next Bezier curve, and execute step 2-3.

[0163] Step 2-3: Determine whether the current coordinate point is end_pt; if the current coordinate point is end_pt, update the value of curve_pts[2] to start_pos, indicating that start_pos is the end point of the Bezier curve to be drawn, and execute step 2-4.

[0164] If the current coordinate point is not end_pt, further judgment is required; judge whether the next coordinate point of the current coordinate point is on the line. If the next coordinate point of the current coordinate point is on the line, update the value of curve_pts[2] to the next coordinate point of the current coordinate point, indicating that the next coordinate point of the current coordinate point is the end point of the Bezier curve to be drawn, and set added_next to TRUE, and execute steps 2-4; if the next coordinate point of the current coordinate point is not on the line, it means that the Bezier curve to be drawn is a continuous Bezier curve, and the end point of the current Bezier curve to be drawn is the midpoint of the line connecting the current coordinate point and the next coordinate point (represented as mid), then update the value of curve_pts[2] to mid, (that is, let curve_pts[2] = (outline.pts[cur_pt] + outline.pts[cur_pt+1] + 1) / 2), and execute steps 2-4.

[0165] Step 2-4: Convert the quadratic Bezier curve to a cubic Bezier curve. After step 2-2 and step 2-3, the first updated value of curve_pts[0] and the first updated value of curve_pts[2] are obtained. The first updated value of curve_pts[0] is the starting endpoint of the quadratic Bezier curve to be drawn, and the first updated value of curve_pts[2] is the ending endpoint of the quadratic Bezier curve to be drawn. The current coordinate point is the control point of the quadratic Bezier curve to be drawn. Based on these three coordinate points of the quadratic Bezier curve to be drawn, the coordinate points of the cubic Bezier curve can be calculated based on the above formula (3).

[0166] Specifically, based on the current coordinate point, the first updated value of curve_pts[0], and the first updated value of curve_pts[2], the second updated value of curve_pts[0] and the first updated value of curve_pts[1] can be calculated. The second updated value of curve_pts[0] is the coordinate of the first control point of the cubic Bezier curve to be drawn, and the first updated value of curve_pts[1] is the coordinate of the second control point of the cubic Bezier curve to be drawn.

[0167] Step 2-5: Execute the curveto instruction from the current drawing point to draw a cubic Bezier curve.

[0168] Specifically, the current drawing point is used as the starting endpoint of the cubic Bezier curve, the second updated value of curve_pts[0] is used as the first control point of the cubic Bezier curve, the first updated value of curve_pts[1] is used as the second control point of the cubic Bezier curve, and the first updated value of curve_pts[2] is used as the ending endpoint of the cubic Bezier curve to draw the cubic Bezier curve.

[0169] Step 2-6: Update the current coordinate point and return according to the value of added_next. Specifically, the next coordinate point of the current coordinate point is used as the new current coordinate point, and the value of added_next is determined; if the value of added_next is TRUE, return to step 2-1 to execute the next loop; if the value of added_next is FALSE, return to step 2-2 to continue drawing the next continuous curve.

[0170] In the first example, we draw Figure 6 As an example, Figure 8 The target glyph is Figure 6 The glyphs shown.

[0171] Step 1: Get the first array of target glyphs and initialize start_pos and end_pt.

[0172] The first array includes 6 coordinate points, wherein coordinate point 1 is the first coordinate point and coordinate point 6 is the last coordinate point. Initialize start_pos to coordinate point 1 and end_pt to coordinate point 6.

[0173] Define the second array POINT curve_pts[3] and initialize it:

[0174] curve_pts[0]=curve_pts[2]=start_pos, curve_pts[1]=0.

[0175] Step 2: Execute the for loop.

[0176] Step 2-1: Determine whether the next coordinate point of the current coordinate point is on the line;

[0177] When the loop is executed for the first time, the current coordinate point is the same as the current drawing point, both of which are start_pos.

[0178] The next coordinate point (coordinate point 2) of the current coordinate point (coordinate point 1) is not on the line, so a Bezier curve needs to be drawn. The current coordinate point is updated to coordinate point 2, and step 2-2 is executed.

[0179] Step 2-2: Set added_next to FALSE; determine whether the previous coordinate point of the current coordinate point is on the line; if the current coordinate point is coordinate point 2 and the previous coordinate point (coordinate point 1) is on the line, update the value of curve_pts[0] to coordinate point 1, indicating that coordinate point 1 is the starting endpoint of the Bezier curve to be drawn; execute step 2-3.

[0180] Step 2-3: Determine whether the current coordinate point is end_pt; if the current coordinate point (coordinate point 2) is not end_pt, and the next coordinate point (coordinate point 3) of the current coordinate point (coordinate point 2) is on the line, then update the value of curve_pts[2] to coordinate point 3, and set the value of added_next to TRUE; execute step 2-4.

[0181] Step 2-4: Convert the quadratic Bezier curve to a cubic Bezier curve; After step 2-2 and step 2-3, obtain the first updated value of curve_pts[0] and the first updated value of curve_pts[2]. Based on the current coordinate point, the first updated value of curve_pts[0] and the first updated value of curve_pts[2], calculate the second updated value of curve_pts[0] and the first updated value of curve_pts[1] to draw the cubic Bezier curve.

[0182] Step 2-5: Execute the curveto instruction from the current drawing point (coordinate point 1) to draw a cubic Bezier curve; at this time, the drawing point moves to the terminal end point of the drawn cubic Bezier curve (coordinate point 3).

[0183] Step 2-6: Update the current coordinate point and return according to the value of added_next. Set the next coordinate point (coordinate point 3) of the current coordinate point (coordinate point 2) as the new current coordinate point, that is, coordinate point 3 is used as the current coordinate point of the traversal; since the value of added_next is TRUE, return to step 2-1 to execute the next loop;

[0184] Step 2-1: Since the next coordinate point (coordinate point 4) of the current coordinate point (coordinate point 3) is on the line, the lineto instruction is executed from the current drawing point (coordinate point 3) to draw a straight line; at this time, the drawing point moves to coordinate point 4; the current coordinate point is updated to coordinate point 4, and the process returns to step 2-1 to execute the next loop;

[0185] Step 2-1: Since the next coordinate point (coordinate point 5) of the current coordinate point (coordinate point 4) is on the line, the lineto instruction is executed from the current drawing point (coordinate point 4) to draw a straight line; at this time, the drawing point moves to coordinate point 5; the current coordinate point is updated to coordinate point 5, and the process returns to step 2-1 to execute the next loop;

[0186] Step 2-1: Since the next coordinate point (coordinate point 6) of the current coordinate point (coordinate point 5) is not on the line, the current coordinate point is updated to coordinate point 6, and step 2-2 is executed to draw the Bezier curve.

[0187] Step 2-2: Set added_next to FALSE; determine whether the previous coordinate point of the current coordinate point is on the line. Since the previous coordinate point (coordinate point 5) of the current coordinate point (coordinate point 6) is on the line, update the value of curve_pts[0] to coordinate point 5, indicating that the previous coordinate point is the starting endpoint of the Bezier curve to be drawn, and execute step 2-3;

[0188] Step 2-3: Determine whether the current coordinate point is end_pt; since the current coordinate point (coordinate point 6) is end_pt, update the value of curve_pts[2] to start_pos;

[0189] Step 2-4: After step 2-2 and step 2-3, the first updated value of curve_pts[0] and the first updated value of curve_pts[2] are obtained. Based on the current coordinate point, the first updated value of curve_pts[0] and the first updated value of curve_pts[2], the second updated value of curve_pts[0] and the first updated value of curve_pts[1] are calculated to draw the cubic Bezier curve.

[0190] Step 2-5: Execute the curveto instruction from the current drawing point (coordinate point 5) to draw a cubic Bezier curve; at this time, the drawing point moves to coordinate point 1.

[0191] All coordinate points in the first array are traversed, the for loop ends, and the closepath instruction is executed. Figure 6 The glyph shown is drawn.

[0192] In the second example, we draw Figure 7Take curve 1 and curve 2 in the figure as examples to illustrate Figure 8 The process shown in FIG. 1 is as follows: Figure 7 Curve 1 and curve 2 in .

[0193] Step 1: Get the first array of the target glyph and initialize start_pos and end_pt. The first array includes four coordinate points: coordinate point 1, coordinate point 2, coordinate point 3, and coordinate point 4. Initialize start_pos to coordinate point 1, end_pt to coordinate point 4, curve_pts[0]=curve_pts[2]=start_pos, curve_pts[1]=0.

[0194] Step 2: Execute the for loop.

[0195] Step 2-1: Determine whether the next coordinate point of the current coordinate point is on the line;

[0196] The next coordinate point (coordinate point 2) of the current coordinate point (coordinate point 1) is not on the line, so a Bezier curve needs to be drawn, the current coordinate point is updated to coordinate point 2, and step 2-2 is executed. At this time, the current drawing point is at the position of coordinate point 1.

[0197] Step 2-2: Set added_next to FALSE; determine whether the previous coordinate point (coordinate point 1) of the current coordinate point (coordinate point 2) is on the line; coordinate point 1 is on the line, so update the value of curve_pt[0] to coordinate point 1, indicating that coordinate point 1 is the starting endpoint of the Bezier curve to be drawn; execute step 2-3.

[0198] Step 2-3: Determine whether the current coordinate point is end_pt; if the current coordinate point (coordinate point 2) is not end_pt, and the next coordinate point of the current coordinate point (coordinate point 3) is not on the line, it is necessary to calculate the coordinates of the midpoint of the line connecting coordinate point 2 and coordinate point 3 (recorded as endpoint 1), and update the value of curve_pts[2] to endpoint 1 (that is, calculate curve_pts[2] = (outline.pts[cur_pt] + outline.pts[cur_pt+1] + 1) / 2); indicating that endpoint 1 is the end endpoint of the Bezier curve to be drawn; execute step 2-4.

[0199] Step 2-4: Convert the quadratic Bezier curve to a cubic Bezier curve. After step 2-2 and step 2-3, the first updated value of curve_pts[0] and the first updated value of curve_pts[2] are obtained. Based on the current coordinate point, the first updated value of curve_pt[0] and the first updated value of curve_pt[2], the second updated value of curve_pt[0] and the first updated value of curve_pt[1] are calculated to draw the cubic Bezier curve.

[0200] Step 2-5: Execute the curveto command from the current drawing point (coordinate point 1), draw three Bezier curves, and draw curve 1. At this time, the drawing point moves to the terminal end point of curve 1 (that is, endpoint 1).

[0201] Step 2-6: Set the next coordinate point of the current coordinate point as the new current coordinate point, that is, set coordinate point 3 as the new current coordinate point; determine the value of added_next. Since the value of added_next is FALSE, return to step 2-2 and continue to draw the next Bezier curve in the continuous curve.

[0202] Step 2-2: Since the previous coordinate point (coordinate point 2) of the current coordinate point (coordinate point 3) is not on the line, the value of curve_pt[0] is updated to the current value of curve_pt[2]. The current value of curve_pt[2] is the end point of the previous Bezier curve, which is also the start point of the next continuous Bezier curve.

[0203] Step 2-3: Since the current coordinate point (coordinate point 3) is not end_pt, and the next coordinate point of the current coordinate point (coordinate point 4) is on the line, the value of curve_pt[2] is updated to coordinate point 4, indicating that coordinate point 4 is the end point of the Bezier curve to be drawn, and added_next is set to TURE.

[0204] Step 2-4: Based on the current coordinate point, the first updated value of curve_pt[0] and the second updated value of curve_pt[2], the second updated value of curve_pt[0] and the first updated value of curve_pt[1] are calculated to draw the cubic Bezier curve.

[0205] Step 2-5: Execute the curveto instruction from the current drawing point (endpoint 1) to draw a cubic Bezier curve, and obtain curve 2; at this time, the drawing point moves to the terminal endpoint of the drawn cubic Bezier curve (ie, coordinate point 4).

[0206] Step 2-6: Set the next coordinate point (coordinate point 4) of the current coordinate point (coordinate point 3) as the new current coordinate point, that is, set coordinate point 4 as the new current coordinate point; since coordinate point 4 is already the last point end_pt, the for loop ends.

[0207] Execute the closepath instruction. The target glyph drawing is completed. Figure 7 The curves 1 and 2 in the figure are drawn.

[0208] In the third example, refer to Fig. 9 , showing a schematic diagram of a target glyph. Fig. 9 The figure shows the shape of the letter "O". Fig. 9 As shown in the figure, the outline of the glyph includes two inner and outer curves, called the inner curve and the outer curve, and the two curves form two closed paths respectively. Taking the outer curve as an example, the first array of the outer curve includes 12 coordinate points from coordinate point 1 to coordinate point 12. The four endpoints are the midpoints of the connecting line calculated during the drawing process, and are shown in the figure for the convenience of description. Fig. 9 It is understandable that the first array does not contain these four endpoints.

[0209] Step 1: Get the first array of the target glyph, and initialize start_pos and end_pt. The first array includes 12 coordinate points. Initialize start_pos to coordinate point 1, end_pt to coordinate point 12, curve_pts[0]=curve_pts[2]=start_pos, curve_pts[1]=0.

[0210] Step 2: Execute the for loop.

[0211] Step 2-1: Determine whether the next coordinate point of the current coordinate point is on the line;

[0212] The next coordinate point (coordinate point 2) of the current coordinate point (coordinate point 1) is not on the line, so a Bezier curve needs to be drawn, the current coordinate point is updated to coordinate point 2, and step 2-2 is executed. At this time, the current drawing point is at the position of coordinate point 1.

[0213] Step 2-2: Set added_next to FALSE. Since the previous coordinate point (coordinate 1) of the current coordinate point (coordinate point 2) is on the line, update the value of curve_pts[0] to coordinate 1, indicating the starting endpoint of the Bezier curve to be drawn.

[0214] Step 2-3: The current coordinate point (coordinate point 2) is not end_pt, and the next coordinate point (coordinate point 3) of the current coordinate point (coordinate point 2) is not on the line, so it is necessary to calculate the coordinates of the midpoint of the line connecting coordinate point 2 and coordinate point 3 (recorded as end point 1), (that is, let curve_pts[2] = (outline.pts[cur_pt] + outline.pts[cur_pt+1] + 1) / 2);

[0215] Step 2-4: Based on the current coordinate point, the first updated value of curve_pts[0] and the second updated value of curve_pts[2], calculate the second updated value of curve_pts[0] and the first updated value of curve_pts[1] to draw a cubic Bezier curve;

[0216] Step 2-5: Execute the curveto command from the current drawing point (coordinate point 1) to draw a cubic Bezier curve; at this time, the drawing point moves to the position of the terminal endpoint of the drawn cubic Bezier curve (that is, the position of endpoint 1);

[0217] Step 2-6: Set the next coordinate point of the current coordinate point (coordinate point 2) as the new current coordinate point, that is, update the current coordinate point to coordinate point 3; judge the value of added_next. Since the value of added_next is FALSE, return to step 2-2 and continue to draw the next Bezier curve in the continuous curve.

[0218] Step 2-2: Set added_next to FALSE. Since the previous coordinate point (coordinate point 2) of the current coordinate point (coordinate point 3) is not on the line, update the value of curve_pts[0] to the current value of curve_pts[2]. The current value of curve_pts[2] is the ending endpoint of the previous Bezier curve, which is also the starting endpoint of the next continuous Bezier curve.

[0219] Step 2-3: If the current coordinate point (coordinate point 3) is not end_pt, and the next coordinate point (coordinate point 4) of the current coordinate point (coordinate point 3) is on the line, then update the value of curve_pts[2] to coordinate point 4, and set the value of added_next to TRUE;

[0220] Step 2-4: Based on the current coordinate point, the first updated value of curve_pts[0] and the second updated value of curve_pts[2], calculate the second updated value of curve_pts[0] and the first updated value of curve_pts[1] to draw a cubic Bezier curve;

[0221] Step 2-5: Execute the curveto instruction from the current drawing point (endpoint 1) to draw a cubic Bezier curve; at this time, the drawing point moves to the position of the terminal end point of the drawn cubic Bezier curve (i.e., coordinate point 4);

[0222] Step 2-6: Set the next coordinate point (coordinate point 4) of the current coordinate point (coordinate point 3) as the current coordinate point. Since the value of added_next is TRUE, return to step 2-1 to execute the next loop.

[0223] Step 2-1: Since the next coordinate point (coordinate point 5) of the current coordinate point (coordinate point 4) is not on the line, the next coordinate point (coordinate point 5) of the current coordinate point is used as the current coordinate point, and step 2-2 is executed to draw the curve;

[0224] Step 2-2: Set added_next to FALSE. Since the previous coordinate point (coordinate point 4) of the current coordinate point (coordinate point 5) is on the line, update the value of curve_pts[0] to coordinate point 4, indicating the starting endpoint of the Bezier curve to be drawn.

[0225] Step 2-3: Since the current coordinate point (coordinate point 5) is not end_pt, and the next coordinate point (coordinate point 6) of the current coordinate point (coordinate point 5) is not on the line, it is necessary to calculate the coordinates of the midpoint of the line connecting coordinate point 5 and coordinate point 6 (recorded as endpoint 2). Endpoint 2 is the end endpoint of the Bezier curve to be drawn. Update the value of curve_pts[2] to endpoint 2 (that is, let curve_pts[2] = (outline.pts[cur_pt] + outline.pts[cur_pt+1] + 1) / 2);

[0226] Step 2-4: Based on the current coordinate point, the first updated value of curve_pts[0] and the second updated value of curve_pts[2], calculate the second updated value of curve_pts[0] and the first updated value of curve_pts[1] to draw a cubic Bezier curve;

[0227] Step 2-5: Execute the curveto command from the current drawing point (coordinate point 4) to draw a cubic Bezier curve; at this time, the drawing point moves to endpoint 2;

[0228] Step 2-6: Set the next coordinate point (coordinate point 6) of the current coordinate point (coordinate point 5) as the current coordinate point. Since the value of added_next is FALSE, return to step 2-2 and continue to draw the next Bezier curve in the continuous curve.

[0229] Step 2-2: Set added_next to FALSE. Since the previous coordinate point (coordinate point 5) of the current coordinate point (coordinate point 6) is not on the line, update the value of curve_pts[0] to the current value of curve_pts[2].

[0230] Step 2-3: Since the current coordinate point (coordinate point 6) is not end_pt, and the next coordinate point (coordinate point 7) of the current coordinate point (coordinate point 6) is on the line, update the value of curve_pts[2] to coordinate point 7, and set the value of added_next to TRUE;

[0231] Step 2-4: Based on the current coordinate point, the first updated value of curve_pts[0] and the second updated value of curve_pts[2], calculate the second updated value of curve_pts[0] and the first updated value of curve_pts[1] to draw a cubic Bezier curve;

[0232] Step 2-5: Execute the curveto command from the current drawing point (endpoint 2) to draw a cubic Bezier curve; at this time, the drawing point moves to coordinate point 7;

[0233] Step 2-6: Set the next coordinate point (coordinate point 7) of the current coordinate point (coordinate point 6) as the current coordinate point. Since the value of added_next is TRUE, return to step 2-1 to execute the next loop.

[0234] Step 2-1: Since the next coordinate point (coordinate point 8) of the current coordinate point (coordinate point 7) is not on the line, the current coordinate point is updated to coordinate point 8, and step 2-2 is executed to draw the curve;

[0235] Step 2-2: Set added_next to FALSE. Since the previous coordinate point (coordinate point 7) of the current coordinate point (coordinate point 8) is on the line, update the value of curve_pts[0] to coordinate point 7, indicating the starting endpoint of the Bezier curve to be drawn.

[0236] Step 2-3: Since the current coordinate point (coordinate point 8) is not end_pt, and the next coordinate point (coordinate point 9) of the current coordinate point (coordinate point 8) is not on the line, it is necessary to calculate the coordinates of the midpoint of the line connecting coordinate point 8 and coordinate point 9 (recorded as endpoint 3), and endpoint 3 is the end endpoint of the Bezier curve to be drawn (that is, let curve_pts[2] = (outline.pts[cur_pt] + outline.pts[cur_pt+1] + 1) / 2);

[0237] Step 2-4: Based on the current coordinate point, the first updated value of curve_pts[0] and the second updated value of curve_pts[2], calculate the second updated value of curve_pts[0] and the first updated value of curve_pts[1] to draw a cubic Bezier curve;

[0238] Step 2-5: Execute the curveto command from the current drawing point (coordinate point 7) to draw a cubic Bezier curve; at this time, the drawing point moves to endpoint 3;

[0239] Step 2-6: Take the next coordinate point (coordinate point 9) of the current coordinate point (coordinate point 8) as the current coordinate point. Since the value of added_next is FALSE, return to step 2-2 to continue drawing the next Bezier curve.

[0240] Step 2-2: Set added_next to FALSE. Since the previous coordinate point (coordinate point 8) of the current coordinate point (coordinate point 9) is not on the line, update the value of curve_pts[0] to the current value of curve_pts[2].

[0241] Step 2-3: Since the current coordinate point (coordinate point 9) is not end_pt, and the next coordinate point (coordinate point 10) of the current coordinate point (coordinate point 9) is on the line, update the value of curve_pts[2] to coordinate point 10, and set added_next to TRUE;

[0242] Step 2-4: Based on the current coordinate point, the first updated value of curve_pts[0] and the second updated value of curve_pts[2], calculate the second updated value of curve_pts[0] and the first updated value of curve_pts[1] to draw a cubic Bezier curve;

[0243] Step 2-5: Execute the curveto command from the current drawing point (endpoint 3) to draw a cubic Bezier curve; at this time, the drawing point moves to coordinate point 10;

[0244] Step 2-6: Set the next coordinate point (coordinate point 10) of the current coordinate point (coordinate point 9) as the current coordinate point. Since the value of added_next is TRUE, return to 2-1 to execute the next loop.

[0245] Step 2-1: Since the next coordinate point (coordinate point 11) of the current coordinate point (coordinate point 10) is not on the line, take coordinate point 11 as the current coordinate point and execute step 2-2 to draw the curve;

[0246] Step 2-2: Set added_next to FALSE. Since the previous coordinate point (coordinate point 10) of the current coordinate point (coordinate point 11) is on the line, update the value of curve_pts[0] to coordinate point 10, indicating the starting endpoint of the Bezier curve to be drawn.

[0247] Step 2-3: Since the current coordinate point (coordinate point 11) is not end_pt, and the next coordinate point (coordinate point 12) of the current coordinate point (coordinate point 11) is not on the line, it is necessary to calculate the coordinates of the midpoint of the line connecting coordinate point 11 and coordinate point 12 (recorded as endpoint 4), and endpoint 4 is the end endpoint of the Bezier curve to be drawn (that is, let curve_pts[2] = (outline.pts[cur_pt] + outline.pts[cur_pt+1] + 1) / 2);

[0248] Step 2-4: Based on the current coordinate point, the first updated value of curve_pts[0] and the second updated value of curve_pts[2], calculate the second updated value of curve_pts[0] and the first updated value of curve_pts[1] to draw a cubic Bezier curve;

[0249] Step 2-5: Execute the curveto command from the current drawing point (coordinate point 10) to draw a cubic Bezier curve; at this time, the drawing point moves to endpoint 4;

[0250] Step 2-6: Take the next coordinate point (coordinate point 12) of the current coordinate point (coordinate point 11) as the current coordinate point. Since the value of added_next is FALSE, return to step 2-2 to continue drawing the next continuous Bezier curve.

[0251] Step 2-2: Set the value of added_next to FALSE. Since the previous coordinate point (coordinate point 11) of the current coordinate point (coordinate point 12) is not on the line, update the value of curve_pts[0] to the current value of curve_pts[2].

[0252] Step 2-3: Since the current coordinate point (coordinate point 12) is end_pt, update the value of curve_pts[2] to start_pos (coordinate point 1);

[0253] Step 2-4: Based on the current coordinate point, the first updated value of curve_pts[0] and the second updated value of curve_pts[2], calculate the second updated value of curve_pts[0] and the first updated value of curve_pts[1] to draw a cubic Bezier curve;

[0254] Step 2-5: Execute the curveto command from the current drawing point (endpoint 4) to draw a cubic Bezier curve; at this time, the drawing point moves to coordinate point 1 to form a closed path, that is, the outer curve of the "O" shape.

[0255] Step 2-6: The first array traversal is completed and the for loop ends.

[0256] Execute the closepath command. The glyph drawing is finished. The inner curve drawing process of the "O" glyph is the same as the outer curve drawing process, which will not be repeated here.

[0257] By using the printing processing method of the present application, for applications running in Wine, when using the printing function, it is possible to avoid abnormalities in the glyph outlines of printed letters, Chinese characters, etc. (such as incomplete stroke display or increased stroke display), thereby improving the user's reading quality.

[0258] Furthermore, in the process of drawing the target glyph, the target glyph may include one outline or more than two outlines, and each outline is a closed path formed by continuous points. The first array of the target glyph obtained in step 101 includes a set of continuous coordinate points, including a drawing start point and a drawing end point. In the actual drawing process, this set of coordinate points forms a complete closed path. Fig. 9 As shown, taking the outer curve as an example, the first array of the outer curve includes 12 coordinate points from coordinate point 1 to coordinate point 12. When drawing the outer curve, any of the 12 coordinate points can be used as the drawing starting point of the closed path. For example, if coordinate point 1 is used as the drawing starting point, then coordinate point 12 is the drawing end point; for another example, if coordinate point 2 is used as the drawing starting point, then coordinate point 1 is used as the drawing end point; for another example, if coordinate point 3 is used as the drawing starting point, then coordinate point 2 is used as the drawing end point; and so on. Therefore, after the drawing starting point and the drawing end point are initialized in step 102, due to the different drawing starting points, there may be the following three situations:

[0259] Case 1: The drawing starting point (start_pos) is on the line. Fig. 9 In the figure, the drawing starting point is coordinate point 1, which is on the line. Fig. 9 In case 1, the drawing starting point is also included as coordinate point 4, coordinate point 7 or coordinate point 10.

[0260] Case 2: The drawing starting point (start_pos) is not on the line, but the previous coordinate point of the drawing starting point is on the line. Fig. 9 In the figure, the drawing starting point is coordinate point 2, which is not on the line, but the previous coordinate point of coordinate point 2 (coordinate point 1) is on the line. Fig. 9 In case 2, the drawing starting point is also included as coordinate point 5, coordinate point 8 or coordinate point 11.

[0261] Case 3: The drawing starting point (start_pos) is not on the line, and the previous coordinate point of the drawing starting point is also not on the line. Fig. 9 In the figure, the drawing starting point is coordinate point 3, which is not on the line, and the previous coordinate point of coordinate point 3 (coordinate point 2) is also not on the line. Fig. 9 In the case 3, the drawing starting point is also included as coordinate point 6, coordinate point 9 or coordinate point 12.

[0262] For case 1, since the drawing starting point (start_pos) is on the line, you can start drawing from the drawing starting point (start_pos). However, for cases 2 and 3, the drawing starting point (start_pos) is not on the line. If you still start drawing from the drawing starting point (start_pos), the drawing result may have problems such as incomplete stroke display or heavy stroke display.

[0263] Therefore, the embodiment of the present application further judges the drawing starting point and the drawing end point after initialization in step 102, handles the above three situations that may occur at the drawing starting point respectively, moves the current drawing point to the accurate position, and avoids abnormal drawing results due to different selections of drawing starting points.

[0264] In an optional embodiment of the present application, the method further includes:

[0265] Step S21, after initializing the drawing starting point and the drawing end point, determine whether the drawing starting point is on the line;

[0266] Step S22: if the drawing starting point is on the line, move the current drawing point to the drawing starting point;

[0267] Step S23: if the drawing starting point is not on the line, determine whether the drawing end point is on the line;

[0268] Step S24: if the drawing end point is on the line, move the current drawing point to the drawing end point, and use the drawing end point to update the third element;

[0269] Step S25: If the drawing end point is not on the line, calculate the midpoint of the line connecting the drawing start point and the drawing end point, move the current drawing point to the midpoint of the line, and use the midpoint of the line to update the third element.

[0270] For case 1, since the drawing starting point (start_pos) is on the line, you can start drawing from the drawing starting point (start_pos). Therefore, you can execute the moveto instruction to move the current drawing point to the drawing starting point (start_pos) and start drawing from the drawing starting point (start_pos).

[0271] If the drawing starting point (start_pos) is not on the line, drawing from the drawing starting point (start_pos) will result in an error, so the accurate drawing point needs to be re-determined. In addition, since the drawing starting point (start_pos) is not on the line, it means that the drawing starting point (start_pos) is a control point, and the current Bezier curve to be drawn is a Bezier curve, and the subsequent process of converting the quadratic Bezier curve to a cubic Bezier curve is required. Therefore, the present application further judges the previous point of the drawing starting point (start_pos). Since the coordinate points in the first array form a closed path, the previous coordinate point of the drawing starting point is the drawing end point. Therefore, when the drawing starting point in the first array is not on the line, the present application further judges whether the drawing end point is on the line. If the drawing end point is on the line, it belongs to case 2; if the drawing end point is not on the line, it belongs to case 3.

[0272] For case 2, the drawing starting point is not on the line, but the drawing end point is on the line, and what is to be drawn is a curve, which means that the drawing end point is the end point of the previous curve. Therefore, the moveto instruction can be executed to move the current drawing point to the position of the drawing end point, and start drawing from the drawing end point. In addition, the value of the third element curve_pts[2] can also be updated with the drawing end point, indicating that the drawing end point is the end point of the previous curve, which is convenient for subsequent conversion of cubic Bezier curves.

[0273] For case 3, the drawing start point is not on the line, and the drawing end point is not on the line either, which means that a continuous curve is to be drawn. The previous curve in the continuous curve has been drawn, and the next curve needs to be drawn. At this time, it is necessary to calculate the midpoint of the line connecting the drawing start point start_pos and the drawing end point end_pt. The midpoint of the line is the common endpoint of the two continuous curves, that is, the end endpoint of the previous curve and the start endpoint of the next curve. At this time, the moveto instruction can be executed to move the current drawing point to the midpoint of the line, and start drawing from the midpoint of the line. In addition, the value of curve_pts[2] is updated with the midpoint of the line for subsequent conversion to cubic Bezier curves.

[0274] against Figure 8 The process shown in this application Figure 8 Step 1 in the above code adds a judgment process for the drawing starting point. The improved process is as follows: Fig.10 Specifically, Figure 8 Step 1 in the further judgment process is as follows:

[0275] In step 1, the first array of the target glyph is obtained, start_pos and end_pt are initialized, and then it is determined whether start_pos is on the line. The following steps are performed according to whether start_pos is on the line:

[0276] Step 1-1: Determine whether start_pos is on the line. If so, execute the moveto instruction to move the current drawing point to start_pos. At this time, the current drawing point is at start_pos. Continue to step 2. If not on the line, execute steps 1-2.

[0277] Step 1-2: Determine whether end_pt is online. If so, execute step 1-3. If not, execute step 1-4.

[0278] Step 1-3: Execute the moveto instruction to move the current drawing point to end_pt. At this time, the current drawing point is located at end_pt. In addition, the value of the third element curve_pt[2] is updated to end_pt. Continue to step 2.

[0279] Step 1-4: Calculate the midpoint mid of the line connecting start_pos and end_pt, and execute the moveto instruction to move the current drawing point to mid. At this time, the current drawing point is located at mid; in addition, update the value of the third element curve_pt[2] to mid; continue to step 2.

[0280] It should be noted that Fig.10 The execution process of step 2 in Figure 8 The same, so Fig.10 Subsequent processes are omitted.

[0281] In summary, the present application provides a printing processing method that can be used to implement a printing function in Wine. The present application improves the process of executing a printing task by a PostScript driver in Wine. In the process of drawing a target glyph, each coordinate point in the first array of the target glyph is judged and processed. When initializing the second array used to draw a cubic Bezier curve, a more accurate initial value is assigned. In the process of drawing a target glyph, when drawing a curve in the target glyph, the coordinates of the accurate cubic Bezier curve can be calculated, so that the cubic Bezier curve can be accurately drawn, avoiding abnormalities in the curves in the printed text, improving the compatibility of the printing function in Wine, and improving the reading quality of the user.

[0282] It should be noted that, for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present application are not limited by the described order of actions, because according to the embodiments of the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present application.

[0283] Reference Fig.11 , shows a structural block diagram of an embodiment of a printing processing device of the present application, the device comprising:

[0284] The data acquisition module 201 is used to acquire a first array of the target glyph in response to a printing task; the first array includes each coordinate point in the target glyph and a category of each coordinate point, wherein the category includes an endpoint or a control point;

[0285] A first initialization module 202, configured to initialize a drawing start point and a drawing end point based on the coordinate points in the first array;

[0286] A second initialization module 203 is used to define a second array for drawing a cubic Bezier curve, and initialize the second array based on the drawing starting point; the first element, the second element and the third element in the second array are respectively used to record the first control point, the second control point and the termination endpoint of the cubic Bezier curve to be drawn;

[0287] The traversal drawing module 204 is used to traverse the first array from the drawing starting point, and if the category of the next coordinate point of the traversed current coordinate point is an endpoint, a straight line is drawn from the current drawing point; if the category of the next coordinate point of the traversed current coordinate point is a control point, the second array is updated based on the current coordinate point and the next coordinate point, and a cubic Bezier curve is drawn from the current drawing point according to the updated second array.

[0288] Optionally, the second initialization module is specifically configured to initialize the first element and the third element as the drawing starting point, and initialize the second element to 0.

[0289] Optionally, the traversal drawing module includes:

[0290] A first updating submodule is configured to determine whether a previous coordinate point of the current coordinate point is on the line to obtain a first determination result; and update the first element according to the first determination result to obtain a first updated value of the first element;

[0291] A second updating submodule is configured to determine whether the current coordinate point is the drawing end point, and obtain a second determination result; and update the third element according to the second determination result, and obtain a first updated value of the third element;

[0292] The third updating submodule is used to calculate the second updated value of the first element and the first updated value of the second element based on the current coordinate point, the first updated value of the first element and the first updated value of the third element, based on the formula for converting the quadratic Bezier curve to the cubic Bezier curve.

[0293] Optionally, the traversal drawing module includes:

[0294] A drawing submodule, used to use the current drawing point as the starting endpoint of the cubic Bezier curve to be drawn, the second updated value of the first element as the first control point of the cubic Bezier curve to be drawn, the first updated value of the second element as the second control point of the cubic Bezier curve to be drawn, and the first updated value of the third element as the terminating endpoint of the cubic Bezier curve to be drawn, so as to draw the cubic Bezier curve.

[0295] Optionally, the first updating submodule is specifically configured to:

[0296] If the previous coordinate point of the current coordinate point is on the line, the first element is updated using the previous coordinate point of the current coordinate point; if the previous coordinate point of the current coordinate point is not on the line, the first element is updated using the current value of the third element.

[0297] Optionally, the second updating submodule is specifically used to:

[0298] If the current coordinate point is the drawing end point, the third element is updated using the drawing starting point; if the current coordinate point is not the drawing end point and the next coordinate point of the current coordinate point is on the line, the third element is updated using the next coordinate point of the current coordinate point; if the current coordinate point is not the drawing end point and the next coordinate point of the current coordinate point is not on the line, the midpoint of the line connecting the current coordinate point and the next coordinate point of the current coordinate point is calculated, and the third element is updated using the midpoint of the line.

[0299] Optionally, the device further comprises:

[0300] A flag setting module, used for setting a preset flag, wherein the initial value of the preset flag is a first value;

[0301] A flag updating module, configured to set the preset flag to a second value when the current coordinate point is not the drawing end point and the next coordinate point of the current coordinate point is on the line;

[0302] The device also includes:

[0303] The return judgment module is used to read the preset flag; if the preset flag is the first value, the traversal operation is continued; if the preset flag is the second value, the operation of continuing to draw the next cubic Bezier curve is executed.

[0304] Optionally, the device further comprises:

[0305] A coordinate judgment module, used to judge whether the drawing starting point is on the line after initializing the drawing starting point and the drawing end point;

[0306] A first processing module, configured to move the current drawing point to the drawing starting point if the drawing starting point is on the line;

[0307] The second processing module is used to determine whether the drawing end point is on the line if the drawing starting point is not on the line; if the drawing end point is on the line, move the current drawing point to the drawing end point, and update the third element using the drawing end point;

[0308] The third processing module is used to calculate the midpoint of the line connecting the drawing starting point and the drawing end point if the drawing end point is not on the line, move the current drawing point to the midpoint of the line, and update the third element using the midpoint of the line.

[0309] In summary, the present application provides a printing processing device that can be used to implement a printing function in Wine. The present application improves the process of executing a printing task by a PostScript driver in Wine. In the process of drawing a target glyph, each coordinate point in the first array of the target glyph is judged and processed. When initializing the second array used to draw a cubic Bezier curve, a more accurate initial value is assigned. In the process of drawing a target glyph, when drawing a curve in the target glyph, the coordinates of the accurate cubic Bezier curve can be calculated, so that the cubic Bezier curve can be accurately drawn, avoiding abnormalities in the curves in the printed text, improving the compatibility of the printing function in Wine, and improving the reading quality of the user.

[0310] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0311] Reference Fig.12, is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.12 As shown, the electronic device includes: a processor, a memory, a communication interface and a communication bus, and the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the steps of the printing processing method of the aforementioned embodiment.

[0312] An embodiment of the present application provides a non-temporary computer-readable storage medium. When the instructions in the storage medium are executed by a program or processor of a terminal, the terminal is enabled to execute the steps of the print processing method of the aforementioned embodiment.

[0313] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0314] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0315] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0316] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a predictable manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1A function specified in one or more boxes.

[0317] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0318] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0319] Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A printing processing method, characterized in that: The method comprises: The Windows program running in Wine receives the print task triggered by the user; In response to the printing task, a first array of a target glyph is obtained; the first array includes each coordinate point of the target glyph and a category of each coordinate point, the category including an endpoint or a control point; the first array includes a group of continuous coordinate points; Initialize a drawing starting point and a drawing end point based on the coordinate points in the first array; the drawing starting point is any coordinate point in the first array, and the drawing end point is the previous coordinate point of the drawing starting point in the first array; initially, the current drawing point is the drawing starting point; A second array for drawing a cubic Bezier curve is defined, and the second array is initialized based on the drawing starting point; the first element, the second element and the third element in the second array are respectively used to record the first control point, the second control point and the termination endpoint of the cubic Bezier curve to be drawn; According to the situation of the drawing starting point, move the current drawing point; Traversing the first array from the drawing starting point, if the category of the next coordinate point of the traversed current coordinate point is an endpoint, drawing a straight line from the current drawing point; If the category of the next coordinate point of the traversed current coordinate point is a control point, the second array is updated based on the current coordinate point and the next coordinate point, and a cubic Bezier curve is drawn starting from the current drawing point according to the updated second array.

2. The method according to claim 1, characterized in that The initializing the second array based on the drawing starting point includes: The first element and the third element are initialized to the drawing starting point, and the second element is initialized to 0.

3. The method according to claim 1, characterized in that The updating of the second array based on the current coordinate point and the next coordinate point includes: Determine whether the previous coordinate point of the current coordinate point is on the line, and obtain a first determination result; According to the first judgment result, the first element is updated to obtain a first updated value of the first element; Determine whether the current coordinate point is the drawing end point, and obtain a second determination result; According to the second judgment result, updating the third element to obtain a first updated value of the third element; According to the current coordinate point, the first updated value of the first element and the first updated value of the third element, based on the formula for converting a quadratic Bezier curve to a cubic Bezier curve, the second updated value of the first element and the first updated value of the second element are calculated.

4. The method according to claim 3, characterized in that The step of drawing a cubic Bezier curve starting from the current drawing point according to the updated second array includes: The cubic Bezier curve is drawn by taking the current drawing point as the starting endpoint of the cubic Bezier curve to be drawn, taking the second updated value of the first element as the first control point of the cubic Bezier curve to be drawn, taking the first updated value of the second element as the second control point of the cubic Bezier curve to be drawn, and taking the first updated value of the third element as the terminating endpoint of the cubic Bezier curve to be drawn.

5. The method according to claim 3, characterized in that: The updating of the first element according to the first judgment result includes: If the previous coordinate point of the current coordinate point is on the line, the first element is updated using the previous coordinate point of the current coordinate point; If the previous coordinate point of the current coordinate point is not on the line, the first element is updated using the current value of the third element.

6. The method according to claim 3, characterized in that: The updating of the third element according to the second judgment result includes: If the current coordinate point is the drawing end point, updating the third element using the drawing starting point; If the current coordinate point is not the drawing end point, and the next coordinate point of the current coordinate point is on the line, then the third element is updated using the next coordinate point of the current coordinate point; If the current coordinate point is not the drawing end point, and the next coordinate point of the current coordinate point is not on the line, the midpoint of the line connecting the current coordinate point and the next coordinate point of the current coordinate point is calculated, and the third element is updated using the midpoint of the line.

7. The method according to claim 6, characterized in that The method further comprises: Setting a preset flag, wherein the initial value of the preset flag is a first value; When the current coordinate point is not the drawing end point and the next coordinate point of the current coordinate point is on the line, setting the preset flag to a second value; After drawing a cubic Bezier curve starting from the current drawing point according to the updated second array, the method further includes: Update the current coordinate point of the traversal to the next coordinate point; Reading the preset flag; If the preset flag is the first value, continue to perform the traversal operation; If the preset flag is the second value, the operation of continuing to draw the next cubic Bezier curve is executed.

8. The method according to claim 1, characterized in that The moving the current drawing point according to the situation of the drawing starting point includes: Determine whether the drawing starting point is on the line; If the drawing starting point is on the line, move the current drawing point to the drawing starting point; If the drawing starting point is not on the line, determining whether the drawing end point is on the line; If the drawing end point is on the line, move the current drawing point to the drawing end point; If the drawing end point is not on the line, the midpoint of the line connecting the drawing start point and the drawing end point is calculated, and the current drawing point is moved to the midpoint of the line.

9. The method according to claim 8, characterized in that If the drawing end point is on the line, the current drawing point is moved to after the drawing end point, and the method further includes: updating the third element using the drawing end point; If the drawing end point is not on the line, the midpoint of the line connecting the drawing start point and the drawing end point is calculated, and the current drawing point is moved to behind the midpoint of the line, and the method further includes: updating the third element using the midpoint of the line.

10. A printing processing device, characterized in that: The device comprises: The task receiving module is used for the Windows program running in Wine to receive the printing tasks triggered by the user; A data acquisition module, configured to acquire a first array of a target glyph in response to the printing task; the first array includes each coordinate point of the target glyph and a category of each coordinate point, the category including an endpoint or a control point; the first array includes a group of continuous coordinate points; A first initialization module, used to initialize a drawing starting point and a drawing end point based on the coordinate points in the first array; the drawing starting point is any coordinate point in the first array, and the drawing end point is the previous coordinate point of the drawing starting point in the first array; initially, the current drawing point is the drawing starting point; A second initialization module is used to define a second array for drawing a cubic Bezier curve, and initialize the second array based on the drawing starting point; the first element, the second element and the third element in the second array are respectively used to record the first control point, the second control point and the termination endpoint of the cubic Bezier curve to be drawn; A drawing point correction module, used for moving the current drawing point according to the situation of the drawing starting point; A traversal drawing module is used to traverse the first array from the drawing starting point, and if the category of the next coordinate point of the traversed current coordinate point is an endpoint, a straight line is drawn from the current drawing point; if the category of the next coordinate point of the traversed current coordinate point is a control point, the second array is updated based on the current coordinate point and the next coordinate point, and a cubic Bezier curve is drawn from the current drawing point according to the updated second array.

11. An electronic device, characterized in that: include: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the steps of the printing processing method according to any one of claims 1 to 9.

12. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the printing processing method according to any one of claims 1 to 9 are implemented.