Text rendering method and device, equipment, medium and product

By rendering text on the server, the increase in rendering time caused by client rendering method is solved, and a more efficient rendering process and faster rendering time is achieved.

CN119514490APending Publication Date: 2025-02-25TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202311084537.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-25
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

The client rendering method may experience an increase in rendering time during web page loading and rendering, resulting in delay in the overall rendering process.

Method used

By rendering text on the server, obtaining rendering requests, generating rendering parameters, determining the layout of text in the target canvas, and rendering text using rendering methods, reducing the steps of client requesting data.

Benefits of technology

It realizes a more efficient text rendering process, shortens rendering time, makes full use of the computing resources on the server, and renders text through various rendering methods, further reducing rendering time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119514490A_ABST
    Figure CN119514490A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a text rendering method and device, equipment, a medium and a product, and the method is applied to a server side and comprises the steps that a rendering request for a to-be-rendered text is acquired, and the rendering request comprises a text demand and an effect demand; generating rendering parameters of the to-be-rendered text based on the text demand and the effect demand; obtaining a target canvas for displaying the to-be-rendered text, and determining the layout of the to-be-rendered text in the target canvas according to the rendering parameters; and rendering the to-be-rendered text by using at least one rendering mode in the target canvas according to the layout. According to the technical scheme provided by the embodiment of the invention, the rendering time consumption is reduced while ensuring that the presentation of the rendering text in the canvas is consistent with the expectation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a text rendering method, a text rendering device, an electronic device, a computer-readable storage medium, and a computer program product. Background Art

[0002] In the process of presenting page content, the rendering method commonly used is client-side rendering; this rendering method requires the browser to start the browser process, load and display the page content. Specifically, the browser first opens the requested page, then establishes multiple request connections to request the required data from the server; this data is processed and rendered locally, and finally presented on the client's browser interface.

[0003] However, this client-side rendering method may increase the rendering time during the web page loading and rendering process. In the process of establishing a request connection and requesting data, a certain amount of network delay and data transmission time will be introduced, resulting in a delay in the overall rendering process. Summary of the Invention

[0004] Embodiments of the present application provide a text rendering method, a text rendering device, an electronic device, a computer-readable storage medium, and a computer program product, which reduce rendering time while ensuring that the presentation of rendered text on a canvas is consistent with expectations.

[0005] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by practice of the present application.

[0006] According to one aspect of an embodiment of the present application, a text rendering method is provided, comprising: obtaining a rendering request for text to be rendered, the rendering request including text requirements and effect requirements; generating rendering parameters for the text to be rendered based on the text requirements and the effect requirements; obtaining a target canvas for displaying the text to be rendered, and determining a layout of the text to be rendered in the target canvas based on the rendering parameters; and rendering the text to be rendered in the target canvas using at least one rendering method based on the layout.

[0007] According to one aspect of an embodiment of the present application, a text rendering device is provided, comprising: an acquisition module for acquiring a rendering request for a text to be rendered, the rendering request including a text requirement and an effect requirement; a generation module for generating rendering parameters for the text to be rendered based on the text requirement and the effect requirement; a determination module for acquiring a target canvas for displaying the text to be rendered, and determining a layout of the text to be rendered in the target canvas based on the rendering parameters; and a rendering module for rendering the text to be rendered in the target canvas using at least one rendering method based on the layout.

[0008] In one embodiment of the present application, the layout includes the position and display content of the text to be rendered in the target canvas; the rendering module is further used to obtain the visualization area of ​​the target canvas and the background information corresponding to the visualization area; determine the visualization content of the text to be rendered based on the position and display content of the text to be rendered in the target canvas and the visualization area, and the visualization content is used to represent the content displayed in the visualization area; render the visualization area based on the background information corresponding to the visualization area and the visualization content of the text to be rendered, so as to render the visualization content of the text to be rendered into the visualization area.

[0009] In one embodiment of the present application, the rendering module is further used to determine the bounding box of the text to be rendered based on the position and display content of the text to be rendered in the target canvas; compare the bounding box with the visualization area to determine the overlapping area between the bounding box and the visualization area; and determine the visualization content based on the display content of the text to be rendered in the overlapping area.

[0010] In one embodiment of the present application, the layout includes the position, display content and area size of the text to be rendered in the target canvas; the rendering module is further used to obtain a local rendering area in the target canvas and background information corresponding to the local rendering area based on the position and area size of the text to be rendered in the target canvas; other areas in the target canvas except the local rendering area are used as non-rendering areas; the local rendering area is rendered based on the background information corresponding to the local rendering area and the display content of the text to be rendered to obtain a target area; the target area and the non-rendering area are synthesized to obtain a rendering result for the rendering request.

[0011] In one embodiment of the present application, the rendering module is further used to obtain a size relationship between the local rendering area and the canvas area corresponding to the target canvas; if the size relationship satisfies a preset relationship, the local rendering area is rendered based on the background information corresponding to the local rendering area and the display content of the text to be rendered to obtain the target area.

[0012] In one embodiment of the present application, the layout includes the position and display content of the text to be rendered in multiple target canvases; the rendering module is further used to determine the current sequence frame to be rendered based on the position and display content of the text to be rendered in the current target canvas, and the background information corresponding to the current target canvas; if the current sequence frame to be rendered is different from the previous sequence frame to be rendered, the current sequence frame to be rendered and the previous sequence frame to be rendered are stored; if the current sequence frame to be rendered is the same as the previous sequence frame to be rendered, the current sequence frame to be rendered and the previous sequence frame to be rendered are both used as pause frames; the stored sequence frames to be rendered are rendered to obtain dynamic frames, and a pause frame is extracted, and the extracted pause frame is rendered to obtain a static frame; the static frame is reused, and the reused static frame and the dynamic frame are synthesized according to the sequence of frames to obtain a rendering result for the rendering request.

[0013] In one embodiment of the present application, the rendering module is further used to calculate the similarity between the rendering content of the current sequence frame to be rendered and the rendering content of the previous sequence frame to be rendered, and determine whether the current sequence frame to be rendered is the same as the previous sequence frame to be rendered based on the similarity; or, obtain the frame time corresponding to the current sequence frame to be rendered and the previous sequence frame to be rendered respectively; if the obtained frame time falls within a preset frame time range, it is determined that the current sequence frame to be rendered is the same as the previous sequence frame to be rendered, wherein the preset frame time range is determined based on the rendering parameters.

[0014] In one embodiment of the present application, the text requirements include font requirements and text content requirements; the generation module is further used to search for target font resources corresponding to the font requirements based on a locally stored font library, and determine the text parameters of the text to be rendered based on the target font resources and the text content requirements; determine the effect parameters corresponding to the effect requirements based on the art effect library used on the client; and generate rendering parameters of the text to be rendered based on the text parameters and the effect parameters.

[0015] In one embodiment of the present application, the device also includes a preloading module for preloading preset basic font resources; when the server is started, a custom font configuration is obtained, and the custom font resources corresponding to the custom font configuration are preloaded; and the font library is generated based on the preloaded basic font resources and the custom font resources.

[0016] In one embodiment of the present application, the generation module is further used to search whether the target font resource exists in the font library during the operation of the server; if the target font resource does not exist in the font library, obtain configuration information corresponding to the target font resource; update a pre-established font dictionary according to the configuration information, and the font dictionary is used to maintain the mapping relationship between font names; preload the target font resource according to the configuration information and the updated font dictionary to update the target font resource to the font library, and search for the target font resource based on the updated font library.

[0017] In one embodiment of the present application, the device also includes a construction module for constructing a rendering interceptor, which is used to verify the key information in the rendering request and record the rendering request to a log file after the key information is verified; if it is determined based on the log file that there is a historical request that is the same as the rendering request, the rendering result corresponding to the historical request is obtained, and the rendering result is used as the rendering result of the rendering request.

[0018] In one embodiment of the present application, the device also includes a recording module for recording the link status of the rendering request to a request log, and recording the rendering process of the text to be rendered to a rendering log; assigning a unique identifier to the request log and the rendering log, and associating the request log and the rendering log according to the unique identifier to form a log file for the rendering request.

[0019] According to one aspect of an embodiment of the present application, an embodiment of the present application provides an electronic device, comprising one or more processors; a storage device for storing one or more computer programs, which, when executed by the one or more processors, enables the electronic device to implement the text rendering method as described above.

[0020] According to one aspect of an embodiment of the present application, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor of an electronic device, the electronic device executes the text rendering method as described above.

[0021] According to one aspect of an embodiment of the present application, an embodiment of the present application provides a computer program product, including a computer program, wherein the computer program is stored in a computer-readable storage medium, and a processor of an electronic device reads and executes the computer program from the computer-readable storage medium, so that the electronic device performs the text rendering method as described above.

[0022] In the technical solution provided in the embodiments of the present application, a more efficient text rendering process is achieved by rendering on the server side, wherein the server side obtains a rendering request for the text to be rendered, which includes text requirements and effect requirements. Based on these requirements, the server side generates precise rendering parameters suitable for the text to be rendered to ensure that the rendered text meets the expected appearance effect. The server side then obtains a target canvas for displaying the text to be rendered, and determines the layout of the text to be rendered in the target canvas based on the rendering parameters to ensure that the presentation of the text in the canvas is consistent with the expectations of the request. Finally, based on the layout in the target canvas, at least one rendering method is used to render the text to be rendered; that is, in the embodiments of the present application, not only is part of the rendering work transferred from the client to the server side, reducing the steps of the client requesting data, thereby shortening the rendering time, but the computing resources of the server side can also be fully utilized to render the text to be rendered through multiple rendering methods, further reducing the rendering time.

[0023] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 It is a schematic diagram of an implementation environment involved in this application;

[0025] Figure 2 is a flowchart of a text rendering method shown in an exemplary embodiment of the present application;

[0026] Figure 3 is a schematic diagram of another text rendering method shown in an exemplary embodiment of the present application;

[0027] Figure 4 is a schematic diagram of visualization area rendering shown in an exemplary embodiment of the present application;

[0028] Figure 5 is a flowchart of another text rendering method shown in an exemplary embodiment of the present application;

[0029] Figure 6 is a flowchart of another text rendering method shown in an exemplary embodiment of the present application;

[0030] Figure 7is a schematic diagram of local area rendering shown in an exemplary embodiment of the present application;

[0031] Figure 8 is a flowchart of another text rendering method shown in an exemplary embodiment of the present application;

[0032] Figure 9 is a flowchart of another text rendering method shown in an exemplary embodiment of the present application;

[0033] Figure 10 is a flowchart of another text rendering method shown in an exemplary embodiment of the present application;

[0034] Figure 11 is a flowchart of another text rendering method shown in an exemplary embodiment of the present application;

