CN102902678B - Content of text composition method and terminal - Google Patents

Content of text composition method and terminal Download PDF

Info

Publication number
CN102902678B
CN102902678B CN201110210479.8A CN201110210479A CN102902678B CN 102902678 B CN102902678 B CN 102902678B CN 201110210479 A CN201110210479 A CN 201110210479A CN 102902678 B CN102902678 B CN 102902678B
Authority
CN
China
Prior art keywords
character
charcount
width
character string
screen
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
Application number
CN201110210479.8A
Other languages
Chinese (zh)
Other versions
CN102902678A (en
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201110210479.8A priority Critical patent/CN102902678B/en
Publication of CN102902678A publication Critical patent/CN102902678A/en
Application granted granted Critical
Publication of CN102902678B publication Critical patent/CN102902678B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Controls And Circuits For Display Device (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The invention provides two kinds of content of text typesetting schemes, wherein in scheme one, pre-estimate the number of characters that terminal screen lastrow can show at most, and according to estimated result and actual conditions, the actual number of characters that can show of each row is adjusted; In scheme two, for each character in character string to be shown, when determining its width, first determine its type, and adopt different width determination modes according to the difference of type, comprise Graphics Device Interface (GDI) mode and non-GDI mode.No matter adopt which kind of scheme, all can improve typesetting efficiency.

Description

Content of text composition method and terminal
Technical field
The present invention relates to terminal browser technology, particularly content of text composition method and corresponding terminal.
Background technology
Existing terminal, as in mobile phone browser technology, a problem demanding prompt solution is exactly for content of text, how on given screen, to carry out rational typesetting.This problem will directly have influence on the rendering speed of the page, especially very large in word amount, when namely there is Long Binary content.
In prior art, usually adopt following type-setting mode:
1) for character string to be shown, from first character wherein, determine its width respectively, and while determining, add up the overall width of each character thereupon, i.e. accumulative width, when appearance 1st ~ N (N be greater than 1 positive integer) overall width of individual character is less than or equal to screen width, when the overall width of 1st ~ N+1 character is greater than the situation of screen width, is shown on terminal screen using the 1st ~ N number of character as a line;
2) after, from N+1 character, repeat said process, namely the width of each character is determined, and add up overall width, when appearance N+1 ~ N+M character (M be greater than 1 positive integer) overall width be less than or equal to screen width, when the overall width of N+1 ~ N+M+1 character is greater than screen width, N+1 ~ N+M character is shown on terminal screen as a line;
Follow-up the like.
Illustrate: suppose in character string to be shown, to co-exist in 7 characters, be respectively character 1, character 2, character 3, character 4, character 5, character 6 and character 7; The width of each character can be obtained respectively, and suppose that the overall width of character 1, character 2 and character 3 is less than screen width, but the overall width of character 1, character 2, character 3 and character 4 is greater than screen width, so character 1, character 2 and character 3 will show as a line, equally, suppose that the overall width of character 4, character 5 and character 6 is less than screen width, but the overall width of character 4, character 5, character 6 and character 7 is greater than screen width, so character 4, character 5 and character 6 will show as another row; Distinguishingly, for remaining character 7, its width may, much smaller than screen width, directly it can be used as a line to carry out showing.
Although aforesaid way can realize rational typesetting, but also there is certain problem: in prior art, usual employing Graphics Device Interface (GDI, Graphics Device Interface) determine the width of each character, implement slow, especially when character is a lot, thus reduce typesetting efficiency, and then reduce page rendering speed.
Summary of the invention
In view of this, fundamental purpose of the present invention is to provide two kinds of content of text composition methods, can improve typesetting efficiency.
Another object of the present invention is to provide two kinds of terminals, typesetting efficiency can be improved.
For achieving the above object, technical scheme of the present invention is achieved in that
A kind of content of text composition method, comprising:
The number of characters charcount that A, estimation terminal screen lastrow can show at most;
B, Graphics Device Interface GDI is utilized to determine the overall width of front charcount character in character string to be shown, and determine whether described overall width equals screen width, if, then a front charcount character is shown on terminal screen as a line, then using the remaining character string do not shown as character string to be shown, repeated execution of steps B;
Otherwise, the value of charcount is adjusted, obtain charcount ', before occurring, the overall width of the individual character of charcount ' is less than or equal to described screen width, when the overall width of front charcount '+1 character is greater than the situation of described screen width, individual for front charcount ' character is shown on terminal screen as a line, then using the remaining character string do not shown as character string to be shown, repeated execution of steps B;
When the overall width of character string to be shown is less than described screen width, character string to be shown is shown on terminal screen as a line, process ends.
A kind of content of text composition method, comprising:
For each character in character string to be shown, determine type belonging to it respectively, described type comprises: Chinese character type, ASCII(American Standard Code for information interchange) ASCII type and other type; If Chinese character type or ASCII type, then utilize non-graphic equipment interface GDI mode to determine its width, if other type, then utilize GDI to determine its width;
Be shown on terminal screen according to the width of each character determined by described character string branch, the overall width of the character in every a line is all less than or equal to screen width.
A kind of terminal, comprising:
First processing unit, for estimating the number of characters charcount that terminal screen lastrow can show at most;
Second processing unit, for the overall width utilizing Graphics Device Interface GDI to determine charcount character before in character string to be shown, and determine whether described overall width equals screen width, if, then a front charcount character is shown on terminal screen as a line, then using the remaining character string do not shown as character string to be shown, repeat self function; Otherwise, the value of charcount is adjusted, obtain charcount ', before occurring, the overall width of the individual character of charcount ' is less than or equal to described screen width, when the overall width of front charcount '+1 character is greater than the situation of described screen width, individual for front charcount ' character is shown on terminal screen as a line, then using the remaining character string do not shown as character string to be shown, repeat self function; When the overall width of character string to be shown is less than described screen width, character string to be shown is shown on terminal screen as a line, ends process.
A kind of terminal, comprising:
3rd processing unit, for for each character in character string to be shown, determine type belonging to it respectively, described type comprises: Chinese character type, ASCII(American Standard Code for information interchange) ASCII type and other type; If Chinese character type or ASCII type, then utilize non-graphic equipment interface GDI mode to determine its width, if other type, then utilize GDI to determine its width;
Fourth processing unit, for the width according to each character determined, described character string branch is shown to terminal screen, the overall width of the character in every a line is all less than or equal to screen width.
Can find out, the invention provides two kinds of content of text typesetting schemes, for scheme one, because it is without the need to all utilizing for each character GDI to determine its width, but determine together for multiple character, therefore improve typesetting efficiency; For scheme two, equally without the need to all utilizing for each character GDI to determine its width, but only just utilizing GDI to determine its width for the character of particular type, also improving typesetting efficiency.
Accompanying drawing explanation
Fig. 1 is the process flow diagram of content of text composition method first embodiment of the present invention.
Fig. 2 is the process flow diagram of content of text composition method second embodiment of the present invention.
Fig. 3 is the composition structural representation of terminal first embodiment of the present invention.
Fig. 4 is the composition structural representation of terminal second embodiment of the present invention.
Embodiment
For problems of the prior art, two kinds of content of text typesetting schemes are proposed in the present invention, wherein in scheme one, pre-estimate the number of characters that terminal screen lastrow can show at most, and according to estimated result and actual conditions, the actual number of characters that can show of each row is adjusted; In scheme two, for each character in character string to be shown, when determining its width, first determine its type, and adopt different width determination modes according to the difference of type, comprise GDI mode and non-GDI mode.No matter adopt which kind of scheme, all avoid and all utilize GDI to determine its width for each character, thus improve typesetting efficiency.
For make technical scheme of the present invention clearly, understand, to develop simultaneously embodiment referring to accompanying drawing, scheme of the present invention be described in further detail.
Fig. 1 is the process flow diagram of content of text composition method first embodiment of the present invention.As shown in Figure 1, comprise the following steps:
Step 11: estimate the number of characters charcount that terminal screen lastrow can show at most.
In actual applications, available onscreen width is divided by the width of a designated character, if result of calculation is integer, then using result of calculation as described charcount, otherwise, result of calculation is rounded rear as described charcount downwards.
Described designated character can be a certain character in character string to be shown, as first character, or, may not be a certain character in character string to be shown, but the character that is fixing, " state " word of such as " China ".
If result of calculation is not integer, be such as 10.2 or 10.8, so, the overall width in line with a line character of actual displayed can not be greater than the principle of screen width, needs result of calculation to round (10) downwards; Certainly, if result of calculation is integer just, then without the need to rounding downwards.
Step 12: utilize GDI to determine the overall width of front charcount character in character string to be shown, and determine whether described overall width equals screen width, if so, then performs step 13, otherwise, perform step 14.
Suppose that the value of charcount is 10, so conventionally, GDI directly can being utilized to obtain the overall width of these 10 characters, without the need to determining the width of 10 characters respectively, being then added.
Step 13: a front charcount character is shown on terminal screen as a line, then using the remaining character string do not shown as character string to be shown, repeated execution of steps 12.
Step 14: the value of charcount is adjusted, obtain charcount ', before occurring, the overall width of the individual character of charcount ' is less than or equal to screen width, when the overall width of front charcount '+1 character is greater than the situation of screen width, individual for front charcount ' character is shown on terminal screen as a line, then using the remaining character string do not shown as character string to be shown, repeated execution of steps 12.
Wherein, when the overall width of character string to be shown is less than screen width, character string to be shown is shown on terminal screen as a line, process ends.
In actual applications, if the overall width of a front charcount character is greater than screen width, so value of adjustable charcount, obtain charcount ', as made charcount '=charcount-1, if the overall width of the individual character of front charcount ' is still greater than screen width, adjustment can be continued, as made charcount '=charcount '-1; Otherwise, if the overall width of a front charcount character is less than screen width, so can make charcount '=charcount+1, if the overall width of the individual character of front charcount ' is still less than screen width, adjustment can be continued, as made charcount '=charcount '+1; Once the overall width of the individual character of charcount ' is less than or equal to screen width before occurring, the overall width of front charcount '+1 character is greater than the situation of screen width, then can stop adjustment, and individual for front charcount ' character is shown on terminal screen as a line, how to be shown as prior art.
Said process can be exemplified below:
Suppose in character string to be shown, to comprise 32 characters altogether, the value of the charcount estimated is 10, so, first the overall width of 1st ~ 10 characters in character string to be shown is determined, and this overall width and screen width are compared, if both are just equal, so direct 1st ~ 10 characters are shown on terminal screen as the first row, otherwise (supposing to be this situation in this example), the value of charcount is adjusted, suppose to meet the requirements when being adjusted to 12, then 1st ~ 12 characters are shown on terminal screen as the first row, afterwards, for 13rd ~ 32 characters, determine the overall width of front 10 characters wherein, suppose, by comparing and adjusting, 13rd ~ 21 characters to be shown on terminal screen as the second row, in addition after, for 22nd ~ 32 characters, determine the overall width of front 10 characters wherein, suppose, by comparing and adjusting, 22nd ~ 29 characters to be shown on terminal screen as the third line, finally, 3 remaining characters are shown on terminal screen as fourth line, process ends.
Fig. 2 is the process flow diagram of content of text composition method second embodiment of the present invention.As shown in Figure 2, comprise the following steps:
Step 21: for each character in character string to be shown, determine type belonging to it respectively, described type comprises: Chinese character type, ASCII(American Standard Code for information interchange) (ASCII, American Standard Codefor Information Interchange) type and other type; If Chinese character type or ASCII type, then utilize non-GDI mode to determine its width, if other type, then utilize GDI to determine its width.
Step 22: be shown on terminal screen according to the width of each character determined by described character string branch, the overall width of the character in every a line is all less than or equal to screen width.
In actual applications, step 21 and 22 may be executed in parallel, and representation shown in Fig. 2 only in order to express easily.
The present embodiment is compared with existing type-setting mode, and difference is only that the mode determining character duration is different, and other identical part repeats no more.
In the present embodiment, for each character, first determine its type, comprise Chinese character type, ASCII type and other type.As a rule, each character is by multiple, and as 16 bit compositions, front several bit wherein, if front 2 or front 3 bits are for identifying the type of this character, so, can determine its type according to bit several before each character.
For the character of Chinese character type, its width is fixing, and this natural width is its width; For the character of ASCII type, although its width is not fixing, its width is clearly determined, therefore, a form can be pre-set, in this form, preserve each self-corresponding width of different ASCII type characters, by inquiring about this form, the width of required character can be obtained; For the character of other type, can, according to existing mode, utilize GDI to obtain its width.
When there is the character of more Chinese character type or ASCII type in content of text, described in the present embodiment, scheme is particularly applicable.
So far, the introduction about the inventive method embodiment is namely completed.
Based on above-mentioned introduction, Fig. 3 is the composition structural representation of terminal first embodiment of the present invention.As shown in Figure 3, comprising:
First processing unit 31, for estimating the number of characters charcount that terminal screen lastrow can show at most;
Second processing unit 32, for the overall width utilizing GDI to determine charcount character before in character string to be shown, and determine whether described overall width equals screen width, if, then a front charcount character is shown on terminal screen as a line, then using the remaining character string do not shown as character string to be shown, repeat self function; Otherwise, the value of charcount is adjusted, obtain charcount ', before occurring, the overall width of the individual character of charcount ' is less than or equal to screen width, when the overall width of front charcount '+1 character is greater than the situation of screen width, individual for front charcount ' character is shown on terminal screen as a line, then using the remaining character string do not shown as character string to be shown, repeat self function; When the overall width of character string to be shown is less than described screen width, character string to be shown is shown on terminal screen as a line, ends process.
Wherein, the first processing unit 31 with screen width divided by the width of a designated character, if result of calculation is integer, then using result of calculation as described charcount, otherwise, result of calculation is rounded rear as described charcount downwards.
Fig. 4 is the composition structural representation of terminal second embodiment of the present invention.As shown in Figure 4, comprising:
3rd processing unit 41, for for each character in character string to be shown, determine type belonging to it respectively, described type comprises: Chinese character type, ASCII type and other type; If Chinese character type or ASCII type, then utilize non-GDI mode to determine its width, if other type, then utilize GDI to determine its width;
Fourth processing unit 42, for the width according to each character determined, described character string branch is shown to terminal screen, the overall width of the character in every a line is all less than or equal to screen width.
Wherein, if the type of a character is Chinese character type, then the 3rd processing unit 41 using the natural width of the type character as its width; If the type of this character is ASCII type, then the 3rd processing unit 41 determines its width by inquiring about the form pre-set, and preserves each self-corresponding width of different ASCII type characters in described form.
In actual applications, the terminal in the various embodiments described above is generally mobile phone.
The specific works flow process of the embodiment of terminal shown in Fig. 3 and 4 please refer to the respective description in embodiment of the method shown in Fig. 1 and 2, repeats no more herein.
Actual measurement proves, scheme of the present invention can improve typesetting efficiency preferably.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, within the spirit and principles in the present invention all, any amendment made, equivalent replacement, improvement etc., all should be included within the scope of protection of the invention.

