CN109145272B - Text rendering and layout method, device, equipment and storage medium - Google Patents
Text rendering and layout method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN109145272B CN109145272B CN201810846808.XA CN201810846808A CN109145272B CN 109145272 B CN109145272 B CN 109145272B CN 201810846808 A CN201810846808 A CN 201810846808A CN 109145272 B CN109145272 B CN 109145272B
- Authority
- CN
- China
- Prior art keywords
- text
- determining
- target
- editing object
- editing
- 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.)
- Active
Links
- 238000009877 rendering Methods 0.000 title claims abstract description 87
- 238000000034 method Methods 0.000 title claims abstract description 42
- 230000004048 modification Effects 0.000 claims description 58
- 238000012986 modification Methods 0.000 claims description 58
- 238000004590 computer program Methods 0.000 claims description 8
- 238000007373 indentation Methods 0.000 claims description 5
- 230000008719 thickening Effects 0.000 claims 1
- 230000006870 function Effects 0.000 description 12
- 238000010586 diagram Methods 0.000 description 9
- 238000012545 processing Methods 0.000 description 8
- 238000012217 deletion Methods 0.000 description 6
- 230000037430 deletion Effects 0.000 description 6
- 230000003287 optical effect Effects 0.000 description 6
- 230000004044 response Effects 0.000 description 5
- 230000002093 peripheral effect Effects 0.000 description 4
- 230000003044 adaptive effect Effects 0.000 description 3
- 230000002452 interceptive effect Effects 0.000 description 3
- 230000008569 process Effects 0.000 description 3
- 230000009466 transformation Effects 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 2
- 239000013307 optical fiber Substances 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 230000003416 augmentation Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000005457 optimization Methods 0.000 description 1
- 230000008707 rearrangement Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/10—Text processing
- G06F40/166—Editing, e.g. inserting or deleting
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Health & Medical Sciences (AREA)
- Artificial Intelligence (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Document Processing Apparatus (AREA)
Abstract
The embodiment of the invention discloses a text rendering and layout method, a text rendering and layout device, text rendering equipment and a storage medium, wherein the method comprises the following steps: obtaining an operation type of an editing operation received by a text box, wherein the operation type comprises at least one of the following: inputting operation, pasting operation, deleting operation and attribute modifying operation; determining a target text and a region to be operated, wherein the target text and the region to be operated are determined according to the operation type, an editing object corresponding to the editing operation and a related text of the editing object, the target text is located in the text box, and the region to be operated is located in a text box region formed by the text box; rendering the target text, and displaying the target text in a layout manner in the region to be operated. When only part of the text in the text box is edited, the problems of time consumption and the like caused by repeated rendering and/or layout due to rendering and/or layout of all the text in the text box are avoided.
Description
Technical Field
The present invention relates to the field of text rendering and layout technologies, and in particular, to a method, an apparatus, a device, and a storage medium for text rendering and layout.
Background
A text box, generally referred to as a movable, resizable container of text or graphics, may be used to place blocks of text on a page or to orient the text differently from other text in a document.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art. Each time there is an editing operation on a text in a text box in an existing intelligent tablet, a paragraph where an edited character in the text box is located is triggered to be redrawn, and if the editing operation affects other paragraphs, the other paragraphs may need to be redrawn. When the paragraph in which the edited text is located is long or there are many artistic words contained in the paragraph, the rendering may be time-consuming.
Disclosure of Invention
Embodiments of the present invention provide a method, an apparatus, a device, and a storage medium for rendering and laying out a text, which avoid the problem of time consumption caused by repeated rendering and/or laying out due to rendering and/or laying out all texts in a text box when only a part of texts in the text box are edited.
In a first aspect, an embodiment of the present invention provides a text rendering and layout method, where the method includes:
obtaining an operation type of an editing operation received by a text box, wherein the operation type comprises at least one of the following: inputting operation, pasting operation, deleting operation and attribute modifying operation;
determining a target text and a region to be operated, wherein the target text and the region to be operated are determined according to the operation type, an editing object corresponding to the editing operation and a related text of the editing object, the target text is located in the text box, and the region to be operated is located in a text box region formed by the text box;
rendering the target text, and displaying the target text in a layout mode in the area to be operated.
In a second aspect, an embodiment of the present invention further provides a text rendering and layout apparatus, where the apparatus includes:
an obtaining module, configured to obtain an operation type of an editing operation received by a text box, where the operation type includes at least one of: inputting operation, pasting operation, deleting operation and attribute modifying operation;
a determining module, configured to determine a target text and a region to be operated, where the target text and the region to be operated are determined according to the operation type, an editing object corresponding to the editing operation, and a text associated with the editing object, the target text is located in the text box, and the region to be operated is located in a text box region formed by the text box;
and the rendering and layout module is used for rendering the target text and displaying the target text in the to-be-operated area in a layout mode.
In a third aspect, an embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the text rendering and layout method according to any one of the embodiments of the present invention when executing the program.
In a fourth aspect, the present invention further provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the text rendering and layout method according to any one of the embodiments of the present invention.
In the embodiment of the present invention, an operation type of an editing operation received by a text box is obtained, where the operation type includes at least one of: inputting operation, pasting operation, deleting operation and attribute modifying operation; determining a target text and a region to be operated, wherein the target text and the region to be operated are determined according to the operation type, an editing object corresponding to the editing operation and a related text of the editing object, the target text is located in the text box, and the region to be operated is located in a text box region formed by the text box; rendering the target text, and displaying the target text in a layout mode in the area to be operated. Aiming at the input operation and the pasting operation, the target text to be rendered and the area to be operated to which the target text needs to be laid out are determined, and repeated rendering and/or layout of other texts without editing operation are avoided; determining a target text and a region to be operated aiming at the deletion operation, and not rendering and/or laying out aiming at the text before the deleted text; and determining a target text and a region to be operated which need to be rendered according to the attribute modification operation and different types of attribute modification operations, and not rendering and/or laying out irrelevant texts. Resources of the display device in the display process after a part of text in the text box is edited are saved, and the response speed of the text box editing operation is improved. When only part of the text in the text box is edited, the problems of time consumption and the like caused by repeated rendering and/or layout due to rendering and/or layout of all the text in the text box are avoided.
Drawings
FIG. 1a is a flowchart of a text rendering and layout method according to a first embodiment of the present invention;
FIG. 1b is a schematic diagram illustrating a transformation of an input operation or a paste operation applied in the first embodiment of the present invention;
FIG. 1c is a schematic diagram of another input operation or paste operation suitable for use in the first embodiment of the present invention;
FIG. 2 is a flowchart of a text rendering and layout method according to a second embodiment of the present invention;
FIG. 3 is a flowchart of a text rendering and layout method according to a third embodiment of the present invention;
FIG. 4 is a flowchart of a text rendering and layout method according to a fourth embodiment of the present invention;
FIG. 5 is a schematic structural diagram of a text rendering and layout apparatus according to a fifth embodiment of the present invention;
fig. 6 is a schematic structural diagram of a computer device in the sixth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
In text processing, the overall framework involves parts such as document management, rendering management, and layout management, each of which has a different function. Specifically, the document management function may be implemented by a document management component, the rendering management function may be implemented by a rendering component, and the layout function may be implemented by a layout component. The document management component, the rendering component and the layout component are all software modules which are developed by developers and have set functions, and can be specifically realized by writing codes with corresponding functions. Specifically, the function of the document management component includes managing paragraphs, managing lines, managing characters, and the like, the function of the rendering component is to render a specified region or render a specified character, and the function of the layout component is to layout a specified text to a specified region.
The text rendering and layout method provided by this embodiment may be executed by a text rendering and layout device, where the text rendering and layout device may be implemented in a software and/or hardware manner, and the text rendering and layout device may be formed by two or more physical entities or may be formed by one physical entity. The text rendering and layout equipment can be a computer, a mobile phone, a tablet, a projector or an interactive intelligent tablet and the like. In an embodiment, an interactive smart tablet is described as an example of a device for text rendering and layout, where the interactive smart tablet may be an integrated device that controls content displayed on a display tablet and implements man-machine interaction operations through a touch technology, and integrates one or more functions of a projector, an electronic whiteboard, a curtain, a sound, a television, a video conference terminal, and the like.
Example one
Fig. 1a is a flowchart of a text rendering and layout method according to an embodiment of the present invention, where this embodiment is applicable to a case where a part of text in a text box is edited, and this method can be executed by a text rendering and layout apparatus according to an embodiment of the present invention, and this apparatus can be implemented in a software and/or hardware manner, and this apparatus can be integrated in a text rendering and layout device. Referring to fig. 1a, the method may specifically include the steps of:
s110, obtaining an operation type of the editing operation received by the text box, wherein the operation type comprises at least one of the following types: input operation, paste operation, delete operation, and modify attribute operation.
Specifically, the text box receives an editing operation input by a user, where an operation type corresponding to the editing operation includes at least one of an input operation, a paste operation, a delete operation, and a modify attribute operation, and optionally, a mode of the editing operation input by the user may be input through a peripheral device or touch input, where the peripheral device may include a keyboard or a mouse. Specifically, the input operation may be to input a text that the user wishes to insert into the text box through the keyboard, and the paste operation may be to copy texts from other sources for insert paste, or to copy texts from other sources to select and replace a text that needs to be replaced in the current text box.
In actual application, the pasting operation may be that the user copies text from other sources and pastes the text to a position where the user wants to insert the text into the text box, and the other sources may be other text boxes or other forms of existing words. The deleting operation is to delete text which the user does not want to appear, and the specific implementation mode can be keyboard deleting or cutting text. The modify attribute operation refers to modifying attributes of the text, and illustratively, the attributes of the text include a word attribute and a paragraph attribute, wherein the word attribute refers to font type, font size, color, bolding, tilting, underlining, superscript, subscript, or artistic word, and the paragraph attribute refers to horizontal alignment, vertical alignment, indentation, bullets, line spacing, or paragraph front and back spacing, and the like. Optionally, the type of editing operation received by the text box may be obtained by the document management component.
S120, determining a target text and an area to be operated, wherein the target text and the area to be operated are determined according to the operation type, an editing object corresponding to the editing operation and a related text of the editing object, the target text is located in the text box, and the area to be operated is located in a text box area formed by the text box.
Specifically, the target text and the region to be operated are determined according to the operation type, the editing object corresponding to the editing operation and the associated text of the editing object. In a specific example, if the editing operation is a deletion operation, the editing object corresponding to the editing operation refers to text content that needs to be deleted, and the associated text of the editing object refers to all texts after the editing object in the text box or texts after the editing object in the paragraph in which the editing object is located in the text box. Illustratively, the target text is located in a text box, the region to be operated is located in a text box region formed by the text box, and the text region formed by the text box refers to a region surrounded by each border of the text box. The target text refers to text needing rendering and/or layout when the editing operation is detected, and the region to be operated refers to a region in a text box to which the target text is laid out. Optionally, the operation of the region to be operated includes rendering and/or layout. Optionally, the determined target text and the region to be operated may be obtained by a document management component.
S130, rendering the target text, and displaying the target text in the to-be-operated area in a layout mode.
The region to be operated may be a region occupied by one character, a region occupied by some characters in one paragraph, or a region occupied by at least one paragraph. Rendering the target text, and laying out the rendered target text in a region to be operated so as to display the target text. Optionally, rendering the target text may be implemented by a rendering component, and displaying the target text in the region to be operated by a layout component.
In the embodiment of the present invention, an operation type of an editing operation received by a text box is obtained, where the operation type includes at least one of: inputting operation, pasting operation, deleting operation and attribute modifying operation; determining a target text and a region to be operated, wherein the target text and the region to be operated are determined according to the operation type, an editing object corresponding to the editing operation and a related text of the editing object, the target text is located in the text box, and the region to be operated is located in a text box region formed by the text box; rendering the target text, and displaying the target text in a layout mode in the area to be operated. When only part of the text in the text box is edited, the problems of time consumption and the like caused by repeated rendering and/or layout due to rendering and/or layout of all the text in the text box are avoided.
Example two
Fig. 2 is a flowchart of a text rendering and layout method according to a second embodiment of the present invention, where in this embodiment, "determining a target text and an area to be operated" is performed on the basis of the second embodiment, where the target text and the area to be operated are optimized according to the operation type, an editing object corresponding to the editing operation, and a text associated with the editing object. Referring to fig. 2, the method may specifically include the following steps:
s210, obtaining an operation type of the editing operation received by the text box, wherein the operation type comprises at least one of the following: input operation, paste operation, delete operation, and modify attribute operation.
And S220, if the operation type is an input operation or a paste operation, determining a first editing object corresponding to the input operation or the paste operation.
Specifically, when the operation type of the editing operation is an input operation or a paste operation, a first editing object corresponding to the input operation or the paste operation is determined. In a specific example, fig. 1b shows a schematic diagram of a transformation of an input operation or a paste operation, and referring to the text box shown in fig. 1b, the layout form of the original text in the text box is: the first line 12324214, the second line 21421442, and the third line 214, the detected input operation is to input character 5 (or to paste copied character 5), and then character 5 is the first editing object. The operation type of the first editing object may be an input operation, that is, a user inputs through a keyboard, or may be a paste operation, in which the user copies from another location of the document or another document and pastes the document into the text box.
And S230, determining the relative target position of the first editing object in the text box.
Optionally, the relative target position of the first editing object in the text box is determined by the document management component, in a specific example, referring to fig. 1b, the target relative position of the character 5 in the text box refers to a distance from the character 5 to the first character (character 1 in the first line) of the paragraph, and illustratively, the distance may be represented by a number of characters, that is, the relative target position of the first editing object character 5 in the text box is 19 characters away from the first character 1 in the first line of the paragraph.
And S240, determining a target text according to the relative target position.
Specifically, the relative target positions are classified according to their difference in the text box, for example, the relative target positions may be the number of characters spaced from the first character of a certain paragraph of text, or the number of characters spaced from the character having some specific mark in a certain paragraph, where the character having a specific mark may be an artistic word, a bold font, or an underlined font, etc. For example, the target text is determined to be different if the relative target position is different, for example, the target text may be text input to the text box by an input operation, or may be text pasted by a paste operation and associated text after the pasted text.
S250, determining an actual target position according to the relative target position, and determining the region to be operated according to the actual target position, wherein the actual target position comprises an actual position of the first editing object in the text box.
Specifically, the actual target position is determined according to the relative target position, where the actual target position includes an actual target position of the first editing object in the text box, and for example, the actual target position refers to coordinates of the corresponding character in the display screen. For example, the actual target position may be determined in such a manner that each character in the paragraph corresponds to an actual target position, and the actual target position is determined by a relationship between the relative target position and the actual target position, for example, if the actual target position of the first character in the paragraph is a, and the relative target position is 19 characters away from the first character in the first line in the paragraph, the actual target position B may be determined, and the region to be operated is determined according to the actual target position B. In a specific example, the region to be operated is a region in a text box corresponding to the actual target position B.
And S260, rendering the target text, and displaying the target text in a layout mode in the area to be operated.
Optionally, determining the target text according to the relative target position includes: and if the relative target position is a segment tail, determining that the first editing object is a target text. And determining whether the relative target position is a paragraph tail, namely, determining that no other text follows the first editing object in the paragraph through the document management component, wherein the first editing object is the target text. Referring to fig. 1b, a character 5 is entered or pasted at the end of the paragraph, followed by no other characters, and in this particular example, the first editing object character 5 is the target text.
On the basis of the above technical solution, a specific example is used to describe a case where the editing object is at the end of a segment. Firstly, when character input is detected, the document management component can search paragraphs to which the characters needing to be input belong, and determine whether the relative target position is at the end of the paragraph. Secondly, the rendering component is started to render the character 5, the position (to-be-operated area) of the character 5 needing to be laid out is determined through the layout component, the character 5 is laid out, and other characters are not moved.
Optionally, determining the target text according to the relative target position includes: and if the relative target position is in a section, determining the first editing object and the associated text of the first editing object as target texts, wherein the associated text of the first editing object comprises the text behind the relative target position.
Wherein, fig. 1c shows a schematic diagram of a transformation of an input operation or a paste operation, referring to the text box shown in fig. 1c, the layout form of the original text in the text box is: the first line 123242142, the second line 142144221, and the third line 4, the detected input operation is to input a character 5 (which may also be to paste the character 5) after the second line 4 th character 1, and the character 5 is the first editing object. Thus, determining that the relative target position is in the segment, the first edited object 5 and the associated text of the first edited object 5 may be determined by the document management component as the target text, optionally, the associated text of the first edited object 5 includes the text after the relative target position, and in fig. 1c, the associated text of the first edited object 5 includes 442214. The determined target text does not include text prior to the relative target position, providing conditions for not repeating the rendering and/or layout.
On the basis of the above technical solution, a specific example is used to describe a case where the editing object is in a segment. Firstly, when character input is detected, the document management component can search the paragraph to which the character to be input belongs, and determine whether the relative target position is in the paragraph. Secondly, a character rendering component is started to render the character 5, a region to be operated is determined through a layout component, and the character 5 and characters behind the character 5 are laid out in the region to be operated. Illustratively, it is also possible to calculate whether there is an augmentation of the number of lines after the input character 5, and if so, to shift the subsequent paragraph as a whole without changing the shift of the individual characters.
In the embodiment of the invention, if the operation type is an input operation or a paste operation, a first editing object corresponding to the input operation or the paste operation is determined; determining a relative target position of the first editing object in the text box; determining a target text according to the relative target position; and determining an actual target position according to the relative target position, and determining the region to be operated according to the actual target position, wherein the actual target position comprises the actual position of the first editing object in the text box. Aiming at the input operation and the pasting operation, the target text needing to be rendered and/or laid out and the area to be operated to which the target text needs to be laid out are determined, so that repeated rendering and/or laying out of other irrelevant texts are avoided, and the response speed to the editing operation is improved.
EXAMPLE III
Fig. 3 is a flowchart of a text rendering and layout method according to a third embodiment of the present invention, and in this embodiment, based on the foregoing embodiment, optimization is performed on "determining a target text and a region to be operated, where the target text and the region to be operated are determined according to the operation type, an editing object corresponding to the editing operation, and a text associated with the editing object. Referring to fig. 3, the method may specifically include the following steps:
s310, obtaining an operation type of the editing operation received by the textbox, wherein the operation type comprises at least one of the following: input operation, paste operation, delete operation, and modify attribute operation.
And S320, if the operation type is the deleting operation, determining a third editing object corresponding to the deleting operation.
Specifically, if the operation type is determined to be the deleting operation, a third editing object corresponding to the deleting operation is determined, where the third editing object is the deleted text. It should be noted that, in the deletion operation, since no new target text is generated, the text following the deleted text is laid out directly without the rendering operation. Rendering is not needed, and the response speed of editing operation is improved.
S330, determining the associated text of the third editing object as a target text, wherein the associated text of the third editing object comprises a text behind the position of the third editing object.
And determining a text after the position of the third editing object as an associated text, and taking the associated text of the third editing object as a target text.
And S340, taking the area behind the position of the third editing object as an area to be operated.
Specifically, the area after the position of the third editing object is determined as the area to be operated. For example, after the third editing object is deleted, the text after the position where the third editing object is located needs to be rearranged, and the rearranged area is the area to be operated.
And S350, rendering the target text, and displaying the target text in a layout mode in the area to be operated.
In the embodiment of the invention, if the operation type is a deletion operation, a third editing object corresponding to the deletion operation is determined; determining the associated text of the third editing object as a target text, wherein the associated text of the third editing object comprises a text behind the position of the third editing object; and taking the area behind the position of the third editing object as an area to be operated. And aiming at the deletion operation, the target text and the region to be operated are determined, and aiming at the text before the deleted text, rendering and/or layout are not performed, so that resources in the process of displaying the text in the edited text box by the display equipment are saved, and the response speed of the editing operation is improved.
Example four
Fig. 4 is a flowchart of a text rendering and layout method according to a fourth embodiment of the present invention, where in this embodiment, "determining a target text and an area to be operated" is performed on the basis of the foregoing embodiment, where the target text and the area to be operated are optimized according to the operation type, an editing object corresponding to the editing operation, and a text associated with the editing object. Referring to fig. 4, the method may specifically include the following steps:
s410, obtaining the operation type of the editing operation received by the text box, wherein the operation type comprises at least one of the following: input operation, paste operation, delete operation, and modify attribute operation.
S420, if the operation type is the operation of attribute modification, determining the modification type of the operation of attribute modification.
And when the operation type is determined to be the operation for modifying the attribute, determining the operation type for modifying the attribute. For example, the modification type corresponding to the word attribute may generally include modifying font color, bolding, tilting, superscript, subscript, artistic word, font type, word size, and the like; the modification types corresponding to the paragraph attributes may generally include horizontal alignment, vertical alignment, indentation, line spacing, paragraph front and back spacing, bullets, and the like.
S430, determining a target text and a region to be operated according to the modification type, the editing object corresponding to the editing operation and the associated text of the editing object.
Specifically, the target text and the region to be operated are determined according to the modification type, the editing object corresponding to the editing operation and the associated text of the editing object.
S440, rendering the target text, and displaying the target text in a layout mode in the area to be operated.
In the embodiment of the invention, if the operation type is attribute modification operation, the modification type of the attribute modification operation is determined; and determining a target text and a region to be operated according to the modification type, the editing object corresponding to the editing operation and the associated text of the editing object. And determining a target text to be rendered and a region to be operated according to the attribute modification operation and different types of attribute modification operations, and not rendering and/or laying out irrelevant texts, so that the response speed to the editing operation is improved.
Optionally, determining a target text and a region to be operated according to the modification type, the editing object corresponding to the editing operation, and the associated text of the editing object, includes:
if the modification type is a first modification type, determining that the editing object and the associated text of the editing object are target texts, and determining that the position of the editing object and the area behind the position of the editing object are to-be-operated areas;
and if the modification type is a second modification type, determining that the editing object is a target text, and determining that the position of the editing object is a region to be operated.
Optionally, for the first modification type, the position of the edited object and the associated text of the edited object are determined by the document management component to be a target text, in a specific example, the target text may be a text and an associated text thereof whose line spacing needs to be adjusted, where the associated text may be a text following the text whose line spacing needs to be adjusted, and then the position of the text whose line spacing needs to be adjusted and an area following the position are determined to be an area to be operated.
In addition, the second modification type includes modifying font color, bolding, tilting, superscript, subscript, artistic word, and the like, and the editing object is determined as the target text for the second modification type. In a specific example, the target text refers to a bolded font, the bolded font is determined as an editing object, and an area where the bolded font is located is an area to be operated.
On the basis of the technical scheme, aiming at operations such as horizontal alignment, vertical alignment, indentation, line spacing, front-section and back-section spacing and the like, only the target text is laid out without rendering; and operations such as changing the bullets need to render and layout the target text.
It should be noted that, in the smart tablet, the default state of the text box is a width adaptive state, and in a specific example, the user clicks a certain set position in the text box to adjust the width adaptive state to a fixed width state. In general, the width-fixed state is a common use state, the width-fixed state is a state in which automatic line feed can be realized, and the width-adaptive text box means that the input text always remains as one line for input and automatic line feed cannot be realized. In the above embodiments, the text boxes are all text boxes with fixed widths, and for the case of adaptive width, the width of the text box may be automatically expanded, if line feed is not performed manually, the segment has only one line, and when inputting or deleting, the processing situation is similar to the case of fixed-width input, which is not described herein again.
On the basis of the technical scheme, the input operation and the pasting operation also comprise an operation of selecting and replacing the specified text, and the method can be specifically realized by preferentially comparing whether the lengths of the text in the selected area and the replacement text are consistent (whether the attributes are consistent or not does not need to be considered), if the lengths are consistent, only rendering the replacement text and laying out the replacement text, and otherwise, not changing the replacement text; if the lengths are not consistent, characters other than the replacement text need to be rearranged in addition to rendering the replacement text.
EXAMPLE five
Fig. 5 is a schematic structural diagram of a text rendering and layout apparatus according to a fifth embodiment of the present invention, which may be integrated into a text rendering and layout device, and is adapted to execute a text rendering and layout method according to the fifth embodiment of the present invention. As shown in fig. 5, the apparatus may specifically include:
an obtaining module 510, configured to obtain an operation type of the editing operation received by the text box, where the operation type includes at least one of: inputting operation, pasting operation, deleting operation and attribute modifying operation;
a determining module 520, configured to determine a target text and a region to be operated, where the target text and the region to be operated are determined according to the operation type, an editing object corresponding to the editing operation, and a text associated with the editing object, the target text is located in the text box, and the region to be operated is located in a text box region formed by the text box;
and a rendering and layout module 530, configured to render the target text and display the target text in the to-be-operated area in a layout manner.
Further, the determining module 520 includes:
the editing object determining sub-module is used for determining a first editing object corresponding to the input operation or the paste operation when the operation type is the input operation or the paste operation;
a relative target position determining module, configured to determine a relative target position of the first editing object in the text box;
the target text determining submodule is used for determining a target text according to the relative target position;
and the to-be-operated area determining submodule is used for determining an actual target position according to the relative target position and determining the to-be-operated area according to the actual target position, wherein the actual target position comprises the actual position of the first editing object in the text box.
Further, the target text determination sub-module is specifically configured to:
and if the relative target position is a segment tail, determining that the first editing object is a target text.
Further, the target text determination sub-module is specifically configured to:
and if the relative target position is in a section, determining the first editing object and the associated text of the first editing object as target texts, wherein the associated text of the first editing object comprises the text behind the relative target position.
Further, the determining module 520 is specifically configured to:
if the operation type is a deleting operation, determining a third editing object corresponding to the deleting operation;
determining the associated text of the third editing object as a target text, wherein the associated text of the third editing object comprises a text behind the position of the third editing object;
and taking the area behind the position of the third editing object as an area to be operated.
Further, the determining module 520 includes:
the modification type determining submodule is used for determining the modification type of the attribute modification operation when the operation type is the attribute modification operation;
and the target text and to-be-operated area determining submodule is used for determining the target text and the to-be-operated area according to the modification type, the editing object corresponding to the editing operation and the associated text of the editing object.
Further, the target text and to-be-operated area determination submodule is specifically configured to:
when the modification type is a first modification type, determining that the editing object and the associated text of the editing object are target texts, and determining that the position of the editing object and the area behind the position of the editing object are areas to be operated;
and when the modification type is a second modification type, determining that the editing object is a target text, and determining that the position of the editing object is a region to be operated.
The text rendering and layout device provided by the embodiment of the invention can execute the text rendering and layout method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
EXAMPLE six
Fig. 6 is a schematic structural diagram of a computer device according to a sixth embodiment of the present invention. FIG. 6 illustrates a block diagram of an exemplary computer device 12 suitable for use in implementing embodiments of the present invention. The computer device 12 shown in FIG. 6 is only an example and should not bring any limitations to the functionality or scope of use of embodiments of the present invention.
As shown in FIG. 6, computer device 12 is in the form of a general purpose computing device. The components of computer device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that couples various system components including the system memory 28 and the processing unit 16.
The system memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)30 and/or cache memory 32. Computer device 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 6, and commonly referred to as a "hard drive"). Although not shown in FIG. 6, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 by one or more data media interfaces. System memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 42 generally carry out the functions and/or methodologies of the described embodiments of the invention.
The processing unit 16 executes various functional applications and data processing by executing programs stored in the system memory 28, for example, implementing a text rendering and layout method provided by an embodiment of the present invention:
that is, the processing unit implements, when executing the program: obtaining an operation type of an editing operation received by a text box, wherein the operation type comprises at least one of the following: inputting operation, pasting operation, deleting operation and attribute modifying operation; determining a target text and a region to be operated, wherein the target text and the region to be operated are determined according to the operation type, an editing object corresponding to the editing operation and a related text of the editing object, the target text is located in the text box, and the region to be operated is located in a text box region formed by the text box; rendering the target text, and displaying the target text in a layout mode in the area to be operated.
EXAMPLE seven
A seventh embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the text rendering and layout method provided in all the embodiments of the invention of the present application:
that is, the program when executed by the processor implements: acquiring an operation type of an editing operation received by a text box, wherein the operation type comprises at least one of the following input operation, pasting operation, deleting operation and attribute modifying operation; determining a target text and a region to be operated, wherein the target text and the region to be operated are determined according to the operation type, an editing object corresponding to the editing operation and a text related to the editing object, the target text is located in the text box, and the region to be operated is located in a text box region formed by the text box; rendering the target text, and displaying the target text in a layout mode in the area to be operated.
Any combination of one or more computer-readable media may be employed. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims (14)
1. A text rendering and layout method, comprising:
obtaining an operation type of an editing operation received by a text box, wherein the operation type comprises at least one of the following: inputting operation, pasting operation, deleting operation and attribute modifying operation;
determining a target text and a region to be operated, wherein the target text and the region to be operated are determined according to the operation type, an editing object corresponding to the editing operation and a text associated with the editing object, the target text is located in the text box, the region to be operated is located in a text box region formed by the text box, the target text refers to a text which needs to be rendered and/or laid out when the editing operation is detected, and the region to be operated refers to a region where the target text is laid out in the text box;
rendering the target text, and displaying the target text in a layout mode in the area to be operated;
wherein, the determining the target text and the region to be operated comprises:
if the operation type is an input operation or a paste operation, determining a first editing object corresponding to the input operation or the paste operation;
determining a relative target position of the first editing object in the text box;
determining a target text according to the relative target position;
and determining an actual target position according to the relative target position, and determining the region to be operated according to the actual target position, wherein the actual target position comprises the actual position of the first editing object in the text box.
2. The method of claim 1, wherein determining the target text from the relative target position comprises:
and if the relative target position is a segment tail, determining that the first editing object is a target text.
3. The method of claim 1, wherein determining target text from the relative target location comprises:
and if the relative target position is in a section, determining the first editing object and the associated text of the first editing object as target texts, wherein the associated text of the first editing object comprises the text behind the relative target position.
4. The method according to claim 1, wherein determining a target text and an area to be operated, wherein the determining of the target text and the area to be operated according to the operation type, an editing object corresponding to the editing operation, and an associated text of the editing object comprises:
if the operation type is a deleting operation, determining a third editing object corresponding to the deleting operation;
determining the associated text of the third editing object as a target text, wherein the associated text of the third editing object comprises a text behind the position of the third editing object;
and taking the area behind the position of the third editing object as an area to be operated.
5. The method according to claim 1, wherein determining a target text and an area to be operated, wherein the determining of the target text and the area to be operated according to the operation type, an editing object corresponding to the editing operation, and an associated text of the editing object comprises:
if the operation type is attribute modification operation, determining the modification type of the attribute modification operation;
and determining a target text and a region to be operated according to the modification type, the editing object corresponding to the editing operation and the associated text of the editing object.
6. The method of claim 5, wherein determining a target text and a region to be operated according to the modification type, an editing object corresponding to the editing operation, and an associated text of the editing object comprises:
if the modification type is a first modification type, determining that the editing object and the associated text of the editing object are target texts, and determining that the position of the editing object and the area behind the position of the editing object are areas to be operated, wherein the first modification type comprises horizontal alignment, vertical alignment, indentation, line spacing, front and back segment spacing, item symbols, font types and word sizes;
and if the modification type is a second modification type, determining that the editing object is a target text, and determining that the position of the editing object is a region to be operated, wherein the second modification type comprises font color modification, thickening, inclination, superscript, subscript and artistic word modification.
7. A text rendering and layout apparatus, comprising:
an obtaining module, configured to obtain an operation type of an editing operation received by a text box, where the operation type includes at least one of: inputting operation, pasting operation, deleting operation and attribute modifying operation;
a determining module, configured to determine a target text and a region to be operated, where the target text and the region to be operated are determined according to the operation type, an editing object corresponding to the editing operation, and a text associated with the editing object, the target text is located in the text box, the region to be operated is located in a text box region formed by the text box, the target text refers to a text that needs to be rendered and/or laid out when the editing operation is detected, and the region to be operated refers to a region where the target text is laid out in the text box;
the rendering and layout module is used for rendering the target text and displaying the target text in the to-be-operated area in a layout mode;
wherein the determining module comprises:
the editing object determining sub-module is used for determining a first editing object corresponding to the input operation or the paste operation when the operation type is the input operation or the paste operation;
a relative target position determining submodule, configured to determine a relative target position of the first editing object in the text box;
the target text determining submodule is used for determining a target text according to the relative target position;
and the to-be-operated area determining submodule is used for determining an actual target position according to the relative target position and determining the to-be-operated area according to the actual target position, wherein the actual target position comprises the actual position of the first editing object in the text box.
8. The apparatus of claim 7, wherein the target text determination sub-module is specifically configured to:
and if the relative target position is a segment tail, determining that the first editing object is a target text.
9. The apparatus of claim 7, wherein the target text determination sub-module is specifically configured to:
and if the relative target position is in a section, determining the first editing object and the associated text of the first editing object as target texts, wherein the associated text of the first editing object comprises the text behind the relative target position.
10. The apparatus of claim 7, wherein the determining module is specifically configured to:
if the operation type is a deleting operation, determining a third editing object corresponding to the deleting operation;
determining the associated text of the third editing object as a target text, wherein the associated text of the third editing object comprises a text behind the position of the third editing object;
and taking the area behind the position of the third editing object as an area to be operated.
11. The apparatus of claim 7, wherein the determining module comprises:
the modification type determining submodule is used for determining the modification type of the attribute modification operation when the operation type is the attribute modification operation;
and the target text and to-be-operated area determining submodule is used for determining the target text and the to-be-operated area according to the modification type, the editing object corresponding to the editing operation and the associated text of the editing object.
12. The apparatus according to claim 11, wherein the target text and to-be-operated region determination submodule is specifically configured to:
when the modification type is a first modification type, determining that the editing object and the associated text of the editing object are target texts, and determining that the position of the editing object and the area behind the position of the editing object are areas to be operated, wherein the first modification type comprises horizontal alignment, vertical alignment, indentation, line spacing, front and back segment spacing, item symbols, font types and word sizes;
and when the modification type is a second modification type, determining that the editing object is a target text, and determining that the position of the editing object is a region to be operated, wherein the second modification type comprises font color modification, bold, inclination, superscript, subscript and artistic word modification.
13. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1-6 when executing the program.
14. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810846808.XA CN109145272B (en) | 2018-07-27 | 2018-07-27 | Text rendering and layout method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810846808.XA CN109145272B (en) | 2018-07-27 | 2018-07-27 | Text rendering and layout method, device, equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109145272A CN109145272A (en) | 2019-01-04 |
CN109145272B true CN109145272B (en) | 2022-09-16 |
Family
ID=64799060
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810846808.XA Active CN109145272B (en) | 2018-07-27 | 2018-07-27 | Text rendering and layout method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109145272B (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110705234B (en) * | 2019-09-05 | 2023-06-30 | 电信科学技术第十研究所有限公司 | Method and device for adaptive typesetting and paging of standard form |
CN112685995A (en) * | 2019-10-18 | 2021-04-20 | 北京国双科技有限公司 | Text underlining processing method and device |
CN110990747A (en) * | 2019-12-17 | 2020-04-10 | 北京思维造物信息科技股份有限公司 | Image generation method, device, equipment and storage medium |
CN111460770B (en) * | 2020-03-30 | 2024-03-08 | 广州视源电子科技股份有限公司 | Method, device, equipment and storage medium for synchronizing element attributes in document |
CN113238686B (en) * | 2021-04-20 | 2023-11-03 | 维沃移动通信(杭州)有限公司 | Document processing method and device and electronic equipment |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101968887A (en) * | 2010-09-08 | 2011-02-09 | 东莞电子科技大学电子信息工程研究院 | Local rendering method for rich media scene |
CN102663002A (en) * | 2012-03-16 | 2012-09-12 | 掌中帷幄(北京)科技有限公司 | Method and system for structured-document rendering |
CN104899227A (en) * | 2014-03-07 | 2015-09-09 | 腾讯科技(深圳)有限公司 | Webpage character rendering method and device |
CN107766117A (en) * | 2017-11-16 | 2018-03-06 | 山东浪潮通软信息科技有限公司 | A kind of method and device of showing interface |
CN108279964A (en) * | 2018-01-19 | 2018-07-13 | 广州视源电子科技股份有限公司 | Text control for character editing and method and device for realizing overlay rendering |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7197702B2 (en) * | 2003-06-13 | 2007-03-27 | Microsoft Corporation | Web page rendering mechanism using external programmatic themes |
-
2018
- 2018-07-27 CN CN201810846808.XA patent/CN109145272B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101968887A (en) * | 2010-09-08 | 2011-02-09 | 东莞电子科技大学电子信息工程研究院 | Local rendering method for rich media scene |
CN102663002A (en) * | 2012-03-16 | 2012-09-12 | 掌中帷幄(北京)科技有限公司 | Method and system for structured-document rendering |
CN104899227A (en) * | 2014-03-07 | 2015-09-09 | 腾讯科技(深圳)有限公司 | Webpage character rendering method and device |
CN107766117A (en) * | 2017-11-16 | 2018-03-06 | 山东浪潮通软信息科技有限公司 | A kind of method and device of showing interface |
CN108279964A (en) * | 2018-01-19 | 2018-07-13 | 广州视源电子科技股份有限公司 | Text control for character editing and method and device for realizing overlay rendering |
Also Published As
Publication number | Publication date |
---|---|
CN109145272A (en) | 2019-01-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109145272B (en) | Text rendering and layout method, device, equipment and storage medium | |
CN109801347B (en) | Method, device, equipment and medium for generating editable image template | |
WO2020119485A1 (en) | Page display method and device, apparatus, and storage medium | |
US9792034B2 (en) | Multi-source, multi-destination data transfers | |
US8850310B2 (en) | Data entry suggestion lists for designated document data entry areas based on data from other document data entry areas | |
US11537278B2 (en) | Interactively presenting a visible portion of a rendering surface on a user device | |
CN109445657A (en) | Document edit method and device | |
CN110032700B (en) | Information release control method and device, storage medium and electronic equipment | |
CN110070593B (en) | Method, device, equipment and medium for displaying picture preview information | |
CN110990014A (en) | Method and device for generating page code of skeleton screen, server and storage medium | |
CN107977155B (en) | Handwriting recognition method, device, equipment and storage medium | |
US20220284377A1 (en) | Method and apparatus for task group positioning | |
CN115079872B (en) | Document processing method, device, equipment and medium | |
WO2023151597A1 (en) | Task processing method and apparatus, electronic device, and computer-readable storage medium | |
CN114003843A (en) | Page generation method, device, equipment and storage medium | |
US10963141B2 (en) | Smart multi-touch layout control for mobile devices | |
CN112860112B (en) | Handwriting erasing method and device of electronic whiteboard, electronic equipment and storage medium | |
CN107656908B (en) | Method and system for implementing placeholder | |
CN111428452B (en) | Annotation data storage method and device | |
CN112507670A (en) | Text editing method and device, electronic equipment and storage medium | |
WO2022228433A1 (en) | Information processing method and apparatus, and electronic device | |
CN115640783A (en) | Method, device, equipment and storage medium for document content display | |
CN115357160A (en) | Document content clicking method, device, electronic equipment, medium and program product | |
US20140365955A1 (en) | Window reshaping by selective edge revisions | |
CN114707470A (en) | Document editing method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |