CN116306498B - Text rendering method and device - Google Patents

Text rendering method and device Download PDF

Info

Publication number
CN116306498B
CN116306498B CN202310547146.7A CN202310547146A CN116306498B CN 116306498 B CN116306498 B CN 116306498B CN 202310547146 A CN202310547146 A CN 202310547146A CN 116306498 B CN116306498 B CN 116306498B
Authority
CN
China
Prior art keywords
initial
font
association table
font name
character code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310547146.7A
Other languages
Chinese (zh)
Other versions
CN116306498A (en
Inventor
史晓斌
康凯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fuxin Kunpeng Beijing Information Technology Co ltd
Original Assignee
Fuxin Kunpeng Beijing Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fuxin Kunpeng Beijing Information Technology Co ltd filed Critical Fuxin Kunpeng Beijing Information Technology Co ltd
Priority to CN202310547146.7A priority Critical patent/CN116306498B/en
Publication of CN116306498A publication Critical patent/CN116306498A/en
Application granted granted Critical
Publication of CN116306498B publication Critical patent/CN116306498B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/109Font handling; Temporal or kinetic typography
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24553Query execution of query operations
    • G06F16/24558Binary matching operations
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The invention provides a text rendering method and a text rendering device, which relate to the technical field of document processing, wherein the text rendering method comprises the following steps: responding to a display instruction of a target document, and aiming at characters in the target document, acquiring initial font names of the characters; matching the initial font name with each first character code in the first association table to determine an initial character code; under the condition that the second association table does not contain the initial font names, matching the initial character codes with each second font name in the second association table, and determining the target font names; and rendering the characters according to the fonts corresponding to the target font names. Proper fonts can be selected for rendering, so that the rendering accuracy of characters and documents is improved; the format and style of the document can be better reserved, so that the rendering effect of the document is improved; and the readability and the aesthetic degree of the document can be improved by rendering with the proper fonts, so that the use experience of a user is improved.

Description

Text rendering method and device
Technical Field
The present invention relates to the field of document processing technologies, and in particular, to a text rendering method and apparatus.
Background
An Open-layout document (OFD) is a novel electronic document format, has the characteristics of high efficiency, safety, reliability, cross-platform and the like, and is suitable for the fields of financial industry, government institutions, enterprises and the like. Word rendering in OFD documents requires the use of fonts, and the selection of fonts has a great impact on rendering effects and user experience. If the selected fonts are not matched or suitable, problems such as poor rendering, messy codes, font deformation and the like can be caused, and the readability and the attractiveness of the document are affected.
In the prior art, when rendering characters, an OFD document searches whether the characters exist in a system according to the names of the characters if the characters are not embedded characters, if not, the characters are rendered by default, and if the default characters are Song's characters but the characters corresponding to the characters are symbol characters, the effect of rendering is messy codes or no method is achieved. Therefore, an effective method is needed to improve the font matching degree and rendering quality, and further improve the rendering effect and user experience.
Disclosure of Invention
Aiming at the problems existing in the prior art, the embodiment of the invention provides a text rendering method and a text rendering device.
The invention provides a text rendering method, which comprises the following steps:
responding to a display instruction of a target document, and aiming at characters in the target document, acquiring initial font names of the characters;
matching the initial font name with each first character code in a first association table to determine an initial character code, wherein each first font name and the corresponding first character code are stored in association in the first association table;
under the condition that the second association table does not contain the initial font names, matching the initial character codes with the second font names in the second association table to determine target font names, wherein the second association table is stored with the second font names and the corresponding second character codes in the document display system in an associated mode;
and rendering the text according to the font corresponding to the target font name.
According to the text rendering method provided by the invention, under the condition that the second association table does not contain the initial font names, the initial character codes are matched with the second font names in the second association table, and the target font names are determined, which comprises the following steps:
Judging whether the initial character codes exist in the second association table or not under the condition that the second association table does not contain the initial font names;
if yes, determining a second font name corresponding to the initial character code as a target font name;
if not, determining the default font name of the document display system as the target font name.
According to the text rendering method provided by the invention, under the condition that the second association table does not contain the initial font names, the initial character codes are matched with the second font names in the second association table, and the target font names are determined, which comprises the following steps:
judging whether the initial character code is a designated character code or not under the condition that the second association table does not contain the initial font name;
and if not, matching the initial character code with each second font name in the second association table, and determining the target font name.
According to the text rendering method provided by the invention, the matching of the initial font name and each first character code in the first association table, after determining the initial character code, further comprises:
And determining the initial font name as a target font name under the condition that the second association table contains the initial font name.
According to the text rendering method provided by the invention, the matching of the initial font name and each first character code in the first association table, and the determination of the initial character code comprise the following steps:
judging whether the initial font name exists in the first association table;
if yes, determining a first character code corresponding to the initial font name as an initial character code;
if not, determining the appointed character code as the initial character code.
According to the text rendering method provided by the invention, if not, the text rendering method further comprises the following steps:
searching an actual character code corresponding to the initial font name;
and storing the initial font name and the actual character code association into the first association table to obtain the updated first association table.
According to the text rendering method provided by the invention, the matching of the initial character code and each second font name in the second association table, before determining the target font name, further comprises:
acquiring each second font name in the document display system;
Determining second character codes corresponding to the second font names according to the first association table;
and storing the second font names and the corresponding second character coding associations into the second association table.
The invention also provides a text rendering device, which comprises:
the first acquisition module is configured to respond to a display instruction of a target document and acquire an initial font name of a word aiming at the word in the target document;
the first matching module is configured to match the initial font names with first character codes in a first association table, and determine initial character codes, wherein the first association table is stored with the collected first font names and the first character codes corresponding to the first font names in an associated mode;
the second matching module is configured to match the initial character code with each second font name in a second association table under the condition that the second association table does not contain the initial font name, and determine a target font name, wherein each second font name and the corresponding second character code in the document display system are stored in the second association table in an associated manner;
and the rendering module is configured to render the text according to the font corresponding to the target font name.
The invention also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor realizes any one of the text rendering methods when executing the program.
The present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a text rendering method as described in any of the above.
The invention also provides a computer program product comprising a computer program which when executed by a processor implements a text rendering method as described in any of the above.
According to the character rendering method and device, the initial font name of characters in the target document is obtained by responding to the display instruction of the target document; then, the initial font name is matched with each first character code in the first association table to determine the initial character code, so that the character codes are classified; under the condition that the second association table does not contain the initial font names, the initial character codes are matched with the second font names in the second association table, the target font names are determined, the similarity between the fonts corresponding to the target font names and the fonts corresponding to the initial font names is improved, the fonts corresponding to the target font names are more suitable, and the rendering accuracy of the document is improved after rendering; the format and style of the document can be better reserved, so that the rendering effect of the document is improved; and the readability and the aesthetic degree of the document can be improved by rendering with the proper fonts, so that the use experience of a user is improved.
Drawings
In order to more clearly illustrate the invention or the technical solutions of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are some embodiments of the invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of a text rendering method according to the present invention;
FIG. 2 is a second flow chart of the text rendering method according to the present invention;
FIG. 3 is a schematic diagram of a text rendering device according to the present invention;
fig. 4 is a schematic structural diagram of an electronic device provided by the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The text rendering method and apparatus of the present invention are described below with reference to fig. 1 to 3.
Fig. 1 is a schematic flow chart of a text rendering method provided by the present invention, and referring to fig. 1, the method includes steps 101 to 104, wherein:
step 101: responding to a display instruction of a target document, and acquiring an initial font name of characters in the target document aiming at the characters.
Firstly, it should be noted that the execution body of the present invention may be any electronic device for performing text rendering, for example, any one of a smart phone, a smart watch, a desktop computer, a portable computer, etc.
Specifically, the target document refers to a document to be displayed or a document to be text-rendered, and the target document may be an OFD document, a portable file format (Portable Document Format, PDF) document, a Word document, a picture format document, or the like. The display instruction refers to an instruction for displaying and presenting the target document. The text is a tool for recording language, which may be chinese, english, french, etc. Font names (family name values) refer to the names of fonts, such as Song's body, regular script, and the like. The initial font name refers to the font name of the text acquired from the document information of the target document.
In practical applications, when a user opens a target document through a document display system (a document display or document editing tool), the execution body receives a display instruction of the target document accordingly. In response to the presentation instruction, the execution body initiates a process of rendering text in the target document.
Under the condition that the target document contains characters, acquiring initial font names of the characters aiming at the characters in the target document: the Font identifier of the text, such as Font ID (Font ID), is acquired first, and the Font name corresponding to the Font identifier is identified as the initial Font name.
It should be noted that there may be a plurality of characters in the target document. At this time, each text in the target document can be respectively rendered according to the text rendering method provided by the invention; all the characters in the target document can be rendered according to the character rendering method provided by the invention; the text of each area in the target document, such as the text in each paragraph, the text in each row, and the like, can be rendered according to the text rendering method provided by the invention; but may be others, and the invention is not limited in any way.
Step 102: and matching the initial font name with each first character code in a first association table to determine the initial character code, wherein each first font name and the corresponding first character code are stored in association in the first association table.
Specifically, the first font name is the collected font name. The character code may be a codeplage value or a charset value. The first character encoding is a character encoding of a first font name.
In practical application, on the basis of obtaining the initial font name of the text in the target document, further, determining initial character coding according to the initial font name and the first association table: and searching a first character code corresponding to the initial font name from the first association table as an initial character code.
Illustratively, the codeplage value is searched from the table a (first association table) using the family value of the font, and the searched codeplage value is used as the initial character code.
It should be noted that, before the initial font name is matched with each first character code in the first association table, the method further includes:
collecting a plurality of first font names, and searching first character codes of the first font names;
and storing each first font name and the corresponding first character coding association thereof into the first association table.
In practical application, the first font names are collected as much as possible, then the character codes of the first font names, namely the first character codes, are searched, and the first font names and the corresponding first character codes are associated and stored in the first association table.
For example, the font names, i.e. the first font names, are collected as much as possible on the internet and in operation, then the codeplage values corresponding to the collected first font names are searched, and the first font names and the corresponding codeplage values are recorded in a first association table in the database, such as table a.
In addition, whether the fonts of the characters in the target document are embedded fonts can be judged according to the initial font names, if yes, the characters are rendered according to the embedded fonts, if not, the initial font names are matched with the first character codes in the first association table, and an initial character code body is determined, namely the characters are rendered by using the fonts contained in the document display system.
Step 103: and under the condition that the second association table does not contain the initial font names, matching the initial character codes with the second font names in the second association table to determine target font names, wherein the second association table is stored with the second font names and the corresponding second character codes in the document display system in an associated mode.
In particular, a document presentation system refers to a tool or software program for presentation or editing of a document. The second font name is a font name contained in the document presentation system. The second character encoding is a character encoding of a second font name.
In practical application, on the basis of determining the initial character code, further, judging whether the second association table contains the initial character code, if not, indicating that the installation package of the corresponding font in the target document is not installed in the document display system, namely, rendering the text according to the corresponding font in the target document is not possible.
Since the character codes are the same and different fonts, the fonts are relatively more similar, namely, the characters are rendered by using the same and different fonts, and the shapes of the characters are more similar, the target font name can be determined according to the initial character codes and the second association table: and searching a second font name corresponding to the initial character code from the first association table as a target font name.
Illustratively, the initial character is encoded as a codeplage value: 369, searching at least one second font name with a code value of 369 from a table b (second association table), namely a font name set, and screening one second font name from the font name set as a target font name according to a set screening rule. The setting of the filtering rule may be to use any one of the second font names as the target font name, or use the first second font name as the target font name, or the like.
Step 104: and rendering the text according to the font corresponding to the target font name.
In practical application, on the basis of determining the target font name, setting the font of the characters as the font corresponding to the target font name, and rendering the characters, thereby displaying the target document.
According to the character rendering method provided by the invention, the initial font name of characters in the target document is obtained by responding to the display instruction of the target document; then, the initial font name is matched with each first character code in the first association table to determine the initial character code, so that the character codes are classified; under the condition that the second association table does not contain the initial font names, the initial character codes are matched with the second font names in the second association table, the target font names are determined, the similarity between the fonts corresponding to the target font names and the fonts corresponding to the initial font names is improved, the fonts corresponding to the target font names are more suitable, and the rendering accuracy of the document is improved after rendering; the format and style of the document can be better reserved, so that the rendering effect of the document is improved; and the readability and the aesthetic degree of the document can be improved by rendering with the proper fonts, so that the use experience of a user is improved.
In one or more optional embodiments of the present invention, in a case where the second association table does not include the initial font name, the matching between the initial character code and each second font name in the second association table is performed to determine a target font name, and the specific implementation process may be as follows:
judging whether the initial character codes exist in the second association table or not under the condition that the second association table does not contain the initial font names;
if yes, determining a second font name corresponding to the initial character code as a target font name;
if not, determining the default font name of the document display system as the target font name.
Specifically, the default font name refers to the name of a font that the document presentation system or program is carrying.
In practical application, if the second association table does not contain the initial font name, it is first confirmed whether the initial character code exists in the second association table.
If the character codes exist, the document display system is provided with an installation package of a character font similar to the character font in the target document, at least one second character font name corresponding to the initial character codes can be searched from the first association table, then the similarity between each second character font name in the at least one second character font name and the initial character font name is determined, and the second character font name corresponding to the highest similarity is used as the target character font name; or determining any one of the at least one second font name as the target font name; or determining a first one of the at least one second font name as the target font name.
If the default font name is not available, the default font name of the document display system is determined as the target font name, and the installation package of the font similar to the font of the Chinese character in the target document is not installed in the document display system.
Therefore, whether the initial character encoding result exists in the second association table or not is subjected to font classification, and a proper font can be more accurately selected for rendering, so that the accuracy of document display is improved.
In one or more optional embodiments of the present invention, in a case where the second association table does not include the initial font name, the matching between the initial character code and each second font name in the second association table is performed to determine a target font name, and the specific implementation process may be as follows:
judging whether the initial character code is a designated character code or not under the condition that the second association table does not contain the initial font name;
and if not, matching the initial character code with each second font name in the second association table, and determining the target font name.
Specifically, a specified character code refers to a specified character code or codes, such as 0.
In practical application, if the initial font name is not contained in the second association table, whether the initial character code is the designated character code or not can be judged, if not, the actual font name of the characters in the description target document is the initial entity name, and correspondingly, the second font name corresponding to the initial character code can be searched from the second association table through the initial character code corresponding to the initial font name as the target font name.
Accordingly, after determining whether the initial character code is a specified character code, the method further includes: if yes, determining the default font name of the document display system as the target font name. In other words, when the initial font name is not included in the second association table and the initial character code is the designated character code, determining that the default font name of the document display system is the target font name, and then performing text rendering by using the font corresponding to the default font name.
In this way, by judging whether or not the initial character code is the specified character code, the character codes are classified, and in the case where the initial character code is not the specified character code, the specified character code is matched to the target font name for rendering, and in the case where the initial character code is the specified character code, the font name is directly defaulted as the target font name for rendering. The method not only can improve the efficiency of determining the target font name, but also can improve the matching degree of determining the target font name and the actual font name of the characters in the target document, thereby better preserving the format and style of the target document and improving the rendering effect and the aesthetic degree.
In one or more optional embodiments of the present invention, the matching the initial font name with each first character code in the first association table, after determining the initial character code, further includes:
and determining the initial font name as a target font name under the condition that the second association table contains the initial font name.
In practical application, on the basis of determining the initial character code, further, judging whether the second association table contains the initial character code, if so, indicating that the document display system is provided with the installation package of the corresponding font in the target document, directly determining the initial font name as the target font name, and rendering the characters by using the font corresponding to the target font name, thereby ensuring that the format and style of the rendered characters are consistent with those of the target document, improving the rendering effect, the readability and the aesthetic degree of the document, and improving the use experience of a user.
In one or more optional embodiments of the present invention, the matching the initial font name with each first character code in the first association table, and determining the initial character code may be implemented as follows:
Judging whether the initial font name exists in the first association table;
if yes, determining a first character code corresponding to the initial font name as an initial character code;
if not, determining the appointed character code as the initial character code.
In practical application, on the basis of acquiring the initial font names of the characters in the target document, searching is further performed in the first association table, if the initial font names are found, the first character codes corresponding to the initial font names in the first association table are determined to be initial character codes, and if the initial character codes cannot be found, the appointed character codes are determined to be the initial character codes. In this way, by judging whether the initial font name exists in the first association table, determining the initial character codes by adopting different methods, classifying the character codes is realized, under the condition that the initial font name exists in the first association table, the first character code corresponding to the initial font name is used as the initial character code, under the condition that the initial font name does not exist in the first association table, the appointed character code is determined as the initial character code, so that the efficiency of determining the target font name can be improved, the matching degree of determining the target font name and the actual font name of characters in the target document can be improved, the format and style of the target document can be better reserved, and the rendering effect and the attractiveness can be improved.
Illustratively, the family value of the font is searched in the table a (the first association table), and if the family value of the font is found, the code value corresponding to the family value of the font is used as the initial character code. If the family value of the font cannot be found, marking the code value corresponding to the family value of the font as 0 (appointed character coding).
It should be noted that, if the initial font name does not exist in the first association table, it is noted that the first font name acquired in the first association table is not abundant enough, and then the first association table may be updated according to the initial font name. I.e. after the initial font name does not exist in the first association table, i.e. if not, further comprising:
searching an actual character code corresponding to the initial font name;
and storing the initial font name and the actual character code association into the first association table to obtain the updated first association table.
Specifically, the actual character encoding entity refers to the character encoding for which the original font name is true.
In practical application, if the initial font name does not exist in the first association table, the initial font name is recorded, so that the first association table is convenient to update subsequently: and searching an actual character code of the initial font name, and adding the initial font name and the actual character code into a first association table to update the first association table. Therefore, the first association table is updated, a rendering foundation can be laid when the characters of the initial font name are rendered next time, and the character rendering capability of the document display system is improved.
Illustratively, when the family value of the font is not found in the table a (the first association table), the corresponding family value is recorded, then the code value corresponding to the family value is collected, and the family value and the code value are associated and added to the table a.
In one or more optional embodiments of the present invention, the matching the initial character code with each second font name in the second association table, before determining the target font name, further includes:
acquiring each second font name in the document display system;
determining second character codes corresponding to the second font names according to the first association table;
and storing the second font names and the corresponding second character coding associations into the second association table.
In practical application, on the basis of determining the first association table, all fonts in the document display system can be acquired, the second font names of all fonts are recognized, and then the second character codes corresponding to the second font names are searched from the first association table: for each second font name, if the second font name exists in the first association table, the first character code of the second font name in the second font name is used as the second character code of the second font name, and if the second font name does not exist in the first association table, the designated character code is determined as the second character code of the second font name. Further, each second font name and its corresponding second character encoding association are stored in a second association table. Therefore, the integrity and the reliability of the second association table can be ensured, and the efficiency and the accuracy of text rendering are further improved.
When the program or the document display system is started, all fonts in the document display system are acquired, the family value corresponding to each font is obtained, the codeage value corresponding to the font is obtained from the table a according to the family value of the font, and the obtained family value and the codeage value corresponding to all fonts are stored in a table b (second association table) in the database.
It should be noted that, each time a second character code corresponding to a second font name is determined, the second font name and its corresponding second character code may be stored in the second association table, or after the second character codes corresponding to all the two font names are determined, each second font name and its corresponding second character code may be stored in the second association table. The present invention is not limited in any way.
The text rendering method provided by the present invention is further described below with reference to fig. 2, where fig. 2 is a second schematic flow chart of the text rendering method provided by the present invention, and specifically includes the following steps.
Step 201: collecting a plurality of first font names, and searching first character codes of the first font names; and storing each first font name and the corresponding first character coding association thereof into a first association table.
Step 202: acquiring each second font name in the document display system; determining second character codes corresponding to the second font names according to the first association table; and storing each second font name and the corresponding second character coding association into a second association table.
Step 203: and responding to the display instruction of the target document, and acquiring the initial font name of the text aiming at the text in the target document.
Step 204: and judging whether the initial font name exists in the first association table.
If not, go to step 205 and step 206. If yes, go to step 207.
Step 205: and searching an actual character code corresponding to the initial font name, and storing the initial font name and the actual character code in a first association table in an associated manner to obtain an updated first association table.
Step 206: the specified character code is determined to be the initial character code.
Step 207: and determining the first character code corresponding to the initial font name as the initial character code.
Step 208: and judging whether the second association table contains the initial font name.
If yes, go to step 209, if no, go to step 210.
Step 209: the initial font name is determined as the target font name.
Step 210: it is determined whether the initial character code is a specified character code.
If yes, go to step 211, if no, go to step 212.
Step 211: and determining the default font name of the document display system as the target font name.
Step 212: and judging whether the initial character codes exist in the second association table.
If yes, go to step 213, if no, go to step 211.
Step 213: and determining the second font name corresponding to the initial character code as the target font name.
Step 214: and rendering the characters according to the fonts corresponding to the target font names.
According to the character rendering method provided by the invention, the initial font name of characters in the target document is obtained by responding to the display instruction of the target document; then, the initial font name is matched with each first character code in the first association table to determine the initial character code, so that the character codes are classified; under the condition that the second association table does not contain the initial font names, the initial character codes are matched with the second font names in the second association table, the target font names are determined, the similarity between the fonts corresponding to the target font names and the fonts corresponding to the initial font names is improved, the fonts corresponding to the target font names are more suitable, and the rendering accuracy of the document is improved after rendering; the format and style of the document can be better reserved, so that the rendering effect of the document is improved; and the readability and the aesthetic degree of the document can be improved by rendering with the proper fonts, so that the use experience of a user is improved.
The text rendering device provided by the invention is described below, and the text rendering device described below and the text rendering method described above can be correspondingly referred to each other.
Fig. 3 is a schematic structural diagram of a text rendering device according to the present invention, and as shown in fig. 3, the text rendering device 300 includes: a first acquisition module 301, a first matching module 302, a second matching module 303, and a rendering module 304, wherein:
a first obtaining module 301, configured to obtain, for a word in a target document, an initial font name of the word in response to a display instruction for the target document;
a first matching module 302, configured to match the initial font name with each first character code in a first association table, and determine an initial character code, where each collected first font name and a corresponding first character code are associated and stored in the first association table;
a second matching module 303, configured to match the initial character code with each second font name in a second association table, where the second association table does not include the initial font name, and determine a target font name, and the second association table stores each second font name and its corresponding second character code in the document display system in association;
And the rendering module 304 is configured to render the text according to the font corresponding to the target font name.
The character rendering device provided by the invention responds to the display instruction of the target document to acquire the initial font name of the characters in the target document; then, the initial font name is matched with each first character code in the first association table to determine the initial character code, so that the character codes are classified; under the condition that the second association table does not contain the initial font names, the initial character codes are matched with the second font names in the second association table, the target font names are determined, the similarity between the fonts corresponding to the target font names and the fonts corresponding to the initial font names is improved, the fonts corresponding to the target font names are more suitable, and the rendering accuracy of the document is improved after rendering; the format and style of the document can be better reserved, so that the rendering effect of the document is improved; and the readability and the aesthetic degree of the document can be improved by rendering with the proper fonts, so that the use experience of a user is improved.
Optionally, the second matching module 303 is further configured to:
Judging whether the initial character codes exist in the second association table or not under the condition that the second association table does not contain the initial font names;
if yes, determining a second font name corresponding to the initial character code as a target font name;
if not, determining the default font name of the document display system as the target font name.
Optionally, the second matching module 303 is further configured to:
judging whether the initial character code is a designated character code or not under the condition that the second association table does not contain the initial font name;
and if not, matching the initial character code with each second font name in the second association table, and determining the target font name.
Optionally, the text rendering device further includes a first determining module configured to:
and determining the initial font name as a target font name under the condition that the second association table contains the initial font name.
Optionally, the first matching module 302 is further configured to:
judging whether the initial font name exists in the first association table;
if yes, determining a first character code corresponding to the initial font name as an initial character code;
If not, determining the appointed character code as the initial character code.
Optionally, the text rendering device further includes:
the searching module is configured to search the actual character codes corresponding to the initial font names;
and the first storage module is configured to store the initial font name and the actual character code in the first association table in an associated mode, and obtain the updated first association table.
Optionally, the text rendering device further includes:
a second obtaining module configured to obtain each second font name in the document display system;
the second determining module is configured to determine second character codes corresponding to the second font names according to the first association table;
and the second storage module is configured to store the second font names and the corresponding second character encoding associations thereof into the second association table.
Fig. 4 illustrates a physical schematic diagram of an electronic device, as shown in fig. 4, which may include: processor 410, communication interface (Communications Interface) 420, memory 430 and communication bus 440, wherein processor 410, communication interface 420 and memory 430 communicate with each other via communication bus 440. Processor 410 may invoke logic instructions in memory 430 to perform a text rendering method comprising: responding to a display instruction of a target document, and aiming at characters in the target document, acquiring initial font names of the characters; matching the initial font name with each first character code in a first association table to determine an initial character code, wherein each first font name and the corresponding first character code are stored in association in the first association table; under the condition that the second association table does not contain the initial font names, matching the initial character codes with the second font names in the second association table to determine target font names, wherein the second association table is stored with the second font names and the corresponding second character codes in the document display system in an associated mode; and rendering the text according to the font corresponding to the target font name.
Further, the logic instructions in the memory 430 described above may be implemented in the form of software functional units and may be stored in a computer-readable storage medium when sold or used as a stand-alone product. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
In another aspect, the present invention also provides a computer program product, the computer program product including a computer program, the computer program being storable on a non-transitory computer readable storage medium, the computer program, when executed by a processor, being capable of executing the text rendering method provided by the above methods, the method comprising: responding to a display instruction of a target document, and aiming at characters in the target document, acquiring initial font names of the characters; matching the initial font name with each first character code in a first association table to determine an initial character code, wherein each first font name and the corresponding first character code are stored in association in the first association table; under the condition that the second association table does not contain the initial font names, matching the initial character codes with the second font names in the second association table to determine target font names, wherein the second association table is stored with the second font names and the corresponding second character codes in the document display system in an associated mode; and rendering the text according to the font corresponding to the target font name.
In yet another aspect, the present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, is implemented to perform the text rendering method provided by the above methods, the method comprising: responding to a display instruction of a target document, and aiming at characters in the target document, acquiring initial font names of the characters; matching the initial font name with each first character code in a first association table to determine an initial character code, wherein each first font name and the corresponding first character code are stored in association in the first association table; under the condition that the second association table does not contain the initial font names, matching the initial character codes with the second font names in the second association table to determine target font names, wherein the second association table is stored with the second font names and the corresponding second character codes in the document display system in an associated mode; and rendering the text according to the font corresponding to the target font name.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (9)

1. A text rendering method, comprising:
responding to a display instruction of a target document, and aiming at characters in the target document, acquiring initial font names of the characters;
matching the initial font name with each first character code in a first association table to determine an initial character code, wherein each first font name and the corresponding first character code are stored in association in the first association table;
under the condition that the second association table does not contain the initial font names, matching the initial character codes with the second font names in the second association table to determine target font names, wherein the second association table is stored with the second font names and the corresponding second character codes in the document display system in an associated mode;
rendering the characters according to the fonts corresponding to the target font names;
wherein, before the initial character code is matched with each second font name in the second association table and the target font name is determined, the method further comprises:
acquiring each second font name in the document display system;
determining second character codes corresponding to the second font names according to the first association table;
And storing the second font names and the corresponding second character coding associations into the second association table.
2. The text rendering method according to claim 1, wherein the matching the initial character code with each second font name in the second association table without the initial font name in the second association table, determining a target font name, includes:
judging whether the initial character codes exist in the second association table or not under the condition that the second association table does not contain the initial font names;
if yes, determining a second font name corresponding to the initial character code as a target font name;
if not, determining the default font name of the document display system as the target font name.
3. The text rendering method according to claim 1, wherein the matching the initial character code with each second font name in the second association table without the initial font name in the second association table, determining a target font name, includes:
judging whether the initial character code is a designated character code or not under the condition that the second association table does not contain the initial font name;
And if not, matching the initial character code with each second font name in the second association table, and determining the target font name.
4. A text rendering method according to any one of claims 1 to 3, wherein the matching the initial font name with each first character code in the first association table, after determining the initial character code, further comprises:
and determining the initial font name as a target font name under the condition that the second association table contains the initial font name.
5. The text rendering method of claim 1, wherein the matching the initial font name with each first character encoding in the first association table, determining an initial character encoding, comprises:
judging whether the initial font name exists in the first association table;
if yes, determining a first character code corresponding to the initial font name as an initial character code;
if not, determining the appointed character code as the initial character code.
6. The text rendering method of claim 5, wherein the if-not-then further comprises:
searching an actual character code corresponding to the initial font name;
And storing the initial font name and the actual character code association into the first association table to obtain the updated first association table.
7. A character rendering device, comprising:
the first acquisition module is configured to respond to a display instruction of a target document and acquire an initial font name of a word aiming at the word in the target document;
the first matching module is configured to match the initial font names with first character codes in a first association table, and determine initial character codes, wherein the first association table is stored with the collected first font names and the first character codes corresponding to the first font names in an associated mode;
the second matching module is configured to match the initial character code with each second font name in a second association table under the condition that the second association table does not contain the initial font name, and determine a target font name, wherein each second font name and the corresponding second character code in the document display system are stored in the second association table in an associated manner;
a rendering module configured to render the text according to the font corresponding to the target font name,
The text rendering device further comprises:
a second obtaining module configured to obtain each second font name in the document display system;
the second determining module is configured to determine second character codes corresponding to the second font names according to the first association table;
and the second storage module is configured to store the second font names and the corresponding second character encoding associations thereof into the second association table.
8. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the text rendering method of any of claims 1 to 6 when the program is executed by the processor.
9. A non-transitory computer readable storage medium having stored thereon a computer program, which when executed by a processor implements the text rendering method according to any of claims 1 to 6.
CN202310547146.7A 2023-05-16 2023-05-16 Text rendering method and device Active CN116306498B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310547146.7A CN116306498B (en) 2023-05-16 2023-05-16 Text rendering method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310547146.7A CN116306498B (en) 2023-05-16 2023-05-16 Text rendering method and device

Publications (2)

Publication Number Publication Date
CN116306498A CN116306498A (en) 2023-06-23
CN116306498B true CN116306498B (en) 2023-09-12

Family

ID=86817107

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310547146.7A Active CN116306498B (en) 2023-05-16 2023-05-16 Text rendering method and device

Country Status (1)

Country Link
CN (1) CN116306498B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116776828B (en) * 2023-08-28 2023-12-19 福昕鲲鹏(北京)信息科技有限公司 Text rendering method, device, equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101833542A (en) * 2010-04-21 2010-09-15 中兴通讯股份有限公司 Method and device for rendering fonts of user interface
CN103365894A (en) * 2012-03-29 2013-10-23 天津书生软件技术有限公司 Font format conversion method and device
CN104281601A (en) * 2013-07-05 2015-01-14 北大方正集团有限公司 Method and device for constructing huge character library and method and device for displaying characters

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120079374A1 (en) * 2010-09-29 2012-03-29 Apple Inc. Rendering web page text in a non-native font

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101833542A (en) * 2010-04-21 2010-09-15 中兴通讯股份有限公司 Method and device for rendering fonts of user interface
CN103365894A (en) * 2012-03-29 2013-10-23 天津书生软件技术有限公司 Font format conversion method and device
CN104281601A (en) * 2013-07-05 2015-01-14 北大方正集团有限公司 Method and device for constructing huge character library and method and device for displaying characters

Also Published As

Publication number Publication date
CN116306498A (en) 2023-06-23

Similar Documents

Publication Publication Date Title
CN109408821B (en) Corpus generation method and device, computing equipment and storage medium
CN116306498B (en) Text rendering method and device
CN112183296B (en) Simulated bill image generation and bill image recognition method and device
US8290925B1 (en) Locating product references in content pages
CN112613293B (en) Digest generation method, digest generation device, electronic equipment and storage medium
CN117391192B (en) Method and device for constructing knowledge graph from PDF by using LLM based on graph database
CN111444906B (en) Image recognition method and related device based on artificial intelligence
CN111159334A (en) Method and system for house source follow-up information processing
CN114708595A (en) Image document structured analysis method, system, electronic device, and storage medium
CN111160445B (en) Bid file similarity calculation method and device
CN114579796B (en) Machine reading understanding method and device
CN111597336A (en) Processing method and device of training text, electronic equipment and readable storage medium
JP2011065322A (en) Character recognition system and character recognition program, and voice recognition system and voice recognition program
CN115437930A (en) Identification method of webpage application fingerprint information and related equipment
CN111310442B (en) Method for mining shape-word error correction corpus, error correction method, device and storage medium
CN113591857A (en) Character image processing method and device and ancient Chinese book image identification method
CN113435217A (en) Language test processing method and device and electronic equipment
CN112949514A (en) Scanned document information processing method and device, electronic equipment and storage medium
CN111444716A (en) Title word segmentation method, terminal and computer readable storage medium
CN110909737A (en) Picture character recognition method and system
CN113722432B (en) Method and device for associating news with stocks
US20230326046A1 (en) Application matching method and application matching device
US20220075930A1 (en) Document search system and document search method
CN117993493A (en) Script generation method, device, equipment and storage medium based on logic atlas
CN116561732A (en) Multi-mode picture verification method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant