1. Technical Field
The disclosure generally relates to a system and method for processing text in an electronic device.
2. Description of Related Art
A text control, such as a text label or a text widget of a software application, is used to display a text or texts. In most situations, a text area provided by the text control is usually limited to accommodate text with a certain number of characters due to a limit on the size of the text area. If the text area is not able to accommodate all characters of a text, the conventional manner for use by a text control is to automatically cut out and drop the redundant characters. However, a user may not be conscious of this editing, which is an undesirable situation.
Many aspects of the embodiments can be better understood with references to the following drawings. The components in the drawings are not necessarily drawn to scale, the emphasis instead being placed upon clearly illustrating the principles of the embodiments. Moreover, in the drawings, like reference numerals designate corresponding parts throughout the several views.
The disclosure is illustrated by way of example and not by way of limitation in the figures of the accompanying drawings in which like references indicate similar elements. It should be noted that references to “an” or “one” embodiment in this disclosure are not necessarily to the same embodiment, and such references mean at least one.
In general, the word “module,” as used herein, refers to logic embodied in hardware or firmware, or to a collection of software instructions, written in a programming languages such as Java, C, or Assembly. One or more software instructions in the modules may be embedded in firmware, such as an EPROM. It is noteworthy, that modules may comprise connected logic units, such as gates and flip-flops, and programmable units such as programmable gate arrays or processors. The modules described herein may be implemented as software and/or hardware modules and may be stored in any type of computer-readable medium or other computer storage device.
In one embodiment, the storage device 120 may be a magnetic or an optical storage system, such as a hard disk drive, an optical drive, or a tape drive. The storage device 120 also stores text that is intended to be presented in a text area. The display device 140 is configured with a display screen, such as a liquid crystal display (LCD) or a cathode-ray tube (CRT) display.
In one embodiment, the text processing system 100 includes a location module 101, an obtaining module 102, a first processing module 103, a second processing module 104, and a presenting module 105. Each of the modules 101-105 may be a software program including one or more computerized instructions that are stored in the storage device 120 and can be executed by the processor 130.
The location module 101 may determine a text area with a fixed height and a fixed width on a screen of the display device 140. As an example, a rectangle text area might be defined which has a size of 200*300 pixels.
The obtaining module 102 may obtain an original text having a plurality of characters with a one or more font sizes from a particular source. The source may be a database or a text file stored in the storage device 120.
The first processing module 103 may calculate width of each character of the original text based on the one or more font sizes. According to width of the text area and the width of each character, the first processing module 103 may determine the maximum number of characters that a row of text area can accommodate. The first processing module 103 may split the original text into a plurality of text lines according to the maximum number of characters that a row of the text area can accommodate.
Referring to
The first processing module 103 may determine presentable text lines, total text lines that the text area can accommodate, based on height of the text area and height of each of the plurality of text lines. The first processing module 103 may further determine text contained in the presentable text lines as a presentable text.
When the presentable text is less than the original text, the second processing module 104 may determine the last separating character of the presentable text, and replace one or more characters after the separating character of the presentable text with one or more predetermined characters. A separating character may be a space character or a punctuation character, for example “ . . . ”.
Referring to
The presenting module 105 may present the presentable text, such as the presentable text 310 of
In block S401, the location module 101 determines a text area with a fixed height and a fixed width on a screen of the display device 140.
In block S402, the obtaining module 102 obtains original text having a plurality of characters with one or more font sizes from a particular source.
In block S403, the first processing module 103 determines presentable text of the original text that the text area can accommodate.
In block S404, if the presentable text is less than the original text, the flow goes to block S405, otherwise goes to block S406.
In block S405, the second processing module 104 determines the last separating character of the presentable text, and replaces the one or more characters after the last separating character of the presentable text with one or more predetermined characters.
In block S406, the presenting module 105 presents the presentable text in the text area.
In block S501, the first processing module 103 splits the original text into a plurality of text lines based on width of the text area and the one or more font sizes.
In block S502, the first processing module 103 calculates height of each of the plurality of text lines.
In block S503, the first processing module 103 determines presentable text lines, total text lines that the text area can accommodate, based on height of the text area and height of each of the plurality of text lines.
In block S504, the first processing module 103 determines text contained in the presentable text lines as presentable text.
In block S601, the first processing module 103 calculates width of each character of the original text based on the relevant font size.
In block S602, the first processing module 103 determines the maximum number of characters that a row of the text area can accommodate based on width of the text area and width of each character.
In block S603, the first processing module 103 splits the original text into a plurality of text lines according to the maximum number of characters that a row of the text area can accommodate.
In block S701, the first processing module 103 determines a maximum top height of character by calculating top height of each character of the text line.
In block S702, the first processing module 103 determines a maximum bottom height of character by calculating bottom height of each character of the text line.
In block S703, the first processing module 103 determines a sum of the maximum top height and the maximum bottom height as height of the text line.
It is to be understood, however, that even though numerous characteristics and advantages have been set forth in the foregoing description of embodiments, together with details of the structures and functions of the embodiments, the disclosure is illustrative only and changes may be made in detail, especially in matters of shape, size, and arrangement of parts within the principles of the disclosure to the full extent indicated by the broad general meaning of the terms in which the appended claims are expressed.
Depending on the embodiment, certain steps of methods described may be removed, others may be added, and the sequence of steps may be altered. It is also to be understood that the description and the claims drawn to a method may include some indication in reference to certain steps. However, the indication used is only to be viewed for identification purposes and not as a suggestion as to an order for the steps.
Number | Date | Country | Kind |
---|---|---|---|
99133056 | Sep 2010 | TW | national |