Content typesetting method and device, computer equipment and storage medium

文档序号:169320 发布日期:2021-10-29 浏览:15次 中文

阅读说明:本技术 一种内容排版方法、装置、计算机设备及存储介质 (Content typesetting method and device, computer equipment and storage medium ) 是由 陶艺月 鲁聃 于 2021-08-13 设计创作,主要内容包括:本公开提供了一种内容排版方法、装置、计算机设备及存储介质,所述方法包括:获取待排版内容中的各文本元素和各所述文本元素的元素类型;基于各所述文本元素的元素类型、以及预设的活字模板指示的各元素类型之间的渲染尺寸关系,确定各所述文本元素的渲染尺寸信息;基于各所述文本元素的渲染尺寸信息和排版样式设置信息,对所述待排版内容进行排版。本公开采用预设的活字模板和排版样式设置信息进行排版时,可以根据元素类型,确定各文本元素的渲染尺寸,避免了每次进行排版时,需要分别对每个文本元素的渲染尺寸进行测量的过程,从而提高了渲染尺寸的计算效率,进而提高了排版效率。(The present disclosure provides a content typesetting method, apparatus, computer device and storage medium, the method comprising: acquiring each text element in the content to be typeset and the element type of each text element; determining rendering size information of each text element based on the element type of each text element and the rendering size relationship between each element type indicated by a preset type template; and typesetting the content to be typeset based on the rendering size information and the typesetting style setting information of each text element. When the typesetting is carried out by adopting the preset type template and the typesetting style setting information, the rendering size of each text element can be determined according to the element type, and the process that the rendering size of each text element needs to be measured when the typesetting is carried out at every time is avoided, so that the computing efficiency of the rendering size is improved, and the typesetting efficiency is further improved.)

1. A content layout method, comprising:

acquiring each text element in the content to be typeset and the element type of each text element;

determining rendering size information of each text element based on the element type of each text element and the rendering size relationship between each element type indicated by a preset type template;

and typesetting the content to be typeset based on the rendering size information and the typesetting style setting information of each text element.

2. The method of claim 1, wherein obtaining each text element and an element type of each text element in the content to be typeset comprises:

determining a plurality of content units from the content to be typeset based on the content unit indication fields in the content to be typeset; the plurality of content units comprises at least one title unit and at least one paragraph unit;

for each content unit, determining each text element in the content unit and the element type of each text element when the content form of the content unit is text.

3. The method according to claim 2, wherein determining rendering size information of each text element based on the element type of each text element and a rendering size relationship between each element type indicated by a preset type template comprises:

for each content unit, determining rendering size information of each text element in the content unit based on rendering size information corresponding to a preset element type in the content unit indicated in the layout style setting information, an element type of each text element in the content unit, and a rendering size relationship between each element type indicated by a preset type template;

the layout style setting information comprises rendering size information corresponding to a preset element type in a title unit and rendering size information corresponding to a preset element type in a paragraph unit.

4. The method according to claim 3, wherein the typesetting of the content to be typeset based on the rendering size information and the typesetting style setting information of each text element comprises:

for each content unit, determining the horizontal occupation size of each text element in the content unit based on the determined rendering size information of each text element in the content unit, and determining the vertical occupation size of each text element in the content unit based on the line height indicated in the typesetting style setting information;

determining each text element arranged in each line by the content unit based on the transverse occupation size of each text element and the transverse occupation size of the whole line in the typesetting page;

and typesetting the content units on at least one typesetting page according to the determined text elements arranged in each line of the content units, the vertical occupation sizes of the text elements, and the typesetting type, paragraph spacing and line spacing indicated in the typesetting style setting information.

5. The method of claim 2, further comprising:

under the condition that the content form of the content unit is non-text, acquiring original size information of the non-text content unit, wherein the original size information comprises height information and width information;

taking the height information as a vertical occupation size of the non-text content unit, and configuring a horizontal occupation size of the non-text content unit into a horizontal occupation size of a whole line;

and typesetting the non-text content units based on the typesetting type and paragraph spacing indicated in the typesetting style setting information, the vertical placeholder and the horizontal placeholder.

6. The method of claim 1, further comprising:

for any text element, if the element type of the text element does not exist in the preset type template, the rendering size information of the element type with the largest rendering size corresponding to the element type in the preset type template is used as the rendering size information of the text element.

7. The method of claim 1, further comprising:

for any text element, if the element type of the text element does not exist in the preset type template, determining the size relationship between the text element and other text elements under the element type in the preset type template based on the acquired original size information of each text element to be typeset;

and updating the rendering size relation between the special element type corresponding to any text element in the preset type template and other element types based on the size relation.

8. The method of claim 1, wherein before determining rendering size information of each text element based on an element type of each text element and a rendering size relationship between element types indicated by a preset type template, further comprising:

displaying the preset type template in an editable state;

acquiring an updated type template obtained after the preset type template is supplemented; the updated type template comprises rendering size relations between special element types which do not exist in the preset type template and other element types;

determining rendering size information of each text element based on the element type of each text element and the rendering size relationship between each element type indicated by a preset type template, including:

and determining rendering size information of each text element to be typeset based on the element type of each text element to be typeset and the updated rendering size relationship between each element type indicated by the type template.

9. A content composing apparatus, comprising:

the first obtaining module is used for obtaining each text element in the content to be typeset and the element type of each text element;

the first determining module is used for determining rendering size information of each text element based on the element type of each text element and the rendering size relation between the element types indicated by a preset type template;

and the first typesetting module is used for typesetting the contents to be typeset based on the rendering size information and the typesetting style setting information of each text element.

10. A computer device, comprising: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating via the bus when a computer device is running, the machine-readable instructions when executed by the processor performing the steps of the content composing method according to any one of claims 1 to 8.

11. A computer-readable storage medium, having stored thereon a computer program for performing, when executed by a processor, the steps of the content layout method according to any one of claims 1 to 8.

Technical Field

The present disclosure relates to the field of information technology, and in particular, to a content composition method, apparatus, computer device, and storage medium.

Background

With the development of internet technology, reading habits of people are gradually changed, and more users like reading contents such as books and news information on terminal equipment.

The typesetting speed of the reading content is directly related to the reading experience of the user. The current typesetting mode is mainly to measure the size of each character after reading content to be typeset is obtained each time, and then typeset according to the size of each character. When reading a lot of contents, the typesetting efficiency of the typesetting mode is low, and the waiting time of the user is easy to be too long.

Disclosure of Invention

The embodiment of the disclosure at least provides a content typesetting method and device, computer equipment and a storage medium.

In a first aspect, an embodiment of the present disclosure provides a content typesetting method, including:

acquiring each text element in the content to be typeset and the element type of each text element;

determining rendering size information of each text element based on the element type of each text element and the rendering size relationship between each element type indicated by a preset type template;

and typesetting the content to be typeset based on the rendering size information and the typesetting style setting information of each text element.

In an optional implementation manner, obtaining each text element in the content to be typeset and an element type of each text element includes:

determining a plurality of content units from the content to be typeset based on the content unit indication fields in the content to be typeset; the plurality of content units comprises at least one title unit and at least one paragraph unit;

for each content unit, determining each text element in the content unit and the element type of each text element when the content form of the content unit is text.

In an optional embodiment, determining rendering size information of each text element based on the element type of each text element and a rendering size relationship between the element types indicated by a preset type template includes:

for each content unit, determining rendering size information of each text element in the content unit based on rendering size information corresponding to a preset element type in the content unit indicated in the layout style setting information, an element type of each text element in the content unit, and a rendering size relationship between each element type indicated by a preset type template;

the layout style setting information comprises rendering size information corresponding to a preset element type in a title unit and rendering size information corresponding to a preset element type in a paragraph unit.

In an optional embodiment, the typesetting the content to be typeset based on the rendering size information and the typesetting style setting information of each text element includes:

for each content unit, determining the horizontal occupation size of each text element in the content unit based on the determined rendering size information of each text element in the content unit, and determining the vertical occupation size of each text element in the content unit based on the line height indicated in the typesetting style setting information;

determining each text element arranged in each line by the content unit based on the transverse occupation size of each text element and the transverse occupation size of the whole line in the typesetting page;

and typesetting the content units on at least one typesetting page according to the determined text elements arranged in each line of the content units, the vertical occupation sizes of the text elements, and the typesetting type, paragraph spacing and line spacing indicated in the typesetting style setting information.

In an optional embodiment, the method further comprises:

under the condition that the content form of the content unit is non-text, acquiring original size information of the non-text content unit, wherein the original size information comprises height information and width information;

taking the height information as a vertical occupation size of the non-text content unit, and configuring a horizontal occupation size of the non-text content unit into a horizontal occupation size of a whole line;

and typesetting the non-text content units based on the typesetting type and paragraph spacing indicated in the typesetting style setting information, the vertical placeholder and the horizontal placeholder.

In an optional embodiment, the method further comprises:

for any text element, if the element type of the text element does not exist in the preset type template, the rendering size information of the element type with the largest rendering size corresponding to the element type in the preset type template is used as the rendering size information of the text element.

In an optional embodiment, the method further comprises:

for any text element, if the element type of the text element does not exist in the preset type template, determining the size relationship between the text element and other text elements under the element type in the preset type template based on the acquired original size information of each text element to be typeset;

and updating the rendering size relation between the special element type corresponding to any text element in the preset type template and other element types based on the size relation.

In an optional implementation manner, before determining rendering size information of each text element based on an element type of each text element and a rendering size relationship between element types indicated by a preset type template, the method further includes:

displaying the preset type template in an editable state;

acquiring an updated type template obtained after the preset type template is supplemented; the updated type template comprises rendering size relations between special element types which do not exist in the preset type template and other element types;

determining rendering size information of each text element based on the element type of each text element and the rendering size relationship between each element type indicated by a preset type template, including:

and determining rendering size information of each text element to be typeset based on the element type of each text element to be typeset and the updated rendering size relationship between each element type indicated by the type template.

In a second aspect, an embodiment of the present disclosure further provides a content typesetting apparatus, including:

the first obtaining module is used for obtaining each text element in the content to be typeset and the element type of each text element;

the first determining module is used for determining rendering size information of each text element based on the element type of each text element and the rendering size relation between the element types indicated by a preset type template;

and the first typesetting module is used for typesetting the contents to be typeset based on the rendering size information and the typesetting style setting information of each text element.

In a third aspect, an embodiment of the present disclosure further provides a computer device, including: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating via the bus when the computer device is running, the machine-readable instructions when executed by the processor performing the steps of the first aspect described above, or any possible implementation of the first aspect.

In a fourth aspect, this disclosed embodiment also provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps in the first aspect or any one of the possible implementation manners of the first aspect.

According to the content typesetting method, the content typesetting device, the computer equipment and the storage medium provided by the embodiment of the disclosure, the preset type template stores the rendering size relationship of the element type of each text element, when typesetting is performed by adopting the preset type template and the typesetting style setting information, the rendering size information of each text element can be determined according to the element type of the text element, and the process that the rendering size of each text element to be typeset needs to be measured when typesetting is performed each time is avoided, so that the rendering size calculation efficiency is improved, and the typesetting efficiency is further improved.

The content typesetting method provided by the embodiment of the disclosure can also complement and update the rendering size relationship between element types in the preset type template before determining the rendering size information of each text element to be typeset, and can improve the calculation efficiency of rendering sizes in the typesetting process, thereby improving the typesetting efficiency.

In order to make the aforementioned objects, features and advantages of the present disclosure more comprehensible, preferred embodiments accompanied with figures are described in detail below.

Drawings

In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the embodiments will be briefly described below, and the drawings herein incorporated in and forming a part of the specification illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the technical solutions of the present disclosure. It is appreciated that the following drawings depict only certain embodiments of the disclosure and are therefore not to be considered limiting of its scope, for those skilled in the art will be able to derive additional related drawings therefrom without the benefit of the inventive faculty.

Fig. 1 is a flowchart illustrating a content typesetting method provided by an embodiment of the disclosure;

FIG. 2 is a flow chart illustrating another content layout method provided by the embodiment of the disclosure;

FIG. 3 is a diagram illustrating a content typesetting apparatus according to an embodiment of the disclosure;

fig. 4 shows a schematic diagram of a computer device provided by an embodiment of the present disclosure.

Detailed Description

In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions of the embodiments of the present disclosure will be described clearly and completely with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are only a part of the embodiments of the present disclosure, not all of the embodiments. The components of the embodiments of the present disclosure, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present disclosure, presented in the figures, is not intended to limit the scope of the claimed disclosure, but is merely representative of selected embodiments of the disclosure. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the disclosure without making creative efforts, shall fall within the protection scope of the disclosure.

The current typesetting mode is mainly to measure the size of each character after reading content to be typeset is obtained each time, and then typeset according to the size of each character. When reading a lot of contents, the typesetting efficiency of the typesetting mode is low, and the waiting time of the user is easy to be too long.

Based on the above, the present disclosure provides a content typesetting method, apparatus, computer device and storage medium, which obtain each text element and the element type of each text element in the content to be typeset; determining rendering size information of each text element based on the element type of each text content element and the rendering size relationship between each element type indicated by a preset type template; and typesetting the content to be typeset based on the rendering size information and the typesetting style setting information of each text element. When the typesetting is carried out by adopting the preset type template and the typesetting style setting information, the rendering size information of each text element can be determined according to the element type, and the process that the rendering size of each content element to be typeset needs to be measured when the typesetting is carried out at every time is avoided, so that the computing efficiency of the rendering size is improved, and the typesetting efficiency is further improved.

It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.

To facilitate understanding of the embodiment, a content layout method disclosed in the embodiment of the present disclosure is first described in detail, where the content layout method provided in the embodiment of the present disclosure is implemented by front-end codes loaded by a client, and specifically, the client may provide a web view (webview) container and load the front-end codes, and the front-end codes execute the content layout method provided in the embodiment of the present disclosure when running.

The content typesetting method provided by the embodiment of the disclosure is suitable for a scene of typesetting the reading content when the reading interface is opened by the equipment terminal.

The content typesetting method provided by the embodiment of the disclosure is described below by taking the execution subject as the terminal device as an example.

Referring to fig. 1, a flowchart of a content typesetting method provided in the embodiment of the present disclosure is shown, where the method includes S101 to S103:

s101: and acquiring each text element in the content to be typeset and the element type of each text element.

Here, the content to be laid out is content for laying out on a reading interface of the client. When the reading interface is opened, the content to be typeset can be obtained from the server; the content to be laid out may include both text-form content and non-text-form content (e.g., pictures, videos, etc.). In this step, the content in text form is mainly obtained, and then each text element in the content in text form is determined.

The text element refers to the smallest content in the text form, such as a word. Text elements may include word elements, number elements, and symbol elements. The character elements may be character elements of any language type, such as chinese character elements, english letter elements, greek letter elements, and the like, wherein the letter elements may include upper case letter elements and lower case letter elements. The number elements may include any number elements such as arabic number elements, roman number elements, and the like. The symbol elements may include punctuation elements, mathematical symbol elements, unit symbol elements, arrow symbol elements, and any other special symbol elements.