Claims (3)

1. a content of text composition method, is characterized in that, comprising:
The number of characters charcount that A, estimation terminal screen lastrow can show at most; Described steps A comprises: with the width of described screen width divided by a designated character, if result of calculation is integer, then using result of calculation as described charcount, otherwise, result of calculation is rounded rear as described charcount downwards; Described designated character is a character in character string to be shown or a fixing character;
B, Graphics Device Interface GDI is utilized to determine the overall width of front charcount character in character string to be shown, and determine whether described overall width equals screen width, if, then a front charcount character is shown on terminal screen as a line, then using the remaining character string do not shown as character string to be shown, repeated execution of steps B;
Otherwise, the value of charcount is adjusted, obtain charcount ', before occurring, the overall width of the individual character of charcount ' is less than or equal to described screen width, when the overall width of front charcount '+1 character is greater than the situation of described screen width, individual for front charcount ' character is shown on terminal screen as a line, then using the remaining character string do not shown as character string to be shown, repeated execution of steps B;
When the overall width of character string to be shown is less than described screen width, character string to be shown is shown on terminal screen as a line, process ends.
2. a terminal, is characterized in that, comprising:
First processing unit, for estimating the number of characters charcount that terminal screen lastrow can show at most; The described first processing unit width of described screen width divided by a designated character, if result of calculation is integer, then using result of calculation as described charcount, otherwise, result of calculation is rounded rear as described charcount downwards; Described designated character is a character in character string to be shown or a fixing character;
Second processing unit, for the overall width utilizing Graphics Device Interface GDI to determine charcount character before in character string to be shown, and determine whether described overall width equals screen width, if, then a front charcount character is shown on terminal screen as a line, then using the remaining character string do not shown as character string to be shown, repeat self function; Otherwise, the value of charcount is adjusted, obtain charcount ', before occurring, the overall width of the individual character of charcount ' is less than or equal to described screen width, when the overall width of front charcount '+1 character is greater than the situation of described screen width, individual for front charcount ' character is shown on terminal screen as a line, then using the remaining character string do not shown as character string to be shown, repeat self function; When the overall width of character string to be shown is less than described screen width, character string to be shown is shown on terminal screen as a line, ends process.
3. terminal according to claim 2, is characterized in that, described terminal is mobile phone.
CN201110210479.8A 2011-07-26 2011-07-26 Content of text composition method and terminal Active CN102902678B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201110210479.8A CN102902678B (en) 2011-07-26 2011-07-26 Content of text composition method and terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201110210479.8A CN102902678B (en) 2011-07-26 2011-07-26 Content of text composition method and terminal

