Search

CN-121997889-A - Text typesetting method, device, equipment, storage medium and program product

CN121997889ACN 121997889 ACN121997889 ACN 121997889ACN-121997889-A

Abstract

The embodiment of the application provides a text typesetting method, a text typesetting device, text typesetting equipment, a storage medium and a program product. The method comprises the steps of determining typesetting parameters of each display line in a display area according to equipment parameters of the display area, determining an optimal typesetting strategy of each word to be displayed in a target text according to the typesetting parameters of each display line based on a greedy algorithm, and typesetting the words to be displayed according to the optimal typesetting strategy of the words to be displayed to generate typesetting results. The method can realize the efficient utilization of screen space, the improvement of visual aesthetic feeling and the guarantee of reading fluency.

Inventors

  • CHEN SHUAI

Assignees

  • 北京侠客汇信息技术有限责任公司

Dates

Publication Date
20260508
Application Date
20251224

Claims (11)

  1. 1.A text typesetting method, comprising: Determining typesetting parameters of each display row in a display area according to equipment parameters of the display area; based on a greedy algorithm, determining an optimal typesetting strategy of each word to be displayed in the target text according to typesetting parameters of each display line; and performing typesetting processing on the words to be displayed according to the optimal typesetting strategy of the words to be displayed, and generating typesetting results.
  2. 2. The method according to claim 1, wherein determining layout parameters for each display line in the display area according to device parameters of the display area comprises: And determining typesetting parameters of each display row in the display area according to the equipment parameters and the user setting parameters of the display area.
  3. 3. The method according to claim 2, wherein determining the layout parameters of each display line in the display area according to the device parameters and the user setting parameters of the display area comprises: And determining typesetting parameters of the display lines according to the screen size and resolution in the equipment parameters and the font size and character spacing in the user setting parameters.
  4. 4. The method according to claim 1, wherein the typesetting processing is performed on the word to be displayed according to the optimal typesetting strategy of the word to be displayed, and generating the typesetting result includes: If the optimal typesetting strategy of the word to be displayed is determined to be a partial linefeed strategy, carrying out character splitting on the word to be displayed; arranging the split first word units at the tail of a current display line, and arranging the split second word units at the starting position of a next display line of the current display line; And merging the split first word units and the split second word units to obtain the typesetting result.
  5. 5. The method of claim 4, wherein said character splitting of said word to be displayed comprises: determining a splitting rule of the word to be displayed according to the language type of the word to be displayed; And according to the splitting rule, carrying out character splitting on the word to be displayed.
  6. 6. The method according to claim 1, wherein the determining an optimal typesetting strategy for each word to be displayed in the target text based on the greedy algorithm according to the typesetting parameters of each display line comprises: And determining the optimal typesetting strategy of the word to be displayed as a line feed strategy if the character width of the word to be displayed is larger than the residual space in the current typesetting parameters based on the greedy algorithm, wherein the line feed strategy is a partial line feed strategy or a complete line feed strategy.
  7. 7. A method according to any one of claims 1 to 6, wherein the typesetting parameters include remaining space of display lines, font size, word spacing and word character width.
  8. 8. A text typesetting apparatus, comprising: The first determining module is used for determining typesetting parameters of each display row in the display area according to the equipment parameters of the display area; The second determining module is used for determining an optimal typesetting strategy of each word to be displayed in the target text according to the typesetting parameters of each display line based on a greedy algorithm; And the typesetting module is used for typesetting the word to be displayed according to the optimal typesetting strategy of the word to be displayed, and generating typesetting results.
  9. 9. An electronic device is characterized by comprising a memory and a processor; The memory stores computer-executable instructions; The processor executing computer-executable instructions stored in the memory, causing the processor to perform the method of any one of claims 1-7.
  10. 10. A computer readable storage medium having stored therein computer executable instructions which when executed by a processor are adapted to carry out the method of any one of claims 1-7.
  11. 11. A computer program product comprising a computer program which, when executed by a processor, implements the method of any of claims 1-7.

Description

Text typesetting method, device, equipment, storage medium and program product Technical Field The present application relates to the field of electronic reading technologies, and in particular, to a text typesetting method, apparatus, device, storage medium, and program product. Background With the popularity of mobile internet and electronic reading devices, users have increasingly demanded to read contents such as electronic books, electronic documents, news information, and the like. In commute, office, leisure, etc. scenarios, users frequently use electronic readers for text reading. In the prior art, for a long word to be displayed, it is directly moved to the next line in its entirety. However, in the above manner, a large number of blank areas are generated at the end of the current line by directly changing the line, so that the text typesetting layout is loose, and the screen space utilization rate is low. Disclosure of Invention The embodiment of the application provides a text typesetting method, a device, equipment, a storage medium and a program product, which can dynamically optimize the typesetting effect of long words, and realize the efficient utilization of screen space, the improvement of visual aesthetic feeling and the guarantee of reading fluency. In a first aspect, an embodiment of the present application provides a text typesetting method, including: Determining typesetting parameters of each display row in a display area according to equipment parameters of the display area; based on a greedy algorithm, determining an optimal typesetting strategy of each word to be displayed in the target text according to typesetting parameters of each display line; and performing typesetting processing on the words to be displayed according to the optimal typesetting strategy of the words to be displayed, and generating typesetting results. In a possible implementation manner, the determining the typesetting parameter of each display row in the display area according to the device parameters of the display area includes: And determining typesetting parameters of each display row in the display area according to the equipment parameters and the user setting parameters of the display area. In a possible implementation manner, the determining the typesetting parameter of each display row in the display area according to the device parameter and the user setting parameter of the display area includes: And determining typesetting parameters of the display lines according to the screen size and resolution in the equipment parameters and the font size and character spacing in the user setting parameters. In one possible implementation manner, the typesetting processing is performed on the word to be displayed according to the optimal typesetting policy of the word to be displayed, so as to generate a typesetting result, which includes: If the optimal typesetting strategy of the word to be displayed is determined to be a partial linefeed strategy, carrying out character splitting on the word to be displayed; arranging the split first word units at the tail of a current display line, and arranging the split second word units at the starting position of a next display line of the current display line; And merging the split first word units and the split second word units to obtain the typesetting result. In a possible implementation manner, the character splitting of the word to be displayed includes: determining a splitting rule of the word to be displayed according to the language type of the word to be displayed; And according to the splitting rule, carrying out character splitting on the word to be displayed. In a possible implementation manner, the determining, based on the greedy algorithm, an optimal typesetting strategy for each word to be displayed in the target text according to the typesetting parameters of each display line includes: And determining the optimal typesetting strategy of the word to be displayed as a line feed strategy if the character width of the word to be displayed is larger than the residual space in the current typesetting parameters based on the greedy algorithm, wherein the line feed strategy is a partial line feed strategy or a complete line feed strategy. In one possible implementation, the typesetting parameters include a remaining space of display lines, font size, word spacing, and word character width. In a second aspect, an embodiment of the present application provides a text typesetting apparatus, including: The first determining module is used for determining typesetting parameters of each display row in the display area according to the equipment parameters of the display area; The second determining module is used for determining an optimal typesetting strategy of each word to be displayed in the target text according to the typesetting parameters of each display line based on a greedy algorithm; And the typesetting module is used for typesetting the word to be