Text processing method, device, equipment and medium

By segmenting and drawing the display text, the high consumption of terminal performance when processing complex special effect text based on Textview control is solved, and lower performance overhead and more efficient text display is achieved.

CN113033147BActive Publication Date: 2025-02-25DOUYIN VISION CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202110325457.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-26
Publication Date
2025-02-25
Estimated Expiration
2041-03-26

AI Technical Summary

Technical Problem

Based on the inherent functional logic of the Textview control, the terminal performance is consumed more seriously when processing complex special effect text.

Method used

By obtaining multiple display attribute sets corresponding to the text to be displayed, the text is divided, and multiple text segments are obtained. The characters in each text segment have the same display attributes, and then each text segment is used as the processing object for drawing, and finally the results of each drawing processing are spliced ​​together.

Benefits of technology

It reduces the consumption of device resources during text drawing processing and reduces the performance overhead of text display in the device.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113033147B_ABST
    Figure CN113033147B_ABST
Patent Text Reader

Abstract

The disclosed embodiments relate to a text processing method, apparatus, device and medium, wherein the method comprises: obtaining at least two display attribute sets corresponding to the text to be displayed; each display attribute set corresponds to characters with the same display effect; segmenting the text to be displayed according to the characters corresponding to each display attribute set to obtain at least two text segments; wherein the characters in each text segment correspond to the same display attribute set; based on the display attribute set corresponding to the characters in each text segment, drawing processing is performed on each text segment to obtain a drawing processing result corresponding to each text segment; according to the position of each character in each text segment in the text to be displayed, each drawing processing result is spliced ​​to obtain a text drawing result. The disclosed embodiments can reduce the consumption of device resources in the text drawing process and reduce the performance overhead of text display in the device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of text processing technology, and in particular to a text processing method, device, equipment and medium. Background Art

[0002] Currently, the display and interactive processing of text in Android applications are usually implemented using Android native controls (Textview). As the functions of applications expand, the display effects of text in applications are becoming more and more diverse.

[0003] However, based on the inherent functional logic of the Textview control, when processing complex special effects text, the consumption of terminal performance is quite serious. Summary of the invention

[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the embodiments of the present disclosure provide a text processing method, apparatus, device and medium.

[0005] In a first aspect, an embodiment of the present disclosure provides a text processing method, including:

[0006] Obtain at least two display attribute sets corresponding to the text to be displayed; wherein each display attribute set corresponds to characters with the same display effect;

[0007] Segment the text to be displayed according to the characters corresponding to each display attribute set to obtain at least two text segments; wherein the characters in each text segment correspond to the same display attribute set;

[0008] Based on the display attribute set corresponding to the characters in each text segment, each text segment is drawn to obtain a drawing result corresponding to each text segment;

[0009] According to the position of each character in each text segment in the text to be displayed, each drawing processing result is spliced ​​to obtain a text drawing result.

[0010] In a second aspect, the present disclosure also provides a text processing device, including:

[0011] A display attribute acquisition module, used to acquire at least two display attribute sets corresponding to the text to be displayed; wherein each display attribute set corresponds to characters with the same display effect;

[0012] A text segmentation module, used to segment the text to be displayed according to the characters corresponding to each display attribute set, to obtain at least two text segments; wherein the characters in each text segment correspond to the same display attribute set;

[0013] A drawing processing module, used to perform drawing processing on each text segment based on a display attribute set corresponding to the characters in each text segment, and obtain a drawing processing result corresponding to each text segment;

[0014] The drawing result splicing module is used to splice the various drawing processing results according to the positions of the various characters in each text segment in the text to be displayed, so as to obtain the text drawing result.

[0015] In a third aspect, an embodiment of the present disclosure further provides an electronic device, comprising a memory and a processor, wherein: a computer program is stored in the memory, and when the computer program is executed by the processor, the electronic device implements any text processing method provided by the embodiment of the present disclosure.

[0016] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the computing device implements any text processing method provided by the embodiment of the present disclosure.

[0017] The technical solution provided by the disclosed embodiment has at least the following advantages over the prior art: in the disclosed embodiment, the text to be displayed is segmented according to the characters corresponding to each display attribute set corresponding to the text to be displayed, so as to obtain multiple text segments, and the characters in one text segment have the same display attributes, and then each text segment is taken as a processing object to perform drawing processing, and finally the various drawing processing results are spliced ​​to obtain a text drawing processing result corresponding to the complete text to be displayed. Compared with the case where the text to be displayed is processed as a whole object, the consumption of device resources in the text drawing processing process is reduced, and the performance overhead of text display in the device is reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0019] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0020] Figure 1 A flowchart of a text processing method provided by an embodiment of the present disclosure;