[0035] Figure 12 is a flowchart of a text rendering method shown in another exemplary embodiment of the present application;

[0036] Figure 13 is a flowchart of another text rendering method shown in another exemplary embodiment of the present application;

[0037] Figure 14 is a flowchart of another text rendering method shown in another exemplary embodiment of the present application;

[0038] Figure 15 is a flowchart of another text rendering method shown in another exemplary embodiment of the present application;

[0039] Figure 16 is a schematic diagram of a server framework shown in another exemplary embodiment of the present application;

[0040] Figure 17 is a flowchart of a text rendering method shown in another exemplary embodiment of the present application;

[0041] Figure 18-a This is a schematic diagram illustrating an exemplary embodiment of the present application for generating a rendering request;

[0042] Figure 18-b is another schematic diagram of generating a rendering request according to an exemplary embodiment of the present application;

[0043] Figure 19 is a schematic diagram of a framework of an interceptor shown in another exemplary embodiment of the present application;

[0044] Figure 20 is a schematic diagram of a log file framework shown in another exemplary embodiment of the present application;

[0045] Figure 21 is a flowchart of a font module shown in another exemplary embodiment of the present application;

[0046] Figure 22 is a schematic diagram of a static canvas and dynamic artistic words shown in another exemplary embodiment of the present application;

[0047] Figure 23 is a schematic diagram of a rendering area shown in another exemplary embodiment of the present application;

[0048] Figure 24 is a schematic diagram of a partial rendering process shown in another exemplary embodiment of the present application;

[0049] Figure 25 is a schematic diagram of an image frame of a pause animation shown in another exemplary embodiment of the present application;

[0050] Figure 26 is a structural block diagram of a text rendering device shown in an exemplary embodiment of the present application;

[0051] Figure 27 A schematic diagram of the structure of a computer system suitable for implementing an electronic device according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0052] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. When the following description refers to the drawings, identical numerals in different figures represent identical or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.

[0053] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically separate entities. That is, these functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0054] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, while others may be combined or partially combined. Therefore, the actual execution order may vary depending on the actual situation.

[0055] It should also be noted that the term "plurality" used in this application refers to two or more. "And / or" describes the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, or B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.

[0056] The following is a detailed description of the technical solutions of the embodiments of the present application in conjunction with the implementation environment:

[0057] See also Figure 1 , Figure 1 1 is a schematic diagram of an implementation environment involved in this application, which includes a terminal 10, a server 20 and a network 30.

[0058] The terminal 10 is configured to generate a rendering request. The terminal 10 may generate a rendering request for text to be rendered based on an instruction of an object. The rendering request includes text requirements and effect requirements.

[0059] The server 20 is used to perform text rendering. The server obtains a rendering request sent by the terminal and generates rendering parameters for the text to be rendered based on the text requirements and effect requirements. Then, the server obtains a target canvas for displaying the text to be rendered, and determines the layout of the text to be rendered in the target canvas based on the rendering parameters. Finally, based on the layout, the server renders the text to be rendered in the target canvas using at least one rendering method.

[0060] It should be noted that in the embodiment of the present application, text with artistic effects is rendered through server-side rendering, and the rendering results are sent to the terminal, so that the terminal can directly display the rendering results without waiting for data loading and rendering.

[0061] Among them, the aforementioned terminal 10 can be any electronic device that can display content, such as a smart phone, a tablet, a laptop, a computer, an intelligent voice interaction device, a smart home appliance, a terminal specifically used in a vehicle, an aircraft, etc. The server 20 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network) and basic cloud computing services such as big data and intelligent platforms. This is not restricted here.

[0062] The terminal 10 and the server 20 establish a communication connection in advance through the network 30, so that the terminal 10 and the server 20 can communicate with each other through the network 30. The network 30 can be a wired network or a wireless network, which is not limited here.

[0063] It should be noted that in the specific implementation of this application, the text to be rendered is related to the user object. When the embodiment of this application is applied to a specific product or technology, it is necessary to obtain permission or consent from the user object, and the collection, use and processing of relevant data need to comply with the relevant laws and standards of the relevant countries and regions.

[0064] The following describes in detail the various implementation details of the technical solutions of the embodiments of the present application:

[0065] like Figure 2 As shown, Figure 2 This is a flowchart of a text rendering method shown in an embodiment of the present application, which can be applied to Figure 1 In the implementation environment shown, the method may be executed by a server. The text rendering method may include steps S210 to S240, which are described in detail as follows:

[0066] S210: Obtain a rendering request for the text to be rendered, where the rendering request includes text requirements and effect requirements.

[0067] In an embodiment of the present application, the server can obtain the rendering request through the terminal, that is, the terminal generates a rendering request in response to the operation of the object and sends the rendering request to the server; the server can also directly receive the rendering request triggered by the object.

[0068] The text to be rendered is text with artistic effects, which can be configured by the server or customized by the object. Text, as a written form of language information, can cover words, sentences, paragraphs, or even larger chapters. For example, the text to be rendered may include text effects with different styles and themes. These texts are specific writing symbols, characters, or sets of symbols that constitute the text. Through the arrangement and combination of texts with different styles and themes, the text presents an artistic effect.

[0069] In an embodiment of the present application, the selection request for the text to be rendered includes text requirements and effect requirements, wherein the text to be rendered may be one or more, which is not limited here. The text requirement includes at least one of the text content requirement of the text to be rendered and the text style requirement, and the text content requirement can reflect the text content of the text to be rendered; in one example, the text content of the text to be rendered may be the text content pre-configured by the server, such as if the text content of the text to be rendered is "ABB", the text content requirement may be the unique identifier corresponding to "ABB". In another example, the text content of the text to be rendered may be determined by the object, that is, the object customizes what text content to render, for example, if the text content of the text to be rendered is "ABC" customized by the object, then the text content requirement may directly be "ABC". The text style requirement may be a font requirement, including conventional "Songti", "Kaishu", etc., or a customized font, and also includes font size.

[0070] In an embodiment of the present application, the effect requirement can reflect the text effect of the text to be rendered, such as beautiful and personalized font style, color, shadow, etc. Of course, the text effect can be one or more text effects pre-configured by the server, or it can be a text effect customized by the object.

[0071] S220: Generate rendering parameters for the text to be rendered based on the text requirements and effect requirements.

[0072] In the embodiment of the present application, the rendering parameters of the text to be rendered refer to all parameters required to render the text to be rendered, including parameters related to the text to be rendered, and may also include relevant parameters of the renderer in the server.

[0073] In one example, the text parameters of the text to be rendered can be determined based on the text requirements, and the effect parameters of the text to be rendered can be determined based on the effect requirements, and then the rendering parameters are generated by combining the text parameters and the effect parameters, or the rendering parameters are generated by combining the text parameters, effect parameters and renderer parameters.

[0074] S230: Obtain a target canvas for displaying the text to be rendered, and determine a layout of the text to be rendered in the target canvas according to rendering parameters.

[0075] It is understandable that the text to be rendered needs to be rendered to the target canvas and displayed through the target canvas. Therefore, it is necessary to first obtain the target canvas. The target canvas can be pre-set by the server or set by the object; wherein, the size of the target canvas can be fixed or flexibly adjusted according to the size of the display area of ​​the terminal.

[0076] In an embodiment of the present application, the target canvas may include background information of the text to be rendered. The background information may be a common background for any text to be rendered, such as a white background. The background information may also be determined based on the display scene of the text to be rendered. The rendering request then also includes the display scene of the text to be rendered, and the server determines the background information based on the display scene. If the background information is an image with image content, the server may generate a target canvas based on the background information.

[0077] Since the target canvas displays the text to be rendered, that is, the text to be rendered needs to be in the target canvas before it can be displayed, it is necessary to first determine the layout of the text to be rendered in the target canvas based on the rendering parameters, and then determine the text to be rendered displayed on the target canvas through the layout.

[0078] The layout of the text to be rendered in the target canvas includes at least one of the position, content, area size, arrangement mode, and animation mode of the text to be rendered in the target canvas. The arrangement mode includes horizontal and vertical arrangement, and the animation mode includes but is not limited to scaling, rotation, flying in, etc.

[0079] S240: Render the text to be rendered in the target canvas using at least one rendering method according to the layout.

[0080] In an embodiment of the present application, at least one rendering method for the text to be rendered can be determined based on the layout, and then the text to be rendered is rendered in the target canvas based on the at least one rendering method. If at least two rendering methods are determined, the text to be rendered can be rendered using both rendering methods simultaneously. For example, if the text to be rendered is text with an animation effect, then during rendering, each sequence of image frames needs to be rendered, and finally the rendered frames are synthesized to form an animation effect. Therefore, multiple sequence of image frames to be rendered can be rendered simultaneously using at least two rendering methods. For another example, when there are multiple texts to be rendered, the multiple texts to be rendered can be rendered simultaneously using at least two rendering methods.

[0081] In an embodiment of the present application, after rendering the text to be rendered, a rendering result for the rendering request is obtained, and the rendering result can be sent to the client for direct display.

[0082] In an embodiment of the present application, a more efficient text rendering process is achieved by rendering on the server side, wherein the server side obtains a rendering request for the text to be rendered, which includes text requirements and effect requirements. Based on these requirements, the server side generates precise rendering parameters suitable for the text to be rendered to ensure that the rendered text meets the expected appearance effect. The server side then obtains a target canvas for displaying the text to be rendered, and determines the layout of the text to be rendered in the target canvas based on the rendering parameters to ensure that the presentation of the text in the canvas is consistent with the expectations of the request. Finally, based on the layout in the target canvas, at least one rendering method is used to render the text to be rendered; that is, in an embodiment of the present application, not only is part of the rendering work transferred from the client side to the server side, reducing the steps of the client requesting data, thereby shortening the rendering time, but the computing resources of the server side can also be fully utilized to render the text to be rendered through multiple rendering methods, further reducing the rendering time.

[0083] In one embodiment of the present application, another text rendering method is provided, which can be applied to Figure 1 In the implementation environment shown, the method can be executed by the server, such as Figure 3 As shown, the text rendering method is Figure 2 Based on S210~S240 shown in Figure 2 Step S240 shown in FIG is expanded into steps S310 to S330; wherein, the layout of the text to be rendered in the target canvas includes the position of the text to be rendered in the target canvas and the display content, and the display content includes the displayed text content and effect content; steps S310 to S330 are described in detail as follows:

[0084] S310: Acquire a visualization area of ​​a target canvas and background information corresponding to the visualization area.

[0085] In an embodiment of the present application, the visualization area of ​​the target canvas is the area where the display area can be displayed and the object is visible; in one example, the area of ​​the visualization area can be equal to the area of ​​the target canvas, that is, the visualization area is the same as the target canvas; in another example, the area of ​​the visualization area can be smaller than the area of ​​the target canvas, for example, the visualization area is all areas except the border of the target canvas; of course, the size of the visualization area can be flexibly adjusted according to actual conditions.

