A graphic-text layout method based on golden ratio and Fibonacci sequence
Patent Information
- Application Number
- CN202611057843.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-16
- Publication Date
- 2026-11-03
AI Technical Summary
Existing printers, limited by their hardware configuration, cannot independently complete the entire process from voice input to aesthetically pleasing typesetting, resulting in a poor user experience. Furthermore, existing automatic typesetting solutions lack aesthetic principles, producing rigid and uninspired layouts.
Employing a typesetting algorithm based on the golden ratio and the Fibonacci sequence, it achieves automated and aesthetically pleasing typesetting by calculating margins, line spacing, and alignment, including dynamic adjustments to text size, alignment, and line spacing.
It enables printers to operate independently with low hardware configurations, improves user experience and ease of use, meets aesthetic and readability requirements, and is suitable for various printing scenarios.
Smart Images

Figure CN123030143A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of printing and typesetting technology, specifically to a graphic and text typesetting method based on the golden ratio and the Fibonacci sequence. Background Technology
[0002] As an important output device besides computers and mobile terminals, printers have long been primarily used as peripherals for computers or mobile phones. There are two main reasons for this: First, the input of printed content relies on mobile phones or computers; second, the printed content needs to be pre-formatted in application software to achieve aesthetics and readability. Otherwise, it is no different from the early mechanical typewriters—using standard fonts, with little variation in font size, alignment, line spacing, margins, and other layout elements, resulting in unattractive output content and making it difficult for users to use and read.
[0003] With the development and popularization of artificial intelligence technology, smart devices based on voice interaction are gradually entering homes and becoming a part of people's lives. Voice input is widely popular due to its convenience, surpassing keyboards and touchscreens, and has become one of the important hallmarks of AI functionality. However, conventional printers, limited by cost and size, use embedded MCU solutions, which suffer from problems such as low computing power and limited memory. Even if voice input functionality is implemented, if layout issues cannot be resolved, the printer still cannot work independently of a computer or mobile phone, and the user experience cannot be substantially improved.
[0004] While some automatic layout solutions exist in existing technologies, most are based on fixed templates or simple center / left alignment rules, lacking a systematic application of layout aesthetics. The layout results are often rigid, lack a sense of hierarchy, and fail to meet users' needs for aesthetic appeal and readability of the output content.
[0005] Therefore, there is a need for a graphic layout method that can be automated and conforms to aesthetic principles under low hardware configuration conditions, so that output devices such as printers can independently complete the entire process from voice input to aesthetically pleasing layout output. Summary of the Invention
[0006] In view of the problems existing in the prior art, this invention constructs a typesetting algorithm scheme that conforms to aesthetic logic for text, images, barcodes, and other content, based on the golden ratio (1:1.618) and the Fibonacci sequence (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181…). This algorithm automatically typesets elements including text size, alignment, line spacing, and margins, meeting the aesthetic and readability requirements of general printing scenarios. This solves the problem of printers being completely dependent on computers and mobile phones, allowing printers to work independently, improving ease of use, and enhancing the user experience.
[0007] The present invention adopts the following technical solution:
[0008] A text and image layout method based on the golden ratio and the Fibonacci sequence includes the following steps:
[0009] Step 1: Obtain the size information of the printing medium and the text content to be printed;
[0010] Step 2: Based on the printed carrier size information, calculate the margin reference value based on the golden ratio, and match the margin reference value with the Fibonacci sequence to determine the layout margin;
[0011] Step 3: Determine the size of the content area based on the layout margins and the size of the printing medium.
[0012] Step 4: Based on the size of the content area and the text to be printed, determine the font size, line spacing, and alignment to complete the text layout;
[0013] Step 5: Generate and output the printable dot matrix data based on the layout results.
[0014] As a preferred embodiment of the present invention, the determination of the layout margin in step two specifically includes: taking the smaller value among the printing carrier sizes as the reference size, calculating the product of the reference size and the golden ratio division coefficient 0.382, and then dividing by 2 to obtain the margin reference value; comparing the margin reference value with each term in the Fibonacci sequence, and selecting the Fibonacci sequence value that is closest to the margin reference value as the layout margin.
[0015] As a preferred embodiment of the present invention, the determination of the layout margin in step two further includes: based on the layout margin, according to the scaling requirements of the content area, jumping to the adjacent Fibonacci sequence value as the adjusted layout margin.
[0016] As a preferred embodiment of the present invention, step three, determining the size of the content area, specifically includes:
[0017] Content area height = Print media height - Top margin - Bottom margin;
[0018] Content area width = Print media width - Left margin - Right margin
[0019] As a preferred embodiment of the present invention, the determination of line spacing in step four specifically includes: multiplying the font size by the golden ratio value of 1.618 to obtain the golden line spacing; or multiplying the font size by 1.5 to obtain the Fibonacci line spacing.
[0020] As a preferred embodiment of the present invention, step four of determining the alignment method specifically includes:
[0021] When the text consists of 1 to 2 lines, use both vertical and horizontal center alignment.
[0022] When the number of text lines is greater than 2, use left alignment and top / bottom center alignment.
[0023] As a preferred embodiment of the present invention, when the layout content simultaneously includes text boxes and images or barcodes, step four further includes: determining a layout scheme based on the number of characters.
[0024] When the number of characters is less than or equal to 5, the first layout scheme is adopted: the height of the text box occupies the golden ratio of 0.382 of the height of the content area, the image or barcode area occupies the remaining height, and the spacing between the text box and the image or barcode area is 0.
[0025] When the number of characters is greater than 5, the second layout scheme is adopted: the height of the image or barcode area occupies the golden ratio of 0.382 of the content area height, the text box occupies the remaining height, and the distance between the text box and the image or barcode area is (content area height - content area height × 0.382) × 0.382.
[0026] As a preferred embodiment of the present invention, when the layout content includes a title text box and a body text box, step four further includes: after determining the height of the content area, dividing it using one of the following layout schemes:
[0027] First layout scheme: The title text box is at the top, with a height of (print media height - top margin × 2 - text box spacing) × 0.382; the body text box is at the bottom, with a height of (print media height - top margin × 2 - text box spacing) × 0.618.
[0028] Second layout scheme: Swap the heights of the title text box and the body text box in the first layout scheme.
[0029] Based on the above method, the present invention also provides a graphic layout system based on the golden ratio and the Fibonacci sequence, comprising:
[0030] The information acquisition module is used to acquire the size information of the printing medium and the text content to be printed;
[0031] The margin calculation module is used to calculate the margin reference value based on the golden ratio according to the size information of the printing carrier, and match the margin reference value with the Fibonacci sequence to determine the layout margin;
[0032] The content area determination module is used to determine the size of the content area based on the layout margins and the size information of the printing carrier;
[0033] The text layout module is used to determine the font size, line spacing, and alignment based on the size of the content area and the text content to be printed, and to complete the text layout.
[0034] The print output module is used to generate and output print dot matrix data based on the layout results.
[0035] The present invention also provides a printer, which includes a voice input module for collecting voice input from a user; a communication module for uploading the voice to a cloud server for voice recognition and receiving the text content returned after recognition; the printer also includes the aforementioned graphic layout system based on the golden ratio and Fibonacci sequence, for automatically layouting and printing the text content.
[0036] The beneficial effects of this invention are as follows: By incorporating the golden ratio and Fibonacci sequence into the typesetting algorithm, this invention achieves automated and aesthetically pleasing typesetting with low hardware configuration, enabling the printer to work independently without a computer or mobile phone, thus improving ease of use and user experience. The printer allows text input via voice, adapting to various layouts and covering approximately 50% of daily usage scenarios. It can independently complete printing tasks without relying on mobile apps or computer editing software, greatly enhancing ease of use. This invention has low hardware requirements; an embedded MCU can meet the memory and computing power needs, avoiding the problems of high memory consumption and lack of flexibility associated with using images to replace text. It can be widely applied to small-screen digital products and smart home appliances (such as smart washing machines and smart water bottles), making their screen displays clear and varied in format, ensuring basic aesthetics and smooth reading. Attached Figure Description
[0037] Figure 1 This is a system architecture diagram for the text content typesetting process using voice input, as described in this invention.
[0038] Figure 2 This is a diagram illustrating the text typesetting method architecture of the present invention.
[0039] Figure 3 This is a diagram illustrating the automatic layout effect of a single text box in Embodiment 2 of the present invention.
[0040] Figure 4 This is an illustration of the automatic layout effect of a single text box and an image or barcode in Embodiment 3 of the present invention;
[0041] Figure 5 This is a diagram illustrating the automatic layout effect of dual text boxes in Embodiment 4 of the present invention. Detailed Implementation
[0042] Example 1
[0043] like Figures 1 to 2 As shown, this invention relates to a graphic and text layout method and method based on the golden ratio and Fibonacci sequence, comprising the following steps:
[0044] Step 1: Obtain the size information of the printing medium and the text content to be printed.
[0045] Printers with voice input capabilities collect user-inputted voice messages, encode them using analog-to-digital encoding, and upload them to a cloud-based ASR server for voice recognition, converting the speech into text. Simultaneously, RFID technology is used to read and record information about the printing medium's dimensions (label paper size), which is then combined and submitted to the server.
[0046] Step 2: Based on the print media size information, calculate the margin reference value according to the golden ratio, and match the margin reference value with the Fibonacci sequence to determine the layout margin.
[0047] Using the smaller value among the print media sizes as the baseline size, calculate the product of the baseline size and the golden ratio coefficient 0.382, then divide by 2 to obtain the margin baseline value. Compare the margin baseline value with each term in the Fibonacci sequence, and select the Fibonacci value that is closest to the margin baseline value as the layout margin.
[0048] Step 3: Determine the size of the content area based on the layout margins and the size of the printing medium.
[0049] Content area height = print media height - top margin - bottom margin; Content area width = print media width - left margin - right margin.
[0050] Step 4: Based on the size of the content area and the text to be printed, determine the font size, line spacing, and alignment to complete the text layout.
[0051] The line spacing is determined by multiplying the font size by the golden ratio value of 1.618 to obtain the golden line spacing; or by multiplying the font size by 1.5 to obtain the Fibonacci ratio line spacing (close to the Fibonacci ratio of 3:2 or 5:3). For example, when the font size is 5pt (approximately 1.76mm), the line spacing is recommended to be set to 2.8mm (1.76×1.618).
[0052] The alignment rules are as follows: when there are 1 to 2 lines of text, use vertical and horizontal center alignment; when there are more than 2 lines of text, use left alignment and vertical and horizontal center alignment.
[0053] Step 5: Generate print dot matrix data based on the layout results, send it to the user's printer terminal, and print it out.
[0054] Example 2
[0055] like Figure 3 As shown, automatic text box formatting:
[0056] 1. Calculation of content area margins
[0057] Use the Fibonacci sequence to determine margins. Using the smaller of the print media dimensions as a baseline, calculate the baseline margin value as (smaller of length and width × 0.382) ÷ 2. Then, select the closest value from the Fibonacci sequence as the margin.
[0058] When the print media size is 40mm wide × 30mm high: (30mm × 0.382) ÷ 2 = 5.73mm. The closest value of the Fibonacci sequence is 5. Therefore, the text box should be 5mm from the top, bottom, left, and right edges.
[0059] When the print media size is 80mm wide × 40mm high: (40mm × 0.382) ÷ 2 = 7.64mm. The closest value of the Fibonacci sequence is 8. Therefore, the text box distances from the top, bottom, left, and right edges are all 8mm.
[0060] When the screen size is 480px × 320px: (320px × 0.382) ÷ 2 = 61.12px. The closest value of the Fibonacci sequence is 55. Therefore, the text box margins at the top, bottom, left, and right are all 55px.
[0061] To zoom in or out of the content area, you can jump to the adjacent Fibonacci number based on the closest approximation value mentioned above. For example, when zooming in on the content area, adjust the margin from 5mm to 3mm; when zooming out on the content area, adjust the margin from 5mm to 8mm.
[0062] 2. Calculation of content area height
[0063] Content area height = Print media height - Top margin - Bottom margin
[0064] When the print media is 30mm high and the margin is 5mm: content area height = 30mm - 5mm - 5mm = 20mm.
[0065] When the print media is 40mm high and the margin is 8mm: content area height = 40mm - 8mm - 8mm = 24mm.
[0066] 3. Calculation of content area width
[0067] Content area width = print media width - left margin - right margin
[0068] When the print media is 40mm wide and the margin is 5mm: the content area width = 40mm - 5mm - 5mm = 30mm.
[0069] When the print media is 80mm wide and the margin is 8mm: the content area width = 80mm - 8mm - 8mm = 64mm.
[0070] 4. Determining text line spacing
[0071] Line spacing = font size × 1.618 (golden line spacing) or font size × 1.5 (Fibonacci line spacing, close to 3:2 or 5:3).
[0072] For example, when the font size is 5pt (approximately 1.76mm), the line spacing is set to 2.8mm (1.76×1.618).
[0073] 5. Determining Text Alignment
[0074] When there are 1 to 2 lines of text, use vertical and horizontal center alignment; when there are more than 2 lines of text, use left alignment and vertical and horizontal center alignment.
[0075] Example 3
[0076] like Figure 4 As shown, automatic layout for a single text box plus an image or barcode:
[0077] 1. Calculation of content area margins
[0078] Similar to Example 2, the Fibonacci sequence is used to determine the margins. For example, when the print media size is 40mm wide × 30mm high, the margin is 5mm.
[0079] 2. Calculation of content area width
[0080] Content area width = print media width - left margin - right margin. For example, if the print media width is 40mm and the margin is 5mm, the content area width = 40mm - 5mm - 5mm = 30mm.
[0081] 3. Separation of images / barcodes from text boxes
[0082] Content area height = Print media height - Top margin - Bottom margin. For example, if the print media height is 30mm and the margin is 5mm, the content area height = 30mm - 5mm - 5mm = 20mm.
[0083] Choose a layout scheme based on the number of characters:
[0084] Layout option A (text ≤ 5, text-based + image):
[0085] The text box height is approximately 11mm (30mm x 0.382). The text is top-aligned.
[0086] The height of the barcode / image area is 20mm - 11mm = 9mm, and the size of the barcode / image is the width of the content area × 9mm. The spacing between the text box and the barcode / image is 0. The text automatically scales to the appropriate size based on the width of the content area.
[0087] If the number of characters is greater than 5, automatically switch to layout scheme B.
[0088] Layout option B (more than 5 characters, primarily images with text descriptions):
[0089] Barcode / image area height = 30mm × 0.382 ≈ 11mm.
[0090] The text area height is 20mm - 11mm = 9mm, and the text is bottom-aligned.
[0091] The spacing between the text box and the barcode / image = (content area height - content area height × 0.382) × 0.382. For example, when the content area height is 20mm, the spacing = (20mm - 20mm × 0.382) × 0.382 ≈ 3mm.
[0092] 4. Text alignment: Center aligned horizontally and vertically.
[0093] Example 4
[0094] like Figure 5 As shown, the double text boxes are automatically formatted:
[0095] 1. Calculation of content area margins
[0096] Similar to Example 2, the Fibonacci sequence is used to determine the margins. For double text boxes, approximately 80% of the use cases involve a large amount of text; therefore, the actual layout is enlarged by one level by default.
[0097] For example, when the print media size is 40mm wide × 30mm high, the baseline margin value is 5.73mm. The closest value of the Fibonacci sequence is 5. Enlarging one level, we take the adjacent value of 3mm. Therefore, the margins of the text box to the top, bottom, left, and right edges are all 3mm.
[0098] When the print media size is 80mm wide × 40mm high, the baseline margin is 7.64mm. The closest value of the Fibonacci sequence is 8. When enlarging by one level, take the adjacent value of 5mm.
[0099] 2. Calculation of content area size
[0100] Content area width = print media width - left margin - right margin. For example, when the print media is 40mm wide and the margin is 3mm, the content area width = 40mm - 3mm - 3mm = 34mm.
[0101] Content area height = Print media height - Top margin - Bottom margin. For example, when the print media height is 30mm and the margin is 3mm, the content area height = 30mm - 3mm - 3mm = 24mm.
[0102] 3. Separating two text boxes
[0103] Two layout schemes are adopted:
[0104] Layout Option A: The title text box is at the top, the text content does not wrap, and the size is adjusted to fit the width of the text box. The height is calculated as (print media height - top margin × 2 - text box spacing) × 0.382. For example, when the print media height is 30mm, the margin is 3mm, and the text box spacing is 3mm, the title text box height is approximately (30mm - 3mm × 2 - 3mm) × 0.382 ≈ 8mm.
[0105] The main text box is at the bottom, and the text content automatically wraps. The size is adjusted to fit the height of the text box, and the height is calculated as (print media height - top margin × 2 - text box spacing) × 0.618. For example, in the example above, the height of the main text box is approximately 13mm (30mm - 3mm × 2 - 3mm) × 0.618.
[0106] Layout Option B: In Option A, the heights of the title text box and the body text box are swapped. That is, the title text box is 13mm high, and the body text box is 8mm high.
[0107] 4. Text box spacing
[0108] The spacing between text boxes is equal to the margin. For example, if the margin is 3mm, the text box spacing is 3mm.
[0109] 5. Text alignment
[0110] Choose center alignment for text that does not need line breaks; choose left alignment for text that needs line breaks.
[0111] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention. In addition, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, features defined with "first," "second," etc., may explicitly or implicitly include one or more of that feature. In the description of this invention, unless otherwise stated, "a plurality of" means two or more.
[0112] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation", "connection", and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal connection of two components. For those skilled in the art, the specific meaning of the above terms in this invention can be understood through the specific circumstances.
[0113] Components not described in detail in this article are existing technologies.
[0114] While the specific embodiments of the present invention have been described in detail above, the present invention is not limited to the above embodiments. Within the scope of knowledge possessed by those skilled in the art, various changes can be made without departing from the spirit of the present invention, and modifications or variations without creative effort are still within the protection scope of the present invention.
Claims
1. A graphic and text layout method based on the golden ratio and the Fibonacci sequence, characterized in that, The steps include the following: Step 1: Obtain the size information of the printing medium and the text content to be printed; Step 2: Based on the printed carrier size information, calculate the margin reference value based on the golden ratio, and match the margin reference value with the Fibonacci sequence to determine the layout margin; Step 3: Determine the size of the content area based on the layout margins and the size of the printing medium. Step 4: Based on the size of the content area and the text to be printed, determine the font size, line spacing, and alignment to complete the text layout; Step 5: Generate and output the printable dot matrix data based on the layout results.
2. The graphic layout method based on the golden ratio and Fibonacci sequence according to claim 1, characterized in that: Step two, in determining the layout margins, specifically includes: using the smaller value among the print media sizes as the reference size, calculating the product of the reference size and the golden ratio coefficient 0.382, and then dividing by 2 to obtain the margin reference value; comparing the margin reference value with each term in the Fibonacci sequence, and selecting the Fibonacci sequence value that is closest to the margin reference value as the layout margin.
3. The graphic layout method based on the golden ratio and Fibonacci sequence according to claim 2, characterized in that: Step two, in determining the layout margins, also includes: based on the layout margins, and according to the scaling requirements of the content area, jumping to the adjacent Fibonacci sequence value as the adjusted layout margins.
4. The graphic layout method based on the golden ratio and Fibonacci sequence according to claim 1, characterized in that: Step three, determining the size of the content area, specifically includes: Content area height = Print media height - Top margin - Bottom margin; Content area width = Print media width - Left margin - Right margin 5. The graphic and text layout method and method thereof based on the golden ratio and Fibonacci sequence as described in claim 1, characterized in that: Step four involves determining the line spacing by multiplying the font size by the golden ratio value of 1.618 to obtain the golden line spacing; or by multiplying the font size by 1.5 to obtain the Fibonacci line spacing.
6. The graphic and text layout method and method thereof based on the golden ratio and Fibonacci sequence as described in claim 1, characterized in that: Step four, determining the alignment method, specifically includes: When the text consists of 1 to 2 lines, use both vertical and horizontal center alignment. When the number of text lines is greater than 2, use left alignment and top / bottom center alignment.
7. The graphic and text layout method and method thereof based on the golden ratio and Fibonacci sequence as described in claim 1, characterized in that: When the layout content includes both text boxes and images or barcodes, step four further includes: determining the layout scheme based on the number of characters. When the number of characters is less than or equal to 5, the first layout scheme is adopted: the height of the text box occupies the golden ratio of 0.382 of the height of the content area, the image or barcode area occupies the remaining height, and the spacing between the text box and the image or barcode area is 0. When the number of characters is greater than 5, the second layout scheme is adopted: the height of the image or barcode area occupies the golden ratio of 0.382 of the content area height, the text box occupies the remaining height, and the distance between the text box and the image or barcode area is (content area height - content area height × 0.382) × 0.
382.
8. The graphic and text layout method and method thereof based on the golden ratio and Fibonacci sequence as described in claim 1, characterized in that: When the layout content includes a title text box and a body text box, step four further includes: after determining the height of the content area, dividing it using one of the following layout schemes: First layout scheme: The title text box is at the top, with a height of (print media height - top margin × 2 - text box spacing) × 0.382; the body text box is at the bottom, with a height of (print media height - top margin × 2 - text box spacing) × 0.
618. Second layout scheme: Swap the heights of the title text box and the body text box in the first layout scheme.
9. A graphic layout system based on the golden ratio and the Fibonacci sequence, characterized in that, include: The information acquisition module is used to acquire the size information of the printing medium and the text content to be printed; The margin calculation module is used to calculate the margin reference value based on the golden ratio according to the size information of the printing carrier, and match the margin reference value with the Fibonacci sequence to determine the layout margin; The content area determination module is used to determine the size of the content area based on the layout margins and the size information of the printing carrier; The text layout module is used to determine the font size, line spacing, and alignment based on the size of the content area and the text content to be printed, and to complete the text layout. The print output module is used to generate and output print dot matrix data based on the layout results.
10. A printer, characterized in that, include: The voice input module is used to collect the user's voice input. The communication module is used to upload the voice to a cloud server for voice recognition and to receive the text content returned after recognition. Furthermore, the graphic layout system based on the golden ratio and Fibonacci sequence as described in claim 9 is used to automatically layout and print the text content.
