Application text display method and device, electronic equipment and storage medium
By responding to text display needs in the application, obtaining language type information and font size mapping relationships, and adjusting font sizes to adapt to the actual pattern of text display, the problem of poor text display effect in different language environments is solved, and a better reading experience and text display effect is achieved.
Patent Information
- Application Number
- CN202411905162.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-04-15
AI Technical Summary
When the application is compatible with languages from different countries, the text display effect is poor, mainly due to inconsistent language lengths or problems that exceed the interface display area.
By responding to the application's text display needs, determine the target text and the expected number of lines, and obtain a list of call locations containing language type information, text display location information and font size mapping relationships. According to the target language type, text display location and font size, display the text and determine the actual number of lines, and determine whether the font size needs to be adjusted to adapt to the actual pattern of the target text display.
It realizes adaptive adjustment of text font size in the application, improves text display effect, adapts to text display needs in different language environments, and improves customer reading experience.
Smart Images

Figure CN119829758A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of text display technology, and in particular to an application text display method and device, electronic equipment, and storage medium. Background Art
[0002] With the popularity of smart devices, multi-language support has become a basic requirement in mobile application development; related technologies usually use fixed font sizes to perform multi-language adaptation. For example, developers preset a set of font sizes based on language characteristics and specify default font size configurations for different languages in the code.
[0003] However, when the front end of the application needs to be compatible with languages of different countries, the text display effect may be poor due to the inconsistent length of the language to be displayed in different language environments. For example, Chinese characters occupy less screen space, while words in English or other Latin alphabet languages may wrap or exceed the interface display area due to longer constituent characters. Summary of the invention
[0004] In view of the above problems, a method and device for displaying application text, an electronic device, and a storage medium are proposed to overcome the above problems or at least partially solve the above problems, including:
[0005] A method for displaying application text, the method comprising:
[0006] In response to the text display requirement of the application, determine the target text and the expected number of lines of the text display requirement of the application, and obtain a call location list; wherein the call location list at least includes the mapping relationship between the language type information, the text display location information and the font size in the application;
[0007] Determine the target language type of the target text, and determine the target text display location and target font size corresponding to the target text according to the call location list;
[0008] Display the target text according to the target language, the target text display location and the target font size, and determine the actual number of lines when the target text is displayed;
[0009] According to the actual number of lines and the expected number of lines, it is determined whether the target font size needs to be adjusted; and if the target font size needs to be adjusted, the target font size is adjusted.
[0010] Optionally, determining the actual number of lines of the target text when it is displayed includes:
[0011] Determine text line height information when the target text is displayed and height information of the location where the target text is displayed;
[0012] The actual number of lines when the target text is displayed is determined based on the text line height information and the height information of the target text display location.
[0013] Optionally, judging whether it is necessary to adjust the target font size according to the actual number of lines and the expected number of lines includes:
[0014] When the actual number of lines is less than or equal to the expected number of lines, determining that the target font size does not need to be adjusted;
[0015] When the actual number of lines is greater than the expected number of lines, it is determined that the target font size needs to be adjusted.
[0016] Optionally, the method further includes:
[0017] Re-execute the step of displaying the target text according to the target text display position and the target font size, and determining the actual number of lines when the target text is displayed.
[0018] Optionally, adjusting the target font size includes:
[0019] The target font size is reduced.
[0020] Optionally, before responding to the application text display requirement, determining the target text and expected number of lines of the application text display requirement, and obtaining the call location list, the method further includes:
[0021] Determine a list of language information and a list of text display locations for the application according to actual business requirements of the application;
[0022] In the case where the font size is used as the minimum granularity, the call location list is created according to the actual business needs, the language type information list and the text display location information list.
[0023] Optionally, the step of determining the target language type of the target text and determining the target text display location and target font size corresponding to the target text according to the call location list further includes:
[0024] A target font setting function is determined and the target font setting function is called.
[0025] An application text display device, the device comprising:
[0026] A target text determination module, for determining the target text and expected number of lines of the application text display requirement in response to the application text display requirement, and obtaining a call location list; wherein the call location list includes at least the mapping relationship between the language type information, the text display location information and the font size in the application;
[0027] A target font size determination module, used to determine the target language type of the target text, and determine the target text display location and target font size corresponding to the target text according to the call location list;
[0028] A target text display module, used to display the target text according to the target language type, the target text display location and the target font size, and determine the actual number of lines when the target text is displayed;
[0029] The target font size adjustment module is used to determine whether the target font size needs to be adjusted according to the actual number of lines and the expected number of lines; and adjust the target font size if the target font size needs to be adjusted.
[0030] An electronic device includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the application text display method as described above when executed by the processor.
[0031] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the application text display method described above is implemented.
[0032] The embodiments of the present invention have the following advantages:
[0033] In an embodiment of the present invention, by responding to the text display requirements of the application, the target text and the expected number of lines of the text display requirements are determined, and a call location list is obtained; wherein the call location list includes the language type information, text display location information and the mapping relationship between the font size within the application; then the target language type of the target text is determined and the target text display location and the target font size corresponding to the target text are determined according to the call location list; thereby, the target text is displayed according to the target language type, the target text display location and the target font size, and the actual number of lines when the target text is displayed is determined; then, according to the actual number of lines and the expected number of lines, it is determined whether the target font size needs to be adjusted; and when the target font size needs to be adjusted, the target font size is adjusted in a manner to realize adaptive adjustment of the font size of the text displayed in the application, which can better adapt to the actual pattern of the target text display location, enhance the customer's reading experience, and improve the text display effect in the application. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the technical solution of the present invention, the accompanying drawings required for use in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0035] Figure 1 is a flowchart of the steps of a method for displaying application text provided by some embodiments of the present invention;
[0036] Figure 2 is an example diagram of the mapping relationship of the present invention provided by some embodiments of the present invention;
[0037] Figure 3 It is a structural diagram of an application text display device provided by some embodiments of the present invention. DETAILED DESCRIPTION
[0038] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0039] With the popularity of smart devices, multi-language support has become a basic requirement in mobile application development; related technologies usually use fixed font sizes to perform multi-language adaptation. For example, developers preset a set of font sizes based on language characteristics and specify default font size configurations for different languages in the code.
[0040] However, when the front end of the application needs to be compatible with languages of different countries, the text display effect may be poor due to the inconsistent length of the language to be displayed in different language environments. For example, Chinese characters occupy less screen space, while words in English or other Latin alphabet languages may wrap or exceed the interface display area due to longer constituent characters.
[0041] In the embodiment of the present invention, based on the core technical concept of adaptively adjusting the font size of the text displayed in the application to adapt to the actual layout of the target text display location, the application text display method in the related art is improved. The present invention will be described in detail below with reference to the accompanying drawings:
[0042] Reference Figure 1 , shows a flowchart of a method for displaying application text provided by some embodiments of the present invention, which may specifically include the following steps:
[0043] Step 101, in response to a text display requirement of an application, determining a target text and an expected number of lines of the text display requirement of the application, and obtaining a call location list; wherein the call location list at least includes a mapping relationship between language type information, text display location information, and font size in the application;
[0044] In the specific implementation, Figure 2 As shown, the application generally specifies the default font size according to the business needs. For example, there are n font sizes, and n is 1 or other numbers. That is to say: for example, if n=1, there is only one font size, such as 16, whether it is Chinese or other languages. If n=2, there are two font sizes, and the business needs may also specify which languages correspond to font size 1 and which languages correspond to font size 2; or, the business needs only specify that some languages correspond to font size 1 and some languages correspond to font size 2, but there are still a few languages that have not been specified, and a random mode is adopted. When a new language is added, it may be necessary to re-acquire the existing font size and formulate a mapping relationship, or perhaps a new font size is also required. In short, there is an n-1 mapping relationship between font size and language, and a language generally corresponds to only one font size at a certain text display location; therefore, the language type information, text display location information, and the mapping relationship between font sizes in this application can be stored with the font size as the minimum granularity to create a call location list for subsequent processes to query and apply.
[0045] On this basis, the target text and expected number of lines of the text display requirements can be determined in response to the text display requirements of the application, and a call list can be obtained, wherein the target text can be the text display content corresponding to the text display requirements, but the language in which it is to be displayed has not yet been determined; and the expected number of lines can also be determined according to actual business needs. For example, for the title text, the expected number of lines can be 1 line (the title content should not wrap). For button text, the expected number of lines is usually 1 line. For the body text, it can be pre-set by comprehensively considering factors such as display size and display position.
[0046] In some embodiments of the present invention, before responding to the application text display requirement, determining the target text and expected number of lines of the application text display requirement, and obtaining the call location list, the method further includes:
[0047] Determine a list of language information and a list of text display locations for the application according to actual business requirements of the application;
[0048] In the case where the font size is used as the minimum granularity, the call location list is created according to the actual business needs, the language type information list and the text display location information list.
[0049] In actual applications, applications generally specify default font sizes based on business needs. For example, there are n font sizes, and n is 1 or other numbers. In other words, if n=1, there is only one font size, such as size 16, whether it is Chinese or other languages. If n=2, there are two font sizes, and business needs may also specify which languages correspond to font size 1 and which languages correspond to font size 2; or, business needs may only specify that some languages correspond to font size 1 and some languages correspond to font size 2, but there are still a few languages that have not been specified, and a random mode is adopted. When a new language is added, it may be necessary to re-acquire the existing font sizes and establish a mapping relationship, or perhaps a new font size must be added. In short, there is an n-1 mapping relationship between font size and language. Generally, one language corresponds to only one font size at a certain text display location. Therefore, the language type information in the application can be collected according to business needs to form a language type information list, and the text display location information list of the application can be determined by collecting specific information of all places where text is displayed in the App (application). Based on the mapping relationship between the language type information list, the text display location information list and the font size, a call location list is created under the condition of storing the font size as the minimum granularity for query and application in subsequent processes.
[0050] Step 102, determining the target language type of the target text, and determining the target text display location and target font size corresponding to the target text according to the call location list;
[0051] In a specific implementation, since a font setting function is often required when displaying text in an application, the corresponding execution process in the embodiment of the present application can be combined with the font setting function for implementation. Specifically, all font setting functions of the App can be counted and replaced to combine the corresponding scheme of the present application with the font setting function; when counting the original font setting functions in the App, it can include but not be limited to: ordinary text setting functions: such as setFont and font setting functions that call the font attribute to assign values; button font setting functions: such as open func setTitle(_title:String?, for state:UIControl.State), and font setting functions that directly set the font size of the button's attribute titleLabel; other font setting functions, if any, can also be added to the function list used by the App for subsequent replacement.
[0052] Furthermore, the function list obtained above can be traversed to replace each font setting function with the method swapping technology. It should be emphasized that in addition to the method swapping technology (swizzle), hooks, runtime dynamic detection technology (KVO, KVC), decompilation technology and aspect technology can also be used to implement the replacement function.
[0053] Furthermore, for the replaced font setting function, in addition to calling the system's original font setting function, you can also perform a statistical addition operation before or after the original function call: that is, add the information stored at the current call point to the call point list (equivalent to an initialization process for the call point list).
[0054] The specific information stored at the current call location may include but is not limited to: the number of lines of code; the setting type, such as text font setting type, button font setting type, or other setting type; the font size of the currently set text; the language corresponding to the currently set text; whether the font size has been adjusted and the number of times the font size has been adjusted; the expected number of lines; device information, such as the device's screen width, height, model, etc.
[0055] The replaced font setting function may also add corresponding "text display modification logic" and "font size adjustment logic" after calling the original font setting function to implement the corresponding process in the embodiment of the present invention.
[0056] Specifically, for "modify text display logic", you can query the call list, and determine the target language type of the target text by entering the parameter: the number of code lines, and determine the target text display location and target font size corresponding to the target text; then display the target text according to the target language type, target text display location and target font size.
[0057] In some embodiments of the present invention, before determining the target language type of the target text and determining the target text display location and target font size corresponding to the target text according to the call location list, the method further includes:
[0058] A target font setting function is determined and the target font setting function is called.
[0059] In actual applications, as mentioned above, since a font setting function is often required when displaying text in an application, the corresponding execution process in the embodiment of the present application can be combined with the font setting function to implement it. Specifically, all font setting functions of the App can be counted and replaced to combine the corresponding scheme of the present application with the font setting function; when counting the original font setting functions in the App, it can include but not be limited to: ordinary text setting functions: such as setFont and font setting functions that call the font attribute to assign values; button font setting functions: such as open funcsetTitle(_title:String?, for state:UIControl.State), and font setting functions that directly set the font size of the button's attribute titleLabel; other font setting functions, if any, can also be added to the function list used by the App for subsequent replacement.
[0060] Furthermore, the function list obtained above can be traversed to replace each font setting function with the method swapping technology. It should be emphasized that in addition to the method swapping technology (swizzle), hooks, runtime dynamic detection technology (KVO, KVC), decompilation technology and aspect technology can also be used to implement the replacement function.
[0061] Furthermore, when there is a demand for application text display, a target font setting function can be determined and called in the replaced font setting function while determining the target text and expected number of lines of the text display demand and obtaining the call location list. For the actual calling process of the replaced font setting function, in addition to calling the system's original font setting function, an add statistics operation can be performed before or after the original function call: that is, the information stored in the current call location is added to the call location list (equivalent to an initialization process for the call location list).
[0062] The specific information stored at the current call location may include but is not limited to: the number of lines of code; the setting type, such as text font setting type, button font setting type, or other setting type; the font size of the currently set text; the language corresponding to the currently set text; whether the font size has been adjusted and the number of times the font size has been adjusted; the expected number of lines; device information, such as the device's screen width, height, model, etc.
[0063] The replaced font setting function may also add corresponding "text display modification logic" and "font size adjustment logic" after calling the original font setting function to implement the corresponding process in the embodiment of the present invention.
[0064] Step 103, displaying the target text according to the target language, the target text display location and the target font size, and determining the actual number of lines when the target text is displayed;
[0065] In a specific implementation, as mentioned above, the call list can be queried, and the target language type of the target text can be determined by inputting the number of lines of code, and the target text display location and target font size corresponding to the target text can be determined; then the target text can be displayed according to the target language type, the target text display location and the target font size; and the actual number of lines when the target text is displayed can be further determined to determine whether the font size of the target text needs to be adjusted.
[0066] Specifically, you can first detect whether the target text has been displayed on the application interface. For example, you can detect changes in the window properties of the corresponding application text display control. When the text display control is displayed on the screen, its window property will be assigned to the current window by the system. If the text display control is not displayed on the screen, the window property will be assigned to null (nil) by the system. Therefore, you can use KVO technology to observe and set this property. If changes in the window property are detected, for example, it becomes a non-null value, it means that the text display control is displayed on the screen. In iOS development, the control UIView has a layoutSubviews method, and the control controller UIViewController also has viewDidLayoutSubviews and viewDidAppear methods. These methods can be called when the control is displayed on the interface.
[0067] Furthermore, after determining that the target text has been displayed on the application interface, the aforementioned "font size adjustment logic" can be executed, that is, whether to adjust the font size of the target text. Since the text has been displayed on the interface, the height of the text control where the target text is displayed and the height of a line of the text control are both fixed values. On this basis, the actual number of lines when the target text is displayed can be equal to the height of the text control / the height of a line of the text control. If the division is not exact, the maximum value can be used.
[0068] On this basis, the actual number of lines can be compared with the expected number of lines. If the actual number of lines is ≤ the expected number of lines, it means that the target font size in the current target language is appropriate and there is no need to adjust the target font size. If the actual number of lines is > the expected number of lines, it means that the target font size in the current target language is inappropriate and needs to be reduced. The font size can be reduced by 1 and then displayed. It should be emphasized that in order to get the display result as soon as possible, the iOS system function layoutIfNeeded or setNeedsLayout can be called so that the adjusted target font size can take effect immediately.
[0069] Furthermore, the steps of displaying the target text according to the target text display location and the target font size, and determining the actual number of lines when the target text is displayed can be re-executed to determine the relationship between the adjusted actual number of lines and the expected number of lines. If the actual number of lines ≤ the expected number of lines, it means that the target font size under the current target language type is appropriate. At this time, the "font size adjustment logic" can be ended, and the relevant information after the font size is updated can be saved in the corresponding position in the "calling location list". If the actual number of lines is still > the expected number of lines, it means that the target font size under the current target language type is inappropriate and needs to be further reduced. At this time, the corresponding process can be executed again according to the same logic until the actual number of lines ≤ the expected number of lines, and then the relevant information after the final font size update is saved in the corresponding position in the "calling location list".
[0070] In some embodiments of the present invention, determining the actual number of lines of the target text when it is displayed includes:
[0071] Determine text line height information when the target text is displayed and height information of the location where the target text is displayed;
[0072] The actual number of lines when the target text is displayed is determined based on the text line height information and the height information of the target text display location.
[0073] In actual applications, as mentioned above, after determining that the target text has been displayed on the application interface, the aforementioned "font size adjustment logic" can be executed, that is, to determine whether to adjust the font size of the target text. Since the text has been displayed on the interface, the height of the text control where the target text is displayed and the height of a line of the text control are both fixed values. On this basis, the actual number of lines when the target text is displayed can be equal to the height of the text control / the height of a line of the text control. If the division is not exact, the maximum value can be used.
[0074] On this basis, the actual number of lines can be compared with the expected number of lines. If the actual number of lines is ≤ the expected number of lines, it means that the target font size in the current target language is appropriate and there is no need to adjust the target font size. If the actual number of lines is > the expected number of lines, it means that the target font size in the current target language is inappropriate and needs to be reduced. You can reduce the font size by 1 and then set the display.
[0075] Step 104 , judging whether it is necessary to adjust the target font size according to the actual number of lines and the expected number of lines; and adjusting the target font size if it is necessary to adjust the target font size.
[0076] In the specific implementation, as mentioned above, after determining that the target text has been displayed on the application interface, the aforementioned "font size adjustment logic" can be executed, that is, whether to adjust the font size of the target text. Since the text has been displayed on the interface, the height of the text control where the target text is displayed and the height of a line of the text control are both fixed values. On this basis, the actual number of lines when the target text is displayed can be equal to the height of the text control / the height of a line of the text control. If the division is not exact, the maximum value can be used.
[0077] On this basis, the actual number of lines can be compared with the expected number of lines. If the actual number of lines is ≤ the expected number of lines, it means that the target font size in the current target language is appropriate and there is no need to adjust the target font size. If the actual number of lines is > the expected number of lines, it means that the target font size in the current target language is inappropriate and needs to be reduced. The font size can be reduced by 1 and then displayed. It should be emphasized that in order to get the display result as soon as possible, the iOS system function layoutIfNeeded or setNeedsLayout can be called so that the adjusted target font size can take effect immediately.
[0078] On this basis, the steps of displaying the target text according to the target text display location and the target font size, and determining the actual number of lines when the target text is displayed can be re-executed to determine the relationship between the adjusted actual number of lines and the expected number of lines. If the actual number of lines ≤ the expected number of lines, it means that the target font size under the current target language type is appropriate. At this time, the "font size adjustment logic" can be ended, and the relevant information after the font size is updated can be saved in the corresponding position in the "calling location list". If the actual number of lines is still > the expected number of lines, it means that the target font size under the current target language type is inappropriate and needs to be further reduced. At this time, the corresponding process can be executed again according to the same logic until the actual number of lines ≤ the expected number of lines, and then the relevant information after the final font size update is saved in the corresponding position in the "calling location list".
[0079] In some embodiments of the present invention, judging whether the target font size needs to be adjusted according to the actual number of lines and the expected number of lines includes:
[0080] When the actual number of lines is less than or equal to the expected number of lines, determining that the target font size does not need to be adjusted;
[0081] When the actual number of lines is greater than the expected number of lines, it is determined that the target font size needs to be adjusted.
[0082] In actual applications, since the text has been displayed on the interface, the height of the text control where the target text is displayed and the height of one line of the text control are both fixed values. On this basis, the actual number of lines when the target text is displayed can be equal to the height of the text control / the height of one line of the text control. If the division is not exact, the maximum value can be used.
[0083] If the actual number of lines is ≤ the expected number of lines, it means that the target font size in the current target language is appropriate and there is no need to adjust the target font size. If the actual number of lines is > the expected number of lines, it means that the target font size in the current target language is inappropriate and needs to be reduced. You can reduce the font size by 1 and then set the display.
[0084] In some embodiments of the present invention, adjusting the target font size includes:
[0085] The target font size is reduced.
[0086] In actual applications, since the text has been displayed on the interface, the height of the text control where the target text is displayed and the height of one line of the text control are both fixed values. On this basis, the actual number of lines when the target text is displayed can be equal to the height of the text control / the height of one line of the text control. If the divisibility is not exact, the maximum value can be used. If the actual number of lines is ≤ the expected number of lines, it means that the target font size in the current target language is appropriate and there is no need to adjust the target font size. If the actual number of lines is > the expected number of lines, it means that the target font size in the current target language is inappropriate and needs to be reduced. The font size can be reduced by 1 and then the display setting can be made.
[0087] In some embodiments of the present invention, the method further comprises:
[0088] Re-execute the step of displaying the target text according to the target text display position and the target font size, and determining the actual number of lines when the target text is displayed.
[0089] In the specific implementation, after determining that the target text has been displayed on the application interface, the aforementioned "font size adjustment logic" can be executed, that is, whether to adjust the font size of the target text. Since the text has been displayed on the interface, the height of the text control where the target text is displayed and the height of a line of the text control are both fixed values. On this basis, the actual number of lines when the target text is displayed can be equal to the height of the text control / the height of a line of the text control. If the division is not exact, the maximum value can be used.
[0090] On this basis, the actual number of lines can be compared with the expected number of lines. If the actual number of lines is ≤ the expected number of lines, it means that the target font size in the current target language is appropriate and there is no need to adjust the target font size. If the actual number of lines is > the expected number of lines, it means that the target font size in the current target language is inappropriate and needs to be reduced. The font size can be reduced by 1 and then displayed. It should be emphasized that in order to get the display result as soon as possible, the iOS system function layoutIfNeeded or setNeedsLayout can be called so that the adjusted target font size can take effect immediately.
[0091] On this basis, the steps of displaying the target text according to the target text display location and the target font size, and determining the actual number of lines when the target text is displayed can be re-executed to determine the relationship between the adjusted actual number of lines and the expected number of lines. If the actual number of lines ≤ the expected number of lines, it means that the target font size under the current target language type is appropriate. At this time, the "font size adjustment logic" can be ended, and the relevant information after the font size is updated can be saved in the corresponding position in the "calling location list". If the actual number of lines is still > the expected number of lines, it means that the target font size under the current target language type is inappropriate and needs to be further reduced. At this time, the corresponding process can be executed again according to the same logic until the actual number of lines ≤ the expected number of lines, and then the relevant information after the final font size update is saved in the corresponding position in the "calling location list".
[0092] On this basis, you can also refer to the above process to conduct a preliminary test on the overall operation of the App, that is, you can display all the pages in the App on the screen once to ensure the effect of automatic adjustment and adjust the font size of all pages to a suitable value before the user actually uses it. You can also use an automatic testing program, or let testers perform smoke testing.
[0093] When all the text controls of the App have undergone self-adjustment, the text display in multiple languages is completely reasonable. At this time, the final "call list" can be stored on the server.
[0094] In addition, since the call list also records the size information of the device, once statistics are performed on one device, other devices of the same model do not need to be counted and can be directly sent to the device. In other words, before the application is released to the market, it only needs to do a preliminary overall test of the popular device models on the market to meet the display requirements of all users without errors. If UI personnel or product personnel are not satisfied with the results of the automated adjustment, they can also manually modify one of them for flexible adjustment.
[0095] In an embodiment of the present invention, by responding to the text display requirements of the application, the target text and the expected number of lines of the text display requirements are determined, and a call location list is obtained; wherein the call location list includes the language type information, text display location information and the mapping relationship between the font size within the application; then the target language type of the target text is determined and the target text display location and the target font size corresponding to the target text are determined according to the call location list; thereby, the target text is displayed according to the target language type, the target text display location and the target font size, and the actual number of lines when the target text is displayed is determined; then, according to the actual number of lines and the expected number of lines, it is determined whether the target font size needs to be adjusted; and when the target font size needs to be adjusted, the target font size is adjusted in a manner to realize adaptive adjustment of the font size of the text displayed in the application, which can better adapt to the actual pattern of the target text display location, enhance the customer's reading experience, and improve the text display effect in the application.
[0096] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0097] Reference Figure 3 , shows a schematic diagram of the structure of an application text display device provided by some embodiments of the present invention, which may specifically include the following modules:
[0098] The target text determination module 301 is used to determine the target text and expected number of lines of the application text display requirement in response to the application text display requirement, and obtain a call location list; wherein the call location list at least includes the mapping relationship between the language type information, the text display location information and the font size in the application;
[0099] A target font size determination module 302 is used to determine the target language type of the target text, and determine the target text display location and target font size corresponding to the target text according to the call location list;
[0100] The target text display module 303 is used to display the target text according to the target language type, the target text display location and the target font size, and determine the actual number of lines when the target text is displayed;
[0101] The target font size adjustment module 304 is used to determine whether the target font size needs to be adjusted according to the actual number of lines and the expected number of lines; and to adjust the target font size if the target font size needs to be adjusted.
[0102] In some embodiments of the present invention, the target text display module 303 includes:
[0103] A height information determination submodule, used to determine text line height information when the target text is displayed and height information of the target text display location;
[0104] The actual line number determination submodule is used to determine the actual line number of the target text when it is displayed based on the text line height information and the height information of the target text display location.
[0105] In some embodiments of the present invention, the target font size adjustment module 304 includes:
[0106] A first determination submodule, configured to determine that it is not necessary to adjust the target font size when the actual number of lines is less than or equal to the expected number of lines;
[0107] The second determination submodule is configured to determine that the target font size needs to be adjusted when the actual number of lines is greater than the expected number of lines.
[0108] In some embodiments of the present invention, the device further comprises:
[0109] The re-execution module is used to re-execute the steps of displaying the target text according to the target text display position and the target font size, and determining the actual number of lines when the target text is displayed.
[0110] In some embodiments of the present invention, the target font size adjustment module 304 includes:
[0111] The downsizing submodule is used to downsize the target font size.
[0112] In some embodiments of the present invention, the device further comprises:
[0113] An information list determination module, used to determine a language type information list and a text display location information list of the application according to actual business requirements of the application;
[0114] The call location list creation module is used to create the call location list according to the actual business needs, the language type information list and the text display location information list with the font size as the minimum granularity.
[0115] In some embodiments of the present invention, the device further comprises:
[0116] The target setting font function calling module is used to determine the target setting font function and call the target setting font function.
[0117] Some embodiments of the present invention also provide an electronic device, which may include a processor, a memory, and a computer program stored in the memory and capable of running on the processor, and when the computer program is executed by the processor, the above-mentioned application text display method is implemented.
[0118] Some embodiments of the present invention further provide a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the above-mentioned application text display method is implemented.
[0119] Some embodiments of the present invention further provide a computer program product, including a computer program, which implements the above application text display method when executed by a processor.
[0120] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0121] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0122] Those skilled in the art will appreciate that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0123] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0124] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0125] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0126] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0127] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the above elements.
[0128] The above is a detailed introduction to the provided application text display method and device, electronic device, and storage medium. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A method for displaying application text, characterized in that: The method comprises: In response to the text display requirement of the application, determine the target text and the expected number of lines of the text display requirement of the application, and obtain a call location list; wherein the call location list at least includes the mapping relationship between the language type information, the text display location information and the font size in the application; Determine the target language type of the target text, and determine the target text display location and target font size corresponding to the target text according to the call location list; Display the target text according to the target language, the target text display location and the target font size, and determine the actual number of lines when the target text is displayed; According to the actual number of lines and the expected number of lines, it is determined whether the target font size needs to be adjusted; and if the target font size needs to be adjusted, the target font size is adjusted.
2. The method according to claim 1, characterized in that The determining the actual number of lines of the target text when it is displayed includes: Determine text line height information when the target text is displayed and height information of the location where the target text is displayed; The actual number of lines when the target text is displayed is determined based on the text line height information and the height information of the target text display location.
3. The method according to claim 1, characterized in that The determining whether the target font size needs to be adjusted according to the actual number of lines and the expected number of lines includes: When the actual number of lines is less than or equal to the expected number of lines, determining that the target font size does not need to be adjusted; When the actual number of lines is greater than the expected number of lines, it is determined that the target font size needs to be adjusted.
4. The method according to claim 1, characterized in that The method further comprises: Re-execute the step of displaying the target text according to the target text display position and the target font size, and determining the actual number of lines when the target text is displayed.
5. The method according to claim 3, characterized in that: The adjusting the target font size includes: The target font size is reduced.
6. The method according to claim 1, characterized in that Before responding to the application text display requirement, determining the target text and expected number of lines of the application text display requirement, and obtaining the call location list, the method further includes: Determine a list of language information and a list of text display locations for the application according to actual business requirements of the application; In the case where the font size is used as the minimum granularity, the call location list is created according to the actual business needs, the language type information list and the text display location information list.
7. The method according to claim 1, characterized in that The step of determining the target language type of the target text and determining the target text display location and target font size corresponding to the target text according to the call location list further includes: A target font setting function is determined and the target font setting function is called.
8. An application text display device, characterized in that: The device comprises: A target text determination module, for determining the target text and expected number of lines of the application text display requirement in response to the application text display requirement, and obtaining a call location list; wherein the call location list at least includes the mapping relationship between the language type information, the text display location information and the font size in the application; A target font size determination module, used to determine the target language type of the target text, and determine the target text display location and target font size corresponding to the target text according to the call location list; A target text display module, used to display the target text according to the target language type, the target text display location and the target font size, and determine the actual number of lines when the target text is displayed; The target font size adjustment module is used to determine whether the target font size needs to be adjusted according to the actual number of lines and the expected number of lines; and adjust the target font size if the target font size needs to be adjusted.
9. An electronic device, characterized in that: The invention comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the application text display method as claimed in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the application text display method according to any one of claims 1 to 7 is implemented.