Publications (2)

Publication Number Publication Date
CN102902678A CN102902678A (en) 2013-01-30
CN102902678B true CN102902678B (en) 2015-09-16

Family

ID=47574918

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201110210479.8A Active CN102902678B (en) 2011-07-26 2011-07-26 Content of text composition method and terminal

Country Status (1)

Country Link
CN (1) CN102902678B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103761220B (en) * 2014-01-20 2017-09-05 深圳市英威诺科技有限公司 A kind of text composition technical method of information software
CN104657339B (en) * 2015-02-09 2017-08-11 深圳市联新移动医疗科技有限公司 The method shown in lines in medical system
CN104994312A (en) * 2015-07-15 2015-10-21 北京金山安全软件有限公司 Video generation method and device
CN107122104B (en) * 2017-03-29 2020-10-16 武汉斗鱼网络科技有限公司 Data display method and device
CN108710601B (en) * 2018-05-14 2022-04-01 广州腾讯科技有限公司 Text display method and equipment, storage medium and electronic equipment
CN109743613B (en) * 2018-12-29 2022-01-18 腾讯音乐娱乐科技(深圳)有限公司 Subtitle processing method, device, terminal and storage medium
CN112862453A (en) * 2021-03-02 2021-05-28 岭东核电有限公司 Process information display method, apparatus, computer device and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1427369A (en) * 2001-12-19 2003-07-02 英业达股份有限公司 Typesetting method of character frame
US6668355B1 (en) * 1999-03-30 2003-12-23 Fujitsu Limited Text editing system
CN101937429A (en) * 2010-09-08 2011-01-05 优视科技有限公司 Page composing method and system for mobile terminal
CN102063413A (en) * 2010-12-15 2011-05-18 掌富科技(南京)有限公司 Fast text composition method of mobile terminal

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020133521A1 (en) * 2001-03-15 2002-09-19 Campbell Gregory A. System and method for text delivery
US7318191B2 (en) * 2002-10-10 2008-01-08 Bhk Systems, L.P. Automated system and method for dynamically generating customized typeset question-based documents

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6668355B1 (en) * 1999-03-30 2003-12-23 Fujitsu Limited Text editing system
CN1427369A (en) * 2001-12-19 2003-07-02 英业达股份有限公司 Typesetting method of character frame
CN101937429A (en) * 2010-09-08 2011-01-05 优视科技有限公司 Page composing method and system for mobile terminal
CN102063413A (en) * 2010-12-15 2011-05-18 掌富科技(南京)有限公司 Fast text composition method of mobile terminal

Also Published As

Publication number Publication date
CN102902678A (en) 2013-01-30

Similar Documents

Publication Publication Date Title
CN102902678B (en) Content of text composition method and terminal
CN103336690B (en) HTML (Hypertext Markup Language) 5-based text-element drawing method and device
CN103177709B (en) Method and device for displaying characters
CN104424165A (en) Messy code detection method and system for text documents
CN101526963A (en) Method for identifying web page coding, device and terminal equipment
CN103268185B (en) The text display method of E-book reader and device
US8957912B2 (en) Displaying items in an application window
CN111898049A (en) Table implementation method and device, computer terminal equipment and storage medium
CN105224540A (en) Page composing method and device
KR20150099936A (en) Method and apparatus for applying an alternate font for maintaining document layout
CN112416331A (en) Page adaptation method and device, electronic equipment and computer readable storage medium
CN102147790A (en) Text type-setting method and type-setting engine
CN103186880B (en) Generate the method and apparatus of thumbnail
CN104516868A (en) Layout space streaming restoring method and layout space streaming restoring system
CN103186506A (en) Method and system for adjusting character pair interval
CN104516859B (en) A kind of word modification method and system
CN101655835B (en) Method for text message processing, text message output and character retrieval in electronic document and device thereof
EP2637109A1 (en) Method for improving rendering speed of browser page
CN1862525A (en) Code conversion method
CN101599264B (en) Method and relevant device for displaying characters on mobile terminal
CN111047671B (en) Method for optimizing drawing path of hand-drawn picture and storage medium
CN103136166B (en) Method and device for font determination
CN105183709B (en) A kind of EXCEL preliminary budgets tabular matter method
CN109308146A (en) A kind of character string adaptivenon-uniform sampling display methods and system based on control property
CN105653506A (en) Method and device for processing texts in GPU on basis of character encoding conversion

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant