CN111402366B - Text rendering method and device, electronic equipment and storage medium - Google Patents

Text rendering method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111402366B
CN111402366B CN202010192591.2A CN202010192591A CN111402366B CN 111402366 B CN111402366 B CN 111402366B CN 202010192591 A CN202010192591 A CN 202010192591A CN 111402366 B CN111402366 B CN 111402366B
Authority
CN
China
Prior art keywords
coordinate
curve
step length
coordinate set
coordinates
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010192591.2A
Other languages
Chinese (zh)
Other versions
CN111402366A (en
Inventor
韩忠涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN202010192591.2A priority Critical patent/CN111402366B/en
Publication of CN111402366A publication Critical patent/CN111402366A/en
Application granted granted Critical
Publication of CN111402366B publication Critical patent/CN111402366B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/60Editing figures and text; Combining figures or text
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

A character rendering method, a device, an electronic device and a storage medium belong to the field of data processing. The method comprises the following steps: when a character rendering instruction is received, determining a target character to be rendered, wherein font data of the target character at least comprises coordinates of a curve coordinate set, and the curve coordinate set at least comprises endpoints of a curve forming the character; dividing a curve between endpoints contained in the curve coordinate set based on a dynamic step length aiming at the curve coordinate set to obtain a plurality of coordinate points corresponding to the curve coordinate set; generating a lattice coordinate set of the font contour curve at least according to a plurality of coordinate points corresponding to the curve coordinate set; and displaying the font outline curve based on the dot matrix coordinate set to obtain the rendered target text. By adopting the technical scheme provided by the application, the font contour curve can be displayed based on the font data.

Description

Text rendering method and device, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of data processing, and in particular, to a text rendering method, a text rendering device, an electronic device, and a storage medium.
Background
For each character, the electronic device may store font data for describing a font contour curve of the character, where the font data includes coordinates of a plurality of sets of coordinate points, and one set of coordinate points may be an end point forming a straight line, or may be an end point of a bezier curve and a control point outside the bezier curve. When rendering the text, in order to meet the requirement of clearly displaying the text, the electronic device may generate a plurality of coordinate points constituting the font contour curve based on the font data, obtain a lattice coordinate set constituting the font contour curve, and then, the electronic device may display the font contour curve based on the lattice coordinate set.
Disclosure of Invention
The application provides a character rendering method, a character rendering device, electronic equipment and a storage medium, which can display a character outline curve based on character data.
In a first aspect, the present application provides a text rendering method, where the method includes:
when a character rendering instruction is received, determining a target character to be rendered, wherein font data of the target character at least comprises coordinates of a curve coordinate set, and the curve coordinate set at least comprises endpoints of a curve forming the character;
Dividing a curve between endpoints contained in the curve coordinate set based on a dynamic step length aiming at the curve coordinate set to obtain a plurality of coordinate points corresponding to the curve coordinate set;
generating a lattice coordinate set of the font contour curve at least according to a plurality of coordinate points corresponding to the curve coordinate set;
and displaying the font outline curve based on the dot matrix coordinate set to obtain the rendered target text.
Optionally, for the curve coordinate set, dividing a curve between endpoints included in the curve coordinate set based on a dynamic step length to obtain a plurality of coordinate points corresponding to the curve coordinate set, including:
acquiring a first coordinate of a first coordinate point aiming at the curve coordinate set;
selecting a step length from a preset step length range;
calculating a second coordinate of a second coordinate point according to the step length and a curve formula of a curve between endpoints included in the curve coordinate set;
if the first coordinate and the second coordinate meet the curve smoothness condition, taking the second coordinate point as a coordinate point corresponding to the curve coordinate set, and redefining the first coordinate point, and executing the step of selecting the step from the preset step range until the dividing ending condition is met;
And if the first coordinate and the second coordinate do not meet the curve smoothness condition, the step length is redetermined, the step length is executed, the step length of calculating the second coordinate point according to the curve formula and the step length is calculated, and the redetermined step length is smaller than the original step length.
Optionally, determining whether the first coordinate and the second coordinate meet a curve smoothness condition includes:
calculating a function value of a preset loss function according to the first coordinate and the second coordinate;
if the function value is larger than a preset threshold value, determining that the first coordinate and the second coordinate do not meet a curve smoothness condition;
and if the function value is not greater than the preset threshold value, determining that the first coordinate and the second coordinate meet a curve smoothness condition.
Optionally, if the first coordinate and the second coordinate meet the curve smoothness condition, the redefining the first coordinate point includes:
taking the second coordinate point as a first coordinate point;
the step length selecting from the preset step length range comprises the following steps:
taking the step length corresponding to the second coordinate point as the lower limit of the step length range to obtain an updated step length range;
And selecting a step size from the updated step size range.
Optionally, after determining the target text to be rendered, the method further includes:
acquiring initial font data of the target characters, wherein coordinates contained in the initial font data are coordinates in a pixel plane;
and carrying out sub-pixelation processing on the initial font data to obtain font data of the target characters, wherein the coordinates contained in the font data are coordinates in a multidimensional pixel space.
In a second aspect, the present application further provides a text rendering device, where the device includes:
the character rendering device comprises a first determining module, a second determining module and a character rendering module, wherein the first determining module is used for determining a target character to be rendered when receiving a character rendering instruction, font data of the target character at least comprises coordinates of a curve coordinate set, and the curve coordinate set at least comprises endpoints of a curve forming the character;
the dynamic dividing module is used for dividing the curve between the endpoints contained in the curve coordinate set based on the dynamic step length aiming at the curve coordinate set to obtain a plurality of coordinate points corresponding to the curve coordinate set;
the generating module is used for generating a lattice coordinate set of the font contour curve at least according to a plurality of coordinate points corresponding to the curve coordinate set;
And the display module is used for displaying the font outline curve based on the dot matrix coordinate set to obtain the rendered target text.
Optionally, the dynamic partitioning module includes:
the first acquisition submodule is used for acquiring first coordinates of a first coordinate point aiming at the curve coordinate set;
a selecting sub-module for selecting a step size from a preset step size range;
the calculation sub-module is used for calculating second coordinates of the second coordinate points according to the step length and a curve formula of a curve between endpoints contained in the curve coordinate set;
the first determining submodule is used for taking the second coordinate point as a coordinate point corresponding to the curve coordinate set when the first coordinate and the second coordinate meet the curve smoothness condition, triggering the obtaining submodule to redetermine the first coordinate point, and triggering the selecting submodule to execute the step of selecting the step from the preset step range until the dividing ending condition is met;
and the selecting submodule is further used for determining the step length again when the first coordinate and the second coordinate do not meet the curve smoothness condition, triggering the calculating submodule to execute the step of calculating the second coordinate of the second coordinate point according to the step length and the curve formula of the curve between the endpoints contained in the curve coordinate set, and the determined step length is smaller than the original step length.
Optionally, the apparatus further includes:
the calculation module is used for calculating the function value of a preset loss function according to the first coordinate and the second coordinate;
the second determining module is used for determining that the first coordinate and the second coordinate do not meet the curve smoothness condition when the function value is larger than a preset threshold value;
and the second determining module is further configured to determine that the first coordinate and the second coordinate satisfy a curve smoothness condition when the function value is not greater than the preset threshold.
Optionally, the obtaining submodule is specifically configured to take the second coordinate point as the first coordinate point under a condition that coordinates of the second coordinate point meet a curve smoothness condition;
the selecting submodule is specifically configured to take a step length corresponding to the second coordinate point as a lower limit of the step length range, and obtain an updated step length range; and selecting a step size from the updated step size range.
Optionally, the apparatus further includes:
the acquisition module is used for acquiring initial font data of the target characters, wherein the initial font data comprise coordinates in a pixel plane;
and the sub-pixelation processing module is used for carrying out sub-pixelation processing on the initial font data to obtain the font data of the target characters, wherein the coordinates contained in the font data are coordinates in a multidimensional pixel space.
In a third aspect, the present application further provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of the first aspects when executing a program stored on a memory.
In a fourth aspect, the present application also provides a computer readable storage medium having instructions stored therein, which when run on a computer, cause the computer to perform any one of the above-described text rendering methods.
In a fifth aspect, the present application also provides a computer program product comprising instructions which, when run on a computer, cause the computer to perform any of the above-described text rendering methods.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages:
according to the method provided by the embodiment of the application, when a character rendering instruction is received, the target character to be rendered can be determined, the font data of the target character at least comprises the coordinates of a curve coordinate set, and the curve coordinate set at least comprises the endpoints of the curve forming the character; dividing a curve between endpoints contained in a curve coordinate set based on a dynamic step length aiming at the curve coordinate set to obtain a plurality of coordinate points corresponding to the curve coordinate set; generating a lattice coordinate set of the font contour curve at least according to a plurality of coordinate points corresponding to each curve coordinate set; and displaying the font outline curve based on the dot matrix coordinate set to obtain the rendered target text.
Because the curves between the endpoints included in the curve coordinate set are divided based on the dynamic step length, the font contour curve displayed based on the dot matrix coordinate set is closer to the real contour curve of the characters, so that the font contour curve can be displayed based on the font data.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
In order to more clearly illustrate the embodiments of the invention or the technical solutions of the prior art, the drawings which are used in the description of the embodiments or the prior art will be briefly described, and it will be obvious to a person skilled in the art that other drawings can be obtained from these drawings without inventive effort.
Fig. 1 is a flowchart of a text rendering method provided in an embodiment of the present application;
FIG. 2a is a text rendering effect diagram according to an embodiment of the present disclosure;
FIG. 2b is a diagram of another text rendering effect according to an embodiment of the present disclosure;
FIG. 3 is a flowchart of another text rendering method according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a target curve according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of a text rendering device according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present application based on the embodiments herein.
The embodiment of the application provides a text rendering method, which can be applied to electronic equipment, wherein the electronic equipment can have a text display function, and the electronic equipment can be a mobile phone, a tablet personal computer, a notebook computer, a wearable electronic equipment and the like.
In the related art, one font may have various representations, such as regular, italic, bold, etc., and the electronic device may display text in various fonts, various representations. By adopting the text rendering method provided by the embodiment of the application, the text with different fonts and different expression forms can be rendered.
Alternatively, by adopting the text rendering method provided by the embodiment of the application, text displayed in the application program of the mobile terminal can be rendered, and text displayed in the application program of the PC (Personal Computer ) terminal can also be rendered.
The following will describe a text rendering method provided in the embodiment of the present application in detail with reference to a specific embodiment, as shown in fig. 1, and the specific steps are as follows:
step 101, when a text rendering instruction is received, determining a target text to be rendered.
The font data of the target text at least comprises coordinates of a curve coordinate set, and the curve coordinate set at least comprises endpoints of curves forming the text.
In implementation, when an artistic font is required to be rendered, a user may perform a text rendering operation, so that the electronic device receives a text rendering instruction, where the text rendering operation may be to click an icon representing a certain font in a state of selecting a text to be rendered; the text rendering operation may be to input text to be rendered in a state where a certain font mode is selected.
After receiving the text rendering instruction, the electronic device may determine text to be rendered. The electronic device can determine the text to be rendered in various modes, for example, the text rendering instruction can carry a text identifier, and the electronic device can take the text corresponding to the text identifier carried by the text rendering instruction as the text to be rendered; in a state of selecting a certain font mode, the electronic device can also use the text input by the user as the text to be rendered.
Then, the electronic device may determine font data of the text to be rendered according to a correspondence between the pre-stored text and the font data. The glyph data for the text to be rendered may include coordinates of a set of rectilinear coordinates and/or coordinates of a set of curvilinear coordinates. For example, the text to be rendered is "earth", and the glyph data may include coordinates of a set of linear coordinates; the text to be rendered is "fly", and the font data may include coordinates of a linear coordinate set and coordinates of a curved coordinate set; the text to be rendered is "heart" and the glyph data may include coordinates of a set of curvilinear coordinates.
The electronic device may determine, for each text to be rendered, whether the font data of the text includes coordinates of the curved coordinate set, and if the font data of the text includes coordinates of the curved coordinate set, the electronic device may use the text as the target text.
If the font data of the text does not contain the coordinates of the curve coordinate set, the font data of the text only contains the coordinates of the straight line coordinate set, and the electronic equipment can display the text directly based on the coordinates of the straight line coordinate set, so that text rendering is realized. Or the electronic device may divide the line between the two end points included in the line coordinate set, and display the text based on the coordinates of the coordinate points obtained by the division, so as to implement text rendering.
In this embodiment of the present application, the font data may include a class identifier of a coordinate set, and the electronic device may determine that a certain coordinate set is a linear coordinate set or a curved coordinate set according to the class identifier of the certain coordinate set.
Optionally, font data of characters with multiple fonts can be pre-stored in the electronic device, and the electronic device can determine the fonts after rendering the characters, namely, determine the target fonts. The electronic device may then determine, among the glyph data for the target font, the glyph data for the text to be rendered.
The electronic device may further perform coordinate transformation on coordinates included in the font data according to a preset reduction ratio or amplification ratio after the font data is acquired, and perform text rendering based on the font data after the coordinate transformation, so as to reduce or amplify the rendered text to a set font size.
Step 102, dividing the curve between the endpoints included in the curve coordinate set based on the dynamic step length for the curve coordinate set, and obtaining a plurality of coordinate points corresponding to the curve coordinate set.
In an implementation, for a curve coordinate set included in font data of a target text, an electronic device may divide a curve between endpoints included in the curve coordinate set based on a dynamic step size, to obtain a plurality of coordinate points corresponding to the curve coordinate set. In the case where the font data of a certain character includes a plurality of curved coordinate sets, the electronic device may determine a plurality of coordinate points corresponding to each curved coordinate set, respectively.
Alternatively, for convenience of description, a curve between end points included in a curve coordinate set is referred to as a target curve. The embodiment of the application also provides a realization mode for dividing the target curve based on the dynamic step length to obtain a plurality of coordinate points corresponding to the curve coordinate set:
the electronic device may determine a curve formula for describing the target curve, and then the electronic device may divide the target curve according to coordinates of the end points, the curve formula, and the dynamic step length, to obtain a plurality of coordinate points. The specific processing will be described in detail later.
And 103, generating a lattice coordinate set of the font contour curve at least according to a plurality of coordinate points corresponding to the curve coordinate set.
In an implementation, if the font data of the text to be rendered includes coordinates of a linear coordinate set, the electronic device may use coordinates of a plurality of coordinate points corresponding to the linear coordinate set and coordinates of two end points included in the linear coordinate set, which constitute a line, as a combined element of the coordinate set, to obtain a lattice coordinate set of the font contour curve.
Alternatively, the electronic device may divide, for a linear coordinate set, a line between endpoints included in the linear coordinate set, and obtain a plurality of coordinate points corresponding to the linear coordinate set. Then, the electronic device may use the coordinates of the plurality of coordinate points corresponding to the curve coordinate set and the coordinates of the plurality of coordinate points corresponding to the straight line coordinate set as the combined elements of the coordinate set to obtain the dot matrix coordinate set of the font contour curve.
If the font data of the text to be rendered only comprises the coordinates of the curve coordinate set, the electronic device can take the coordinates of a plurality of coordinate points corresponding to the curve coordinate set as the combined elements of the coordinate set to obtain the dot matrix coordinate set of the font contour curve.
And 104, displaying the font outline curve based on the dot matrix coordinate set to obtain the rendered target text.
In implementation, the electronic device may determine, in a preset display interface, a plurality of coordinate points forming a font outline curve according to coordinates included in the lattice coordinate set, connect the plurality of coordinate points, and generate the font outline curve, so as to obtain the rendered target text.
In one possible implementation manner, the electronic device may assemble each coordinate point in the lattice coordinate set into a primitive, perform texture mapping processing and rasterization processing on the primitive, and then perform antialiasing processing on the result of the rasterization processing, so as to obtain the rendered target text. For the specific processing procedure, reference may be made to the processing procedures of primitive assembly, texture mapping processing, rasterization processing and antialiasing processing in the related art, which are not described herein.
As shown in fig. 2a, in the text rendering effect diagram obtained by rendering text in the related art, the font edge in the image area identified by 210 is not smooth enough, and the text rendering effect is poor. Fig. 2b is a text rendering effect diagram obtained by rendering the same text by using the text rendering method provided in the embodiment of the present application, and it can be seen that the font edge in the image area identified by 220 is significantly smoother, and the text rendering effect is good.
In the embodiment of the application, when receiving a text rendering instruction, the electronic device may determine a target text to be rendered, where font data of the target text at least includes coordinates of a curve coordinate set, and the curve coordinate set includes at least endpoints of a curve forming the text; dividing a curve between endpoints contained in a curve coordinate set based on a dynamic step length aiming at the curve coordinate set to obtain a plurality of coordinate points corresponding to the curve coordinate set; generating a lattice coordinate set of the font contour curve at least according to a plurality of coordinate points corresponding to each curve coordinate set; and displaying the font outline curve based on the dot matrix coordinate set to obtain the rendered target text.
Because the curves between the endpoints included in the curve coordinate set are divided based on the dynamic step length, the font contour curve displayed based on the dot matrix coordinate set is closer to the real contour curve of the characters, so that the font contour curve can be displayed based on the font data.
Optionally, an implementation manner of dividing a curve between endpoints included in a curve coordinate set based on a dynamic step length to obtain a plurality of coordinate points corresponding to the curve coordinate set is provided in an embodiment of the present application, as shown in fig. 3, including:
Step 301, obtaining a first coordinate of a first coordinate point for a curve coordinate set.
In an implementation, for each curve coordinate set included in the font data of the text to be rendered, the electronic device may select an endpoint from two endpoints included in the curve coordinate set, and use the initial endpoint as the first coordinate point, and use the coordinates of the initial endpoint as the first coordinate point.
In the curve dividing process, besides the initial end point, the electronic device can also select coordinate points from the coordinate points corresponding to the determined curve coordinate set, the selected coordinate points are used as first coordinate points, the coordinates of the selected coordinate points are used as first coordinates, and the specific processing process is described in detail later.
For example, the coordinates included in the curved coordinate set are the coordinates of two endpoints B0 and B1, the coordinates of the control point C, and the electronic device may use the endpoint B0 as the first coordinate point and the coordinates of B0 as the first coordinate point. For ease of description, the curve between the endpoints contained in the set of curve coordinates is referred to as the target curve. Fig. 4 is a schematic diagram of a target curve according to an embodiment of the present application.
Step 302, selecting a step size from a preset step size range.
Wherein, the electronic device can be preset with a step range, and the step range can be expressed as [0, step max ],step max The value can be 0.99, and a developer can change the step range according to the requirement.
In implementations, the electronic device may randomly select a value from a range of step sizes as the step size.
Step 303, calculating the second coordinates of the second coordinate point according to the step length and the curve formula of the curve between the endpoints included in the curve coordinate set.
In implementations, the electronic device may determine a curve formula for describing the target curve, and then the electronic device may calculate the second coordinates of the second coordinate point according to the step size, the curve formula.
In this embodiment of the present application, a bezier curve for describing a grapheme outline curve may be divided into a second-order bezier curve and a third-order bezier curve, and the electronic device may determine that the target curve belongs to the second-order bezier curve or the third-order bezier curve based on coordinates of a certain curve coordinate set, a preset curve formula of the second-order bezier curve and a preset curve formula of the third-order bezier curve, so as to determine the curve formula of the target curve. The specific processing procedure may refer to any processing procedure in the related art for determining a curve category based on coordinates of a plurality of coordinate points forming a curve and a curve formula, and will not be described herein.
Optionally, a curve formula of the n-order bezier curve is shown in formula (1):
Figure BDA0002416447510000101
wherein t represents the step size, n and P i Representing glyph data parameters, i ε [0, n]。
First coordinates of first coordinate point
Figure BDA0002416447510000102
Can be expressed as B (t i ),t i Can represent the step length of the first coordinate point relative to the initial endpoint, and when the first coordinate point is the initial endpoint, t i The value may be 0. The step size selected from the step size range is +.>
Figure BDA0002416447510000111
The electronic device can be adapted to the step size chosen>
Figure BDA0002416447510000112
And (1) calculating a second coordinate of the second coordinate point to obtain
Figure BDA0002416447510000113
Namely->
Figure BDA0002416447510000114
Step 304, it is determined whether the first coordinate and the second coordinate satisfy the curve smoothness condition.
In implementation, the electronic device may determine whether the first coordinate and the second coordinate satisfy the curve smoothness condition, if the first coordinate and the second coordinate do not satisfy the curve smoothness condition, the step size selection is indicated to be inappropriate, and if the second coordinate point is used as a coordinate point corresponding to the curve coordinate set, and a font outline curve is displayed based on the coordinate point corresponding to the curve coordinate set, a problem of uneven font edges may occur. Thus, in this case, the electronic device may perform step 305 to re-select the step size, re-determine the second coordinate point.
If the first coordinate and the second coordinate satisfy the curve smoothness condition, the step size is indicated to be properly selected, and if the second coordinate point is used as a coordinate point corresponding to the curve coordinate set, the font contour curve displayed based on the corresponding coordinate point of the curve coordinate set is smoother and more similar to the real contour curve of the text, so in this case, the electronic device may execute step 306 to determine whether the division ending condition of the target curve is satisfied.
The specific processing procedure of the electronic device for judging whether the first coordinate and the second coordinate meet the curve smoothness condition will be described in detail later.
Step 305, redetermine the step size.
Wherein the redetermined step size is smaller than the original step size.
In practice, the electronic device may redetermine the step size in a number of ways, and in one possible implementation, the electronic device may randomly select a value smaller than the original step size from the step size range as the redetermined step size. In another possible implementation manner, the electronic device may calculate the new step size according to the original step size and a preset step size selection formula.
The electronic device may then calculate the second coordinate of the second coordinate point according to the curve formula and the redetermined step size, and determine whether the first coordinate and the second coordinate satisfy the curve smoothness condition, i.e., the electronic device returns to step 303.
Alternatively, the step size selection formula may be
Figure BDA0002416447510000115
Wherein (1)>
Figure BDA0002416447510000116
Is the original step length, t i Is the step size of the first coordinate point relative to the initial endpoint.
For example, the original step size
Figure BDA0002416447510000121
Is 0.6, t i 0, the redetermined step size may be 0.3.
In the embodiment of the application, since the second coordinate point is generated according to the curve formula of the target curve and the step length randomly selected from the step length range for each first coordinate point, the step length between each first coordinate point and the second coordinate point corresponding to the first coordinate point is different, so that curve division based on dynamic step length is realized.
And 306, taking the second coordinate point as a coordinate point corresponding to the curve coordinate set, and judging whether the division ending condition is met.
Wherein the dividing end condition may be that the number of coordinate points corresponding to the curve coordinate set reaches a preset number threshold, or the dividing end condition may be that the step length corresponding to the currently determined second coordinate point reaches a preset step length threshold, for example, the dividing end condition may be that
Figure BDA0002416447510000122
In an implementation, the electronic device may store the second coordinate of the curve coordinate set and the second coordinate point corresponding to the curve coordinate set with the second coordinate point as the coordinate point corresponding to the curve coordinate set. Then, the electronic device may determine whether the division end condition is satisfied.
If the division ending condition is met, the condition shows that the font outline curve displayed based on the coordinate points corresponding to the curve coordinate set is smooth and is close to the real outline curve of the characters, and the electronic equipment can not perform subsequent division processing on the target curve.
If the division end condition is not satisfied, it indicates that the grapheme outline curve displayed based on the coordinate points corresponding to the curve coordinate set is not smooth enough, in which case the electronic device may perform step 307 to further divide the target curve.
In step 307, if the division end condition is not satisfied, the first coordinate point is newly determined.
In implementations, the manner in which the electronic device re-determines the first coordinate point may be varied, and in one possible implementation, the electronic device may select the initial endpoint as the first coordinate point. In another possible implementation manner, the electronic device may use the currently determined second coordinate point as the first coordinate point.
Optionally, when the electronic device selects the currently determined second coordinate point as the first coordinate point, the electronic device may use the step length corresponding to the second coordinate point as the lower limit of the step length range to obtain an updated step length range, and then the electronic device may select the step length from the updated step length range.
For example, as shown in fig. 4, the currently determined second coordinate point is B2, the step size corresponding to the second coordinate point B2 is 0.3, the electronic device may set the second coordinate point B2 as the first coordinate point, and set the lower limit of the step size range to be the step size corresponding to the second coordinate point B2 to be 0.3, so as to obtain an updated step size range [0.3,0.99], and then the electronic device may select the step size from the updated step size range [0.3,0.99 ].
In this embodiment of the present application, the step size may be used to measure the distance between the second coordinate point and the initial endpoint, where the coordinate point with the step size of 0 corresponds to the initial endpoint, and the coordinate point with the step size of 1 corresponds to the other endpoint of the target curve. The step length range is updated according to the step length corresponding to the second coordinate point, and the step length is selected from the updated step length range, so that the step lengths selected from the updated step length range are larger than the step length corresponding to the last second coordinate point, and the effect that the current second coordinate point is far from the initial endpoint and close to the other endpoint compared with the last second coordinate point on the target curve is achieved.
Further, in the process of dynamically dividing the target curve, the second coordinate points can be sequentially determined according to the direction from the initial end point to the other end point of the target curve, so that the determined second coordinate points are uniformly distributed on the target curve, and the smoothness of the font outline curve is further improved.
In this embodiment of the present application, the electronic device may obtain, for each curve coordinate set, a first coordinate of a first coordinate point, and select a step from a preset step range, and then, the electronic device may calculate, according to a curve formula and the step, a second coordinate of a second coordinate point, and then determine whether the first coordinate and the second coordinate satisfy a curve smoothness condition. If the first coordinate and the second coordinate meet the curve smoothness condition, the electronic equipment can take the second coordinate point as a coordinate point corresponding to the curve coordinate set, and redetermine the first coordinate point, and execute the step of selecting the step from the preset step range until the dividing ending condition is met; if the first coordinate and the second coordinate do not meet the curve smoothness condition, the electronic device can redetermine the step length, and execute the step of calculating the second coordinate of the second coordinate point according to the curve formula and the step length, wherein the redetermined step length is smaller than the original step length.
Since the refined coordinate points on the target curve are obtained based on the Expectation-maximization algorithm and the dynamic step length, the target curve can be divided based on the dynamic step length. Specifically, the electronic device repeatedly selects a step length from the step length range for each first coordinate point until the second coordinate of the second coordinate point and the first coordinate of the first coordinate point determined according to the selected step length meet the curve smoothness condition, and takes the second coordinate point meeting the curve smoothness condition as a coordinate point corresponding to the curve coordinate set. Therefore, the subsequent character outline curve which is smooth and is closer to the real outline curve of the characters based on the coordinate points corresponding to the curve coordinate set can be ensured, and the character rendering effect can be improved.
Alternatively, the developer research finds that: the smoothness of the curve can be measured by using the function value of the preset loss function, and the smoother the curve is when the function value is smaller. Therefore, the electronic device can determine whether the coordinates of the second coordinate point meet the curve smoothness condition based on the preset loss function, and the specific processing procedure comprises:
and step 1, calculating a function value of a preset loss function according to the first coordinate and the second coordinate.
In an implementation, the electronic device may calculate the function value of the preset loss function according to the first coordinate, the second coordinate, and a formula of the preset loss function.
Alternatively, the formula of the preset loss function may be as shown in formula (2):
Figure BDA0002416447510000141
wherein L (Q) represents a function value of a predetermined loss function, and B (t) i ) And
Figure BDA0002416447510000142
first coordinate representing a first coordinate point, < >>
Figure BDA0002416447510000143
Representing the second coordinate of the second coordinate point calculated based on the curve formula and the step size, ++>
Figure BDA0002416447510000144
Representing step size +.>
Figure BDA0002416447510000145
The desired coordinates of the second coordinate point. Q represents the curve smoothness factor, the smaller the Q value, the smoother the thinned curve, and in the embodiment of the application, the Q can take the value of 0.8.
And step 2, judging whether the function value is larger than a preset threshold value.
Wherein, the preset threshold value can be 0.01.
In implementations, the electronic device may determine whether the function value is greater than a preset threshold. If the function value is greater than the preset threshold, the electronic equipment can execute the step 3; if the function value is not greater than the preset threshold, the electronic device may perform step 4.
And 3, determining that the first coordinate and the second coordinate do not meet the curve smoothness condition.
And 4, determining that the first coordinate and the second coordinate meet the curve smoothness condition.
In this embodiment of the present application, the electronic device may calculate a function value of a preset loss function according to the first coordinate and the second coordinate, and then determine whether the function value is greater than a preset threshold. When the function value is larger than a preset threshold, the electronic device can judge that the first coordinate and the second coordinate meet the curve smoothness condition, and when the function value is not larger than the preset threshold, the electronic device can judge that the first coordinate and the second coordinate do not meet the curve smoothness condition. Because the smoothness of the curve is measured based on the function value of the preset loss function, when the function value of the preset loss function is not greater than the preset threshold value, the first coordinate and the second coordinate are determined to meet the curve smoothness condition, so that the font contour curve displayed based on the second coordinate point is smoother and is closer to the real contour curve of the characters, and the character rendering effect can be improved.
Optionally, the font data of a certain character includes coordinates of a plurality of coordinate points constituting the character, and in general, the plurality of coordinate points belong to a two-dimensional pixel space, and the coordinates of the plurality of coordinate points are coordinates in a pixel plane. For convenience of description, the font data in the case where the coordinates belong to the pixel plane is referred to as initial font data. That is, in general, the font data acquired by the electronic device is initial font data.
After the font data of the target text is determined according to the correspondence between the text and the font data, that is, after the initial font data of the target text is determined, the electronic device may directly use the initial font data as the font data of the target text. In order to improve the text rendering efficiency and the text rendering precision, the electronic device may perform sub-pixelation processing on the initial font data, and use the font data obtained after the sub-pixelation processing as the font data of the target text.
The embodiment of the application provides an implementation mode for carrying out sub-pixelation processing on initial font data to obtain font data, which comprises the following steps:
and step 1, acquiring initial font data of the target characters.
Wherein the initial glyph data contains coordinates in the pixel plane.
In implementation, after receiving the text rendering instruction, the electronic device may determine the font data of the target text, that is, determine the initial font data of the target text, according to the correspondence between the pre-stored text and the font data.
And step 2, carrying out sub-pixelation processing on the initial font data to obtain the font data of the target characters.
Wherein the glyph data contains coordinates that are coordinates in the multi-dimensional pixel space.
In an implementation, the electronic device may perform coordinate conversion on the coordinates of each coordinate point included in the initial font data according to a preset coordinate conversion mode to obtain the coordinates of the coordinate point after coordinate conversion, so that the electronic device may determine the coordinates of a plurality of coordinate points included in the initial font data in a multidimensional pixel space.
Then, the electronic device may take coordinates of the plurality of coordinate points in the multidimensional pixel space as font data of the target text.
In the embodiment of the application, coordinate conversion is performed on a certain coordinate point, so that the coordinate point in a two-dimensional pixel space can be split into a plurality of coordinate points in a multi-dimensional pixel space.
If a plurality of coordinate points corresponding to the curved coordinate set are determined directly based on the initial glyph data, that is, the calculation is performed directly based on the coordinates in the pixel plane, the calculation accuracy is 0.5 pixel. After the coordinates in the pixel plane included in the initial font data are converted, that is, after the initial font data are subjected to sub-pixelation, the calculation accuracy can be improved to 0.5/N pixels. In this embodiment, the N value may take a value of 64, and may select two directions, i.e., a vertical direction and a horizontal direction, to perform the sub-pixelation processing.
In the embodiment of the application, the electronic device may acquire initial font data of the target text, and then perform sub-pixelation processing on the initial font data to obtain font data of the target text. Because the initial font data is subjected to sub-pixelation processing, floating point calculation can be converted into shaping calculation, so that the calculation speed can be improved, and the character rendering efficiency can be improved. Further, by converting coordinates in the pixel plane included in the initial font data into coordinates in the multidimensional pixel space, the calculation accuracy can be improved.
Optionally, after determining the dot matrix coordinate set, the electronic device may further map coordinates belonging to the multidimensional pixel space in the dot matrix coordinate set back to the pixel plane, so as to perform anti-aliasing processing capable of further improving the text rendering effect based on the coordinates belonging to the pixel plane.
Based on the same technical concept, the application also provides a text rendering device, as shown in fig. 5, the device comprises:
a first determining module 510, configured to determine, when a text rendering instruction is received, a target text to be rendered, where font data of the target text includes at least coordinates of a curve coordinate set, and the curve coordinate set includes at least endpoints of a curve that forms the text;
The dynamic dividing module 520 is configured to divide, for the curve coordinate set, a curve between endpoints included in the curve coordinate set based on a dynamic step length, to obtain a plurality of coordinate points corresponding to the curve coordinate set;
the generating module 530 is configured to generate a lattice coordinate set of the grapheme outline curve according to at least a plurality of coordinate points corresponding to the curve coordinate set;
and the display module 540 is configured to display the font contour curve based on the lattice coordinate set, and obtain the rendered target text.
Optionally, the dynamic partitioning module includes:
the first acquisition submodule is used for acquiring first coordinates of a first coordinate point aiming at the curve coordinate set;
a selecting sub-module for selecting a step size from a preset step size range;
the calculation sub-module is used for calculating second coordinates of the second coordinate points according to the step length and a curve formula of a curve between endpoints contained in the curve coordinate set;
the first determining submodule is used for taking the second coordinate point as a coordinate point corresponding to the curve coordinate set when the first coordinate and the second coordinate meet the curve smoothness condition, triggering the obtaining submodule to redetermine the first coordinate point, and triggering the selecting submodule to execute the step of selecting the step from the preset step range until the dividing ending condition is met;
And the selecting submodule is further used for determining the step length again when the first coordinate and the second coordinate do not meet the curve smoothness condition, triggering the calculating submodule to execute the step of calculating the second coordinate of the second coordinate point according to the step length and the curve formula of the curve between the endpoints contained in the curve coordinate set, and the determined step length is smaller than the original step length.
Optionally, the apparatus further includes:
the calculation module is used for calculating the function value of a preset loss function according to the first coordinate and the second coordinate;
the second determining module is used for determining that the first coordinate and the second coordinate do not meet the curve smoothness condition when the function value is larger than a preset threshold value;
and the second determining module is further configured to determine that the first coordinate and the second coordinate satisfy a curve smoothness condition when the function value is not greater than the preset threshold.
Optionally, the obtaining submodule is specifically configured to take the second coordinate point as the first coordinate point under a condition that coordinates of the second coordinate point meet a curve smoothness condition;
the selecting submodule is specifically configured to take a step length corresponding to the second coordinate point as a lower limit of the step length range, and obtain an updated step length range; and selecting a step size from the updated step size range.
Optionally, the apparatus further includes:
the acquisition module is used for acquiring initial font data of the target characters, wherein the initial font data comprise coordinates in a pixel plane;
and the sub-pixelation processing module is used for carrying out sub-pixelation processing on the initial font data to obtain the font data of the target characters, wherein the coordinates contained in the font data are coordinates in a multidimensional pixel space.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages:
according to the device provided by the embodiment of the application, when a character rendering instruction is received, the target character to be rendered can be determined, the font data of the target character at least comprises the coordinates of a curve coordinate set, and the curve coordinate set at least comprises the endpoints of a curve forming the character; dividing a curve between endpoints contained in a curve coordinate set based on a dynamic step length aiming at the curve coordinate set to obtain a plurality of coordinate points corresponding to the curve coordinate set; generating a lattice coordinate set of the font contour curve at least according to a plurality of coordinate points corresponding to each curve coordinate set; and displaying the font outline curve based on the dot matrix coordinate set to obtain the rendered target text.
Because the curves between the endpoints included in the curve coordinate set are divided based on the dynamic step length, the font contour curve displayed based on the dot matrix coordinate set is closer to the real contour curve of the characters, so that the font contour curve can be displayed based on the font data.
The embodiment of the present application further provides an electronic device, as shown in fig. 6, including a processor 601, a communication interface 602, a memory 603, and a communication bus 604, where the processor 601, the communication interface 602, and the memory 603 perform communication with each other through the communication bus 604,
a memory 603 for storing a computer program;
the processor 601 is configured to execute the program stored in the memory 603, and implement the following steps:
when a character rendering instruction is received, obtaining target characters to be rendered, wherein font data of the target characters at least comprise coordinates of a curve coordinate set, and the curve coordinate set at least comprises endpoints of curves forming the characters;
dividing a curve between endpoints contained in the curve coordinate set based on a dynamic step length aiming at the curve coordinate set to obtain a plurality of coordinate points corresponding to the curve coordinate set;
generating a lattice coordinate set of the font contour curve at least according to a plurality of coordinate points corresponding to the curve coordinate set;
And displaying the font outline curve based on the dot matrix coordinate set to obtain the rendered target text.
Optionally, for the curve coordinate set, dividing a curve between endpoints included in the curve coordinate set based on a dynamic step length to obtain a plurality of coordinate points corresponding to the curve coordinate set, including:
acquiring a first coordinate of a first coordinate point aiming at the curve coordinate set;
selecting a step length from a preset step length range;
calculating a second coordinate of a second coordinate point according to the step length and a curve formula of a curve between endpoints included in the curve coordinate set;
if the first coordinate and the second coordinate meet the curve smoothness condition, taking the second coordinate point as a coordinate point corresponding to the curve coordinate set, and redefining the first coordinate point, and executing the step of selecting the step from the preset step range until the dividing ending condition is met;
and if the first coordinate and the second coordinate do not meet the curve smoothness condition, the step length is redetermined, the step length is executed, the step length of calculating the second coordinate point according to the curve formula and the step length is calculated, and the redetermined step length is smaller than the original step length.
Optionally, determining whether the first coordinate and the second coordinate meet a curve smoothness condition includes:
calculating a function value of a preset loss function according to the first coordinate and the second coordinate;
if the function value is larger than a preset threshold value, determining that the first coordinate and the second coordinate do not meet a curve smoothness condition;
and if the function value is not greater than the preset threshold value, determining that the first coordinate and the second coordinate meet a curve smoothness condition.
Optionally, if the first coordinate and the second coordinate meet the curve smoothness condition, the redefining the first coordinate point includes:
taking the second coordinate point as a first coordinate point;
the step length selecting from the preset step length range comprises the following steps:
taking the step length corresponding to the second coordinate point as the lower limit of the step length range to obtain an updated step length range;
and selecting a step size from the updated step size range.
Optionally, after determining the target text to be rendered, the method further includes:
acquiring initial font data of the target characters, wherein coordinates contained in the initial font data are coordinates in a pixel plane;
And carrying out sub-pixelation processing on the initial font data to obtain font data of the target characters, wherein the coordinates contained in the font data are coordinates in a multidimensional pixel space.
The communication bus mentioned by the above terminal may be a peripheral component interconnect standard (Peripheral Component Interconnect, abbreviated as PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, abbreviated as EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the terminal and other devices.
The memory may include random access memory (Random Access Memory, RAM) or non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP for short), etc.; but also digital signal processors (Digital Signal Processing, DSP for short), application specific integrated circuits (Application Specific Integrated Circuit, ASIC for short), field-programmable gate arrays (Field-Programmable Gate Array, FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages:
according to the electronic equipment provided by the embodiment of the application, when a character rendering instruction is received, a target character to be rendered can be determined, font data of the target character at least comprises coordinates of a curve coordinate set, and the curve coordinate set at least comprises endpoints of curves forming the character; dividing a curve between endpoints contained in a curve coordinate set based on a dynamic step length aiming at the curve coordinate set to obtain a plurality of coordinate points corresponding to the curve coordinate set; generating a lattice coordinate set of the font contour curve at least according to a plurality of coordinate points corresponding to each curve coordinate set; and displaying the font outline curve based on the dot matrix coordinate set to obtain the rendered target text.
Because the curves between the endpoints included in the curve coordinate set are divided based on the dynamic step length, the font contour curve displayed based on the dot matrix coordinate set is closer to the real contour curve of the characters, so that the font contour curve can be displayed based on the font data.
In yet another embodiment provided herein, a computer readable storage medium having instructions stored therein that, when executed on a computer, cause the computer to perform the text rendering method of any of the above embodiments is also provided.
In yet another embodiment provided herein, there is also provided a computer program product containing instructions that, when run on a computer, cause the computer to perform the text rendering method of any of the above embodiments.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present application, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), etc.
It should be noted that in this document, relational terms such as "first" and "second" and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The foregoing is only a specific embodiment of the invention to enable those skilled in the art to understand or practice the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A text rendering method, the method comprising:
when a character rendering instruction is received, determining a target character to be rendered, wherein font data of the target character at least comprises coordinates of a curve coordinate set, and the curve coordinate set at least comprises endpoints of a curve forming the character;
dividing a curve between endpoints contained in the curve coordinate set based on a dynamic step length aiming at the curve coordinate set to obtain a plurality of coordinate points corresponding to the curve coordinate set;
generating a lattice coordinate set of the font contour curve at least according to a plurality of coordinate points corresponding to the curve coordinate set;
displaying a font outline curve based on the dot matrix coordinate set to obtain a rendered target character;
the method for dividing the curve between the endpoints included in the curve coordinate set based on the dynamic step length to obtain a plurality of coordinate points corresponding to the curve coordinate set includes:
acquiring a first coordinate of a first coordinate point aiming at the curve coordinate set;
selecting a step length from a preset step length range;
calculating a second coordinate of a second coordinate point according to the step length and a curve formula of a curve between endpoints included in the curve coordinate set;
If the first coordinate and the second coordinate meet the curve smoothness condition, taking the second coordinate point as a coordinate point corresponding to the curve coordinate set, and redefining the first coordinate point, and executing the step of selecting the step from the preset step range until the dividing ending condition is met;
and if the first coordinate and the second coordinate do not meet the curve smoothness condition, the step length is redetermined, the step length is executed, the step length of calculating the second coordinate point according to the curve formula and the step length is calculated, and the redetermined step length is smaller than the original step length.
2. The method of claim 1, wherein determining whether the first coordinate and the second coordinate satisfy a curve smoothness condition comprises:
calculating a function value of a preset loss function according to the first coordinate and the second coordinate;
if the function value is larger than a preset threshold value, determining that the first coordinate and the second coordinate do not meet a curve smoothness condition;
and if the function value is not greater than the preset threshold value, determining that the first coordinate and the second coordinate meet a curve smoothness condition.
3. The method of claim 1, wherein if the first and second coordinates satisfy a curve smoothness condition, the re-determining the first coordinate point comprises:
taking the second coordinate point as a first coordinate point;
the step length selecting from the preset step length range comprises the following steps:
taking the step length corresponding to the second coordinate point as the lower limit of the step length range to obtain an updated step length range;
and selecting a step size from the updated step size range.
4. The method of claim 1, wherein after determining the target text to be rendered, further comprising:
acquiring initial font data of the target characters, wherein coordinates contained in the initial font data are coordinates in a pixel plane;
and carrying out sub-pixelation processing on the initial font data to obtain font data of the target characters, wherein the coordinates contained in the font data are coordinates in a multidimensional pixel space.
5. A text rendering device, the device comprising:
the character rendering device comprises a first determining module, a second determining module and a character rendering module, wherein the first determining module is used for determining a target character to be rendered when receiving a character rendering instruction, font data of the target character at least comprises coordinates of a curve coordinate set, and the curve coordinate set at least comprises endpoints of a curve forming the character;
The dynamic dividing module is used for dividing the curve between the endpoints contained in the curve coordinate set based on the dynamic step length aiming at the curve coordinate set to obtain a plurality of coordinate points corresponding to the curve coordinate set;
the generating module is used for generating a lattice coordinate set of the font contour curve at least according to a plurality of coordinate points corresponding to the curve coordinate set;
the display module is used for displaying the font outline curve based on the dot matrix coordinate set to obtain rendered target characters;
wherein, the dynamic partitioning module includes:
the first acquisition submodule is used for acquiring first coordinates of a first coordinate point aiming at the curve coordinate set;
a selecting sub-module for selecting a step size from a preset step size range;
the calculation sub-module is used for calculating second coordinates of the second coordinate points according to the step length and a curve formula of a curve between endpoints contained in the curve coordinate set;
the first determining submodule is used for taking the second coordinate point as a coordinate point corresponding to the curve coordinate set when the first coordinate and the second coordinate meet the curve smoothness condition, triggering the obtaining submodule to redetermine the first coordinate point, and triggering the selecting submodule to execute the step of selecting the step from the preset step range until the dividing ending condition is met;
And the selecting submodule is further used for determining the step length again when the first coordinate and the second coordinate do not meet the curve smoothness condition, triggering the calculating submodule to execute the step of calculating the second coordinate of the second coordinate point according to the step length and the curve formula of the curve between the endpoints contained in the curve coordinate set, and the determined step length is smaller than the original step length.
6. The apparatus of claim 5, wherein the apparatus further comprises:
the calculation module is used for calculating the function value of a preset loss function according to the first coordinate and the second coordinate;
the second determining module is used for determining that the first coordinate and the second coordinate do not meet the curve smoothness condition when the function value is larger than a preset threshold value;
and the second determining module is further configured to determine that the first coordinate and the second coordinate satisfy a curve smoothness condition when the function value is not greater than the preset threshold.
7. The apparatus of claim 5, wherein the obtaining submodule is specifically configured to take the second coordinate point as the first coordinate point if the coordinates of the second coordinate point satisfy a curve smoothness condition;
The selecting submodule is specifically configured to take a step length corresponding to the second coordinate point as a lower limit of the step length range, and obtain an updated step length range; and selecting a step size from the updated step size range.
8. The apparatus of claim 5, wherein the apparatus further comprises:
the acquisition module is used for acquiring initial font data of the target characters, wherein the initial font data comprise coordinates in a pixel plane;
and the sub-pixelation processing module is used for carrying out sub-pixelation processing on the initial font data to obtain the font data of the target characters, wherein the coordinates contained in the font data are coordinates in a multidimensional pixel space.
9. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for carrying out the method steps of any one of claims 1-4 when executing a program stored on a memory.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, carries out the method steps according to any of claims 1-4.
CN202010192591.2A 2020-03-18 2020-03-18 Text rendering method and device, electronic equipment and storage medium Active CN111402366B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010192591.2A CN111402366B (en) 2020-03-18 2020-03-18 Text rendering method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010192591.2A CN111402366B (en) 2020-03-18 2020-03-18 Text rendering method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111402366A CN111402366A (en) 2020-07-10
CN111402366B true CN111402366B (en) 2023-06-30