[0086] It is worth noting that the visualization area in the embodiment of the present application corresponds to background information. The background information is for the entire visualization area, and it can be a blank background or a background with specific information.

[0087] S320: Determine the visualization content of the text to be rendered according to the position and display content of the text to be rendered in the target canvas and the visualization area, where the visualization content is used to represent the content displayed in the visualization area.

[0088] In an embodiment of the present application, the display content of the text to be rendered that falls within the visualization area can be determined based on the position of the text to be rendered in the target canvas and the visualization area, and the display content that falls within the visualization area is used as the visualization content of the text to be rendered. The visualization content is used to represent the content displayed in the visualization area, that is, the content that can be finally presented on the display.

[0089] In one example, based on the display content of the text to be rendered in the target canvas, the area of ​​the region corresponding to the text to be rendered can be preliminarily determined, and then combined with the position, the area and position of the text to be rendered in the target canvas can be determined, and then compared with the area and position of the visualization area to determine whether the display content of the text to be rendered falls within the visualization area.

[0090] S330: Render the visualization area based on the background information corresponding to the visualization area and the visualization content of the text to be rendered, so as to render the visualization content of the text to be rendered into the visualization area.

[0091] In an embodiment of the present application, the server performs global rendering on the visualization area, that is, it renders the background and the visualization content of the text to be rendered in the visualization area; wherein, after clearing the visualization area, the background of the visualization area is rendered based on the background information corresponding to the visualization area, and then the visualization content is rendered in the visualization area after the background is rendered; or after clearing the visualization area, the background and visualization content of the visualization area are rendered at the same time.

[0092] If the display content of the text to be rendered includes content that exceeds the visualization area, there is no need to render the exceeding content.

[0093] like Figure 4 As shown, the target canvas 410 includes a visualization area 411, and the display content 420 of the text to be rendered partially falls within the visualization area 411. When rendering, only the visualization content 421 is rendered, that is, "abc" is rendered without rendering "xyz" which is not in the visualization area.

[0094] It should be noted that Figure 3 For more details on steps S210 to S230, see Figure 2 Steps S210 to S230 are not described in detail here.

[0095] In an embodiment of the present application, the visual content of the text to be rendered is determined based on the position and display content of the text to be rendered in the target canvas, as well as the visual area, and then only the visual content is rendered within the visual area. This can avoid unnecessary rendering of some invisible text, reduce the rendering workload and overhead, and thus improve rendering efficiency.

[0096] The present invention provides another text rendering method, which can be applied to Figure 1 In the implementation environment shown, the method can be executed by the server, such as Figure 5 As shown, the text rendering method is Figure 3 Based on the basis shown in Figure 3 The step S320 shown in FIG is expanded into steps S510 to S530.

[0097] Steps S510 to S530 are described in detail as follows:

[0098] S510: Determine a bounding box of the text to be rendered based on the position and display content of the text to be rendered in the target canvas.

[0099] In an embodiment of the present application, the size and position of the bounding box of the text to be rendered can be determined based on the position of the text to be rendered in the target canvas and the display content. The size of the bounding box is the minimum rectangle that surrounds the display content of the text to be rendered. It can be understood that, under the premise of a unified font size, the size of the bounding box is different based on the different display content. For example, the bounding box of the display content "A" is larger than the bounding box of the display content "a"; the position of the bounding box is the position of the text to be rendered, where the size of the bounding box can be expressed as the width and height of the matrix, and then the area of ​​the bounding box can be determined; the position of the bounding box can be expressed as the coordinates of the upper left corner of the position of the text to be rendered.

[0100] S520: Compare the bounding box with the visualization area to determine an overlapping area between the bounding box and the visualization area.

[0101] S530: Determine the visual content according to the display content of the text to be rendered in the overlapping area.

[0102] In an embodiment of the present application, the area and position of the bounding box can be compared with the area and position of the visualization area to determine the overlapping area between the bounding box and the visualization area. Specifically, when the overlap between the bounding box and the visualization area is determined based on the position of the bounding box and the position of the visualization area, the overlapping area is determined based on the area of ​​the bounding box and the area of ​​the visualization area. If the overlapping area is less than a preset area threshold, the overlapping area can be ignored, i.e., it is deemed that the bounding box and the visualization area do not contain an overlapping area. Only if the overlapping area is greater than the preset area threshold is the visualization content determined.

[0103] In one example, at least a portion of the display content of the text to be rendered is within the overlapping area, and the display content of the text to be rendered within the overlapping area can be directly used as the visual content.

[0104] In another example, after determining the display content of the text to be rendered in the overlapping area, it is determined whether the proportion of the displayed content to the total content of the text to be rendered is greater than a preset proportion. If it is greater than the preset proportion, the display content in the overlapping area is used as visualization content to avoid wasting resources caused by rendering only too little content.

[0105] It should be noted that Figure 5 For a detailed description of steps S210 to S230, S310, and S330, see Figure 3 Steps S210 to S230, S310, and S330 are shown and will not be described in detail here.

[0106] In an embodiment of the present application, the bounding box of the text to be rendered is determined based on the position of the text to be rendered in the target canvas and the display content, and then the overlapping area between the bounding box and the visualization area is determined, so that the display content in the overlapping area is used as the visualization content, thereby ensuring the accuracy of the determination of the visualization content.

[0107] The present invention also provides another text rendering method, which can be applied to Figure 1 In the implementation environment shown, the method can be executed by the server, such as Figure 6 As shown, in Figure 2 Based on the basis shown in Figure 2 The step S240 shown in FIG is expanded into steps S610 to S640. The layout of the text to be rendered in the target canvas includes the position of the text to be rendered in the target canvas, the displayed content, and the size of the area occupied. Steps S610 to S640 are described in detail as follows:

[0108] S610: Acquire a local rendering area in the target canvas and background information corresponding to the local rendering area according to the position of the text to be rendered in the target canvas and the size of the area occupied by the text.

[0109] In an embodiment of the present application, the size of the area occupied by the text to be rendered in the target canvas can be the size of the bounding box of the text to be rendered. The position and size of the local rendering area in the target canvas can be determined based on the position of the text to be rendered in the target canvas and the size of the area occupied by the text to be rendered. The size of the layout rendering area matches the size of the area occupied by the text to be rendered in the target canvas, that is, the size of the layout rendering area is greater than or equal to the size of the area occupied by the text to be rendered in the target canvas. Background information corresponding to the local rendering area is specific to the local rendering area, that is, partial background information in the target canvas.

[0110] S620: Use other areas of the target canvas except the local rendering area as non-rendering areas.

[0111] It is understood that the size of the local rendering area should be smaller than the size of the target canvas. Therefore, the area of ​​the target canvas other than the local rendering area is treated as a non-rendering area. This non-rendering area includes corresponding background information. The background information corresponding to this non-rendering area and the background information corresponding to the local rendering area are combined to form a complete background information of the target canvas. Since this non-rendering area does not include any text to be rendered, it does not need to be rendered.

[0112] S630: Render the local rendering area based on background information corresponding to the local rendering area and display content of the text to be rendered to obtain a target area.

[0113] In an embodiment of the present application, the server performs partial rendering on the target canvas, that is, rendering only the local rendering area, rendering the background and the displayed content of the text to be rendered in the local rendering area. This can be done by clearing the local rendering area and then simultaneously rendering the background of the local rendering area and the displayed content of the text to be rendered in the local rendering area to obtain the target area, which includes the rendered text and background.

[0114] S640: Synthesize the target area and the non-rendering area to obtain a rendering result for the rendering request.

[0115] As described above, the non-rendering area includes corresponding background information, and the non-rendering area does not include the text to be rendered. The target area and the non-rendering area can be synthesized to obtain a rendering result in which the text to be rendered is rendered in a target canvas.

[0116] like Figure 7As shown, the local rendering area 711 and the non-rendering area 712 are determined according to the position of the text to be rendered in the target canvas 710 and the size of the area occupied. The non-rendering area 712 includes background information. When rendering is performed, only the local rendering area 711 is rendered to render the text "Abcxyz", the bold font effect and the background information into the local rendering area 711.

[0117] It should be noted that Figure 6 For more details on steps S210 to S230, see Figure 2 Steps S210 to S230 shown in FIG will not be described in detail here.

[0118] In an embodiment of the present application, a local rendering area in the target canvas is obtained based on the position of the text to be rendered in the target canvas and the size of the area occupied, and then the local rendering area is rendered only based on the display content and the corresponding background information. This can ensure text rendering while avoiding rendering all content, reducing the rendering workload and overhead, thereby improving rendering efficiency.

[0119] In one embodiment of the present application, another text rendering method is provided, which can be applied to Figure 1 In the implementation environment shown, the method can be executed by the server, such as Figure 8 As shown, the text rendering method is Figure 6 Based on the basis shown in Figure 6 The step S630 shown in FIG is expanded to S810 to S820. The steps S810 to S820 are described in detail as follows:

[0120] S810: Obtain a size relationship between the local rendering area and a canvas area corresponding to the target canvas.

[0121] Although the size of the local rendering area should be smaller than the size in the target canvas, if the local rendering area is only slightly smaller than the target canvas, it means that the difference between local drawing and global drawing is not much. Therefore, in an embodiment of the present application, the size relationship between the local rendering area and the canvas area corresponding to the target canvas is obtained, and whether to perform local drawing is determined based on the size relationship; wherein, the size of the local rendering area is compared with the canvas area corresponding to the target canvas.

[0122] S820: If the size relationship satisfies a preset relationship, the local rendering area is rendered based on background information corresponding to the local rendering area and the display content of the text to be rendered to obtain a target area.

[0123] In an embodiment of the present application, the preset relationship includes a local rendering area being smaller than a preset proportion of the canvas area corresponding to the target canvas, wherein the preset proportion can be flexibly adjusted according to actual conditions, that is, if the local rendering area is smaller than the preset proportion of the canvas area corresponding to the target canvas, local rendering is performed.

[0124] In other embodiments of the present application, if the local rendering area is larger than the preset proportion of the canvas area corresponding to the target canvas, global rendering is performed, and there is no need to distinguish between the local rendering area and the non-rendering area, and the display content of the text to be rendered is directly rendered into the target canvas; it can be understood that when global rendering is performed, there is no need to perform synthesis after partial rendering, and rendering can be completed more quickly.

[0125] In one example, when performing global rendering, the text to be rendered is directly rendered on the background of the target canvas without clearing the target canvas.

[0126] It should be noted that Figure 8 For more detailed information on steps S210 to S230, S610 to S620, and S640, see Figure 6 Steps S210 to S230, S610 to S620, and S640 are shown and will not be described in detail here.

[0127] In an embodiment of the present application, local rendering is performed only when the size relationship between the local rendering area and the canvas area corresponding to the target canvas meets a preset relationship, so as to avoid the situation where the local rendering area is large and the local rendering consumes more rendering workload than the global rendering.

[0128] It is worth noting that, in one embodiment of the present application, another text rendering method is provided, which can be applied to Figure 1 In the implementation environment shown, the method can be executed by the server, such as Figure 9 As shown, the text rendering method is Figure 2 Based on the above, step S240 is expanded to S910-S940. The layout of the text to be rendered in the target canvas includes the position and display content of the text to be rendered in multiple target canvases. That is, the text to be rendered includes an animation effect. The layout includes the position and display content of the text to be rendered in each sequence frame. Sequence frame refers to a technology for generating dynamic text effects. It decomposes an animation into multiple static images and plays them in a certain order and speed to form a dynamic effect. Steps S910-S940 are described in detail as follows:

[0129] S910: Determine a current sequence frame to be rendered according to the position and display content of the text to be rendered in the current target canvas, and background information corresponding to the current target canvas.

[0130] It can be understood that a target canvas can be viewed as a sequence frame. The rendering content of the current sequence frame to be rendered can be determined based on the position and display content of the text to be rendered in the current target canvas, as well as the background information corresponding to the current target canvas. The rendering content includes the background, the text content, position, and arrangement of the text to be rendered.

[0131] Similarly, each sequence frame to be rendered can be determined based on the position and display content of the text to be rendered in each target canvas, and the background information corresponding to each target canvas. The background information corresponding to multiple target canvases can be the same or different, which is not limited here.

[0132] In an embodiment of the present application, there is a time sequence relationship between multiple sequence frames to be rendered. The time sequence relationship is determined between the multiple sequence frames to be rendered, and then the complete animation effect can be obtained by synthesizing each sequence frame to be rendered. The time sequence relationship can be determined based on the relationship between the position of the text to be rendered in multiple target canvases and the display content; or the time sequence relationship can be carried in the layout of the text to be rendered in multiple target canvases.

[0133] S920: If the current sequence frame to be rendered is different from the previous sequence frame to be rendered, store the current sequence frame to be rendered and the previous sequence frame to be rendered; if the current sequence frame to be rendered is the same as the previous sequence frame to be rendered, use both the current sequence frame to be rendered and the previous sequence frame to be rendered as pause frames.

[0134] In an embodiment of the present application, the current sequence frame to be rendered can be compared with the previous sequence frame to be rendered to determine whether the current sequence frame to be rendered is the same as the previous sequence frame to be rendered, where the two sequence frames being the same means that the contents of the two sequence frames are completely consistent.

[0135] If the current sequence frame to be rendered is different from the previous sequence frame to be rendered, the current sequence frame to be rendered and the previous sequence frame to be rendered are stored; if the current sequence frame to be rendered is the same as the previous sequence frame to be rendered, it means that the current sequence frame to be rendered and the previous sequence frame to be rendered are actually still pictures, and there is an animation pause, and the current sequence frame to be rendered and the previous sequence frame to be rendered are both used as pause frames.

[0136] Repeat steps S910 to S920 to determine whether each frame in the sequence to be rendered is a stay frame.

[0137] S930 , rendering the stored sequence of frames to be rendered to obtain a dynamic frame, extracting a pause frame, and rendering the extracted pause frame to obtain a static frame.

[0138] In the embodiment of the present application, the stored sequence frames to be rendered are non-static images with different contents, and each stored sequence frame to be rendered is rendered to obtain various dynamic frames.

[0139] It can be understood that the pause frame is a sequence of still images with the same content to be rendered, but the pause frames may also have different contents. For example, the pause frames include frames 1 to 9, and pause frames 1 to 4 are frames with the same content, and pause frames 5 to 9 are frames with the same content, but the content of pause frame 4 is different from that of pause frame 5. Therefore, multiple pause frames can be divided based on the frame content to obtain multiple groups of pause frames with different contents, and then only one frame is extracted from each group of pause frames, and the extracted pause frame is rendered to obtain a static frame. Continuing with the above example, the pause frames 1 to 9 are divided to obtain a first group of pause frames (pause frames 1 to 4) and a second group of pause frames (pause frames 5 to 9). Any frame is extracted from the first group of pause frames for rendering to obtain a first static frame, and any frame is extracted from the second group of pause frames for rendering to obtain a second static frame.

[0140] In other embodiments of the present application, when rendering the stored sequence frames to be rendered and the extracted pause frames, the Figures 3 to 5 Rendering can also be done by Figures 6 to 8 Rendering mode.

[0141] S940 , multiplexing the static frames, and synthesizing the multiplexed static frames and the dynamic frames according to a frame sequence to obtain a rendering result corresponding to the rendering request.

[0142] In an embodiment of the present application, the static frame is reused based on the number of pause frames, for example, 3 first static frames are reused and 4 second static frames are reused. After rendering to obtain the dynamic frame and the static frame, the reused static frame and the dynamic frame are synthesized in sequence based on the order of the frames to obtain a complete text rendering result with animation effect.

[0143] It should be noted that Figure 9 For more details on steps S210 to S230, see Figure 2 Steps S210 to S230 are not described in detail here.

[0144] In an embodiment of the present application, when two adjacent sequence frames to be rendered are different, both of the two adjacent sequence frames to be rendered are rendered; when two adjacent sequence frames to be rendered are the same, only one frame is extracted for rendering, and the frame is reused to avoid redundant rendering of some static or repeated artistic text, thereby improving performance and efficiency.

[0145] In one embodiment of the present application, another text rendering method is provided, which can be applied to Figure 1In the implementation environment shown, the method can be executed by the server, such as Figure 10 As shown, the text rendering method is Figure 9 Based on the above, S1010 to S1030 are added. Among them, step S1010 is a method for determining whether two sequence frames are the same, and S1020 to S1030 are another method for determining whether two sequence frames are the same, which are described in detail as follows:

[0146] S1010: Calculate the similarity between the rendering content of the current sequence frame to be rendered and the rendering content of the previous sequence frame to be rendered, and determine whether the current sequence frame to be rendered is the same as the previous sequence frame to be rendered based on the similarity.

[0147] In an embodiment of the present application, the server can calculate the similarity between the rendering content of the current frame to be rendered and the rendering content of the previous sequence frame to be rendered, and calculate the similarity of the background of the two frames, the text content, position, arrangement, etc. of the text to be rendered. If the similarity between the two frames is greater than a preset threshold, the preset threshold should be close to 100%. For example, if the preset threshold is 98%, it can be determined that the current sequence frame to be rendered is the same as the previous sequence to be rendered.

[0148] In one example, the rendering content of the current sequence frame to be rendered and the rendering content of the previous sequence frame to be rendered can be converted into frame vectors respectively, and then the cosine distance between the two frame vectors is calculated to represent the similarity between the current sequence frame to be rendered and the previous sequence frame to be rendered.

[0149] S1020: Obtain the frame times corresponding to the current sequence frame to be rendered and the previous sequence frame to be rendered.

[0150] In an embodiment of the present application, the frame time corresponding to the current sequence frame to be rendered can be obtained from the layout of the text to be rendered in the current target canvas. Similarly, the frame time corresponding to the previous sequence frame to be rendered can be obtained from the layout of the text to be rendered in the previous target canvas.

[0151] S1030: If the acquired frame time belongs to a preset frame time range, determine that the current sequence frame to be rendered is the same as the previous sequence frame to be rendered, wherein the preset frame time range is determined based on rendering parameters.

[0152] In an embodiment of the present application, when the text to be rendered is text with animation effects, the server can determine a preset frame time range based on the rendering parameters, wherein the rendering parameters include the total duration of the animation effect, the duration of the still picture, and the duration of the non-still picture. The preset frame time range is the time range corresponding to the still picture. If the acquired frame times all belong to the preset frame time range, it means that both sequence frames belong to still pictures, that is, the current sequence frame to be rendered is the same as the previous sequence frame to be rendered.

[0153] In another example, if the animation effect of the text to be rendered is set by the server, the time range corresponding to the still picture in the animation effect can also be obtained and used as the preset frame time range.

[0154] It should be noted that Figure 10 For more detailed information on steps S210 to S230 and S910 to S940, see Figure 9 Steps S210 to S230 and S910 to S940 are shown and will not be described in detail here.

[0155] In an embodiment of the present application, whether two adjacent sequence frames to be rendered are the same is determined by calculating the similarity between them. Whether two adjacent sequence frames to be rendered are the same can also be determined by whether the frame times of the two adjacent sequence frames to be rendered fall within a preset frame time range, thereby ensuring accuracy.

[0156] It is worth noting that Figures 3 to 5 、 Figures 6 to 8 ,as well as Figures 9 and 10 The rendering methods shown can be performed simultaneously. For example, the server can start three threads, each thread can implement a rendering method, and then the three threads can render simultaneously, further reducing the rendering time.

[0157] In one embodiment of the present application, another text rendering method is provided, which can be applied to Figure 1 In the implementation environment shown, the method can be executed by the server, such as Figure 11 As shown, the text rendering method is Figure 2 Based on the above, step S220 is expanded into steps S1110 to S1130. The text requirements include font requirements and text content requirements. Steps S1110 to S1130 are described in detail as follows:

[0158] S1110 : Searching for a target font resource corresponding to the font requirement based on a locally stored font library, and determining text parameters of the text to be rendered based on the target font resource and the text content requirement.

[0159] In an embodiment of the present application, the server preloads various fonts to form a font library and stores them locally. Therefore, when the corresponding font resources need to be found, the corresponding font resources can be quickly read. Font resources refer to font files used to generate text effects, which usually contain glyph data for different languages ​​and character sets.

[0160] In one example, the font requirement includes a unique identifier of the required target font resource, and the locally stored font library stores font resources corresponding to different identifiers. The unique identifier included in the font requirement can be compared one by one with the identifiers in the font library to find the corresponding target font resource.

[0161] The text content requirement indicates the text content of the text to be rendered. Therefore, the text parameters of the text to be rendered can be determined based on the target font resource and the text content requirement. The text parameters include at least the target font resource and the text content.

[0162] S1120. Determine effect parameters corresponding to effect requirements based on the art effect library used on the client.

[0163] The effect requirement indicates the text effect of the text to be rendered. Since the server displays it on the client after rendering is completed, in order to ensure that the same rendering effect is displayed on the client, the server introduces the art effect library used on the client; it can be understood that if the rendering is displayed on other devices after completion, the art effect library used on other devices can also be introduced.

[0164] In an embodiment of the present application, the text effect indicated by the effect requirement can be searched from the art effect library used by the client, and the corresponding effect parameters can be determined.

[0165] S1130: Generate rendering parameters for the text to be rendered based on the text parameters and the effect parameters.

[0166] In an embodiment of the present application, text parameters and effect parameters may be synthesized to obtain rendering parameters of the text to be rendered.

[0167] It should be noted that Figure 11 For more details on steps S210, S230 to S240, see Figure 2 Steps S210 and S230 to S240 are not described in detail here.

[0168] In an embodiment of the present application, font resources are preloaded in advance, so that during operation, the corresponding text parameters can be determined directly based on the locally stored font library, reducing the time spent on loading and using font resources, and determining the artistic parameters through the artistic effect library used on the client to ensure that the rendering results display the same rendering effect on the client.

[0169] In one embodiment of the present application, another text rendering method is provided, which can be applied to Figure 1 In the implementation environment shown, the method can be executed by the server, such as Figure 12 As shown, the text rendering method is Figure 11Based on the above, steps S1210 to S1230 are added before S1110. Steps S1210 to S1230 are described in detail as follows:

[0170] S1210: Preload preset basic font resources.

[0171] In the embodiments of the present application, the preset basic font resources include system font resources, Windows font resources, and Mac font resources. System fonts refer to some commonly used or basic font resources that come with or are installed by default in the operating system, such as Songti, Heiti, Arial, etc. Windows fonts refer to some font resources designed or optimized specifically for the Windows operating system, such as Microsoft Yahei and Huawen Xihei. Mac fonts refer to some font resources designed or optimized specifically for the Mac operating system, such as Pingfang and Huawen Heiti. The preset basic font resources can be preloaded by packaging them into an image, that is, these font resources are packaged into a portable or copyable file or data set according to a certain format or specification.

[0172] S1220. When the server is started, obtain the custom font configuration and preload the custom font resources corresponding to the custom font configuration.

[0173] In an embodiment of the present application, in addition to basic font resources, custom font resources can also be used. Custom font resources refer to some special or unique font resources obtained or added from the font server according to the needs or selections of the object, such as In the Mood for Love, Magical Girl, etc.; when the server is started, that is, before the service starts running, some initialization or preparation work is performed, such as loading configuration files, connecting to the database, etc. When the server is started, the custom font configuration can be obtained from the font server, or the custom font configuration can be obtained from the object's request.

[0174] The font configuration includes the font name, font type, font size, and font version. Based on the font configuration, the corresponding custom font resources can be obtained and preloaded.

[0175] S1230: Generate a font library based on preloaded basic font resources and custom font resources.

[0176] In an embodiment of the present application, the preloaded basic font resources and custom font resources can be directly used as font resources of the font library; the basic font resources and custom font resources can also be compared to filter out font resources whose font differences are less than a preset difference threshold, and a font library can be generated based on the filtered font resources; the basic font resources and custom font resources can also be combined to generate new font resources, and the new font resources, basic font resources and custom font resources can be used as font resources of the font library.

[0177] It should be noted that Figure 12 For more detailed information on steps S210, S1110 to S1130, and S230 to S240, see Figure 11 Steps S210, S1110 to S1130, and S230 to S240 are shown and will not be described in detail here.

[0178] In the embodiment of the present application, not only are preset basic font resources preloaded, but custom font resources can also be obtained when the service is started, and then a font library is generated so that the font library can meet various font demand scenarios.

[0179] This application embodiment provides another text rendering method, which can be applied to Figure 1 In the implementation environment shown, the method can be executed by the server, such as Figure 13 As shown, the text rendering method is Figure 11 Based on the example shown in FIG, step S1110 is expanded into steps S1310 to S1350; wherein, steps S1310 to S1350 are described in detail as follows:

[0180] S1310: During the operation of the server, search the font library to see whether the target font resource exists.

[0181] In an embodiment of the present application, during the operation of the server, a search is performed to determine whether a target font resource exists in the font library to determine the corresponding font parameters.

[0182] S1320: If the target font resource does not exist in the font library, obtain configuration information corresponding to the target font resource.

[0183] In an embodiment of the present application, if the target font resource does not exist in the font library, the missing target font resource needs to be dynamically updated. First, the configuration information corresponding to the target font resource is obtained from the font server. The configuration information includes font name, font type, font version, etc.

[0184] S1330: Update a pre-established font dictionary according to the configuration information, where the font dictionary is used to maintain a mapping relationship between font names.

[0185] In an embodiment of the present application, a font dictionary is pre-established, which is used to maintain a mapping relationship between font names to smooth out the differences between the parameter font name and the font name actually used. For example, the font name input by the object may be Chinese or English, while the font name actually used may be in other languages ​​or encodings.

[0186] S1340: Preload the target font resource according to the configuration information and the updated font dictionary to update the target font resource into the font library, and search for the target font resource based on the updated font library.

[0187] In an embodiment of the present application, a target font resource is generated based on the configuration information and the updated font dictionary, and the target font resource is preloaded, and then the target font resource is updated to the font library, so that the target font resource is searched in the updated font library.

[0188] S1350: Determine text parameters of the text to be rendered based on target font resources and text content requirements.

[0189] It should be noted that Figure 13 For more detailed information on steps S210, S1120 to S1130, and S230 to S240, see Figure 11 Steps S210, S1120-S1130, and S230-S240 shown are not repeated here.

[0190] In an embodiment of the present application, when the service is running, if it is found that some font resources are not preloaded or new font resources are added, these missing or newly added font resources are dynamically updated, thereby ensuring the integrity and timeliness of the service functions and effects.

[0191] This application embodiment provides another text rendering method, which can be applied to Figure 1 In the implementation environment shown, the method can be executed by the server, such as Figure 14 As shown, the text rendering method is Figure 2 Based on the Figure 2 As shown, step S1410 is added before S210, steps S1420 to S1430 are added after S210, and S220 is expanded to S1440. Steps S1410 to S1440 are described in detail as follows:

[0192] S1410: Build a rendering interceptor.

[0193] An interceptor is a function that abstracts functions or codes that are not related to the core business logic or are scattered in various modules into independent aspects. It can be dynamically woven into the target method or function without modifying the original code structure or logic.

[0194] In an embodiment of the present application, the rendering interceptor abstracts functions unrelated to the rendering business logic into an independent aspect, where functions unrelated to the rendering business logic include parameter verification, logging, and caching, etc., to ensure the purity and high cohesion of the core logic module.

[0195] S1420: Verify key information in the rendering request through the rendering interceptor, and after the key information is verified, record the rendering request to a log file.

[0196] In an embodiment of the present application, after obtaining a rendering request, the rendering request is input into a rendering interceptor, and the key information in the rendering request is verified by the rendering interceptor, such as whether the rendering request contains necessary and legal requirements, such as text content, font type or color selection, etc.; if it contains necessary and legal requirements, it means that the key information in the rendering request has been verified, and the rendering request is recorded in a log file for subsequent analysis.

[0197] In one example, in addition to verifying key information in the rendering request, exception information in the rendering request may also be captured. The exception information may be information unrelated to rendering or information that cannot be processed by the server.

[0198] S1430: If it is determined based on the log file that there is a historical request identical to the rendering request, obtain a rendering result corresponding to the historical request, and use the rendering result as a rendering result of the rendering request.

[0199] In an embodiment of the present application, rendering efficiency and resource conservation can be improved based on log files. A rendering request can be compared with historical requests in the log file. Specifically, the requirements contained in the rendering request are compared with the requirements contained in the historical requests to determine whether there is a historical request that is identical to the rendering request. If there is a historical request that is identical to the rendering request, the rendering result corresponding to the historical request can be directly obtained from the memory and directly used as the rendering result of the rendering request without re-rendering. It is understood that both S1420 and S1430 can be executed by the rendering interceptor.

[0200] S1440: If it is determined based on the log file that there is no historical request identical to the rendering request, then rendering parameters for the text to be rendered are generated based on the text requirements and the effect requirements.

[0201] It should be noted that Figure 14 For a detailed description of steps S210, S230 to S240, see Figure 2 Steps S210, S230-S240 shown in FIG will not be repeated here.

[0202] In an embodiment of the present application, by constructing a rendering interceptor, functions unrelated to the rendering business logic are abstracted into an independent aspect, ensuring the purity and high cohesion of the core rendering business. At the same time, by comparing the rendering request with the historical request, the service efficiency is improved and resources are saved.

[0203] This application embodiment provides another text rendering method, which can be applied to Figure 1 In the implementation environment shown, the method can be executed by the server, such as Figure 15 As shown, the text rendering method is Figure 2 Based on the Figure 2 Steps S1510 to S1520 are added after S240 shown in the figure. Steps S1510 to S1520 are described in detail as follows:

[0204] S1510: Record the link status of the rendering request in the request log, and record the rendering process of the text to be rendered in the rendering log.

[0205] In an embodiment of the present application, the link status of the rendering request includes a series of nodes from initiating the request to returning the response from the server, such as a browser, a web server, and a server; the information corresponding to the series of nodes, such as the request address, the requirements included in the request, and the network address, is recorded in the request log.

[0206] The rendering process of the text to be rendered includes a font resource determination process and a text rendering process to a canvas. The rendering process of the text to be rendered is recorded in a rendering log.

[0207] S1520 : Assign unique identifiers to the request log and the rendering log, and associate the request log and the rendering log according to the unique identifiers to form a log file for the rendering request.

[0208] In an embodiment of the present application, a unique identifier is assigned to the request log and the rendering log. The unique identifier is used to represent the identifier of each node and step involved in the request. The request log and the rendering request are associated with each other through the unique identifier, thereby forming a log file for the rendering request. The log file for the rendering request can reflect the execution order, time, result, etc. of each node and step in the rendering request. The corresponding node and step can be quickly found later through the unique identifier.

[0209] It should be noted that Figure 15 For a detailed description of steps S210 to S240, see Figure 2 Steps S210 to S240 shown in FIG will not be described in detail here.

[0210] In an embodiment of the present application, the link status of the rendering request is recorded in the request log, and the rendering process of the text to be rendered is recorded in the rendering log, and a unique identifier is assigned to associate the request log and the rendering log to form a log file. Subsequently, the unique identifier can be used to quickly find the nodes and steps where problems or exceptions occur in the request link, and the relevant log information can be viewed, so as to conveniently locate and troubleshoot the causes and solutions of the problems or exceptions.

[0211] For ease of understanding, the present application embodiment also provides a text rendering method, which is described by taking the text as an artistic word as an example; first, the architecture diagram of the server is described, such as Figure 16 As shown, the server includes a rendering interceptor, a font module, an art font package, a renderer, a runtime environment, and a generator; wherein the rendering interceptor organizes the log module, the buffer module, the participation verification module, and the exception capture module in a unified manner, and the log module, the buffer module, the participation verification module, and the exception capture module are functional modules unrelated to the rendering business.

[0212] The font module is mainly responsible for font preloading, font dictionary maintenance, and incremental font additional loading. It can provide different font services according to different scenarios and needs. Among them, font preloading means downloading the font resources that may be used to the local cache in advance before the page is loaded, thereby reducing the waiting time when the page is rendered, such as preloading system fonts, Windows fonts, and Mac; font dictionary maintenance means establishing a mapping relationship between fonts and characters according to different languages ​​and character sets, so that the corresponding font resources can be found quickly; incremental font additional loading means that when the page is rendered, if it is found that some characters do not have corresponding font resources, these missing font resources are dynamically requested and loaded, thereby ensuring the integrity of the page display, such as obtaining custom font resources through the interface configuration of the custom font module, downloading custom font resources and storing them.

[0213] The WordArt package is a toolkit for creating beautiful and personalized text effects. It generates WordArt in various styles and themes based on input or selection. The package includes WordArt in different colors, various WordArt templates, and WordArt templates with multiple styles. It also includes subtitles in various styles, animation configuration tables for WordArt, and style configurations.

[0214] The word art package is introduced as an npm package, which is a toolkit for managing and distributing JavaScript code libraries or modules. It can easily install and update various dependencies and plug-ins. The client is pixi and the server is pixi / node. In this way, the same or similar code or technology is used to achieve the same or similar functions or effects on different platforms or environments, thereby reducing code duplication and maintenance costs, and ensuring the uniformity of effects on multiple terminals (browser, client, server). Among them, pixi is a JavaScript library for creating high-performance 2D graphics and animations; pixi / node is a JavaScript library for using pixi on the server side. It can take advantage of the characteristics of Node.js, such as asynchronous, event-driven, modular, etc., to achieve efficient graphics rendering.

[0215] The renderer includes parameter initialization steps, renderer instance, canvas recording steps, and sequence frame image generation steps. The canvas recording includes multi-dimensional optimization methods, namely local rendering optimization, visualization area optimization, and pause animation optimization. Multi-dimensional optimization further reduces rendering time.

[0216] The server-side running environment includes pixi / node and headless-gl. Server-side rendering is implemented through technologies such as headless-gl, Mesa and Xvfb. Headless-gl is a JavaScript library for creating and operating WebGL contexts in Node.js. Headless-gl uses OpenGL (OpenGL is a cross-platform API for creating 2D and 3D graphics applications), and OpenGL is implemented by Mesa, which is an open source graphics library for implementing the OpenGL API. Mesa can provide software rendering capabilities on devices that do not support OpenGL hardware acceleration. Headless-gl, Mesa and Xvfb (X virtual framebuffer, a virtual display server for running graphics applications in a displayless or graphicsless environment) work together to provide a CPU-simulated offscreen rendering environment for server-side devices without graphics cards. The offscreen rendering environment refers to a graphics rendering environment that does not rely on a display or window system, and can save the rendering results in memory or output them to a file.

[0217] The generator is used to synthesize rendered images in a certain order to form a dynamic effect.

[0218] In the embodiment of the present application, the server realizes the intelligent rendering of complex graphics and text by integrating complex font modules; the engine modules are differentiated by domain through intelligent interceptors to ensure clear calling of module boundaries and improve system performance; by directly pulling font modules and font packages from the server, font module maintenance preloading, font dictionary maintenance, and incremental font additional loading, the font loading speed is reduced to 0ms through local reading; and headless-gl, Mesa and Xvfb technologies are used through OpenGL's Mesa to provide a CPU-simulated offscreen rendering environment for server devices without graphics cards, which is lighter and easier to use; in addition, the renderer instance's canvas recording enables the renderer to maintain multi-dimensional multi-threaded simultaneous rendering, reducing rendering time.

[0219] This embodiment of the present application can be used for intelligent generation and configuration rendering of artistic words in videos. Based on the above server-side structure, such as Figure 17 As shown, the text rendering method includes:

[0220] S1710: Get a rendering request.

[0221] In the embodiment of the present application, the object can trigger a request through the control of the interface, such as Figure 18-a As shown, the interface configures preset artistic words, which include text content and artistic effects. For example, if the object selects the "xxxxx" artistic word, the generated rendering request includes the "xxxxx" text content and the shadow bubble effect; Figure 18-b As shown, the object can also output corresponding text content through the interface, such as triggering the text input interface (adding subtitles) through the "New Text" control, entering text in the text input interface, and selecting the corresponding style of artistic effect, and then generating the rendering request based on the object selection.

[0222] S1720. Verify the rendering request through a rendering interceptor.

[0223] The implementation of the interceptor uses the concept of aspect-oriented programming (AOP). AOP is suitable for certain applications with horizontal logic (slicable). Horizontal logic refers to functions or codes that are unrelated to the core business logic or scattered in various modules, such as logging and caching. They usually do not belong to any specific module or level, but span multiple modules or levels.

[0224] In the service of word art rendering, when the server receives a request, the actions performed in sequence are: parameter verification -> reporting (storage) logs -> cache management -> exception capture. These functions are not directly related to the core business (rendering business) logic, and are not the main purpose or function of word art rendering. Instead, they are some auxiliary or enhanced functions that do not affect the results or effects of word art rendering, but are only used to improve the quality and stability of the service. Therefore, in the embodiment of the present application, these functions are abstracted, which ensures the purity and high cohesion of the core logic module, so that the core logic module only contains code and logic related to word art rendering, and is not interfered with or polluted by other irrelevant or scattered functions or codes, thereby improving the readability, maintainability and reusability of the core logic module.

[0225] like Figure 19 As shown, the interceptor can implement the functions of parameter verification->reporting (storage) logs->cache management->exception capture, where:

[0226] Parameter verification refers to checking the rendering request for key information, that is, whether the necessary and legal parameters are included in the verification, such as text content, font type, color selection, etc. If the parameters do not meet the requirements, an error message will be returned or the service will be denied.

[0227] Reporting (storing) logs means recording relevant information about rendering requests and service responses into log files, such as request time, request content, response time, response content, etc., to facilitate subsequent analysis and testing of service performance and quality.

[0228] Cache management refers to the use of caching mechanisms to improve service efficiency and save resources. For example, already rendered WordArt effects can be saved in memory or disk. After receiving a rendering request, it is determined whether it is the same or similar cache request. If a cache hit is found, the rendering result is directly obtained from the cache without the need for re-rendering.

[0229] Exception capture refers to handling various exceptions or errors that may occur during the service process, such as network failure, rendering failure, insufficient resources, etc. If an exception or error occurs, a friendly error message or prompt will be returned, and the normal operation of the service will be restored as much as possible.

[0230] like Figure 20As shown, the log files in the embodiment of the present application include xvfb logs, font logs, Hawkeye logs, CDN (Content Delivery Network) logs, and code exception logs. The xvfb log refers to a log file used to record the operation of the xvfb server; the xvfb log includes: the startup time, parameters, status, etc. of the xvfb server; the graphics requests, responses, and results processed by the xvfb server; and errors, exceptions, and warnings generated by the xvfb server.

[0231] A font log is a log file used to record the management of font resources. The font log includes: the source, type, size, version, etc. of the font resources; the storage location, method, status, etc. of the font resources; the update time, frequency, content, etc. of the font resources.

[0232] Eagle Eye log records the status of the request link, such as client IP, container name, reporting machine and other information. Among them, the container name refers to the container technology or platform used when the service is running, and the reporting machine refers to the physical or virtual machine used when the service is running, such as cloud server, local server, etc.; it is used together with Wuji and network request log; among them, Wuji refers to a service for temporary and persistent storage of request content and return results, and the network request log refers to a log file used to record network request status, including basic information contained in the network request, CDN information of sequence frames, etc.

[0233] CDN logs record any exceptions that occur during the process of uploading generated text effect images from the server to the CDN server. When an exception occurs, the scheduled script task can push an alarm message to relevant personnel or systems.

[0234] A code exception log is a log file used to record errors or exceptions that occur during code execution.

[0235] The aforementioned logs are linked in series using trace IDs to facilitate location and troubleshooting. A trace ID is a unique identifier used to identify and trace each node and step in the request chain, typically consisting of a string of numbers or letters. By establishing connections and associations through trace IDs, a complete and clear request chain diagram is formed. The request chain diagram can reflect the execution order, time, and results of each node and step in the request chain.

[0236] S1730: Perform rendering service based on the rendering request.

[0237] The rendering services include S1731 to S1735, which are described in detail as follows:

[0238] S1731. Extract the font requirements in the rendering request.

[0239] S1732. Load the font library.

[0240] S1733. Determine whether the font resource corresponding to the font requirement in the request is in the font library. If not, go to S1734; if yes, go to S1735.

[0241] S1734. Load the custom font module.

[0242] The client rendering solution is that the font resources are downloaded and loaded after each client is started, which will bring a time consumption of 80ms-120ms. In the embodiment of the present application, the font module is optimized and changed to a pre-loading and dynamic update strategy. That is, the font module adopts different strategies to load and update font resources when the service is started and when it is running, thereby improving the efficiency and flexibility of the font module. The overall font module process is as follows: Figure 21 shown.

[0243] System font resources, Windows font resources, and Mac font resources are all preloaded by packaging them into images. Custom font resources are preloaded when the service starts, going through the steps of pulling font configuration -> updating font name dictionary -> downloading -> storing -> installing. The purpose of the font name dictionary is to smooth out the differences between the parameterized font name and the actual font name used. Downloading refers to downloading the custom font resource file from the server based on the pulled font configuration information. The file can be provided in the form of a compressed package or link, such as ZIP, URL, etc. The downloaded custom font resource file is saved to the local cache and the custom font resource file stored in the local cache is installed to the system. When the service is running, there are also cases where new fonts are added in the clipper. For example, the object adds some new custom font resources through a tool or interface for editing or selecting text effects (commonly called a clipper), such as uploading a new TTF (TrueTypeFont) file. At this time, it is detected whether the new font exists in the local cache. If not, the font incremental update logic will be performed, that is, going through the steps of pulling font configuration -> updating font name dictionary -> downloading -> storing -> installing.

[0244] S1735. The server performs rendering.

[0245] The server-side rendering process includes S17351 to S17356, which are described in detail as follows:

[0246] S17351. Start renderer instantiation.

[0247] Start the renderer instantiation, that is, open the renderer, pull the canvas with background information, and introduce the art effect package. This art effect package can be used during client rendering and is introduced in the form of an npm package. The corresponding effect parameters are determined by the art effect package and the effect requirements in the rendering request.

[0248] S17352. Generate rendering parameters.

[0249] The rendering parameters are synthesized based on the effect parameters and the text parameters determined by the font library.

[0250] S17353. Rendering is performed based on three rendering optimization methods.

[0251] It is understandable that when there is animation in the word art, the number of frames that need to be calculated will increase a lot, resulting in a lot of rendering and buffer acquisition overhead, so the time overhead will also rise. Therefore, in the embodiment of the present application, the rendering can be divided into static canvas and dynamic word art, such as Figure 22 As shown, the first area only contains a static canvas (white background), which contains content that does not change with the animation and does not need to be re-rendered and buffered with each frame of the image; the second area contains dynamic artistic text, which changes with the animation, such as text color, size, angle, etc., and needs to be re-rendered and buffered with each frame of the image. In order to save or transmit the rendered canvas content to other places, the canvas content needs to be converted into a binary data stream. This data stream is called a buffer, and this conversion process is called obtaining the buffer.

[0252] In order to avoid generating a large amount of rendering and buffer acquisition overhead, in the embodiment of the present application, three rendering optimization methods include visualization area optimization, local rendering optimization and pause animation optimization.

[0253] Visualization area optimization: Only the visible portion of the canvas is rendered, while the portion outside the visible range is not rendered, thereby reducing rendering workload and overhead; because some WordArt may exceed the canvas boundary, or some parts may enter or leave the canvas during the animation process. The general principle is to traverse all WordArt, treat each WordArt as a rectangle, calculate the area and position of this rectangle, and use this to determine whether the WordArt is within the visual area of ​​the canvas. If not, the entire canvas buffer is not obtained; this can avoid unnecessary rendering and buffer acquisition for some invisible or unimportant WordArt, thereby improving performance and efficiency. For the specific process, please refer to Figures 3 to 5 , I will not go into details here.

[0254] Local rendering optimization: Not all content needs to be rendered. Only local areas of the canvas are rendered. For example, only the parts of the canvas that have changed or need to be updated are rendered, while the parts that have not changed or do not need to be updated are not rendered, thereby reducing the workload and overhead of rendering. Figure 23 As shown in the figure, the area to be drawn is the bold rectangle area, and the area outside the bold rectangle area does not need to be drawn. Figure 24 As shown in the figure, the principle of local rendering optimization is to determine whether local rendering is needed based on the loaded rendering parameters. Specifically, the content in the canvas can be determined based on the rendering parameters. If it has changed, local rendering is required. Then, the local area of ​​the changed word art is calculated and it is determined whether the local area is less than 80% of the canvas. If the local area is less than 80% of the canvas, the local area is locally rendered and combined with other areas to form a complete image frame. If the safe area is greater than 80% of the canvas, the canvas is directly globally rendered to generate a complete image frame. For the specific process, please refer to Figures 6 to 8 , I will not go into details here.

[0255] Dwell animation optimization: For animation effects with a dwell period (i.e., no changes between the start and end of the animation), only one frame of image required for the dwell period is extracted instead of all frames during the dwell period, thereby reducing the workload and overhead of extracting frames; because artistic text may have some animation effects with a dwell period, such as entry and exit, flashing, etc., artistic text is static and unchanged, and remains consistent with the previous frame. Figure 25 As shown, the bold selected part actually shows the static animation; the general principle is to traverse all the artistic words, determine whether each artistic word has a dwell period, and calculate the frame image required for the dwell period (usually the previous frame image at the beginning or end of the dwell period), so as to determine whether it is necessary to extract all the frames of the dwell period. If not, only the frame image required for the dwell period is extracted, and this frame image is reused during the dwell period; this can avoid unnecessary frame image extraction for some static or repeated artistic words, thereby improving performance and efficiency. For the specific process, please refer to Figures 9 and 10 , I will not go into details here.

[0256] S17354. Destroy the renderer instance.

[0257] In an embodiment of the present application, after rendering is completed, the renderer instance can be destroyed to save server-side rendering resources.

[0258] S17355. Generate image sequence frames based on the rendering results.

[0259] S17356. Synthesize the image sequence frames to obtain rendered text with animation effect.

[0260] In the embodiment of the present application, the performance of dynamic text rendering is improved by server-side rendering, and high-speed rendering can be achieved; server-side rendering is achieved by technologies such as headless-gl, Mesa and Xvfb, which can reduce the overall resource loss of the machine and the time for starting the browser process, opening the web page, establishing multiple request connections, etc. caused by client-side rendering, which is more direct and efficient; a rendering interceptor is constructed to separate non-core functions (i.e., buffering function, verification function and exception capture function, etc.) so that the main thread can focus on the rendering of artistic characters, and other modules play an auxiliary role, thereby improving performance as much as possible; a horizontal logging system is constructed to asynchronously store the engine in different logging systems, and locate it through trice id to improve the overall engine high availability; in addition, the core fonts are loaded by preloading to reduce the preparation time of the artistic character engine rendering.

[0261] Here, we introduce an embodiment of the device of the present application, which can be used to perform the text rendering method in the above embodiment of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the text rendering method in the above embodiment of the present application.

[0262] The embodiment of the present application provides a text rendering device, such as Figure 26 As shown, the device includes:

[0263] An acquisition module 2610 is configured to acquire a rendering request for the text to be rendered, the rendering request including text requirements and effect requirements;

[0264] The generation module 2620 is further used to generate rendering parameters of the text to be rendered based on the text requirements and effect requirements;

[0265] Determining module 2630, configured to obtain a target canvas for displaying the text to be rendered, and determine a layout of the text to be rendered in the target canvas according to rendering parameters;

[0266] The rendering module 2640 is configured to render the text to be rendered in the target canvas using at least one rendering method according to the layout.

[0267] In one embodiment of the present application, based on the aforementioned scheme, the layout includes the position and display content of the text to be rendered in the target canvas; the rendering module is further used to obtain the visualization area of ​​the target canvas, and the background information corresponding to the visualization area; the visualization content of the text to be rendered is determined according to the position and display content of the text to be rendered in the target canvas, and the visualization area, and the visualization content is used to represent the content displayed in the visualization area; the visualization area is rendered based on the background information corresponding to the visualization area and the visualization content of the text to be rendered, so as to render the visualization content of the text to be rendered into the visualization area.

[0268] In one embodiment of the present application, based on the aforementioned scheme, the rendering module is further used to determine the bounding box of the text to be rendered based on the position and display content of the text to be rendered in the target canvas; compare the bounding box with the visualization area to determine the overlapping area between the bounding box and the visualization area; and determine the visualization content based on the display content of the text to be rendered in the overlapping area.

[0269] In one embodiment of the present application, based on the aforementioned scheme, the layout includes the position of the text to be rendered in the target canvas, the displayed content and the size of the area occupied; the rendering module is further used to obtain the local rendering area in the target canvas and the background information corresponding to the local rendering area according to the position of the text to be rendered in the target canvas and the size of the area occupied; other areas in the target canvas except the local rendering area are used as non-rendering areas; the local rendering area is rendered based on the background information corresponding to the local rendering area and the displayed content of the text to be rendered to obtain the target area; the target area and the non-rendering area are synthesized to obtain the rendering result for the rendering request.

[0270] In one embodiment of the present application, based on the aforementioned scheme, the rendering module is further used to obtain the size relationship between the local rendering area and the canvas area corresponding to the target canvas; if the size relationship satisfies the preset relationship, the local rendering area is rendered based on the background information corresponding to the local rendering area and the display content of the text to be rendered to obtain the target area.

[0271] In one embodiment of the present application, based on the aforementioned scheme, the layout includes the position and display content of the text to be rendered in multiple target canvases; the rendering module is further used to determine the current sequence frame to be rendered based on the position and display content of the text to be rendered in the current target canvas, and the background information corresponding to the current target canvas; if the current sequence frame to be rendered is different from the previous sequence frame to be rendered, the current sequence frame to be rendered and the previous sequence frame to be rendered are stored; if the current sequence frame to be rendered is the same as the previous sequence frame to be rendered, the current sequence frame to be rendered and the previous sequence frame to be rendered are both used as pause frames; the stored sequence frames to be rendered are rendered to obtain dynamic frames, and a pause frame is extracted, and the extracted pause frame is rendered to obtain a static frame; the static frames are reused, and the reused static frames and dynamic frames are synthesized according to the sequence of frames to obtain the rendering result for the rendering request.

[0272] In one embodiment of the present application, based on the aforementioned scheme, the rendering module is further used to calculate the similarity between the rendering content of the current sequence frame to be rendered and the rendering content of the previous sequence frame to be rendered, and determine whether the current sequence frame to be rendered is the same as the previous sequence frame to be rendered based on the similarity; or, obtain the frame time corresponding to the current sequence frame to be rendered and the previous sequence frame to be rendered respectively; if the obtained frame time falls within a preset frame time range, it is determined that the current sequence frame to be rendered is the same as the previous sequence frame to be rendered, wherein the preset frame time range is determined based on the rendering parameters.

[0273] In one embodiment of the present application, based on the aforementioned scheme, the text requirements include font requirements and text content requirements; the generation module is further used to search for target font resources corresponding to the font requirements based on a locally stored font library, and determine the text parameters of the text to be rendered based on the target font resources and the text content requirements; determine the effect parameters corresponding to the effect requirements based on the art effect library used on the client; and generate rendering parameters for the text to be rendered based on the text parameters and the effect parameters.

[0274] In one embodiment of the present application, based on the aforementioned scheme, the device also includes a preloading module for preloading preset basic font resources; when the server is started, a custom font configuration is obtained, and the custom font resources corresponding to the custom font configuration are preloaded; and a font library is generated based on the preloaded basic font resources and custom font resources.

[0275] In one embodiment of the present application, based on the aforementioned scheme, the generation module is further used to search whether the target font resource exists in the font library during operation on the server; if the target font resource does not exist in the font library, obtain configuration information corresponding to the target font resource; update the pre-established font dictionary according to the configuration information, and the font dictionary is used to maintain the mapping relationship between font names; preload the target font resource according to the configuration information and the updated font dictionary to update the target font resource to the font library, and search for the target font resource based on the updated font library.

[0276] In one embodiment of the present application, based on the aforementioned scheme, the device also includes a construction module for constructing a rendering interceptor, which is used to verify the key information in the rendering request and record the rendering request to a log file after the key information is verified. If it is determined based on the log file that there is a historical request that is the same as the rendering request, the rendering result corresponding to the historical request is obtained, and the rendering result is used as the rendering result of the rendering request.

[0277] In one embodiment of the present application, based on the aforementioned scheme, the device also includes a recording module for recording the link status of the rendering request to the request log, and recording the rendering process of the text to be rendered to the rendering log; assigning a unique identifier to the request log and the rendering log, and associating the request log and the rendering log according to the unique identifier to form a log file for the rendering request.

[0278] It should be noted that the apparatus provided in the above embodiment and the method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs operations has been described in detail in the method embodiment and will not be repeated here.

[0279] An embodiment of the present application also provides an electronic device, comprising one or more processors and a storage device, wherein the storage device is used to store one or more computer programs, and when the one or more computer programs are executed by one or more processors, the electronic device implements the text rendering method as described above.

[0280] Figure 27 A schematic diagram of the structure of a computer system suitable for implementing an electronic device according to an embodiment of the present application is shown.

[0281] It should be noted that Figure 27 The computer system 2700 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0282] like Figure 27 As shown, computer system 2700 includes a processor (Central Processing Unit, CPU) 2701, which can perform various appropriate actions and processes according to the program stored in read-only memory (Read-Only Memory, ROM) 2702 or the program loaded from storage portion 2708 into random access memory (Random Access Memory, RAM) 2703, such as executing the method in the above embodiment. Various programs and data required for system operation are also stored in RAM 2703. CPU 2701, ROM 2702 and RAM 2703 are connected to each other via bus 2704. Input / output (I / O) interface 2705 is also connected to bus 2704.

[0283] In some embodiments, the following components are connected to the I / O interface 2705: an input section 2706 including a keyboard, a mouse, and the like; an output section 2707 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section 2708 including a hard disk; and a communication section 2709 including a network interface card such as a LAN (Local Area Network) card or a modem. The communication section 2709 performs communication processing via a network such as the Internet. A drive 2710 is also connected to the I / O interface 2705 as needed. Removable media 2711, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 2710 as needed, so that computer programs read therefrom can be installed into the storage section 2708 as needed.

[0284] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 2709, and / or installed from the removable medium 2711. When the computer program is executed by the processor (CPU) 2701, the various functions defined in the system of the present application are executed.

[0285] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (Erasable Programmable Read Only Memory), a flash memory, an optical fiber, a portable compact disk read-only memory (Compact Disc Read-Only Memory, CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal can take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. A computer program embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, or any suitable combination thereof.

[0286] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions and operations of the devices, methods and computer program products according to various embodiments of the present application. Among them, each box in the flowchart or block diagram can represent a module, program segment, or part of the code, and the above-mentioned module, program segment, or part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and a computer program.

[0287] The units or modules described in the embodiments of the present application may be implemented in software or hardware, and the units or modules described may also be provided in a processor. The names of these units or modules do not, in certain circumstances, limit the units or modules themselves.

[0288] Another aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-described text rendering method. The computer-readable storage medium may be included in the electronic device described in the above embodiments, or may exist independently and not be incorporated into the electronic device.

[0289] Another aspect of the present application further provides a computer program product, comprising a computer program stored in a computer-readable storage medium. A processor of an electronic device reads the computer program from the computer-readable storage medium and executes the computer program, causing the electronic device to perform the text rendering method described above in each of the above embodiments.

[0290] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiment of the application, the features and functions of two or more modules or units described above can be concretized in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be concretized.

[0291] Other embodiments of the present invention will readily occur to those skilled in the art after considering the specification and practicing the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present invention that follow the general principles of this application and include common knowledge or customary techniques in the art that are not disclosed herein.

[0292] The above content is only a preferred exemplary embodiment of the present application and is not intended to limit the implementation scheme of the present application. Ordinary technicians in this field can easily make corresponding changes or modifications based on the main concept and spirit of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection required by the claims.

Claims

1. A text rendering method, characterized in that: Applied to the server, including: Obtaining a rendering request for the text to be rendered, the rendering request including a text requirement and an effect requirement; Generate rendering parameters of the text to be rendered based on the text requirement and the effect requirement; Acquire a target canvas for displaying the text to be rendered, and determine a layout of the text to be rendered in the target canvas according to the rendering parameters; The text to be rendered is rendered in the target canvas using at least one rendering method according to the layout.

2. The method according to claim 1, characterized in that The layout includes the position and display content of the text to be rendered in the target canvas; The rendering of the text to be rendered in the target canvas using at least one rendering method according to the layout includes: Acquire a visualization area of ​​the target canvas and background information corresponding to the visualization area; Determining visualization content of the text to be rendered according to the position and display content of the text to be rendered in the target canvas and the visualization area, wherein the visualization content is used to represent content displayed in the visualization area; The visualization area is rendered based on the background information corresponding to the visualization area and the visualization content of the text to be rendered, so as to render the visualization content of the text to be rendered into the visualization area.

3. The method according to claim 2, characterized in that The determining the visualization content of the text to be rendered according to the position and display content of the text to be rendered in the target canvas and the visualization area includes: Determining a bounding box of the text to be rendered based on a position and display content of the text to be rendered in the target canvas; comparing the bounding box with the visualization area to determine an overlapping area between the bounding box and the visualization area; The visual content is determined according to display content of the text to be rendered in the overlapping area.

4. The method according to claim 1, characterized in that: The layout includes the position, display content and area occupied by the text to be rendered in the target canvas; and the rendering of the text to be rendered in the target canvas using at least one rendering method according to the layout includes: Acquire a local rendering area in the target canvas and background information corresponding to the local rendering area according to the position of the text to be rendered in the target canvas and the size of the area occupied by the text; Using other areas of the target canvas except the local rendering area as non-rendering areas; Rendering the local rendering area based on background information corresponding to the local rendering area and display content of the text to be rendered to obtain a target area; The target area and the non-rendering area are synthesized to obtain a rendering result for the rendering request.

5. The method according to claim 4, characterized in that The rendering of the local rendering area based on the background information corresponding to the local rendering area and the display content of the text to be rendered to obtain a target area includes: Obtaining a size relationship between the local rendering area and a canvas area corresponding to the target canvas; If the size relationship satisfies a preset relationship, the local rendering area is rendered based on the background information corresponding to the local rendering area and the display content of the text to be rendered to obtain a target area.

6. The method according to claim 1, characterized in that The layout includes the position and display content of the text to be rendered in the plurality of target canvases; Rendering the text to be rendered in the target canvas according to the layout using at least one rendering method includes: Determining a current sequence frame to be rendered according to the position and display content of the text to be rendered in the current target canvas and background information corresponding to the current target canvas; If the current sequence frame to be rendered is different from the previous sequence frame to be rendered, the current sequence frame to be rendered and the previous sequence frame to be rendered are stored; if the current sequence frame to be rendered is the same as the previous sequence frame to be rendered, the current sequence frame to be rendered and the previous sequence frame to be rendered are both used as stay frames; Rendering the stored sequence frames to be rendered to obtain a dynamic frame, extracting a stay frame, and rendering the extracted stay frame to obtain a static frame; The static frames are multiplexed, and the multiplexed static frames and the dynamic frames are synthesized according to a sequence of frames to obtain a rendering result for the rendering request.

7. The method according to claim 6, characterized in that The method further comprises: Calculating the similarity between the rendering content of the current sequence frame to be rendered and the rendering content of the previous sequence frame to be rendered, and determining whether the current sequence frame to be rendered is the same as the previous sequence frame to be rendered according to the similarity; or, Obtaining the frame times corresponding to the current sequence of frames to be rendered and the previous sequence of frames to be rendered respectively; If the acquired frame time belongs to a preset frame time range, it is determined that the current sequence of frames to be rendered is the same as the previous sequence of frames to be rendered, wherein the preset frame time range is determined based on the rendering parameters.

8. The method according to claim 1, characterized in that The text requirement includes a font requirement and a text content requirement; the rendering parameters of the text to be rendered are generated based on the text requirement and the effect requirement, including: Searching for a target font resource corresponding to the font requirement based on a locally stored font library, and determining text parameters of the text to be rendered based on the target font resource and the text content requirement; Determine the effect parameters corresponding to the effect requirement based on the art effect library used on the client; The rendering parameters of the text to be rendered are generated based on the text parameters and the effect parameters.

9. The method according to claim 8, characterized in that Before searching the target font resource corresponding to the font requirement based on the locally stored font library, the method further includes: Preload preset basic font resources; When the server is started, a custom font configuration is obtained, and a custom font resource corresponding to the custom font configuration is preloaded; The font library is generated based on the preloaded basic font resources and the custom font resources.

10. The method according to claim 8, characterized in that The searching for a target font resource corresponding to the font requirement based on the locally stored font library includes: During the operation of the server, searching whether the target font resource exists in the font library; If the target font resource does not exist in the font library, obtaining configuration information corresponding to the target font resource; Updating a pre-established font dictionary according to the configuration information, wherein the font dictionary is used to maintain a mapping relationship between font names; The target font resource is preloaded according to the configuration information and the updated font dictionary to update the target font resource into the font library, and the target font resource is searched based on the updated font library.

11. The method according to any one of claims 1 to 10, characterized in that: Before obtaining the rendering request for the text to be rendered, the method further includes: constructing a rendering interceptor; After obtaining the rendering request for the text to be rendered, the method further includes: Verifying key information in the rendering request through a rendering interceptor, and recording the rendering request to a log file after the key information is verified; If it is determined based on the log file that there is a historical request that is the same as the rendering request, a rendering result corresponding to the historical request is obtained, and the rendering result is used as the rendering result of the rendering request.

12. The method according to any one of claims 1 to 10, characterized in that: After rendering the text to be rendered according to the at least one rendering mode, the method further includes: Recording the link status of the rendering request in a request log, and recording the rendering process of the text to be rendered in a rendering log; A unique identifier is assigned to the request log and the rendering log, and the request log and the rendering log are associated according to the unique identifier to form a log file for the rendering request.

13. A text rendering device, characterized in that: include: An acquisition module, used to acquire a rendering request for the text to be rendered, wherein the rendering request includes a text requirement and an effect requirement; A generating module is further used to generate rendering parameters of the text to be rendered based on the text requirement and the effect requirement; A determination module, used for acquiring a target canvas for displaying the text to be rendered, and determining a layout of the text to be rendered in the target canvas according to the rendering parameters; A rendering module is used to render the text to be rendered in the target canvas according to the layout using at least one rendering method.

14. An electronic device, characterized in that: include: one or more processors; A storage device for storing one or more programs, which, when executed by the one or more processors, enables the electronic device to execute the method according to any one of claims 1 to 12.

15. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor of an electronic device, the electronic device executes the method according to any one of claims 1 to 12.

16. A computer program product, characterized in that The computer program product comprises a computer program, wherein the computer program is stored in a computer-readable storage medium, and a processor of an electronic device reads and executes the computer program from the computer-readable storage medium, so that the electronic device executes the method according to any one of claims 1 to 12.

Citation Information

Cited By

  • Aggregation processing method and device of real-time trajectory data, electronic equipment and storage medium

    CN120316363A

  • Dynamic wordart generation method based on SVG hierarchical rendering and Canvas font calculation and related equipment

    CN121349574A