Text font size adjustment method and device, electronic device, and storage medium
By constructing a program entry set to directly access the text setting program in the application, the problem of complex logic of text font size adjustment in the prior art is solved, and a text font size adjustment with simple logic and easy maintenance is achieved.
Patent Information
- Application Number
- CN202111189976.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-12
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2041-10-12
AI Technical Summary
In the prior art, the logic of the text font size adjustment function is complex and inconvenient to maintain, especially when an application includes multiple business modules, and it is necessary to perceive the calling relationship of the text setting program within each business module.
By building a program entry set in the application, directly accessing the text setting program in each business module, and using the direct channel in the program entry set to pass the target font size, there is no need to perceive the calling relationship within the business module, so as to achieve the adjustment of the text font size.
The logic of text font size adjustment has been simplified, which improves the convenience of maintenance and upgrades. The font size adjustment method of each business module is consistent, which facilitates unified management.
Smart Images

Figure CN115964990B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminal control, and in particular to a method and device for adjusting text font size, an electronic device, and a storage medium. Background Art
[0002] Different users have different requirements for text font size. For example, elderly users, due to aging and other factors, may have decreased vision and therefore require a relatively large text font size. Meanwhile, young users, with good eyesight, may prefer a relatively small text font size. To meet the varying needs of different users, various applications have implemented text font size adjustment functionality. However, the logic behind implementing this functionality is complex and difficult to maintain. Summary of the Invention
[0003] To solve the above technical problems, embodiments of the present application provide a method and device for adjusting text font size, an electronic device, and a storage medium.
[0004] According to one aspect of an embodiment of the present application, a method for adjusting text font size is provided, the method comprising:
[0005] After receiving the font size adjustment instruction, determining the text to be adjusted whose font size is to be adjusted from the application program;
[0006] Searching for a target program entry corresponding to the business module to which the text to be adjusted belongs from a program entry set, wherein the program entry set includes program entries corresponding to a plurality of business modules deployed by the application program, and the program entries included in the program entry set are used to provide a direct channel for accessing a text setting program set in the corresponding business module;
[0007] determining a target font size of the text to be adjusted according to the font size adjustment instruction;
[0008] The target font size of the text to be adjusted is passed into the corresponding text setting program according to the target program entry, so that the corresponding text setting program adjusts the font size of the text to be adjusted contained in the corresponding business module based on the target font size of the text to be adjusted.
[0009] According to one aspect of an embodiment of the present application, a device for adjusting text font size is provided, the device comprising:
[0010] A first determining module is configured to determine, from the application program, a text to be adjusted whose font size is to be adjusted after receiving the font size adjustment instruction;
[0011] a search module configured to search for a target program entry corresponding to the business module to which the text to be adjusted belongs from a program entry set, wherein the program entry set includes program entries corresponding to a plurality of business modules deployed by the application program, and the program entries included in the program entry set are used to provide a direct channel for accessing a text setting program set in the corresponding business module;
[0012] a second determining module configured to determine a target font size of the text to be adjusted according to the font size adjustment instruction;
[0013] The adjustment module is configured to pass the target font size of the text to be adjusted into the corresponding text setting program according to the target program entry, so that the corresponding text setting program adjusts the font size of the text to be adjusted contained in the corresponding business module based on the target font size of the text to be adjusted.
[0014] In one embodiment of the present application, each business module included in the application is provided with a text setting program; the device further includes:
[0015] A program search module configured to search for a text setting program from each of the business modules;
[0016] A program entry generation module is configured to construct a direct access channel for accessing the found text setting program, and generate a program entry corresponding to the corresponding business module according to the direct access channel;
[0017] The set obtaining module is configured to obtain the program entry set based on the generated program entry.
[0018] In one embodiment of the present application, the program entry generation module includes:
[0019] an inserting module configured to insert an anchor point at a starting point of the found text setting program through a preset function, so as to establish a mapping relationship between the preset function and the corresponding text setting program;
[0020] The direct access generation module is configured to generate a direct access channel for accessing the corresponding text setting program according to the mapping relationship between the preset function and the corresponding text setting program.
[0021] In one embodiment of the present application, the apparatus further includes:
[0022] The size determination module is configured to determine the target size of the view to which the text to be adjusted belongs based on the target font size of the text to be adjusted, the view to which the text to be adjusted belongs, and the view layout relationship of the page to which the text to be adjusted belongs.
[0023] The view adjustment module is configured to adjust the size of the view to which the text to be adjusted belongs based on the determined target size.
[0024] In one embodiment of the present application, the first determining module includes:
[0025] The page determination module is configured to determine a page whose font size is to be adjusted from the application program.
[0026] The text determination module is configured to traverse the views in the page, and if the display object corresponding to the traversed view is text, the display object is used as the text to be adjusted whose font size is to be adjusted.
[0027] In one embodiment of the present application, the page determination module includes:
[0028] The view controller determination module is configured to determine the undestroyed view controllers in the key window of the application; wherein one page corresponds to one view controller.
[0029] The page determination submodule is configured to use the page corresponding to the determined view controller as the page whose font size is to be adjusted.
[0030] In one embodiment of the present application, the apparatus further includes:
[0031] The generating module is configured to generate text data according to the text to be adjusted after the font size is adjusted.
[0032] The storage module is configured to store the text data so as to adjust the font size of the text in the corresponding page based on the stored text data when a font size adjustment instruction is received again.
[0033] According to one aspect of an embodiment of the present application, an electronic device is provided, including:
[0034] one or more processors;
[0035] The storage device is used to store one or more programs, and when the one or more programs are executed by the one or more processors, the electronic device implements the method as described above.
[0036] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a computer, the computer executes the method described above.
[0037] According to one aspect of an embodiment of the present application, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the method described above.
[0038] In the technical solution provided in the embodiments of the present application, after receiving a font size adjustment instruction, the text to be adjusted whose font size is to be adjusted is determined from the application; the target program entry corresponding to the business module to which the text to be adjusted belongs is searched from the program entry set, wherein the program entry set includes program entries corresponding to multiple business modules deployed by the application, and the program entry is used to provide a direct channel for accessing the text setting program set in the corresponding business module; the target font size of the text to be adjusted is determined according to the font size adjustment instruction; the target font size of the text to be adjusted is passed into the corresponding text setting program according to the target program entry, so that the corresponding text setting program adjusts the font size of the text to be adjusted contained in the corresponding business module based on the target font size of the text to be adjusted; in this way, through the program entry set, the direct channel of the text setting program set in each business module deployed in the application can be queried, and the target font size of the text to be adjusted is passed into the corresponding text setting program through the direct channel, without the need to perceive the calling relationship of the text setting program within each business module, so that the implementation logic is simple and easy to maintain.
[0039] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The accompanying drawings are incorporated into and constitute a part of the specification, illustrating embodiments consistent with the present application and, together with the specification, serving to explain the principles of the present application. It is obvious that the drawings described below are merely some embodiments of the present application, and a person of ordinary skill in the art can derive other drawings based on these drawings without inventive effort. In the drawings:
[0041] Figure 1 It is a schematic diagram of an implementation environment involved in this application.
[0042] Figure 2 This is a flowchart of a method for adjusting text font size shown in an exemplary embodiment of the present application.
[0043] Figure 3 FIG. 4 is a flowchart of a method for adjusting text font size shown in another exemplary embodiment of the present application.
[0044] Figure 4 yes Figure 3 The illustrated embodiment is a flow chart of step S220 in an exemplary embodiment.
[0045] Figure 5 The figure is a flowchart of a method for adjusting text font size according to another exemplary embodiment.
[0046] Figure 6 FIG. 1 is a schematic diagram showing a comparison of pages before and after adjustment according to an exemplary embodiment of the present application.
[0047] Figure 7 yes Figure 2 The illustrated embodiment is a flow chart of step S110 in an exemplary embodiment.
[0048] Figure 8 FIG. 4 is a flowchart of a method for adjusting text font size shown in an exemplary embodiment of the present application.
[0049] Figure 9 It is a block diagram of a device for adjusting text font size shown in an exemplary embodiment of the present application.
[0050] Figure 10 It is a structural diagram of an electronic device shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0051] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. When the following description refers to the drawings, identical numerals in different figures represent identical or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0052] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically separate entities. That is, these functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0053] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, while others may be combined or partially combined. Therefore, the actual execution order may vary depending on the actual situation.
[0054] It should also be noted that the term "plurality" used in this application refers to two or more. "And / or" describes the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, or B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.
[0055] In the related art, in order to meet the needs of different users for text font size, a text font size adjustment function is deployed in the application. However, in the related art, the application includes different business modules, and each business module is provided with a text setting program. When implementing the text font size adjustment, it is necessary to first notify the business module, and then the business module queries the internal call relationship, finds the text setting program set by itself according to the internal call relationship, and then adjusts the font size of the text based on the text setting program. The implementation logic is complex, and the internal call relationships of different business modules are different, which is not convenient for maintenance. Based on this, the embodiment of the present application proposes a text font size adjustment method and device, electronic device, and storage medium, so that the text font size adjustment implementation logic is simple and easy to maintain.
[0056] See also Figure 1 , Figure 1 Schematic diagram of an implementation environment involved in the present application, which includes a terminal device 100 and a text font size adjustment device 200, wherein the terminal device 100 and the adjustment device 200 communicate with each other via a wired or wireless network.
[0057] The terminal device 100 has an application installed therein, wherein the application provides a font size adjustment function. The adjustment apparatus 200 is used to adjust the text font size of the application installed in the terminal device 100 .
[0058] Among them, after receiving the font size adjustment instruction, the adjustment device 200 determines the text to be adjusted whose font size is to be adjusted from the application of the terminal device 100; searches for the target program entry corresponding to the business module to which the text to be adjusted belongs from the program entry set, wherein the program entry set includes program entries corresponding to multiple business modules deployed by the application, and the program entry is used to provide a direct channel to access the text setting program set in the corresponding business module; determines the target font size of the text to be adjusted according to the font size adjustment instruction; passes the target font size of the text to be adjusted into the corresponding text setting program according to the target program entry, so that the corresponding text setting program adjusts the font size of the text to be adjusted contained in the corresponding business module based on the target font size of the text to be adjusted; in this way, through the program entry set, the direct channel of the text setting program set in each business module deployed in the application can be queried, and the target font size of the text to be adjusted can be passed into the corresponding text setting program through the direct channel, without the need to perceive the calling relationship of the text setting program within each business module, so that the implementation logic is simple and easy to maintain.
[0059] Among them, the terminal device 100 includes but is not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, car terminals, etc.
[0060] In one embodiment, the adjustment device 200 can be a server of the terminal device 100, wherein the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. This is not restricted here.
[0061] In another embodiment, the adjustment device 200 and the terminal device 100 may be the same electronic device. That is, after receiving the font size adjustment instruction, the adjustment device 200 determines the text to be adjusted whose font size is to be adjusted from the application programs installed on the device; searches for the target program entry corresponding to the business module to which the text to be adjusted belongs from the program entry set; determines the target font size of the text to be adjusted based on the font size adjustment instruction; and transmits the target font size of the text to be adjusted to the corresponding text setting program based on the target font size of the text to be adjusted, so that the corresponding text setting program adjusts the font size of the text to be adjusted contained in the corresponding business module based on the target font size of the text to be adjusted.
[0062] It should be noted that, in addition to the aforementioned application scenarios, the embodiments of the present application can also be applied to various application scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, etc. In actual applications, corresponding adjustments can be made according to the specific application scenarios. For example, if applied to a cloud technology scenario, the application in the terminal device 100 can be an application running based on cloud technology; if applied to an artificial intelligence scenario, the application in the terminal device 100 can be an application created based on artificial intelligence technology; if applied to a smart transportation or assisted driving scenario, the terminal device 100 can be an in-vehicle terminal, a navigation terminal, etc., and the application in the terminal device 100 can be an application for navigation, an application for assisted driving, etc.
[0063] See also Figure 2 , Figure 2 This is a flow chart of a method for adjusting the font size of a text according to an exemplary embodiment. Figure 1 The implementation environment shown and Figure 1 The text font size adjustment device 200 in the illustrated implementation environment is specifically implemented.
[0064] like Figure 2 As shown, in an exemplary embodiment, the method for adjusting the text font size may include steps S110 to S140, which are described in detail as follows:
[0065] Step S110 : After receiving the font size adjustment instruction, determine the text to be adjusted whose font size is to be adjusted from the application program.
[0066] First, it should be noted that an application refers to a computer program designed to perform one or more specific tasks. During operation, an application displays a page that may contain text, images, etc. A font size adjustment instruction is used to instruct adjustment of the font size of the text contained in the application. It may indicate enlarging the font size of the text or reducing the font size of the text. The font size adjustment instruction may be generated based on a user's operation. That is, the user may trigger a font size adjustment function in the application to generate a font size adjustment instruction. For example, the application may include a font size adjustment control, and the user may trigger the font size adjustment control through a user input interface (e.g., a physical button or a touch screen), thereby generating a font size adjustment instruction. Alternatively, the font size adjustment instruction may be automatically generated based on relevant parameters. For example, in order to implement a function that adaptively adjusts the text font size based on the distance between the user and the terminal device, a font size adjustment instruction may be automatically generated when the distance between the user and the terminal device changes. Of course, the font size adjustment instruction may also be generated based on other methods, and this embodiment does not limit the method for generating the font size adjustment instruction.
[0067] The text to be adjusted is the text in the application whose font size needs to be adjusted. It can be Rich Text Format (RTF) or plain text. This embodiment does not limit the type of text to be adjusted. It should be noted that Rich Text supports a variety of formats, including text, links, pictures, etc., and supports adjustment of underline, font size, word spacing, baseline offset value, font paragraph style, line spacing, line wrapping method, and text alignment parameters.
[0068] Secondly, during the running process of the application, a font size adjustment instruction for the application may be received. After receiving the font size adjustment instruction, the text to be adjusted, whose font size is to be adjusted, may be determined from the application.
[0069] The specific method for determining the text to be adjusted whose font size is to be adjusted from the application can be flexibly set according to actual needs. For example, in one embodiment, in order to achieve comprehensive adjustment of the font size of text within the application, all text included in the application can be used as the text to be adjusted; or, in another embodiment, the text included in the page currently displayed in the application can be used as the text to be adjusted; or, in yet another embodiment, the page currently displayed in the application and the page currently stored in the cache can be first determined, and the text included in the determined page can be used as the text to be adjusted.
[0070] Step S120 , searching the program entry set for a target program entry corresponding to the business module to which the text to be adjusted belongs.
[0071] It should be noted that there are multiple business modules deployed in the application. For example, for "WeChat", it includes business modules such as "Friends Circle", "Official Account", and "Video Account". In each business module, a text setting program is provided. The text setting program is used to control parameters such as the font size of the text, for example, the setfont() function. The program entry set contains program entries corresponding to multiple business modules deployed by the application. The program entry is used to provide a direct channel to access the text setting program set in the corresponding business module. In this way, the text setting program set in the business module can be directly accessed through the direct channel, so there is no need to perceive the calling relationship of the text setting program within each business module.
[0072] After determining the text to be adjusted whose font size is to be adjusted from the application, determine the business module to which the text to be adjusted belongs, so that the program entry corresponding to the business module to which the text to be adjusted belongs can be found from the program entry set, and the found program entry is used as the target program entry.
[0073] Step S130 : determining the target font size of the text to be adjusted according to the font size adjustment instruction.
[0074] The target font size is the font size of the text to be adjusted after adjustment. In other words, the target font size is the font size that the text to be adjusted is expected to reach.
[0075] After receiving a font size adjustment instruction and determining the text to be adjusted whose font size is to be adjusted from the application, the target font size of the text to be adjusted can be determined based on the font size adjustment instruction. The method of determining the target font size of the text to be adjusted based on the font size adjustment instruction can be flexibly set according to actual needs. For example, the font size adjustment instruction can be parsed. If the font size adjustment instruction includes a target font size parameter for the text to be adjusted, the target font size of the text to be adjusted can be obtained from the font size adjustment instruction. If the font size adjustment instruction only includes a font size adjustment trend parameter, wherein the font size adjustment trend parameter includes enlarging the font size or reducing the font size, the target font size of the text to be adjusted can be determined based on the current font size of the text to be adjusted and the font size adjustment trend parameter.
[0076] It should be noted that Figure 2 In the embodiment, the example of executing step S120 first and then executing step S130 is used for explanation; in actual operation, step S130 may be executed first and then step S120, or step S120 and step S130 may be executed at the same time. In this embodiment, the execution order of step S120 and step S130 is not restricted.
[0077] Step S140 , the target font size of the text to be adjusted is passed to the corresponding text setting program according to the target program entry, so that the corresponding text setting program adjusts the font size of the text to be adjusted contained in the corresponding business module based on the target font size of the text to be adjusted.
[0078] After finding the target program entry and determining the target font size of the text to be adjusted, the calling relationship related to the text setting program in the business module can be skipped, and the target font size can be directly passed into the corresponding text setting program according to the target program entry, so that the corresponding text setting program adjusts the font size of the text to be adjusted contained in the corresponding business module based on the target font size. For example, assuming that the application includes three business modules, namely business module a, business module b, and business module c, and the text to be adjusted belongs to business module a, then the program entry corresponding to business module a is used as the target program entry, and the target font size is passed into the program entry corresponding to business module a, so that the text setting program set in business module a adjusts the font size of the text to be adjusted in business module a based on the target font size.
[0079] Among them, the specific way in which the text setting program adjusts the font size of the text to be adjusted contained in the corresponding business module based on the target font size of the text to be adjusted can be flexibly set according to actual needs. For example, the text setting program can control the generation of text data of the text to be adjusted corresponding to the target font size, and then, when the page to which the text to be adjusted belongs is displayed, the generated text data will be drawn in the page to which the text to be adjusted belongs.
[0080] The technical solution provided by this embodiment, after receiving the font size adjustment instruction, determines the text to be adjusted whose font size is to be adjusted from the application; searches for the target program entry corresponding to the business module to which the text to be adjusted belongs from the program entry set, wherein the program entry set includes program entries corresponding to multiple business modules deployed by the application, and the program entry is used to provide a direct channel to access the text setting program set in the corresponding business module; determines the target font size of the text to be adjusted according to the font size adjustment instruction; passes the target font size of the text to be adjusted into the corresponding text setting program according to the target program entry, so that the corresponding text setting program adjusts the font size of the text to be adjusted contained in the corresponding business module based on the target font size of the text to be adjusted; through the program entry set, the direct channel of the text setting program set in each business module deployed in the application can be queried, and the target font size of the text to be adjusted is passed into the corresponding text setting program through the direct channel, without the need to perceive the calling relationship of the text setting program within each business module, so that the implementation logic is simple, and the font size adjustment method of each business module is the same, which is convenient for maintenance and upgrading.
[0081] See also Figure 3 , Figure 3 FIG. 1 is a flow chart showing a method for adjusting the font size of a text according to another exemplary embodiment. Figure 3 As shown, under the condition that a text setting program is set in each business module included in the application, Figure 2 Before step S120 (searching the target program entry corresponding to the business module to which the text to be adjusted belongs from the program entry set) in the illustrated embodiment, the method may further include steps S210 to S230, which are described in detail as follows:
[0082] Step S210: Search for a text setting program in each business module.
[0083] The application program is deployed with multiple business modules, and each business module is provided with a text setting program. In this embodiment, the text setting program is searched for in each business module included in the application program.
[0084] Step S220: construct a direct channel for accessing the found text setting program, and generate a program entry corresponding to the corresponding business module according to the direct channel.
[0085] After finding the text setting program, a direct access channel is constructed to access the text setting program, and based on the direct access channel to the text setting program, a program entry corresponding to the business module to which the text setting program belongs is generated. For example, assuming that text setting program a belongs to business module A, after finding text setting program a in business module A, a direct access channel is constructed to access text setting program a, and based on the direct access channel to text setting program a, a program entry corresponding to business module A is generated.
[0086] The specific implementation method of constructing a direct channel for accessing the found text setting program can be flexibly set according to actual needs. For example, in one implementation, a direct channel for accessing the found text setting program can be constructed based on memory mapping technology.
[0087] Step S230: obtaining the program entry set based on the generated program entry.
[0088] After generating the program entry corresponding to each business module, a program entry set can be obtained.
[0089] In this embodiment, before adjusting the font size of the text, a text setting program is first searched for in each business module, a direct channel for accessing the found text setting program is constructed, and a program entry corresponding to the corresponding business module is generated based on the direct channel. Then, a program entry set is obtained based on the generated program entry, so that after receiving the font size adjustment instruction, the program entry of the font setting program corresponding to the text to be adjusted can be quickly found based on the program entry set, thereby adjusting the font size of the text to be adjusted, improving the speed of font size adjustment, and in the process of searching for the font setting program, there is no need to perceive the complex calling relationship within the business module, so the implementation logic is simple, which is convenient for subsequent maintenance and upgrades.
[0090] See also Figure 4 , Figure 4 yes Figure 3 The flowchart of step S220 in the embodiment shown is in an exemplary embodiment. Figure 4 As shown, the process of constructing a direct channel for accessing the found text setting program may include steps S221 to S222, which are described in detail as follows:
[0091] Step S221 : inserting an anchor point at the starting point of the found text setting program through a preset function to construct a mapping relationship between the preset function and the corresponding text setting program.
[0092] The preset function can be a hook function or other functions. In iOS (a mobile operating system developed by Apple), the hook function can be implemented through method swizzling. It should be understood that method swizzling is a syntax feature used in iOS development, which allows iOS programs to be hooked during operation.
[0093] By using a preset function, an anchor point is inserted at the starting point of the found text setting program, thereby establishing a mapping relationship between the preset function and the corresponding text setting program.
[0094] Step S222: generating a direct channel for accessing the corresponding text setting program according to the mapping relationship between the preset function and the corresponding text setting program.
[0095] After obtaining the mapping relationship between the preset function and the corresponding text setting program, a direct channel for accessing the corresponding text setting program can be generated based on the mapping relationship between the preset function and the corresponding text setting program, thereby obtaining the program entry corresponding to the corresponding business module. In this way, by calling the preset function, the anchor point of the text setting program can be found, and the text setting program set in the business module can be directly accessed based on the anchor point, thereby providing a unified entry for the text setting programs of multiple business modules in the application.
[0096] See also Figure 5 , Figure 5 FIG. 1 is a flow chart of a method for adjusting text font size according to another exemplary embodiment. Figure 5 As shown, in Figure 2 After step S130 (determining the target size of the text to be adjusted according to the font size adjustment instruction) in the illustrated embodiment, the method may further include steps S310 to S320, which are described in detail as follows:
[0097] Step S310 , determining a target size of the view to which the text to be adjusted belongs based on the target font size of the text to be adjusted, the view to which the text to be adjusted belongs, and the view layout relationship of the page to which the text to be adjusted belongs.
[0098] It should be noted that the view to which the text to be adjusted belongs is the parent view of the text to be adjusted, and the text to be adjusted will be displayed in this view.
[0099] If only the text size is adjusted, the text size may not match the view size, resulting in an uncoordinated screen and incomplete text display. To avoid these problems, in this embodiment, the size of the view to which the text to be adjusted belongs is also adjusted. After determining the target font size of the text to be adjusted, the target size of the view to which the text to be adjusted belongs can also be determined based on the target font size, the view to which the text to be adjusted belongs, and the view layout relationship of the page to which the text to be adjusted belongs.
[0100] The specific implementation of step S310 can be flexibly set according to actual needs.
[0101] For example, in one example, based on the target font size of the text to be adjusted, the view to which the text to be adjusted belongs, and the view layout relationship of the page to which the text to be adjusted belongs, the process of determining the target size of the view to which the text to be adjusted belongs may include steps S311 to S312, which are described in detail as follows:
[0102] Step S311 : obtaining a target size of a display area corresponding to the text to be adjusted based on a target font size of the text to be adjusted.
[0103] The specific method of obtaining the target size of the display area corresponding to the text to be adjusted based on the target font size of the text to be adjusted can be flexibly set according to actual needs.
[0104] For example, in one embodiment, step S311 may be steps S410 to S450, which are described in detail as follows:
[0105] Step S410: Obtain the specific content of the text to be adjusted.
[0106] Step S420: Obtain the maximum width of the display area corresponding to the text to be adjusted.
[0107] A mapping relationship between the font size of the text to be adjusted and the maximum width of the corresponding display area may be preset, and then the corresponding maximum width may be found from the mapping relationship based on the target font size of the text to be adjusted.
[0108] Step S430: determining the maximum number of lines corresponding to the text to be adjusted based on the specific content of the text to be adjusted.
[0109] Based on the obtained maximum width and the target font size of the text to be adjusted, the number of words that can be displayed in a line can be determined. Then, based on the specific content of the text to be adjusted and the number of words that can be displayed in a line, the maximum number of lines corresponding to the text to be adjusted can be determined.
[0110] Step S440: Obtain the line spacing, character spacing, and paragraph style of the text to be adjusted.
[0111] Step S450 , determining a target size of a display area corresponding to the text to be adjusted based on the maximum width, maximum number of lines, target font size, line spacing, character spacing, and paragraph style of the text to be adjusted.
[0112] Among them, parameters such as the maximum width, maximum number of lines, target font size, line spacing, character spacing and paragraph style of the text to be adjusted can be passed into the boundingRectWithSize function, so that the boundingRectWithSize function determines the target size of the display area corresponding to the text to be adjusted based on the maximum width, maximum number of lines, target font size, line spacing, character spacing and paragraph style.
[0113] In this embodiment, parameters such as the character spacing, baseline offset value, line breaking method, and text alignment method of the text to be adjusted can also be obtained and passed into the boundingRectWithSize function as reference parameters for determining the target size of the display area corresponding to the text to be adjusted.
[0114] In another example, a mapping relationship between the font size of the text to be adjusted and the size of the display area corresponding to the text to be adjusted can be pre-set. Then, from the mapping relationship, the size corresponding to the target font size of the text to be adjusted is found as the target size of the display area corresponding to the text to be adjusted. In the mapping relationship between the font size of the text to be adjusted and the size of the display area corresponding to the text to be adjusted, the size of the display area corresponding to the text to be adjusted can be determined based on the method corresponding to steps S410 to S450, and of course, can also be determined based on other methods.
[0115] Step S312 : determining a target size of the view to which the text to be adjusted belongs based on a target size of the display area corresponding to the text to be adjusted and a view layout relationship of the page to which the text to be adjusted belongs.
[0116] The margin (outer margin) and padding (inner margin) of the view to which the text to be adjusted belongs can be determined based on the target size of the display area corresponding to the text to be adjusted, and the target size of the view to which the text to be adjusted belongs can be determined based on the margin and padding of the view to which the text to be adjusted belongs and the view layout relationship of the page to which the text to be adjusted belongs. The larger the target size of the display area corresponding to the text to be adjusted, the smaller the margin and padding of the view to which the text to be adjusted belongs, or the smaller the target size of the display area corresponding to the text to be adjusted, the larger the margin and padding of the view to which the text to be adjusted belongs.
[0117] Step S320 : adjusting the size of the view to which the text to be adjusted belongs based on the determined target size.
[0118] After determining the target size of each view in the page to which the text to be adjusted belongs, the size of the view to which the text to be adjusted belongs is adjusted.
[0119] See also Figure 6 ,in, Figure 6 , the left side shows the font size of the text and the size of the view before adjustment, and the right side shows the font size of the text and the size of the view after adjustment.
[0120] In this embodiment, the target size of the view to which the text to be adjusted belongs is determined based on the target font size of the text to be adjusted, the view to which the text to be adjusted belongs, and the view layout relationship of the page to which the text to be adjusted belongs. Then, based on the determined target size, the size of the view to which the text to be adjusted belongs is adjusted. In this way, when the font size of the text is adjusted, the size of the view to which the text belongs is also adjusted, so that the size of the text matches the size of the view to which it belongs; and when determining the size of the view to which it belongs, the view layout relationship is referred to, so as to avoid the problem of blocking other views after the view is adjusted.
[0121] In an exemplary embodiment, if only the size of the view to which the text to be adjusted belongs is adjusted, the size of the view will not match the size of the parent view of the view. Figure 5 After step S310, the parent view of the view to which the text to be adjusted belongs may be determined first. Then, based on the target size of the view to which the text to be adjusted belongs, the target size of the corresponding parent view may be determined, and the size of the corresponding parent view may be adjusted based on the target size of the parent view. Of course, in other embodiments, the sizes of all views in the page to which the text to be adjusted belongs may also be adjusted to make the adjusted page coordinated.
[0122] See also Figure 7 , Figure 7 yes Figure 2 The flowchart of step S110 in the embodiment shown is in an exemplary embodiment. Figure 7 As shown, the process of determining the text to be adjusted whose font size is to be adjusted from the application program may include steps S111 to S112, which are described in detail as follows:
[0123] Step S111 : determining a page whose font size is to be adjusted from the application program.
[0124] The pages whose font sizes are to be adjusted may be all pages included in the application, or may be pages currently being displayed.
[0125] Alternatively, in one embodiment, step S111 may include: determining an undestroyed view controller in the key window of the application; using the page corresponding to the determined view controller as the page whose font size is to be adjusted, wherein one page corresponds to one view controller. It should be noted that the KeyWindow (key window) refers to the active window, that is, the window that can receive user input events; the KeyWindow includes a view controller (viewController), which is used to control the view, and one page corresponds to one view controller. After the view controller is created, the view controller will be destroyed when certain conditions are met. The page corresponding to the undestroyed view controller in the key window of the application can be used as the page whose font size is to be adjusted.
[0126] Step S112 , traversing the views in the page, if the display object corresponding to the traversed view is text, then using the display object as the text to be adjusted whose font size is to be adjusted.
[0127] After determining the page whose font size is to be adjusted, the views in the page may be traversed. If the display object corresponding to the traversed view is text, the display object is used as the text whose font size is to be adjusted.
[0128] In an exemplary embodiment, Figure 3 After step S140, the method for adjusting the text font size may further include steps S150 to S160, which are described in detail as follows:
[0129] Step S150 , generating text data according to the text to be adjusted after the font size is adjusted.
[0130] In this embodiment, text data is generated based on the text to be adjusted after the font size is adjusted, that is, the text to be adjusted corresponding to the target font size.
[0131] Step S160 , storing the text data so that when a font size adjustment instruction is received again, the font size of the text in the corresponding page is adjusted based on the stored text data.
[0132] After generating the text data, the text data is stored. In this way, when the font size adjustment instruction is received again, if the text to be adjusted corresponding to the font size adjustment instruction received again and the target font size corresponding to the text to be adjusted match the stored text data, the text to be adjusted can be directly drawn in the page to which the text to be adjusted belongs based on the stored text data, without the need to generate the text data again, thereby improving the speed of font size adjustment.
[0133] See also Figure 8 In an exemplary embodiment, the method for adjusting the text font size includes:
[0134] Start font switching. After receiving the font size adjustment instruction, start font switching.
[0135] Create TXFontCenter. Create TXFontCenter and initialize TXFontCenter. During the initialization process, create NSOperationQueue (operation queue) inside TXFontCenter. Then, you can use TXFontCenter to implement subsequent steps such as "add to NSOperationQueue".
[0136] Add to NSOperationQueue, where the view written to NSOperationQueue is processed first. Specifically, first traverse all undestroyed viewControllers (view controllers) in the current keyWindow (key window), and obtain the display objects corresponding to the view (view) and its subviews (subviews) in the viewController through the objc_getAssociatedObject function; if there is a text-related API (Application Programming Interface) in the display object, then use the display object as the text to be adjusted, and obtain and save the view layout relationship of the page to which the text to be adjusted belongs; then, determine the target font size of the text to be adjusted based on the font size adjustment instruction, and add the view to which the text to be adjusted belongs and the target size of the display area corresponding to the text to be adjusted to NSOperationQueue. Among them, the objc_getAssociatedObject function is an association function.
[0137] Determine whether the view to which the text to be adjusted belongs has a parent view. Here, you can obtain the view to which the text to be adjusted belongs from NSOperationQueue and determine whether the view to which the text to be adjusted belongs has a parent view.
[0138] If it exists, recursively traverse the parent view of the view to which the text to be adjusted belongs.
[0139] Modify the size of the view based on the view layout relationship. If a parent view exists, determine the target size of the view to which the text to be adjusted belongs and the parent view of the view to which the text to be adjusted belongs based on the view layout relationship, and then modify the size of the corresponding view based on the target size.
[0140] Generating text data corresponding to the target font size. Passing the target font size into the corresponding text setting program through the target program entry, so that the corresponding text setting program controls the generation of text data corresponding to the target font size for the text to be adjusted.
[0141] Write the text data into the cache. When the page to which the text to be adjusted belongs is displayed, the text data is retrieved from the cache and drawn on the page to which the text to be adjusted belongs.
[0142] The text data may also be stored, so that when a font size adjustment instruction is received again, if the font size adjustment instruction matches the text data, the text data may be directly obtained and drawn on the page.
[0143] Figure 9 1 is a block diagram of a device for adjusting text font size, shown in an exemplary embodiment of the present application. The device includes:
[0144] The first determination module 901 is configured to determine the text to be adjusted whose font size is to be adjusted from the application after receiving the font size adjustment instruction; the search module 902 is configured to search for the target program entry corresponding to the business module to which the text to be adjusted belongs from the program entry set, wherein the program entry set includes program entries corresponding to multiple business modules deployed by the application, and the program entries included in the program entry set are used to provide a direct channel to access the text setting program set in the corresponding business module; the second determination module 903 is configured to determine the target font size of the text to be adjusted according to the font size adjustment instruction; the adjustment module 904 is configured to pass the target font size of the text to be adjusted into the corresponding text setting program according to the target program entry, so that the corresponding text setting program adjusts the font size of the text to be adjusted contained in the corresponding business module based on the target font size of the text to be adjusted.
[0145] In another exemplary embodiment, under the condition that a text setting program is provided in each business module included in the application, the apparatus further comprises:
[0146] The program search module is configured to search for a text setting program from each business module.
[0147] The program entry generation module is configured to build a direct channel for accessing the text setting program that has been found, and generate a program entry corresponding to the corresponding business module based on the direct channel.
[0148] The set obtaining module is configured to obtain a program entry set based on the generated program entry.
[0149] In another exemplary embodiment, the program entry generation module includes:
[0150] The inserting module is configured to insert an anchor point at the starting point of the found text setting program through a preset function to establish a mapping relationship between the preset function and the corresponding text setting program.
[0151] The direct access generation module is configured to generate a direct access channel for accessing the corresponding text setting program according to the mapping relationship between the preset function and the corresponding text setting program.
[0152] In another exemplary embodiment, the apparatus further comprises:
[0153] The size determination module is configured to determine the target size of the view to which the text to be adjusted belongs based on the target font size of the text to be adjusted, the view to which the text to be adjusted belongs, and the view layout relationship of the page to which the text to be adjusted belongs.
[0154] The view adjustment module is configured to adjust the size of the view to which the text to be adjusted belongs based on the determined target size.
[0155] In another exemplary embodiment, the first determining module 901 includes:
[0156] The page determination module is configured to determine a page whose font size is to be adjusted from the application program.
[0157] The text determination module is configured to traverse the views in the page. If the display object corresponding to the traversed view is text, the display object is used as the text to be adjusted whose font size is to be adjusted.
[0158] In another exemplary embodiment, the page determination module includes:
[0159] The view controller determination module is configured to determine an undestroyed view controller in a key window of an application; wherein one page corresponds to one view controller.
[0160] The page determination submodule is configured to use the page corresponding to the determined view controller as the page whose font size is to be adjusted.
[0161] In another exemplary embodiment, the apparatus further comprises:
[0162] The generating module is configured to generate text data according to the text to be adjusted after the font size is adjusted.
[0163] The storage module is configured to store the text data so as to adjust the font size of the text in the corresponding page based on the stored text data when a font size adjustment instruction is received again.
[0164] It should be noted that the apparatus provided in the above embodiment and the method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs operations has been described in detail in the method embodiment and will not be repeated here.
[0165] An embodiment of the present application also provides an electronic device, including a storage device and one or more processors, wherein the storage device is used to store one or more programs. When the one or more programs are executed by one or more processors, the electronic device implements the text font size adjustment method provided in the above-mentioned embodiments.
[0166] Figure 10 The figure is a schematic structural diagram of an electronic device according to an exemplary embodiment.
[0167] It should be noted that the electronic device is only an example adapted for this application and cannot be considered to provide any limitation on the scope of use of this application. The electronic device cannot be interpreted as needing to rely on or must have Figure 10 One or more components of an exemplary electronic device shown in FIG.
[0168] like Figure 10 As shown in FIG. 1 , in an exemplary embodiment, the electronic device includes a processing component 1001, a memory 1002, a power supply component 1003, a multimedia component 1004, an audio component 1005, a sensor component 1007, and a communication component 1008. Not all of the above components are required, and the electronic device may add other components or reduce certain components according to its own functional requirements, which is not limited in this embodiment.
[0169] The processing component 1001 generally controls the overall operation of the electronic device, such as operations associated with display, data communication, and log data processing. The processing component 1001 may include one or more processors 1009 to execute instructions to complete all or part of the steps of the above operations. In addition, the processing component 1001 may include one or more modules to facilitate interaction between the processing component 1001 and other components. For example, the processing component 1001 may include a multimedia module to facilitate interaction between the multimedia component 1004 and the processing component 1001.
[0170] The memory 1002 is configured to store various types of data to support operations on the electronic device. Examples of such data include instructions for any application or method operating on the electronic device. The memory 1002 stores one or more modules configured to be executed by the one or more processors 1009 to complete all or part of the steps in the method described in the above embodiments.
[0171] The power supply component 1003 provides power to various components of the electronic device. The power supply component 1003 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device.
[0172] The multimedia component 1004 includes a screen that provides an output interface between the electronic device and the user. In some embodiments, the screen may include a TP (Touch Panel) and an LCD (Liquid Crystal Display). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, slides, and gestures on the touch panel. The touch sensor may not only sense the boundaries of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.
[0173] The audio component 1005 is configured to output and / or input audio signals. For example, the audio component 1005 includes a microphone, which is configured to receive external audio signals when the electronic device is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. In some embodiments, the audio component 1005 also includes a speaker for outputting audio signals.
[0174] The sensor component 1007 includes one or more sensors for providing status assessments of various aspects of the electronic device. For example, the sensor component 1007 can detect the open / close state of the electronic device and the temperature change of the electronic device.
[0175] The communication component 1008 is configured to facilitate wired or wireless communication between the electronic device and other devices. The electronic device can access a wireless network based on a communication standard, such as Wi-Fi (Wireless-Fidelity).
[0176] I understand. Figure 10 The structure shown is for illustration only. The electronic device may include Figure 10 More or fewer components as shown, or with Figure 10 Different components are shown. Figure 10 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0177] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. Among them, each box in the flowchart or block diagram can represent a module, program segment, or part of the code, and the above-mentioned module, program segment, or part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0178] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. In some cases, the names of these units do not constitute limitations on the units themselves.
[0179] Another aspect of the present application provides a computer-readable storage medium having computer-readable instructions stored thereon. When executed by a computer processor, the computer executes the text font size adjustment method provided in each of the above embodiments. The computer-readable storage medium may be included in the electronic device described in the above embodiments, or may exist independently and not be incorporated into the electronic device.
[0180] It should be noted that the computer-readable storage medium of the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, which carries a computer-readable computer program. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. A computer program embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, or any suitable combination thereof.
[0181] Another aspect of the present application provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the text font size adjustment method provided in each of the above embodiments.
[0182] The above content is only a preferred exemplary embodiment of the present application and is not intended to limit the implementation scheme of the present application. Ordinary technicians in this field can easily make corresponding changes or modifications based on the main ideas and spirit of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection required by the claims.
Claims
1. A method for adjusting the font size of a text, characterized in that: The method comprises: After receiving the font size adjustment instruction, determining the text to be adjusted whose font size is to be adjusted from the application program; Searching for a target program entry corresponding to the business module to which the text to be adjusted belongs from a program entry set, wherein the program entry set includes program entries corresponding to a plurality of business modules deployed by the application program, and the program entries included in the program entry set are used to provide a direct channel for accessing a text setting program set in the corresponding business module; determining a target font size of the text to be adjusted according to the font size adjustment instruction; The target font size of the text to be adjusted is passed into the corresponding text setting program according to the target program entry, so that the corresponding text setting program adjusts the font size of the text to be adjusted contained in the corresponding business module based on the target font size of the text to be adjusted.
2. The method according to claim 1, wherein Each business module included in the application is provided with a text setting program; before searching the set of program entries for a target program entry corresponding to the business module to which the text to be adjusted belongs, the method further comprises: Finding a text setting program from each of the business modules; Constructing a direct access channel to the found text setting program, and generating a program entry corresponding to the corresponding business module according to the direct access channel; The program entry set is obtained based on the generated program entry.
3. The method according to claim 2, wherein The construction provides a direct access to the found text setting program, including: Inserting an anchor point at the starting point of the found text setting program through a preset function to establish a mapping relationship between the preset function and the corresponding text setting program; A direct channel for accessing the corresponding text setting program is generated according to the mapping relationship between the preset function and the corresponding text setting program.
4. The method according to claim 1, wherein After determining the target font size of the text to be adjusted according to the font size adjustment instruction, the method further includes: Determining a target size of the view to which the text to be adjusted belongs based on a target font size of the text to be adjusted, the view to which the text to be adjusted belongs, and a view layout relationship of a page to which the text to be adjusted belongs; Based on the determined target size, the size of the view to which the text to be adjusted belongs is adjusted.
5. The method according to claim 1, wherein The step of determining the text to be adjusted whose font size is to be adjusted from the application program includes: Determine the page from the application for which the font size is to be adjusted; The views in the page are traversed, and if the display object corresponding to the traversed view is text, the display object is used as the text to be adjusted whose font size is to be adjusted.
6. The method according to claim 5, wherein The step of determining the page whose font size is to be adjusted from the application program includes: Determining an undestroyed view controller in a key window of the application; wherein one page corresponds to one view controller; The page corresponding to the determined view controller is used as the page whose font size is to be adjusted.
7. The method according to claim 1, wherein After the target font size of the text to be adjusted is transferred to the corresponding text setting program according to the target program entry, so that the corresponding text setting program adjusts the font size of the text to be adjusted contained in the corresponding business module based on the target font size of the text to be adjusted, the method further includes: Generate text data according to the text to be adjusted after the font size is adjusted; The text data is stored so that when a font size adjustment instruction is received again, the font size of the text in the page to which the text to be adjusted belongs is adjusted based on the stored text data.
8. A device for adjusting the font size of a text, characterized in that: include: A first determining module is configured to determine, from the application program, a text to be adjusted whose font size is to be adjusted after receiving the font size adjustment instruction; a search module configured to search for a target program entry corresponding to the business module to which the text to be adjusted belongs from a program entry set, wherein the program entry set includes program entries corresponding to a plurality of business modules deployed by the application program, and the program entries included in the program entry set are used to provide a direct channel for accessing a text setting program set in the corresponding business module; a second determining module configured to determine a target font size of the text to be adjusted according to the font size adjustment instruction; The adjustment module is configured to pass the target font size of the text to be adjusted into the corresponding text setting program according to the target program entry, so that the corresponding text setting program adjusts the font size of the text to be adjusted contained in the corresponding business module based on the target font size of the text to be adjusted.
9. An electronic device, characterized in that: include: one or more processors; A storage device is used to store one or more programs, and when the one or more programs are executed by the one or more processors, the electronic device implements the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that Computer-readable instructions are stored thereon, and when the computer-readable instructions are executed by a processor of a computer, the computer is caused to execute the method according to any one of claims 1 to 7.
11. A computer program product comprising computer instructions, characterized in that When the computer instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Method and system for regulating type font of single module
CN104484315A
Font switching method, mobile terminal and computer readable storage medium
CN107153551A