CN112307713A - Automatic text typesetting method and system based on Android system - Google Patents

Automatic text typesetting method and system based on Android system Download PDF

Info

Publication number
CN112307713A
CN112307713A CN202011165501.7A CN202011165501A CN112307713A CN 112307713 A CN112307713 A CN 112307713A CN 202011165501 A CN202011165501 A CN 202011165501A CN 112307713 A CN112307713 A CN 112307713A
Authority
CN
China
Prior art keywords
text
height
display area
display
font
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.)
Withdrawn
Application number
CN202011165501.7A
Other languages
Chinese (zh)
Inventor
邓立
罗文�
唐涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Lango Electronic Science and Technology Co Ltd
Original Assignee
Guangzhou Lango Electronic Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Lango Electronic Science and Technology Co Ltd filed Critical Guangzhou Lango Electronic Science and Technology Co Ltd
Priority to CN202011165501.7A priority Critical patent/CN112307713A/en
Publication of CN112307713A publication Critical patent/CN112307713A/en
Withdrawn legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/109Font handling; Temporal or kinetic typography
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/189Automatic justification

Abstract

The invention relates to the technical field of computer typesetting, and provides an Android system-based automatic text typesetting method and system, which comprises the following operation steps: acquiring a text to be displayed; acquiring the resolution of a display area, and determining the width and height of the display area for displaying the text; measuring the length of single-line display of the text according to the size of the current text font; dividing the length of the single-line display of the text by the width of the display area, and calculating to obtain the display line number of the text in the display area; acquiring the object characteristics of the text font, and calculating the height required by the display of each line of the text according to the object characteristics; calculating the product of the line number and the height required by the display of each line of the text to obtain the required height of the display of the current font text; the invention aims to provide a mode for efficient automatic typesetting of text conversion into pictures with specified resolution sizes.

Description

Automatic text typesetting method and system based on Android system
Technical Field
The invention relates to the technical field of computer typesetting, in particular to an automatic text typesetting method and system based on an Android system.
Background
At present, most of text display in the market application adopts a fixed font size mode for display, and the mode can not meet a plurality of application scenes, such as: converting a piece of text into a picture with a specified resolution size; in the prior art, a text is clearly and regularly drawn in a display area with a specified resolution, a user needs to manually write the text content into the display area, and manually adjust the size of a text font, the line feed of the text and other operations according to the size of the display area, so that the display effect that the text is fully paved and the display area is not exceeded is achieved. However, the manual operation mode has troublesome operation, inconvenient typesetting adjustment and low efficiency.
At this time, in order to solve the problems of inconvenient manual typesetting adjustment and low efficiency of a user, when a text is converted into a picture with a specified resolution for automatic typesetting, font size and line feed need to be automatically adjusted according to the length of characters and the resolution of the picture converted from a target, and the whole picture is fully paved.
Disclosure of Invention
Aiming at the defects of the prior art, the invention provides an automatic text typesetting method and system based on an Android system, and aims to provide a mode for converting a text into a picture with a specified resolution for efficient automatic typesetting.
In order to achieve the purpose, the invention is realized by the following technical scheme:
an Android system based automatic text typesetting method comprises the following operation steps: acquiring a text to be displayed; acquiring the resolution of a display area, and determining the width and height of the display area for displaying the text;
measuring the length of single-line display of the text according to the size of the current text font; dividing the length of the single-line display of the text by the width of the display area, and calculating to obtain the display line number of the text in the display area; acquiring the object characteristics of the text font, and calculating the height required by the display of each line of the text according to the object characteristics; calculating the product of the line number and the height required by the display of each line of the text to obtain the required height of the display of the current font text;
comparing the required height with the height of the display area, if the required height is greater than the height of the display area, subtracting 1 from the font size, and returning to re-measure the length of the single-line display of the text; otherwise, the current font size is adopted for text drawing; wherein the size of the text font is initially set to a maximum value.
An automatic text typesetting system based on an Android system comprises: the sampling module is used for acquiring a text to be displayed and acquiring the resolution information of a display area;
the font module is used for adjusting the size of the text font, measuring the length of single-line display, extracting the object characteristics of the text font and measuring the height required by the single-line display of the text;
and the operation processing module is used for acquiring the acquisition information of the sampling module and the measurement information of the font module, calculating the required height of the current font text display, and comparing and judging the required height with the height of the display area.
Furthermore, after the text to be displayed is obtained, the font size unit of the text is determined to be sp or px, and if the font size unit of the text is px, the font size unit needs to be converted into sp through the unit.
Furthermore, the width and the height of the display area are kept unchanged after the determination, the width of the display area is less than or equal to the maximum width of the display area, and the height of the display area is less than or equal to the maximum height of the display area.
Further, obtaining an externally written width boundary value, the width of the display area being equal to the difference between the maximum width of the display area and the width boundary value;
and acquiring an externally written height boundary value, wherein the height of the display area is equal to the difference between the maximum height of the display area and the height boundary value.
Net plug-in is adopted by the font module.
The invention provides an Android system based automatic text typesetting method and system, and compared with the prior art, the method has the following beneficial effects:
according to the method, under an Android system, the size of a text font is adjusted by using a font module, the length and the height of the text font are measured, the length of the text in a single-line state is obtained, the required display line number of the text to be displayed in a fixed display area is calculated and obtained, the effect of automatic line changing is achieved, then the required height of each line of the text to be displayed is calculated through the object characteristics of the text font, the required height of the current font text to be displayed is obtained, and the required height is compared with the height of the fixed display area until the required height is less than or equal to the height of the display area; obtaining the size of the self-adaptive font so as to draw the text to achieve the display effect that the display area is fully paved and not exceeded; the typesetting method and the typesetting system can be well suitable for different texts, solve the problem that the font size adjustment and line feed of different text contents are difficult, and can efficiently realize the automatic font size adjustment in a fixed display area to achieve the full and no-excess display effect.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flow chart of an automatic typesetting method of the invention;
FIG. 2 is a diagram of an automatic typesetting system of the invention;
FIG. 3 is a schematic diagram of text height determination according to the present invention;
FIG. 4 is a diagram illustrating an automatic typesetting method according to the invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example (b):
referring to fig. 1, the method for automatically typesetting a text based on an Android system includes the following operation steps:
step 1: acquiring a text to be displayed;
step 2: acquiring the resolution of a display area, and determining the width and height of the display area for displaying a text;
and step 3: measuring the length of single-line display of the text according to the size of the current text font;
and 4, step 4: dividing the length of the single-line display of the text by the width of the display area, and calculating to obtain the display line number of the text in the display area;
and 5: acquiring object characteristics of a text font, and calculating the height required by displaying each line of the text according to the object characteristics;
step 6: calculating the product of the line number and the height required by the display of each line of the text to obtain the required height of the display of the current font text;
and 7: comparing the required height with the height of the display area, if the required height is greater than the height of the display area, subtracting 1 from the font size, and returning to the step 3 to re-measure the length of the single-line display of the text; otherwise, the current font size is adopted for text drawing.
Wherein the size of the text font is initially set to a maximum value.
In this embodiment, specifically, when the text to be displayed is acquired, the user may select the text to be displayed by using the external device, and the system may automatically acquire the text in the selected area. The resolution of the display area is large, and when the standard density state is adopted, a user can independently input the pixel values of the width and the height of the display area. After the text to be displayed is obtained, the font size unit of the text is judged to be sp or px, if the font size unit is px, the font size unit needs to be converted into sp through the unit, (the font size unit is px, and the font size unit is converted into sp through multiplying px by the scaling density of the display area).
In this embodiment, preferably, after the width and the height of the display area are determined, the subsequent steps remain unchanged, the width of the display area is less than or equal to the maximum width of the display area, and the height of the display area is less than or equal to the maximum height of the display area. Specifically, after determining the resolution of the display area, a user can set the edge margin of the display area (picture) according to the picture display requirement, the size of the margin and the boundary value can be input and set by the user, the system obtains the externally written width boundary value, and the width of the display area is equal to the difference between the maximum width of the display area and the width boundary value; and acquiring an externally written height boundary value, wherein the height of the display area is equal to the difference between the maximum height of the display area and the height boundary value. The width and height of the area actually used for text display are calculated.
Referring to fig. 3, in step 5, object features of a text font are obtained, and a height required for displaying each line of the text is calculated through the object features; in the embodiment, the object characteristics of the font are obtained by a Paint brush object mpaint.getfontmetrics method, where each of the active, dependent, top, and bottom is an attribute of text content, that is, an attribute of the text content, and the baseline is a baseline, where all texts drawn in an Android system are from baseline, a distance from the baseline up to a text highest position is called the active (upward gradient), and a distance from the baseline to the text lowest position is called the dependent (downward gradient); the height required for displaying each line is the distance between top-bottom as the height of the text of the line.
An automatic text typesetting system based on an Android system, referring to fig. 2, includes: the sampling module is used for acquiring a text to be displayed and acquiring the resolution information of a display area;
the font module is used for adjusting the size of the text font, measuring the length displayed in a single line, extracting the object characteristics of the text font and measuring the height required by the single line display of the text;
and the operation processing module is used for acquiring the acquisition information of the sampling module and the measurement information of the font module, calculating the required height of the current font text display, and comparing and judging the required height with the height of the display area.
The implementation preferably further comprises a display device for displaying the text in the fixed area, for displaying the selected text and displaying the result of the conversion of the final drawing into the picture.
Net plug-in is adopted by the font module in the embodiment, specifically, the maximum font size is set by using paint.
Referring to fig. 4, in the invention, under an Android system, the font size of a text is adjusted by using a font module, and the length and height of the font of the text are measured, the length of the text in a single-line state is obtained first, the required display line number of the text to be displayed in a fixed display area is calculated and obtained, so that an automatic line changing effect is achieved, then the required height of each line of the text to be displayed is calculated according to the object characteristics of the font of the text, the required height of the text to be displayed at the current font is obtained, and the required height is compared with the height of the fixed display area until the required height is less than or equal to the; obtaining the size of the self-adaptive font so as to draw the text to achieve the display effect that the display area is fully paved and not exceeded; the typesetting method and the typesetting system can be well suitable for different texts, solve the problem that the font size adjustment and line feed of different text contents are difficult, and can efficiently realize the automatic adjustment of the font size in the fixed display area.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (6)

