A method for obtaining the font size of a text flow formula, a computer device, and a computer-readable storage medium

By cyclically peeling off the formula template and calculating the offset, the problem of inconsistent font sizes in the formula is solved, and the precise calculation of the font sizes at each position in the formula is achieved, which is simple and fast.

CN114492301BActive Publication Date: 2024-11-19YOZOSOFT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111650895.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2024-11-19
Estimated Expiration
2041-12-30

AI Technical Summary

Technical Problem

The prior art is difficult to effectively calculate the font sizes of each position in the formula, resulting in inconsistent settings.

Method used

By obtaining the number of layers of the formula template, starting from the target position point, peeling it from the inside to the outside layer, declaring the variable to store the font size offset, and calculating the font size offset according to the template type and slot type, and finally determining the formula font size for each position in it.

Benefits of technology

It realizes accurate calculation of each font size in the formula, which is simple to operate, fast to be fast and has high accuracy.

✦ Generated by Eureka AI based on patent content.
Patent Text Reader

Abstract

The present invention provides a method for obtaining the font size of a text flow formula, comprising the following steps: obtaining the number of layers of a formula template, the number of template layers obtained being the number of loops; declaring a variable for storing the offset size of the font size of the position to be calculated relative to a reference; in the first loop, respectively calculating the offset of the font size according to the template type and the slot type; after the first loop is completed, obtaining the outer slot type where the slot is located according to the slot position, and continuing to loop until the loop reaches the outermost template. The present invention has the advantages of being able to accurately calculate the size of each font in the formula, high accuracy, high speed, etc.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of computers, and in particular to a method for obtaining a font size of a text flow formula. Background Art

[0002] There are many commonly used formulas, each corresponding to a different template. When you select the entire formula to set the font size, the font size at each position in the formula is different. This requires a special algorithm to analyze the internal structure of the formula to obtain the corresponding parameters of the font size, and finally calculate the actual font size at the corresponding position.

[0003] Therefore, it is necessary to provide a new technical solution. Summary of the invention

[0004] In order to solve the technical problems existing in the prior art, the present invention discloses a method for obtaining the font size of a text flow formula, and the specific technical solution is as follows:

[0005] The present invention provides a method for obtaining a font size of a text flow formula, comprising the following steps:

[0006] S1, obtain the number of layers of the formula template, start the cycle from the target position, and peel off layer by layer from the inside to the outside. The number of template layers obtained is the number of cycles. Formulas at the same level do not participate in the calculation of the number of layers;

[0007] S2, before the loop, declare a variable to store the offset of the font size of the position to be calculated relative to the benchmark. The benchmark refers to the font size of the entire formula, that is, the initial size passed in;

[0008] S3, the first loop, obtains the template type and slot type of the position, and calculates the offset of the font size according to the different template types and slot types;

[0009] S4, after the first loop is completed, the outer slot type of the slot is obtained according to the slot position, and the loop continues until the outermost template is reached;

[0010] S5. Finally, there are only three font sizes obtained. If the offset is greater than or equal to 0, it is the base size. If the offset is -1, the size is 2 / 3 of the base size. If the offset is less than or equal to -2, the font size is 1 / 2 of the base size.

[0011] Furthermore, the template types include fraction formulas, box formulas, superscript formulas, subscript formulas, subscript-superscript formulas, left subscript-superscript formulas, radical formulas, N-ary operator formulas, separator formulas, equation array formulas, function formulas, tone formulas, character combination formulas, upper limit formulas, lower limit formulas, box formulas, horizontal bar formulas, matrix formulas, differential formulas and operator formulas; the slot types include base, superscript, subscript, upper and lower limits and radicals.

[0012] Furthermore, if the template type is a fractional formula, it will also be affected by the horizontal, vertical, no horizontal line, inline and other attributes. The offset value of the no horizontal line type is -1, the offset value of the inline type is -1, and the other cases are the base size, and the offset value is 0;

[0013] If the template type is a superscript formula, subscript formula, superscript and subscript formula, left superscript and left subscript formula, or N-ary operator formula, it must be calculated together with the slot type. If the slot type is a superscript or subscript type, the offset is -1, and the rest of the positions are the base size.

[0014] If the template type is upper and lower limit formula, and the slot type is upper and lower limit type, the offset is -1, and the remaining positions are the base size;

[0015] If the template type is a radical formula and the slot is a root type, the font size offset is -2, and the rest of the positions are the base size;

[0016] If the template type is a boxed formula, in general, the font size offset should be -1. In special cases, if the inner layer is a character combination formula and the outer layer is a boxed formula, the font size offset in the character combination template should be +1.

[0017] The font sizes of other template types not specially marked are the base sizes.

[0018] The present invention also provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0019] S1, obtain the number of layers of the formula template, start the cycle from the target position, and peel off layer by layer from the inside to the outside. The number of template layers obtained is the number of cycles. Formulas at the same level do not participate in the calculation of the number of layers;

[0020] S2, before the loop, declare a variable to store the offset of the font size of the position to be calculated relative to the benchmark. The benchmark refers to the font size of the entire formula, that is, the initial size passed in;

[0021] S3, the first loop, obtains the template type and slot type of the position, and calculates the offset of the font size according to the different template types and slot types;

[0022] S4, after the first loop is completed, the outer slot type of the slot is obtained according to the slot position, and the loop continues until the outermost template is reached;

[0023] S5. Finally, there are only three font sizes obtained. If the offset is greater than or equal to 0, it is the base size. If the offset is -1, the size is 2 / 3 of the base size. If the offset is less than or equal to -2, the font size is 1 / 2 of the base size.

[0024] The present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:

[0025] S1, obtain the number of layers of the formula template, start the cycle from the target position, and peel off layer by layer from the inside to the outside. The number of template layers obtained is the number of cycles. Formulas at the same level do not participate in the calculation of the number of layers;

[0026] S2, before the loop, declare a variable to store the offset of the font size of the position to be calculated relative to the benchmark. The benchmark refers to the font size of the entire formula, that is, the initial size passed in;

[0027] S3, the first loop, obtains the template type and slot type of the position, and calculates the offset of the font size according to the different template types and slot types;

[0028] S4, after the first loop is completed, the outer slot type of the slot is obtained according to the slot position, and the loop continues until the outermost template is reached;

[0029] S5. Finally, there are only three font sizes obtained. If the offset is greater than or equal to 0, it is the base size. If the offset is -1, the size is 2 / 3 of the base size. If the offset is less than or equal to -2, the font size is 1 / 2 of the base size.

[0030] The present invention has the following beneficial effects:

[0031] 1. The method for obtaining the font size of a text flow formula provided by the present invention is simple, easy to implement and convenient to operate.

[0032] 2. The method for obtaining the font size of a text flow formula provided by the present invention can accurately calculate the size of each font in the formula with high accuracy and high speed.

[0033] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. DETAILED DESCRIPTION

[0034] In order to further illustrate the technical means adopted by the present invention and the technical effects achieved, a detailed description is given below in conjunction with embodiments.

[0035] The present invention provides a method for obtaining a font size of a text flow formula, comprising the following steps:

[0036] S1, obtain the number of layers of the formula template, start the cycle from the target position, and peel off layer by layer from the inside to the outside. The number of template layers obtained is the number of cycles. Formulas at the same level do not participate in the calculation of the number of layers;

[0037] S2, before the loop, declare a variable to store the offset of the font size of the position to be calculated relative to the benchmark. The benchmark refers to the font size of the entire formula, that is, the initial size passed in;

[0038] S3, the first loop, obtains the template type and slot type of the position, and calculates the offset of the font size according to the different template types and slot types;

[0039] S4, after the first loop is completed, the outer slot type of the slot is obtained according to the slot position, and the loop continues until the outermost template is reached;

[0040] S5. Finally, there are only three font sizes obtained. If the offset is greater than or equal to 0, it is the base size. If the offset is -1, the size is 2 / 3 of the base size. If the offset is less than or equal to -2, the font size is 1 / 2 of the base size.

[0041] The template types include fraction formulas, box formulas, superscript formulas, subscript formulas, subscript-superscript formulas, left subscript-superscript formulas, radical formulas, N-ary operator formulas, separator formulas, equation array formulas, function formulas, tone formulas, character combination formulas, upper limit formulas, lower limit formulas, frame formulas, horizontal bar formulas, matrix formulas, differential formulas and operator formulas; the slot types include base, superscript, subscript, upper and lower limits and radicals.

[0042] If the template type is a fractional formula, it will also be affected by the horizontal, vertical, no horizontal line, and embedded properties. The offset value of the no horizontal line type is -1, the offset value of the embedded type is -1, and in other cases, it is the base size and the offset value is 0;

[0043] If the template type is a superscript formula, subscript formula, superscript and subscript formula, left superscript and left subscript formula, or N-ary operator formula, it must be calculated together with the slot type. If the slot type is a superscript or subscript type, the offset is -1, and the rest of the positions are the base size.

[0044] If the template type is upper and lower limit formula, and the slot type is upper and lower limit type, the offset is -1, and the remaining positions are the base size;

[0045] If the template type is a radical formula and the slot is a root type, the font size offset is -2, and the rest of the positions are the base size;

[0046] If the template type is a boxed formula, in general, the font size offset should be -1. In special cases, if the inner layer is a character combination formula and the outer layer is a boxed formula, the font size offset in the character combination template should be +1.

[0047] The font sizes of other template types not specially marked are the base sizes.

[0048] The present invention further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps in the above method embodiment when executing the computer program.

[0049] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method embodiment are implemented.

[0050] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification.

[0051] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify and vary the above embodiments within the scope of the present invention.

Claims

1. A method for obtaining the font size of a text flow formula, characterized in that: The steps include: S1, obtain the number of layers of the formula template, start the cycle from the target position, and peel off layer by layer from the inside to the outside. The number of template layers obtained is the number of cycles. Formulas at the same level do not participate in the calculation of the number of layers; S2, before the loop, declare a variable to store the offset of the font size of the position to be calculated relative to the benchmark. The benchmark refers to the font size of the entire formula, that is, the initial size passed in; S3, the first loop, obtains the template type and slot type of the position, and calculates the offset of the font size according to the different template types and slot types; S4, after the first loop is completed, the outer slot type of the slot is obtained according to the slot position, and the loop continues until the outermost template is reached; S5, finally there are only three font sizes. If the offset is greater than or equal to 0, it is the base size. If the offset is equal to -1, the size is 2 / 3 of the base size. If the offset is less than or equal to -2, the font size is 1 / 2 of the base size. The template types include fraction formula, box formula, superscript formula, subscript formula, subscript-superscript formula, left subscript-superscript formula, radical formula, N-ary operator formula, separator formula, equation array formula, function formula, tone formula, character combination formula, upper limit formula, lower limit formula, box formula, horizontal bar formula, matrix formula, differential formula and operator formula; The slot types include base, superscript, subscript, upper and lower limits, and root.

2. The method for obtaining the font size of a text flow formula according to claim 1, characterized in that: If the template type is a fractional formula, it will also be affected by attributes such as horizontal, vertical, no horizontal line, and inline. The offset value of the no horizontal line type is -1, the offset value of the inline type is -1, and in other cases it is the base size and the offset value is 0.

3. The method for obtaining the font size of a text flow formula according to claim 1, characterized in that: If the template type is a superscript formula, subscript formula, superscript and subscript formula, left superscript and left subscript formula, or N-ary operator formula, it is calculated in conjunction with the slot type. If the slot type is a superscript or subscript type, the offset is -1, and the remaining positions are the base size.

4. The method for obtaining the font size of a text flow formula according to claim 1, characterized in that: If the template type is upper and lower limit formula and the slot type is upper and lower limit type, the offset is -1 and the remaining positions are the base size.

5. The method for obtaining the font size of a text flow formula according to claim 1, characterized in that: If the template type is a radical formula and the slot is a root type, the font size offset is -2, and the remaining positions are the base size.

6. The method for obtaining the font size of a text flow formula according to claim 1, characterized in that: If the template type is a boxed formula, in general: the font size offset should be -1. In special cases: the inner layer is a character combination formula and the outer layer is a boxed formula, then the font size offset in the character combination template should be +1.

7. The method for obtaining the font size of a text flow formula according to claim 1, characterized in that: The font sizes of template types not specifically marked are all base sizes.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.