A method, apparatus, electronic device, and storage medium for the column-based typesetting of ancient-style genealogy book pages.
By using a column-based quantitative typesetting method, a unified column coordinate system is constructed and ancient genealogy pages are generated according to the genealogy style rules. This solves the problems of font loading race and poor reflow performance in existing technologies, and achieves consistent ancient genealogy output across platforms, supporting flexible switching between multiple styles.
Patent Information
- Application Number
- CN202611267154.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-20
- Publication Date
- 2026-11-17
AI Technical Summary
Existing technologies for automatic typesetting of ancient books and genealogies suffer from problems such as font loading race conditions leading to misalignment, poor reflow performance, inconsistent output across multiple platforms, and the need to rewrite typesetting logic when expanding the style. They cannot ensure the determinism and cross-platform consistency of layout, connection and pagination results without relying on rendering measurements.
The column-based quantitative layout method is adopted. By setting a uniform column width for the entire spectrum, a column coordinate system is constructed. The spectrum layout is generated by pure arithmetic according to the alignment rules and connection rules of the genealogy system. A uniform page model is output. Each rendering end only draws according to the coordinates and does not perform layout calculations. It supports the plug-and-play switching of multiple genealogy systems.
Completely eliminates font loading race conditions and misalignment, improves reflow performance to millisecond level, achieves cross-platform output consistency, conforms to ancient book printing standards, and supports seamless switching between multiple lineage styles.
Smart Images

Figure CN123115135A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer automatic typesetting technology, specifically to a method, apparatus, electronic device, and computer-readable storage medium for automatically typesetting structured genealogical data into ancient-style genealogical pages in the form of ancient book scrolls (including various lineage styles such as Suzhou-style hanging silk and classical European style). Background Technology
[0002] Genealogies are documents that record family lineages and the deeds of individuals. Traditional genealogies (or genealogical records) adopt the format of ancient books: the pages are in units of cylindrical leaves (one leaf with two sides, folded and bound), and the layout includes elements such as the page frame, text center, fishtail, columns, and leaf numbers. The text is arranged vertically and read from right to left. There are various traditional styles of lineage charts, such as the Suzhou-style vertical line chart (with vertical lines hanging down, the chart and biography integrated, and fathers and sons connected by horizontal lines) and the classical European style (generations are arranged horizontally, and fathers and sons are not connected by lines, but separated by fixed horizontal lines). Automatically arranging structured genealogical data (members, relationships, brief introductions, and section manuscripts) into the above-mentioned ancient book format is a key technology in genealogy digitization.
[0003] Existing automatic typesetting solutions can be broadly categorized into two types:
[0004] The first category is document flow plus rendering measurement schemes. This type of scheme first renders the content on the page or a hidden container (such as the browser DOM or HTML template), then measures the actual coordinates of each element using the rendering engine, and calculates pagination and connection positions accordingly. For example, Chinese patent CN110110270B discloses a method for generating large-scale genealogical charts in parallel processing, which writes personal information into an HTML template and uses the browser kernel to merge and render the genealogical chart. Chinese patent application CN111797056A discloses a method for generating vectorized family trees, which uses a bibliographic generation scheduling algorithm and a pylon diagram generation scheduling algorithm, combined with an HTML template to generate bibliographic files and pylon diagram files respectively, and then converts and merges them into a family tree. Another example is Chinese patent CN110532257B, which discloses a method for visualizing family tree data, which determines the member position array by traversing a multi-branch tree and then visualizes it. This type of scheme has the following inherent drawbacks:
[0005] 1. Font loading race conditions cause misalignment. Chinese typesetting fonts (especially vertical Song and Kai fonts) are large and load slowly. Measurements taken before the font is fully loaded will yield the coordinates of the reverted font. By the time the font is loaded, the actual position of the element has changed, causing lines to fail to align with preset ports, and causing misalignment between column boundaries and page boundaries. This problem is particularly prominent in vertical ancient book typesetting scenarios.
[0006] 2. Measurement is rendering, and performance deteriorates with scale. In this type of solution, every parameter adjustment (font size, column width, style change) requires a complete re-render before measurement. When the family tree reaches hundreds or even thousands of people, the re-rendering time is significantly longer, and the measurement results are unstable due to the rendering environment (browser version, system font, resolution).
[0007] 3. Inconsistent output across multiple platforms. Previews are typically rendered on the browser side, while exported print documents (such as PDFs) are rendered separately on the server side. These two rendering and measurement paths are independent, and the same input often results in inconsistencies in page margins and line positions between preview and export, making it difficult to meet the "what you see is what you get" publishing requirements.
[0008] The second type is the pre-set template application scheme. This type of scheme pre-sets several layout templates (such as the method for inputting, formatting, and outputting genealogical information based on a webpage display disclosed in Chinese patent application CN115146203A). Users select a template based on the content characteristics and fill in the content. This type of scheme has a rigid format and cannot express the leaf and column relationships, the five-generation naming convention, or the "see after" annotations found in ancient genealogical texts, nor can it guarantee cross-end consistency.
[0009] Furthermore, the typesetting rules of both of the above schemes are hard-coded and coupled with the specific style. The typesetting logic needs to be rewritten for each lineage style that is supported, and it is impossible to switch styles by replacing the rule set under the same coordinate system.
[0010] Therefore, how to completely determine the layout, connections, and pagination results of genealogical data before arrangement without relying on any rendering measurements, ensuring consistent output from multiple rendering ends, and supporting multiple genealogical systems with the same coordinate system is a technical problem that urgently needs to be solved in this field. Summary of the Invention
[0011] I. Purpose of the Invention
[0012] This invention aims to provide a method, apparatus, electronic device, and storage medium for the column-based typesetting of ancient-style genealogy pages, in order to solve the technical problems in existing rendering and measurement schemes, such as font loading race conditions leading to misalignment, poor reflow performance, inconsistent output across multiple terminals, and the need to rewrite the typesetting logic for style expansion.
[0013] II. Technical Solution
[0014] To achieve the above objectives, the first aspect of the present invention provides a method for quantitatively formatting the columns of a traditional Chinese genealogy book, comprising the following steps:
[0015] S1. Set a uniform column width for the entire spectrum and construct a column coordinate system with the column as the basic unit of measurement, where the horizontal axis is the column number and the vertical axis is the pixel row height; divide the nodes in the spectrum data into the name area and the introduction area. The name area occupies 1 column, and the introduction area occupies k columns according to its content, where k is a positive integer.
[0016] S2. According to the alignment rules corresponding to the selected lineage system, recursively calculate the column coordinates of each node with the column number as the basic unit; where the width of the node is the larger value between its own width and the sum of the widths of all its offspring, so that the horizontal span of the parent node covers the horizontal span of its subtree.
[0017] S3. Divide the content area of the cotyledon into generation zones in the vertical direction according to the preset generation number N. The vertical coordinate of the top of the i-th generation is the product of i and the zone height, so that the vertical position of the nodes of the same generation on any cotyledon is consistent. N is an integer greater than 1.
[0018] S4. Generate the spectral lines using pure arithmetic based on the column coordinates and the vertical coordinates of the generation top, according to the connection rules corresponding to the selected pedigree system.
[0019] S5. Divide the global column coordinate sequence into cylindrical leaves according to the column boundary diversion rule: the leaf boundary always falls on the column boundary, and the node content is continuously arranged across the leaf at the column boundary.
[0020] S6. Output the layout result as a unified page model independent of the rendering end. The unified page model records the coordinates of each text and line. Input the unified page model into multiple rendering ends, including at least two of the following: bitmap canvas rendering end, document object model rendering end, and vector document rendering end. Each rendering end only draws according to coordinates and does not perform layout calculations.
[0021] In an alternative implementation:
[0022] When the genealogical system is the Soviet-style vertical line system, the alignment rule is the right-edge alignment rule: the name zone column number of the parent node is equal to the right-edge column number of its child tree, and the right-edge column number of the child tree is equal to the name zone column number of its eldest child; the node width is the larger of 1 + k columns, the width of its offspring, and the sum of the number of columns between siblings. The connection rules are as follows: for a single child, a line is drawn vertically downwards from the center of the parent's name zone column; for multiple children, a line is drawn vertically downwards from the center of the parent's name zone column to the horizontal bar line, extends horizontally through the horizontal bar line, and then vertically upwards to the center of each child's name zone column. Furthermore, when the horizontal bar line crosses the fold of the page, it is cut into left and right segments at the edges of the page on both sides of the fold without crossing the fold; the endpoints of each connection line terminate at the outer edge of the name zone.
[0023] When the phylogenetic system is the classical European system: no connection is generated between parent and child nodes; a fixed horizontal line is drawn at the boundary of adjacent generation zones, and N generation zones are divided into N intergenerations by N-1 fixed horizontal lines, with each node arranged in the corresponding intergeneration according to its generation.
[0024] Optionally, the minimum starting unit for pagination is a half-leaf; when a node spans a half-leaf, the number of columns in the half-leaf is rounded up according to its starting column number, and the carry-over column number is determined by the product of the rounded result and the number of columns in the half-leaf; sibling columns are omitted when they fall exactly on the starting column boundary of a half-leaf; the name section is moved to the next leaf for layout when the number of remaining columns in the current leaf is less than the preset minimum number of columns.
[0025] Optionally, the content of the introduction area is divided into blocks and arranged in a unified manner according to the number of characters. The block is drawn on the leaf where it falls, and the decorative elements of the name area are drawn only on the leaf where the name area is located.
[0026] Optionally, a preset generation number N is used as a reference. If the last generation node of a reference has descendants, only its name is mentioned. The last generation node is repeated at the beginning of the next reference, and its brief introduction is written. The page number of the transition reference is filled in twice.
[0027] Optionally, the table of contents page numbers are generated iteratively with convergence: the table of contents sections are first placed with zero-occupying leaves, and after the arrangement is finalized, the number of leaves occupied by the table of contents itself is calculated and the starting leaf numbers of the subsequent sections are rearranged. This process is repeated until the number of leaves occupied converges. Sections before the table of contents do not participate in the translation.
[0028] Optionally, the profile text is automatically generated from structured member information according to preset synthesis rules, and the profile text of the individual and their associated spouse and parents is recalculated when any member information is changed.
[0029] The second aspect of the present invention provides a column-based typesetting device for ancient genealogy pages, comprising a column coordinate system construction module, a column coordinate calculation module, a generation zone division module, a connection generation module, a pagination module, and a unified model output module, each module being used to perform the corresponding steps in the above method.
[0030] A third aspect of the present invention provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the above-described method.
[0031] A fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the above-described method.
[0032] III. Beneficial Effects
[0033] Compared with the prior art, the present invention has the following beneficial effects:
[0034] 1. Completely eliminate misalignment caused by font loading race conditions. All coordinates of layout, links, and pagination are determined by pure arithmetic of column numbers and column widths before layout. No rendering measurement interfaces are called during the layout process. Whether the font has finished loading does not affect the coordinate results. Link ports are strictly aligned with column and page boundaries.
[0035] 2. Reflow performance and rendering desensitization. After adjusting any parameters (font size, column width, style, calendar, daughter's book transmission switch, etc.), the entire score can be reflowed in milliseconds without re-rendering; in actual tests, the entire score of fifty to nearly one hundred people was returned in milliseconds.
[0036] 3. Consistent output across platforms. Preview and export consume the same unified page model. Rendering ends such as bitmap canvas, document object model, vector PDF, and vector SVG only perform coordinate drawing and zero layout calculations. The output results are verified to have zero mismatch, achieving true WYSIWYG.
[0037] 4. Format is pluggable. Alignment and connection rules are organized into a replaceable set of rules according to the phylogenetic system. The column coordinate system, generation zone division and column boundary pagination mechanism are fully reused in the Soviet style vertical lines, classical European style and other formats. New formats do not require changes to the coordinate system and pagination mechanism.
[0038] 5. Conforms to the standards of ancient book printing. The column division ensures that the introduction is continuous across pages at the column boundaries and that the name section is not isolated; the rules such as mentioning five generations at a time and referring to the following notes, one category per page in the page center, and automatic merging of page center volume numbers ensure that the output pages conform to the traditional printing standards in terms of format. Attached Figure Description
[0039] Figure 1 is the main flowchart of the column-based quantitative layout method;
[0040] Figure 2 is a structural block diagram of the column-based typesetting device;
[0041] Figure 3 is a schematic diagram of recursively calculating the right-edge aligned column number using the column coordinate system;
[0042] Figure 4 is a schematic diagram of the equal division of generational zones;
[0043] Figure 5 is a schematic diagram of generating lines using pure arithmetic according to the Soviet-style vertical wire system;
[0044] Figure 6 is a schematic diagram of the column boundary pagination rules and the two-pass page number backfilling method;
[0045] Figure 7 is a schematic diagram of the classical European style of genealogy arrangement. Detailed Implementation
[0046] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only for explaining the present invention and are not intended to limit the present invention.
[0047] Example 1: Construction of the Grid Coordinate System
[0048] In this embodiment, the genealogical data is input in the form of a structured member tree, and each node (member) carries attributes with a unified source: name, gender, birth and death, brief introduction text, spousal relationship, child relationship, special relationship annotation (adoption / adoption / concurrent adoption / top son), etc.
[0049] Set a uniform column width COL_W (e.g., 52 pixels) across the entire spectrum, and construct a column coordinate system using columns as the basic unit of measurement: the horizontal axis is the column number (an integer, increasing from right to left; corresponding to the reading order of ancient books, with smaller column numbers on the right), and the vertical axis is the pixel row height. The horizontal coordinate of any text or line is determined by multiplying the column number by the column width and adding an offset. No rendering measurement interface (such as the browser's element measurement API) is called throughout the typesetting process. No special typesetting logic is needed for the fold lines within the text area: when the horizontal coordinate exceeds the width of the right half of the page, the fold line width is uniformly added (jump function fx(x) = x ≥ halfW ? x + foldW : x). For typesetting, the fold line is simply a pure coordinate offset.
[0050] Each node is divided into a name area and a description area: the name area contains the member's name, occupying 1 column; the description area contains biographical information (style name, birth and death dates, spouse, children, etc.), occupying k columns based on the amount of content. k is determined as follows: subtract the preset line gap (i.e., the line height occupied by the horizontal bar) from the band height bandH to obtain the available height infoH of the description area; divide infoH by the character spacing and round down to obtain the number of lines that each column can hold perCol; k is determined by the number of lines of description content and perCol, i.e., k = ⌈number of lines / perCol⌉ and not less than 1.
[0051] Example 2: Pluggable organization of style rule sets
[0052] The alignment rules (Examples 3 and 5) and connection rules (Examples 4 and 5) are organized into a replaceable rule set according to the phylogenetic system: the column coordinate system, generational division (Example 6), column boundary flow pagination (Example 7), and unified page model output (Example 15) are common and unchanging mechanisms for all styles; when switching styles, only the alignment rules and connection rules are replaced, and the coordinate system and pagination mechanism are not modified in any way. Thus, the same engine can output both Soviet-style vertical silk notation pages and classical European-style notation pages.
[0053] It should be noted that the right-edge alignment, straight horizontal bars, and generational horizontal columns are all traditional formats of the corresponding styles and belong to existing genealogical standards, and are not created by this invention. The contribution of this invention is to directly generate the genealogical layout, connection and pagination results that conform to the above traditional formats using column coordinate system and pure arithmetic expressions, without the need for rendering and measurement throughout the typesetting process, and to make the output of multiple rendering terminals consistent.
[0054] Example 3: Right-edge alignment recursion of the Soviet-style drooping wire system
[0055] When the genealogy is in the Soviet-style vertical line system, the column numbers are calculated recursively from bottom to top according to the right edge alignment rule:
[0056] Leaf node (no children): width W = 1 + k columns; Parent node: W = max(1 + k, Σ child width + sibGap × (number of children − 1)), where sibGap is the number of sibling columns; and the parent node's name zone column number = the right edge column number of the subtree = the name zone column number of the eldest child.
[0057] Thus, the parent name column, its right edge, and the eldest child name column are aligned, forming the Suzhou-style vertical scroll layout feature of "parent on the right of child, and elder on the right among siblings" (see Figure 3). The partition between sibling nodes is omitted when it falls exactly on the starting boundary of a half-leaf to avoid empty partitions at the beginning of a half-leaf.
[0058] The ordering rules for sibling nodes of the same generation are: sons first, then daughters; within the same gender, the eldest comes first; the eldest daughter who is the heir is placed at the beginning of the daughters' group. Since the reading direction is opposite between the ancient text rendering end and the tree diagram rendering end, the array order is adapted to the reading direction of the rendering end: the array in the ancient text rendering end is in ascending order (elder brother before younger brother), and the array in the tree diagram rendering end is in descending order, so that in both rendering results, each generation is arranged from right to left according to the same seniority order.
[0059] Example 4: Pure Arithmetic Generation of Connections in the Soviet-Style Vertical Wire System
[0060] In the Soviet-style vertical line system, based on the column number and the vertical coordinate of the top, the connection is generated in two cases using pure arithmetic (see...). Figure 5 ):
[0061] Single child: A vertical line is drawn from the center of the parent name area to the center of the child name area, called a straight line; Multiple children: A vertical line is drawn from the center of the parent name area to the horizontal bar line (a fixed row height between the bottom of the parent and the top of the child), then extends horizontally through the horizontal bar line to directly above the center of each child name area, and then vertically upwards to the center of each child name area.
[0062] Two detailed rules for connecting lines: First, when a horizontal line crosses the fold of the core of a page, it is cut into two segments at the edges of the core on both sides of the fold, without crossing the fold, in order to adapt to the physical form of the folded binding of the page; Second, the endpoints of each connecting line end at the outer edge of the name zone (for example, the top of the name circle, with the vertical coordinate of the endpoint taken as the top edge of the name zone minus the radius of the name circle), so that the connecting line just touches the name zone without penetrating the text.
[0063] The coordinates of all endpoints of the connection are arithmetic expressions of column number and height, independent of any measurement; the port (name zone column center) is part of the text coordinate expression, so the connection and text are naturally aligned.
[0064] Example 5: Genealogical Arrangement in Classical European Style
[0065] When the phylogenetic system is in the classical European style (see Figure 7): no connections are generated between parent and child nodes; fixed horizontal lines are drawn at the boundaries of adjacent generation zones, and N generation zones are divided into N generations by N-1 fixed horizontal lines (for example, when N=5, 5 generations are divided by 4 fixed horizontal lines). Each node falls into the corresponding generation according to its generation, and the horizontal position is still determined by the column coordinate system of Example 1 according to the column number. Kinship is not expressed by connections, but by column affiliation: the horizontal span of the parent node is still recursively synthesized according to the width of all its offspring, so that the parent name area covers all columns of its subtree (when there are multiple children, the parent span = the sum of the spans of each child plus the sibling column), and the older generation is on the right. The column coordinate system, generation zone division and column boundary pagination mechanism are completely shared with the Soviet vertical line system, only the alignment details and connection rules are replaced according to the system.
[0066] Example 6: Generation Zone Division
[0067] The content area of the cotyledon is divided vertically into generation bands according to a predetermined number of generations N (e.g., N=5, corresponding to a five-generation-per-section format): band height bandH = content area height / N. The ordinate of the apex of the i-th generation = i × bandH (0 basis). The node height is fixed to the band height, and the apex of a child node = the apex of the parent node + bandH. Thus, the vertical position of nodes of the same generation on any cotyledon is strictly consistent (see Figure 4), and the introduction area never crosses the lower edge of its generation band.
[0068] Example 7: Column-based page navigation
[0069] Pagination is executed according to the column boundary splitting rules (see Figure 6):
[0070] 1. Leaf boundary always falls on the fence boundary: Each leaf tube contains exactly P = 2C fences (C is the number of half-leaf fences), and the right and left boundaries of the leaf tube are both fence boundaries;
[0071] 2. The minimum starting unit is half a leaf: when spanning half a leaf, the number of columns in the half leaf is rounded up according to the starting column number of the node, and the carry-over column number is determined by the product of the rounded result and the number of columns in the half leaf.
[0072] 3. Introduction Continuous Across Leaves: The introduction area is cut at the column boundary. The cutting and column placement are controlled by the number of characters (each block does not exceed the product of the preset number of columns and the number of characters in each column). Vertically, each line contains one character, and spaces occupy a line. The text at the cross-leaf section is not cut or reduced. The introduction is drawn on the leaf section where the block falls. If the name section is not on the same leaf, its continuation column is still drawn on the same leaf. The decorative elements of the name section (name circle, label, etc.) are only drawn on the leaf section where the name section is located.
[0073] 4. Names in an isolated position: When the number of remaining columns for a name in the current leaf is less than the preset minimum number of columns (e.g., 3 columns), the entire name in the current leaf will be moved to the next leaf to avoid the name being isolated on the leaf edge.
[0074] Example 8: Filling in page numbers by extracting points and using the two-pass method
[0075] Using a preset generation number N as a unit (e.g., five generations per unit): if the last generation node of a unit has descendants, only their name is mentioned in this unit (without a brief introduction); the last generation node is repeated at the beginning of the next unit with a complete brief introduction, realizing the "repeated appearance at the beginning of the unit" format in genealogy. Optionally, subsequent units can be arranged closely in the last column of the preceding unit: one column apart when they are in the same half-leaf, no spacing when they fall exactly at the half-leaf boundary, and if the remaining columns are insufficient to accommodate the colophon column plus two columns, the space is given to the next half-leaf.
[0076] The transition notes ("See Next Volume X" and "Continued from Previous Volume X") are generated using a two-stage method: During the first layout, placeholders are written at the locations where transitions are needed; after all the pages are arranged and the page numbers are determined, the placeholders are filled back into the target page numbers one by one during the second layout. This ensures that the page number notes are strictly consistent with the actual layout and do not become misaligned with additions or deletions of content.
[0077] Example 9: Iterative convergence of table of contents page numbers and genealogical volume division
[0078] The entire genealogy comprises multiple sections (preface, explanatory notes, origins, lineage, biographies, literary works, etc.). The page numbers of the table of contents depend on the overall layout of the book, and the page number of the table of contents itself changes the page numbers of subsequent sections, creating a circular dependency. This embodiment uses iterative convergence to generate the page numbers of the table of contents: during the first layout, the table of contents sections occupy zero page positions; after the layout is complete, the page number of the table of contents sections is calculated; the starting page numbers of each section following the table of contents are shifted according to this page number and rearranged; the above calculation and shifting are repeated until the page number of the table of contents converges (in actual testing, no more than 4 rounds); sections located before the table of contents (such as the title page and preface) do not participate in the shifting, and their page numbers are not affected by the page number of the table of contents.
[0079] When the genealogy section exceeds the capacity of a single volume, it is divided into volumes: the volume points are sorted lexicographically according to the ranking path (a path string composed of the seniority numbers of each generation), with elders entering the previous volume first, and contemporaries in seniority order; the general genealogy retains the title of the person dividing the volume but cuts off their subtree, and writes "See next volume X" in small double-column under their name; each volume continues the generation number by generation offset, so that the generation number is continuous across volumes. After the genealogy volume occupies the volume number, the volume number of the subsequent default-numbered volumes is automatically extended; the first page of each volume has a reserved title page in the typesetting engine, into which the genealogy title is injected.
[0080] Example 10: Automatic Synthesis and Linked Recalculation of Transmitted Text
[0081] The biographical information in the introduction section is automatically generated from structured member data according to preset synthesis rules. The synthesis order is: courtesy name, place of origin, birth and death dates, education and employment, handwritten supplements, death and burial details, spouse section, and children section. The spouse section is arranged in the order of marriage; if only the surname is known, it is written as "married to Ms. X"; if the full name is known, it is written directly. The children section is arranged in order of birth, with sons listed first and daughters listed consecutively. The handwritten supplements of members are stored independently and are not overwritten by the automatic synthesis.
[0082] The transmission text is selected using a three-tiered priority system: first, the handwritten manuscript of the genealogy is prioritized; second, the cached text synthesized by the server using the above formula is selected; if neither is available, it is assembled on-site during typesetting. In the lunar calendar mode, the Gregorian calendar synthesis cache is skipped, and the text is assembled on-site according to the lunar calendar to ensure that all transmission dates are in the lunar calendar.
[0083] When any member's information (including name) changes, the profile text of that member and their associated spouse (spouse segment updated accordingly) and associated parents (children segment updated accordingly) are recalculated. When a member is deleted, their associated spouse and associated parents are collected first, and then recalculated one by one after deletion. This ensures that the text is consistent throughout the score, eliminating the need for manual modification at each location.
[0084] Example 11: Modeling and Dual-Track Labeling of Special Clan Relationships
[0085] For traditional patriarchal relationships such as adoption, succession, concurrent adoption, and lineage succession, this embodiment adopts the following modeling: An adopted person automatically creates a mirror node in their biological father's position. The mirror node only records their name and is marked "adopted," without continuing their lineage or recording their biography. The real node is attached to the adoptive father's position and marked "inherited," with normal continuation of lineage and recording of their biography. Concurrent adoption members establish mutually linked dual files, with birth and death dates and gender maintained synchronously in both files, while names, spouses, and children are independent. Daughters who have been adopted as lineage successors are listed first in the daughters' group with the adoption marker.
[0086] Short annotations on the genealogy (such as "adopted," vertically placed on one side of the name section) and detailed biographical texts (such as "adopted by Mr. X," "Mr. X's second son adopted," with the entry being the daughter section) are automatically generated by the same data model, forming a dual-track annotation. The ranking in the detailed text ("which son") is automatically derived according to the order of the biological father's sons and must be written. Adoption and concurrent adoption are mutually exclusive; when one side's relationship is deleted, the other side is automatically unattached and becomes the legitimate heir.
[0087] Example 12: Rules for the Layout of Ancient Manuscripts
[0088] The text sections, including the preface, explanatory notes, and biographies, are arranged according to the writing rules of ancient books.
[0089] Line tail / head avoidance: Sentence terminators and closing brackets shall not be placed at the start of a column (prefer compacting at column tail without overflow), and opening brackets shall not be placed at the column tail; Non-separable pairs: Ellipses and dashes shall not be split, and numbers and units (year, month, day, hour, minute, second, yuan, volume, leaf, age, generation, etc.) shall be moved as an integral atomic group; Two-column interlinear note: Small characters are arranged in two columns within one column grid, the right column is read first, short notes are evenly divided between two columns with the right column having one more character, the main text after the note is adsorbed back to the main text grid line, and interlinear notes are divided into two levels: compact (half-character square) and slender (half the horizontal width of long-body characters); Hanging indent: For entries starting with the leading character "一", all subsequent paragraphs and continued columns shall be indented by a fixed character position, and the indent is automatically cleared for the next leading entry; Signature / inscription: Inscription text is arranged across columns, each column is independently bottom-anchored to the grid within the column, extremely long text automatically continues to the next column with the last column bottom-aligned; Simplified-to-Traditional conversion: One-click Simplified-to-Traditional conversion is performed at the word level on complete sentences before typesetting (the multi-character ambiguity of words like "乾 / 幹" cannot be resolved on individual character coordinate units), original text segments marked with @…@ are first extracted as placeholders and restored after conversion, serving as a rescue channel for conversion errors.
[0090] Embodiment Thirteen: Parametric Automatic Generation of Ancient Book Elements
[0091] Flyleaf: Within the half leaf of the specified folded sheet, the chronicle text is placed flush to the top in the rightmost column, the studio / publishing text is placed bottom-aligned in the leftmost column, and the genealogy name text is centered; The character spacing of the genealogy name text is set to the font size plus 15%, the column spacing is set to the font size plus 25%, the column group width does not exceed the column width minus 8, and the font size is not less than the preset lower limit; The genealogy name is allowed to break across columns, the continued column is to its left, and the entire column group is centered; If the layout width and height exceed the limit, the font size is automatically decreased until the constraints are satisfied.
[0092] Cover: The cover document model is defined by parameter slots (background color, material, subtle pattern, title label, spine, seal, back cover text); Random patterns (such as crackle glaze pattern) generate geometric primitives through a pseudo-random function with a fixed seed, the output is identical for the same parameters and the same seed, ensuring pixel-perfect consistency across multiple generations and multi-end rendering.
[0093] Printed area and fish-tail ornament: The printed area is divided into three zones by anchor points at the height percentage of the folded sheet of the upper and lower fish-tail ornaments, the genealogy name and studio name are centered as a whole, the volume number is top-hung, the leaf number is bottom-hung, the category is centered, one category per leaf, and the volume number in the printed area is automatically merged continuously according to the context within the volume; Multiple styles of fish-tail ornaments are drawn through parametric geometry, and each rendering end distributes and draws according to the style identifier.
[0094] Embodiment Fourteen: Verification, Retry Degradation and Export Anti-Abuse for AI Document Generation
[0095] When generating ancient texts such as genealogical prefaces and explanatory notes using a large language model, a generation-verification-retry-degradation pipeline is executed: after the first generation, structural verification is performed according to the ancient text marking grammar rules (marking pairings, type whitelists); if the verification fails, the error list is fed back to the model for regeneration (up to a preset number of times); if it still fails, the model is marked as degraded and returned, without blocking manual editing; if the model service is unavailable, the business is degraded without interruption.
[0096] The entire book's proofreading adopts a rule-driven architecture: deterministic rules (birth and death logic, required missing fields, generational gaps, duplicate ordering, misuse of generational names, etc.) are used to scan the entire book to generate a machine-readable list of problems, and then the large model translates the list into a natural language report; when the large model is unavailable, the machine text is output directly.
[0097] Anti-abuse measures for exporting electronic books: When placing an order, a snapshot of the layout parameters, section fingerprints, and total number of pages is saved. Upon delivery, the layout is rearranged and compared with the snapshot. If the total number of pages exceeds the order agreement, delivery is refused. During preview rendering, the "draft" watermark is baked into the canvas pixels, making the screenshot unusable for printing.
[0098] Example 15: Unified Page Model and Consistent Rendering Across Multiple Platforms
[0099] All layout results are output as a unified page model (PageModel) independent of the rendering end: coordinate data organized by leaf, recording the content, font, font size, and coordinates of each character, the type and endpoint coordinates of each connection line, and the coordinates of decorative elements such as the page frame, page margin, footer, category, and leaf number. In addition to geometric coordinates, text units also carry rendering semantic tags (unit type, horizontal compression factor, explicit font, and color). The rendering end only distributes and draws according to these tags, without performing any layout calculations. When publicly shared for reading, the server arranges and distributes coordinate data on-site when a visitor opens the link, without pre-generating files, retaining copies, or distributing draft content that is not yet finalized.
[0100] A unified page model is input into multiple rendering platforms for rendering: bitmap canvas rendering (canvas preview), document object model rendering (DOM preview), and vector document rendering (server-side vector PDF export, SVG export). Each rendering platform only performs coordinate drawing, with zero layout calculations, so the output results are consistent across platforms (verified by comparing with the same music book, there is zero coordinate mismatch across platforms).
[0101] Example 16: Apparatus, Equipment and Media
[0102] The column-based quantitative typesetting device of this embodiment (see Figure 2) includes: a column coordinate system construction module, a column coordinate calculation module, a generation band division module, a connection generation module, a pagination module, and a unified model output module, which respectively execute the corresponding steps of the above methods. This device can be deployed on a server (such as a Node.js process), and the client submits genealogy data and receives the unified page model via a network interface.
[0103] Electronic devices include a memory and a processor. The memory stores a computer program, and the processor executes the program to implement the methods described above. A computer-readable storage medium stores the computer program; the medium can be a hard disk, optical disk, flash memory, etc.
[0104] Example 17: Effect Verification
[0105] When the same structured genealogical data (55-person and 97-person genealogies) is input into this embodiment: the entire genealogy rearrangement takes milliseconds; there is no misalignment after rearranging any font size, column width, or style parameters are adjusted; when switching between the Soviet-style vertical scrolling style and the classical European style, the coordinate system and pagination mechanism are reused, and only the rule set is replaced; the coordinates are zero mismatched when comparing the output from four ends: bitmap canvas, document object model, vector PDF, and vector SVG; the output genealogy pages conform to the cylindrical leaf format: the page frame and page center are complete, five generations are mentioned once, the page numbers of the "see after" note are correct, the introduction spans the page continuously, and there are no isolated names in the name section.
[0106] Example 18: Replacement Method
[0107] It should be understood that the specific values and forms in the above embodiments are examples and not limitations: the column width is not limited to 52 pixels and can be any fixed physical size; the preset generation number N is not limited to 5; the preset minimum number of columns for name area space is not limited to 3 columns; the character spacing, column spacing ratio (15%, 25%) and column group width constraint (column width minus 8) of the title page can be other values as needed for the layout; the rendering end is not limited to bitmap canvas, document object model, or vector document, and any rendering end that draws according to coordinates is acceptable; the genealogy system is not limited to the Soviet style and classical European style, and any system that expresses alignment and connection rules using column coordinate system can be included. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the protection scope of this invention.
Claims
1. A method for quantitatively formatting the columns of a traditional Chinese genealogy book, characterized in that... Includes the following steps: S1. Set a uniform column width for the entire spectrum and construct a column coordinate system with the column as the basic unit of measurement, where the horizontal axis is the column number and the vertical axis is the pixel row height; divide the nodes in the spectrum data into a name area and a description area, where the name area occupies 1 column and the description area occupies k columns according to its content, where k is a positive integer; S2. According to the alignment rules corresponding to the selected lineage system, recursively calculate the column coordinates of each node with the column number as the basic unit; where the width of the node is the larger value between its own width and the sum of the widths of all its offspring, so that the horizontal span of the parent node covers the horizontal span of its subtree. S3. Divide the content area of the cotyledon into generation zones in the vertical direction according to the preset generation number N. The vertical coordinate of the top of the i-th generation is the product of i and the zone height, so that the vertical position of the nodes of the same generation on any cotyledon is consistent. N is an integer greater than 1. S4. According to the connection rules corresponding to the selected lineage system, generate the lineage connection using pure arithmetic based on the column coordinates and the vertices of the generation. S5. Divide the global column coordinate sequence into cylindrical leaves according to the column boundary diversion rule: the leaf boundary always falls on the column boundary, and the node content is continuously arranged across the leaf at the column boundary. S6. Output the layout result as a unified page model independent of the rendering end. The unified page model records the coordinates of each text and line. Input the unified page model into multiple rendering ends. The multiple rendering ends include at least two of the following: bitmap canvas rendering end, document object model rendering end, and vector document rendering end. Each rendering end only draws according to the coordinates and does not perform layout calculations.
2. The column-based typesetting method according to claim 1, characterized in that, The lineage system is the Soviet-style vertical line system, and the alignment rule is the right-edge alignment rule: the name zone column number of the parent node is equal to the right-edge column number of its subtree, and the right-edge column number of the subtree is equal to the name zone column number of its eldest child; the node width is the larger of the following two values: 1 + k columns, the sum of the width of its children and the number of columns between siblings.
3. The column-based typesetting method according to claim 2, characterized in that, The connection rules corresponding to the Suzhou-style hanging wire system are as follows: when there is only one child, draw a vertical line downward from the center of the parent's name area; when there are multiple children, draw a vertical line downward from the center of the parent's name area to the horizontal bar line, extend horizontally through the horizontal bar line, and then draw a vertical line upward to the center of each child's name area.
4. The column-based typesetting method according to claim 3, characterized in that, When the horizontal bar crosses the fold of the core of the printing plate, it is cut into two segments at the edges of the core on both sides of the fold, without crossing the fold; the endpoints of each connecting line end at the outer edge of the name zone.
5. The column-based typesetting method according to claim 1, characterized in that, The phylogenetic system is a classical European system: no connection is generated between parent and child nodes; a fixed horizontal line is drawn at the boundary of adjacent generation zones, and N generation zones are divided into N intergenerations by N-1 such fixed horizontal lines, with each node arranged in the corresponding intergeneration according to its generation.
6. The column-based typesetting method according to claim 1, characterized in that, The number of columns k occupied by the introduction area is determined as follows: the available height of the introduction area is obtained by subtracting the preset line spacing from the band height; the number of lines that each column can accommodate is obtained by dividing the available height by the character spacing and rounding down; k is determined by the number of lines of the introduction content and the number of lines that each column can accommodate; and the node height is fixed as the band height, and the top ordinate of the child node is equal to the top ordinate of the parent node plus the band height.
7. The column-based typesetting method according to claim 1, characterized in that, The minimum starting unit for pagination is a half-leaf; when a node spans a half-leaf, the number of columns in the half-leaf is rounded up according to the starting column number of the node, and the carry-over column number is determined by multiplying the rounded result by the number of columns in the half-leaf; the gap between sibling nodes is omitted when it falls exactly on the starting column boundary of a half-leaf; when the remaining number of columns in the name area on the current leaf is less than the preset minimum number of columns, the name area is moved to the next leaf for pagination.
8. The column-based typesetting method according to claim 1, characterized in that, The content segmentation and placement of the introduction area are uniformly controlled by the number of characters: each segment does not exceed the product of the preset number of columns and the number of characters in each column, each column is arranged vertically with one character per line, and a space occupies one line; the segment is drawn on the leaf where it falls, and the introduction continuation column is still drawn on the leaf when the name area is not on the same leaf, and the decorative elements of the name area are only drawn on the leaf where the name area is located.
9. The column-based typesetting method according to claim 1, characterized in that, It also includes the following rules for extraction windows: each extraction is based on the preset generation number N; if the last generation node of an extraction has descendants, only its name is mentioned. The next section will reiterate this last node and include a brief introduction.
10. The column-based typesetting method according to claim 9, characterized in that, It also includes transfer pointers, the page numbers of which are generated in two passes: during the first pass, placeholders are used to mark the transfer positions, and after all the pages are arranged, the placeholders are filled back into the target page number.
11. The column-based typesetting method according to claim 1, characterized in that, It also includes the iterative convergence generation of the table of contents page numbers: during the first layout, the table of contents sections occupy zero leaf space, and after the layout is completed, the leaf space of the table of contents section is calculated; the starting leaf numbers of each section after the table of contents are shifted according to the leaf space of the section and the layout is rearranged; the above calculation and shifting are repeated until the leaf space of the section converges; the sections before the table of contents do not participate in the shifting.
12. The column-based typesetting method according to claim 1, characterized in that, The sorting rules for sibling nodes of the same generation are: sons first, daughters second, and elders of the same gender first; daughters who are the eldest sons of the main family are placed at the beginning of the daughter group; and the array order is adapted to the reading direction of the rendering end, so that the offspring in each rendering result are arranged from right to left according to the sorting rules.
13. The column-based typesetting method according to claim 1, characterized in that, The profile text in the profile area is automatically generated from structured member data according to preset synthesis rules. The synthesis rules are spliced in the order of font size, place of origin, birth and death, education and employment, handwritten supplements, death and burial, spouse section, and children section. When any member's data changes, the profile text of that member and his / her related spouse and parents are recalculated.
14. The column-based typesetting method according to claim 1, characterized in that, Each page has a unique category, meaning one page has one category; the volume number in the volume is automatically merged and consecutive according to the context within the volume.
15. The column-based typesetting method according to claim 1, characterized in that, It also includes the following steps for generating the title page: within the specified half-page of the cylindrical leaf, the date text is placed at the top of the right column, the hall name and colophon text are placed at the bottom of the left column, and the genealogy name text is centered; the character spacing of the genealogy name text is the font size plus 15%, the column spacing is the font size plus 25%, the column group width does not exceed the column width minus 8, and the font size is not less than the preset lower limit value.
16. A grid-based typesetting device for ancient-style genealogy book pages, characterized in that, include: The column coordinate system construction module is used to set a uniform column width for the entire spectrum, construct a column coordinate system with the column as the basic unit of measurement, and divide the nodes in the spectrum data into a name area occupying 1 column and a description area occupying k columns, where k is a positive integer; The column coordinate calculation module is used to recursively calculate the column coordinates of each node according to the alignment rules corresponding to the selected lineage system, with the column number as the basic unit. The width of a node is the larger of its own width and the sum of the widths of all its descendants. The generation zone division module is used to divide the cotyledon content area into generation zones in the vertical direction according to a preset number of generations N. The vertical coordinate of the top of the i-th generation is the product of i and the zone height. The connection generation module is used to generate spectrum connections using pure arithmetic based on the column coordinates and the vertices of the generation, according to the connection rules corresponding to the selected genealogy system. The pagination module is used to divide the global column coordinate sequence into leaflets according to the column boundary flow rules. The leaflet boundary always falls on the column boundary, and the node content is continuously arranged across the leaflet at the column boundary. The unified model output module is used to output the layout result as a unified page model that is independent of the rendering end, and input the unified page model into multiple rendering ends for drawing, so that each rendering end outputs a consistent layout result.
17. An electronic device, characterized in that, It includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the column quantization typesetting method as described in any one of claims 1 to 15.
18. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the column quantization typesetting method as described in any one of claims 1 to 15.
Citation Information
Patent Citations
A method and apparatus for generating large-scale genealogical charts in parallel processing
CN110110270B
A method and system for visualizing genealogy data
CN110532257B
Vectorized family tree book generation method and system
CN111797056A
Method for inputting, typesetting and outputting genealogy information based on webpage display
CN115146203A