1. An Android system based automatic text typesetting method is characterized by comprising the following operation steps:
acquiring a text to be displayed;
acquiring the resolution of a display area, and determining the width and height of the display area for displaying the text;
measuring the length of single-line display of the text according to the size of the current text font;
dividing the length of the single-line display of the text by the width of the display area, and calculating to obtain the display line number of the text in the display area;
acquiring the object characteristics of the text font, and calculating the height required by the display of each line of the text according to the object characteristics;
calculating the product of the line number and the height required by the display of each line of the text to obtain the required height of the display of the current font text;
comparing the required height with the height of the display area, if the required height is greater than the height of the display area, subtracting 1 from the font size, and returning to re-measure the length of the single-line display of the text; otherwise, the current font size is adopted for text drawing;
wherein the size of the text font is initially set to a maximum value.
2. The Android system-based text automatic typesetting method as claimed in claim 1, wherein after the text to be displayed is obtained, the font size unit of the text is determined to be sp or px, and if px, the font size unit is converted to sp.
3. The Android system-based text automatic typesetting method as claimed in claim 1, wherein the width and the height of the display area are kept unchanged after the determination, the width of the display area is less than or equal to the maximum width of the display area, and the height of the display area is less than or equal to the maximum height of the display area.
4. The Android system-based text automatic typesetting method according to claim 4, characterized in that an externally written width boundary value is obtained, and the width of the display area is equal to the difference between the maximum width of the display area and the width boundary value;
and acquiring an externally written height boundary value, wherein the height of the display area is equal to the difference between the maximum height of the display area and the height boundary value.
5. The automatic text typesetting system based on the Android system is characterized by comprising the following steps:
the sampling module is used for acquiring a text to be displayed and acquiring the resolution information of a display area;
the font module is used for adjusting the size of the text font, measuring the length of single-line display, extracting the object characteristics of the text font and measuring the height required by the single-line display of the text;
and the operation processing module is used for acquiring the acquisition information of the sampling module and the measurement information of the font module, calculating the required height of the current font text display, and comparing and judging the required height with the height of the display area.
6. The Android system-based automatic text typesetting system of claim 5, wherein the font module adopts a paint.
CN202011165501.7A 2020-10-27 2020-10-27 Automatic text typesetting method and system based on Android system Withdrawn CN112307713A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011165501.7A CN112307713A (en) 2020-10-27 2020-10-27 Automatic text typesetting method and system based on Android system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011165501.7A CN112307713A (en) 2020-10-27 2020-10-27 Automatic text typesetting method and system based on Android system

Publications (1)

Publication Number Publication Date
CN112307713A true CN112307713A (en) 2021-02-02

Family

ID=74331092

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011165501.7A Withdrawn CN112307713A (en) 2020-10-27 2020-10-27 Automatic text typesetting method and system based on Android system

Country Status (1)