Family

ID=71413484

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010192591.2A Active CN111402366B (en) 2020-03-18 2020-03-18 Text rendering method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111402366B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112528596A (en) * 2020-12-01 2021-03-19 北京达佳互联信息技术有限公司 Rendering method and device for special effect of characters, electronic equipment and storage medium
CN117236280A (en) * 2023-09-13 2023-12-15 北京饼干科技有限公司 Vertical text display method and device

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1038161C (en) * 1993-12-28 1998-04-22 张贻明 Enlargement of characters by sample function curves
JPH08146936A (en) * 1994-11-21 1996-06-07 Fujitsu Ltd Method and device for processing outline font data
JP3474037B2 (en) * 1995-10-12 2003-12-08 シャープ株式会社 Character pattern generator
CN101764945B (en) * 2008-11-04 2013-05-01 新奥特(北京)视频技术有限公司 Subtitle dramatizing method based on closed outline of Bezier
CN103578450B (en) * 2012-07-31 2016-02-03 国民技术股份有限公司 A kind of character display method, character display device and safety certification device
CN104461483A (en) * 2013-09-16 2015-03-25 北大方正集团有限公司 Font rendering method and device, rendering platform client and server

Also Published As

Publication number Publication date
CN111402366A (en) 2020-07-10

Similar Documents

Publication Publication Date Title
CN105741334B (en) Thermodynamic chart providing method and device
CN111402366B (en) Text rendering method and device, electronic equipment and storage medium
JP2010113624A (en) Device and method for drawing bezier curve and program
US10540789B2 (en) Line stylization through graphics processor unit (GPU) textures
WO2013005366A1 (en) Anti-aliasing image generation device and anti-aliasing image generation method
CN114792355B (en) Virtual image generation method and device, electronic equipment and storage medium
CN114820972A (en) Contour line and/or contour surface generation method, system, device and storage medium
CN112785493B (en) Model training method, style migration method, device, equipment and storage medium
CN112562043B (en) Image processing method and device and electronic equipment
CN114241032A (en) Area analysis-based region division method, device, equipment and storage medium
CN110840483B (en) Real-time logarithmic compression method and system for digital ultrasonic diagnostic apparatus
CN111857627A (en) Graphic processing method, apparatus, device and storage medium
US8687011B2 (en) Techniques for efficient sampling for image effects
KR102346329B1 (en) System and method for producing webtoon using three dimensional data
CN115409856A (en) Lung medical image processing method, device, equipment and storage medium
CN114581586A (en) Method and device for generating model substrate, electronic equipment and storage medium
US7656408B1 (en) Method and system for animating a border
CN114359905B (en) Text recognition method and device, electronic equipment and storage medium
US11631220B2 (en) Digital object surface inflation
CN114359903B (en) Text recognition method, device, equipment and storage medium
CN110704609B (en) Text theme visualization method and device based on community membership
CN114581676B (en) Processing method, device and storage medium for feature image
CN114677265A (en) Image processing method, image processing apparatus, electronic device, and storage medium
CN117788482A (en) Rapid selection and cutting method for massive point cloud data
CN114492733A (en) Text detection method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant