Text processing method, character processing method, device, storage medium and program product

By constructing width mapping data, the visual width of text is evaluated based on the glyph width of characters, which solves the problem of inconsistent character width descriptions under different fonts, realizes accurate evaluation and processing of text display width, and improves display effect.

CN121479074APending Publication Date: 2026-02-06HANGZHOU ALIBABA INT INTERNET IND CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511541332.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-24
Publication Date
2026-02-06

AI Technical Summary

Technical Problem

In existing technologies, estimating the actual display width of text on a display page based on the number of text characters is inaccurate, resulting in inaccurate processing results and easily leading to text character truncation or wasted display space.

Method used

By constructing width mapping data, the glyph width corresponding to each character is determined, and the visual width of the text is evaluated based on the glyph width. The description method of character width under different fonts is unified, and the relative character widths of different fonts are fused and processed to obtain the glyph width, which is then saved to the mapping data to support visual width calculation.

Benefits of technology

It improves the accuracy of evaluating the actual display width of text on the display page, ensures the feasibility and accuracy of visual width calculation, is applicable to different font environments, and reduces waste and truncation in text display.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121479074A_ABST
    Figure CN121479074A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a text processing method, a character processing method, equipment, a storage medium and a program product. The method comprises the steps of determining a to-be-processed first text; searching character pattern widths corresponding to characters included in the first text from width mapping data; the width mapping data comprises font widths corresponding to a plurality of characters respectively; the font width is obtained by fusing relative character widths of different fonts corresponding to the same character; the relative character width is obtained by calculating the reference character width of the reference character; determining a first visual width of the first text based on the font width; the first visual width is used for evaluating the page display width of the first text. According to the technical scheme provided by the embodiment of the invention, the accuracy of page display width evaluation of the text is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of Internet technology, and in particular to a text processing method, character processing method, device, storage medium, and program product. Background Technology

[0002] With the rapid development of internet technology, people can browse various text information and obtain the content they want through the display pages of terminal devices, which provides convenience for people's lives, work, study, entertainment and many other aspects.

[0003] Currently, in designing display control sizes or in text application scenarios where the display control needs to switch between displaying text in one language and text in another within the same page area, the actual display width of the text on the display page is usually estimated based on the number of characters contained in the text, in order to perform corresponding processing operations. However, this estimation method is inaccurate, leading to inaccurate processing results. Summary of the Invention

[0004] This application provides a text processing method, character processing method, device, storage medium, and program product to improve the accuracy of evaluating the actual display width of text on a display page.

[0005] Firstly, this application provides a text processing method, including: Determine the first text to be processed; The glyph widths corresponding to the characters included in the first text are found from the width mapping data; the width mapping data includes the glyph widths corresponding to multiple characters respectively; the glyph widths are obtained by merging the relative character widths of different fonts corresponding to the same character; the relative character widths are calculated based on the base character width of the base character; Based on the font width, a first visual width of the first text is determined; the first visual width is used to evaluate the page display width of the first text.

[0006] Secondly, this application provides a character processing method, including: Determine the character width for different fonts corresponding to multiple characters; Determine the base character and the width of the base character corresponding to different fonts; For any font, calculate the relative character width of any character relative to the baseline character width; The relative character widths of the same character corresponding to different fonts are merged to obtain the glyph width of the character; The multiple characters and their corresponding glyph widths are saved to width mapping data; the width mapping data is used to find the glyph widths corresponding to the characters included in the first text, the glyph widths are used to determine the first visual width of the first text, and the first visual width is used to evaluate the page display width of the first text.

[0007] Thirdly, this application provides a computing device, including a processing component and a storage component; The storage component stores a computer program; the computer program is invoked and executed by the processing component to implement the text processing method as described in the first aspect, or the character processing method as described in the second aspect.

[0008] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processing component, implements the text processing method as described in the first aspect, or the character processing method as described in the second aspect.

[0009] Fifthly, this application provides a computer program product, including computer program instructions, which, when executed by a processing component, implement the text processing method as described in the first aspect, or the character processing method as described in the second aspect.

[0010] In this embodiment, a first text to be processed can be determined, the glyph widths corresponding to the characters included in the first text can be found from the width mapping data, and the first visual width of the first text can be determined based on the glyph widths. By determining the first visual width of the first text based on the glyph widths corresponding to the characters included in the first text, a more accurate assessment of the actual display width of the text on the display page can be achieved. Compared with the method of assessing the page display width of the text based on the number of characters, the solution of this embodiment greatly improves the assessment accuracy.

[0011] Furthermore, by constructing width mapping data, technical support is provided for finding the glyph widths corresponding to the characters included in the first text, ensuring the smooth and efficient calculation of the first visual width of the first text. During the implementation of the width mapping data, by setting a base character and the base character widths of different fonts corresponding to the base character, the relative character width of any character is calculated relative to the base character width. This solves the problem of inconsistent character width descriptions under different fonts, unifies the width units corresponding to character widths in different fonts, and provides strong support for merging the relative character widths of the same character corresponding to different fonts to obtain the glyph width of the character. Moreover, by calculating the glyph width of the characters and saving it to the width mapping data, the calculation of the visual width can be made unaffected by the font, ultimately achieving a more accurate assessment of the actual display width. Therefore, regardless of whether the font of the first text to be processed is explicitly stated, the first visual width of the first text can be determined based on the glyph widths of the characters included in the first text, ensuring the feasibility of the first visual width calculation.

[0012] These or other aspects of this application will become more apparent in the following description of the embodiments. Attached Figure Description

[0013] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 A flowchart of one embodiment of a character processing method provided in this application is shown; Figure 2 A flowchart of one embodiment of a text processing method provided in this application is shown; Figure 3 A schematic diagram of a character comparison interface in a practical application is shown; Figure 4 This diagram illustrates the architecture of a system in a practical application. Figure 5 This invention provides a schematic diagram of the structure of one embodiment of a character processing apparatus. Figure 6 This invention provides a schematic diagram of the structure of one embodiment of a text processing apparatus. Figure 7 A schematic diagram of a computing device in a practical application is shown. Detailed Implementation

[0014] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments of this application and the corresponding drawings. Apparently, the described embodiments are only a part of the embodiments of this application, rather than all of them. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in this application without creative efforts fall within the scope of protection of this application.

[0015] It should be noted that in the case where the embodiments of this application involve user information, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the embodiments of this application are all information and data authorized by the user or fully authorized by all parties. Additionally, the collection, use, and processing of relevant data need to comply with relevant laws, regulations, and standards of relevant countries and regions, and corresponding operation entrances are provided for users to choose to authorize or reject. Moreover, various models (including but not limited to language models or large models) involved in this application comply with relevant laws and standards.

[0016] In addition, it should be noted that in the case where the embodiments of this application involve user interaction operations or trigger operations, the user interaction operations or trigger operations involved in the embodiments of this application include but are not limited to: interaction operations in various ways such as touch operations, gesture operations, voice operations, head movement operations, eye movement operations, etc.; among them, touch operations include but are not limited to: click operations, double-click operations, long-press operations, slide operations, pinch operations, or mouse hover operations, etc. Slide operations include but are not limited to: linear slides, curved slides, etc.

[0017] As described in the background art section, currently, it is usually based on the number of characters included in the text to evaluate the actual display width of the text on the display page, and corresponding processing operations are performed, such as allocating a larger display space for text with a larger number of characters. However, the inventors have found through research that the character widths of different characters, that is, the actual display widths occupied on the display page, are usually different. For example, the English word "Cancel" (6 characters) has a larger actual display width than "Illegal" (7 characters) and occupies more display space, while the Chinese phrase "确认选择" (4 characters) has approximately the same actual display width as the English word "Confirm" (7 characters) and occupies approximately the same display space. Therefore, this evaluation method is inaccurate, resulting in situations such as text character truncation or display space waste when the text is displayed on the page.

