CN111402366A - Character rendering method and device, electronic equipment and storage medium - Google Patents

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

Info

Publication number
CN111402366A
CN111402366A CN202010192591.2A CN202010192591A CN111402366A CN 111402366 A CN111402366 A CN 111402366A CN 202010192591 A CN202010192591 A CN 202010192591A CN 111402366 A CN111402366 A CN 111402366A
Authority
CN
China
Prior art keywords
coordinate
curve
step length
coordinates
font data
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.)
Granted
Application number
CN202010192591.2A
Other languages
Chinese (zh)
Other versions
CN111402366B (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

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Controls And Circuits For Display Device (AREA)

Abstract

A character rendering method, a character rendering device, electronic equipment 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 target characters to be rendered, wherein the font data of the target characters at least comprise coordinates of a curve coordinate set, and the curve coordinate set at least comprises an endpoint of a curve forming the characters; aiming at the curve coordinate group, dividing a curve between end points contained in the curve coordinate group based on the dynamic step length to obtain a plurality of coordinate points corresponding to the curve coordinate group; generating a dot matrix coordinate set of the font outline curve at least according to a plurality of coordinate points corresponding to the curve coordinate set; and displaying a font outline curve based on the dot matrix coordinate set to obtain the rendered target characters. By adopting the technical scheme provided by the application, the display of the font outline curve based on the font data can be realized.

Description

Character rendering method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of data processing, and in particular, to a method and an apparatus for rendering text, an electronic device, and a storage medium.
Background
For each character, font data for describing a font outline curve of the character can be stored in the electronic device, wherein the font data comprises coordinates of a plurality of groups of coordinate points, and one group of coordinate points can be an end point forming a straight line, an end point of a Bezier curve and a control point outside the Bezier curve. In order to meet the requirement of clearly displaying characters when rendering characters, the electronic device may generate a plurality of coordinate points constituting a font outline curve based on font data to obtain a dot matrix coordinate set constituting the font outline curve, and then, the electronic device may display the font outline curve based on the dot matrix 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 font outline curve based on font data.
In a first aspect, the present application provides a text rendering method, including:
when a character rendering instruction is received, determining target characters to be rendered, wherein the font data of the target characters at least comprise coordinates of a curve coordinate set, and the curve coordinate set at least comprises an endpoint of a curve forming the characters;
aiming at the curve coordinate group, dividing a curve between end points contained in the curve coordinate group based on the dynamic step length to obtain a plurality of coordinate points corresponding to the curve coordinate group;
generating a dot matrix coordinate set of the font outline curve at least according to a plurality of coordinate points corresponding to the curve coordinate set;
and displaying a font outline curve based on the dot matrix coordinate set to obtain the rendered target characters.
Optionally, the dividing, for the curve coordinate group, a curve between end points included in the curve coordinate group based on the dynamic step length to obtain a plurality of coordinate points corresponding to the curve coordinate group includes:
acquiring a first coordinate of a first coordinate point aiming at the curve coordinate group;
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 contained 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 group, re-determining the first coordinate point, and executing the step of selecting the step length from the preset step length range until the division finishing condition is met;
and if the first coordinate and the second coordinate do not meet the curve smoothness condition, re-determining the step length, and executing the step of calculating the second coordinate of the second coordinate point according to the curve formula and the step length, wherein the re-determined step length is smaller than the original step length.
Optionally, the determining whether the first coordinate and the second coordinate satisfy the 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 the curve smoothness condition;
and if the function value is not larger than the preset threshold value, determining that the first coordinate and the second coordinate meet the curve smoothness condition.
Optionally, if the first coordinate and the second coordinate satisfy the curve smoothness condition, the re-determining the first coordinate point includes:
taking the second coordinate point as a first coordinate point;
the step length is selected from a preset step length range, and the step length selection method 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 the 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 character, wherein the coordinates contained in the initial font data are coordinates in a pixel plane;
and performing sub-pixelation processing on the initial font data to obtain the font data of the target character, wherein the coordinates contained in the font data are the coordinates in a multi-dimensional pixel space.
In a second aspect, the present application further provides a text rendering apparatus, the apparatus comprising:
the system comprises a first determining module, a second determining module and a rendering module, wherein the first determining module is used for determining target characters to be rendered when character rendering instructions are received, the font data of the target characters at least comprise coordinates of a curve coordinate set, and the curve coordinate set at least comprises an endpoint of a curve forming the characters;
the dynamic division module is used for dividing a curve between end points contained in the curve coordinate group based on the dynamic step length aiming at the curve coordinate group to obtain a plurality of coordinate points corresponding to the curve coordinate group;
the generating module is used for generating a dot matrix coordinate set of the font outline 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 characters.
Optionally, the dynamic partitioning module includes:
the first obtaining submodule is used for obtaining a first coordinate of a first coordinate point aiming at the curve coordinate group;
the selection submodule is used for selecting the step length from a preset step length range;
the calculation submodule is used for calculating a second coordinate of a second coordinate point according to the step length and a curve formula of a curve between end points contained in the curve coordinate group;
the first determining submodule is used for taking the second coordinate point as a coordinate point corresponding to the curve coordinate group when the first coordinate and the second coordinate meet the curve smoothness condition, triggering the obtaining submodule to re-determine the first coordinate point, and triggering the selecting submodule to execute the step of selecting the step length from the preset step length range until the dividing finishing condition is met;
and the selection submodule is further used for re-determining the step length when the first coordinate and the second coordinate do not meet the curve smoothness condition, and triggering the calculation submodule to execute the step of calculating the second coordinate of the second coordinate point according to the step length and a curve formula of a curve between endpoints included in the curve coordinate group, wherein the re-determined step length is smaller than the original step length.
Optionally, the apparatus further comprises:
the calculation module is used for calculating a 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;
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 sub-module is specifically configured to take the second coordinate point as the first coordinate point under a condition that the coordinate of the second coordinate point meets a curve smoothness condition;
the selection submodule is specifically used for 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 the step size from the updated step size range.
Optionally, the apparatus further comprises:
the acquisition module is used for acquiring initial font data of the target character, and coordinates contained in the initial font data are coordinates in a pixel plane;
and the sub-pixelation processing module is used for performing sub-pixelation processing on the initial font data to obtain the font data of the target character, wherein the coordinates contained in the font data are the coordinates in a multi-dimensional 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 mutual communication through the communication bus;
a memory for storing a computer program;
a processor adapted to perform the method steps of any of the first aspects when executing a program stored in the memory.
In a fourth aspect, the present application further provides a computer-readable storage medium having stored therein instructions, which when run on a computer, cause the computer to perform any 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 text rendering methods described above.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages:
the method provided by the embodiment of the application can determine the target characters to be rendered when the character rendering instruction is received, wherein the font data of the target characters at least comprise coordinates of a curve coordinate set, and the curve coordinate set at least comprises an endpoint of a curve forming the characters; aiming at a curve coordinate group, dividing a curve between end points contained in the curve coordinate group based on a dynamic step length to obtain a plurality of coordinate points corresponding to the curve coordinate group; generating a dot matrix coordinate set of the font outline 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 characters.
Because the curves between the end points contained in the curve coordinate set are divided based on the dynamic step length, the font outline curve displayed based on the dot matrix coordinate set is closer to the real outline curve of the characters, and the font outline curve can be displayed based on 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 present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
Fig. 1 is a flowchart of a text rendering method according to an embodiment of the present application;
fig. 2a is a diagram of a text rendering effect according to an embodiment of the present application;
fig. 2b is a diagram of another text rendering effect provided in the embodiment of the present application;
FIG. 3 is a flow chart of another method for rendering text according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a target curve provided by an embodiment of the present application;
fig. 5 is a schematic structural diagram of a text rendering apparatus 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
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in 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 obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
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 can be a mobile phone, a tablet computer, a notebook computer, a wearable electronic equipment and the like.
In the related art, a font may have multiple representations, such as normal, italic, bold, etc., and the electronic device may display text in multiple fonts and multiple representations. By adopting the character rendering method provided by the embodiment of the application, characters with different fonts and different expression forms can be rendered.
Optionally, with the text rendering method provided in this embodiment of the present application, text displayed in an application program at a mobile terminal may be rendered, and text displayed in an application program at a PC (Personal Computer) terminal may also be rendered.
A detailed description will be given below of a text rendering method provided in an embodiment of the present application with reference to a specific implementation manner, as shown in fig. 1, 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 character at least comprises coordinates of a curve coordinate set, and the curve coordinate set at least comprises an endpoint of a curve forming the character.
In implementation, when an artistic font needs to be rendered, a user may perform a text rendering operation to enable the electronic device to receive a text rendering instruction, where the text rendering operation may be to click an icon representing a certain font in a state where a text to be rendered is selected; 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 may determine the text to be rendered in multiple ways, for example, the text rendering instruction may carry a text identifier, and the electronic device may use the text corresponding to the text identifier carried by the text rendering instruction as the text to be rendered; in a state where a certain font mode is selected, the electronic device may 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 pre-stored correspondence between the text and the font data. The glyph data of 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 "soil", and the glyph data may include coordinates of a set of rectilinear coordinates; the character to be rendered is flying, and the font data can comprise coordinates of a linear coordinate set and coordinates of a curve 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 character to be rendered, whether the font data of the character includes coordinates of a curve coordinate set, and if the font data of the character includes coordinates of the curve coordinate set, the electronic device may use the character as a target character.
If the font data of the character does not contain the coordinates of the curve coordinate set, the font data of the character only contains the coordinates of the linear coordinate set, and the electronic equipment can directly display the character based on the coordinates of the linear coordinate set, so that character rendering is realized. Alternatively, the electronic device may divide a straight line between two end points included in the straight line coordinate group, and display the text based on coordinates of coordinate points obtained by the division, thereby implementing text rendering.
In this embodiment of the application, the font datum may include a category identifier of a coordinate group, and the electronic device may determine that a certain coordinate group is a linear coordinate group or a curved coordinate group according to the category identifier of the certain coordinate group.
Optionally, the electronic device may store font data of characters with multiple fonts in advance, and the electronic device may determine the font after the characters are rendered, that is, determine the target font. Then, the electronic device may determine glyph data of the text to be rendered among the glyph data of the target font.
The electronic equipment can also perform coordinate transformation on coordinates contained in the font data according to a preset reduction proportion or amplification proportion after the font data are obtained, and perform character rendering based on the font data after the coordinate transformation so as to reduce or amplify the rendered characters to the set font size.
Step 102, aiming at a curve coordinate set, dividing a curve between end points 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.
In implementation, for a curve coordinate set included in the font data of the target text, the electronic device may divide a curve between endpoints included in the curve coordinate set based on the dynamic step size to obtain a plurality of coordinate points corresponding to the curve coordinate set. In a case where the font datum 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 the curve coordinate set is referred to as a target curve. The embodiment of the present application further provides an implementation manner for dividing a target curve based on a dynamic step length to obtain a plurality of coordinate points corresponding to a 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 the coordinates of the end points, the curve formula, and the dynamic step length to obtain a plurality of coordinate points. The specific processing procedure will be described in detail later.
And 103, generating a lattice coordinate set of the font outline curve at least according to a plurality of coordinate points corresponding to the curve coordinate set.
In 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 constituting a straight line included in the linear coordinate set as combination elements of the coordinate set to obtain a dot matrix coordinate set of the font outline curve.
Alternatively, the electronic device may divide a straight line between end points included in the linear coordinate group with respect to the linear coordinate group to obtain a plurality of coordinate points corresponding to the linear coordinate group. Then, the electronic device may use the coordinates of the plurality of coordinate points corresponding to the curved coordinate set and the coordinates of the plurality of coordinate points corresponding to the linear coordinate set as combination elements of the coordinate set to obtain a lattice coordinate set of the glyph contour curve.
If the font data of the character to be rendered only includes the coordinates of the curve coordinate set, the electronic device may use the coordinates of the plurality of coordinate points corresponding to the curve coordinate set as a combination element of the coordinate set to obtain a dot matrix coordinate set of the font outline curve.
And 104, displaying the font outline curve based on the dot matrix coordinate set to obtain the rendered target characters.
In implementation, the electronic device may determine, in the preset display interface, a plurality of coordinate points forming a font outline curve according to coordinates included in the dot matrix coordinate set, connect the plurality of coordinate points, and generate the font outline curve, thereby obtaining the rendered target text.
In a feasible implementation manner, the electronic device may assemble each coordinate point in the dot matrix coordinate set into a primitive, perform texture mapping and rasterization on the primitive, and perform anti-aliasing on a result of the rasterization to obtain a rendered target character. The specific processing procedure may refer to processing procedures of primitive assembling, texture mapping processing, rasterization processing, and anti-aliasing processing in the related art, and details are not described here.
As shown in fig. 2a, which is a text rendering effect diagram obtained by rendering text in the related art, it can be seen that the font edge in the image area identified by 210 is not smooth enough, and the text rendering effect is poor. And 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 obviously smoother, and the text rendering effect is good.
In the embodiment of the application, the electronic device can determine the target characters to be rendered when receiving the character rendering instruction, the font data of the target characters at least comprise coordinates of a curve coordinate set, and the curve coordinate set at least comprises end points of curves forming the characters; aiming at a curve coordinate group, dividing a curve between end points contained in the curve coordinate group based on a dynamic step length to obtain a plurality of coordinate points corresponding to the curve coordinate group; generating a dot matrix coordinate set of the font outline 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 characters.
Because the curves between the end points contained in the curve coordinate set are divided based on the dynamic step length, the font outline curve displayed based on the dot matrix coordinate set is closer to the real outline curve of the characters, and the font outline curve can be displayed based on font data.
Optionally, an embodiment of the present application provides an implementation manner that a curve between endpoints included in a curve coordinate set is divided based on a dynamic step size to obtain a plurality of coordinate points corresponding to the curve coordinate set, as shown in fig. 3, the implementation manner includes:
step 301, obtaining a first coordinate of a first coordinate point for a curve coordinate set.
In implementation, for each curve coordinate set included in the font data of the text to be rendered, the electronic device may select an end point from two end points included in the curve coordinate set as an initial end point, use the initial end point as a first coordinate point, and use the coordinate of the initial end point as the first coordinate.
In the curve dividing process, in addition to the initial end point, the electronic device may also select a coordinate point from coordinate points corresponding to the determined curve coordinate group, use the selected coordinate point as a first coordinate point, and use the coordinate of the selected coordinate point as a first coordinate, which will be described in detail later in the specific processing process.
For example, the coordinates included in the curved-line coordinate set are the coordinates of two endpoints B0 and B1, and the coordinates of the control point C, the electronic device may take the endpoint B0 as the first coordinate point and the coordinates of B0 as the first coordinates. For convenience of description, a curve between end points included in the curve coordinate set is referred to as a target curve. Fig. 4 is a schematic diagram of a target curve provided in the embodiment of the present application.
Step 302, selecting a step size from a preset step size range.
Wherein, a step range can be preset in the electronic device, and the step range can be expressed as 0, stepmax],stepmaxThe value can be 0.99, and developers can change the step range according to needs.
In practice, the electronic device may randomly select a value from the range of step sizes as the step size.
Step 303, calculating a second coordinate of the second coordinate point according to the step length and a curve formula of a curve between endpoints included in the curve coordinate set.
In implementations, the electronic device may determine a curve formula describing the target curve, and then the electronic device may calculate the second coordinates of the second coordinate points according to the step size, the curve formula.
In this embodiment of the application, the bezier curve used for describing the font profile 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 the coordinate 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, thereby determining the curve formula of the target curve. The specific processing procedure may refer to any one of coordinates and curve formulas based on a plurality of coordinate points constituting a curve in the related art, and the processing procedure for determining the curve type is not described herein again.
Optionally, a curve formula of the n-th order bezier curve is shown in formula (1):
Figure BDA0002416447510000101
where t represents the step size, n and PiRepresenting a glyph data parameter, i ∈ [0, n]。
First coordinates of the first coordinate point
Figure BDA0002416447510000102
Can be represented as B (t)i),tiMay represent a step size of the first coordinate point with respect to an initial endpoint, and when the first coordinate point is the initial endpoint, tiMay take the value 0. The step size selected from the range of step sizes is
Figure BDA0002416447510000111
The electronic device can select the step length
Figure BDA0002416447510000112
And (1) calculating a second coordinate of the second coordinate point to obtain
Figure BDA0002416447510000113
That is to say
Figure BDA0002416447510000114
And step 304, judging whether the first coordinate and the second coordinate meet 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 length is improperly selected, and if the second coordinate is used as a coordinate point corresponding to the curve coordinate set and the font outline curve is displayed based on the coordinate point corresponding to the curve coordinate set, a problem that a font edge is not smooth may occur. Therefore, in this case, the electronic device may execute step 305 to reselect the step size and redetermine the second coordinate point.
If the first coordinate and the second coordinate satisfy the curve smoothness condition, it indicates that the step length is properly selected, and if the second coordinate point is taken as the 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 closer to the true contour curve of the text, so in this case, the electronic device may execute step 306 to determine whether the division end condition of the target curve is satisfied.
The following will describe in detail a specific processing procedure of the electronic device for determining whether the first coordinate and the second coordinate satisfy the curve smoothness condition.
Step 305, the step size is re-determined.
And the redetermined step length is smaller than the original step length.
In an implementation, the electronic device may re-determine the step size in a plurality of ways, and in a possible implementation, the electronic device may randomly select a value smaller than the original step size from the range of step sizes as the re-determined step size. In another possible implementation manner, the electronic device may calculate the new step length according to the original step length and a preset step length selection formula.
Then, the electronic device may calculate the second coordinate of the second coordinate point according to the curve formula and the re-determined step length, and determine whether the first coordinate and the second coordinate satisfy the curve smoothness condition, that is, the electronic device returns to perform step 303.
Alternatively, the step size selection formula may be
Figure BDA0002416447510000115
Wherein the content of the first and second substances,
Figure BDA0002416447510000116
is the original step length, tiIs the step size of the first coordinate point relative to the initial endpoint.
E.g. original step size
Figure BDA0002416447510000121
Is 0.6, tiAt 0, the step size to be re-determined may be 0.3.
In the embodiment of the application, 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 aiming at each first coordinate point, so that the step length between each first coordinate point and the second coordinate point corresponding to the first coordinate point is different, and curve division based on the dynamic step length is realized.
And step 306, taking the second coordinate point as a coordinate point corresponding to the curve coordinate group, and judging whether the division ending condition is met.
The dividing end condition may be that the number of coordinate points corresponding to the curve coordinate group reaches a preset number threshold, or 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 the number of coordinate points corresponding to the curve coordinate group reaches a preset number threshold, or that the step length corresponding to the currently determined second coordinate point reaches a preset step length threshold
Figure BDA0002416447510000122
In an implementation, the electronic device may store the second coordinates of the curved coordinate set and the second coordinate point in correspondence with the second coordinate point as the coordinate point corresponding to the curved coordinate set. Then, the electronic apparatus may determine whether the division end condition is satisfied.
If the division end condition is met, the font outline curve displayed based on the coordinate points corresponding to the curve coordinate group is smooth and is close to the real outline curve of the characters, and the electronic equipment can not perform subsequent division processing aiming at the target curve.
If the division end condition is not satisfied, it indicates that the glyph 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 determined again.
In implementation, the electronic device may determine the first coordinate point again in various ways, and in a 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 a step length corresponding to the second coordinate point as a 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 use the second coordinate point B2 as the first coordinate point, and set the lower limit of the step size range to 0.3 corresponding to the second coordinate point B2, 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, the step size may be used to measure how far and how close the second coordinate point is relative to 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 another 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 length selected from the updated step length range is ensured to be larger than the step length corresponding to the previous second coordinate point, and the effect that the current second coordinate point is far away from the initial end point and is close to the other end point on the target curve compared with the previous second coordinate point is achieved.
Furthermore, the second coordinate points can be sequentially determined according to the direction from the initial endpoint to the other endpoint of the target curve in the process of dynamically dividing 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 application, the electronic device may obtain, for each curved coordinate group, a first coordinate of the first coordinate point, and select a step length from a preset step length range, and then, the electronic device may calculate a second coordinate of the second coordinate point according to the curved formula and the step length, and then determine whether the first coordinate and the second coordinate satisfy the curved 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 group, re-determine the first coordinate point, and execute the step of selecting the step length from the preset step length range until the division finishing 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 a step of calculating a 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 EM algorithm (maximum Expectation algorithm) and the dynamic step length, the target curve can be divided based on the dynamic step length. Specifically, the electronic device repeatedly selects the step length from the step length range for each first coordinate point until the second coordinate of the second coordinate point determined according to the selected step length and the first coordinate of the first coordinate point meet the curve smoothness condition, and uses the second coordinate point meeting the curve smoothness condition as the coordinate point corresponding to the curve coordinate group. Therefore, the subsequent character shape contour curve which is smooth and is closer to the real contour curve of the character can be displayed on the basis of the coordinate points corresponding to the curve coordinate group, and the character rendering effect can be improved.
Alternatively, the developer finds: the smoothness of the curve can be measured by using the function value of the preset loss function, and the curve is smoother the smaller the function value is. 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 the following steps:
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 a 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 the function value of the predetermined loss function, B (t)i) And
Figure BDA0002416447510000142
a first coordinate representing a first coordinate point,
Figure BDA0002416447510000143
a second coordinate representing a second coordinate point calculated based on the curve formula and the step size,
Figure BDA0002416447510000144
representing a step size of
Figure BDA0002416447510000145
The desired coordinates of the second coordinate point. Q represents a curve smoothnessThe smaller the Q value is, the smoother the refined curve is, and in the embodiment of the application, the value of Q can be 0.8.
And 2, judging whether the function value is larger than a preset threshold value.
Wherein the preset threshold may be 0.01.
In an implementation, the electronic device may determine whether the function value is greater than a preset threshold. If the function value is larger than the preset threshold value, 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, the electronic device may calculate a function value of the 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 greater than the preset threshold, the electronic device may determine that the first coordinate and the second coordinate satisfy the curve smoothness condition, and when the function value is not greater than the preset threshold, the electronic device may determine that the first coordinate and the second coordinate do not satisfy the curve smoothness condition. The smoothness degree of the curve is measured based on the function value of the preset loss function, and when the function value of the preset loss function is not larger than the preset threshold value, the first coordinate and the second coordinate are determined to meet the curve smoothness condition, so that the font profile curve displayed based on the second coordinate point is smoother and closer to the real profile curve of the character, 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 glyph data in the case where coordinates belong to a pixel plane is referred to as initial glyph data. That is, normally, the font data acquired by the electronic device is the initial font data.
After determining the font data of the target character according to the corresponding relationship between the characters and the font data, that is, after determining the initial font data of the target character, the electronic device may directly use the initial font data as the font data of the target character. In order to improve the character rendering efficiency and the character rendering precision, the electronic device may perform sub-pixelation on the initial font data, and use the font data obtained after sub-pixelation as the font data of the target character.
The embodiment of the application provides an implementation mode for performing sub-pixelation processing on initial font data to obtain font data, which comprises the following steps of:
step 1, obtaining initial font data of a target character.
Wherein the initial glyph data includes coordinates in the pixel plane.
In implementation, after receiving the text rendering instruction, the electronic device may determine font data of the target text according to a pre-stored correspondence between the text and the font data, that is, determine initial font data of the target text.
And 2, performing sub-pixelation processing on the initial font data to obtain the font data of the target character.
Wherein the font datum comprises coordinates in a 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 glyph data according to a preset coordinate conversion manner to obtain coordinates of the coordinate point after the coordinate conversion, and thus, the electronic device may determine the coordinates of the plurality of coordinate points included in the initial glyph data in the multi-dimensional pixel space.
The electronic device may then take the coordinates of the plurality of coordinate points in the multi-dimensional pixel space as glyph data for the target text.
In the embodiment of the present 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 curve coordinate set are determined directly based on the initial glyph data, i.e., calculation is performed directly based on coordinates in the pixel plane, the calculation accuracy is 0.5 pixels. After coordinate conversion is carried out on the coordinates in the pixel plane contained in the initial font data, namely sub-pixelation processing is carried out on the initial font data, the calculation precision can be improved to 0.5/N pixels. In this embodiment, the value of N may be 64, and two directions, i.e., a vertical direction and a horizontal direction, may be selected to perform sub-pixelation processing.
In the embodiment of the application, the electronic device can acquire the initial font data of the target character, and then perform sub-pixelation processing on the initial font data to obtain the font data of the target character. Since the initial font data is subjected to sub-pixelation processing, floating point type calculation can be converted into shaping calculation, so that the calculation speed can be increased, and the character rendering efficiency can be improved. Further, by converting the coordinates in the pixel plane included in the initial font datum into coordinates in the multi-dimensional pixel space, the calculation accuracy can be improved.
Optionally, after the dot matrix coordinate set is determined, the electronic device may further map the coordinates belonging to the multi-dimensional 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 present application further provides a text rendering apparatus, as shown in fig. 5, the apparatus includes:
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 at least includes coordinates of a curve coordinate set, and the curve coordinate set at least includes an endpoint of a curve that constitutes the text;
a dynamic division module 520, configured to divide a curve between endpoints included in the curve coordinate group based on a dynamic step size for the curve coordinate group, so as to obtain a plurality of coordinate points corresponding to the curve coordinate group;
a generating module 530, configured to generate a lattice coordinate set of the glyph contour 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 a font outline curve based on the dot matrix coordinate set, so as to obtain a rendered target character.
Optionally, the dynamic partitioning module includes:
the first obtaining submodule is used for obtaining a first coordinate of a first coordinate point aiming at the curve coordinate group;
the selection submodule is used for selecting the step length from a preset step length range;
the calculation submodule is used for calculating a second coordinate of a second coordinate point according to the step length and a curve formula of a curve between end points contained in the curve coordinate group;
the first determining submodule is used for taking the second coordinate point as a coordinate point corresponding to the curve coordinate group when the first coordinate and the second coordinate meet the curve smoothness condition, triggering the obtaining submodule to re-determine the first coordinate point, and triggering the selecting submodule to execute the step of selecting the step length from the preset step length range until the dividing finishing condition is met;
and the selection submodule is further used for re-determining the step length when the first coordinate and the second coordinate do not meet the curve smoothness condition, and triggering the calculation submodule to execute the step of calculating the second coordinate of the second coordinate point according to the step length and a curve formula of a curve between endpoints included in the curve coordinate group, wherein the re-determined step length is smaller than the original step length.
Optionally, the apparatus further comprises:
the calculation module is used for calculating a 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;
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 sub-module is specifically configured to take the second coordinate point as the first coordinate point under a condition that the coordinate of the second coordinate point meets a curve smoothness condition;
the selection submodule is specifically used for 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 the step size from the updated step size range.
Optionally, the apparatus further comprises:
the acquisition module is used for acquiring initial font data of the target character, and coordinates contained in the initial font data are coordinates in a pixel plane;
and the sub-pixelation processing module is used for performing sub-pixelation processing on the initial font data to obtain the font data of the target character, wherein the coordinates contained in the font data are the coordinates in a multi-dimensional pixel space.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages:
the device provided by the embodiment of the application can determine the target characters to be rendered when a character rendering instruction is received, wherein the font data of the target characters at least comprise coordinates of a curve coordinate set, and the curve coordinate set at least comprises an endpoint of a curve forming the characters; aiming at a curve coordinate group, dividing a curve between end points contained in the curve coordinate group based on a dynamic step length to obtain a plurality of coordinate points corresponding to the curve coordinate group; generating a dot matrix coordinate set of the font outline 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 characters.
Because the curves between the end points contained in the curve coordinate set are divided based on the dynamic step length, the font outline curve displayed based on the dot matrix coordinate set is closer to the real outline curve of the characters, and the font outline curve can be displayed based on font data.
The embodiment of the present application further provides an electronic device, as shown in fig. 6, which includes 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 complete mutual communication through the communication bus 604,
a memory 603 for storing a computer program;
the processor 601 is configured to implement the following steps when executing the program stored in the memory 603:
when a character rendering instruction is received, acquiring target characters to be rendered, wherein the font data of the target characters at least comprise coordinates of a curve coordinate set, and the curve coordinate set at least comprises an endpoint of a curve forming the characters;
aiming at the curve coordinate group, dividing a curve between end points contained in the curve coordinate group based on the dynamic step length to obtain a plurality of coordinate points corresponding to the curve coordinate group;
generating a dot matrix coordinate set of the font outline curve at least according to a plurality of coordinate points corresponding to the curve coordinate set;
and displaying a font outline curve based on the dot matrix coordinate set to obtain the rendered target characters.
Optionally, the dividing, for the curve coordinate group, a curve between end points included in the curve coordinate group based on the dynamic step length to obtain a plurality of coordinate points corresponding to the curve coordinate group includes:
acquiring a first coordinate of a first coordinate point aiming at the curve coordinate group;
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 contained 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 group, re-determining the first coordinate point, and executing the step of selecting the step length from the preset step length range until the division finishing condition is met;
and if the first coordinate and the second coordinate do not meet the curve smoothness condition, re-determining the step length, and executing the step of calculating the second coordinate of the second coordinate point according to the curve formula and the step length, wherein the re-determined step length is smaller than the original step length.
Optionally, the determining whether the first coordinate and the second coordinate satisfy the 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 the curve smoothness condition;
and if the function value is not larger than the preset threshold value, determining that the first coordinate and the second coordinate meet the curve smoothness condition.
Optionally, if the first coordinate and the second coordinate satisfy the curve smoothness condition, the re-determining the first coordinate point includes:
taking the second coordinate point as a first coordinate point;
the step length is selected from a preset step length range, and the step length selection method 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 the 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 character, wherein the coordinates contained in the initial font data are coordinates in a pixel plane;
and performing sub-pixelation processing on the initial font data to obtain the font data of the target character, wherein the coordinates contained in the font data are the coordinates in a multi-dimensional pixel space.
The communication bus mentioned in the above terminal may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the terminal and other equipment.
The Memory may include a Random Access Memory (RAM) or a 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 processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages:
the electronic equipment provided by the embodiment of the application can determine the target characters to be rendered when receiving the character rendering instruction, wherein the font data of the target characters at least comprise coordinates of a curve coordinate set, and the curve coordinate set at least comprises an endpoint of a curve forming the characters; aiming at a curve coordinate group, dividing a curve between end points contained in the curve coordinate group based on a dynamic step length to obtain a plurality of coordinate points corresponding to the curve coordinate group; generating a dot matrix coordinate set of the font outline 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 characters.
Because the curves between the end points contained in the curve coordinate set are divided based on the dynamic step length, the font outline curve displayed based on the dot matrix coordinate set is closer to the real outline curve of the characters, and the font outline curve can be displayed based on font data.
In yet another embodiment provided by the present application, a computer-readable storage medium is further provided, which has instructions stored therein, and when the instructions are executed on a computer, the instructions cause the computer to execute the text rendering method according to any one of the above embodiments.
In yet another embodiment provided by the present application, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the text rendering method of any of the above embodiments.
The computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, e.g., from one website site, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DS L)) or wireless (e.g., infrared, wireless, microwave, etc.) manner to another website site, computer, server, or data center.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be 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. Also, 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 an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present invention, which enable those skilled in the art to understand or practice the present 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 (12)

1. A method of text rendering, the method comprising:
when a character rendering instruction is received, determining target characters to be rendered, wherein the font data of the target characters at least comprise coordinates of a curve coordinate set, and the curve coordinate set at least comprises an endpoint of a curve forming the characters;
aiming at the curve coordinate group, dividing a curve between end points contained in the curve coordinate group based on the dynamic step length to obtain a plurality of coordinate points corresponding to the curve coordinate group;
generating a dot matrix coordinate set of the font outline curve at least according to a plurality of coordinate points corresponding to the curve coordinate set;
and displaying a font outline curve based on the dot matrix coordinate set to obtain the rendered target characters.
2. The method according to claim 1, wherein the dividing a curve between end points included in the curve coordinate set based on the dynamic step size for the curve coordinate set to obtain a plurality of coordinate points corresponding to the curve coordinate set comprises:
acquiring a first coordinate of a first coordinate point aiming at the curve coordinate group;
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 contained 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 group, re-determining the first coordinate point, and executing the step of selecting the step length from the preset step length range until the division finishing condition is met;
and if the first coordinate and the second coordinate do not meet the curve smoothness condition, re-determining the step length, and executing the step of calculating the second coordinate of the second coordinate point according to the curve formula and the step length, wherein the re-determined step length is smaller than the original step length.
3. The method of claim 2, 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 the curve smoothness condition;
and if the function value is not larger than the preset threshold value, determining that the first coordinate and the second coordinate meet the curve smoothness condition.
4. The method of claim 2, wherein said re-determining the first coordinate point if the first and second coordinates satisfy the curve smoothness condition comprises:
taking the second coordinate point as a first coordinate point;
the step length is selected from a preset step length range, and the step length selection method 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 the step size from the updated step size range.
5. The method of claim 1, wherein after determining the target text to be rendered, further comprising:
acquiring initial font data of the target character, wherein the coordinates contained in the initial font data are coordinates in a pixel plane;
and performing sub-pixelation processing on the initial font data to obtain the font data of the target character, wherein the coordinates contained in the font data are the coordinates in a multi-dimensional pixel space.
6. A text rendering apparatus, the apparatus comprising:
the system comprises a first determining module, a second determining module and a rendering module, wherein the first determining module is used for determining target characters to be rendered when character rendering instructions are received, the font data of the target characters at least comprise coordinates of a curve coordinate set, and the curve coordinate set at least comprises an endpoint of a curve forming the characters;
the dynamic division module is used for dividing a curve between end points contained in the curve coordinate group based on the dynamic step length aiming at the curve coordinate group to obtain a plurality of coordinate points corresponding to the curve coordinate group;
the generating module is used for generating a dot matrix coordinate set of the font outline 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 characters.
7. The apparatus of claim 6, wherein the dynamic partitioning module comprises:
the first obtaining submodule is used for obtaining a first coordinate of a first coordinate point aiming at the curve coordinate group;
the selection submodule is used for selecting the step length from a preset step length range;
the calculation submodule is used for calculating a second coordinate of a second coordinate point according to the step length and a curve formula of a curve between end points contained in the curve coordinate group;
the first determining submodule is used for taking the second coordinate point as a coordinate point corresponding to the curve coordinate group when the first coordinate and the second coordinate meet the curve smoothness condition, triggering the obtaining submodule to re-determine the first coordinate point, and triggering the selecting submodule to execute the step of selecting the step length from the preset step length range until the dividing finishing condition is met;
and the selection submodule is further used for re-determining the step length when the first coordinate and the second coordinate do not meet the curve smoothness condition, and triggering the calculation submodule to execute the step of calculating the second coordinate of the second coordinate point according to the step length and a curve formula of a curve between endpoints included in the curve coordinate group, wherein the re-determined step length is smaller than the original step length.
8. The apparatus of claim 7, further comprising:
the calculation module is used for calculating a 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;
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.
9. The apparatus according to claim 7, wherein the obtaining sub-module is specifically configured to take the second coordinate point as the first coordinate point on the condition that the coordinates of the second coordinate point satisfy a curve smoothness condition;
the selection submodule is specifically used for 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 the step size from the updated step size range.
10. The apparatus of claim 6, further comprising:
the acquisition module is used for acquiring initial font data of the target character, and coordinates contained in the initial font data are coordinates in a pixel plane;
and the sub-pixelation processing module is used for performing sub-pixelation processing on the initial font data to obtain the font data of the target character, wherein the coordinates contained in the font data are the coordinates in a multi-dimensional pixel space.
11. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any one of claims 1 to 5 when executing a program stored in the memory.
12. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method steps of any one of claims 1 to 5.
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 true CN111402366A (en) 2020-07-10
CN111402366B 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)

Cited By (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

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1104790A (en) * 1993-12-28 1995-07-05 张贻明 Enlargement of characters by sample function curves
US5898439A (en) * 1994-11-21 1999-04-27 Fujitsu Limited Method and apparatus for drawing characters which draws curved segments based on approximate points
US5959635A (en) * 1995-10-12 1999-09-28 Sharp Kabushiki Kaisha Character pattern generator
CN101764945A (en) * 2008-11-04 2010-06-30 新奥特(北京)视频技术有限公司 Subtitle dramatizing method based on closed outline of Bezier
CN103578450A (en) * 2012-07-31 2014-02-12 国民技术股份有限公司 Character display method, character display device and safety authentication device
CN104461483A (en) * 2013-09-16 2015-03-25 北大方正集团有限公司 Font rendering method and device, rendering platform client and server

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1104790A (en) * 1993-12-28 1995-07-05 张贻明 Enlargement of characters by sample function curves
US5898439A (en) * 1994-11-21 1999-04-27 Fujitsu Limited Method and apparatus for drawing characters which draws curved segments based on approximate points
US5959635A (en) * 1995-10-12 1999-09-28 Sharp Kabushiki Kaisha Character pattern generator
CN101764945A (en) * 2008-11-04 2010-06-30 新奥特(北京)视频技术有限公司 Subtitle dramatizing method based on closed outline of Bezier
CN103578450A (en) * 2012-07-31 2014-02-12 国民技术股份有限公司 Character display method, character display device and safety authentication device
CN104461483A (en) * 2013-09-16 2015-03-25 北大方正集团有限公司 Font rendering method and device, rendering platform client and server

Cited By (3)

* 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
CN117236280B (en) * 2023-09-13 2024-05-24 北京饼干科技有限公司 Vertical text display method and device

Also Published As

Publication number Publication date
CN111402366B (en) 2023-06-30

Similar Documents

Publication Publication Date Title
CN112288665B (en) Image fusion method and device, storage medium and electronic equipment
CN111950056B (en) BIM display method and related equipment for building informatization model
CN112785493B (en) Model training method, style migration method, device, equipment and storage medium
CN111402366B (en) Text rendering method and device, electronic equipment and storage medium
CN114612600B (en) Virtual image generation method and device, electronic equipment and storage medium
CN110363837B (en) Method and device for processing texture image in game, electronic equipment and storage medium
US10970892B2 (en) Electronic apparatus for drawing figure based on function data stored in advance or based on drawing data received from server depending on type of figure to be drawn, and information processing method, system, and medium for same
CN106469138B (en) Word cloud generation method and device
CN111523531A (en) Word processing method and device, electronic equipment and computer readable storage medium
CN112562043B (en) Image processing method and device and electronic equipment
CN113204296B (en) Method, device and equipment for highlighting graphics primitive and storage medium
CN112132941B (en) Text rendering method, device, equipment and storage medium
US11461874B2 (en) Graphics processing using matrices of transformations
US10922863B2 (en) Systems and methods for efficiently generating and modifying an outline of electronic text
CN107977923B (en) Image processing method, image processing device, electronic equipment and computer readable storage medium
US10885685B2 (en) Electronic apparatus for drawing graphs of mathematical expressions
JP2009122998A (en) Method for extracting outline from solid/surface model, and computer software program
CN114820908B (en) Virtual image generation method and device, electronic equipment and storage medium
CN110704609B (en) Text theme visualization method and device based on community membership
CN117911578B (en) Text rendering method and device, computer equipment and storage medium
JP4834642B2 (en) Graphic change device, graphic change method, computer program, and recording medium
CN114677265A (en) Image processing method, image processing apparatus, electronic device, and storage medium
US20230078041A1 (en) Method of displaying animation, electronic device and storage medium
CN109324797B (en) Desktop icon generation method, computer readable storage medium and terminal equipment
CN111611782B (en) Connection point generation method and device

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