In the typesetting process, text elements with the same horizontal size can be used as an element type, for example, if the rendered size of each chinese character is the same, then the chinese character can be used as an element type.

Considering that the lateral sizes rendered by different text elements are not necessarily the same during the typesetting process, for example, the lateral size rendered by the english letter "w" is larger than the lateral size rendered by the english letter "f", and the lateral size rendered by the capital letter of the same english letter is larger than the lateral size rendered by the small letter. Considering further that the number of letter elements, number elements and symbol elements in the existing word elements is limited, regarding each letter (upper case and lower case are distinguished), each number and each symbol as an element type does not seriously increase the amount of calculation, and it is convenient to divide the element types, therefore, in one embodiment, each letter, each number and each symbol can be considered as an element type, for example, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 can be considered as a text element of 10 element types.

As mentioned above, the content to be typeset also includes content in a non-text form, and for the content in the non-text form, a picture, a video, a component, etc. can be used as a non-text element.

In the embodiment of the present disclosure, the content to be laid out may be a complete piece of content, for example, a novel, and thus the content to be laid out may include a title and a paragraph. In general, the rendered sizes of the title and the paragraph are different, for example, the rendered size of the text content in the title is larger than the rendered size of the text content in the paragraph. Therefore, in one embodiment, a plurality of content units including at least one title unit and at least one paragraph unit may be determined from the content to be laid out based on the content unit indication field in the content to be laid out, and then, for each content unit, in the case where the content form of the content unit is text, each text element in the content unit and the element type of each text element may be determined.

The content unit indication field refers to field information for indicating each content unit and each content unit type in the content to be typeset. For example, some content elements in the content to be laid out are marked with the field "content", and the field "content" may indicate that these content elements are one content unit. If a certain content unit is marked with a field "type 'paramph'" at the end, the field "type 'paramph'" may indicate that the content unit is a paragraph unit.

The content unit indication field may be marked in advance in the content to be typeset, the content to be typeset acquired from the server may include the content unit indication field, and the content unit included in the content to be typeset may be determined according to the content unit indication field.

According to the content unit indication field, a plurality of content units in text form and/or non-text form contained in the content to be typeset can be determined. And in general, a title unit of the content units is a text-form content unit, and a paragraph unit is a text-form and/or non-text-form content unit.

After obtaining each text element and the element type of each text element, the process of determining rendering size information of each text element and the process of typesetting the content in the text form, that is, the steps of S102 and S103, may be sequentially performed, and the typesetting process for the content in the non-text form in the content to be typeset will be described in detail later.

S102: and determining rendering size information of each text element based on the element type of each text element and the rendering size relationship between each element type indicated by the preset type template.

In the embodiment of the present disclosure, the preset type template may be an information template in which, before performing S102, element types (not necessarily including element types corresponding to each text element in the content to be laid out) of a plurality of preset text elements and rendering size information of each element type are integrated in advance. Rendering size information of various element types is integrated in the type template as much as possible, so that the rendering size information of each text element to be typeset can be determined more comprehensively during actual typesetting. Here, the rendering size of each element type in the type template does not necessarily represent actual rendering size information, and the rendering size of each element type in the type template represents a relative rendering size between the element types, that is, a rendering size relationship. In the actual rendering process, rendering can be performed according to the rendering size information of each element type in the type template, or a target element type can be selected from the type template, the text element of the target element type is rendered according to the preset rendering size information, and then the rendering size information of the text element of other element types is determined according to the rendering size relationship between the target element type and other element types. Table one shows a type of type template.

Watch 1

Element type Character (Chinese character) a b f …… + @ ……
Rendering size 19 11 11 6 …… 12 20 17 ……

In the table, a plurality of element types and rendering size information of each element type are shown, and the unit of the rendering size is a Pixel (px). For example, the rendering size for an element type of "word" is 19px, the rendering size for an element type of letter "a" is 11px, the rendering size for an element type of letter "f" is 11px, and so on.

By the rendering size of each element type, it can be obtained that the rendering size ratio of the element type "word" to the element type "a" is 19: 11, the rendering size ratio of element type "word" to element type "f" is 19: 6, the rendering size ratio of element type "a" to element type "f" is 11: 6, and the like.

It should be noted here that, in the actual typesetting, rendering is not necessarily performed according to the rendering size information of each element type in the type template, the actual rendering size information of any one of the element types may be given, then the actual rendering size information of other element types is determined according to the determined rendering size relationship between any two element types, and finally rendering is performed according to the actual rendering size information of each element type.

For example, in the actual rendering process, when a text element of the element type "word" is rendered at a rendering size of 19px, it can be determined that the actual rendering size of the element type "a" is 11px and the actual rendering size of the element type "f" is 6 px; when text elements of the rendering element type "word" are rendered at 39px, it can be determined that the actual rendering size of the element type "a" is 22px, the actual rendering size of the element type "f" is 12px, and the like.

As described above, in the composition process, rendering sizes of the text elements of the title unit and the text elements of the paragraph unit may be different, and therefore, here, the rendering size information of each text content element in the content unit may be determined for each content unit based on rendering size information corresponding to a preset element type in the content unit indicated in the composition style setting information, an element type of each text element in the content unit, and a rendering size relationship between each element type indicated by a preset type template; the layout style setting information includes rendering size information corresponding to a preset element type in the title unit and rendering size information corresponding to a preset element type in the paragraph unit.

When determining rendering size information of each text element in the title unit, for example, rendering size information corresponding to a preset element type in the title unit indicated in the layout style setting information is rendering size information of an element type "word" (may be different from the rendering size information of the element type "word" in the type template), at this time, the text element of the element type "word" in the title unit may be rendered according to the rendering size information of the element type "word" in the title unit indicated in the layout style setting information, and rendering size information of other element types in the title unit may be determined according to the rendering size information of the element type "word" and the rendering size relationship between the element type "word" in the type template and other element types.

Specifically, for example, when the rendering size information indicating the element type "word" in the title unit in the layout style setting information is 24px, and the rendering size information indicating the element type "word" in the type template in table one is 19px, the text element of the element type "word" may be rendered according to 24px, and according to the rendering size relationship between the element type "word" and other element types in the type template in table one, the rendering size information indicating the element type "a" may be determined to be 24 × 11/19px, the rendering size information indicating the element type "f" may be 24 × 6/19px, and the like.

The process of determining rendering size information of each text element in the paragraph unit is similar to the process of determining rendering size information of each text element in the title unit, and is not described herein again.

The text elements in the title unit and the text elements in the paragraph unit are rendered respectively by the rendering size information corresponding to the preset element type in the title unit and the rendering size information corresponding to the preset element type in the paragraph unit contained in the typesetting style setting information, so that the diversity of content typesetting is realized.

S103: and typesetting the content to be typeset based on the rendering size information and the typesetting style setting information of each text element.

When the content to be typeset is typeset, the horizontal occupation size of the text elements and the vertical occupation size of the text elements are also considered. The horizontal occupation size refers to size information occupied in the horizontal direction of the typesetting page, and the vertical occupation size refers to size information occupied in the vertical direction of the typesetting page.

In one embodiment, for each content unit, determining the horizontal placeholder size of each text element in the content unit based on the determined rendering size information of each text element in the content unit, and determining the vertical placeholder size of each text element in the content unit based on the line height indicated in the layout style setting information; determining each text element of the content units arranged in each line based on the transverse occupation size of each text element and the transverse occupation size of the whole line in the typesetting page; and typesetting the content units on at least one typesetting page according to the determined text elements arranged in each line of the content units, the vertical occupation sizes of the text elements and the typesetting type, paragraph spacing and line spacing indicated in the typesetting style setting information.

Here, the rendering size information includes width information of the text elements, and in the embodiment of the present disclosure, a distance between two text elements may be set to be zero by default, and thus, for each content unit, a lateral footprint of each text element in the content unit may be determined based on the determined rendering size information of each text element in the content unit.

For each text element, a corresponding original aspect ratio may be provided, after rendering size information (that is, width information) of each text element is determined, the height information of the text element may be determined according to the original aspect ratio, but in order to perform layout better, in an actual process, the height information of the text element is not necessarily adopted for layout, for each content unit, a vertical placeholder size of each text element in the content unit may be determined according to a line height indicated in layout style setting information, and then layout is performed according to the vertical placeholder size. The vertical placeholders corresponding to different text elements may be the same in the same content element.

Further, in order to make the composition effect better, the vertical footprint may be determined according to a line height indicated in the composition style setting information and a preset filling interval, wherein the vertical footprint is equal to a sum of the line height and the preset filling interval, and the preset filling interval may include an upper filling interval and a lower filling interval. For example, according to the rendering size information (horizontal footprint) of the element type "word" and the preset original aspect ratio, it is determined that the height of the element type "word" is 14px, the height of the layout style setting information indicating the element type "word" is 16px, the preset upper padding interval and the preset lower padding interval are respectively 2px, and then the vertical footprint of the actually rendered element type "word" is 20 px.

Next, based on the lateral occupation size of each text element and the lateral occupation size of the whole line in the layout page, each text element with content units arranged in each line can be determined. At the end of each line, if the lateral footprint is not sufficient to accommodate the text elements to be laid out, the text elements to be laid out may be laid out in the next line or the pitch of each laid out text element in the line may be adjusted.

The type of layout refers to a manner of switching content, and may specifically include horizontal switching and vertical switching, and the type of layout may be preset and may not be related to the content unit.

The typesetting type for transverse switching relates to a paging process, and specifically paging can be performed according to a preset paging rule.

Specifically, for the horizontally switched layout type, when performing layout, line layout and page layout may be performed. When the line layout and the page layout are performed, the line and the page that have been laid out may be cached. Wherein line caching refers to storing the typeset text elements in the line, the line number of the line in the page, and the like. Page cache refers to storing the typeset text elements in the page, the number of lines in the page, the number of pages in the page, etc.

When the text elements are typeset in a line, for each text element to be typeset currently, it may be determined whether the text element to be typeset currently is the first text element of the paragraph in which the text element is located, and if so, the text element to be typeset currently is arranged in a new line. If not, for each line, based on the lateral placeholder size of the text element already laid out (which can be obtained from the line cache), the lateral placeholder size of the text element to be currently laid out, and the lateral placeholder size of the entire line, it may be determined whether the text element to be currently laid out will overflow in the line. If the text element to be typeset does not overflow, the text element to be typeset currently can be arranged in the row; if the text element to be typeset overflows, the text element to be typeset currently can be arranged in a new line, and the text element is subjected to line caching.

When the text elements are typeset, if the text elements to be typeset currently need to be arranged in a new line, at this time, whether the page overflows after the text elements to be typeset currently are arranged in the new line can be judged according to the vertical position-occupying information of the text elements already typeset in each line and the vertical position-occupying information of the typeset page. If the page does not overflow, the current text element to be typeset can be arranged in a new line in the page; if overflow occurs, the text element to be typeset currently can be arranged in the first line of the next page, and page caching and line caching are performed on the text element.

The typesetting type of the vertically switched content does not relate to the paging process, so typesetting can be performed only according to the row arrangement rule, and details are not repeated here.

In a possible implementation manner, for any text element to be typeset, if the element type of any text element does not exist in the preset type template, rendering size information of a target element type with a largest rendering size corresponding to each element type existing in the preset type template may be used as rendering size information of any text element.

In this embodiment, in general, rendering size information of any text element whose element type does not exist in a preset type template does not exceed rendering size information of a target element type whose rendering size is the largest, and therefore, when rendering size information of a target element type whose corresponding rendering size is the largest is used as rendering size information of the text element, the text element does not overflow in a layout page, and the appearance of the layout page is not affected.

In a special case, when the rendering size information of the text element exceeds the rendering size information of the target element type with the largest rendering size, the rendering size information of the text element can be set in a self-defined manner. Here, the preset type template in an editable state may be displayed to the user, an updated type template obtained by performing user-defined setting on the type template by the user may be acquired, the updated type template may include rendering size information that is user-defined set by the user on any text element of which the element type does not exist in the preset type template, and finally, the any text element may be typeset according to the updated type template.

When the element type of any text element does not exist in the type template, in a possible implementation manner, the size relationship between any text element and other content elements under the element type existing in the preset type template can be determined based on the acquired original size information of each text element to be typeset; and updating the rendering size relation between the special element type corresponding to any text element in the preset type template and other element types based on the size relation.

In this embodiment, the original size information of each text element to be typeset may be measured in a measuring manner using canvas, and then the size relationship between the original size information of each text element to be typeset is determined based on the original size information, thereby determining the size relationship between any text element and other content elements existing in the preset type template under the element type. After the size relationship is determined, the rendering size relationship between the special element type corresponding to any text element and other element types can be added to the preset type template, so that the preset type template is updated.

After the type template is updated, the updated type template may be used to determine rendering size information of each text element to be typeset, so in a possible implementation manner, before step S102 is executed, a preset type template in an editable state may be displayed; then obtaining an updated type template obtained after supplementing the preset type template; the updated type template comprises rendering size relations between the special element types which do not exist in the preset type template and other element types.

The updated type template may be an updated type template obtained by a user setting the type template in a user-defined manner, or an updated type template obtained by supplementing a preset type template based on a size relationship between any text element and other text elements in the element type of the preset type template. The process of updating the type template is as described above. The process of updating the type template can be performed off-screen calculation and local storage at the client or the webpage, and the calculation process and the actual experience of the user of the embodiment of the disclosure are not affected.

And finally, based on the element types of the text elements to be typeset and the rendering size relationship among the element types indicated by the updated type template, determining the rendering size information of the text elements to be typeset. This process is the same as the process of S102 described above, and is not described here again.

Having described the process of typesetting for content in text form, and for content in non-text form, i.e. in case the content unit is in non-text form, in one possible embodiment, the original size information of the non-text content unit may be obtained, the original size information including height information and width information; taking the height information as a vertical occupation size of the non-text content unit, and configuring a horizontal occupation size of the non-text content unit into a horizontal occupation size of the whole line; and typesetting the non-text content units based on the typesetting type and paragraph spacing, the vertical occupation size and the horizontal occupation size indicated in the typesetting style setting information.

The original size information of the non-text content unit may be obtained when the content to be typeset is obtained from the server. The vertical placeholder size and the horizontal placeholder size of the content elements in the non-text form can be determined according to the original size information, wherein the horizontal placeholder size of the content elements in the non-text form is configured to be the horizontal placeholder size of the whole line, namely, one content element in the non-text form is laid out in one line. The layout types here are the same as the aforementioned layout types, and are not described here again. In a specific implementation, the content units in the non-text form may be laid out as a paragraph, or may be combined with the content units in the text form to be laid out as a paragraph.

In a possible implementation manner, when the content to be typeset obtained this time is completely the same as the typesetting content obtained in the last typesetting, the content to be typeset of this time can be typeset by using the line cache and the page cache in the last typesetting; when the content to be typeset obtained this time is not identical to the typesetting content obtained in the last typesetting, the content to be typeset this time can be typeset according to the content typesetting method provided by the embodiment of the disclosure, and the line cache and the page cache in the last typesetting are deleted while the line cache and the page cache in this time are retained.

For explaining the content typesetting method provided by the embodiment of the present disclosure in detail, the following process of typesetting a novel is taken as an example to explain the content typesetting method, and specifically, refer to fig. 2.

Here, the composed novel may be presented in a view interface of the client. Before the method is executed, the client can obtain the content to be typeset, namely the novel to be typeset from the server.

According to the content unit indication field in the content to be typeset, a title unit, a paragraph unit and the like are obtained, for example, the content to be typeset includes [ { content: "xxxxxx", type: "paragraph", "}, { content: "xxxxxx", type: "param", "jc", in accordance with the content unit indication field "content", "type: and the paragraph can determine that the content to be typeset comprises two paragraph units.

Then, for each content unit, it is determined whether the content is in text form, and in the case where the content is determined to be in text form, the text element of the content unit and the element type of the text element are acquired. And then determining rendering size information of the text element according to the element type of the text element and the rendering size relation between the element types indicated in the type template. And under the condition that the content units (such as pictures) in a non-text form are determined, acquiring original size information of the non-text content, taking the height information in the original size information as the vertical occupation size of the non-text content units, and configuring the horizontal occupation size of the non-text content units into the horizontal occupation size of the whole line.

The rendering size information of the text element refers to width information of the text element, and the distance between adjacent text elements is zero by default, so that the transverse occupation size of the text element can be determined according to the rendering size information of the text element.

When rendering is performed according to the transverse occupation size of the text elements, whether a current line overflows or not is determined according to the transverse occupation size of each text element and the transverse occupation size of the whole line in the typesetting page, if the current line overflows, information such as the typesetted text elements in the line and the line number of the line is output, namely a line cache is output, the text elements to be typeset are added to the next line, and whether the current content unit is finished or not is judged; if not, adding the text element to be typeset to the line, updating the typeset text element in the line, namely updating the line cache, and judging whether the current content unit is finished.

Under the condition that the current content unit is not finished, repeatedly executing the step of acquiring the text element of the content unit and the element type of the text element; and under the condition that the current content unit is finished, judging whether the current page overflows or not according to the line cache and the vertical occupation size of the text element determined according to the line height indicated in the typesetting setting information. When the content unit includes a content unit in a non-text form, whether the current page overflows or not may be judged according to the line cache, the vertical occupation size of the text element determined according to the line height indicated in the layout setting information, and the vertical occupation information of the content unit in the non-text form.

The vertical placeholder size of the text element determined according to the line height indicated in the layout setting information may refer to the process of S103, which is not described herein again.

If the current page overflows, outputting the typesetted text elements, the typesetted content units in a non-text form, the typesetted line number in the current page and the page number of the current page, namely outputting page cache, adding the content to be typeset to the next page, and judging whether the typesetting content is finished; if the current page is not overflowed, the content to be typeset can be added to the current page, the typesetted text elements or the content units in the non-text form in the current page are updated, namely page cache is updated, and whether the typesetting content is finished or not is judged.

Under the condition that the typesetting content is not finished, repeatedly executing the process of obtaining the unit content; when the typesetting content is finished, the typesetting is finished, and the page cache can be output, so that the typesetting can be directly performed according to the page cache when the same typesetting content is obtained next time.

It will be understood by those skilled in the art that in the method of the present invention, the order of writing the steps does not imply a strict order of execution and any limitations on the implementation, and the specific order of execution of the steps should be determined by their function and possible inherent logic.

Based on the same inventive concept, a content typesetting device corresponding to the content typesetting method is also provided in the embodiments of the present disclosure, and as the principle of solving the problem of the device in the embodiments of the present disclosure is similar to the content typesetting method in the embodiments of the present disclosure, the implementation of the device can refer to the implementation of the method, and repeated details are not repeated.

Referring to fig. 3, a schematic diagram of an architecture of a content typesetting apparatus provided in the embodiment of the present disclosure is shown, where the apparatus includes: a first obtaining module 301, a first determining module 302 and a first layout module 303; wherein the content of the first and second substances,

a first obtaining module 301, configured to obtain each text element in the content to be typeset and an element type of each text element;

a first determining module 302, configured to determine rendering size information of each text element based on an element type of each text element and a rendering size relationship between each element type indicated by a preset type template;

the first layout module 303 is configured to layout the content to be laid out based on the rendering size information and the layout style setting information of each text element.

In an optional implementation manner, the first obtaining module 301 is specifically configured to:

determining a plurality of content units from the content to be typeset based on the content unit indication fields in the content to be typeset; the plurality of content units comprises at least one title unit and at least one paragraph unit;

for each content unit, determining each text element in the content unit and the element type of each text element when the content form of the content unit is text.

In an optional implementation manner, the first determining module 302 is specifically configured to:

for each content unit, determining rendering size information of each text element in the content unit based on rendering size information corresponding to a preset element type in the content unit indicated in the layout style setting information, an element type of each text element in the content unit, and a rendering size relationship between each element type indicated by a preset type template;

the layout style setting information comprises rendering size information corresponding to a preset element type in a title unit and rendering size information corresponding to a preset element type in a paragraph unit.

In an optional implementation manner, the first layout module 303 is specifically configured to:

for each content unit, determining the horizontal occupation size of each text element in the content unit based on the determined rendering size information of each text element in the content unit, and determining the vertical occupation size of each text element in the content unit based on the line height indicated in the typesetting style setting information;

determining each text element arranged in each line by the content unit based on the transverse occupation size of each text element and the transverse occupation size of the whole line in the typesetting page;

and typesetting the content units on at least one typesetting page according to the determined text elements arranged in each line of the content units, the vertical occupation sizes of the text elements, and the typesetting type, paragraph spacing and line spacing indicated in the typesetting style setting information.

In an alternative embodiment, the apparatus further comprises:

the second acquisition module is used for acquiring original size information of the non-text content unit under the condition that the content form of the content unit is non-text, wherein the original size information comprises height information and width information;

a configuration module, configured to use the height information as a vertical footprint of the non-text content unit, and configure a horizontal footprint of the non-text content unit as a horizontal footprint of an entire row;

and the second typesetting module is used for typesetting the non-text content units based on the typesetting type and the paragraph spacing indicated in the typesetting style setting information, the vertical occupation size and the horizontal occupation size.

In an alternative embodiment, the apparatus further comprises:

and the storage module is used for aiming at any text element, and if the element type of any text element does not exist in the preset type template, rendering size information of the element type with the largest corresponding rendering size in all the element types existing in the preset type template is used as the rendering size information of any text element.

In an alternative embodiment, the apparatus further comprises:

a second determining module, configured to determine, for any text element, a size relationship between the text element and another text element existing in the element type in the preset type template based on the obtained original size information of each text element to be typeset, if the element type of the text element does not exist in the preset type template;

and the updating module is used for updating the rendering size relation between the special element type corresponding to any text element in the preset type template and other element types based on the size relation.

In an alternative embodiment, the apparatus further comprises:

the display module is used for displaying the preset type template in an editable state;

the third obtaining module is used for obtaining an updated type template obtained after the preset type template is supplemented; the updated type template comprises rendering size relations between special element types which do not exist in the preset type template and other element types;

the first determining module 302 is specifically configured to determine rendering size information of each text element to be typeset based on the element type of each text element to be typeset and the updated rendering size relationship between the element types indicated by the type template.

The description of the processing flow of each module in the device and the interaction flow between the modules may refer to the related description in the above method embodiments, and will not be described in detail here.

Based on the same technical concept, the embodiment of the disclosure also provides computer equipment. Referring to fig. 4, a schematic structural diagram of a computer device 400 provided in the embodiment of the present disclosure includes a processor 401, a memory 402, and a bus 403. The memory 402 is used for storing execution instructions and includes a memory 4021 and an external memory 4022; the memory 4021 is also referred to as an internal memory, and is configured to temporarily store operation data in the processor 401 and data exchanged with an external memory 4022 such as a hard disk, the processor 401 exchanges data with the external memory 4022 through the memory 4021, and when the computer device 400 operates, the processor 401 communicates with the memory 402 through the bus 403, so that the processor 401 executes the following instructions:

acquiring each text element in the content to be typeset and the element type of each text element;

determining rendering size information of each text element based on the element type of each text element and the rendering size relationship between each element type indicated by a preset type template;

and typesetting the content to be typeset based on the rendering size information and the typesetting style setting information of each text element.

The embodiments of the present disclosure also provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the content typesetting method in the above method embodiments are executed. The storage medium may be a volatile or non-volatile computer-readable storage medium.

The embodiments of the present disclosure also provide a computer program product, where the computer program product carries a program code, where instructions included in the program code may be used to execute the steps of the content typesetting method in the foregoing method embodiments, which may be referred to in the foregoing method embodiments specifically, and are not described herein again.

The computer program product may be implemented by hardware, software or a combination thereof. In an alternative embodiment, the computer program product is embodied in a computer storage medium, and in another alternative embodiment, the computer program product is embodied in a Software product, such as a Software Development Kit (SDK), or the like.

It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, apparatus, and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.

The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.

In addition, functional units in the embodiments of the present disclosure may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.

The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present disclosure may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present disclosure. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.

Finally, it should be noted that: the above-mentioned embodiments are merely specific embodiments of the present disclosure, which are used for illustrating the technical solutions of the present disclosure and not for limiting the same, and the scope of the present disclosure is not limited thereto, and although the present disclosure is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive of the technical solutions described in the foregoing embodiments or equivalent technical features thereof within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present disclosure, and should be construed as being included therein. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.

19页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种HTML编辑方法、装置、电子设备及计算机可读存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!