CN117873616A - Text self-adaptive display method and device, electronic equipment and storage medium - Google Patents

Text self-adaptive display method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117873616A
CN117873616A CN202311759226.5A CN202311759226A CN117873616A CN 117873616 A CN117873616 A CN 117873616A CN 202311759226 A CN202311759226 A CN 202311759226A CN 117873616 A CN117873616 A CN 117873616A
Authority
CN
China
Prior art keywords
text
control
width
target text
parent layout
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311759226.5A
Other languages
Chinese (zh)
Inventor
韦武浚
李绍斌
唐杰
邱园
王付荣
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Gree Electric Appliances Inc of Zhuhai
Zhuhai Lianyun Technology Co Ltd
Original Assignee
Gree Electric Appliances Inc of Zhuhai
Zhuhai Lianyun Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Gree Electric Appliances Inc of Zhuhai, Zhuhai Lianyun Technology Co Ltd filed Critical Gree Electric Appliances Inc of Zhuhai
Priority to CN202311759226.5A priority Critical patent/CN117873616A/en
Publication of CN117873616A publication Critical patent/CN117873616A/en
Pending legal-status Critical Current

Links

Abstract

The embodiment of the invention provides a text self-adaptive display method, a device, electronic equipment and a storage medium, wherein the method comprises the following steps: loading a page control and acquiring the text size of the page control; acquiring a target text and the character number of the target text, and acquiring screen resolution; the target text is the text of the target language; determining a first tiling width corresponding to the target text according to the character number, the screen resolution and the text size of the page control of the target text; acquiring a parent layout control corresponding to the target text and the control width of the parent layout control through the page control; and displaying the target text through the parent layout control in a self-adaptive manner according to the text size, the first tiling width and the control width. Therefore, the control does not need to be adjusted manually in the later period, and the text adaptation is more convenient.

Description

Text self-adaptive display method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of computer technology, and in particular, to a text adaptive display method, a text adaptive display device, an electronic apparatus, and a computer readable storage medium.
Background
Along with the increasing development of some enterprises, overseas markets are developed, so that the APP of the enterprise performs multilingual display for the overseas markets, and in order to adapt the APP to certain languages, various adaptations are often required to be performed in a certain page control for a corresponding certain language, but the adaptation mode is troublesome, and when the control area changes, the text control needs to be manually adjusted for multiple times in the later period.
Disclosure of Invention
In view of the above problems, embodiments of the present invention have been made to provide a text adaptive display method, a text adaptive display apparatus, an electronic device, and a computer-readable storage medium that overcome or at least partially solve the above problems.
In order to solve the above problems, an embodiment of the present invention discloses a text adaptive display method, which includes:
loading a page control and acquiring the text size of the page control;
acquiring a target text and the character number of the target text, and acquiring screen resolution; the target text is the text of the target language;
determining a first tiling width corresponding to the target text according to the character number of the target text, the screen resolution and the text size of the page control;
Acquiring a parent layout control corresponding to the target text and the control width of the parent layout control through the page control;
and displaying the target text through the parent layout control in a self-adaptive mode according to the text size, the first tiling width and the control width.
Optionally, the adaptively displaying the target text through the parent layout control according to the text size, the first tiling width and the control width includes:
judging whether the parent layout control meets the requirement of line feed display of the target text or not according to the control width and the first tiling width;
if the parent layout control meets the requirement of line feed display of the target text, line feed is carried out on the target text, and a second paving width of the text left after line feed is determined;
and displaying the target text through the parent layout control in a self-adaptive mode according to the text size, the second paving width and the control width.
Optionally, the adaptively displaying the target text through the parent layout control according to the text size, the second tile width and the control width includes:
judging whether the parent layout control meets the requirement of line feed display of the residual text or not according to the control width and the second paving width;
If the parent layout control meets the requirement of line feed display of the residual text, displaying the target text in a first display mode through the parent layout control; the first display mode is line feed display;
and if the parent layout control does not meet the requirement of line feed display of the residual text, adjusting the size of the text according to a preset size, and adaptively displaying the target text through the parent layout control based on the adjusted size of the text again.
Optionally, the determining, according to the control width and the first tiling width, whether the parent layout control meets the requirement of line feed to display the target text includes:
if the width of the control is larger than or equal to the first tiling width, determining that the parent layout control does not meet line feed display of the target text;
and if the width of the control is smaller than the first tiling width, determining that the parent layout control meets the requirement of line feed display of the target text.
Optionally, the determining, according to the control width and the second tile width, whether the parent layout control meets the requirement of line feed to display the remaining text includes:
if the width of the control is larger than or equal to the second paving width, determining that the parent layout control meets the requirement of displaying the residual text in a line feed manner;
And if the width of the control is smaller than the second paving width, determining that the parent layout control does not meet the requirement of line feed display of the residual text.
Optionally, the obtaining, through the page control, a parent layout control corresponding to the target text and a control width of the parent layout control includes:
acquiring a control identity corresponding to the target text through the page control;
and acquiring a parent layout control corresponding to the target text and the control width of the parent layout control according to the control identity.
Optionally, the determining the second width of the spread of the text remaining after the line feed includes:
acquiring the character number of the text left after line feed;
and determining a second paving width corresponding to the residual text according to the character number of the residual text, the screen resolution and the text size of the page control.
The embodiment of the invention also discloses a text self-adaptive display device, which comprises:
the first acquisition module is used for loading the page control and acquiring the text size of the page control;
the second acquisition module is used for acquiring the target text and the character number of the target text and acquiring the screen resolution;
The determining module is used for determining a first tiling width corresponding to the target text according to the character number of the target text, the screen resolution and the text size of the page control;
the third acquisition module is used for acquiring a parent layout control corresponding to the target text and the control width of the parent layout control through the page control;
and the display module is used for adaptively displaying the target text through the parent layout control according to the text size, the first tiling width and the control width.
Optionally, the display module includes:
the judging sub-module is used for judging whether the parent layout control meets the requirement of line feed display of the target text according to the control width and the first tiling width;
the determining submodule is used for carrying out line feed on the target text if the parent layout control meets line feed display of the target text, and determining a second paving width of the text left after line feed;
and the display sub-module is used for adaptively displaying the target text through the parent layout control according to the text size, the second paving width and the control width.
Optionally, the display submodule includes:
The judging unit is used for judging whether the parent layout control meets the requirement of line feed display of the residual text according to the control width and the second paving width;
the first display unit is used for displaying the target text in a first display mode through the parent layout control if the parent layout control meets the requirement of line feed display of the residual text; the first display mode is line feed display;
and the second display unit is used for adjusting the size of the text according to a preset size if the parent layout control does not meet the requirement of line feed display of the residual text, and displaying the target text through the parent layout control in a self-adaptive mode based on the adjusted size of the text again.
Optionally, the judging submodule includes:
the first determining unit is used for determining that the parent layout control does not meet the requirement of line feed display of the target text if the width of the control is larger than or equal to the first tiling width;
and the second determining unit is used for determining that the parent layout control meets the requirement of line feed display of the target text if the width of the control is smaller than the first tiling width.
Optionally, the judging unit includes:
the first determining subunit is configured to determine that the parent layout control satisfies line feed to display the remaining text if the control width is greater than or equal to the second width;
And the second determining subunit is configured to determine that the parent layout control does not satisfy line feed display of the remaining text if the control width is smaller than the second tile width.
Optionally, the third obtaining module includes:
the first acquisition sub-module is used for acquiring the control identity corresponding to the target text through the page control;
and the second acquisition sub-module is used for acquiring the parent layout control corresponding to the target text and the control width of the parent layout control according to the control identity.
Optionally, the determining submodule includes:
the acquisition unit is used for acquiring the character number of the text left after line feed;
and the third determining unit is used for determining a second paving width corresponding to the residual text according to the character number of the residual text, the screen resolution and the text size of the page control.
The invention also discloses an electronic device, which comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor realizes the steps of the text self-adaptive display method when executing the computer program.
The invention also discloses a computer readable storage medium, on which a computer program is stored, which when being executed by a processor implements the steps of the text adaptive display method as described above.
The embodiment of the invention has the following advantages:
according to the embodiment of the invention, the page control is loaded, the text size of the page control is obtained, then the target text and the character number of the target text are obtained, and the screen resolution is obtained, wherein the target text is the target language text, then the first tiling width corresponding to the target text is determined according to the character number of the target text, the screen resolution and the text size of the page control, then the control widths of the father layout control and the father layout control corresponding to the target text are obtained through the page blank control, finally the target text is displayed through the father layout control in a self-adaption mode according to the text size, the first tiling width and the space width, and accordingly the target text can be displayed through the father layout control in a self-adaption mode, later artificial adjustment of the control is not needed, and the self-adaption display of the text is more convenient while the labor cost is reduced.
Drawings
FIG. 1 is a flow chart of steps of a text adaptive display method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a target text structure according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a parent layout control structure provided by an embodiment of the present invention;
FIG. 4 is a flowchart illustrating steps of another text adaptive display method according to an embodiment of the present invention;
FIG. 5A is a schematic diagram of displaying a target text according to an embodiment of the present invention;
FIG. 5B is a schematic diagram of another target text display provided by an embodiment of the present invention;
fig. 6 is a block diagram of a text adaptive display device according to an embodiment of the present invention.
Detailed Description
In order that the above-recited objects, features and advantages of the present invention will become more readily apparent, a more particular description of the invention will be rendered by reference to the appended drawings and appended detailed description.
In the related art, when the APP is adapted to some languages, various adaptations are performed for the corresponding languages, and the control is often required to be adjusted manually for many times in the later period, so that the method is troublesome in adaptation. The invention provides a text self-adaptive display method for solving the technical problems, which has the core conception that page controls are loaded, the text sizes of the page controls are obtained, then the character numbers of target texts and the target texts are obtained, the screen resolution is obtained, then the first tiling width corresponding to the target texts is determined according to the character numbers of the target texts, the screen resolution and the text sizes of the page controls, then the control widths of father layout controls and father layout controls corresponding to the target texts are obtained through page blank controls, finally the target texts are adaptively displayed through the father layout controls according to the text sizes, the first tiling width and the space width, so that the target texts are adaptively displayed through the father layout controls based on the text sizes of the page controls, the first tiling width corresponding to the target texts and the control widths of the father layout controls, and later artificial adjustment of the controls is not needed.
Referring to fig. 1, a step flowchart of a text adaptive display method provided by an embodiment of the present invention is shown, where the method specifically may include the following steps:
and step 101, loading a page control and acquiring the text size of the page control.
In the embodiment of the invention, when the text is adaptively displayed, the page control can be loaded first, and then the text size of the page space can be obtained, for example: when a user clicks into the APP, the page space is recorded, and at this time, the text size of the page space can be obtained, where the text size is a preset size of displaying a single character, and a unit of the size can be DP (device independent pixels, length unit, and independent pixel of the device), for example, the text size is 50DP, and the text size belongs to a text parameter. In the present invention, the text size may be set according to actual requirements, and the specific size of the text is not specifically limited herein.
The device independent pixel is also called a device independent pixel, density independent Density Independent or device independent pixel, abbreviated as DIP or DP, which is a physical measurement unit, and is converted into application of physical pixels based on a computer-controlled coordinate system and abstract pixels (virtual pixels) by a program of an underlying system. A typical use is to allow mobile device software to extend information display and user interaction to different screen sizes. The application is allowed to make measurements in units of abstract pixels, while the underlying graphics system converts the application's abstract pixel measurements into physical pixels appropriate for the particular device.
102, acquiring a target text and the character number of the target text, and acquiring screen resolution; the target text is the text of the target language.
In the embodiment of the invention, after the text size of the page control is obtained, the target text and the character number of the target text can be obtained, wherein the target text can be the text of a target language, and the target language can be multiple languages, for example: the language in which the APP operates is Chinese, then the target language is Chinese, the language in which the APP operates is English, and then the target language is English. The specific language of the target language in the present invention is not specifically limited herein.
Number of characters: refers to the number of characters actually used in text, including letters, numbers, punctuation marks, special characters, and the like. Each character occupies a character position, regardless of its length or width. For example, in computer and telecommunications technology, a character is the basic information of a unit of glyphs, glyph-like units, or symbols. A character is an abstract entity that may be represented using a variety of different character schemes or code pages.
In one embodiment, the target text and the number of characters of the target text may be obtained by: firstly, acquiring a pre-stored text and a corresponding language and a target language, judging whether the corresponding language of the pre-stored text is the same as the target language, if the corresponding language of the pre-stored text is the same as the target language, determining the pre-stored text as the target text, and if the corresponding language of the pre-stored text is different from the target language, converting the pre-stored text into the target text corresponding to the target language, and acquiring the character numbers of the target text and the target text.
For example: the pre-stored text is Chinese, namely the initial language of the APP operation is Chinese, the initial text is the pre-stored text, namely the language corresponding to the pre-stored text is Chinese, and because of the switching of the APP operation language, the initial language is switched to English, namely the target language is English, then the fact that the corresponding language of the pre-stored text is different from the target language can be judged, at the moment, the pre-stored text is converted into the target text corresponding to the target language, namely the pre-stored text which is Chinese is converted into the target text of English, and then the character numbers of the target text and the target text are acquired.
In the embodiment of the invention, when the target text and the character number of the target text are acquired, the screen resolution can be acquired, and the screen resolution is the screen resolution of the operation APP terminal.
The resolution is one of very important performance indexes, and the whole image can be imagined as a large chessboard, and the resolution is expressed by the number of crossing points of all warps and wefts. For a screen with a resolution of 1024×768, each horizontal line contains 1024 pixels, and there are 768 lines in total, i.e. the number of scanning columns is 1024 columns, and the number of rows is 768 rows.
It should be noted that, the sequence of step 101 and step 102 in the present invention may be set according to the actual requirement, and may be that the page control is loaded first, the text size of the page control is obtained, then the number of characters of the target text and the target text is obtained, and the screen resolution is obtained, or that the number of characters of the target text and the target text is obtained first, and the screen resolution is obtained, then the page control is loaded, and the text size of the page control is obtained, or that the page control is loaded, and the text size of the page control is obtained, and meanwhile, the number of characters of the target text and the target text is obtained, and the screen resolution is obtained.
And step 103, determining a first tiling width corresponding to the target text according to the character number of the target text, the screen resolution and the text size of the page control.
In the embodiment of the invention, after the target text, the character number of the target text and the screen resolution are obtained, the first tiling width corresponding to the target text can be determined according to the character number of the target text, the screen resolution and the text size of the page control. In the present invention, the first tiling width is the width of the target text without line feed, i.e., the sum of the widths of all characters in the target text. Fig. 2 shows a schematic diagram of a target text structure according to an embodiment of the present invention.
Specifically, the number of characters of the target text is 100, the text size is 1DP, and the screen resolution is 1DP, and the width is 30 pixels in the lateral direction, so that the first tile width corresponding to the target text is 3000 pixels.
In the present invention, the screen resolution is also the screen DPI (Dots Per Inch), which is a unit of measure for digital dot matrix images, which refers to the number of sampled, displayable, or output Dots Per Inch of length. DPI refers to pixels per inch, i.e., scanning accuracy. The lower the DPI, the lower the definition of the scan, and the pictures used on the web are all 72DPI, due to the network transport speed, but the more this parameter cannot be used for the photos to be developed, which must be 300DPI or higher, 350DPI. For example, to print 4*6 inches, the scan accuracy must be 300DPI, and then the file size should be (4×300) ×6×300) =1200 pixels×1800 pixels.
And 104, acquiring a parent layout control corresponding to the target text and the control width of the parent layout control through the page control.
In the embodiment of the invention, after the first tiling width corresponding to the target text is determined, the parent layout control corresponding to the target text can be obtained through the page space, and then the control width of the parent layout control is obtained, wherein the parent layout control is used for displaying the target text. Fig. 3 is a schematic diagram of a parent layout control structure according to an embodiment of the present invention. In the invention, the width of the control is smaller than or equal to the screen width of the screen, and the control width is set for the parent layout control to prevent the target text from exceeding the screen during display. When the target text is displayed, the tiling width of each row of the target text can only be equal to the width of the control at most, so that the width of the control of the parent layout control can not be exceeded when the target text is displayed, and the target text can not exceed the screen when the target text is displayed.
In an embodiment, the parent layout control and the control width of the parent layout control corresponding to the target text are obtained through the page control, and the method can be obtained as follows: acquiring a control identity corresponding to a target text through a page control; and acquiring the parent layout control corresponding to the target text and the control width of the parent layout control according to the control identity.
In the invention, a corresponding control identity mark can be set for each control, when a page control is loaded to acquire a target text, the control identity mark corresponding to the target text can be acquired, and then the corresponding parent layout control and the control width of the parent layout control are acquired from a plurality of controls through the control identity mark, wherein the control width of the parent layout control can be the display width of the display text, namely the maximum display width of each row when the text is displayed in the parent layout control.
In an embodiment, the page control may include a root control, which may be a button, a linear layout, a relative layout, or the like, and may obtain a control identifier penetrated by the root control, and then obtain a corresponding parent layout control and a control width of the parent layout control according to the control identifier.
And step 105, adaptively displaying the target text through the parent layout control according to the text size, the first tiling width and the control width.
In the embodiment of the invention, after the parent layout control and the control width of the parent layout control are obtained, the target text can be displayed through the parent layout control in a self-adaptive manner according to the text size, the first tiling width and the control width.
In one embodiment, the adaptation to display the target text through the parent layout control may be accomplished by: judging whether the parent layout control meets the line feed display target text or not according to the width of the control and the first tiling width; if the parent layout control meets the requirement of line feed display of the target text, line feed is carried out on the target text, and a second paving width of the residual text after line feed is determined; and displaying the target text through the parent layout control in a self-adaptive mode according to the text size, the second paving width and the control width.
Specifically, a first tiling width corresponding to the target text is 3000 pixels, and the width of the control is only 2000 pixels, so that the first tiling width is larger than the width of the control, namely the target text cannot be displayed in one row through the parent layout control and can only be displayed in multiple rows, then the target text is subjected to line feed at the moment, the second tiling width of the residual text after line feed is determined, the residual text is other texts of the text displayed in the first row in the target text, namely the text which is not displayed in the first row in the target text, and then the target text is displayed through the parent layout control in a self-adaptive manner according to the size of the text, the second tiling width and the width of the control.
In the embodiment of the invention, the second width of the rest text after line feed is determined in the following manner: acquiring the character number of the text left after line feed; and determining a second paving width corresponding to the residual text according to the character number of the residual text, the screen resolution and the text size of the page control.
For example: after the line of the target text is fed, the number of characters of the target text is 100, the number of the rest text is 30, the text size is 1DP, and the screen resolution is 1DP, namely, the width is 30 pixels in the transverse direction, so that the second spreading width corresponding to the target text is 900 pixels.
In the embodiment of the invention, if the parent layout control does not meet the requirement of line feed display of the target text, the target text is displayed in a line display mode through the parent layout control. In the invention, if the parent layout control does not meet the line feed display target text, the parent layout control can display the target text without line feed, and the target text can be displayed in a line display mode directly without line feed through the parent layout control.
In the embodiment of the invention, whether the parent layout control meets the requirement of line feed display of the target text is judged according to the control width and the first tiling width, and the judgment can be performed in the following manner: if the width of the control is larger than or equal to the first tiling width, determining that the parent layout control does not meet the requirement of line feed display of the target text; and if the width of the control is smaller than the first tiling width, determining that the parent layout control meets the line feed display target text.
For example: the first tiling width corresponding to the target text is 3000 pixels, and the width of the control is 3000 pixels, so that the width of the control is equal to the first tiling width, the parent layout control is determined to be capable of meeting the requirement of displaying the target text without line feed, and the target text can be displayed in a line display mode, namely the parent layout control is determined to be not capable of meeting the requirement of displaying the target text with line feed. And the width of the control is 2000 pixel points, and then the width of the control is smaller than the first tiling width, and the target text cannot be displayed in a line display mode through the parent layout control, namely, the parent layout control is determined to meet the requirement of line feed display of the target text.
In the embodiment of the invention, according to the text size, the second width of the tile and the width of the control, the method for adaptively displaying the target text through the parent layout control can specifically comprise the following steps: judging whether the parent layout control meets the requirement of line feed display of the residual text or not according to the width of the control and the second paving width; if the parent layout control meets the requirement of line feed display of the residual text, displaying the target text in a first display mode through the parent layout control; the first display mode is line feed display; if the parent layout control does not meet the requirement of line feed display of the residual text, the size of the text is adjusted according to the preset size, and the target text is displayed through the parent layout control in a self-adaptive mode based on the adjusted size of the text again.
Specifically, if the second width of the tile corresponding to the remaining text satisfies the requirement of displaying the remaining text in a line-feed manner, the remaining text may be displayed through the parent layout control in a line-feed manner, that is, the target text may be displayed in a two-line manner. If the second paving width corresponding to the residual text does not meet the requirement of line feed display of the residual text, the residual text can not be displayed in the second line, the text size is modified according to the preset size, namely the text parameter of the page space is modified, and the target text is displayed through the father layout control in a self-adaptive mode again based on the adjusted text size.
For example: if the second tiling width corresponding to the residual text does not meet the requirement of line feed display of the residual text, and the preset size is 1DP, the text size can be reduced by 1DP, namely, the text size in the process of displaying the target text is reduced, at the moment, the first tiling width corresponding to the target text is also reduced, and then the target text is displayed through the parent layout control in a self-adaptive mode according to the modified text size, the reduced first tiling width and the control width until the target text can be displayed through the parent layout.
In the embodiment of the invention, whether the parent layout control meets the requirement of line feed display of the residual text or not is judged according to the control width and the second paving width, and the judgment can be carried out in the following mode: if the width of the control is larger than or equal to the second paving width, determining that the parent layout control meets the requirement of line feed display of the residual text; and if the width of the control is smaller than the second paving width, determining that the parent layout control does not meet the requirement of line feed display of the residual text.
For example: the second paving width corresponding to the residual text is 2100 pixels, the width of the control is only 2000 pixels, then the width of the control is smaller than the second paving width, namely the residual text cannot be displayed in one line through the parent layout control and can only be displayed in multiple lines, then the parent layout control can be determined not to meet the requirement of line feed for displaying the residual text, if the second paving width corresponding to the residual text is 1900 pixels, then the width of the control is larger than the second paving width, namely the residual text can be displayed in one line through the parent layout control, then the parent layout control can be determined to meet the requirement of line feed for displaying the residual text, namely the target text can be displayed in a two-line display mode.
In the embodiment of the invention, if the parent layout control does not meet the requirement of displaying the residual text after line feed, the residual text can be fed, the second paving width of the residual text after line feed is determined again, and whether the parent layout control meets the requirement of displaying the residual text after line feed is judged according to the control width and the second paving width until the line feed operation is carried out until the parent layout control can display the target text.
For example: and if the tiling width corresponding to the residual text is greater than the control width, the residual text is determined to be the residual text, the tiling width corresponding to the residual text and the control width are judged, the target text is displayed in a line-feed manner, namely, the target text is displayed in a two-line display manner, if the tiling width corresponding to the residual text is greater than the control width, the residual text is fed, the text after line feed is determined to be the residual text, namely, the texts except the first line and the second line are determined to be the residual text, the tiling width corresponding to the residual text and the control width are judged, if the tiling width corresponding to the residual text is less than or equal to the control width, the target text is displayed in a line-feed manner, namely, the target text is displayed in a three-line display manner, and if the tiling width corresponding to the residual text is greater than the control width, the residual text is fed again until the parent layout control can display the target text. That is, the text size is not required to be adjusted according to the preset size, and only the line feed operation is required to be performed until the parent layout control can display the target text.
In the embodiment of the invention, if the parent layout control does not meet the requirement of displaying the residual text in a line feed manner, a preset threshold value can be set when the text is processed in a manner of adjusting the size according to the preset size, the preset threshold value is the minimum size of the text, if the text is adjusted to the preset threshold value according to the preset size, namely, the text size is adjusted to the minimum set value, at this time, whether the parent layout control meets the requirement of displaying the target text in a line feed manner is judged according to the first tiling width of the control width of the parent layout control and the target text adjusted to the minimum set sub-value, if the parent layout control does not meet the requirement of displaying the target text in a line feed manner, if the parent layout control meets the requirement of displaying the target text in a line feed manner, the target text is fed in a line feed manner, if the tiling width of the residual text corresponding to the target text after line feed is smaller than or equal to the control width, and if the tiling width of the residual text corresponding to the control text after line feed is larger than the control blank, namely, the residual text is not displayed in a line feed manner until the residual text is not displayed by the parent layout operation again.
In the embodiment of the invention, the page control is loaded, and the text size of the page control is obtained; acquiring a target text and the character number of the target text, and acquiring screen resolution; the target text is the text of the target language; determining a first tiling width corresponding to the target text according to the character number, the screen resolution and the text size of the page control of the target text; acquiring a parent layout control corresponding to the target text and the control width of the parent layout control through the page control; according to the text size, the first tiling width and the control width, the target text is displayed through the parent layout control in a self-adaptive mode, so that the target text can be displayed through the parent layout control in a self-adaptive mode based on the text size of the page control, the first tiling width corresponding to the target text and the control width of the parent layout control, later-stage manual adjustment on the control is not needed, and the method is more convenient compared with the prior art.
For better explanation of the embodiment of the present invention, referring to fig. 4, a flowchart illustrating steps of another text adaptive display method provided by the embodiment of the present invention is shown, and specific steps are as follows:
firstly, acquiring the target text and the character number of the target text, acquiring the screen resolution, then acquiring the text size of the page control, determining a first tiling width corresponding to the target text according to the character number of the target text, the screen resolution and the text size of the page control, acquiring the parent layout control corresponding to the target text and the control width of the parent layout control according to the control identity, and judging whether the parent layout control meets the requirement of line feed display of the target text according to the control width and the first tiling width.
When judging whether the parent layout control meets the line feed display target text according to the control width and the first tiling width, if the parent layout control does not meet the line feed display target text, displaying the target text through the parent layout control, if the parent layout control meets the line feed display target text, line feed the target text, and judging whether the parent layout control meets the control width according to the second tiling width of the residual text after line feed, namely judging whether the second line after line feed can meet the display of the residual text, namely judging whether the target text can be displayed in a two-line display mode through the parent layout control.
And when judging whether the parent layout control meets the control width according to the second paving width of the residual text after line feed, if the second paving width of the residual text meets the control width, displaying the target text in a line feed display mode through the parent layout control.
When judging whether the parent layout control meets the control width according to the second paving width of the residual text after line feed, if the second paving width of the residual text does not meet the control width, namely the second line after line feed does not meet the requirement of displaying the residual text, adjusting according to the preset size and the text size, then acquiring the adjusted text size, judging the display mode of the target text again until the target text is displayed through the parent layout control, and completing text self-adaptive display.
As shown in fig. 5A, a target text display schematic diagram provided by the embodiment of the present invention is shown, where the target text in fig. 5A is not displayed in a line feed, and the scenario in fig. 5A is as follows: judging whether the parent layout control meets the line feed display target text or not according to the control width and the first tiling width, and if the parent layout control does not meet the line feed display target text, displaying the target text in a line display mode through the parent layout control.
As shown in fig. 5B, another target text display schematic diagram provided by the embodiment of the present invention is shown, where the target text in fig. 5B is displayed in a line feed manner, and the scenario in fig. 5B is as follows: judging whether the parent layout control meets the line feed display target text according to the width of the control and the first flat width, if the parent layout control meets the line feed display target text, line feed is carried out on the target text, the second flat width of the residual text after line feed is determined, and then judging whether the parent layout control meets the line feed display residual text according to the width of the control and the second flat width; if the parent layout control meets the requirement of line feed display of the residual text, displaying the target text in a first display mode through the parent layout control; the first display mode is line feed display.
In the embodiment of the invention, the page control is loaded, and the text size of the page control is obtained; acquiring a target text and the character number of the target text, and acquiring screen resolution; the target text is the text of the target language; determining a first tiling width corresponding to the target text according to the character number, the screen resolution and the text size of the page control of the target text; acquiring a parent layout control corresponding to the target text and the control width of the parent layout control through the page control; according to the text size, the first tiling width and the control width, the target text is displayed through the parent layout control in a self-adaptive mode, so that the target text can be displayed through the parent layout control in a self-adaptive mode based on the text size of the page control, the first tiling width corresponding to the target text and the control width of the parent layout control, later-stage manual adjustment on the control is not needed, and the method is more convenient compared with the prior art.
It should be noted that, for simplicity of description, the method embodiments are shown as a series of acts, but it should be understood by those skilled in the art that the embodiments are not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred embodiments, and that the acts are not necessarily required by the embodiments of the invention.
Referring to fig. 6, a block diagram of a text adaptive display device according to an embodiment of the present invention is shown, which may specifically include the following modules:
the first obtaining module 601 is configured to load a page control and obtain a text size of the page control;
a second obtaining module 602, configured to obtain a target text and a character number of the target text, and obtain a screen resolution;
a determining module 603, configured to determine a first tiling width corresponding to the target text according to the number of characters of the target text, the screen resolution, and the text size of the page control;
a third obtaining module 604, configured to obtain, through the page control, a parent layout control corresponding to the target text and a control width of the parent layout control;
and the display module 605 is configured to adaptively display the target text through the parent layout control according to the text size, the first tiling width and the control width.
In one embodiment, the display module 605 includes:
the judging sub-module is used for judging whether the parent layout control meets the requirement of line feed display of the target text according to the control width and the first tiling width;
The determining submodule is used for carrying out line feed on the target text if the parent layout control meets line feed display of the target text, and determining a second paving width of the text left after line feed;
and the display sub-module is used for adaptively displaying the target text through the parent layout control according to the text size, the second paving width and the control width.
In one embodiment, the display submodule includes:
the judging unit is used for judging whether the parent layout control meets the requirement of line feed display of the residual text according to the control width and the second paving width;
the first display unit is used for displaying the target text in a first display mode through the parent layout control if the parent layout control meets the requirement of line feed display of the residual text; the first display mode is line feed display;
and the second display unit is used for adjusting the size of the text according to a preset size if the parent layout control does not meet the requirement of line feed display of the residual text, and displaying the target text through the parent layout control in a self-adaptive mode based on the adjusted size of the text again.
In an embodiment, the judging submodule includes:
The first determining unit is used for determining that the parent layout control does not meet the requirement of line feed display of the target text if the width of the control is larger than or equal to the first tiling width;
and the second determining unit is used for determining that the parent layout control meets the requirement of line feed display of the target text if the width of the control is smaller than the first tiling width.
In an embodiment, the judging unit includes:
the first determining subunit is configured to determine that the parent layout control satisfies line feed to display the remaining text if the control width is greater than or equal to the second width;
and the second determining subunit is configured to determine that the parent layout control does not satisfy line feed display of the remaining text if the control width is smaller than the second tile width.
In one embodiment, the third obtaining module 604 includes:
the first acquisition sub-module is used for acquiring the control identity corresponding to the target text through the page control;
and the second acquisition sub-module is used for acquiring the parent layout control corresponding to the target text and the control width of the parent layout control according to the control identity.
In an embodiment, the determining submodule includes:
The acquisition unit is used for acquiring the character number of the text left after line feed;
and the third determining unit is used for determining a second paving width corresponding to the residual text according to the character number of the residual text, the screen resolution and the text size of the page control.
In the embodiment of the invention, a first acquisition module is used for loading the page control and acquiring the text size of the page control; the second acquisition module is used for acquiring the target text and the character number of the target text and acquiring the screen resolution; the determining module is used for determining a first tiling width corresponding to the target text according to the character number of the target text, the screen resolution and the text size of the page control; the third acquisition module is used for acquiring a parent layout control corresponding to the target text and the control width of the parent layout control through the page control; and the display module is used for adaptively displaying the target text through the parent layout control according to the text size, the first tiling width and the control width. Therefore, the target text can be adaptively displayed through the parent layout control based on the text size of the page control, the first tiling width corresponding to the target text and the control width of the parent layout control, and the control does not need to be adjusted manually in the later period, so that the method is more convenient compared with the prior art.
For the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments for relevant points.
The embodiment of the invention also provides electronic equipment, which comprises:
the text self-adaptive display method comprises a processor, a memory and a computer program which is stored in the memory and can run on the processor, wherein the computer program realizes all the processes of the text self-adaptive display method embodiment when being executed by the processor, can achieve the same technical effects, and is not repeated here for avoiding repetition.
The embodiment of the invention also provides a computer readable storage medium, on which a computer program is stored, which when executed by a processor, realizes the processes of the text adaptive display method embodiment, and can achieve the same technical effects, and in order to avoid repetition, the description is omitted here.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described by differences from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other.
It will be apparent to those skilled in the art that embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the invention may take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or terminal device comprising the element.
The foregoing has outlined in detail a text adaptive display method, a text adaptive display device, an electronic device and a computer readable storage medium, wherein specific examples are provided herein to illustrate the principles and embodiments of the present invention and to help understand the method and core idea of the present invention; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present invention, the present description should not be construed as limiting the present invention in view of the above.

Claims (10)

1. A method for adaptively displaying text, the method comprising:
loading a page control and acquiring the text size of the page control;
acquiring a target text and the character number of the target text, and acquiring screen resolution; the target text is the text of the target language;
determining a first tiling width corresponding to the target text according to the character number of the target text, the screen resolution and the text size of the page control;
acquiring a parent layout control corresponding to the target text and the control width of the parent layout control through the page control;
And displaying the target text through the parent layout control in a self-adaptive mode according to the text size, the first tiling width and the control width.
2. The method of claim 1, wherein said adaptively displaying said target text via said parent layout control according to said text size, said first tile width, and said control width, comprises:
judging whether the parent layout control meets the requirement of line feed display of the target text or not according to the control width and the first tiling width;
if the parent layout control meets the requirement of line feed display of the target text, line feed is carried out on the target text, and a second paving width of the text left after line feed is determined;
and displaying the target text through the parent layout control in a self-adaptive mode according to the text size, the second paving width and the control width.
3. The text adaptive display method of claim 2, wherein the adaptively displaying the target text through the parent layout control according to the text size, the second tile width, and the control width comprises:
judging whether the parent layout control meets the requirement of line feed display of the residual text or not according to the control width and the second paving width;
If the parent layout control meets the requirement of line feed display of the residual text, displaying the target text in a first display mode through the parent layout control; the first display mode is line feed display;
and if the parent layout control does not meet the requirement of line feed display of the residual text, adjusting the size of the text according to a preset size, and adaptively displaying the target text through the parent layout control based on the adjusted size of the text again.
4. The text adaptive display method according to claim 2, wherein the determining whether the parent layout control satisfies a line feed to display the target text according to the control width and the first tile width includes:
if the width of the control is larger than or equal to the first tiling width, determining that the parent layout control does not meet line feed display of the target text;
and if the width of the control is smaller than the first tiling width, determining that the parent layout control meets the requirement of line feed display of the target text.
5. The text adaptive display method according to claim 3, wherein the determining whether the parent layout control satisfies a line feed to display the remaining text according to the control width and the second tile width includes:
If the width of the control is larger than or equal to the second paving width, determining that the parent layout control meets the requirement of displaying the residual text in a line feed manner;
and if the width of the control is smaller than the second paving width, determining that the parent layout control does not meet the requirement of line feed display of the residual text.
6. The text adaptive display method according to claim 1, wherein the obtaining, by the page control, a parent layout control corresponding to the target text and a control width of the parent layout control includes:
acquiring a control identity corresponding to the target text through the page control;
and acquiring a parent layout control corresponding to the target text and the control width of the parent layout control according to the control identity.
7. The text adaptive display method according to claim 2, wherein determining the second width of the spread of the text remaining after the line feed comprises:
acquiring the character number of the text left after line feed;
and determining a second paving width corresponding to the residual text according to the character number of the residual text, the screen resolution and the text size of the page control.
8. A text adaptive display device, the device comprising:
The first acquisition module is used for loading the page control and acquiring the text size of the page control;
the second acquisition module is used for acquiring the target text and the character number of the target text and acquiring the screen resolution;
the determining module is used for determining a first tiling width corresponding to the target text according to the character number of the target text, the screen resolution and the text size of the page control;
the third acquisition module is used for acquiring a parent layout control corresponding to the target text and the control width of the parent layout control through the page control;
and the display module is used for adaptively displaying the target text through the parent layout control according to the text size, the first tiling width and the control width.
9. An electronic device, comprising: a processor, a memory and a computer program stored on the memory and capable of running on the processor, which when executed by the processor performs the steps of the text adaptive display method of any of claims 1-7.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the text adaptive display method according to any of claims 1-7.
CN202311759226.5A 2023-12-19 2023-12-19 Text self-adaptive display method and device, electronic equipment and storage medium Pending CN117873616A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311759226.5A CN117873616A (en) 2023-12-19 2023-12-19 Text self-adaptive display method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311759226.5A CN117873616A (en) 2023-12-19 2023-12-19 Text self-adaptive display method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117873616A true CN117873616A (en) 2024-04-12

Family

ID=90589255

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311759226.5A Pending CN117873616A (en) 2023-12-19 2023-12-19 Text self-adaptive display method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117873616A (en)

Similar Documents

Publication Publication Date Title
JP4261558B2 (en) Image processing method
US8593666B2 (en) Method and system for printing a web page
CN105912336A (en) Multi-screen adaptive method for mobile terminal front-end development
US20070253633A1 (en) Image enhancement employing partial template matching
CN117873616A (en) Text self-adaptive display method and device, electronic equipment and storage medium
US9609171B2 (en) Applying luminance conversion processing in accordance with image attribute information to improve edge detection and image data correction for pseudo halftone processing
EP0415742B1 (en) Image processing apparatus
JP2007001166A (en) Image processing method, image processing apparatus and program
JP5825306B2 (en) Image scaling apparatus and image scaling method
CN114879920A (en) Printing data typesetting method and device, printer, electronic equipment and storage medium
CN102096903B (en) Page rasterized character smooth processing method and system
CN101365043A (en) Spot array stage pixel point color calibrating method and device
EP2571244A2 (en) Image processing apparatus, method, image forming apparatus, and storage medium
JP7452059B2 (en) Information processing device and program
KR101197097B1 (en) Method for providing webpage adaptive device and device thereof
EP2654283A1 (en) Method for halftoning
JP6918610B2 (en) Image processing equipment and programs
JP6358198B2 (en) Image forming apparatus and program
US20200300661A1 (en) Information processing apparatus and non-transitory computer readable medium
CN113805822A (en) Ticket printing generation method, device, equipment and medium on embedded terminal
CN116861849A (en) Method and system for setting multiple line spacing of rich text
CN117656680A (en) Printing method and device
JP2023069216A (en) Image processing device, printer, image processing method, and program
CN114140811A (en) Certificate sample generation method and device, electronic equipment and storage medium
CN113657085A (en) Text typesetting method and device, electronic equipment and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination