Movatterモバイル変換


[0]ホーム

URL:


CN116392810A - Text display method and device, electronic equipment and readable storage medium - Google Patents

Text display method and device, electronic equipment and readable storage medium
Download PDF

Info

Publication number
CN116392810A
CN116392810ACN202310411618.6ACN202310411618ACN116392810ACN 116392810 ACN116392810 ACN 116392810ACN 202310411618 ACN202310411618 ACN 202310411618ACN 116392810 ACN116392810 ACN 116392810A
Authority
CN
China
Prior art keywords
text
text component
bounding box
size information
sliding
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
CN202310411618.6A
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.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network 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 Netease Hangzhou Network Co LtdfiledCriticalNetease Hangzhou Network Co Ltd
Priority to CN202310411618.6ApriorityCriticalpatent/CN116392810A/en
Publication of CN116392810ApublicationCriticalpatent/CN116392810A/en
Pendinglegal-statusCriticalCurrent

Links

Images

Classifications

Landscapes

Abstract

The embodiment of the disclosure provides a text display method, a text display device, an electronic device and a readable storage medium, wherein the method comprises the following steps: acquiring a language switching instruction for text content, and performing language switching on the text content according to the language switching instruction; determining size information of a text component bounding box corresponding to the text content after switching; and adjusting the sliding area of the text component according to the size information of the text component bounding box. According to the embodiment of the disclosure, the text component capable of adaptively adjusting the sliding area is provided, when the text content is changed, the size information of the text component bounding box is redetermined, when the size of the text component bounding box is changed, the sliding area of the text component is dynamically adjusted, a user can completely acquire the text content in the display area through actively sliding the text component, and the information of texts of different languages can be completely and reasonably displayed in different language environments.

Description

Text display method and device, electronic equipment and readable storage medium
Technical Field
The present disclosure relates to the field of computer technology, and in particular, to a text display method, a text display device, an electronic apparatus, and a computer-readable storage medium.
Background
With the globalization development of the gaming industry, more and more game items will provide different kinds of languages for players to choose from. However, the difference of language types may cause a difference in the length or width of the text, and after the content with the same meaning is translated in different languages, the obtained text may have a larger difference in length. In the case where the display area is fixed, text of a part of language categories may be cut, resulting in information loss. If the display area is dynamically adjusted according to the bounding box sizes of the texts of different languages, other data carriers such as texts, images and the like can be blocked by the oversized display area, namely, other images or texts except the concerned text component can be blocked when the increased display area is oversized, for example, the display area of the A text can be blindly increased, the display of the B text can be blocked, and information can still be lost.
Disclosure of Invention
In view of the above, embodiments of the present disclosure are presented to provide a text display method and corresponding text display device, an electronic apparatus, and a computer-readable storage medium that overcome or at least partially solve the above problems.
The embodiment of the disclosure discloses a text display method, which comprises the following steps:
acquiring a language switching instruction for text content, and performing language switching on the text content according to the language switching instruction;
determining size information of a text component bounding box corresponding to the text content after switching;
and adjusting the sliding area of the text component according to the size information of the text component bounding box.
The embodiment of the disclosure also discloses a text display device, which comprises:
the acquisition and language switching module is used for acquiring a language switching instruction for text content and performing language switching on the text content according to the language switching instruction;
the determining module is used for determining the size information of the text component bounding box corresponding to the switched text content;
and the adjusting module is used for adjusting the sliding area of the text component according to the size information of the text component bounding box.
The embodiment of the disclosure also discloses an electronic device, which comprises: 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 implements a text display method as described above.
The disclosed embodiments also disclose a computer readable storage medium having stored thereon a computer program which when executed by a processor implements a text display method as described above.
Embodiments of the present disclosure include the following advantages:
in the embodiment of the disclosure, a language switching instruction for text content may be obtained, the text content may be subjected to language switching according to the language switching instruction, after the text content is subjected to language switching, size information of a text component bounding box corresponding to the switched text content may be determined, and a sliding region of the text component may be adjusted according to the size information of the text component bounding box. By adopting the method, the text component capable of adaptively adjusting the sliding area is provided, after the text content is changed, the size information of the text component bounding box is redetermined, after the size of the text component bounding box is changed, the sliding area of the text component is dynamically adjusted, the sliding area range of the text component is determined, whether the file component can slide or not is automatically calculated, a user can actively control the text content presented in the display area by actively sliding/dragging the text component, so that the complete text content can be seen in the display area, the information of texts of different languages can be completely and reasonably displayed in different language environments, the possibility that the text component is cut by mistake is avoided, and the design labor cost is reduced.
Drawings
FIG. 1 is a schematic diagram of a prior art text display using a text ticker;
FIG. 2 is a flow chart of steps of a text display method provided by an embodiment of the present disclosure;
FIG. 3 is a flow chart of steps of another text display method provided by an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a positional relationship of a display area and a text component bounding box in an embodiment of the present disclosure;
FIG. 5 is a schematic illustration of a text component sliding area of an embodiment of the present disclosure;
FIG. 6 is a schematic diagram of a text component configuration of an embodiment of the present disclosure;
FIG. 7 is a schematic diagram of text component display text content in a different language environment in accordance with an embodiment of the present disclosure;
fig. 8 is a block diagram of a text display device according to an embodiment of the present disclosure;
fig. 9 is a block diagram of an electronic device according to an embodiment of the present disclosure.
Detailed Description
To make the above objects, features and advantages of the present disclosure more comprehensible, the present disclosure is described in further detail below with reference to the accompanying drawings and detailed description, and it is apparent that the described embodiments are only a part of the embodiments of the present disclosure, but not all embodiments. All other embodiments derived by a person of ordinary skill in the art based on the embodiments in the disclosure fall within the scope of the disclosure.
With the globalization development of the gaming industry, more and more game items will provide different kinds of languages for players to choose from. How to completely and reasonably display the information of the texts with different language types under the condition of fixed display area is an important problem to be discussed and solved by the present disclosure.
In the prior art, the information of the texts with different languages is usually displayed by adopting a mode of word ticker or word size reduction.
For the text ticker, the principle is as shown in fig. 1, in order to solve the problem that the size of a bounding box of a text component is larger than that of a display area, a solution strategy for changing space in time is adopted, the text component is rolled along the direction from the upper limit of the bounding box to the lower limit of the bounding box, and when the text component reaches the lower limit of the bounding box, the text component is reset, and the process is circularly executed.
For reducing the font size, the principle is to reduce the bounding box size by actively reducing the font size of the text component, and repeating the process until the text component bounding box size is smaller than the display area.
The above scheme has the following problems:
for the text ticker, since the text is periodically moved at a fixed speed, when a player misses a part of text content, the player needs to wait for a complete period to run and then read the part of text content again, and the player cannot actively control the text movement, so that the reading experience is poor. Meanwhile, too long text can lead to long horse race lights, and players need to wait for at least one running period, so that the players feel lengthy in game, and the game evaluation is affected. Therefore, the text ticker mode is only applicable to the situation that the size of the text component bounding box is slightly larger than the display area.
For reducing the word size, the calculation amount is increased and the performance consumption is high because the word size needs to be continuously reduced and the relation between the bounding box size and the size of the display area is judged. Meanwhile, there are cases where the display requirement is not satisfied yet when the font is reduced to the minimum size, that is, the text content may still exceed the display area. Finally, too small a word size can affect the player's reading experience. Therefore, the way to reduce the font size is also only applicable to the case where the text component bounding box size is slightly larger than the display area.
Based on the above, the disclosure relates to providing a text display method applicable to a bounding box with a large difference between the size of the bounding box and the size of the display area, which can enable a player to obtain text content information of a text component completely, reasonably and autonomously. The text component is high in universality, reasonable in performance and capable of adaptively adjusting the sliding range.
According to the embodiment of the disclosure, the language switching instruction for the text content can be obtained, the language of the text content can be switched according to the language switching instruction, after the language of the text content is switched, the size information of the text component bounding box corresponding to the switched text content can be determined, and the sliding area of the text component can be adjusted according to the size information of the text component bounding box. By adopting the method, the text component capable of adaptively adjusting the sliding area is provided, after the text content is changed, the size information of the text component bounding box is redetermined, after the size of the text component bounding box is changed, the sliding area of the text component is dynamically adjusted, the sliding area range of the text component is determined, whether the file component can slide or not is automatically calculated, a user can actively slide/drag the text component to actively control the text content presented in the display area, so that the complete text content can be seen in the display area, the information of texts of different languages can be completely and reasonably displayed in different language environments, the possibility that the text component is cut by mistake is avoided, and the design labor cost is reduced.
Referring to fig. 2, a flowchart illustrating steps of a text display method provided by an embodiment of the present disclosure may specifically include the following steps:
step 201, obtaining a language switching instruction for text content, and performing language switching on the text content according to the language switching instruction.
In the embodiment of the present disclosure, each step in a text display method may be executed by a server or a terminal device. The terminal device may be various terminal devices such as a computer, a mobile phone, a tablet computer, a game console, a PDA, etc., and the specific type of the terminal device is not limited in the embodiment of the present application.
In the embodiment of the disclosure, a language switching instruction for text content may be obtained, and a user may perform a language switching operation in a current display page to switch a language type of the text content from a first language to a second language, and at this time, a corresponding language switching instruction may be generated. Text content may be language switched based on the generated language switching instruction, for example, english text may be translated into chinese text.
Step 202, determining size information of a text component bounding box corresponding to the text content after switching.
The language switching of the text content may cause a size change of the text component bounding box. Wherein a text component may refer to a data carrier capable of loading vector literal resources and information. The text component bounding box may be a closed area that completely encloses the text component, and in particular may refer to a smallest rectangular area that can completely enclose the text component.
In the embodiment of the disclosure, the size information of the text component bounding box corresponding to the text content after the language switching can be determined.
Andstep 203, adjusting the sliding area of the text component according to the size information of the text component bounding box.
The text component of the embodiments of the present disclosure is slidable, and the sliding area of the text component changes according to the change of the text component bounding box size information. When the size information of the text component bounding box changes, the sliding area of the text component is dynamically adjusted, that is, in the embodiment of the disclosure, the sliding area range of the text component can be automatically calculated and determined, and whether the file component can slide or not (the original non-slidable text component is adjusted to be a slidable file component or the original slidable text component is adjusted to be a non-slidable text component), and the text content after language switching is completely displayed in the display area of the current display page is realized by actively sliding the text component in the sliding area.
In summary, in the embodiment of the present disclosure, a language switching instruction for text content may be obtained, the text content may be language switched according to the language switching instruction, after the language switching is performed on the text content, size information of a text component bounding box corresponding to the text content after switching may be determined, and a sliding region of the text component may be adjusted according to the size information of the text component bounding box. By adopting the method, the text component capable of adaptively adjusting the sliding area is provided, after the text content is changed, the size information of the text component bounding box is redetermined, after the size of the text component bounding box is changed, the sliding area of the text component is dynamically adjusted, the sliding area range of the text component is determined, whether the file component can slide or not is automatically calculated, a user can actively control the text content presented in the display area by actively sliding/dragging the text component, so that the complete text content can be seen in the display area, the information of texts of different languages can be completely and reasonably displayed in different language environments, the possibility that the text component is cut by mistake is avoided, and the design labor cost is reduced.
Referring to fig. 3, a flowchart illustrating steps of another text display method provided by an embodiment of the disclosure may specifically include the following steps:
step 301, obtaining a language switching instruction for text content, and performing language switching on the text content according to the language switching instruction.
In the embodiment of the present disclosure, each step in a text display method may be executed by a server or a terminal device. The terminal device may be various terminal devices such as a computer, a mobile phone, a tablet computer, a game console, a PDA, etc., and the specific type of the terminal device is not limited in the embodiment of the present application.
In the embodiment of the disclosure, a language switching instruction for text content can be acquired, and the text content is subjected to language switching based on the acquired language switching instruction.
In an optional embodiment of the present disclosure, instep 301, language switching is performed on the text content according to the language switching instruction, which may specifically include the following sub-steps:
in the substep S11, it is determined that the language switching instruction indicates the target language type to be switched.
And a substep S12, switching the text content into a target language text corresponding to the target language type.
The embodiment of the disclosure can provide a plurality of language types, can determine the target language type to which the language switching instruction indicates to switch, and then switch the text content into the target language text corresponding to the target language type.
Step 302, determining size information of a text component bounding box corresponding to the text content after switching.
As the text content changes, the size of the text component bounding box changes. The size information of the text component bounding box corresponding to the text content after the language switching can be determined.
In an optional embodiment of the present disclosure, determining the size information of the text component bounding box corresponding to the text content after the switching instep 302 may specifically include the following sub-steps:
and a substep S21, recalculating and determining the size information of the corresponding text component bounding box according to the size information of each character in the switched text content.
In the embodiment of the disclosure, the size information of the corresponding text component bounding box is recalculated and determined according to the size information of each character in the switched text content.
In an optional embodiment of the present disclosure, the size information of the text component bounding box includes a length and a height of the text component bounding box, and the step S21 of recalculating and determining the size information of the corresponding text component bounding box according to the size information of each character in the switched text content may specifically include the following substeps:
Determining the maximum value of the number of lines, the line spacing of each line, the number of characters corresponding to each line, the rendering length of each character, the character spacing of each character and the character rendering height corresponding to each line after switching; based on a preset text component bounding box length calculation formula, calculating and determining the length of the corresponding text component bounding box by adopting the rendering length of each character, the character spacing of each character and the number of characters corresponding to each row respectively; and calculating and determining the height of the corresponding text component bounding box by adopting the maximum value in the character rendering height, the line spacing and the line number of each line, which are respectively corresponding to each line, based on a preset text component bounding box height calculation formula.
Since the text component bounding box may be the smallest rectangular area that can completely enclose the text component, determining the size information of the text component bounding box may be determining the length and width of the text component bounding box.
In a specific implementation, assuming that the length of the text component bounding box is L, the height of the text component bounding box is H, and the rendering length of the character i is Li Character i and character i+1 have a character spacing di The number of characters in one row is n;
Let the line spacing between the j-th line text and the j+1-th line text be hj The maximum value of the character rendering height in each line of text is sj The text component contains m lines of text, and a calculation formula of the size of the bounding box of the text component can be obtained as follows:
Figure BDA0004185059440000071
step 303, determining a display area of the text content on the current display page, and determining position information and size information of the display area.
In the embodiment of the disclosure, the text content has a corresponding display area, and the display area may specifically be an area manually specified based on the performance effect, and the text content located in the area may be displayed in the screen.
The display area of the text content in the current display page may be determined, and the position information and the size information of the display area may be determined.
And step 304, recalculating and determining the sliding area of the text component according to the size information of the text component bounding box and the position information and the size information of the display area.
Based on the size information of the text component bounding box, the position information of the display area, and the size information of the display area, the sliding area of the text component may be recalculated. The sliding area of the text component may be an area formed by an upper limit and a lower limit of the text component, and may specifically be a rectangular area.
In an optional embodiment of the present disclosure, the size information of the display area includes a length and a height of the display area, and thestep 304 of recalculating and determining the sliding area of the text component according to the size information of the text component bounding box and the position information and the size information of the display area may specifically include the following sub-steps:
in a substep S31, a first difference between the length of the text component bounding box and the length of the display area is calculated, and a sliding range of the text component in a first direction is determined based on the first difference.
In a substep S32, a second difference between the height of the text component bounding box and the height of the display area is calculated, and a sliding range of the text component in a second direction is determined based on the second difference.
A substep S33 of determining the sliding region of the text component based on the position information of the display region, the sliding range of the text component in the first direction, and the sliding range of the text component in the second direction.
In an embodiment of the present disclosure, a first difference between a length of a text component bounding box and a length of a display area may be calculated, and a sliding range of the text component in a first direction is determined based on the first difference; a second difference between the height of the text component bounding box and the height of the display area can be calculated, and the sliding range of the text component in a second direction is determined based on the second difference; then, based on the position information of the display area, a sliding range of the text component in the first direction and a sliding range of the text component in the second direction are determined.
As shown in fig. 4, a schematic diagram of a positional relationship between a display area and a text component bounding box according to an embodiment of the present disclosure is shown, assuming that the length of the text content display area is a, the height of the text content display area is B, and coordinates of four vertices of the display area in a screen are (x1 ,y1 )、(x2 ,y1 )、(x1 ,y2 )、(x2 ,y2 ) The coordinates of the top left corner vertex of the text component bounding box in the screen are (x, y), and the sliding area of the text component is obtained based on the difference between the following two states:
1. the upper left corner of the text component bounding box is aligned with the upper left corner of the display area; 2. the lower right corner of the text component bounding box is aligned with the lower right corner of the display area.
Taking the vertex coordinates of the upper left corner of the text component bounding box as variables, the sliding region of the text component can be expressed by the following formula:
Figure BDA0004185059440000091
as shown in fig. 5, a schematic diagram of a text component sliding area according to an embodiment of the disclosure is shown, where a hatched area indicates the text component sliding area.
In an alternative embodiment of the present disclosure, the following steps may be specifically performed:
and controlling the text component to slide in the sliding area so as to display the switched text content in the display area.
In an alternative embodiment of the present disclosure, the following steps may be specifically performed:
And responding to the sliding operation of the user on the text component, and controlling the text component to slide in the sliding area.
After automatically calculating the sliding region of the text component, the user can perform sliding operation on the text component, for example, drag a sliding control for the text component, respond to the sliding operation, control the text component to slide in the sliding region, and by controlling the text component to slide in the sliding region, the user can view the complete text content after language switching, namely, display the target language text after language switching in the display region of the current display page.
The text display method of the embodiment of the disclosure can be applied to a game client, and when the text component using the technology is detected to display text content, firstly, the bounding box size of the text component under the language text is calculated. Then, the sliding range of the text component is calculated by comparing the size relation between the bounding box size and the display area. And finally, setting the slidability of the text and the sliding area thereof according to the calculated sliding range, and limiting the text to slide only in the calculated sliding area.
In a specific implementation, a text component in the present disclosure may be enabled by inputting a preset attribute value in a preset attribute field of the text component, and a specific configuration manner may be shown in fig. 6. Therefore, the mutual decoupling of the code writing of the programmer and the design of the designer is realized, the programmer does not need to modify each text, and the working efficiency of both parties is improved.
The specific effect of using the text component is checked in the game, the change of the size of the bounding box of the text component is realized by switching different languages, and whether the sliding range of the text component is consistent with the expected range is checked. Referring to fig. 7, a schematic diagram of text content is shown for a text component in a different language environment according to an embodiment of the present disclosure. FIG. 7 illustrates a Chinese description of a prop in a game, wherein the text component is used in the description portion, and in a Chinese language environment, the sliding area of the text in the text component is basically equivalent to the display area, so that the text cannot slide up and down. When the English language environment is switched to, the English description of the prop exceeds the original display area, the upper limit and the lower limit of the text sliding area of the text component are calculated as shown in the upper right diagram of FIG. 7 and the lower right diagram of FIG. 7 respectively, and text information can be completely read in a sliding mode. The effectiveness of the text component in the scheme is proved by the difference of the sliding range of the text component in the Chinese and English environments, and meanwhile, the function can be suitable for any language environment, and the development efficiency is greatly improved.
In summary, in the embodiment of the present disclosure, a language switching instruction for text content may be obtained, the text content may be language switched according to the language switching instruction, after the language switching is performed on the text content, size information of a text component bounding box corresponding to the text content after switching may be determined, and a sliding region of the text component may be adjusted according to the size information of the text component bounding box. By adopting the method, the text component capable of adaptively adjusting the sliding area is provided, after the text content is changed, the size information of the text component bounding box is redetermined, after the size of the text component bounding box is changed, the sliding area of the text component is dynamically adjusted, the sliding area range of the text component is determined, whether the file component can slide or not is automatically calculated, a user can actively control the text content presented in the display area by actively sliding/dragging the text component, so that the complete text content can be seen in the display area, the information of texts of different languages can be completely and reasonably displayed in different language environments, the possibility that the text component is cut by mistake is avoided, and the design labor cost is reduced.
The utility model provides a general text component, can change self slip scope according to text component bounding box and display area's size automatically, realized can both be complete under the different language environment rationally demonstrate the information of different language class texts, avoided text component by the possibility of wrong cutting, reduced designer's human cost, greatly improved game client's development efficiency.
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 disclosed embodiments are not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the disclosed 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 disclosed embodiments.
Referring to fig. 8, a block diagram of a text display device provided in an embodiment of the disclosure is shown, which may specifically include the following modules:
an acquiring andlanguage switching module 801, configured to acquire a language switching instruction for text content, and perform language switching on the text content according to the language switching instruction;
A determiningmodule 802, configured to determine size information of a text component bounding box corresponding to the text content after switching;
and theadjusting module 803 is configured to adjust the sliding area of the text component according to the size information of the text component bounding box.
In an embodiment of the disclosure, the adjusting module includes:
the first determining submodule is used for determining a display area of the text content in a current display page and determining position information and size information of the display area;
and the first calculation determination submodule is used for recalculating and determining the sliding area of the text component according to the size information of the text component bounding box and the position information and the size information of the display area.
In an embodiment of the disclosure, the determining module includes:
and the second calculation and determination submodule is used for recalculating and determining the size information of the corresponding text component bounding box according to the size information of each character in the switched text content.
In an embodiment of the present disclosure, the size information of the text component bounding box includes a length and a height of the text component bounding box, and the second calculation determining sub-module includes:
A first determining unit, configured to determine a maximum value of a line number, a line spacing of each line, a number of characters corresponding to each line, a rendering length of each character, a character spacing of each character, and a character rendering height corresponding to each line, which are included in the text content after switching;
the first calculation determining unit is used for calculating and determining the length of the corresponding text component bounding box by adopting the rendering length of each character, the character spacing of each character and the number of characters corresponding to each row respectively based on a preset text component bounding box length calculation formula;
and the second calculation determining unit is used for calculating and determining the height of the corresponding text component bounding box by adopting the maximum value in the character rendering height, the line spacing and the line number which are respectively corresponding to each line based on a preset text component bounding box height calculation formula.
In an embodiment of the disclosure, the size information of the display area includes a length and a height of the display area, and the first calculation determining submodule includes:
a first calculating and determining unit, configured to calculate a first difference between a length of the text component bounding box and a length of the display area, and determine a sliding range of the text component in a first direction based on the first difference;
A second calculating and determining unit, configured to calculate a second difference between the height of the text component bounding box and the height of the display area, and determine a sliding range of the text component in a second direction based on the second difference;
and a second determining unit configured to determine the sliding region of the text component based on position information of the display region, a sliding range of the text component in a first direction, and a sliding range of the text component in a second direction.
In an embodiment of the disclosure, the apparatus further includes:
and the first sliding module is used for controlling the text component to slide in the sliding area so as to display the switched text content in the display area.
In an embodiment of the present disclosure, the obtaining and language switching module includes:
the second determining submodule is used for determining the target language type to which the language switching instruction indicates to switch;
and the switching sub-module is used for switching the text content into the target language text corresponding to the target language type.
In an embodiment of the disclosure, the apparatus further includes:
and the second sliding module is used for responding to the sliding operation of the user on the text component and controlling the text component to slide in the sliding area.
In summary, in the embodiment of the present disclosure, a language switching instruction for text content may be obtained, the text content may be language switched according to the language switching instruction, after the language switching is performed on the text content, size information of a text component bounding box corresponding to the text content after switching may be determined, and a sliding region of the text component may be adjusted according to the size information of the text component bounding box. By adopting the method, the text component capable of adaptively adjusting the sliding area is provided, after the text content is changed, the size information of the text component bounding box is redetermined, after the size of the text component bounding box is changed, the sliding area of the text component is dynamically adjusted, the sliding area range of the text component is determined, whether the file component can slide or not is automatically calculated, a user can actively control the text content presented in the display area by actively sliding/dragging the text component, so that the complete text content can be seen in the display area, the information of texts of different languages can be completely and reasonably displayed in different language environments, the possibility that the text component is cut by mistake is avoided, and the design labor cost is reduced.
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 disclosure further provides an electronic device, as shown in fig. 9, including: aprocessor 901, amemory 902, and a computer program stored in the memory and capable of running on the processor, where the computer program when executed by the processor implements the respective processes of the above-described embodiment of a text display method, and achieves the same technical effects, for example:
theprocessor 901 is configured to execute a computer program stored in thememory 902, and implement the following steps:
acquiring a language switching instruction for text content, and performing language switching on the text content according to the language switching instruction;
determining size information of a text component bounding box corresponding to the text content after switching;
and adjusting the sliding area of the text component according to the size information of the text component bounding box.
In an alternative embodiment, the adjusting the sliding area of the text component according to the size information of the text component bounding box includes:
Determining a display area of the text content on a current display page, and determining position information and size information of the display area;
and recalculating and determining the sliding area of the text component according to the size information of the text component bounding box and the position information and the size information of the display area.
In an optional implementation manner, the determining the size information of the text component bounding box corresponding to the text content after switching includes:
and recalculating and determining the size information of the corresponding text component bounding box according to the size information of each character in the switched text content.
In an optional implementation manner, the size information of the text component bounding box includes a length and a height of the text component bounding box, and the recalculating and determining the size information of the corresponding text component bounding box according to the size information of each character in the switched text content includes:
determining the maximum value of the number of lines, the line spacing of each line, the number of characters corresponding to each line, the rendering length of each character, the character spacing of each character and the character rendering height corresponding to each line after switching;
Based on a preset text component bounding box length calculation formula, calculating and determining the length of the corresponding text component bounding box by adopting the rendering length of each character, the character spacing of each character and the number of characters corresponding to each row respectively;
and calculating and determining the height of the corresponding text component bounding box by adopting the maximum value in the character rendering height, the line spacing and the line number of each line, which are respectively corresponding to each line, based on a preset text component bounding box height calculation formula.
In an alternative embodiment, the size information of the display area includes a length and a height of the display area, and the recalculating the sliding area for determining the text component according to the size information of the text component bounding box and the position information and the size information of the display area includes:
calculating a first difference value between the length of the text component bounding box and the length of the display area, and determining a sliding range of the text component in a first direction based on the first difference value;
calculating a second difference value between the height of the text component bounding box and the height of the display area, and determining a sliding range of the text component in a second direction based on the second difference value;
The sliding region of the text component is determined based on the positional information of the display region, a sliding range of the text component in a first direction, and a sliding range of the text component in a second direction.
In an alternative embodiment, the method further comprises:
and controlling the text component to slide in the sliding area so as to display the switched text content in the display area.
In an optional embodiment, the language switching of the text content according to the language switching instruction includes:
determining a target language type to which the language switching instruction indicates switching;
and switching the text content into target language text corresponding to the target language type.
In an alternative embodiment, the method further comprises:
and responding to the sliding operation of the user on the text component, and controlling the text component to slide in the sliding area.
In summary, in the embodiment of the present disclosure, a language switching instruction for text content may be obtained, the text content may be language switched according to the language switching instruction, after the language switching is performed on the text content, size information of a text component bounding box corresponding to the text content after switching may be determined, and a sliding region of the text component may be adjusted according to the size information of the text component bounding box. By adopting the method, the text component capable of adaptively adjusting the sliding area is provided, after the text content is changed, the size information of the text component bounding box is redetermined, after the size of the text component bounding box is changed, the sliding area of the text component is dynamically adjusted, the sliding area range of the text component is determined, whether the file component can slide or not is automatically calculated, a user can actively control the text content presented in the display area by actively sliding/dragging the text component, so that the complete text content can be seen in the display area, the information of texts of different languages can be completely and reasonably displayed in different language environments, the possibility that the text component is cut by mistake is avoided, and the design labor cost is reduced.
The embodiments of the present disclosure also provide a computer readable storage medium, on which a computer program is stored, where the computer program when executed by a processor implements the processes of the above-described embodiments of a text display method, and achieves the same technical effects, for example:
the processor, when configured to execute a computer program stored on a computer readable storage medium, performs the steps of:
acquiring a language switching instruction for text content, and performing language switching on the text content according to the language switching instruction;
determining size information of a text component bounding box corresponding to the text content after switching;
and adjusting the sliding area of the text component according to the size information of the text component bounding box.
In an alternative embodiment, the adjusting the sliding area of the text component according to the size information of the text component bounding box includes:
determining a display area of the text content on a current display page, and determining position information and size information of the display area;
and recalculating and determining the sliding area of the text component according to the size information of the text component bounding box and the position information and the size information of the display area.
In an optional implementation manner, the determining the size information of the text component bounding box corresponding to the text content after switching includes:
and recalculating and determining the size information of the corresponding text component bounding box according to the size information of each character in the switched text content.
In an optional implementation manner, the size information of the text component bounding box includes a length and a height of the text component bounding box, and the recalculating and determining the size information of the corresponding text component bounding box according to the size information of each character in the switched text content includes:
determining the maximum value of the number of lines, the line spacing of each line, the number of characters corresponding to each line, the rendering length of each character, the character spacing of each character and the character rendering height corresponding to each line after switching;
based on a preset text component bounding box length calculation formula, calculating and determining the length of the corresponding text component bounding box by adopting the rendering length of each character, the character spacing of each character and the number of characters corresponding to each row respectively;
and calculating and determining the height of the corresponding text component bounding box by adopting the maximum value in the character rendering height, the line spacing and the line number of each line, which are respectively corresponding to each line, based on a preset text component bounding box height calculation formula.
In an alternative embodiment, the size information of the display area includes a length and a height of the display area, and the recalculating the sliding area for determining the text component according to the size information of the text component bounding box and the position information and the size information of the display area includes:
calculating a first difference value between the length of the text component bounding box and the length of the display area, and determining a sliding range of the text component in a first direction based on the first difference value;
calculating a second difference value between the height of the text component bounding box and the height of the display area, and determining a sliding range of the text component in a second direction based on the second difference value;
the sliding region of the text component is determined based on the positional information of the display region, a sliding range of the text component in a first direction, and a sliding range of the text component in a second direction.
In an alternative embodiment, the method further comprises:
and controlling the text component to slide in the sliding area so as to display the switched text content in the display area.
In an optional embodiment, the language switching of the text content according to the language switching instruction includes:
determining a target language type to which the language switching instruction indicates switching;
and switching the text content into target language text corresponding to the target language type.
In an alternative embodiment, the method further comprises:
and responding to the sliding operation of the user on the text component, and controlling the text component to slide in the sliding area.
In summary, in the embodiment of the present disclosure, a language switching instruction for text content may be obtained, the text content may be language switched according to the language switching instruction, after the language switching is performed on the text content, size information of a text component bounding box corresponding to the text content after switching may be determined, and a sliding region of the text component may be adjusted according to the size information of the text component bounding box. By adopting the method, the text component capable of adaptively adjusting the sliding area is provided, after the text content is changed, the size information of the text component bounding box is redetermined, after the size of the text component bounding box is changed, the sliding area of the text component is dynamically adjusted, the sliding area range of the text component is determined, whether the file component can slide or not is automatically calculated, a user can actively control the text content presented in the display area by actively sliding/dragging the text component, so that the complete text content can be seen in the display area, the information of texts of different languages can be completely and reasonably displayed in different language environments, the possibility that the text component is cut by mistake is avoided, and the design labor cost is reduced.
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 disclosure may be provided as a method, apparatus, or computer program product. Accordingly, the disclosed embodiments 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 present disclosure 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 disclosure 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 disclosure. 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 the preferred embodiments of the disclosed embodiments 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 disclosed embodiments.
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 described in detail a text display method, a text display device, an electronic device and a computer readable storage medium provided by the present disclosure, and specific examples have been applied herein to illustrate the principles and embodiments of the present disclosure, the above examples being provided only to assist in understanding the method of the present disclosure and its core ideas; meanwhile, as one of ordinary skill in the art will have variations in the detailed description and the application scope in light of the ideas of the present disclosure, the present disclosure should not be construed as being limited to the above description.

Claims (11)

1. A text display method, the method comprising:
acquiring a language switching instruction for text content, and performing language switching on the text content according to the language switching instruction;
determining size information of a text component bounding box corresponding to the text content after switching;
and adjusting the sliding area of the text component according to the size information of the text component bounding box.
2. The method of claim 1, wherein adjusting the sliding region of the text component according to the size information of the text component bounding box comprises:
determining a display area of the text content on a current display page, and determining position information and size information of the display area;
and recalculating and determining the sliding area of the text component according to the size information of the text component bounding box and the position information and the size information of the display area.
3. The method according to claim 1 or 2, wherein determining the size information of the text component bounding box corresponding to the text content after switching includes:
and recalculating and determining the size information of the corresponding text component bounding box according to the size information of each character in the switched text content.
4. The method according to claim 3, wherein the size information of the text component bounding box includes a length and a height of the text component bounding box, and the recalculating the size information of the text component bounding box according to the size information of each character in the text content after the switching includes:
determining the maximum value of the number of lines, the line spacing of each line, the number of characters corresponding to each line, the rendering length of each character, the character spacing of each character and the character rendering height corresponding to each line after switching;
based on a preset text component bounding box length calculation formula, calculating and determining the length of the corresponding text component bounding box by adopting the rendering length of each character, the character spacing of each character and the number of characters corresponding to each row respectively;
and calculating and determining the height of the corresponding text component bounding box by adopting the maximum value in the character rendering height, the line spacing and the line number of each line, which are respectively corresponding to each line, based on a preset text component bounding box height calculation formula.
5. The method of claim 4, wherein the size information of the display area includes a length and a height of the display area, and wherein the recalculating the sliding area of the text component based on the size information of the text component bounding box and the position information and the size information of the display area includes:
Calculating a first difference value between the length of the text component bounding box and the length of the display area, and determining a sliding range of the text component in a first direction based on the first difference value;
calculating a second difference value between the height of the text component bounding box and the height of the display area, and determining a sliding range of the text component in a second direction based on the second difference value;
the sliding region of the text component is determined based on the positional information of the display region, a sliding range of the text component in a first direction, and a sliding range of the text component in a second direction.
6. The method of claim 5, wherein the method further comprises:
and controlling the text component to slide in the sliding area so as to display the switched text content in the display area.
7. The method of claim 1, wherein said language switching the text content according to the language switching instruction comprises:
determining a target language type to which the language switching instruction indicates switching;
and switching the text content into target language text corresponding to the target language type.
8. The method according to claim 1, wherein the method further comprises:
and responding to the sliding operation of the user on the text component, and controlling the text component to slide in the sliding area.
9. A text display device, the device comprising:
the acquisition and language switching module is used for acquiring a language switching instruction for text content and performing language switching on the text content according to the language switching instruction;
the determining module is used for determining the size information of the text component bounding box corresponding to the switched text content;
and the adjusting module is used for adjusting the sliding area of the text component according to the size information of the text component bounding box.
10. An electronic device, comprising: a processor, a memory and a computer program stored on the memory and capable of running on the processor, which computer program, when executed by the processor, implements a text display method as claimed in any one of claims 1-8.
11. A computer-readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, implements a text display method according to any one of claims 1 to 8.
CN202310411618.6A2023-04-132023-04-13Text display method and device, electronic equipment and readable storage mediumPendingCN116392810A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202310411618.6ACN116392810A (en)2023-04-132023-04-13Text display method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202310411618.6ACN116392810A (en)2023-04-132023-04-13Text display method and device, electronic equipment and readable storage medium

Publications (1)

Publication NumberPublication Date
CN116392810Atrue CN116392810A (en)2023-07-07

Family

ID=87010294

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202310411618.6APendingCN116392810A (en)2023-04-132023-04-13Text display method and device, electronic equipment and readable storage medium

Country Status (1)

CountryLink
CN (1)CN116392810A (en)

Similar Documents

PublicationPublication DateTitle
JP6984840B2 (en) Real-time comment display method and electronic devices
EP3279866A1 (en)Method and apparatus for generating synthetic picture
US9773072B2 (en)Systems and methods for developing adaptive layouts for electronic content
US10169307B2 (en)Method and system for the use of adjustment handles to facilitate dynamic layout editing
KR102591542B1 (en) Table processing methods, devices, smart interactive tablets and storage media
CN108156510B (en)Page focus processing method and device and computer readable storage medium
CN104915186B (en)A kind of method and apparatus making the page
CN114241105B (en)Interface rendering method, device, equipment and computer readable storage medium
CN112835499A (en)Carousel graph display method, device, equipment and medium
EP2874054A1 (en)Application text adjusting method, device, and terminal
CN106886511B (en)Network table processing method and device
CN112579927A (en)Method and device for displaying navigation bar
CN112287264B (en)Webpage layout method and device, electronic equipment and storage medium
CN115237522A (en)Page self-adaptive display method and device
CN107122104B (en)Data display method and device
CN114118029A (en)Image processing method, device, equipment and storage medium
US20130073943A1 (en)Trial based multi-column balancing
CN113792237B (en)Optimization method and device for card layout, storage medium and processor
CN110471700A (en)Graphic processing method, device, storage medium and electronic equipment
CN116392810A (en)Text display method and device, electronic equipment and readable storage medium
CN109992182B (en)Electronic book batch page turning method, electronic equipment and computer storage medium
CN111739084B (en)Picture processing method, atlas processing method, computer device, and storage medium
CN115793909A (en)Page interaction method and system
CN111814087B (en)Dynamic layout method and device of Web window, electronic equipment and readable storage medium
CN112416216A (en)Work display method, electronic device and storage medium

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination

[8]ページ先頭

©2009-2025 Movatter.jp