Text Emoji Rendering Method, Device, Computer Device and Storage Medium
By obtaining Unicode encoded values and generating rendering data, using path vector points and rendering layer colors for scaling, the problem of text expression scaling deformation and low efficiency is solved, and efficient rendering is achieved.
Patent Information
- Application Number
- CN202111385880.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-22
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2041-11-22
AI Technical Summary
In the prior art, text expressions are prone to deformity when scaling and have large data volumes, resulting in low rendering efficiency.
By obtaining Unicode encoded values, determine whether there is rendering data in memory. If it does not exist, generate and save the rendering data. Use the path vector points and rendering layer colors for scaling, and use the graphics engine to render text expressions.
Improves the rendering efficiency of text expressions and ensures that there is no deformation after scaling.
Smart Images

Figure CN114049409B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the technical field of text rendering, and in particular, to a method, device, computer device and storage medium for rendering text expressions. Background Art
[0002] With the application of text, various text expressions need to be loaded and displayed on various devices. The existing processing method is to build the mapping relationship between Unicode expression codes and corresponding expression pictures. When the terminal receives a Unicode expression code, it displays the picture through the mapping relationship. This display method will cause the displayed text expression to be blurred when the picture is scaled, that is, the text expression will be deformed after scaling; moreover, due to the large number of expressions, the built-in pictures will also lead to a large amount of data and large space occupation, resulting in low rendering efficiency. Summary of the Invention
[0003] The embodiments of the present invention provide a method, device, computer device and storage medium for rendering text expressions, aiming to solve the problems of low rendering efficiency and deformation after scaling of existing text expressions.
[0004] In a first aspect, the embodiments of the present invention provide a method for rendering text expressions, which includes:
[0005] If a preset text expression rendering instruction is received, obtain the Unicode encoding value corresponding to the preset text expression rendering instruction;
[0006] Judge whether there is rendering data corresponding to the Unicode encoding value in the memory, where the rendering data includes path vector points and rendering layer colors;
[0007] If the rendering data exists in the memory, obtain the rendering data from the memory;
[0008] If the rendering data does not exist in the memory, generate the rendering data according to the glyph index corresponding to the Unicode encoding value, and save the generated rendering data to the memory;
[0009] Perform a scaling process on the path vector points, and render and generate a text expression corresponding to the preset text expression rendering instruction through a graphics engine according to the scaled path vector points and the rendering layer colors.
[0010] Further, if a preset start instruction is received, judge whether there is path node information in a preset folder; if the path node information exists in the preset folder, obtain the rendering data from the path node information, and save the rendering data to the memory.
[0011] Further, if the path node information does not exist in the preset folder, obtain a rendering layer through a glyph index corresponding to a preset Unicode data list, and determine the rendering layer color according to the color index in the rendering layer and the color table in the color panel; call a preset path function by executing a drawing method in the HarfBuzz text shaping engine to obtain path vector points; save the rendering layer color and the path vector points to the preset folder and the memory.
[0012] Further, determine whether there is a glyph index corresponding to the Unicode code value in the preset mapping table; if there is a glyph index corresponding to the Unicode code value in the preset mapping table, determine whether layer data can be obtained according to the glyph index; if the layer data can be obtained according to the glyph index, generate the rendering data according to the layer data, and save the rendering data to the memory.
[0013] Further, if there is no glyph index corresponding to the Unicode code value in the preset mapping table or if the layer data cannot be obtained according to the glyph index, issue a prompt for non-text emojis to the user.
[0014] Further, calculate the ratio of the size of the text emoji corresponding to the preset text emoji rendering instruction to the initial size of the text emoji, and use the ratio as the scaling factor of the path vector points; perform a scaling process on the path vector points according to the scaling factor.
[0015] Further, set the brush color in the graphics engine according to the rendering layer color; generate a text emoji corresponding to the preset text emoji rendering instruction according to the brush color, the scaled path vector points, and the canvas rendering in the graphics engine.
[0016] In a second aspect, an embodiment of the present invention further provides a text emoji rendering device, which includes:
[0017] A first obtaining unit, configured to obtain a Unicode code value corresponding to the preset text emoji rendering instruction if a preset text emoji rendering instruction is received;
[0018] A first judging unit, configured to judge whether there is rendering data corresponding to the Unicode code value in the memory, where the rendering data includes path vector points and a rendering layer color;
[0019] A processing unit, configured to, if the rendering data exists in the memory, obtain the rendering data from the memory, and perform a scaling process on the path vector points;
[0020] A first storage unit, configured to generate the rendering data according to a glyph index corresponding to the Unicode code value and store the generated rendering data in the memory if the rendering data does not exist in the memory.
[0021] A generation unit, configured to perform a scaling process on the path vector points, and render, through a graphics engine, a text expression corresponding to the preset text expression rendering instruction according to the scaled path vector points and the rendering layer color.
[0022] In a third aspect, an embodiment of the present invention further provides a computer device, which includes a memory and a processor. A computer program is stored on the memory, and when the processor executes the computer program, the above method is implemented.
[0023] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium. The storage medium stores a computer program, and when the computer program is executed by a processor, the above method can be implemented.
[0024] An embodiment of the present invention provides a method, an apparatus, a computer device, and a storage medium for rendering text expressions. The method includes: if a preset text expression rendering instruction is received, obtaining a Unicode code value corresponding to the preset text expression rendering instruction; determining whether rendering data corresponding to the Unicode code value exists in a memory, where the rendering data includes path vector points and a rendering layer color; if the rendering data exists in the memory, obtaining the rendering data from the memory; if the rendering data does not exist in the memory, generating the rendering data according to a glyph index corresponding to the Unicode code value and storing the generated rendering data in the memory; performing a scaling process on the path vector points, and rendering, through a graphics engine, a text expression corresponding to the preset text expression rendering instruction according to the scaled path vector points and the rendering layer color. The technical solution of the embodiment of the present invention can improve the rendering efficiency of text expressions by storing the rendering data in the memory without generating the rendering data each time; because the path vector points are scaled and then the text expression is generated according to the scaled path vector points and the rendering layer color, the text expression will not be deformed after scaling. Description of the Drawings
[0025] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0026] Figure 1 Schematic flowchart of a text expression rendering method provided by an embodiment of the present invention;
[0027] Figure 2 Schematic sub - flowchart of a text expression rendering method provided by an embodiment of the present invention;
[0028] Figure 3 Schematic sub - flowchart of a text expression rendering method provided by an embodiment of the present invention;
[0029] Figure 4 Schematic flowchart of a text expression rendering method provided by another embodiment of the present invention;
[0030] Figure 5 Schematic block diagram of a text expression rendering device provided by an embodiment of the present invention; and
[0031] Figure 6 Schematic block diagram of a computer device provided by an embodiment of the present invention. Detailed implementation manners
[0032] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0033] It should be understood that when used in this specification and the appended claims, the terms "comprises" and "comprising" indicate the presence of the described features, wholes, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their combinations.
[0034] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in this specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an", and "the" are intended to include the plural forms.
[0035] It should be further understood that the term " / and" as used in this specification of the present invention and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0036] As used in this specification and the appended claims, the term "if" may be construed, depending on the context, as "when" or "once" or "in response to determining" or "in response to detecting". Similarly, the phrase "if determined" or "if [the described condition or event] is detected" may be construed, depending on the context, to mean "once determined" or "in response to determining" or "once [the described condition or event] is detected" or "in response to detecting [the described condition or event]".
[0037] Please refer to Figure 1 , Figure 1 which is a schematic flowchart of the text expression rendering method provided by an embodiment of the present invention. The text expression rendering method of the embodiment of the present invention can be applied to a terminal, such as intelligent terminal devices like smart phones, laptops, desktop computers, notebook computers, etc., and the text expression rendering method is implemented through software installed on the terminal to improve the rendering efficiency of text expressions and remain unchanged after scaling. The following provides a detailed description of the text expression rendering method. As Figure 1 shown, the method includes the following steps S100 - S140.
[0038] S100. If a preset text expression rendering instruction is received, obtain the Unicode code value corresponding to the preset text expression rendering instruction.
[0039] In the embodiment of the present invention, when the user selects a text expression and clicks the send button, the sending of a preset text expression rendering instruction will be triggered. The application program with the text expression receives the preset text expression rendering instruction and obtains the Unicode code value corresponding to the preset text expression rendering instruction. It should be noted that in the embodiment of the present invention, the reason why the application program with the text expression needs to obtain the Unicode code value corresponding to the preset text expression rendering instruction is that each text expression corresponds to a unique Unicode code value, and the text expression can be characterized by the Unicode code value. Understandably, the Unicode code value is, for example, 0x1eb7d.
[0040] S110. Determine whether rendering data corresponding to the Unicode code value exists in the memory, where the rendering data includes path vector points and rendering layer colors.
[0041] In an embodiment of the present invention, after obtaining the Unicode encoding value corresponding to the preset text expression rendering instruction, it is determined whether there is rendering data corresponding to the Unicode encoding value in the memory, where the rendering data includes path vector points and rendering layer colors. It can be understood that the scaling of text is achieved by controlling text vector points, and an expression is a type of text. Therefore, text expressions can be rendered through path vector points and corresponding rendering layer colors, and the text expressions remain unchanged in shape after scaling.
[0042] S120. If the rendering data exists in the memory, obtain the rendering data from the memory.
[0043] S130. If the rendering data does not exist in the memory, generate the rendering data according to the glyph index corresponding to the Unicode encoding value, and save the generated rendering data to the memory.
[0044] In an embodiment of the present invention, it is determined whether there is rendering data corresponding to the Unicode encoding value in the memory. If the rendering data exists in the memory, it indicates that there is no need to generate the rendering data, and the rendering data is directly obtained from the memory. If the rendering data does not exist in the memory, it indicates that the rendering data needs to be generated, and the rendering data is generated according to the glyph index corresponding to the Unicode encoding value, and the generated rendering data is saved to the memory to avoid repeated generation of the rendering data.
[0045] Please refer to Figure 2 , in an embodiment, for example, in an embodiment of the present invention, the step S130 includes the following steps S131 - S134.
[0046] S131. Determine whether there is a glyph index corresponding to the Unicode encoding value in the preset mapping table. If there is a glyph index corresponding to the Unicode encoding value in the preset mapping table, execute step S132; otherwise, execute step S134.
[0047] S132. Determine whether layer data can be obtained according to the glyph index. If the layer data can be obtained according to the glyph index, execute step S133; otherwise, execute step S134.
[0048] S133. Generate the rendering data according to the layer data, and save the rendering data to the memory.
[0049] S134. Send a prompt of non - text expression to the user.
[0050] In an embodiment of the present invention, if the rendering data does not exist in the memory, it indicates that the rendering data needs to be generated. First, it is determined whether there is a glyph index corresponding to the Unicode code value in a preset mapping table, where the preset mapping table can represent the mapping relationship between the Unicode code value and the glyph index. If there is a glyph index corresponding to the Unicode code value in the preset mapping table, it is then determined whether layer data can be obtained according to the glyph index. If the layer data can be obtained according to the glyph index, the rendering data is generated according to the layer data. Specifically, the rendering layer color is determined according to the color panel and color table in the layer data. By executing the drawing method in the HarfBuzz text shaping engine to call a preset path function to obtain path vector points, where the preset path function includes a move point function, a line function, a quadratic Bézier curve function, and a cubic Bézier curve function, the rendering layer color and the path vector points are used as the rendering data, and the rendering data is saved to the memory. Understandably, if there is no glyph index corresponding to the Unicode code value in the preset mapping table or if the layer data cannot be obtained according to the glyph index, a non-text emoji prompt is sent to the user to remind the user to select a text emoji.
[0051] S140. Scale the path vector points, and render a text emoji corresponding to the preset text emoji rendering instruction through a graphics engine according to the scaled path vector points and the rendering layer color.
[0052] In an embodiment of the present invention, after obtaining the rendering data, the path vector points in the rendering data are scaled, and then a text emoji corresponding to the preset text emoji rendering instruction can be rendered through a paintbrush and a canvas in the graphics engine according to the scaled path vector points and the rendering layer color. It should be noted that in an embodiment of the present invention, the graphics engine is a Skia graphics engine. In other embodiments, the graphics engine can also be other graphics engines, such as an OGRE graphics engine, depending on the actual situation.
[0053] Please refer to Figure 3 , in an embodiment, for example, in an embodiment of the present invention, the step S130 includes the following steps S141-S144.
[0054] S141. Calculate the ratio of the size of the text emoji corresponding to the preset text emoji rendering instruction to the initial text emoji size, and use the ratio as the scaling factor of the path vector points.
[0055] S142. Scale the path vector points according to the scaling factor.
[0056] S143. Set the brush color in the graphics engine according to the color of the rendering layer;
[0057] S144. Render and generate a text expression corresponding to the preset text expression rendering instruction according to the brush color, the path vector points after scaling processing, and the canvas in the graphics engine.
[0058] In an embodiment of the present invention, first calculate the ratio of the size of the text expression corresponding to the preset text expression rendering instruction to the size of the initial text expression. For example, the size of the text expression corresponding to the preset text expression rendering instruction is Size1, the size of the initial text expression is Size0, and the ratio is Size1 / Size0. Take this ratio as the scaling factor of the path vector points; after obtaining the scaling factor, perform scaling processing on the path vector points according to the scaling factor; set the brush color in the graphics engine according to the color of the rendering layer; render and generate a text expression corresponding to the preset text expression rendering instruction by successively superimposing multiple layers according to the brush color, the path vector points after scaling processing, and the canvas in the graphics engine. Understandably, since this text expression is generated based on the path vector points after scaling processing, it will not be deformed after scaling.
[0059] Figure 4 It is a schematic flowchart of a text expression rendering method provided for another embodiment of the present invention. As Figure 4 shown, in an embodiment of the present invention, the text expression rendering method of this embodiment includes steps S200 - S290. Among them, steps S200 - S240 are similar to steps S100 - S140 in the above embodiment and will not be elaborated here. The following details the additional steps S250 - S290 in this embodiment.
[0060] S250. If a preset start instruction is received, determine whether there is path node information in the preset folder. If there is path node information in the preset folder, execute step S260; otherwise, execute step S270;
[0061] S260. Obtain the rendering data from the path node information and save the rendering data to the memory;
[0062] S270. Obtain the rendering layer through the glyph index corresponding to the preset Unicode data list, and determine the rendering layer color according to the color index in the rendering layer and the color table in the color panel;
[0063] S280. Call a preset path function to obtain path vector points by executing the drawing method in the HarfBuzz text shaping engine;
[0064] S290. Save the color of the rendering layer and the path vector points to the preset folder and the memory.
[0065] In the embodiment of the present invention, before the application program with text expressions receives the preset text expression rendering instruction, as long as the application program is started, the sending of the preset start instruction can be triggered. The application program receives the preset start instruction, determines whether there is path node information in the preset folder. If there is the path node information in the preset folder, obtain the rendering data from the path node information, and save the rendering data to the memory, where the path node information includes the rendering data and a preset Unicode data list; if there is no such path node information in the preset folder, obtain the rendering layer through the glyph index corresponding to the preset Unicode data list, and determine the color of the rendering layer according to the color index in the rendering layer and the color table in the color panel; obtain the path vector points by executing the drawing method in the HarfBuzz text shaping engine to call the preset path functions, where the preset path functions include a move point function, a line function, a quadratic Bezier curve function, and a cubic Bezier curve function; save the color of the rendering layer and the path vector points to the preset folder and the memory to avoid generating rendering data next time and improve the rendering efficiency of text expressions. It should be noted that before determining whether there is path node information in the preset folder, the expression font is loaded through the HarfBuzz text shaping engine, and the preset path functions are set as callback functions and the initial text expression size is set.
[0066] Figure 5 FIG. is a schematic block diagram of a text expression rendering device 200 provided by an embodiment of the present invention. As Figure 5 shown, corresponding to the above text expression rendering method, the present invention also provides a text expression rendering device 200. The text expression rendering device 200 includes units for executing the above text expression rendering method, and the device can be configured in a terminal. Specifically, please refer to Figure 5 , the text expression rendering device 200 includes a first obtaining unit 201, a first determining unit 202, a processing unit 203, a first saving unit 204, and a generating unit 205.
[0067] Among them, the first acquisition unit 201 is configured to obtain the Unicode encoding value corresponding to the preset text expression rendering instruction if a preset text expression rendering instruction is received; the first judgment unit 202 is configured to judge whether rendering data corresponding to the Unicode encoding value exists in the memory, where the rendering data includes path vector points and rendering layer colors; the processing unit 203 is configured to obtain the rendering data from the memory if the rendering data exists in the memory, and perform a scaling process on the path vector points; the first storage unit 204 is configured to generate the rendering data according to the glyph index corresponding to the Unicode encoding value if the rendering data does not exist in the memory, and save the generated rendering data to the memory; the generation unit 205 is configured to perform a scaling process on the path vector points, and render and generate a text expression corresponding to the preset text expression rendering instruction through a graphics engine according to the scaled path vector points and the rendering layer colors.
[0068] In some embodiments, such as this embodiment, the first storage unit 204 includes a first judgment subunit 2041, a second judgment subunit 2042, a first generation subunit 2043, and a prompt unit 2044.
[0069] Among them, the first judgment subunit 2041 is configured to judge whether a glyph index corresponding to the Unicode encoding value exists in a preset mapping table; the second judgment subunit 2042 is configured to judge whether layer data can be obtained according to the glyph index if a glyph index corresponding to the Unicode encoding value exists in the preset mapping table; the first generation subunit 2043 is configured to generate the rendering data according to the layer data and save the rendering data to the memory if the layer data can be obtained according to the glyph index; the prompt unit 2044 is configured to send a non-text expression prompt to the user if a glyph index corresponding to the Unicode encoding value does not exist in the preset mapping table or if the layer data cannot be obtained according to the glyph index.
[0070] In some embodiments, such as this embodiment, the generation unit 205 includes a calculation unit 2051, a scaling unit 2052, a setting unit 2053, and a second generation subunit 2054.
[0071] Among them, the calculation unit 2051 is configured to calculate the ratio of the size of the text expression corresponding to the preset text expression rendering instruction to the initial size of the text expression, and use the ratio as the scaling factor of the path vector point; the scaling unit 2052 is configured to perform a scaling process on the path vector point according to the scaling factor; the setting unit 2053 is configured to set the brush color in the graphics engine according to the rendering layer color; the second generation subunit 2054 is configured to render and generate a text expression corresponding to the preset text expression rendering instruction according to the brush color, the path vector points after the scaling process, and the canvas in the graphics engine.
[0072] In some embodiments, such as this embodiment, the text expression rendering device 200 further includes a second determination unit 206, a second acquisition unit 207, a third acquisition unit 208, a call unit 2091, and a second storage unit 2092.
[0073] Among them, the second determination unit 206 is configured to determine whether there is path node information in the preset folder if a preset start instruction is received; the second acquisition unit 207 is configured to, if there is the path node information in the preset folder, acquire rendering data from the path node information and save the rendering data to the memory; the third acquisition unit 208 is configured to, if there is no such path node information in the preset folder, acquire a rendering layer through a glyph index corresponding to a preset Unicode data list, and determine a rendering layer color according to a color index in the rendering layer and a color table in the color panel; the call unit 2091 is configured to call a preset path function by executing a drawing method in the HarfBuzz text shaping engine to obtain path vector points; the second storage unit 2092 is configured to save the rendering layer color and the path vector points to the preset folder and the memory.
[0074] The specific implementation manner of the text expression rendering device 200 in the embodiments of the present invention corresponds to the above process verification method, and will not be elaborated herein.
[0075] The above text expression rendering device can be implemented in the form of a computer program, and the computer program can run on a computer device as shown in Figure 6 shown.
[0076] Please refer to Figure 6 , Figure 6 which is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 300 is a terminal, and the terminal can be an electronic device with a communication function such as a smart phone, a desktop computer, a laptop computer, a tablet computer, etc.
[0077] Refer to Figure 6, the computer device 300 includes a processor 302, a memory, and a network interface 305 connected via a system bus 301. Among them, the memory may include a storage medium 303 and an internal memory 304.
[0078] The storage medium 303 can store an operating system 3031 and a computer program 3032. When the computer program 3032 is executed, it can cause the processor 302 to execute a text emoji rendering method.
[0079] The processor 302 is used to provide computing and control capabilities to support the operation of the entire computer device 300.
[0080] The internal memory 304 provides an environment for the operation of the computer program 3032 in the storage medium 303. When the computer program 3032 is executed by the processor 302, it can cause the processor 302 to execute a text emoji rendering method.
[0081] The network interface 305 is used for network communication with other devices. Those skilled in the art can understand that Figure 6 the structure shown in is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device 300 to which the solution of this application is applied. The specific computer device 300 may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.
[0082] Among them, the processor 302 is used to run the computer program 3032 stored in the memory to implement the following steps: if a preset text emoji rendering instruction is received, obtain the Unicode encoding value corresponding to the preset text emoji rendering instruction; determine whether there is rendering data corresponding to the Unicode encoding value in the memory, where the rendering data includes path vector points and rendering layer colors; if the rendering data exists in the memory, obtain the rendering data from the memory; if the rendering data does not exist in the memory, generate the rendering data according to the glyph index corresponding to the Unicode encoding value, and save the generated rendering data to the memory; perform a scaling process on the path vector points, and render through a graphics engine according to the scaled path vector points and the rendering layer colors to generate a text emoji corresponding to the preset text emoji rendering instruction.
[0083] In some embodiments, such as this embodiment, before the processor 302 implements the step of obtaining the Unicode code value corresponding to the preset text emoji rendering instruction if the preset text emoji rendering instruction is received, the specific implementation further includes the following steps: if a preset start instruction is received, determine whether path node information exists in the preset folder; if the path node information exists in the preset folder, obtain the rendering data from the path node information and save the rendering data to the memory.
[0084] In some embodiments, such as this embodiment, after the processor 302 implements the step of determining whether path node information exists in the preset folder, the specific implementation further includes the following steps: if the path node information does not exist in the preset folder, obtain a rendering layer through a glyph index corresponding to a preset Unicode data list, and determine the rendering layer color according to the color index in the rendering layer and the color table in the color panel; call a preset path function by executing a drawing method in the HarfBuzz text shaping engine to obtain path vector points; save the rendering layer color and the path vector points to the preset folder and the memory.
[0085] In some embodiments, such as this embodiment, when the processor 302 implements the step of generating the rendering data according to the glyph index corresponding to the Unicode code value and saving the generated rendering data to the memory, the specific implementation is as follows: determine whether a glyph index corresponding to the Unicode code value exists in the preset mapping table; if a glyph index corresponding to the Unicode code value exists in the preset mapping table, determine whether layer data can be obtained according to the glyph index; if the layer data can be obtained according to the glyph index, generate the rendering data according to the layer data and save the rendering data to the memory; if a glyph index corresponding to the Unicode code value does not exist in the preset mapping table or if the layer data cannot be obtained according to the glyph index, send a non-text emoji prompt to the user.
[0086] In some embodiments, such as this embodiment, when the processor 302 implements the step of scaling the path vector points and rendering a text expression corresponding to the preset text expression rendering instruction through a graphics engine based on the scaled path vector points and the rendering layer color, the specific implementation is as follows: Calculate the ratio of the size of the text expression corresponding to the preset text expression rendering instruction to the initial text expression size, and use the ratio as the scaling factor of the path vector points; Scale the path vector points according to the scaling factor; Set the brush color in the graphics engine according to the rendering layer color; Render a text expression corresponding to the preset text expression rendering instruction based on the brush color, the scaled path vector points, and the canvas in the graphics engine.
[0087] It should be understood that in the embodiments of the present application, the processor 302 may be a central processing unit (CPU), and the processor 302 may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), off-the-shelf programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0088] Those of ordinary skill in the art can understand that all or part of the processes of the methods in the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a storage medium, and the storage medium is a computer-readable storage medium. The computer program is executed by at least one processor in the computer system to implement the process steps of the embodiments of the above methods.
[0089] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program. The computer program is executed by at least one processor in the computer system to implement the process steps of the embodiments of the above text expression rendering method.
[0090] The storage medium may be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, an optical disc, or other various computer-readable storage media that can store program codes.
[0091] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.
[0092] In several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0093] The steps in the method embodiments of the present invention can be adjusted, combined, and deleted according to actual needs. The units in the device embodiments of the present invention can be combined, divided, and deleted according to actual needs. In addition, the functional units in each embodiment of the present invention can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit.
[0094] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, a terminal, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present invention.
[0095] In the above embodiments, the descriptions of each embodiment have their own emphases. For the parts not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0096] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention is also intended to include these changes and modifications.
[0097] As described above, it is only the specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention can easily think of various equivalent modifications or substitutions, and these modifications or substitutions should all be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A method for rendering text expressions, characterized in that Including: If a preset text emoji rendering instruction is received, obtain the Unicode code value corresponding to the preset text emoji rendering instruction; Determine whether rendering data corresponding to the Unicode code value exists in the memory, where the rendering data includes path vector points and rendering layer colors; If the rendering data exists in the memory, obtain the rendering data from the memory; If the rendering data does not exist in the memory, generate the rendering data according to the glyph index corresponding to the Unicode code value, and save the generated rendering data to the memory; Calculate the ratio of the size of the text emoji corresponding to the preset text emoji rendering instruction to the initial text emoji size, and use the ratio as the scaling factor of the path vector points; Perform scaling processing on the path vector points according to the scaling factor; Set the brush color in the graphics engine according to the rendering layer color; Render and generate a text emoji corresponding to the preset text emoji rendering instruction according to the brush color, the scaled path vector points, and the canvas in the graphics engine.
2. The text expression rendering method according to claim 1, wherein Before the step of "If a preset text emoji rendering instruction is received, obtain the Unicode code value corresponding to the preset text emoji rendering instruction", it further includes: If a preset start instruction is received, determine whether path node information exists in a preset folder; If the path node information exists in the preset folder, obtain the rendering data from the path node information and save the rendering data to the memory.
3. The text expression rendering method according to claim 2, wherein After the step of "Determine whether path node information exists in a preset folder", it further includes: If the path node information does not exist in the preset folder, obtain a rendering layer through the glyph index corresponding to a preset Unicode data list, and determine the rendering layer color according to the color index in the rendering layer and the color table in the color panel; Call a preset path function by executing a drawing method in the HarfBuzz text shaping engine to obtain path vector points; Save the rendering layer color and the path vector points to the preset folder and the memory.
4. The text expression rendering method according to claim 1, wherein The step of "Generate the rendering data according to the glyph index corresponding to the Unicode code value, and save the generated rendering data to the memory" includes: Determine whether a glyph index corresponding to the Unicode code value exists in a preset mapping table; If a glyph index corresponding to the Unicode code value exists in the preset mapping table, determine whether layer data can be obtained according to the glyph index; If the layer data can be obtained according to the glyph index, generate the rendering data according to the layer data, and save the rendering data to the memory.
5. The text expression rendering method according to claim 4, wherein After the step of "Determine whether a glyph index corresponding to the Unicode code value exists in a preset mapping table", it further includes: If there is no glyph index corresponding to the Unicode encoding value in the preset mapping table or if the layer data cannot be obtained according to the glyph index, a prompt for non-text emoticons is sent to the user.
6. A text expression rendering device, characterized in that Including: A first acquisition unit, configured to acquire a Unicode encoding value corresponding to the preset text emoticon rendering instruction if a preset text emoticon rendering instruction is received; A first judgment unit, configured to judge whether there is rendering data corresponding to the Unicode encoding value in the memory, where the rendering data includes path vector points and rendering layer colors; A processing unit, configured to acquire the rendering data from the memory if the rendering data exists in the memory, and perform a scaling process on the path vector points; A first saving unit, configured to generate the rendering data according to the glyph index corresponding to the Unicode encoding value if the rendering data does not exist in the memory, and save the generated rendering data to the memory; A calculation unit, configured to calculate a ratio of the size of the text emoticon corresponding to the preset text emoticon rendering instruction to the size of the initial text emoticon, and use the ratio as a scaling factor for the path vector points; A scaling unit, configured to perform a scaling process on the path vector points according to the scaling factor; A setting unit, configured to set a brush color in the graphics engine according to the rendering layer color; A second generation subunit, configured to generate a text emoticon corresponding to the preset text emoticon rendering instruction according to the brush color, the path vector points after the scaling process, and the canvas in the graphics engine for rendering; 7. A computer device, characterized in that, The computer device includes a memory and a processor, and a computer program is stored on the memory. When the processor executes the computer program, the text emoticon rendering method according to any one of claims 1-5 is implemented.
8. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, and when the computer program is executed by a processor, the text emoticon rendering method according to any one of claims 1-5 can be implemented.
Citation Information
Patent Citations
Method and device for rendering characters
CN103186919A
Subtitle rendering method and device, equipment and computer readable storage medium
CN113326677A