[0021] Figure 2 A flowchart of another text processing method provided by an embodiment of the present disclosure;

[0022] Figure 3 A structural schematic diagram of a text processing device provided by an embodiment of the present disclosure;

[0023] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0024] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.

[0025] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0026] Figure 1 The flowchart of a text processing method provided in the embodiment of the present disclosure can be applied to the case of how to draw text during the text display process. The text processing method can be executed by a text processing device, which can be implemented by software and / or hardware and can be integrated on any electronic device with computing capabilities, such as a mobile terminal, a computer, and a tablet computer.

[0027] like Figure 1 As shown, the text processing method provided by the embodiment of the present disclosure may include:

[0028] S101. Obtain at least two display attribute sets corresponding to the text to be displayed; wherein each display attribute set corresponds to characters having the same display effect.

[0029] The display attribute is used to describe the display effect of each character in the text to be displayed. The display attribute may include font, font size, color, style and special effects, etc. At least two display attribute sets corresponding to the text to be displayed are pre-deployed in the electronic device. Exemplarily, the attributes of each control on the page are pre-defined in the page layout file of an application on the electronic device. The control attributes include a display attribute set corresponding to the text to be displayed on the control. Assuming that the text to be displayed on control A includes 10 characters, the display attribute set corresponding to the first 5 characters is: black font, bold, size 16, luminous style, and the display attribute set corresponding to the last 5 characters is red font, not bold, size 12, underlined. After the display text is displayed, drawn and displayed using this solution, the user can see the display effects corresponding to the first 5 characters and the last 5 characters respectively.

[0030] Optionally, before obtaining at least two display attribute sets corresponding to the text to be displayed, the text processing method provided by the embodiment of the present disclosure further includes: determining the attributes of the control used to carry the text to be displayed, and caching the attributes of the control to obtain at least two display attribute sets from the cached control attributes. That is, during the text processing process, the electronic device can first load the page layout file into the memory, then parse the control attributes from the page layout file, and cache the control attributes; after obtaining the text to be displayed on the control from the server or the network, the required display attribute set can be directly obtained from the cached control attributes, thereby speeding up the acquisition efficiency of the text display attributes.

[0031] The text to be displayed can be any text that can be displayed on the page, such as a title, a body, an information flow, etc. Based on different page display requirements, the text to be displayed can be specifically determined.

[0032] S102: Segment the text to be displayed according to the characters corresponding to each display attribute set to obtain at least two text segments; wherein the characters in each text segment correspond to the same display attribute set.

[0033] After the text to be displayed is segmented according to the characters corresponding to the display attribute set, the characters in each text segment correspond to the same display attribute set, that is, have the same display effect. The number of characters included in each text segment is not specifically limited in the embodiment of the disclosure.

[0034] Exemplarily, at least one preset character length corresponding to each display attribute set may be first determined; then, the display text may be segmented according to the characters determined by each preset character length to obtain at least two text segments. For example, if one display attribute set defines the display attributes corresponding to the first x1 characters, and another display attribute set defines the display attributes corresponding to the last x2 characters, the display text may be segmented in such a way that the first x1 characters and the last x2 characters are each regarded as a text segment.

[0035] By segmenting the text to be displayed according to the preset character length corresponding to the display attribute set, characters corresponding to the same display attribute can be divided into the same text segment, and then these characters can be uniformly drawn, thereby improving the drawing processing efficiency.

[0036] Furthermore, the text to be displayed is segmented according to the characters determined by each preset character length to obtain at least two text segments, including: according to each preset character length, the text to be displayed is segmented from the character starting position of the text to be displayed in sequence to obtain at least two text segments. By segmenting the text to be displayed in sequence, the text mis-segmentation operation can be reduced. At the same time, in the process of sequentially segmenting the text, each text segment can also be numbered and marked in sequence, and then after completing the drawing process of each text segment, the various drawing processing results can be spliced ​​in sequence according to the number to improve the splicing efficiency.

[0037] S103: Based on the display attribute set corresponding to the characters in each text segment, each text segment is subjected to drawing processing to obtain a drawing processing result corresponding to each text segment.

[0038] Specifically, based on the display attribute set corresponding to the characters in each text segment, a static layout function can be used to draw each text segment to obtain a drawing result corresponding to each text segment. The static layout function can be used to draw and display multiple lines of text or complex text including multiple display attributes. In the disclosed embodiment, the static layout function is used to draw each text segment. Compared with the dynamic layout function in the TextView control that performs an overall processing on the displayed text, the consumption of device resources during the text drawing process can be reduced, and the performance overhead of text display in electronic devices can be reduced.

[0039] It should be noted that the text to be displayed in the embodiment of the present disclosure corresponds to at least two display attribute sets, that is, the text to be displayed is a text with personalized text display requirements, or called spannable text. In the processing logic of the Textview control, the spannable text is treated as a whole and drawn using a dynamic layout function. The consumption of device resources during the processing is very large, which affects the operation of the device. However, this solution divides the spannable text and then uses a static layout function to draw each text segment. On the basis of ensuring the final text display effect, it can also reduce the consumption of device resources and reduce device performance overhead.

[0040] In addition, each drawing processing result can be cached so that when there is a drawing processing requirement that is the same as that of a processed text segment, the cached drawing processing result can be reused. For example, each drawing processing result is cached according to the correspondence between the drawing processing result and the text segment and the display attribute set. When processing a new text to be displayed, after the new text to be displayed is segmented, a query can be performed in the cache based on the new text segment and the display attribute set. If the same text segment and display attribute set are queried, the corresponding drawing processing result in the cache can be directly used as the drawing processing result of the current new text segment, thereby eliminating the operation of re-drawing the current new text segment, which helps to speed up the text drawing process.

[0041] If the system font of the device changes during the text processing, for example, the electronic device detects the user's system font modification operation or obtains the user's system font modification request, the cached drawing processing results are cleared, and each text segment is redrawn to cache new drawing processing results. Considering the situation where the font of the text to be displayed on any page of the electronic device is associated with the system font, the change of the system font will cause the font of the text to be displayed to change, and the display attribute set obtained during the text processing belongs to the display attribute before the system font changes, and the font attribute therein has become invalid. Therefore, it is necessary to clear the cached drawing processing results at this time, and update the font in the display attribute set according to the changed system font, and then redraw each text segment in the cache, cache the new drawing processing results, so that in the subsequent text processing process, if there is the same drawing processing requirement as the processed text segment, the cached new drawing processing results are reused. And if the drawing processing result of the newly cached text segment has not been displayed, the new drawing processing result can be directly displayed.

[0042] Optionally, in the process of obtaining the drawing processing result corresponding to each text segment, it also includes: determining the response event of each text segment, and establishing the corresponding relationship between each text segment and the respective response event. That is, in the embodiment of the present disclosure, it is supported to add a corresponding response event separately for each text segment in the text to be displayed. The response event may include but is not limited to a click event, a double-click event, a long press event, and a voice control event, etc. The response event may include a response function for a user touch operation (such as a single click, a double click, a long press, etc.) or a user voice and a set feedback operation. The feedback operation may be a page jump operation to jump to a specified page, a pop-up preset information or a preset dialog box, etc., which can be flexibly set according to business needs, and the embodiment of the present disclosure is not specifically limited. Taking a click event as an example, the click event includes a click response function for a user click operation and a set page jump operation. After the text is displayed, the user clicks on the text segment to which the click event has been added, and the electronic device will jump from the current text display page to the specified page.

[0043] Compared with the existing solution that can only add a touch event to the entire text to be displayed, this solution realizes the addition of touch events with text segments as processing objects, realizes the fine-grained application of touch events, expands the interactive operations supported by text, and improves the fun of text interaction.

[0044] S104 , according to the position of each character in each text segment in the text to be displayed, splice each drawing processing result to obtain a text drawing result.

[0045] That is, the character positions in the spliced ​​text drawing result correspond one-to-one to the character positions in the text to be displayed.

[0046] In the embodiment of the present disclosure, the text to be displayed is segmented according to the characters corresponding to each display attribute set corresponding to the text to be displayed, so as to obtain multiple text segments, and the characters in one text segment have the same display attributes. Then, each text segment is taken as a processing object and drawing processing is performed. Finally, the various drawing processing results are spliced ​​to obtain a text drawing processing result corresponding to the complete text to be displayed. Compared with the case where the text to be displayed is processed as a whole object, the consumption of device resources in the text drawing processing process is reduced, and the performance overhead of text display in the device is reduced.

[0047] Furthermore, the text processing method provided by the embodiment of the present disclosure also includes: in response to a display trigger operation (i.e., a display request), displaying the text drawing result; wherein the display trigger operation includes at least one of the following: a display page switching operation, a display page sliding operation, and a touch operation of a page display button. That is, in the embodiment of the present disclosure, the text drawing process and the text display process can be divided into two stages. After receiving the text to be displayed, the present solution can be used in advance to perform drawing processing on the text to be displayed (i.e., text pre-drawing), and the text drawing result can be cached. When the display trigger operation is detected, the text drawing result is displayed. Text pre-drawing helps to improve the text display efficiency. Of course, the text drawing result can also be displayed after the text drawing process is completed, which is not specifically limited by the embodiment of the present disclosure.

[0048] In one exemplary embodiment, in response to a display page switching operation triggered by a user, for example, switching from page A to page B, and displaying a text drawing result in page B.

[0049] Example 2: In response to a user's page display sliding operation (including sliding the page up and down or left and right), for example, a new page area is displayed, and a text drawing result is displayed in the new page area.

[0050] Example three: In response to a user's touch operation on a page display button (ie, for triggering a display request for text to be displayed), a text drawing result is displayed in the current page.

[0051] On the basis of the above technical solution, optionally, in the process of stitching together the various drawing processing results, the following is further included:

[0052] Determine a first text width occupied in total by the previously spliced ​​drawing processing results;

[0053] According to the first text width and the preset text line display width, the line break position of the characters in the subsequent splicing drawing processing result is determined to perform line break display on the characters in the subsequent splicing drawing processing result.

[0054] Among them, the preset text line display width (width) refers to the standard display width of the pre-set text line. The character line break position in the splicing process is determined according to the first text width and the preset text line display width, which can ensure the page display effect of the text to be displayed and avoid the phenomenon that some characters are blocked due to the large number of characters in each line during the text display process.

[0055] Furthermore, the text processing method provided by the embodiment of the present disclosure may also include:

[0056] Determine, according to a preset first margin, a display position of a text segment starting with the first character of the line in each text line;

[0057] According to the preset second margin, the display position of the text segment with the line end character as the termination character in each text line is determined.

[0058] Among them, the preset first margin can be used to determine the distance between the first character of each text line (i.e., the first character in the text line) and the page boundary that is perpendicular to the text line direction and closest to the first character of the line, and the preset second margin can be used to determine the distance between the end character of each text line (i.e., the last character in the text line) and the page boundary that is perpendicular to the text line direction and closest to the end character of the line.

[0059] For example, from the perspective of the page displayed on the terminal by the user, if the characters in the text line are arranged from left to right, that is, the first character of the line is at the leftmost side of the text line and the end character of the line is at the rightmost side of the text line, then the preset first margin may refer to the preset left margin, and the preset second margin may refer to the preset right margin; if the characters in the text line are arranged from right to left, that is, the first character of the line is at the rightmost side of the text line and the end character of the line is at the leftmost side of the text line, then the preset first margin may refer to the preset right margin, and the preset second margin may refer to the preset left margin.

[0060] Specifically, from the perspective of the page displayed on the terminal by the user, the preset left margin refers to the distance from the first character of each line of text to the left edge of the page, and the preset right margin refers to the distance from the last character of each line of text to the right edge of the page. For example, according to the preset left margin, the display position of the first text segment in the text to be displayed is first determined, and then based on the display position of the first text segment, the display position of the second text segment is determined in turn, and it is determined whether the total first text width occupied by the splicing result of the drawing processing results corresponding to the two text segments exceeds the preset text line display width. If it exceeds, the line break position of the characters in the second drawing processing result is determined based on the preset text line display width, so that the characters after the line break position are displayed in a new line, and at the same time, according to the preset right margin, the display position of the characters before the line break position is determined; if it does not exceed, based on the display position of the second text segment, the display position of the third text segment is continued to be determined, and at the same time, it is determined whether the total first text width occupied by the splicing result of the drawing processing results corresponding to the three text segments exceeds the preset text line display width. If it exceeds, the line break position of the characters in the third drawing processing result is determined based on the preset text line display width, that is, the above operations are repeated until the processing of the entire text to be displayed is completed, and finally the effect of positionally displaying the text drawing results according to the preset left margin and the preset right margin is achieved.

[0061] In addition, for the two page boundaries parallel to the text line direction, the distance between the first text line in the text to be displayed and the nearest page boundary (the distance between each character in the first line of text and the nearest page boundary is equal), and the distance between the last text line and the nearest page boundary (the distance between each character in the last line of text and the nearest page boundary is equal). Exemplarily, if the text lines in the text to be displayed are arranged from top to bottom, the distance between the first text line in the text to be displayed and the nearest page boundary is the preset top margin, and the distance between the last text line in the text to be displayed and the nearest page boundary is the preset bottom margin; if the text lines in the text to be displayed are arranged from bottom to top, the distance between the first text line in the text to be displayed and the nearest page boundary is the preset bottom margin, and the distance between the last text line in the text to be displayed and the nearest page boundary is the preset top margin.

[0062] The disclosed embodiment supports determining the display position of a text segment according to a preset margin, thereby ensuring that the final display effect of the text meets the display requirements of the page margin and guarantees the text display effect.

[0063] Figure 2 This is a flowchart of another text processing method provided by the embodiment of the present disclosure, which is further optimized and expanded based on the above technical solution and can be combined with the above optional implementation methods. Figure 2 As shown, the text processing method provided by the embodiment of the present disclosure may include:

[0064] S201. Obtain at least two display attribute sets corresponding to the text to be displayed; wherein each display attribute set corresponds to characters having the same display effect.

[0065] S202: Segment the text to be displayed according to the characters corresponding to each display attribute set to obtain at least two text segments; wherein the characters in each text segment correspond to the same display attribute set.

[0066] S203 : Segment the display background area of ​​the text to be displayed based on the character segmentation length of the text to be displayed and the preset text line display height to obtain background segments corresponding to each text segment.

[0067] During the background segmentation process, the height of the background segment can be adaptively determined based on the preset text line display height (referring to the pre-set standard display height of the text line), and the width of the background segment can be determined based on the character segmentation length (i.e., the width of the corresponding text segment). The display background can be a preset color or a preset image. The entire text to be displayed matches the display background area, and through background segmentation, it can be achieved to match the corresponding background segment for each text segment. For example, text segment A corresponds to a red background segment, and text segment B corresponds to a yellow background segment; or, text segment C uses an image area showing a blue sky as a background segment, and text segment D uses an image area showing a green mountain as a background segment, etc.

[0068] S204: Based on the display attribute set corresponding to the characters in each text segment, each text segment is subjected to drawing processing to obtain a drawing processing result corresponding to each text segment.

[0069] S205: Combine the background segment corresponding to each text segment and the drawing processing result.

[0070] For each text segment, its corresponding background segment and drawing processing result can be combined together as the processing result of the text segment. In the process of splicing the various drawing processing results, the background segment is also involved in the splicing to maintain the matching of the background segment and the drawing processing result. That is, in the text display process, it can be ensured that each drawing processing result uses its corresponding background segment as the display background.

[0071] In addition, the combined processing results of the background fragment and the drawing processing results corresponding to each text segment can also be cached. In the process of processing new text to be displayed, if there is a drawing processing requirement (that is, the text segment content is the same, the display attributes are the same, and the required background fragment is the same), the cached combined processing results can be reused.

[0072] S206 , according to the position of each character in each text segment in the text to be displayed, the background segment corresponding to each text segment and the combination result of the drawing processing result are spliced ​​to obtain a text drawing result.

[0073] In the embodiment of the present disclosure, the text to be displayed is segmented and the display background area is segmented according to multiple display attribute sets corresponding to the text to be displayed, and then each text segment is taken as a processing object for drawing processing. Finally, each drawing processing result and each background segment are spliced ​​together to obtain a text drawing processing result corresponding to the complete text to be displayed. Compared with the case where the text to be displayed is processed as a whole object, the consumption of device resources in the text drawing process is reduced, and the performance overhead of text display in the device is reduced.

[0074] Furthermore, in the disclosed embodiment, through background segmentation, each text segment independently corresponds to a background segment. If there is a need to update the background segment, such as changing the color of a specific background segment, etc., flexible modification can be achieved with high operability.

[0075] Figure 3 A structural diagram of a text processing device provided in an embodiment of the present disclosure can be applied to the case of how to draw text during text display. The text processing device can be implemented by software and / or hardware, and can be integrated on any electronic device with computing capabilities, such as a mobile terminal, a computer, and a tablet computer.

[0076] like Figure 3 As shown, the text processing device 300 provided in the embodiment of the present disclosure may include a display attribute acquisition module 301, a text segmentation module 302, a drawing processing module 303 and a drawing result splicing module 304, wherein:

[0077] The display attribute acquisition module 301 is used to acquire at least two display attribute sets corresponding to the text to be displayed; wherein each display attribute set corresponds to characters with the same display effect;

[0078] The text segmentation module 302 is used to segment the text to be displayed according to the characters corresponding to each display attribute set to obtain at least two text segments; wherein the characters in each text segment correspond to the same display attribute set;

[0079] A drawing processing module 303 is used to perform drawing processing on each text segment based on a display attribute set corresponding to the characters in each text segment, and obtain a drawing processing result corresponding to each text segment;

[0080] The drawing result splicing module 304 is used to splice the various drawing processing results according to the positions of the various characters in each text segment in the text to be displayed, so as to obtain a text drawing result.

[0081] Optionally, the text processing device 300 provided in the embodiment of the present disclosure further includes:

[0082] A drawing result display module, used for displaying the text drawing result in response to a display trigger operation;

[0083] The display triggering operation includes at least one of the following: a display page switching operation, a display page sliding operation, and a touch operation of a page display button.

[0084] Optionally, the drawing processing module 303 is specifically used for:

[0085] Based on the display attribute set corresponding to the characters in each text segment, each text segment is drawn using a static layout function to obtain a drawing result corresponding to each text segment.

[0086] Optionally, the text segmentation module 302 includes:

[0087] A character length determination unit, used to determine at least one preset character length corresponding to each display attribute set;

[0088] The text segment determination unit is used to segment the text to be displayed according to the characters determined by each preset character length to obtain at least two text segments.

[0089] Optionally, the text segment determination unit is specifically used for:

[0090] According to each preset character length, the text to be displayed is segmented in sequence from the starting position of the characters in the text to be displayed to obtain at least two text segments.

[0091] Optionally, the text processing device 300 provided in the embodiment of the present disclosure further includes:

[0092] A first text width determination module, used to determine a first text width occupied in total by the previously spliced ​​drawing processing results;

[0093] The line break position determination module is used to determine the line break position of the characters in the post-joined drawing processing result according to the first text width and the preset text line display width, so as to perform line break display on the characters in the post-joined drawing processing result.

[0094] Optionally, the text processing device 300 provided in the embodiment of the present disclosure further includes:

[0095] A first display position determination module, used to determine the display position of the text segment with the first character of the line as the starting character in each text line according to a preset first margin;

[0096] The second display position determination module is used to determine the display position of the text segment with the line end character as the termination character in each text line according to the preset second margin.

[0097] Optionally, the text processing device 300 provided in the embodiment of the present disclosure further includes:

[0098] A background segmentation module, used to segment the display background area of ​​the text to be displayed based on the character segmentation length of the text to be displayed and the preset text line display height, to obtain background segments corresponding to each text segment;

[0099] A combination processing module, used for combining the background segment corresponding to each text segment and the drawing processing result;

[0100] Accordingly, the drawing result splicing module 304 is specifically used for:

[0101] According to the position of each character in each text segment in the text to be displayed, the background segment corresponding to each text segment and the combination result of the drawing processing result are spliced ​​to obtain the text drawing result.

[0102] Optionally, the text processing device 300 provided in the embodiment of the present disclosure further includes:

[0103] The response event determination module is used to determine the response event of each text segment and establish a corresponding relationship between each text segment and its respective response event.

[0104] Optionally, the text processing device 300 provided in the embodiment of the present disclosure further includes:

[0105] The drawing result cache module is used to cache each drawing processing result so that when there is a drawing processing requirement that is the same as that of the processed text segment, the cached drawing processing result can be reused.

[0106] Optionally, the text processing device 300 provided in the embodiment of the present disclosure further includes:

[0107] The cache clearing module is used to clear the cached drawing processing results if the system font of the device changes during the text processing process, and re-draw each text segment to cache new drawing processing results.

[0108] Optionally, the text processing device 300 provided in the embodiment of the present disclosure further includes:

[0109] The control attribute determination module is used to determine the attributes of the control used to carry the text to be displayed, and cache the attributes of the control to obtain at least two display attribute sets from the cached control attributes.

[0110] The text processing device provided in the embodiment of the present disclosure can execute any text processing method provided in the embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method. The contents not described in detail in the embodiment of the device of the present disclosure can refer to the description in any method embodiment of the present disclosure.

[0111] Figure 4A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure is used to exemplify an electronic device that implements the text processing method provided in an embodiment of the present disclosure. The electronic device in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, smart home devices, wearable electronic devices, servers, etc. Figure 4 The electronic device shown is only an example and should not bring any limitation to the functions and occupation scope of the embodiments of the present disclosure.

[0112] like Figure 4 As shown, the electronic device 400 includes one or more processors 401 and a memory 402 .

[0113] The processor 401 may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 400 to perform desired functions.

[0114] The memory 402 may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on a computer-readable storage medium, and the processor 401 may run the program instructions to implement the text processing method provided by the embodiment of the present disclosure, and may also implement other desired functions. Various contents such as input signals, signal components, noise components, etc. may also be stored in the computer-readable storage medium.

[0115] Among them, the text processing method provided by the embodiment of the present disclosure may include: obtaining at least two display attribute sets corresponding to the text to be displayed; wherein each display attribute set corresponds to characters with the same display effect; according to the characters corresponding to each display attribute set, the text to be displayed is segmented to obtain at least two text segments; wherein the characters in each text segment correspond to the same display attribute set; based on the display attribute set corresponding to the characters in each text segment, each text segment is drawn to obtain a drawing processing result corresponding to each text segment; according to the position of each character in each text segment in the text to be displayed, each drawing processing result is spliced ​​to obtain a text drawing result. It should be understood that the electronic device 400 can also execute other optional implementation schemes provided by the embodiment of the method of the present disclosure.

[0116] In one example, the electronic device 400 may further include: an input device 403 and an output device 404, and these components are interconnected via a bus system and / or other forms of connection mechanisms (not shown).

[0117] In addition, the input device 403 may also include, for example, a keyboard, a mouse, and the like.

[0118] The output device 404 can output various information to the outside, including the determined distance information, direction information, etc. The output device 404 can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, and the like.

[0119] Of course, to simplify, Figure 4 Only some of the components related to the present disclosure in the electronic device 400 are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application situations, the electronic device 400 may also include any other appropriate components.

[0120] In addition to the above methods and devices, the embodiments of the present disclosure may also be a computer program product, which includes computer program instructions. When the computer program instructions are executed by a processor, the computing device implements any text processing method provided by the embodiments of the present disclosure.

[0121] The computer program product may be written in any combination of one or more programming languages ​​to write program code for performing the operations of the disclosed embodiments, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user electronic device, partially on the user electronic device, as a separate software package, partially on the user electronic device and partially on a remote electronic device, or entirely on a remote electronic device.

[0122] In addition, the embodiments of the present disclosure may also provide a computer-readable storage medium on which computer program instructions are stored. When the computer program instructions are executed by a processor, the computing device implements any text processing method provided by the embodiments of the present disclosure.

[0123] Among them, the text processing method provided by the embodiment of the present disclosure may include: obtaining at least two display attribute sets corresponding to the text to be displayed; wherein each display attribute set corresponds to characters with the same display effect; according to the characters corresponding to each display attribute set, the text to be displayed is segmented to obtain at least two text segments; wherein the characters in each text segment correspond to the same display attribute set; based on the display attribute set corresponding to the characters in each text segment, each text segment is drawn to obtain a drawing processing result corresponding to each text segment; according to the position of each character in each text segment in the text to be displayed, each drawing processing result is spliced ​​to obtain a text drawing result. It should be understood that when the computer program instructions are executed by the processor, they can also enable the computing device to implement other optional implementation schemes provided by the embodiment of the method of the present disclosure.

[0124] Computer readable storage media can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

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

[0126] The above are only specific embodiments of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to these embodiments herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A text processing method, characterized in that: include: Acquire at least two display attribute sets corresponding to the text to be displayed; wherein each display attribute set corresponds to characters having the same display effect, and acquiring the at least two display attribute sets comprises: loading a page layout file, parsing the control attributes of each control from the page layout file and caching the control attributes, and after acquiring the text to be displayed on the control, acquiring the control attributes of the control used to carry the text to be displayed from the cached control attributes, and acquiring the at least two display attribute sets from the control attributes; Segment the text to be displayed according to the characters corresponding to each display attribute set to obtain at least two text segments; wherein the characters in each text segment correspond to the same display attribute set; Segmenting the display background area of ​​the text to be displayed based on the character segmentation length of the text to be displayed and the preset text line display height to obtain background segments corresponding to each text segment; Based on the display attribute set corresponding to the characters in each text segment, each text segment is drawn using a static layout function to obtain a drawing result corresponding to each text segment; Combine the background fragment and the drawing processing result corresponding to each text segment; According to the position of each character in each text segment in the text to be displayed, the background segment corresponding to each text segment and the combination result of the drawing processing result are spliced ​​to obtain a text drawing result; The method further comprises: Cache the text drawing result; In response to detecting a display triggering operation, the text drawing result is displayed in a page corresponding to the display triggering operation.

2. The method according to claim 1, characterized in that Also includes: In response to the display triggering operation, the text drawing result is displayed.

3. The method according to claim 1, characterized in that The text to be displayed is segmented according to the characters corresponding to each display attribute set to obtain at least two text segments, including: Determining at least one preset character length corresponding to each display attribute set; The text to be displayed is segmented according to the characters determined by each preset character length to obtain the at least two text segments.

4. The method according to claim 3, characterized in that The step of segmenting the text to be displayed according to the characters determined by each preset character length to obtain the at least two text segments includes: According to each preset character length, the text to be displayed is segmented in sequence from the starting position of the characters of the text to be displayed to obtain the at least two text segments.

5. The method according to claim 1, characterized in that: Also includes: Determine a first text width occupied in total by the previously spliced ​​drawing processing results; According to the first text width and the preset text line display width, the line break position of the characters in the subsequent splicing drawing processing result is determined to perform line break display on the characters in the subsequent splicing drawing processing result.

6. The method according to claim 5, characterized in that Also includes: Determine, according to a preset first margin, a display position of a text segment starting with the first character of the line in each text line; According to the preset second margin, the display position of the text segment with the line end character as the termination character in each text line is determined.

7. The method according to claim 1, characterized in that Also includes: Determine the response event of each text segment, and establish a corresponding relationship between each text segment and the respective response event.

8. The method according to claim 1, characterized in that Also includes: Each drawing processing result is cached so that when there is a drawing processing requirement that is the same as that of the processed text segment, the cached drawing processing result is reused.

9. The method according to claim 8, characterized in that Also includes: If the system font of the device changes during text processing, the cached drawing processing results are cleared, and each text segment is redrawn to cache new drawing processing results.

10. A text processing device, characterized in that: include: A display attribute acquisition module, used to acquire at least two display attribute sets corresponding to the text to be displayed; wherein each display attribute set corresponds to characters with the same display effect; A text segmentation module, used to segment the text to be displayed according to the characters corresponding to each display attribute set, to obtain at least two text segments; wherein the characters in each text segment correspond to the same display attribute set; A background segmentation module, used to segment the display background area of ​​the text to be displayed based on the character segmentation length of the text to be displayed and a preset text line display height, to obtain background segments corresponding to each text segment; A drawing processing module, used to perform drawing processing on each text segment using a static layout function based on a display attribute set corresponding to characters in each text segment, to obtain a drawing processing result corresponding to each text segment; A combination processing module, used for combining the background segment corresponding to each text segment and the drawing processing result; A drawing result splicing module is used to splice the background fragments corresponding to each text segment and the combination result of the drawing processing result according to the positions of each character in each text segment in the text to be displayed, so as to obtain a text drawing result; The device is also used for: Cache the text drawing result; In response to detecting a display triggering operation, displaying the text drawing result in a page corresponding to the display triggering operation; The display attribute acquisition module is further used for: Loading a page layout file, parsing the control properties of each control from the page layout file and caching the control properties, after obtaining the text to be displayed on the control, obtaining the control properties of the control used to carry the text to be displayed from the cached control properties, and obtaining the at least two display property sets from the control properties.

11. An electronic device, characterized in that: The electronic device comprises a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the electronic device implements the text processing method according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a computing device, the computing device implements the text processing method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Font processing method and device in chat application and electronic equipment

    CN109871161A

  • Long character string display method, system, storage medium and terminal

    CN111832250A

  • Image processing method and system, electronic equipment and storage medium

    CN112241303A

  • Method and device for solving problem of automatic line feed of Textview control

    CN112445551A