Text adjustment method and related product thereof

By listening to the content changes of the text node, obtaining actual font information and calculating target zoom ratio, solving the problem of low -adaptation and repair efficiency of the existing technology of the existing technology, achieved efficient and accurate text repair, and improved the efficiency of site expansion.

CN119378488APending Publication Date: 2025-01-28GUANGZHOU XIYIN INT IMPORT & EXPORT CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411273396.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-11
Publication Date
2025-01-28

AI Technical Summary

Technical Problem

The prior art is difficult to efficiently and conveniently perform adaptive scaling repair of text during site expansion, resulting in high computing performance consumption, low repair accuracy and low efficiency.

Method used

By listening to the content changes of each text node, obtain the actual font information of the update text, determine the actual text width, and based on actual font information, actual text width, font size changes, and expectation information calculation target scaling ratio to achieve text Adaptive adjustment.

Benefits of technology

The adaptive zoom repair of the text was achieved efficiently and conveniently, reducing the computing performance consumption, improving the accuracy of text repair, thereby improving the efficiency of site expansion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119378488A_ABST
    Figure CN119378488A_ABST
Patent Text Reader

Abstract

The invention discloses a text adjustment method and a related product thereof. The method comprises the following steps: monitoring a content change event of each text node; if the content change event is monitored, obtaining actual font information of an updated text in the text node where the content change event occurs, and determining an actual text width of the updated text based on the actual font information; determining font size variation based on the actual font information and expected configuration information input by the user; and determining a target scaling of the updated text based on the actual font information, the actual text width, the font size variation and the expected configuration information. According to the method, the text can be efficiently, conveniently and adaptively zoomed and repaired, the calculation performance consumption is reduced, and the text repairing accuracy is improved, so that the site expansion efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application generally relates to the field of data processing technology. More specifically, the present application relates to a text adjustment method and related products. Background Art

[0002] In the process of expanding the site and launching it to overseas countries, each site expansion requires repairing a large number of text style confusion problems. However, each person involved in the site expansion may use a different repair solution, which cannot meet all the real complex online scenarios that require text adaptive repair, nor can it meet the goal of rapidly expanding the site. The existing text adaptive repair method can obtain the final text scaling value through boundary probing. However, if this existing solution is used for adaptive repair, it is necessary to write additional repair code for different online scenarios, which is complex to use, and a line of text may need to be calculated dozens of times to obtain the final text scaling value. Not only does the calculation consume a lot of performance, but the calculated value is prone to errors, resulting in different forms of expression between different sites, causing the text to be constantly adjusted for each site expansion, which is inefficient.

[0003] In view of this, there is an urgent need to provide a text adjustment method so that the text can be adaptively scaled and repaired efficiently and conveniently, the computing performance consumption can be reduced, the accuracy of text repair can be improved, and the efficiency of site expansion can be improved. Summary of the invention

[0004] In order to at least solve one or more of the technical problems mentioned above, the present application proposes a text adjustment method and related products in multiple aspects. The text adjustment method can efficiently and conveniently perform adaptive scaling repair on text, reduce computing performance consumption, and improve text repair accuracy, thereby improving the efficiency of site expansion.

[0005] In a first aspect, the present application provides a text adjustment method, comprising: monitoring content change events of each text node; if a content change event is monitored, obtaining actual font information of the updated text in the text node where the content change event occurs, and determining the actual text width of the updated text based on the actual font information; determining a font size change based on the actual font information and desired configuration information input by a user; and determining a target scaling ratio for the updated text based on the actual font information, the actual text width, the font size change, and the desired configuration information.

[0006] In one embodiment, the actual font information includes an actual font size, and the expected configuration information includes an expected text width; wherein determining the font size change based on the actual font information and the expected configuration information input by the user includes: determining the font size change based on the actual font size and the expected text width.

[0007] In one embodiment, determining a target scaling ratio for updating text based on actual font information, actual text width, font size change, and expected configuration information includes: determining an inferred text width based on actual font size and font size change; determining a target scaling ratio based on actual text width, expected text width, font size change, and inferred text width.

[0008] In one embodiment, determining the target zoom ratio based on the actual text width, the expected text width, the font size change, and the inferred text width includes: determining the target zoom ratio by a zoom ratio formula based on the actual text width, the expected text width, the font size change, and the inferred text width; the zoom ratio formula is:

[0009]

[0010] Where S is the target scaling ratio, W s is the actual text width, W e is the expected text width, D is the font size change, W t To calculate the text width.

[0011] In one embodiment, monitoring the content change event of each text node includes: creating an observer object corresponding to each text node; inputting the observer object corresponding to each text node into a preset monitoring interface to monitor the content change event of each text node through the preset monitoring interface.

[0012] In one embodiment, the actual font information also includes an actual character size and an actual font weight; wherein, determining the actual text width of the updated text based on the actual font information includes: inputting the actual font size, the actual character size and the actual font weight into a preset measurement interface to obtain the actual text width output by the preset measurement interface.

[0013] In one embodiment, before obtaining the actual font information of the updated text in the text node where the content change event occurs, the method further includes: monitoring the font loading time of the updated text by executing a time-limited function.

[0014] In one embodiment, obtaining the actual font information of the updated text in the text node where the content change event occurs includes: if the font loading time is less than or equal to the preset duration, obtaining the actual font information of the updated text; if the font loading time is greater than the preset duration, obtaining the system native font corresponding to the updated text as the actual font information of the updated text.

[0015] In a second aspect, the present application provides a device for text adjustment, comprising: a memory; and at least one processor, configured to: monitor content change events of each text node; if the content change event is monitored, obtain actual font information of the updated text in the text node where the content change event occurs, and determine the actual text width of the updated text based on the actual font information; determine a font size change based on the actual font information and desired configuration information input by a user; determine a target scaling ratio for the updated text based on the actual font information, the actual text width, the font size change, and the desired configuration information.

[0016] In a third aspect, the present application provides a non-volatile machine-readable medium having program code for text adjustment stored thereon. When the program code is executed by at least one processor, the code guides the execution operation of the at least one processor. The program code includes: if the content change event is monitored, obtaining the actual font information of the updated text in the text node where the content change event occurs, and determining the actual text width of the updated text based on the actual font information; determining the font size change based on the actual font information and the expected configuration information input by the user; determining the target scaling ratio of the updated text based on the actual font information, the actual text width, the font size change and the expected configuration information.

[0017] The technical solution provided by this application may have the following beneficial effects:

[0018] The text adjustment method and related products provided by the present application monitor the content change event of each text node to obtain the content update status of each text node. If the content change event is monitored, the actual font information of the updated text in the text node where the content change event occurs is obtained, and the actual text width of the updated text is determined based on the actual font information, so that the width occupied by the updated text can be known.

[0019] Furthermore, the present application can determine the font size change based on the actual font information and the desired configuration information input by the user, and then determine the target scaling ratio of the updated text based on the actual font information, the actual text width, the font size change and the desired configuration information. Thus, the updated text can be adaptively adjusted according to the target scaling ratio, and the target scaling ratio can be determined by only one calculation, reducing computing performance consumption.

[0020] In general, this application can efficiently and conveniently perform adaptive scaling and repair of text, reduce computing performance consumption, and improve text repair accuracy, thereby improving the efficiency of site expansion. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] By reading the detailed description below with reference to the accompanying drawings, the above and other purposes, features and advantages of the exemplary embodiments of the present application will become easy to understand. In the accompanying drawings, several embodiments of the present application are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:

[0022] Figure 1 An exemplary flow chart showing a text adjustment method according to some embodiments of the present application is shown;

[0023] Figure 2 An exemplary flow chart showing a text adjustment method according to some other embodiments of the present application is shown;

[0024] Figure 3 An exemplary flow chart showing a text adjustment method according to some further embodiments of the present application is shown;

[0025] Figure 4 The block diagram shows the hardware configuration of a device 400 for text adjustment that can implement the text adjustment method according to an embodiment of the present application. DETAILED DESCRIPTION

[0026] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. For the simplicity and clarity of the description, the figure marks may be repeated in the drawings to indicate corresponding or similar elements when deemed appropriate. In addition, the present application sets forth many specific details in order to provide a thorough understanding of the embodiments described herein. However, it will be understood by those of ordinary skill in the art that the embodiments described herein may be practiced without these specific details. In other cases, well-known methods, processes, and components are not described in detail to avoid blurring the embodiments described herein. Moreover, the description should not be regarded as limiting the scope of the embodiments described herein. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application.

[0027] It should be understood that the possible terms "first" or "second" etc. in the claims, specifications and drawings disclosed in this application are used to distinguish different objects, rather than to describe a specific order. The terms "include" and "comprise" used in the specification and claims of this application indicate the presence of the described features, wholes, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or their collections.

[0028] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in this application specification and claims, unless the context clearly indicates otherwise, the singular forms of "a", "an" and "the" are intended to include plural forms. It should also be further understood that the term "and / or" used in this application specification and claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.

[0029] As used in this specification and claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.

[0030] The existing text adaptive repair method can obtain the final text scaling value through boundary probing. However, if this existing solution is used for adaptive repair, it is necessary to write additional repair code for different online scenarios, which is highly complex to use. In addition, a line of text may need to be calculated dozens of times to obtain the final text scaling value. Not only is the calculation performance consumption high, but the calculated value is prone to errors, resulting in different expressions between different sites. As a result, the text needs to be constantly adjusted for each site expansion, which is inefficient.

[0031] In view of this, there is an urgent need to provide a text adjustment method so that the text can be adaptively scaled and repaired efficiently and conveniently, the computing performance consumption can be reduced, the accuracy of text repair can be improved, and the efficiency of site expansion can be improved.

[0032] The specific implementation of the present application is described in detail below with reference to the accompanying drawings.

[0033] Figure 1 An exemplary flowchart 100 showing a text adjustment method in some embodiments of the present application is shown in FIG. Figure 1 , the text adjustment method shown in the embodiment of the present application may include:

[0034] In step S101, the content change event of each text node is monitored. In the embodiment of the present application, the aforementioned text node refers to the regional position for presenting text in the display interface. In addition, the content change event refers to the event of content change update in the text node. Exemplarily, there is a regional position for presenting titles in a row in a certain display interface. This regional position for presenting titles can be regarded as a text node. If the initial content of this text node is empty, and the title information is filled in after a certain interface feedback information, then it can be determined that a content change event has occurred in this text node.

[0035] In step S102, if a content change event is monitored, the actual font information of the updated text in the text node where the content change event occurs is obtained, and the actual text width of the updated text is determined based on the actual font information. Exemplarily, the exemplary example in step S101 is continued to explain that the text content of the title information is the updated text, so that the actual font information of the updated text can be known. Among them, the actual font information can include but is not limited to the actual font size, etc. It can be understood that in actual applications, the specific content of the actual font information needs to be determined according to the actual application situation, and the present application does not impose any restrictions in this regard.

[0036] Furthermore, the actual text width of the entire updated text can be determined based on the actual font information of the updated text. Assuming that the updated text has four characters, the actual text width of the updated text of the four characters can be determined based on the actual font information of the updated text, so that the actual width occupied by the updated text can be known.

[0037] In step S103, the font size change is determined based on the actual font information and the expected configuration information input by the user. In the embodiment of the present application, the aforementioned expected configuration information may include but is not limited to the expected text width. It is understandable that the actual font size needs to be changed based on the actual font size in the actual font information and the expected text width in the expected configuration information to make the updated text reach the expected text width, so that the font size change can be determined.

[0038] In step S104, the target scaling ratio of the updated text is determined based on the actual font information, the actual text width, the font size change and the expected configuration information. In the embodiment of the present application, the updated text can be adaptively adjusted according to the determined target scaling ratio so that the updated text as a whole meets the expected text width.

[0039] The embodiment of the present application monitors the content change event of each text node to learn the content update status of each text node. If the content change event is monitored, the actual font information of the updated text in the text node where the content change event occurs is obtained, and the actual text width of the updated text is determined based on the actual font information, so that the width occupied by the updated text can be known. Further, the present application can determine the font size change based on the actual font information and the expected configuration information input by the user, and then determine the target scaling ratio of the updated text based on the actual font information, the actual text width, the font size change and the expected configuration information. Thus, the updated text can be adaptively adjusted according to the target scaling ratio, and only one calculation is needed to determine the target scaling ratio, reducing the computing performance consumption. In general, the present application can efficiently and conveniently perform adaptive scaling repair on the text, reduce computing performance consumption, and improve the accuracy of text repair, thereby improving the efficiency of site expansion.

[0040] In some embodiments, the actual font information may include but is not limited to the actual font size, and the expected configuration information may include but is not limited to the expected text width, so that the actual font size and the expected text width can be used to determine the font size change, and then determine the target scaling ratio. Figure 2 The process of determining the target scaling ratio is described in detail. Figure 2 An exemplary flowchart 200 showing a text adjustment method in some other embodiments of the present application is shown in FIG. Figure 2 , the text adjustment method shown in the embodiment of the present application may include:

[0041] In step S201, the font size change is determined based on the actual font size and the expected text width. It is understandable that after the actual font size is increased or decreased by a certain amount, the changed font size can be obtained, and then the changed text width can be determined based on the changed font size. Among them, the method of determining the text width based on the font size can be determined using the measureText function in Canvas. Canvas is an API interface for painting provided by HTML5, which allows developers to draw complex graphics and even animations in the browser, and the measureText function can be used to measure the width of the text, that is, the text width can be output based on the input text. It is understandable that there are various ways to determine the text width. In actual applications, it is necessary to select an appropriate method to determine the text width based on the actual application situation. The present application does not impose any restrictions in this regard.

[0042] In step S202, the estimated text width is determined based on the actual font size and the font size change. In the embodiment of the present application, since the font size change is calculated based on the actual font size and the expected text width, it can be understood that the estimated text width determined by the estimated font size obtained after the actual font size is increased or decreased by the font size change may not be equal to the expected text width, but is close to the expected text width. Exemplarily, assuming that the current line of text is "Free Gifts", the font size is 24px in the English scene, and the text width is 100px. However, when this line of text is switched to the French scene, this line of text will be updated to "Cadeaux gratuits". If the font size remains at 24px, the text width will be expanded to 180px. It can be seen that the text width in the French scene will be wider than the text width in the English scene, which will cause confusion in the text style. At this time, by increasing or decreasing the font size by the font size change amount, for example, reducing the font size by 10px, the current estimated font size is 14px, and then the above-mentioned measureText function can be used to determine the estimated text width, for example, 120px.

[0043] In step S203, the target zoom ratio is determined based on the actual text width, the expected text width, the font size change, and the inferred text width. In an embodiment of the present application, the target zoom ratio can be determined by a zoom ratio formula based on the actual text width, the expected text width, the font size change, and the inferred text width, wherein the zoom ratio formula is:

[0044]

[0045] Where S is the target scaling ratio, W s is the actual text width, W e is the expected text width, D is the font size change, W t To calculate the text width. Therefore, according to the above zoom ratio formula, the target zoom ratio can be calculated at one time, avoiding multiple tentative calculations to determine the target zoom ratio through boundary heuristics (boundary heuristics means that, for example, the actual text size is 60 and the text width is 120px. If the expected text width is 100px, the font is tentatively reduced by 1px, that is, 59px. At this time, it is determined whether the text width is 100px. If not, the font is tentatively reduced by 1px, and so on, until the text width is 100px. Stop) to reduce the number of calculations and reduce computing performance consumption.

[0046] It is understandable that after determining the target scaling ratio, the text can be adjusted in combination with other parameters in the expected configuration information. The expected configuration information can also include line break parameters (multiLine) and the like. Exemplarily, the exemplary example in step S202 is used to explain that, assuming that the target scaling ratio is 0.5, that is, the font size needs to be scaled from 24px to 12px in the French scene, if the line break parameter at this time is a parameter corresponding to no line break, then the 12px font style is configured on the text area of ​​the line, and the adjustment can be completed.

[0047] In some embodiments, the font loading time for updating text can be limited to avoid blocking the page loading process. Figure 3 An exemplary flowchart 300 of a text adjustment method according to some other embodiments of the present application is shown. Figure 3 , the text adjustment method shown in the embodiment of the present application may include:

[0048] In step S301, the content change events of each text node are monitored. In an embodiment of the present application, an observer object corresponding to each text node can be created respectively, and then the observer object corresponding to each text node can be input into a preset monitoring interface to monitor the content change events of each text node through the preset monitoring interface. Among them, the preset monitoring interface can be MutationObsever of JavaScript. Exemplarily, for example, the initial content of the text node corresponding to the title is empty, and after a certain interface returns information, the text node corresponding to the title is filled with updated text, then this text update change can be monitored by the preset monitoring interface.

[0049] It is understandable that, in actual applications, the monitoring method of content change events needs to be determined according to the actual application situation, and this application does not impose any restrictions in this regard.

[0050] In step S302, if a content change event is detected, the font loading time of the updated text is monitored through a time-limited execution function. In an embodiment of the present application, the time-limited execution function can be a Promise function of JavaScript. The reason for setting a time-limited execution function to monitor the font loading time of the updated text is that the calculation of the text width depends on obtaining the font style, and the process of obtaining the font style can be regarded as the font loading time. For example, such as Songti and Heiti, the width occupied by the same amount of text is inconsistent. However, there are some custom fonts in some interfaces, which require a certain amount of time to request loading. After loading is completed, the accurate text width can be calculated according to the font style. If the network environment is poor, causing the network font to load slowly, the timing of calculating the text width will also be delayed, thereby blocking the subsequent rendering and refreshing of the page.

[0051] In step S303, the actual font information of the updated text in the text node where the content change event occurs is obtained. In an embodiment of the present application, if the font loading time is less than or equal to the preset duration, the actual font information of the updated text is obtained; if the font loading time is greater than the preset duration, the system native font corresponding to the updated text is obtained as the actual font information of the updated text, and the font loading of the updated text is no longer waited. Among them, the preset duration can be set to 1 second. It can be understood that in actual applications, the preset duration needs to be set according to the actual application situation. The present application does not impose any restrictions in this regard.

[0052] In step S304, the actual text width of the updated text is determined based on the actual font information. In an embodiment of the present application, the actual font information may also include the actual character type (the character type is a set of glyphs with the same appearance style and the same typesetting size, which may include Songti, Kaiti, Heiti, etc.) and the actual font weight (font weight refers to the thickness of the font). When calculating the actual text width, the actual font size, the actual character type and the actual font weight may be input into the preset measurement interface to obtain the actual text width output by the preset measurement interface. Among them, the preset measurement interface may be the measureText function in Canvas. This API interface is used to determine the actual text width, which has high accuracy and is not affected by styles such as document flow layout. Moreover, the calculation speed is fast and is not limited by the text node loading speed. The calculation can be started only after the text content and font style are obtained. It can be understood that there are various ways to determine the actual text width. In practical applications, it is necessary to select a suitable method to determine the actual text width according to the actual application situation. The present application does not impose any restrictions in this regard.

[0053] Corresponding to the aforementioned application function implementation method embodiment, the present application also provides a device for text adjustment and corresponding embodiments.

[0054] Figure 4 FIG. 4 is a block diagram showing a hardware configuration of a device 400 for text adjustment that can implement the text adjustment method of an embodiment of the present application. Figure 4 As shown, the device 400 for text adjustment may include a processor 410 and a memory 420. Figure 4 In the device 400 for text adjustment, only the components related to this embodiment are shown. Therefore, it is obvious to those skilled in the art that the device 400 for text adjustment may also include Figure 4 The components shown in the figure are different from the common components. For example: fixed-point arithmetic units.

[0055] The device 400 for text adjustment may correspond to a computing device having various processing functions, such as functions for generating a neural network, training or learning a neural network, quantizing a floating-point neural network to a fixed-point neural network, or retraining a neural network. For example, the device 400 for text adjustment may be implemented as various types of devices, such as a personal computer (PC), a server device, a mobile device, etc.

[0056] The processor 410 controls all functions of the device 400 for text adjustment. For example, the processor 410 controls all functions of the device 400 for text adjustment by executing a program stored in the memory 420 on the device 400 for text adjustment. The processor 410 may be implemented by a central processing unit (CPU), a graphics processing unit (GPU), an application processor (AP), an artificial intelligence processor chip (IPU), etc. provided in the device 400 for text adjustment. However, the present application is not limited thereto.

[0057] In some embodiments, the processor 410 may include an input / output (I / O) unit 411 and a computing unit 412. The I / O unit 411 may be used to receive various data, such as actual font information. Exemplarily, the computing unit 412 may be used to determine the actual text width of the updated text based on the actual font information received via the I / O unit 411; further determine the font size change based on the actual font information and the desired configuration information input by the user; further determine the target scaling ratio of the updated text based on the actual font information, the actual text width, the font size change, and the desired configuration information. This target scaling ratio may be output by the I / O unit 411, for example. The output data may be provided to the memory 420 for reading and use by other devices (not shown), or may be directly provided to other devices for use.

[0058] The memory 420 is hardware for storing various data processed in the device 400 for text adjustment. For example, the memory 420 can store processed data and data to be processed in the device 400 for text adjustment. The memory 420 can store data sets involved in the text adjustment method process that has been processed or to be processed by the processor 410, such as actual font information, etc. In addition, the memory 420 can store applications, drivers, etc. to be driven by the device 400 for text adjustment. For example: the memory 420 can store various programs related to the text adjustment method to be executed by the processor 410. The memory 420 can be a DRAM, but the present application is not limited thereto. The memory 420 can include at least one of a volatile memory or a non-volatile memory. The non-volatile memory can include a read-only memory (ROM), a programmable ROM (PROM), an electrically programmable ROM (EPROM), an electrically erasable programmable ROM (EEPROM), a flash memory, a phase change RAM (PRAM), a magnetic RAM (MRAM), a resistive RAM (RRAM), a ferroelectric RAM (FRAM), etc. The volatile memory may include dynamic RAM (DRAM), static RAM (SRAM), synchronous DRAM (SDRAM), PRAM, MRAM, RRAM, ferroelectric RAM (FeRAM), etc. In an embodiment, the memory 420 may include at least one of a hard disk drive (HDD), a solid state drive (SSD), a high-density flash memory (CF), a secure digital (SD) card, a micro secure digital (Micro-SD) card, a mini secure digital (Mini-SD) card, an extreme digital (xD) card, caches, or a memory stick.

[0059] In summary, the specific functions implemented by the memory 420 and the processor 410 of the device 400 for text adjustment provided in the implementation manner of this specification can be explained in comparison with the aforementioned implementation manner in this specification, and can achieve the technical effects of the aforementioned implementation manner, and will not be repeated here.

[0060] In this embodiment, the processor 410 can be implemented in any suitable manner. For example, the processor 410 can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (such as software or firmware) executable by the (micro)processor, a logic gate, a switch, an application specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller, etc.

[0061] It should also be understood that any module, unit, component, server, computer, terminal or device that executes instructions exemplified herein may include or otherwise access computer-readable media, such as storage media, computer storage media or data storage devices (removable and / or non-removable) such as disks, optical disks or tapes. Computer storage media may include volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information, such as computer-readable instructions, data structures, program modules or other data.

[0062] The foregoing content can be better understood in accordance with the following terms:

[0063] Clause A1. A text adjustment method, comprising: monitoring content change events of each text node; if the content change event is monitored, obtaining the actual font information of the updated text in the text node where the content change event occurs, and determining the actual text width of the updated text based on the actual font information; determining the font size change based on the actual font information and expected configuration information input by the user; determining the target scaling ratio of the updated text based on the actual font information, the actual text width, the font size change and the expected configuration information.

[0064] Clause A2. A text adjustment method according to Clause A1, wherein the actual font information includes an actual font size, and the expected configuration information includes an expected text width; wherein determining the font size change based on the actual font information and the expected configuration information input by the user includes: determining the font size change based on the actual font size and the expected text width.

[0065] Clause A3. A text adjustment method according to clause A2, wherein determining the target scaling ratio of the updated text based on the actual font information, the actual text width, the font size change and the expected configuration information comprises: determining an inferred text width based on the actual font size and the font size change; determining the target scaling ratio based on the actual text width, the expected text width, the font size change and the inferred text width.

[0066] Clause A4. A text adjustment method according to clause A3, wherein the determining the target scaling ratio based on the actual text width, the expected text width, the font size change and the estimated text width comprises: determining the target scaling ratio by a scaling ratio formula based on the actual text width, the expected text width, the font size change and the estimated text width; the scaling ratio formula is:

[0067]

[0068] Where S is the target scaling ratio, W s is the actual text width, W e is the expected text width, D is the font size change, W t is the estimated text width.

[0069] Clause A5. A text adjustment method according to clause A1, wherein monitoring the content change events of each text node comprises: creating observer objects corresponding to each text node respectively; inputting the observer objects corresponding to each text node into a preset monitoring interface to monitor the content change events of each text node through the preset monitoring interface.

[0070] Clause A6. A text adjustment method according to Clause A2, wherein the actual font information also includes an actual character size and an actual font weight; wherein determining the actual text width of the updated text based on the actual font information comprises: inputting the actual font size, the actual character size and the actual font weight into a preset measurement interface to obtain the actual text width output by the preset measurement interface.

[0071] Clause A7. A text adjustment method according to Clause A1, wherein, before obtaining the actual font information of the updated text in the text node where the content change event occurs, the method further comprises: monitoring the font loading time of the updated text by executing a time-limited function.

[0072] Clause A8. A text adjustment method according to Clause A7, wherein obtaining the actual font information of the updated text in the text node where the content change event occurs includes: if the font loading time is less than or equal to a preset duration, obtaining the actual font information of the updated text; if the font loading time is greater than the preset duration, obtaining the system native font corresponding to the updated text as the actual font information of the updated text.

[0073] Item A9, a device for text adjustment, characterized in that it includes: a memory; and at least one processor, which is configured to: monitor content change events of each text node; if the content change event is monitored, obtain the actual font information of the updated text in the text node where the content change event occurs, and determine the actual text width of the updated text based on the actual font information; determine the font size change based on the actual font information and the expected configuration information input by the user; determine the target scaling ratio of the updated text based on the actual font information, the actual text width, the font size change and the expected configuration information.

[0074] Item A10, a non-volatile machine-readable medium having program code for text adjustment stored thereon, wherein when the program code is executed by at least one processor, the code guides the execution operation of the at least one processor, and the program code includes: monitoring the content change event of each text node; if the content change event is monitored, obtaining the actual font information of the updated text in the text node where the content change event occurs, and determining the actual text width of the updated text based on the actual font information; determining the font size change based on the actual font information and the expected configuration information input by the user; determining the target scaling ratio of the updated text based on the actual font information, the actual text width, the font size change and the expected configuration information.

[0075] Although multiple embodiments of the present application have been shown and described herein, it is obvious to those skilled in the art that such embodiments are provided only by way of example. Those skilled in the art can think of many changes, modifications and alternatives without departing from the thought and spirit of the present application. It should be understood that in the process of practicing the present application, various alternatives to the embodiments of the present application described herein can be adopted. The attached claims are intended to limit the scope of protection of the present application, and therefore cover equivalents or alternatives within the scope of these claims.

Claims

1. A text adjustment method, characterized in that: include: Listen for content change events of each text node; If the content change event is monitored, then obtaining actual font information of the updated text in the text node where the content change event occurs, and determining the actual text width of the updated text based on the actual font information; Determining a font size change based on the actual font information and desired configuration information input by a user; A target scaling ratio of the updated text is determined based on the actual font information, the actual text width, the font size change amount, and the desired configuration information.

2. The text adjustment method according to claim 1, characterized in that: The actual font information includes an actual font size, and the expected configuration information includes an expected text width; wherein determining the font size change based on the actual font information and the expected configuration information input by the user comprises: The font size change amount is determined based on the actual font size and the desired text width.

3. The text adjustment method according to claim 2, characterized in that: The determining the target scaling ratio of the updated text based on the actual font information, the actual text width, the font size change and the expected configuration information comprises: Determining an estimated text width based on the actual font size and the font size change; The target zoom ratio is determined based on the actual text width, the expected text width, the font size change, and the inferred text width.

4. The text adjustment method according to claim 3, characterized in that: The determining the target scaling ratio based on the actual text width, the expected text width, the font size change and the estimated text width comprises: Determining the target zoom ratio by a zoom ratio formula based on the actual text width, the expected text width, the font size change and the estimated text width; The scaling ratio formula is: Where S is the target scaling ratio, W s is the actual text width, W e is the expected text width, D is the font size change, W t is the estimated text width.

5. The text adjustment method according to claim 1, characterized in that: The monitoring of the content change event of each text node includes: Create an observer object corresponding to each text node respectively; The observer object corresponding to each text node is input into a preset monitoring interface, so as to monitor the content change event of each text node through the preset monitoring interface.

6. The text adjustment method according to claim 2, characterized in that: The actual font information further includes an actual character size and an actual font weight; wherein determining the actual text width of the updated text based on the actual font information comprises: The actual font size, the actual character size and the actual font weight are input into a preset measurement interface to obtain the actual text width output by the preset measurement interface.

7. The text adjustment method according to claim 1, characterized in that: Before obtaining the actual font information of the updated text in the text node where the content change event occurs, the method further includes: The font loading time of the updated text is monitored by a time-limited execution function.

8. The text adjustment method according to claim 7, characterized in that: The step of obtaining the actual font information of the updated text in the text node where the content change event occurs includes: If the font loading time is less than or equal to the preset time, obtaining the actual font information of the updated text; If the font loading time is greater than the preset time length, the system native font corresponding to the updated text is obtained as the actual font information of the updated text.

9. A device for text adjustment, characterized in that include: Memory; as well as at least one processor configured to: Listen for content change events of each text node; If the content change event is monitored, then obtaining actual font information of the updated text in the text node where the content change event occurs, and determining the actual text width of the updated text based on the actual font information; Determining a font size change based on the actual font information and desired configuration information input by a user; A target scaling ratio of the updated text is determined based on the actual font information, the actual text width, the font size change amount, and the desired configuration information.

10. A non-transitory machine-readable medium having stored thereon a program code for text adjustment, wherein when the program code is executed by at least one processor, the code directs the execution operation of the at least one processor, the program code comprising: Listen for content change events of each text node; If the content change event is monitored, then obtaining actual font information of the updated text in the text node where the content change event occurs, and determining the actual text width of the updated text based on the actual font information; Determining a font size change based on the actual font information and desired configuration information input by a user; A target scaling ratio of the updated text is determined based on the actual font information, the actual text width, the font size change amount, and the desired configuration information.