Country Link
CN (1) CN112307713A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023016117A1 (en) * 2021-08-13 2023-02-16 北京字节跳动网络技术有限公司 Content typesetting method and apparatus, computer device, and storage medium
CN116680034A (en) * 2023-08-02 2023-09-01 山东依鲁光电科技有限公司 LED asynchronous display screen self-adaptive mass-sending realization method

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101876967A (en) * 2010-03-25 2010-11-03 深圳市万兴软件有限公司 Method for generating PDF text paragraphs
CN102436439A (en) * 2010-09-29 2012-05-02 鸿富锦精密工业(深圳)有限公司 Text box and text display method
CN103345493A (en) * 2013-06-27 2013-10-09 广州市动景计算机科技有限公司 Method, device and system for text content displaying on mobile terminal
CN104915332A (en) * 2015-06-15 2015-09-16 广东欧珀移动通信有限公司 Method and device for generating composing template
CN105260352A (en) * 2015-09-20 2016-01-20 杭州电子科技大学 Automatic typesetting method for streaming text
CN106095374A (en) * 2016-06-23 2016-11-09 Tcl集团股份有限公司 The method and system that a kind of word size adaptation various countries language shows
CN109740141A (en) * 2019-01-10 2019-05-10 成都品果科技有限公司 A method of typesetting beautification is carried out to text based on canvas
CN110705234A (en) * 2019-09-05 2020-01-17 电信科学技术第十研究所有限公司 Self-adaptive typesetting and paging method and device for system form
CN110929471A (en) * 2018-09-18 2020-03-27 深圳市鸿合创新信息技术有限责任公司 Method and terminal for displaying rich text and electronic equipment
CN111310082A (en) * 2018-12-11 2020-06-19 杭州海康威视系统技术有限公司 Page display method and device

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101876967A (en) * 2010-03-25 2010-11-03 深圳市万兴软件有限公司 Method for generating PDF text paragraphs
CN102436439A (en) * 2010-09-29 2012-05-02 鸿富锦精密工业(深圳)有限公司 Text box and text display method
CN103345493A (en) * 2013-06-27 2013-10-09 广州市动景计算机科技有限公司 Method, device and system for text content displaying on mobile terminal
CN104915332A (en) * 2015-06-15 2015-09-16 广东欧珀移动通信有限公司 Method and device for generating composing template
CN105260352A (en) * 2015-09-20 2016-01-20 杭州电子科技大学 Automatic typesetting method for streaming text
CN106095374A (en) * 2016-06-23 2016-11-09 Tcl集团股份有限公司 The method and system that a kind of word size adaptation various countries language shows
CN110929471A (en) * 2018-09-18 2020-03-27 深圳市鸿合创新信息技术有限责任公司 Method and terminal for displaying rich text and electronic equipment
CN111310082A (en) * 2018-12-11 2020-06-19 杭州海康威视系统技术有限公司 Page display method and device
CN109740141A (en) * 2019-01-10 2019-05-10 成都品果科技有限公司 A method of typesetting beautification is carried out to text based on canvas
CN110705234A (en) * 2019-09-05 2020-01-17 电信科学技术第十研究所有限公司 Self-adaptive typesetting and paging method and device for system form

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023016117A1 (en) * 2021-08-13 2023-02-16 北京字节跳动网络技术有限公司 Content typesetting method and apparatus, computer device, and storage medium
CN116680034A (en) * 2023-08-02 2023-09-01 山东依鲁光电科技有限公司 LED asynchronous display screen self-adaptive mass-sending realization method
CN116680034B (en) * 2023-08-02 2023-10-27 山东依鲁光电科技有限公司 LED asynchronous display screen self-adaptive mass-sending realization method

Similar Documents

Publication Publication Date Title
CN112307713A (en) Automatic text typesetting method and system based on Android system
US7466875B1 (en) Method and system for determining the legibility of text in an image
EP2343670A2 (en) Apparatus and method for digitizing documents
US20020076111A1 (en) Method and apparatus for formatting OCR text
CN110008450B (en) Picture generation method, device, equipment and medium
US11587343B2 (en) Method and system for converting font of Chinese character in image, computer device and medium
CN106845545B (en) Image recognition method and device in automatic digital electric meter calibration device
CN101986247A (en) Electronic reader and text display method thereof
WO2015078159A1 (en) Webpage display method and device
CN109598185B (en) Image recognition translation method, device and equipment and readable storage medium
US20180218523A1 (en) Snapping Line Generation
CN106910195B (en) Webpage layout monitoring method and device
JP2010108389A (en) Image display device and program
CN110738598A (en) Image adaptation method, electronic device and storage medium
CN110688889B (en) Image-text content comparison method and device
US9204011B1 (en) Apparatus and method for extracting a background luminance map of an image, de-shading apparatus and method
WO2016188104A1 (en) Information processing method and information processing device
US11929049B2 (en) Output content generation apparatus, output content generation method and program
CN110674811B (en) Image recognition method and device
CN111310082B (en) Page display method and device
CN112068834A (en) JS-based data rendering method and device
US11915480B2 (en) Image processing apparatus and image processing method
CN110545427A (en) PDF document compression method and device and electronic equipment
US10580175B2 (en) Apparatus, method and system for resolution dependent graphical representation of signals
CN108346126B (en) Method and device for drawing mobile phone picture based on memory copy mode

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
WW01 Invention patent application withdrawn after publication

Application publication date: 20210202

WW01 Invention patent application withdrawn after publication