Precise PDF font matching method and system based on multi-dimensional data fusion
Through the multi-dimensional data fusion method, the matching accuracy and speed issues of the PDF editing system in Unicode character set processing are solved, efficient and accurate font matching and copyright compliance are achieved, and the user experience is improved.
Patent Information
- Application Number
- CN202510580809.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-07
- Publication Date
- 2025-09-23
AI Technical Summary
Existing PDF editing systems have limited matching accuracy and speed when processing Unicode extended character sets, and cannot meet users' needs for real-time and consistency. In addition, the dynamic adjustment capability of font metric information is weak, resulting in typesetting dislocation and inconvenient operation.
A multi-dimensional data fusion method is adopted. The data pre-collection layer collects and caches font matching data. The feature calculation layer performs character-by-character scanning and dynamic Unicode segmented font set optimization. The hierarchical decision engine layer performs font matching according to scenario requirements to ensure document visual consistency and copyright compliance.
It achieves efficient and accurate font matching, avoids garbled characters, improves operational efficiency and user experience, and avoids copyright compliance risks.
Smart Images

Figure CN120688441A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of document editing technology, and in particular to a PDF font precise matching method and system based on multi-dimensional data fusion. Background Art
[0002] With the development of society, the Portable Document Format (PDF), as a common document format, has become increasingly common in daily work and life, and the demand for editing PDF documents is increasing. Current PDF editing systems present numerous challenges when editing documents, particularly font matching technology, which remains insufficiently intelligent for multilingual documents and complex typesetting scenarios. Current algorithms have limited matching accuracy and speed when processing the Unicode extended character set, failing to fully meet user requirements for real-time performance and consistency. Furthermore, the dynamic adjustment capabilities of font metric information are limited, resulting in frequent typesetting misalignments and inconvenient operation. Summary of the Invention
[0003] The purpose of the present invention is to provide a PDF font precise matching method and system based on multi-dimensional data fusion, so as to solve the problems that the current algorithm has limited matching accuracy and matching speed when processing the Unicode extended character set, cannot fully meet the user's requirements for real-time performance and consistency, and has weak dynamic adjustment capability of font metric information, resulting in frequent typesetting dislocation and inconvenient operation.
[0004] To achieve the above object, the present invention adopts the following technical solutions: A PDF font accurate matching method based on multi-dimensional data fusion, comprising: The data pre-collection layer collects fonts matching multi-dimensional data sources, caches them, and updates the data during user inactive periods; The feature calculation layer scans the original data character by character, calculates similarity, and optimizes the dynamic Unicode segmented font set; The hierarchical decision engine layer matches fonts based on scenario-based requirements. On the premise of ensuring the visual consistency of the document after user editing, it selects font resources for the user's editing operations and performs embedded operations on the font resources.
[0005] In one embodiment, the data pre-collection layer includes: Collect system global font metric information; Extract PDF metadata; Read the copyright information of the font authorization library; Collect user operation scenarios.
[0006] In one embodiment, the collecting system global font metric information includes: Load all installed TrueType and OpenType font files from memory through the API interface provided by the operating system; Perform in-depth analysis of each font file to extract key metric information; Pay attention to specific parameters to prevent overlapping between text lines; Cache all extracted metrics information.
[0007] In one embodiment, extracting PDF metadata includes: For each PDF document, read the character map of the embedded font and parse the mapping relationship between character codes and glyphs; Parse the font descriptor of each font and extract attribute information from it; Get the ToUnicode table, which provides a mapping from character codes to standard Unicode characters and supports text search, copy and paste functions; understand and analyze coded information; Caches all extracted font metadata information.
[0008] In one embodiment, the feature calculation layer includes: The system is deeply integrated with the Fontconfig library to perform a detailed scan of each character in the specified Unicode block and build a set of fonts supported by the system; Dynamic Unicode segmented font set optimization algorithm; Combined with the system global font metric information collection and the dynamic Unicode segmented font set optimization algorithm, the generated font mapping table is sorted by similarity, and combined with the extracted PDF metadata, the similarity of the characters in the PDF is calculated.
[0009] In one embodiment, the detailed scanning of each character in the specified Unicode block includes: Define Unicode blocks; The system scans each character in the Unicode block one by one and queries its corresponding Unicode code; Use the Fontconfig library to find all fonts in the system that support the character, and record all fonts that can correctly render the character and their properties; Combined with reading the copyright information of the font licensing library, commercially licensed fonts in the font collection are excluded; Further optimize font selection strategy based on font collection; The system caches commonly used font collections and configurations in the background.
[0010] In one embodiment, the dynamic Unicode segmented font set optimization algorithm includes: Traverse the entire Unicode mapping table and check whether the font sets of adjacent characters are the same; If multiple consecutive characters are found to have the same font set, the Unicode ranges of the characters are merged; The system generates a new font mapping table, each segment contains the starting and ending Unicode code points and their corresponding font set information; Dynamically adjust and optimize the font mapping table based on the user's actual operation; Cache common font mapping segments.
[0011] In one embodiment, the sorting of the generated font mapping table by similarity and the calculation of the similarity of the characters in the PDF in combination with the extraction of PDF metadata include: Load and parse the system font file from memory, extract key metric information, and cache it; Using the font metric information extracted by the system global font metric information collection, the font sets in the font mapping table generated by the dynamic Unicode segmented font set optimization algorithm are sorted by similarity; Combined with the data extracted from the PDF metadata, the system performs similarity calculations on the characters in the PDF; By calculating the similarity score between the character and each font in the font collection, the system selects the font with the highest similarity for rendering; Cache frequently used font mapping segments and similarity scores.
[0012] In one embodiment, the hierarchical decision engine layer includes: The system captures the user's operation behavior and current operation scenario in real time through the PDF page operation API; The system generates a compact and efficient font mapping table, where each segment contains the starting and ending Unicode code points and their corresponding font set information; Using key metric information extracted from the system global font metric information collection, similarity sorting is performed on the font sets in the font mapping table generated by the dynamic Unicode segmented font set optimization algorithm; Insert text into blank spaces and edit within paragraphs; Caches font data and descriptor IDs.
[0013] A multi-dimensional data fusion PDF font precision matching system, including: The data pre-collection module is used to collect the multi-dimensional data sources required for font matching in advance, cache them, and update the data during user inactivity periods; Feature calculation module, used to scan the original data character by character, measure similarity calculation and optimize the dynamic Unicode segmented font set; The hierarchical decision engine module is used to match fonts based on scenario-based requirements. While ensuring the visual consistency of the document after editing, it quickly selects the most appropriate font resources for the user's editing operations and performs reasonable embedded operations on the font resources.
[0014] It can be seen from the above technical solution that compared with the prior art, the present invention has at least the following advantages and positive effects: a multi-dimensional data fusion PDF font precise matching method and system in an embodiment of the present invention, the method includes a data pre-collection layer that collects font matching multi-dimensional data sources, caches them, and updates the data during the user's inactive time period; the feature calculation layer scans the original data character by character, measures similarity calculation, and optimizes the dynamic Unicode segmented font set; the hierarchical decision engine layer performs font matching according to scenario requirements, selects font resources for the user's editing operations, and performs embedded operations on the font resources while ensuring the visual consistency of the document after the user edits; through multi-dimensional data fusion and dynamic priority scheduling, efficient and accurate font matching is achieved, which can effectively avoid the situation where the fonts used in the PDF document are displayed as garbled characters, and can also avoid copyright compliance risks. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following briefly describes the drawings required for the specific embodiments or the description of the prior art. Similar elements or parts are generally identified by similar reference numerals throughout the drawings. Elements or parts in the drawings are not necessarily drawn to scale.
[0016] Figure 1 Schematic diagram of the process of a multi-dimensional data fusion PDF font accurate matching method of the present invention; Figure 2 This is a flow chart of the data pre-collection layer in step S1 of the present invention; Figure 3 This is a flow chart of collecting system global font metric information in step S110 of the present invention; Figure 4 A schematic diagram of a process for obtaining font metric information by a Freetype system according to an embodiment of the present invention; Figure 5 A schematic diagram of a process for obtaining font metric information on a Linux platform according to an embodiment of the present invention; Figure 6A schematic diagram of a process for obtaining font metric information on a Mac platform according to an embodiment of the present invention; Figure 7 This is a schematic diagram of the process of extracting PDF metadata in step S120 of the present invention; Figure 8 Schematic diagram of the process of reading copyright information of the font authorization library in step S130 of the present invention Figure 9 This is a flow chart of collecting the user's operation scenario in step S140 of the present invention; Figure 10 This is a schematic diagram of the process of the feature calculation layer in step S2 of the present invention; Figure 11 This is a flow chart of scanning each character in detail in step S210 of the present invention; Figure 12 This is a flow chart of the dynamic Unicode segmented font set optimization algorithm in step S220 of the present invention; Figure 13 This is a flow chart of calculating the similarity of the measurement in step S230 of the present invention; Figure 14 This is a schematic diagram of the process of the hierarchical decision engine layer in step S3 of the present invention; Figure 15 This is a structural diagram of a multi-dimensional data fusion PDF font accurate matching system of the present invention. DETAILED DESCRIPTION
[0017] In order to more clearly illustrate the purpose, technical solutions and advantages of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. The example implementation methods can be implemented in various forms and should not be understood as being limited to the examples described herein. On the contrary, these implementation methods are provided to make the present invention more comprehensive and complete, and to fully convey the concepts of the example implementation methods to those skilled in the art.
[0018] In addition, the described features, structures or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present invention. However, it will be appreciated by those skilled in the art that the technical solutions of the present invention can be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known methods, devices, implementations or operations are not shown or described in detail to avoid blurring various aspects of the present invention.
[0019] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically separate entities. That is, these functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0020] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, while others may be combined or partially combined. Therefore, the actual execution order may vary depending on the actual situation.
[0021] The present invention is described in detail below with reference to specific embodiments.
[0022] Example 1
[0023] The present invention provides a PDF font accurate matching method based on multi-dimensional data fusion, referring to Figure 1 , Figure 1 The figure is a flow chart of a PDF font accurate matching method based on multi-dimensional data fusion according to the present invention.
[0024] Depend on Figure 1 It can be seen that a PDF font accurate matching method based on multi-dimensional data fusion includes the following steps: S1. The data pre-collection layer collects the multi-dimensional data sources required for font matching, caches them, and updates the data during the user's inactive period; Figure 2 , Figure 2 This is a flow chart of the data pre-collection layer of the present invention, where step S1 specifically includes the following steps: S110, collect system global font metric information; reference Figure 3 , Figure 3 This is a flow chart of the process of collecting global font metric information of the system according to the present invention. Step S110 specifically includes the following steps: S111. Load system fonts: Load all installed TrueType (TTF) and OpenType (OTF) font files from the memory through the API interface provided by the operating system.
[0025] S112. Parsing font files: performing in-depth parsing on each font file to extract key metric information.
[0026] It should be noted that, in this embodiment, the key metric information includes but is not limited to glyph outline data, character width, baseline offset and other information.
[0027] S113. Pay attention to specific parameters: Pay special attention to the usWinAscent and usWinDescent values in the OS / 2 table. The usWinAscent and usWinDescent parameters define the maximum ascent and descent heights of the font, which can effectively prevent overlapping between lines of text.
[0028] S114, caching measurement information: caching all extracted measurement information for subsequent quick retrieval to improve text rendering speed.
[0029] It should be noted that, in this embodiment, the user's inactive time includes but is not limited to the time after the document is saved.
[0030] refer to Figure 4 , Figure 4 Schematic diagram of the process of obtaining font metrics information for the Freetype system. Figure 4 It can be seen that the FreeType system obtains font metric information, including the following steps: (1) Check the number of command line parameters; (2) When argc==2, load a single font file and initialize the FreeType library; if initialization is successful, load the font file in the specified path; if loading is successful, print font information and clean up resources; if loading fails, output an error message and exit; (3) When argc==3, load a single font file and initialize the FreeType library; if initialization is successful, load the font collection file according to the index; if loading is successful, print the font information including the index and clean up the resources; if loading fails, output an error message and exit; (4) When argc outputs other conditions, output an error message and end.
[0031] refer to Figure 5 , Figure 5 Schematic diagram of the process of obtaining font metrics information for Linux platform. Figure 5 It can be seen that obtaining font metric information on the Linux platform includes the following steps: (1) Initialize the Fontconfig library; (2) If the initialization is successful, create the Fontconfig configuration; if configuring the Windows / Android / Apple platform, load the predefined default configuration; if configuring the Linux platform, try to load the system font configuration; if the loading is successful, load the system font configuration; if the recording fails, load the predefined default configuration; (3) Create a font set and extract font information; (4) Fill font information into unordered_map; (5) Write font information into a binary file; (6) Read font information from binary file; (7) Query font information, including but not limited to query by full name, query by family, query by style, and query by family and style; (8) Output the query results and visualize the font information into a text file.
[0032] refer to Figure 6 , Figure 6 Flowchart for obtaining font metrics information for the Mac platform. Figure 6 It can be seen that obtaining font metric information on the Mac platform includes the following steps: (1) Performance timing starts, and GetAllSystemFonts is called to obtain the system fonts; (2) Create a system font collection and obtain a matching font descriptor; if a font descriptor is obtained, traverse the font descriptor, create a font object and obtain font properties; after traversing all fonts, release the collection resources and return the font list; if no font descriptor is obtained, output an error message and return an empty list; (3) After the performance timing is completed, the statistical information is output, and the first five font samples are output; (4) Print font information and generate an analysis report. Print font information includes but is not limited to printing font family, printing style name, printing PostScript name, printing file path of PostScript name, printing font weight and width, printing variable font, bold, italic information, and printing separators; the content of the analysis report includes but is not limited to counting the number of variable fonts, counting the number of fonts that support bold, and counting the number of fonts that support italics.
[0033] In summary, after collecting global font metrics information, the system can pre-calculate basic font information before text rendering and cache it. This allows direct use of these pre-calculated results during actual rendering, reducing the overhead of repeated calculations and improving the speed and efficiency of text rendering. For example, in a PDF document containing a large amount of text, obtaining font metrics information in advance can quickly determine the text layout and improve software responsiveness.
[0034] S120, Extract PDF metadata; Reference Figure 7 , Figure 7 The flowchart of the present invention for extracting PDF metadata is shown below. The specific implementation steps of step S120 are as follows: S121. Read the character map of the embedded font: For each PDF document, read the character map (CMap) of the embedded font and parse the mapping relationship between character codes and glyphs. This is especially important for multi-byte encoding.
[0035] When reading the embedded font's character map, if the mapping table is correct and complete, the character code for multi-byte characters can be accurately mapped to the corresponding glyph. For example, the Chinese character "" in GBK encoding is encoded as a two-byte value. If the embedded font's character map contains the mapping for this character, the character's shape will be displayed correctly when the text is displayed.
[0036] However, if the character map is incomplete, some characters in multi-byte encodings may not have corresponding glyphs. For example, if an embedded font only supports some GBK-encoded Chinese characters, when encountering a GBK-encoded Chinese character that is not included in the map, it will be displayed as garbled characters or a default replacement character (such as a square or question mark).
[0037] S122, parsing font descriptor: further parsing the font descriptor (FontDescriptor) of each font to extract attribute information therefrom.
[0038] It should be noted that, in this embodiment, the attribute information includes but is not limited to font name, weight, width and other information.
[0039] S123. Extract ToUnicode table: Obtain the ToUnicode table, which provides a mapping from character codes to standard Unicode characters and supports text search, copy, and paste functions.
[0040] S124. Analyze encoding information: Understand and analyze encoding information to ensure that characters in the CID font are correctly interpreted and displayed.
[0041] It should be noted that, in this embodiment, the coding information includes but is not limited to Identity-H coding.
[0042] S125, caching metadata: caching all extracted font metadata information to facilitate quick retrieval in subsequent operations, thereby improving processing efficiency.
[0043] In summary, extracting PDF metadata can quickly categorize and index a large number of PDF fonts, making it easier for users to find the fonts they need within a massive file. Keywords, summaries, and other information in the metadata can be used as indexing information for search engines, helping users find their target fonts more accurately.
[0044] S130, read the copyright information of the font authorization library; reference Figure 8, Figure 8 This is a flow chart of reading copyright information from a font authorization library according to the present invention. The specific implementation steps of step S130 are as follows: S131. Connect to the authorization library: Connect to the world's authoritative font authorization library to verify the commercial use rights of fonts in real time.
[0045] It should be noted that, in this embodiment, the font authorization library includes but is not limited to font libraries such as Monotype and Adobe Fonts.
[0046] S132. Query font license: When the user selects a font for a project, the system will automatically query detailed license information.
[0047] It should be noted that, in this embodiment, the detailed licensing information includes but is not limited to whether the font selected by the user is allowed to be used commercially, whether the font can be embedded in PDF or other documents, and whether the font has regional restrictions.
[0048] S133. Collecting supplementary information: Collecting supplementary information of the font.
[0049] It should be noted that, in this embodiment, the supplementary information of the font includes but is not limited to whether the font is allowed to be embedded, whether the font can be used commercially, and the complete copyright information of the font.
[0050] It should be noted that the complete copyright information of the font includes but is not limited to the font's author, copyright holder and copyright statement.
[0051] S134. Cache copyright information: Cache all acquired font usage permissions and supplementary information to avoid repeated queries and optimize resource management.
[0052] In summary, by reading the copyright information from the font licensing database and verifying the commercial use rights of fonts in real time, you can ensure that the fonts you use comply with legal requirements, thereby avoiding the risk of copyright infringement. This real-time verification feature can help users quickly screen fonts that meet commercial use requirements, avoiding wasting time and effort on unauthorized fonts.
[0053] S140: Collect the user's operation scenario. Figure 9 , Figure 9 The flowchart of the present invention for collecting user operation scenarios is shown below. The specific implementation steps of step S140 are as follows: S141. Capturing user behavior: Using the PDF page operation API, user operation behaviors are captured in real time, such as inserting text in a blank space, editing text within a paragraph, selecting text for replacement, and selecting a font after selecting text.
[0054] S142. Dynamically adjust the strategy: Based on the captured operation scenario, dynamically adjust the matching strategy. For example, recommend similar font styles, optimize typesetting, provide intelligent prompts, etc. to improve editing efficiency and experience.
[0055] S143. Apply new font: When the user changes the font, the new font is applied immediately and the display effect is adjusted. At the same time, the character spacing and line spacing are recalculated to keep the layout intact.
[0056] S144. Cache operation mode: Cache common operation modes and configurations to reduce repeated calculation time and provide users with a smooth interactive experience.
[0057] Before processing a PDF document, steps S110 and S120 are executed to ensure sufficient font metrics and metadata to support accurate font matching. Based on user needs, the legality and compliance of the selected fonts are confirmed in step S130 to ensure that no copyright violations occur. During the actual editing process, the method mentioned in step S140 is used to respond to user actions in real time and dynamically adjust the font matching strategy as needed, thereby optimizing the user experience.
[0058] S2, the feature calculation layer scans the original data character by character, measures similarity and optimizes the dynamic Unicode segmented font set; Figure 10 , Figure 10 This is a flow chart of the feature calculation layer of the present invention, where step S2 specifically includes the following steps: S210, the system is deeply integrated with the Fontconfig library to perform a detailed scan of each character in the specified Unicode block and build a set of fonts supported by the system. Figure 11 , Figure 11 The flowchart of the present invention for scanning each character in detail is shown below. The specific implementation steps of step S210 are as follows: S211. Define Unicode blocks: The user can specify one or more Unicode blocks, such as Basic Latin, Cyrillic, CJK unified Chinese characters, etc.
[0059] S212, character-by-character scanning: The system scans each character in these blocks one by one and queries its corresponding Unicode code.
[0060] S213. Searching for supporting fonts: Searching for all fonts in the system that support the character through the Fontconfig library, and recording all fonts that can correctly render the character and their attributes.
[0061] It should be noted that, in this embodiment, the attributes include but are not limited to font name, style, font weight, etc.
[0062] S214, excluding commercially licensed fonts: In combination with the above step S130, excluding commercially licensed fonts in the font collection to ensure legal use.
[0063] S215, optimizing font selection strategy: Based on the font set, further optimizing the font selection strategy, for example, sorting by priority, automatically replacing fonts with missing characters, and dynamically adjusting font selection to meet the needs of multilingual mixed text.
[0064] S216. Cache commonly used font collections: To improve the user experience, the system will cache commonly used font collections and configurations in the background to reduce the time consumption of repeated queries.
[0065] S220, Dynamic Unicode Segmented Font Set Optimization Algorithm. Reference Figure 12 , Figure 12 This is a flow chart of the dynamic Unicode segmented font set optimization algorithm of the present invention. The specific implementation steps of step S220 are as follows: S221. Identify continuous Unicode ranges of the same font set: traverse the entire Unicode mapping table and check one by one whether the font sets of adjacent characters are the same.
[0066] S222. Merge Unicode ranges: If multiple consecutive characters are found to have the same font set, the system will merge the Unicode ranges of these characters. For example, if all characters from U+4E00 to U+4E0F are supported by the same font set, the system will merge this range into a single segment.
[0067] S223. Generate a new font mapping table: After merging continuous Unicode ranges of the same font set, the system generates a new, more compact font mapping table, where each segment contains the starting and ending Unicode code points and their corresponding font set information.
[0068] S224. Dynamically adjust and optimize the font mapping table: Dynamically adjust and optimize the font mapping table according to the user's actual operation to ensure real-time performance and accuracy.
[0069] S225. Cache frequently used font mapping segments: The system caches frequently used font mapping segments in the background to reduce the time consumed by repeated calculations, ensuring a quick response when processing similar documents or character sets, and providing a smooth and efficient interactive experience.
[0070] S230, combining the system global font metric information collection and the dynamic Unicode segmented font set optimization algorithm, sorting the generated font mapping table by similarity, and calculating the similarity of the characters in the PDF by combining the extracted PDF metadata. Figure 13 , Figure 13 The flowchart of the present invention for calculating the similarity measurement is shown below. The specific implementation steps of step S230 are as follows: S231 , using the metric information from step S110 : loading and parsing all system font files from the memory, extracting key metric information such as glyph outlines, character widths, and baseline offsets, and caching them.
[0071] S232. Similarity Sorting: Using the font metrics extracted in step S110, the fonts in the font mapping table generated in step S220 are sorted by similarity. By comparing metrics such as glyph outlines and character widths of different fonts, similarity scores are calculated. The fonts are sorted based on these scores, ensuring that fonts with higher similarity are ranked first.
[0072] S233. PDF Character Similarity Calculation: The system calculates the similarity of characters in the PDF document, combining the character map, font descriptor, ToUnicode table, and encoding information of the PDF document's embedded fonts extracted in step S120. Specifically, the system extracts information such as the character's Unicode encoding, character width, and baseline offset from the PDF document, then searches the font map for the most appropriate font set.
[0073] S234. Select the best font: By calculating the similarity score between the character and each font in the font set, the system selects the font with the highest similarity for rendering, thereby ensuring the best display effect of the text content.
[0074] S235. Cache similarity scores: Cache commonly used font mapping segments and similarity scores to reduce the time consumed by repeated calculations, ensure rapid response when processing similar documents or character sets, and provide a smooth and efficient interactive experience.
[0075] S3, the hierarchical decision engine layer matches fonts based on scenario-based requirements. On the premise of ensuring the visual consistency of the document after editing, it quickly selects the most appropriate font resource for the user's editing operation and performs reasonable embedding operations on the font resource. Figure 14 , Figure 14 This is a flow chart of the hierarchical decision engine layer of the present invention. Step S3 specifically includes the following steps: S310, User Scenario Capture: In step S140, the system uses the PDF page operation API to capture user actions and current scenarios in real time. These captured actions and scenarios provide important context for subsequent font matching. Understanding the user's specific actions helps the system better predict and meet the user's font needs. For example, a user inserts text into a blank space or edits within a paragraph.
[0076] S320, Dynamic Unicode Segmented Font Set Optimization Algorithm: At step S220, the system generated a compact and efficient font mapping table. Each segment contains the starting and ending Unicode code points and their corresponding font set information. The font mapping table provides basic data support for font selection. By merging consecutive Unicode ranges with the same font set, the system not only reduces redundant information but also improves font matching and rendering efficiency.
[0077] S330, Metric Similarity Calculation: In step S230, the system uses the key metric information extracted from the global font metric information collection in step S110 to sort the fonts in the font mapping table generated in step S220 by similarity. By comparing the metric information of different fonts, a similarity score is calculated between them. The fonts are sorted based on this score, ensuring that fonts with higher similarity are ranked first, so that they are preferred in subsequent rendering.
[0078] S340, insert text in blank space and edit within paragraph: S341. Insert text in a blank space: When the user inserts text in a blank space, the system directly selects a suitable font from the font mapping table generated in step S220, which simplifies the font selection process and improves the user experience.
[0079] S342, Intra-Segment Editing: For intra-segment editing, the system combines steps S110 and S120 to ensure that the metrics of the inserted characters are consistent with those of the preceding and following segments. Specifically, the system first extracts key metrics such as the glyph outline, character width, and baseline offset of the preceding and following characters from step S110. It then uses the character map, font descriptor, and other detailed properties extracted from step S120 to calculate the best matching font to ensure the overall consistency of the text block.
[0080] S350, Caching Mechanism: To further improve efficiency, the system caches font data and descriptor IDs. Frequently used font mapping segments and metric information can be quickly accessed when processing similar documents or character sets, reducing the time spent on recalculation and providing a smooth and efficient interactive experience. Furthermore, cached descriptor IDs make subsequent queries and applications of the same font configuration much faster, significantly improving system responsiveness and performance.
[0081] To summarize, in this application, a PDF font precise matching method based on multi-dimensional data fusion includes a data pre-collection layer that collects font matching multi-dimensional data sources, caches them, and updates the data during user inactive time periods; a feature calculation layer that scans the original data character by character, measures similarity, and optimizes the dynamic Unicode segmented font set; a hierarchical decision engine layer that matches fonts based on scenario requirements, selects font resources for the user's editing operations, and performs embedded operations on the font resources while ensuring the visual consistency of the document after editing by the user; through multi-dimensional data fusion and dynamic priority scheduling, efficient and accurate font matching is achieved, which can effectively avoid the situation where fonts used in PDF documents are displayed as garbled characters, and can also avoid copyright compliance risks.
[0082] Example 2 refer to Figure 15 The present invention provides a PDF font accurate matching system based on multi-dimensional data fusion. Figure 15 This is a structural diagram of the multi-dimensional data fusion PDF font accurate matching system of the present invention.
[0083] Depend on Figure 15 It can be seen that a multi-dimensional data fusion PDF font accurate matching system includes: a data pre-collection module 210, a feature calculation module 220 and a hierarchical decision engine module 230.
[0084] The data pre-collection module 210 is used to collect the multi-dimensional data sources required for font matching in advance, cache them, and update the data during the user's inactive period.
[0085] The feature calculation module 220 is used to scan the original data character by character, measure similarity calculation and optimize the dynamic Unicode segmented font set; The hierarchical decision engine module 230 is used to match fonts according to scenario requirements. On the premise of ensuring the visual consistency of the document after the user edits, it quickly selects the most appropriate font resources for the user's editing operations and performs reasonable embedding operations on the font resources.
[0086] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not disclosed herein. The description and examples are to be considered as exemplary only, and the true scope and spirit of the present invention are indicated by the claims. It should be understood that the present invention is not limited to the precise structure described above and shown in the accompanying drawings, and that various modifications and changes can be made without departing from its scope. The scope of the present invention is limited only by the appended claims.
Claims
1. A PDF font accurate matching method based on multi-dimensional data fusion, characterized in that: include: The data pre-collection layer collects fonts matching multi-dimensional data sources, caches them, and updates the data during user inactive periods; The feature calculation layer scans the original data character by character, calculates similarity metrics, and optimizes the dynamic Unicode segmented font set; The hierarchical decision engine layer matches fonts based on scenario-based requirements. On the premise of ensuring the visual consistency of the document after user editing, it selects font resources for the user's editing operations and performs embedded operations on the font resources.
2. The PDF font accurate matching method based on multi-dimensional data fusion according to claim 1 is characterized in that: The data pre-collection layer includes: Collect system global font metric information; Extract PDF metadata; Read the copyright information of the font authorization library; Collect user operation scenarios.
3. The PDF font accurate matching method based on multi-dimensional data fusion according to claim 2 is characterized in that: The acquisition system global font metric information includes: Load all installed TrueType and OpenType font files from memory through the API interface provided by the operating system; Perform in-depth analysis of each font file to extract key metric information; Pay attention to specific parameters to prevent overlapping between text lines; Cache all extracted metrics information.
4. The PDF font accurate matching method based on multi-dimensional data fusion according to claim 2 is characterized in that: Extracting PDF metadata includes: For each PDF document, read the character map of the embedded font and parse the mapping relationship between character codes and glyphs; Parse the font descriptor of each font and extract attribute information from it; Get the ToUnicode table, which provides a mapping from character codes to standard Unicode characters and supports text search, copy and paste functions; understand and analyze coded information; Caches all extracted font metadata information.
5. The PDF font accurate matching method based on multi-dimensional data fusion according to claim 2 is characterized in that: The feature calculation layer includes: The system is deeply integrated with the Fontconfig library to perform a detailed scan of each character in the specified Unicode block and build a set of fonts supported by the system; Dynamic Unicode segmented font set optimization algorithm; Combined with the system global font metric information collection and the dynamic Unicode segmented font set optimization algorithm, the generated font mapping table is sorted by similarity, and combined with the extracted PDF metadata, the similarity of the characters in the PDF is calculated.
6. The PDF font accurate matching method based on multi-dimensional data fusion according to claim 5 is characterized in that: The detailed scanning of each character in the specified Unicode block includes: Define Unicode blocks; The system scans each character in the Unicode block one by one and queries its corresponding Unicode code; Use the Fontconfig library to find all fonts in the system that support the character, and record all fonts that can correctly render the character and their properties; Combined with reading the copyright information of the font licensing library, commercially licensed fonts in the font collection are excluded; Further optimize font selection strategy based on font collection; The system caches commonly used font collections and configurations in the background.
7. The PDF font accurate matching method based on multi-dimensional data fusion according to claim 5 is characterized in that: The dynamic Unicode segmented font set optimization algorithm includes: Traverse the entire Unicode mapping table and check whether the font sets of adjacent characters are the same; If multiple consecutive characters are found to have the same font set, the Unicode ranges of the characters are merged; The system generates a new font mapping table, each segment contains the starting and ending Unicode code points and their corresponding font set information; Dynamically adjust and optimize the font mapping table based on the user's actual operation; Cache common font mapping segments.
8. The PDF font accurate matching method based on multi-dimensional data fusion according to claim 5 is characterized in that: The similarity sorting of the generated font mapping table and the similarity calculation of the characters in the PDF in combination with the extracted PDF metadata include: Load and parse the system font file from memory, extract key metric information, and cache it; Using the font metric information extracted by the system global font metric information collection, the font sets in the font mapping table generated by the dynamic Unicode segmented font set optimization algorithm are sorted by similarity; Combined with the data extracted from the PDF metadata, the system performs similarity calculations on the characters in the PDF; By calculating the similarity score between the character and each font in the font collection, the system selects the font with the highest similarity for rendering; Cache frequently used font mapping segments and similarity scores.
9. The PDF font accurate matching method based on multi-dimensional data fusion according to claim 5 is characterized in that: The hierarchical decision engine layer includes: The system captures the user's operation behavior and current operation scenario in real time through the PDF page operation API; The system generates a compact and efficient font mapping table, where each segment contains the starting and ending Unicode code points and their corresponding font set information; Using key metric information extracted from the system global font metric information collection, similarity sorting is performed on the font sets in the font mapping table generated by the dynamic Unicode segmented font set optimization algorithm; Insert text into blank spaces and edit within paragraphs; Caches font data and descriptor IDs.
10. A multi-dimensional data fusion PDF font accurate matching system, characterized by: include: The data pre-collection module is used to collect the multi-dimensional data sources required for font matching in advance, cache them, and update the data during user inactivity periods; Feature calculation module, used to scan the original data character by character, measure similarity calculation and optimize the dynamic Unicode segmented font set; The hierarchical decision engine module is used to match fonts based on scenario-based requirements. While ensuring the visual consistency of the document after editing, it quickly selects the most appropriate font resources for the user's editing operations and performs reasonable embedded operations on the font resources.