[0018] Therefore, in order to solve the above-mentioned technical problems, the inventors have proposed the technical solution of this application, including: determining the first text to be processed; finding the glyph width corresponding to the characters included in the first text from the width mapping data; the width mapping data includes the glyph width corresponding to multiple characters respectively; the glyph width is obtained by fusion processing based on the relative character width of the same character corresponding to different fonts; the relative character width is calculated based on the base character width of the base character; determining the first visual width of the first text based on the glyph width; the first visual width is used to evaluate the page display width of the first text.

[0019] The first visual width of the first text is determined based on the glyph width of the characters included in the first text. Based on the first visual width, a more accurate assessment of the actual display width of the text on the display page is achieved. Compared with the method of assessing the page display width of the text based on the number of characters, the solution of this application embodiment greatly improves the assessment accuracy.

[0020] Furthermore, by constructing width mapping data, technical support is provided for finding the glyph widths corresponding to the characters included in the first text, ensuring the smooth and efficient calculation of the first visual width of the first text. During the implementation of the width mapping data, by setting a base character and the base character widths of different fonts corresponding to the base character, the relative character width of any character is calculated relative to the base character width. This solves the problem of inconsistent character width descriptions under different fonts, unifies the width units corresponding to character widths in different fonts, and provides strong support for merging the relative character widths of the same character corresponding to different fonts to obtain the glyph width of the character. Moreover, by calculating the glyph width of the characters and saving it to the width mapping data, the calculation of the visual width can be made unaffected by the font, ultimately achieving a more accurate assessment of the actual display width. Therefore, regardless of whether the font of the first text to be processed is explicitly stated, the first visual width of the first text can be determined based on the glyph widths of the characters included in the first text, ensuring the feasibility of the first visual width calculation.

[0021] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0022] The technical solution of this application embodiment can be implemented based on width mapping data. The process of obtaining width mapping data is described below.

[0023] Figure 1This flowchart illustrates an embodiment of a character data processing method provided in this application. The system architecture to which this embodiment applies may include a server and a client. The client and server can establish a connection via a network, which may include various connection types, such as wired, wireless communication links, or fiber optic cables. The client can interact with the server via the network to send processing requests or receive processing results from the server.

[0024] The client can be a browser, an app (application), a web application such as an H5 (HyperText Markup Language 5) application, a mini-program (also known as a lightweight application), or a cloud application. The client can be deployed on electronic devices and depends on the device to run or on certain apps within the device. Electronic devices can have displays and support information browsing, such as personal mobile terminals like smartphones, tablets, personal computers, desktop computers, smart speakers, smartwatches, etc.

[0025] The server side can include servers that provide various services, such as servers that provide instant messaging or servers that provide conversion models.

[0026] It should be noted that the server can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. The server can also be a server in a distributed system, or a server combined with blockchain. The server can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology.

[0027] The technical solution of this embodiment can be executed by the server or by the client, and this application does not limit it in this regard.

[0028] It should be noted that the technical solutions of this application embodiment are applicable to a virtual network environment. The described users generally refer to "virtual users." Real users can register user accounts on the server through registration to obtain user identities in the network environment. The interaction between the server and the user can be implemented based on the user account. The corresponding data received or sent by the server to the user is also based on the user account. In fact, the user terminal corresponding to the user account receives or sends corresponding data to the generating server.

[0029] Figure 1 The character processing method shown may include the following steps: 101: Determine the character width of different fonts for multiple characters.

[0030] In this embodiment, character width refers to the actual display width occupied by the character on the display page, which has a fixed value and is independent of factors such as font size and screen resolution. Furthermore, the character width of the same character can differ depending on the font, and can be obtained from a common font database.

[0031] In a practical application, for example, the character widths of multiple characters corresponding to different fonts can be obtained from open-source font databases such as DejaVu (an open-source font based on the Bitstream Vera font family) and Liberation (an open-source font based on the TrueType standard).

[0032] 102: Determine the base character and the base character width for different fonts.

[0033] 103: For any font, calculate the relative character width of any character to the base character width.

[0034] Considering that character widths may be described differently in different fonts, such as using different units, a baseline character can be set for easier calculation. The character widths corresponding to this baseline character in different fonts can then be set as the baseline character widths for those fonts. Within the same font, the ratio between the character width of any character other than the baseline character and the character width of the baseline character in that font is taken as the relative character width for that character within that font.

[0035] In other words, for any font, the relative character width of the base character is the value 1, which represents 1 unit width. The relative character width of other characters is the ratio of the character width of the base character. If the ratio is 0.5, it represents 0.5 units of width; if the ratio is 1.2, it represents 1.2 units of width, and so on.

[0036] In a practical application, the character "M" can be set as the base character. The width of "M" in different fonts can be set to the base character width for each font, and its relative width in different fonts can be set to the value 1, representing 1 unit width. For example, for the font "Arial," if the ratio of the width of the character "A" to the width of the character "M" is 0.9, then the relative width of "A" in the font "Arial" is 0.9, representing 0.9 units of width. For the font "Calibri," if the ratio of the width of "A" to the width of the character "M" is 0.8, then the relative width of "A" in the font "Calibri" is 0.8, representing 0.8 units of width.

[0037] Of course, the above-mentioned base characters are merely illustrative examples and can be set to other characters or any characters according to actual needs. This application does not impose any restrictions on this.

[0038] 104: Merge the relative character widths of the same character in different fonts to obtain the character's glyph width.

[0039] As an optional implementation, the relative character widths of the same character across different fonts can be averaged to obtain the character's glyph width. In this case, the glyph width can refer to the average of the relative character widths of the character across different fonts. This can be used to characterize the actual display width of the character on the display page when a specific font is not explicitly specified, providing support for subsequent calculations of the text's visual width.

[0040] For the base character, since its relative character width in different fonts is always 1, its glyph width is also 1. For other characters besides the base character, the glyph width of each character can be the average of the relative character widths in the different fonts corresponding to that character. Taking the character "A" with two fonts, "Arial" and "Calibri", corresponding to relative character widths of 0.9 and 0.8 respectively, as an example, the glyph width of the character "A" is 0.85.

[0041] As an alternative implementation, the relative character widths of the same character corresponding to different fonts can be summed to obtain the glyph width of the character. In this case, the glyph width can refer to the sum of the relative character widths of the character corresponding to different fonts.

[0042] Of course, other fusion processing methods can be set according to actual needs, and this application does not impose any restrictions on this.

[0043] 105: Save multiple characters and their corresponding glyph widths to the width mapping data.

[0044] This width mapping data allows you to look up the glyph widths of the characters included in the first text, thus determining the first visual width of the first text based on the glyph widths. In a practical application, the width mapping data can be a width mapping table.

[0045] Optionally, the width mapping data can be compressed, and the compression result and character processing logic can be encapsulated in a character processing module. In a practical application, a base64 encoding tool can be used to compress the width mapping data to obtain compressed data.

[0046] As an optional implementation, the character processing module can provide a calling interface to support calls to related processing systems such as text processing and display control design to perform corresponding processing operations.

[0047] As an alternative implementation, the character processing module can be encapsulated in a programming language supported by the relevant processing system, such as Java (an object-oriented, cross-platform programming language), JavaScript (a lightweight, interpreted, or just-in-time compiled programming language), or Python (a high-level, interpreted, general-purpose programming language), so that it can be deployed in the corresponding processing system to perform the corresponding processing operations, realize multi-processing system and cross-processing system deployment, improve the applicability of width-mapped data, and enhance ease of use.

[0048] In this embodiment, the character widths of multiple characters corresponding to different fonts can be determined, a base character and the base character widths of the base character corresponding to different fonts can be determined, and for any font, the relative character width of any character relative to the base character width can be calculated. The relative character widths of the same character corresponding to different fonts are fused to obtain the glyph width of the character, and the glyph widths corresponding to multiple characters are saved to width mapping data. By constructing width mapping data, it is possible to support finding the glyph widths corresponding to the characters included in the first text, so as to determine the first visual width of the first text based on the glyph width. Based on the first visual width, a more accurate evaluation of the actual display width of the text on the display page can be achieved. Compared with the method of evaluating the page display width of the text based on the number of characters, the solution of this embodiment greatly improves the evaluation accuracy.

[0049] Furthermore, by setting a baseline character and the baseline character width for different fonts corresponding to that baseline character, the ratio of the character width of any character to the baseline character width is used as the relative character width for any font. This solves the problem of inconsistent character width descriptions across different fonts, unifies the width units for character widths in different fonts, and provides strong support for merging the relative character widths of the same character across different fonts to obtain the character's glyph width. Moreover, by calculating the glyph width of characters and saving it to width mapping data, the calculation of visual width is unaffected by the font, ultimately enabling a more accurate assessment of the actual display width. Therefore, regardless of whether the font of the first text is explicitly specified in subsequent processing requests, the first visual width of the first text can be determined based on the glyph width of the characters included in the first text, ensuring the feasibility of the first visual width calculation.

[0050] To improve the accuracy of subsequent text visual width calculations, the relative character widths of each character corresponding to different fonts can be saved together in the width mapping data. Therefore, in some embodiments, the above method may further include: The relative character widths of multiple characters corresponding to different fonts are saved to the width mapping data.

[0051] At this time, the width mapping data can be used to find the relative character width of the characters included in the first text corresponding to the first font when the first text is specified in the processing request, and the relative character width can be used to determine the first visual width of the first text; and to find the glyph width of the characters included in the first text when the first text is not specified in the processing request.

[0052] By saving the relative character widths of multiple characters corresponding to different fonts into the width mapping data, it is possible to find the relative character widths of the characters included in the first text corresponding to the font when the font of the first text is explicitly specified in subsequent processing requests, and determine the first visual width of the first text based on the relative character widths. This improves the accuracy of the calculation of the first visual width and the accuracy of the page display width of the first text.

[0053] The following describes the process of text processing based on width-mapped data.

[0054] Figure 2 A flowchart of another embodiment of a text processing method provided in this application.

[0055] In a practical application, the technical solution of this embodiment can be applied to the server. The server can deploy or call the character processing module through an interface to perform corresponding operations using the width mapping data encapsulated in the character processing module.

[0056] In another practical application, the technical solution of this embodiment can be applied to a client. The client can utilize a locally deployed character processing module or call the character processing module through an interface to perform corresponding operations using the width mapping data encapsulated in the character processing module.

[0057] Figure 2 The text processing method shown may include the following steps: 201: Identify the first text to be processed.

[0058] 202: Find the glyph width of the characters included in the first text from the width mapping data.

[0059] The width mapping data can include the glyph widths corresponding to multiple characters. These glyph widths are obtained by merging the relative character widths of different fonts corresponding to the same character. The relative character width of any character can be calculated based on its character width and the base character width of a reference character. The implementation of the width mapping data is as follows: Figure 1 The embodiments shown have been described in detail, and will not be repeated here.

[0060] 203: Determine the first visual width of the first text based on the character width.

[0061] In this embodiment, the first text may include at least one character, and the width of the glyph corresponding to each of the at least one character can be summed to obtain the first visual width of the first text.

[0062] The first visual width can be used to evaluate the page display width of the first text. Page display width can refer to the actual display width, that is, the actual width of the text when it is displayed on the page, and can be related to text display requirements such as font size and character spacing.

[0063] Specifically, as described above, the first visual width in this embodiment is obtained by summing the glyph widths corresponding to at least one character, and the glyph width is obtained by merging relative character widths. Therefore, the first visual width is also a relative value. Based on this, the first visual width can be converted into a real width value according to a preset proportional relationship, and then the actual display width corresponding to the first text can be determined based on the width value corresponding to the first visual width and the text display requirements.

[0064] For example, if the text display requirements include font size, the actual display width can be calculated by multiplying the width value corresponding to the first visual width with a preset ratio corresponding to the font size. Similarly, if the text display requirements include character spacing, the actual display width can be calculated by adding the width value corresponding to the first visual width with the corresponding spacing of the characters included in the first text, and so on.

[0065] Optionally, in practical applications, corresponding processing operations can also be performed based on the first visual width.

[0066] Based on the calculated first visual width, different processing operations can be performed in different practical application scenarios.

[0067] In a practical application, performing corresponding processing operations based on the first visual width may include: Based on the first visual width and in accordance with the text display requirements, determine the display size of the target display control corresponding to the first text.

[0068] The target display control may include, for example, an input box, a button, or a label. Text display requirements may include font size, character spacing, and the ratio between the actual width of the text displayed in the display control and the size of the display control. The display size of the target display control can be determined based on the page display width of the first text, according to the ratio between the actual width of the text displayed in the display control and the size of the display control.

[0069] Optionally, prior to this, the above method may also include: Obtain the text display requirements, which can be provided by the user.

[0070] In addition, after performing the corresponding processing operation, the above method may also include: Based on the display size of the target display control, a size prompt is generated and provided to the user so that the user can set the display size of the target display control on the display page according to the size prompt.

[0071] By combining text display requirements, the display size of the target display control corresponding to the first text is determined based on the first visual width. This improves the accuracy and rationality of the display size setting of display controls in page design scenarios involving display control size settings, thereby enhancing the text display effect of the display controls.

[0072] In addition, based on the given or calculated second visual width, and the visual difference information between the first and second visual widths, processing operations such as adjusting the first text and adjusting the display size of the target display control can be performed, which will be described in subsequent embodiments.

[0073] In this embodiment, the first text to be processed can be determined, the glyph widths corresponding to the characters included in the first text can be found from the width mapping data, and the first visual width of the first text can be determined based on the glyph widths. Based on the first visual width, a series of processing operations such as adjusting the first text and setting and adjusting the display size of display controls can be performed. By determining the first visual width of the first text based on the glyph widths corresponding to the characters included in the first text, a more accurate assessment of the actual display width of the text on the display page can be achieved. Compared to the method of assessing the page display width of text based on the number of characters, the solution of this embodiment greatly improves the accuracy of the assessment, thereby improving the accuracy of the processing results.

[0074] Furthermore, by constructing width mapping data, technical support is provided for finding the glyph widths corresponding to the characters included in the first text, ensuring the smooth and efficient calculation of the first visual width of the first text. During the implementation of the width mapping data, by setting a base character and the base character widths of different fonts corresponding to the base character, the relative character width of any character is calculated relative to the base character width. This solves the problem of inconsistent character width descriptions under different fonts, unifies the width units corresponding to character widths in different fonts, and provides strong support for merging the relative character widths of the same character corresponding to different fonts to obtain the glyph width of the character. Moreover, by calculating the glyph width of the characters and saving it to the width mapping data, the calculation of the visual width is unaffected by the font, ultimately achieving a more accurate assessment of the actual display width. Therefore, regardless of whether the font of the first text is explicitly stated in the processing request, the first visual width of the first text can be determined based on the glyph widths of the characters included in the first text, ensuring the feasibility of the first visual width calculation and thus ensuring the smooth execution of subsequent processing operations.

[0075] To further improve the accuracy of text visual width calculation, when the font corresponding to the first text is explicitly specified in the processing request, the text visual width can be calculated based on the relative character widths of the characters included in the text corresponding to that font. Therefore, in some embodiments, the width mapping data may also include the relative character widths of multiple characters corresponding to different fonts.

[0076] Based on this, the above method may also include: If the first font corresponding to the first text is specified in the processing request, the relative character width of the first font corresponding to the characters included in the first text is found from the width mapping data, and the first visual width of the first text is determined based on the relative character width.

[0077] Specifically, the first visual width of the first text can be obtained by summing the relative character widths of the characters included in the first text.

[0078] At this point, finding the glyph width corresponding to the characters included in a text from the width mapping data can include: If the first font corresponding to the first text is not specified in the processing request, the glyph width corresponding to the characters included in the first text is found from the width mapping data.

[0079] By explicitly specifying the font of the first text in the processing request, the relative character width of the characters included in the first text corresponding to the font is found from the width mapping data, and the first visual width of the first text is determined based on the relative character width. This further improves the accuracy of the first visual width calculation, which in turn helps to improve the accuracy of subsequent processing results.

[0080] In practical applications, the multiple characters included in the width mapping data can be characters of the first character type, and their glyph widths can be obtained by merging the relative character widths of different fonts. In addition, the text may also involve other types of characters, whose relative character widths are consistent across different fonts; therefore, their glyph widths can be set to a preset relative character width. Based on this, in some embodiments, the above method may further include: Identify the character types corresponding to the characters included in the first text.

[0081] Based on this, finding the glyph width corresponding to the characters included in the first text from the width mapping data can include: Find the glyph width of the character belonging to the first character type among the characters included in the first text from the width mapping data.

[0082] The above methods may also include: Determine the glyph width of the characters belonging to any second character type among the characters included in the first text; the glyph width of multiple characters of any second character type is a preset relative character width.

[0083] In this embodiment, the character type may include a first character type and at least one second character type. The character type corresponding to a character can be determined based on the character's identification information. Characters of different second character types have different glyph widths, while characters belonging to the same second character type have the same glyph width, which is the corresponding preset relative character width.

[0084] In a practical application, one type of second character can include CJK characters (characters used in Chinese, Japanese, and Korean), whose corresponding glyph width can be set to 1980, representing 1980 units of width. Another type of second character can include emojis (a special type of character in Unicode), whose corresponding glyph width can be set to 2000, representing 2000 units of width.

[0085] By prioritizing the identification of the character types corresponding to the characters included in the first text, and according to the character types corresponding to each character, the corresponding glyph width can be found from the width mapping data for characters of the first character type, while for characters of the second character type, the corresponding preset relative character width can be directly used as its glyph width, thereby improving the comprehensiveness and accuracy of glyph width determination.

[0086] The process of performing corresponding processing operations based on the first visual width is described in detail below. In some embodiments, determining the first text to be processed may include: In response to the processing request, determine the first text to be processed; The above methods may also include: In response to the processing request, a specific second visual width to be processed is determined.

[0087] Based on this, the corresponding processing operations performed according to the first visual width may include: Based on the visual difference information between the first visual width and the second visual width, perform the corresponding processing operation.

[0088] In this embodiment, the second visual width can be a given limit width for the first visual width of the first text, such as the width threshold corresponding to the first visual width, or it can be the visual width of another text, the maximum display width that the target display control corresponding to the first text can bear, etc., and there can be a variety of implementation methods.

[0089] Visual difference information refers to the width difference between a first visual width and a second visual width, which can be calculated by subtracting the visual widths of the two. Based on this visual difference information, corresponding adjustment operations can be performed. For example, if the second visual width is a given threshold of the first visual width, and the first visual width exceeds the second visual width, the first text and / or the second visual width can be adjusted to ensure the first visual width meets the visual width requirement. For instance, replacing at least one character in the first text or changing the language of the first text can reduce its first visual width so that it does not exceed the second visual width, thus meeting the visual width requirement. Alternatively, the second visual width can be increased so that the first visual width does not exceed the adjusted second visual width, thus meeting the visual width requirement. Furthermore, the first text can be adjusted simultaneously to reduce its first visual width and increase its second visual width, ensuring the first text meets the visual width requirement.

[0090] In a practical application, the second visual width can be the visual width of another text. For ease of description, it can be referred to as the second text. In some embodiments, determining the first text to be processed in response to a processing request may include: In response to the processing request, determine the first text and the second text to be processed.

[0091] In this embodiment, the first text can be in a first language, and the second text can be in a second language. The content of the first and second texts can be the same; for example, the first text could be "the world's best website," and the second text could be "the excellent website in the world." They convey the same information, but their descriptive languages ​​differ: the first text uses Chinese, and the second text uses English. Of course, the content of the first and second texts can also be different, and this application does not impose any restrictions on this.

[0092] Based on this, determining the second visual width to be processed may include: Find the glyph width corresponding to the characters included in the second text from the width mapping data; The second visual width of the second text is determined based on the character width.

[0093] The specific implementation of this process and Figure 2 The calculation process for the first visual width of the first text in the illustrated embodiment is the same and will not be repeated here.

[0094] At this point, based on the visual difference information between the first visual width and the second visual width, the corresponding processing operations can include: Based on the visual difference information between the first visual width and the second visual width, generate a first prompt message; or, based on the visual difference information, perform a text adjustment operation.

[0095] The first prompt information may include visual difference information to inform the user of the difference in visual width between the two texts. For example, the visual width of the first text is larger than that of the second text, and the difference between the two is 2.

[0096] Optionally, the first prompt may also include a text adjustment prompt to guide the user to perform a text adjustment operation. For example, if the visual width difference between the first and second texts is 2, the first prompt could be: "The visual width difference between the first and second texts is 2. Please adjust the first text so that the visual width difference is less than 1."

[0097] Alternatively, a corresponding text adjustment model can be used to automatically adjust the first text so that the difference in visual width between the two is less than 1, and so on.

[0098] By calculating the first visual width of the first text and the second visual width of the second text, a more accurate assessment of the actual display width of the first text on the display page is achieved based on the first visual width, and a more accurate assessment of the actual display width of the second text on the display page is achieved based on the second visual width. Then, based on the visual difference information between the first and second visual widths, a first prompt message is generated to inform the user of the difference in visual width, or to prompt the user to perform a text adjustment operation, or to automatically perform a text adjustment operation using a conversion model, thereby improving the adaptability between the actual display widths of texts in different languages ​​and improving the display effect of texts in different languages.

[0099] In a practical application, the first text and the second text can be provided by the user. Therefore, in some embodiments, determining the first text and the second text to be processed in response to a processing request may include: Provides a character comparison interface; The system detects text input operations in the character comparison interface, generates a processing request, and determines the first and second text input.

[0100] Based on this, after generating the first prompt message, the above method may further include: The first prompt message is displayed on the character comparison interface.

[0101] The first prompt information may include visual difference information and text adjustment prompt information to prompt the user to perform text adjustment operations. Optionally, the first prompt information may also include information such as the first visual width and number of characters of the first text, and the second visual width and number of characters of the second text.

[0102] Optionally, text input operations in the character comparison interface can be detected, and information such as the visual width and number of characters of the input text can be calculated and displayed in real time, so that users can stop the input operation in time.

[0103] For ease of understanding, Figure 3 This diagram illustrates a character comparison interface used in a real-world application. Figure 3 As shown, the character comparison interface displays a first text input component 301, a second text input component 302, and a prompt information display component 303. The first text input component 301 and the second text input component 302 can be implemented as text input boxes, supporting user input of first and second text. The prompt information display component 303 is implemented as a display box, used to display visual differences between the first and second text, text adjustment prompts, and other content. Optionally, the character comparison interface 30 may also display visual width limitation and character count display components, used to display the visual width and character count corresponding to the first and second texts respectively, for user viewing.

[0104] In a practical application, the first text can be obtained by converting the second text's second language into the first language using a conversion model. The conversion models involved in this application's embodiments, including the first, second, and third conversion models mentioned in the following embodiments, can all be language models (LMs) based on artificial intelligence. This application's embodiments do not limit the number of model parameters supported by the model, aiming to meet actual needs. The conversion model can be a deep learning model used to process and generate natural language text, implemented based on a neural network architecture, and pre-trained on large amounts of data.

[0105] In a practical application, this transformation model can include an encoder, a decoder, a self-attention layer, and a feed-forward neural network. The encoder is mainly used to convert input data (usually in sequence form) into vector representations. This process can capture the semantic features of the input data. The decoder is responsible for converting the intermediate representations generated by the encoder into output data (usually in sequence form). The self-attention layer is a mechanism that allows the model to pay attention to other positions in the sequence to better encode the information of the current position. The feed-forward neural network can perform nonlinear transformations on the output of the self-attention layer to enhance the model's expressive power. All these parts work together, enabling the model built on them to perform well in various complex processing tasks, such as natural language processing, machine translation, computer vision, speech recognition, and intelligent question answering.

[0106] In a practical application, the conversion model can be deployed in a processing system to perform the operation of converting a second text from a second language to a first language to generate a first text in response to a call instruction from the processing system. Therefore, in some embodiments, determining the first text to be processed and the second text in response to a processing request may include: Upon detecting the conversion result generated by calling the first conversion model to convert the second text from the second language to the first language, a processing request is generated, and the second text and the first text in the conversion result are determined.

[0107] Based on this, text adjustment operations can include, according to visual difference information: If the visual difference information does not meet the requirements for text conversion, the first conversion model is invoked to convert the second language of the second text into the first language in order to regenerate the first text.

[0108] The text conversion requirements may include, for example, that the visual width difference between the first text and the second text is within a preset range or does not exceed a preset threshold, and can be set according to actual needs.

[0109] If the visual difference information meets the requirements for text conversion, the first text can be output directly.

[0110] If the visual difference information does not meet the text conversion requirements, the first conversion model deployed can be called again to perform the language conversion operation to regenerate the first text. For the regenerated first text, the first visual width calculation operation is re-executed until the visual difference information with the second visual width meets the text conversion requirements, and the first text is output.

[0111] In another practical application, the conversion model can be deployed in a separate conversion control terminal, responding to the terminal's invocation instructions to convert the second language of the second text into the first language to generate the first text. The processing system can establish a communication connection with the conversion control terminal to obtain the conversion results and processing requests sent by the terminal. Therefore, in some embodiments, determining the first text and the second text in response to the processing request includes: In response to a processing request sent by the conversion control terminal, determine the first text and the second text included in the processing request.

[0112] In this process, the first text is obtained by the conversion control terminal calling the second conversion model to convert the second text from its second language to its first language.

[0113] Based on this, text adjustment operations can include, according to visual difference information: If the visual difference information does not meet the text conversion requirements, the first conversion model is invoked to convert the second language of the second text into the first language to regenerate the first text, and the first visual width calculation operation continues to be performed until the visual difference information meets the text conversion requirements. If the visual difference information meets the requirements for text conversion, the first text is provided to the conversion control terminal.

[0114] By calculating the visual difference between the first visual width of the language-converted first text and the second visual width of the original second text, and determining whether the visual difference meets the text conversion requirements, if the requirements are not met, the language conversion operation is re-executed using the conversion model. This avoids a large difference in the actual display width between the language-converted text and the original text on the display page, which could lead to character truncation or wasted display space when displayed in the same page area or display control. This improves the adaptability of the original text and the language-converted text for the same display space in language conversion scenarios, thereby improving the text display effect.

[0115] To improve the language conversion efficiency of the conversion model, optionally, when the visual difference information does not meet the text conversion requirements, calling the first conversion model to convert the second language of the second text into the first language to regenerate the first text may include: When visual difference information does not meet the requirements for text conversion, language conversion instructions are generated based on visual difference information. Based on the language conversion instruction, the first conversion model is invoked to convert the second language of the second text into the first language, so as to regenerate the first text.

[0116] The language conversion instruction can include the first visual width of the current first text, the second visual width of the second text, visual difference information between the two, and the target visual width for re-executing the language conversion task. For example, the language conversion instruction could be: The first visual width of the current first text is 12, the second visual width of the second text is 15, and the visual width difference is 3. Please re-execute the operation of converting the second language of the second text to the first language to regenerate the first text with a target visual width of 14 and output it.

[0117] In a practical application, the conversion model can be a RAG model (Retrieval-Augmented Generation), which allows the model to refer to given instructions when performing language conversion to generate text, generating more suitable text output, improving the accuracy of the generated results, reducing the number of generation times, and thus improving model efficiency.

[0118] The above one or more embodiments provide an implementation method in which the second visual width is the visual width of the second text. In another practical application, the second visual width can be the visual width of the text that the target display control can support.

[0119] Therefore, in some embodiments, determining the second visual width to be processed may include: Determine the target display control corresponding to the first text; Based on the display size of the target display control and the text display requirements, determine the second visual width that the target display control can support.

[0120] The target display controls may include, for example, input boxes, buttons, and labels. Text display requirements may include font size, character spacing, and the ratio between the actual width of the text displayed in the control and the size of the control, which can be set according to actual needs.

[0121] Specifically, the actual display width that the target display control can support can be determined according to the ratio between the actual display width of the text in the display control and the size of the display control. Based on the actual display width and the text display requirements, the width value of the text corresponding to the actual display width can be determined. Then, this width value is converted into a relative value according to a preset ratio, serving as the second visual width that the target display control can support. For example, if the text display requirements include font size, the width value of the text corresponding to the actual display width can be obtained by multiplying the actual display width by the preset ratio corresponding to the font size. Similarly, if the text display requirements include character spacing, the width value of the text corresponding to the actual display width can be obtained by calculating the difference between the actual display width and the spacing of the characters included in the first text, and so on.

[0122] At this point, based on the visual difference information between the first visual width and the second visual width, the corresponding processing operations can include: Based on the visual difference information between the first visual width and the second visual width, determine whether the first text matches the target display control; If not, generate a second prompt message to suggest adjusting the first text; Alternatively, if the first text is obtained by converting the second language of the second text into the first language, the third conversion model is invoked to convert the second language of the second text into the first language to regenerate the first text, and the first visual width calculation operation continues until the first text matches the target display control.

[0123] Determining whether the first text matches the target display control can involve judging whether the visual difference information meets the matching requirements. For example, the matching requirements could be that the first visual width is less than the second visual width, and the difference between their visual widths is within a preset range.

[0124] If the first text matches the target display control, the first text can be output for display in the target display control.

[0125] If the first text does not match the target display control, a second prompt message can be generated based on the visual difference information and matching requirements between the two and provided to the user to prompt the user to adjust the first text. The second prompt message can include visual difference information and text adjustment prompts. In a practical application, the second prompt message could be: The visual width difference between the first text and the target display control is 3. Please adjust the first text to increase its visual width and reduce the difference between it and the visual width that the target display control can support, so that the visual width difference is between 1 and 2.

[0126] Alternatively, if the first text is obtained by the conversion model automatically converting the second text from the second language to the first language, the third conversion model can be called to perform a language conversion operation to regenerate the first text. For the regenerated first text, the first visual width calculation operation is re-executed until it matches the target display control.

[0127] Furthermore, if the first text does not match the target display control, a third prompt message can be generated to prompt the user to adjust the display size of the target display control to fit the first text. This implementation process is consistent with the process of setting the display size of the target display control in the aforementioned embodiments, and will not be described again.

[0128] By calculating the first visual width of the first text, a relatively accurate assessment of the actual display width of the text on the display page is achieved. Then, based on the visual difference between the first visual width and the maximum visual width that the target display control can support, a precise judgment is made as to whether the first text matches the target display control. If a mismatch is determined, a second prompt can be generated to suggest that the user adjust the first text or display size. Alternatively, in scenarios involving language conversion, the language conversion model can be used to automatically re-execute the language conversion operation to regenerate the first text, improving the adaptability of the language-converted text to the target display control and enhancing the display effect of the language-converted text.

[0129] Of course, in addition to the above processing methods, other optional processing methods can be set according to actual needs based on the calculated first visual width of the first text, and this application does not impose any restrictions on this.

[0130] It should be noted that some processes described in the above embodiments and accompanying drawings include multiple operations appearing in a specific order. However, it should be clearly understood that these operations may not be executed in the order they appear in this document, or they may be executed in parallel. The operation numbers, such as 101, 102, etc., are merely used to distinguish different operations and do not represent any execution order. Furthermore, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should also be noted that the descriptions such as "first" and "second" in this document are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to different types.

[0131] Figure 4 This diagram illustrates a system architecture used in a practical application. The following section will combine... Figure 4 The schematic diagram shown illustrates the technical solution of this application.

[0132] like Figure 4 As shown, the system architecture can include a server-side 401 and a client-side 402.

[0133] The server-side 401 redirect can retrieve character widths for multiple characters in different fonts from open-source font databases such as DejaVu (an open-source font based on the Bitstream Vera font family) and Liberation (an open-source font based on the TrueType standard). It then sets a baseline character and sets the character widths corresponding to this baseline character in different fonts as the baseline character widths for each font. For any given font, the ratio of the character width of any given character to the baseline character width is used as the relative character width. The relative character widths of the same character in different fonts are then merged, for example, by averaging, to obtain the glyph width of the character. All characters, their respective glyph widths, and the relative character widths of each character in different fonts are saved together in width mapping data, such as a width mapping table.

[0134] The server-side 401 redirect can use tools such as base64 encoding to compress the width mapping table. Then, using programming languages ​​corresponding to the processing system, such as Java (an object-oriented, cross-platform programming language), JavaScript (a lightweight, interpreted, or just-in-time compiled programming language), or Python (a high-level, interpreted, general-purpose programming language), the compression result and character processing logic code can be encapsulated in a character processing module. This enables the character processing module to be deployed across multiple processing systems, allowing each system to perform a series of processing operations such as text adjustment and setting and adjusting the display size of display controls. This improves the applicability and ease of use of the width mapping data.

[0135] During character processing, server 401 can respond to the processing request sent by client 402, determine the first text, and identify the character types corresponding to the characters included in the first text. For characters of the first character type, if the processing request explicitly specifies the first font corresponding to the first text, the server finds the relative character width of the first font corresponding to the characters included in the first text from the width mapping data; if the processing request does not explicitly specify the first font, the server finds the glyph width corresponding to the character from the width mapping data. For characters of the second character type, such as CJK characters, emoticons, and other special characters, the server uses the corresponding preset relative character width as the glyph width corresponding to that character. The server sums the glyph widths corresponding to the characters included in the first text to obtain the first visual width of the first text, and performs a series of processing operations such as text adjustment and setting and adjusting the display size of display controls based on the first visual width, and sends the processing result to client 402.

[0136] The first visual width of the first text is determined based on the glyph width of the characters included in the first text. Based on the first visual width, a more accurate assessment of the actual display width of the text on the display page is achieved. Therefore, the processing operation performed based on the first visual width can improve the accuracy of the processing results compared with the processing operation performed based on the number of characters.

[0137] Furthermore, by constructing width mapping data, technical support is provided for finding the glyph widths corresponding to the characters included in the first text, ensuring the smooth and efficient calculation of the first visual width of the first text. During the implementation of the width mapping data, by setting a base character and the base character widths of different fonts corresponding to the base character, the relative character width of any character is calculated relative to the base character width. This solves the problem of inconsistent character width descriptions under different fonts, unifies the width units corresponding to character widths in different fonts, and provides strong support for merging the relative character widths of the same character corresponding to different fonts to obtain the glyph width of the character. Moreover, by calculating the glyph width of the characters and saving it to the width mapping data, the calculation of the visual width is unaffected by the font, ultimately achieving a more accurate assessment of the actual display width. Therefore, when the font of the first text is not explicitly specified in the processing request, the first visual width of the first text can be determined based on the glyph widths of the characters included in the first text, ensuring the feasibility of the first visual width calculation and thus ensuring the smooth execution of subsequent processing operations. Furthermore, when the font of the first text is explicitly specified in the processing request, the first visual width of the first text is determined based on the relative character width, which further improves the accuracy of the first visual width calculation and thus helps to improve the accuracy of subsequent processing results.

[0138] In a practical application, server 401 can obtain the user's text input operation in the character comparison interface of client 402, and determine the first text and second text provided by the user. It searches for the glyph widths corresponding to the characters included in the second text from the width mapping data, and determines the second visual width of the second text based on the glyph widths. Based on the visual difference information between the first and second visual widths, it generates a first prompt message and displays it in the character comparison interface to inform the user of the visual width difference between the two texts in different languages, or to prompt the user to perform text adjustment operations, thereby improving the adaptability between the actual display widths of texts in different languages ​​and enhancing the display effect of texts in different languages.

[0139] In another practical application, the server-side 401 function can detect the conversion result generated by calling the first conversion model to convert the second text from a second language to a first language, and determine the second text and the first text in the conversion result. It then searches the width mapping data for the glyph widths corresponding to the characters included in the second text, and determines the second visual width of the second text based on these glyph widths. Based on the visual difference information between the first and second visual widths, if the visual difference information does not meet the text conversion requirements, it calls the first conversion model to convert the second text from a second language to a first language to regenerate the first text. For the regenerated first text, it re-executes the first visual width calculation operation until the visual difference information with the second visual width meets the text conversion requirements. This avoids a large difference in the actual display width between the language-converted text and the original text on the display page, which could lead to character truncation or wasted display space when displayed in the same page area or display control. This improves the adaptability of the original text and the language-converted text for the same display space in language conversion scenarios, thus improving the text display effect.

[0140] In another practical application, the server-side 401 can determine the target display control corresponding to the first text, and based on the display size of the target display control and the text display requirements, determine the second visual width that the target display control can support. Based on the visual difference information between the first and second visual widths, it determines whether the first text matches the target display control. If they do not match, a second prompt message can be generated to remind the user to adjust the display size of the first text or the target display control. Alternatively, if the first text is obtained by converting the second language of the second text to the first language, a language conversion operation can be automatically performed using a conversion model to regenerate the first text, and the first visual width calculation operation can continue until the first text matches the target display control. By calculating the first visual width of the first text, a relatively accurate assessment of the actual display width of the text on the display page can be achieved. Furthermore, based on the visual difference information between the first visual width and the maximum visual width that the target display control can support, a precise judgment on whether the first text matches the target display control can be made based on the visual difference information. If the two are determined to be mismatched, a second prompt message can be generated to prompt the user to adjust the first text or display size. Alternatively, in scenarios involving language conversion, the language conversion operation can be automatically re-executed using a conversion model to regenerate the first text, thereby improving the adaptability of the converted text to the target display control and enhancing the display effect of the converted text.

[0141] Figure 5 This application provides a schematic diagram of the structure of a character processing device according to one embodiment. The device may include the following modules: The first determining module 501 is used to determine the character width of multiple characters corresponding to different fonts.

[0142] The second determining module 502 is used to determine the base character and the width of the base character corresponding to different fonts.

[0143] The first calculation module 503 is used to calculate the relative character width of any character to the baseline character width for any font.

[0144] The second calculation module 504 is used to merge the relative character widths of the same character corresponding to different fonts to obtain the character's glyph width.

[0145] The first storage module 505 is used to save multiple characters and their corresponding glyph widths to width mapping data. The width mapping data can be used to find the glyph widths corresponding to the characters included in the first text. The glyph widths can be used to determine the first visual width of the first text. The first visual width can be used to evaluate the page display width of the first text.

[0146] In some embodiments, the device may further include: The second saving module is used to save the relative character widths of multiple characters corresponding to different fonts to the width mapping data. This width mapping data can be used to find the relative character widths of the characters included in the first text corresponding to the first font when the first text is specified to correspond to the first font in the processing request.

[0147] Figure 5 The character processing device can perform Figure 1 The implementation principle and technical effects of the character processing method described in the illustrated embodiments will not be repeated here. The specific methods by which each module and unit of the character processing device in the above embodiments performs its operations have been described in detail in the embodiments related to this method, and will not be elaborated upon here.

[0148] Figure 6 This application provides a schematic diagram of the structure of a text processing apparatus according to one embodiment. The apparatus may include the following modules: The third determining module 601 is used to determine the first text to be processed; The first search module 602 is used to search for the glyph widths corresponding to the characters included in the first text from the width mapping data; the width mapping data includes the glyph widths corresponding to multiple characters respectively; the glyph widths are obtained by merging the relative character widths of the same character corresponding to different fonts; the relative character widths are calculated based on the base character width of the base character; The fourth determining module 603 is used to determine the first visual width of the first text based on the font width; the first visual width is used to evaluate the page display width of the first text.

[0149] In some embodiments, the device may further include: The processing module is used to perform corresponding processing operations based on the first visual width.

[0150] In some embodiments, the third determining module 601 may be specifically used to determine the first text to be processed in response to a processing request; The device may also include: The fifth determining module is used to determine the second visual width to be processed in response to the processing request; The processing module can be used to perform corresponding processing operations based on the visual difference information between the first visual width and the second visual width.

[0151] In some embodiments, the third determining module 601 may be specifically used to determine a first text and a second text in response to a processing request; the first text uses a first language and the second text uses a second language; The fifth determining module can be used to find the glyph widths corresponding to the characters included in the second text from the width mapping data; and to determine the second visual width of the second text based on the glyph widths. The processing module can be used to generate a first prompt message based on the visual difference information between the first visual width and the second visual width; or, based on the visual difference information, to perform text adjustment operations.

[0152] In some embodiments, the third determining module 601 may be specifically used to provide a character comparison interface; detect text input operations in the character comparison interface, generate a processing request, and determine the first text and the second text input. The device may also include: The display module is used to display the first prompt message in the character comparison interface.

[0153] In some embodiments, the third determining module 601 can be specifically used to detect the conversion result generated by calling the first conversion model to convert the second text into the first language, generate a processing request, and determine the second text and the first text in the conversion result; The processing module can be used to call the first conversion model to convert the second language of the second text into the first language when the visual difference information does not meet the requirements for text conversion, so as to regenerate the first text.

[0154] In some embodiments, the third determining module 601 may be specifically used to determine the first text and the second text included in the processing request in response to a processing request sent by the conversion control terminal; the first text is obtained by the conversion control terminal calling the second conversion model to convert the second text into the first language; The processing module can be used to call the first conversion model to convert the second language of the second text into the first language when the visual difference information does not meet the text conversion requirements, so as to regenerate the first text and continue to perform the first visual width calculation operation until the visual difference information meets the text conversion requirements; when the visual difference information meets the text conversion requirements, the first text is provided to the conversion control terminal.

[0155] In some embodiments, the fifth determining module may be specifically used to determine the target display control corresponding to the first text; and to determine the second visual width that the target display control can bear based on the display size of the target display control and the text display requirements. The processing module can be used to determine whether the first text matches the target display control based on the visual difference information between the first visual width and the second visual width; if not, generate a second prompt message to prompt adjustment of the first text; or, if the first text is obtained by converting the second language of the second text into the first language, call the third conversion model to convert the second language of the second text into the first language to regenerate the first text, and continue to perform the first visual width calculation operation until the first text matches the target display control.

[0156] In some embodiments, the processing module may be specifically used to determine the display size of the target display control corresponding to the first text based on the first visual width, according to the text display requirements.

[0157] In some embodiments, the width mapping data also includes the relative character widths of multiple characters corresponding to different fonts; The device may also include: The second search module is used to search for the relative character width of the characters included in the first text corresponding to the first font from the width mapping data when the first font corresponding to the first text is specified in the processing request. The sixth determining module is used to determine the first visual width of the first text based on the relative character width; The first lookup module 602 can be used to look up the glyph width of the characters included in the first text from the width mapping data when the first font corresponding to the first text is not specified in the processing request.

[0158] In some embodiments, the width mapping data includes multiple characters of a first character type; The device may also include: The recognition module is used to identify the character types corresponding to the characters included in the first text. The first lookup module 602 can be used to find the glyph width of the character belonging to the first character type among the characters included in the first text from the width mapping data; The device may also include: The seventh determining module is used to determine the glyph width of the characters belonging to any second character type among the characters included in the first text; the glyph width of multiple characters of any second character type is a preset relative character width.

[0159] Figure 6 The text processing device can perform Figure 2 The implementation principle and technical effects of the text processing method described in the illustrated embodiments will not be repeated here. The specific methods by which each module and unit of the text processing device in the above embodiments performs its operations have been described in detail in the embodiments related to this method, and will not be elaborated upon here.

[0160] Figure 7 This is a schematic diagram of the structure of one embodiment of a computing device provided in this application. Figure 7 As shown, in practical applications, the computing device may include a storage component 701 and a processing component 702.

[0161] Storage component 701 is used to store computer programs and can be configured to store various other data to support operation on a computing device. Examples of this data include instructions for any application or method operating on the computing device, data structures, contact data, phone book data, messages, pictures, videos, etc.

[0162] Processing component 702, coupled to storage component 701, is used to execute computer programs in storage component 701 for implementing, etc. Figure 1 The character processing method shown or Figure 2 The text processing method shown.

[0163] Furthermore, such as Figure 7 As shown, the computing device may also include other components such as a communication component 703, a display component 704, a power supply component 705, and an audio component 706. Figure 7 The diagram only shows some components and does not mean that the device includes only these components. Figure 7 The components shown. Additionally... Figure 7The components within the dashed box are optional, not mandatory, and their specific requirements depend on the product form of the computing device. The computing device in this embodiment can be a terminal device such as a desktop computer, laptop computer, smartphone, or IoT (Internet of Things) device, or a server-side device such as a conventional server, cloud server, or server array. If the computing device in this embodiment is implemented as a terminal device such as a desktop computer, laptop computer, or smartphone, it may include... Figure 7 The components within the dashed box; if the computing device in this embodiment is implemented as a conventional server, cloud server, or server array, etc., then it may not include... Figure 7 The component within the dashed box.

[0164] The processing component described above includes one or more processors to execute computer instructions to complete all or part of the steps in the method described above. Alternatively, the processing component may be implemented as one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the method described above.

[0165] The aforementioned storage components can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random-Access Memory (SRAM), Electrically Erasable Programmable Read Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.

[0166] The aforementioned communication component is configured to facilitate wired or wireless communication between the device housing the communication component and other devices. The device housing the communication component can access wireless networks based on communication standards, such as mobile communication networks, or combinations thereof. In one exemplary embodiment, the communication component receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel.

[0167] The aforementioned display components may include a screen, which may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can sense not only the boundaries of touch or swipe actions but also the duration and pressure associated with the touch or swipe operation.

[0168] The aforementioned power supply components provide power to various components within the device in which they reside. These power supply components may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power to the device in which they reside.

[0169] The aforementioned audio component can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC) configured to receive external audio signals when the device containing the audio component is in an operating mode, such as call mode, recording mode, or voice recognition mode. The received audio signals can be further stored in memory or transmitted via a communication component. In some embodiments, the audio component also includes a speaker for outputting audio signals.

[0170] Accordingly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, enables the processor to implement the steps in the above-described method embodiments. The computer-readable storage medium includes volatile or non-volatile components, or a combination thereof, and can be removable or non-removable. Examples of computer-readable storage media include, but are not limited to, phase-change random access memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random-access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), flash memory or other memory technologies, CD-ROM, Digital Video Disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium. Accordingly, this application also provides a computer program product, which includes a computer program or instructions that, when executed by a processor, cause the processor to implement the steps in the above method embodiments. It should be understood that each step or combination of steps in the above method flow can be implemented by the computer program or instructions. Furthermore, these computer programs or instructions can be applied to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device, enabling the processor of the general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to function as an apparatus for implementing the corresponding functions in the above method embodiments.

[0171] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0172] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0173] Finally, it should be noted that the above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A text processing method, characterized in that, include: Determine the first text to be processed; Find the glyph widths corresponding to the characters included in the first text from the width mapping data; The width mapping data includes the glyph widths corresponding to multiple characters; the glyph widths are obtained by merging the relative character widths of the same character with different fonts; the relative character widths are calculated based on the base character width of the base character. Based on the character width, determine the first visual width of the first text; The first visual width is used to evaluate the page display width of the first text.

2. The method according to claim 1, characterized in that, Also includes: Based on the first visual width, perform the corresponding processing operation.

3. The method according to claim 2, characterized in that, The first text to be processed includes: In response to the processing request, determine the first text to be processed; The method further includes: In response to the processing request, determine the second visual width to be processed; The step of performing the corresponding processing operation based on the first visual width includes: Based on the visual difference information between the first visual width and the second visual width, perform the corresponding processing operation.

4. The method according to claim 3, characterized in that, In response to the processing request, determining the first text to be processed includes: In response to a processing request, a first text and a second text to be processed are determined; the first text is in a first language, and the second text is in a second language. The determination of the second visual width to be processed includes: Find the glyph width corresponding to the characters included in the second text from the width mapping data; Based on the character width, determine the second visual width of the second text; The step of performing corresponding processing operations based on the visual difference information between the first visual width and the second visual width includes: A first prompt message is generated based on the visual difference information between the first visual width and the second visual width; or, a text adjustment operation is performed based on the visual difference information.

5. The method according to claim 4, characterized in that, In response to the processing request, determining the first text and the second text to be processed includes: Provides a character comparison interface; The system detects text input operations in the character comparison interface, generates a processing request, and determines the first and second text input. After generating the first prompt message, the method further includes: The first prompt message is displayed on the character comparison interface.

6. The method according to claim 4, characterized in that, In response to the processing request, determining the first text and the second text to be processed includes: Upon detecting the conversion result generated by calling the first conversion model to convert the second text from the second language to the first language, a processing request is generated, and the second text and the first text in the conversion result are determined; The step of performing text adjustment operation based on the visual difference information includes: If the visual difference information does not meet the text conversion requirements, the first conversion model is invoked to convert the second text from the second language to the first language in order to regenerate the first text.

7. The method according to claim 4, characterized in that, In response to the processing request, determining the first text and the second text to be processed includes: In response to a processing request sent by the conversion control terminal, the first text and the second text included in the processing request are determined; the first text is obtained by the conversion control terminal calling a second conversion model to convert the second text from a second language to a first language; The step of performing text adjustment operation based on the visual difference information includes: If the visual difference information does not meet the text conversion requirements, the first conversion model is invoked to convert the second language of the second text into the first language to regenerate the first text, and the first visual width calculation operation continues to be performed until the visual difference information meets the text conversion requirements. If the visual difference information meets the text conversion requirements, the first text is provided to the conversion control terminal.

8. The method according to claim 3, characterized in that, The determination of the second visual width to be processed includes: Determine the target display control corresponding to the first text; Based on the display size and text display requirements of the target display control, determine the second visual width that the target display control can support; The step of performing corresponding processing operations based on the visual difference information between the first visual width and the second visual width includes: Based on the visual difference information between the first visual width and the second visual width, determine whether the first text matches the target display control; If not, generate a second prompt message to prompt adjustment of the first text; or, if the first text is obtained by converting the second language of the second text into the first language, call a third conversion model to convert the second language of the second text into the first language to regenerate the first text, and continue to perform the first visual width calculation operation until the first text matches the target display control.

9. The method according to claim 2, characterized in that, The step of performing the corresponding processing operation based on the first visual width includes: According to the text display requirements, the display size of the target display control corresponding to the first text is determined based on the first visual width.

10. The method according to claim 1, characterized in that, The width mapping data also includes the relative character widths of the multiple characters corresponding to different fonts; The method further includes: If the first font corresponding to the first text is specified in the processing request, the relative character width of the characters included in the first text corresponding to the first font is found from the width mapping data, and the first visual width of the first text is determined based on the relative character width. The step of finding the glyph width corresponding to the characters included in the first text from the width mapping data includes: If the first font corresponding to the first text is not specified in the processing request, the glyph width corresponding to the characters included in the first text is found from the width mapping data.

11. The method according to claim 1, characterized in that, The width mapping data includes multiple characters of the first character type; The method further includes: Identify the character types corresponding to the characters included in the first text; The step of finding the glyph width corresponding to the characters included in the first text from the width mapping data includes: Find the glyph width of the character belonging to the first character type among the characters included in the first text from the width mapping data; The method further includes: Determine the glyph width of the characters belonging to any second character type among the characters included in the first text; the glyph width of multiple characters of any second character type is a preset relative character width.

12. A character processing method, characterized in that, include: Determine the character width for different fonts corresponding to multiple characters; Determine the base character and the width of the base character corresponding to different fonts; For any font, calculate the relative character width of any character relative to the baseline character width; The relative character widths of the same character corresponding to different fonts are merged to obtain the glyph width of the character; Save the multiple characters and their corresponding glyph widths to the width mapping data; The width mapping data is used to find the glyph width corresponding to the characters included in the first text. The glyph width is used to determine the first visual width of the first text. The first visual width is used to evaluate the page display width of the first text.

13. A computing device, characterized in that, This includes processing components and storage components; The storage component stores a computer program; the computer program is invoked and executed by the processing component to implement the text processing method as described in any one of claims 1 to 11, or the character processing method as described in claim 12.

14. A computer-readable storage medium, characterized in that, It stores a computer program, which, when executed by the processing component, implements the text processing method as described in any one of claims 1 to 11, or the character processing method as described in claim 12.

15. A computer program product, characterized in that, It includes a computer program or instructions that, when executed by a processing component, implement the text processing method as described in any one of claims 1 to 11, or the character processing method as described in claim 12.