Text typesetting

By determining and using character measurement data to typeset with a supported font, the method maintains document aesthetics when original fonts are absent, addressing the challenge of inconsistent display due to missing fonts.

JP7955344B2Active Publication Date: 2026-11-24BEIJING KINGSOFT OFFICE SOFTWARE INC +1
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
JP2024513144
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2021-08-26
Filing Date
2021-12-28
Publication Date
2026-11-24
Estimated Expiration
2041-12-28

AI Technical Summary

Technical Problem

When a document's original fonts are missing, the document is displayed with a significantly different typesetting, affecting aesthetics and reading experience, and installing missing fonts is cumbersome and costly.

Method used

Determine the original font, check if the local application supports it, obtain character measurement data if it doesn't, and display the text using a supported font based on the original font's data to maintain consistency.

Benefits of technology

Maintains document typesetting consistency even when original fonts are missing by using character measurement data to typeset with a supported font, ensuring aesthetic continuity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007955344000001
    Figure 0007955344000001
  • Figure 0007955344000002
    Figure 0007955344000002
  • Figure 0007955344000003
    Figure 0007955344000003
Patent Text Reader

Abstract

The present invention relates to a method, an apparatus, an electronic device, a server, and a computer-readable storage medium for typesetting text, and relates to the computer technical field. According to an example of the method, when the method is applied to a local application executed on a terminal device, it may include the steps of: determining an original font to be used in a target text; determining whether the local application supports the original font; if the local application does not support the original font, obtaining character measurement data of the original font; displaying the target text in a first font supported by the local application; and typesetting the displayed target text based on the character measurement data of the original font.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] The present invention relates to the computer technology field, and more specifically to methods, apparatus, electronic devices, and storage media for typesetting text. [Background technology]

[0002] When a terminal device opens a document using a local application, if the document's original fonts are missing, the document may be displayed with a typesetting significantly different from the original, potentially affecting the document's aesthetics and reading experience. The current common solution is to install the missing fonts in the current environment. However, this method requires searching for, downloading, and installing fonts, and fonts may incur additional costs, making widespread adoption and application difficult. Therefore, a new method of text typesetting needs to be proposed. [Overview of the Initiative]

[0003] One objective of the embodiments of the present invention is to provide a novel text typesetting technique for maintaining consistency between document typesetting and the original typesetting when fonts are missing.

[0004] According to a first aspect of the present invention, a method for typesetting text is provided. The method includes the steps of: determining an original font to be used for target text; determining whether a local application supports the original font; if the local application does not support the original font, obtaining character measurement data for the original font; displaying the target text with a first font supported by the local application; and typesetting the displayed target text based on the character measurement data for the original font.

[0005] A second aspect of the present invention provides a method for typesetting text. The method includes: receiving a font identifier of the original font of a target text transmitted by a terminal device; searching for character measurement data of the original font based on the font identifier of the original font; and transmitting the character measurement data of the original font to the terminal device so that the terminal device typesets the target text displayed in a first font supported by a local application of the terminal device based on the character measurement data of the original font.

[0006] A third aspect of the present invention provides a text typesetting apparatus. The apparatus includes a first determination module for determining an original font to be used for target text; a second determination module for determining whether a local application supports the original font; an acquisition module for acquiring character measurement data of the original font if the local application does not support the original font; and a typesetting module for typesetting the target text displayed in a first font supported by a local application on a terminal device, based on the character measurement data of the original font.

[0007] A fourth aspect of the present invention provides a text typesetting apparatus. The apparatus includes a receiving module for receiving a font identifier of the original font of a target text transmitted by a terminal device; a searching module for searching for character measurement data of the original font based on the font identifier of the original font; and a transmitting module for transmitting character measurement data of the original font to the terminal device so that the terminal device displays the target text in a first font supported by its local application and typesets the target text based on the character measurement data of the original font.

[0008] According to a fifth aspect of the present invention, an electronic device is provided that includes a memory and a processor. The memory is used to store a computer program, and the processor is used to execute the computer program and carry out a method according to the first or second aspect of the present invention.

[0009] According to a sixth aspect of the present invention, a computer-readable storage medium storing a computer program is provided. When the computer program is executed by a processor, the method according to the first aspect of the present invention or the method according to the second aspect of the present invention is carried out.

[0010] One beneficial effect of the embodiments of the present invention is that, if a local application does not support the original font of the target document, the local application can maintain consistency between the document typesetting and the original typesetting even when the original font is missing from the local application by displaying the target text using a first font that it supports and typesetting the target text based on character measurement data corresponding to the original font.

[0011] Other features and advantages of embodiments of the present invention will become apparent from the following detailed description of exemplary embodiments of the present invention with reference to the accompanying drawings. [Brief explanation of the drawing]

[0012] The accompanying drawings, incorporated into the specification and constituting part of the specification, illustrate embodiments of the present invention and are used to explain the principles of these embodiments, along with their descriptions. [Figure 1] This is a schematic diagram of a document processing system according to an embodiment of the present invention. [Figure 2] This is a flowchart of a text typesetting method according to an embodiment of the present invention. [Figure 3] This is a schematic diagram of character measurement data according to an embodiment of the present invention. [Figure 4] This is an illustrative diagram of a text typesetting method according to an embodiment of the present invention. [Figure 5] It is a flowchart of a text typesetting method according to an embodiment of the present invention. [Figure 6] It is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present invention. [Figure 7] It is a schematic diagram of a hardware structure of a server according to an embodiment of the present invention. [[MODES FOR CARRYING OUT THE INVENTION]]

[0013] Hereinafter, various exemplary embodiments of the present invention will be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangements of components and steps, mathematical expressions, and values described in the following embodiments do not limit the scope of the present invention unless otherwise specified.

[0014] Hereinafter, the description of at least one exemplary embodiment is merely illustrative in nature and should not be construed as limiting the present invention, its application or use.

[0015] Techniques, methods and devices known to those skilled in the art may not be described in detail, but where appropriate, said techniques, methods and devices should be considered part of this specification.

[0016] In all examples shown and described herein, any specific values should be construed as merely illustrative and not limiting. Accordingly, other examples of the exemplary embodiments may have different values.

[0017] In the accompanying drawings below, similar reference numerals and alphabets are used to denote similar items, so once an item is defined in one drawing, no further explanation is required in subsequent drawings. (Text typesetting method)

[0018] FIG. 1 is a block diagram of a document processing system according to an embodiment of the present invention. As shown in FIG. 1, the document processing system includes a server 101 and a terminal device 103, and the server 101 and the terminal device 103 can communicate with each other via a network 102.

[0019] The configuration of the server 101 may include, but is not limited to, a processor 1011, a memory 1012, an interface device 1013, a communication device 1014, an input device 1015, and an output device 1016. The processor 1011 may include, but is not limited to, a central processing unit (CPU), a microcontroller unit (MCU), or the like. The memory 1012 may include, but is not limited to, a read-only memory (ROM), a random access memory (RAM), a non-volatile memory such as a hard disk, or the like. The interface device 1013 may include, but is not limited to, a universal serial bus (USB) interface, a serial interface, a parallel interface, or the like. The communication device 1014 can perform, for example, wired communication or wireless communication, and specifically may include WiFi communication, Bluetooth (registered trademark) communication, 2G / 3G / 4G / 5G communication, or the like. The input device 1015 includes, but is not limited to, a keyboard, a mouse, a touch screen, a microphone, or the like. The output device 1016 includes, but is not limited to, a display screen, a speaker, or the like. The configuration of the server 101 may also include only some of the aforementioned devices.

[0020] The terminal device 103 may be an electronic device on which a smart operating system (e.g., Android, iOS, Windows, Linux®, etc.) is installed, and includes, but is not limited to, portable computers, desktop computers, mobile phones, tablet computers, etc. The configuration of the terminal device 103 includes, but is not limited to, a processor 1031, memory 1032, interface device 1033, communication device 1034, GPU (Graphics Processing Unit) 1035, display device 1036, input device 1037, speaker 1038, microphone 1039, and camera 1030. The processor 1031 includes, but is not limited to, a central processing unit CPU, a microprocessor MCU, etc. The memory 1032 includes, but is not limited to, ROM (read-only memory), RAM (random access memory), non-volatile memory such as a hard disk, etc. The interface device 1033 includes, but is not limited to, a USB interface, a serial interface, a parallel interface, etc. The communication device 1034 can perform wired or wireless communication, for example, and may include WiFi communication, Bluetooth communication, 2G / 3G / 4G / 5G communication, etc. The GPU 1035 is used to process images. The display device 1036 includes, but is not limited to, a liquid crystal screen, a touchscreen, etc. The input device 1037 includes, but is not limited to, a keyboard, a mouse, a touchscreen, etc. The configuration of the terminal device 103 may include only some of the devices in the above-mentioned device.

[0021] In one embodiment of the present invention, a user can open a target text via a terminal device 103 and typeset and edit the target text. The local application may be, for example, document editing software, instant messaging software, office software, or a browser. In one example, the user may register an account with the local application in advance, and after logging into the account, the typesetting method according to the embodiment of the present invention can be used.

[0022] In one example, the local application is an application that can be executed on the terminal device, and may be, for example, a native application, a web application, a hybrid application, or a light application. A native application is an application that can be executed directly on the current operating system. A web application is a web application that needs to be executed in a browser. A hybrid application may be a combination of a native application and a web application, and is usually a native application that has a built-in browser. A light application is an application that can be used without requiring a download, and the user can use it by searching for it and using it directly, or by scanning a QR code (registered trademark).

[0023] The document processing system shown in Figure 1 is illustrative and does not limit the embodiments, applications, or uses of the present invention. While several server and terminal devices have been described earlier, those skilled in the art will understand that embodiments of the present invention may relate to only some of these devices. For example, a server may relate only to a processor, memory, and communication device, and a terminal device may relate only to a processor, memory, communication device, input device, and display screen. Those skilled in the art can design instructions according to the methods disclosed in the embodiments of the present invention. How instructions control the processor to perform actions is well-known in the art and therefore a detailed explanation is omitted here.

[0024] As shown in Figure 2, an embodiment of the present invention provides a method for typesetting text. The method includes steps S102 to S108. Steps S102 to S108 can be performed by a terminal device.

[0025] Step S102: Determine the original font to be used for the target text.

[0026] In embodiments of the present invention, the target text may be any part of the text in a document. In one example, the terminal device obtains the original font information of the target text from the document and determines the original font to be used for the target text. Generally, this original font information may be stored in the document data of the document.

[0027] In embodiments of the present invention, the font may include fonts loaded into the operating system of a terminal device, fonts loaded into a client of the terminal device (e.g., a browser or application), or fonts stored on a server, and may also be fonts embedded in a document file. Here, a document file may contain fonts, but a document file containing fonts usually has a relatively large amount of data. Furthermore, fonts loaded into the operating system of a terminal device, fonts loaded into a client of the terminal device, and fonts embedded in a document file all belong to the fonts supported by the local application of the terminal device and can be collectively referred to as local fonts. Fonts stored on a server can be called server fonts or cloud fonts.

[0028] Step S104: Determine whether the local application supports the original font.

[0029] After the original font to be used for the target text is determined, the local application checks whether that original font is included in all the fonts it supports. If it is not included, it is determined that the local application does not support that original font.

[0030] The fonts supported by a local application may be determined based on the installed font packets. For example, if a local application installs the font packet for a particular font, it means that the local application supports that font. Generally, the base packet of a local application comes pre-installed with many widely used font packets, and one of these fonts can be set as the default font. If a user wants to use a niche font, they will need to download the corresponding font packet separately. For example, if the original font is loaded into the terminal device's operating system or the local application, or if the original font is stored in the target text, the local application is considered to support that original font; otherwise, it is considered that the local application does not support that original font.

[0031] Step S106: If the local application does not support the original font, obtain the character measurement data for the original font.

[0032] In the embodiments of the present invention, "characters" include characters and symbols, and symbols include, but are not limited to, punctuation marks, mathematical symbols, special symbols, etc., while characters include, but are not limited to, Chinese characters, alphabets, etc.

[0033] In the embodiment of the present invention, the font's glyph measurement data includes the height and width of the glyph. The glyph measurement data of the original font includes the glyph width of the original font and the glyph height of the original font, which are the width and height of the glyph in the target text in the original font state. For the same font, at the same font size, the sizes of different glyphs may be designed to be the same or different. For the same font, at the same font size, if not all of its glyphs adopt the same size, a mapping relationship between the glyphs and the glyph width and height at the font size is established. In this way, the mapping relationship is used as the glyph measurement data of the corresponding font, and the width and height of each glyph in the corresponding font can be queried based on the mapping relationship.

[0034] In one example, the glyph measurement data further includes an ascent value of the glyph.

[0035] As shown in FIG. 3(a) and FIG. 3(b), for the same Chinese character "早", two different fonts have different widths and heights and different ascent values at the same font size. The width and height of the font shown in FIG. 3(b) are both smaller than those of the font in FIG. 3(a). The ascent value of the font shown in FIG. 3(a) is 0, that is, it is neither higher nor lower than the baseline. The ascent value of the font shown in FIG. 3(b) is a positive value, and the font is higher than the baseline. If the ascent value of the font is a negative value, it indicates that the font is lower than the baseline.

[0036] In one example, the glyph measurement data may further include other features for representing the position and / or size of the glyph, which is not limited herein.

[0037] In one example, the font's glyph measurement data may be obtained by measuring the glyph (for example, specifically an image model of the glyph). For example, the target text is displayed in a certain font in advance, and the glyph measurement data of the target text in the font is measured to obtain the glyph measurement data of the font.

[0038] In one example, the server may have pre-stored character measurement data for each font size of each font.

[0039] In one example, a terminal device obtaining character measurement data for the original font may involve searching the terminal device's local cache for character measurement data corresponding to the original font.

[0040] In one example, a terminal device obtaining character measurement data for an original font may first search its local cache for the original font's character measurement data, and if the data is not found in the local cache, it may obtain the original font's character measurement data from the server. In this example, after obtaining the original font's character measurement data from the server, the terminal device may store it in its local cache, allowing it to directly read the font's character measurement data from the local cache the next time it needs to use the font.

[0041] Step S108: The target text is displayed using the first font supported by the local application, and the target text is typeset based on the character measurement data of the original font.

[0042] In one example, the terminal device displays the target text in a first font according to the original font size of the target text, and typesets the target text displayed in the first font based on the character measurement data of the original font.

[0043] Before displaying the target text in a first font supported by the local application, the method may further include the step of determining the first font. In embodiments of the present invention, the terminal device selects a first font that matches the original font from all fonts supported by the local application. An example is given below.

[0044] Example 1 for determining the first font: Selecting a first font that matches the original font from all fonts supported by the local application may involve steps S202-S206.

[0045] Step S202: Obtain the replacement font list for the original font.

[0046] In one example, the degree of match between any one font and other fonts is detected in advance, and fonts whose match degree reaches a match degree threshold are selected as replacement fonts for that font. In an embodiment of the present invention, the degree of match between two fonts can be determined based on character measurement data of the two fonts. For any one font, a list of replacement fonts is established based on its replacement font, and the replacement fonts in the replacement font list may be sorted in descending order of match degree. The terminal device may obtain the list of replacement fonts for each font from the server.

[0047] The following explains how to determine the degree of match between font B and font A, using font A as an example.

[0048] The first difference is calculated as the difference between the width of character C in font A and the width of character C in font B.

[0049] The second difference is calculated as the difference between the height of character C in font A and the height of character C in font B. Here, character C may be a single character or a string of characters.

[0050] In one example, the degree of match between font B and font A is determined based on the absolute value of the first difference. Here, the larger the absolute value of the first difference, the lower the degree of match between font B and font A, and the smaller the absolute value of the first difference, the higher the degree of match between font B and font A.

[0051] In one example, the degree of match between font B and font A is determined based on the absolute value of the second difference. Here, the larger the absolute value of the second difference, the lower the degree of match between font B and font A, and the smaller the absolute value of the second difference, the higher the degree of match between font B and font A.

[0052] In one example, the sum of the absolute values ​​of the first difference and the absolute values ​​of the second difference is calculated, and the degree of match between font B and font A is determined based on this sum. The larger the sum, the lower the degree of match between font B and font A, and the smaller the sum, the higher the degree of match between font B and font A.

[0053] In step S204, a candidate font is determined from the replacement fonts in the replacement font list, and the candidate font is a font supported by the local application.

[0054] Step S206: The font with the highest degree of match to the original font among the candidate fonts is selected as the first font.

[0055] In this example, a candidate font supported by the local application is selected from the replacement fonts in the replacement font list, and then the candidate font that best matches the original font (for example, the candidate font ranked highest in the replacement font list sorted by matching degree, as mentioned above) is selected as the first font.

[0056] Determining the first font using candidate fonts supported by the local application in the replacement font list is more convenient and faster, as it eliminates the need for the terminal device to perform complex calculations.

[0057] Example 2 for determining the first font: Selecting a first font that matches the original font from all fonts supported by the local application may involve steps S302-S304.

[0058] Step S302: Determine the character type of the target text.

[0059] Character types include Type 1 and Type 2. Type 1 refers to target text characters that are square characters such as Chinese characters, where the width and height of different Chinese characters are approximately the same. Type 2 refers to target text characters that include alphabets, Roman letters, Mongolian script, or Arabic script, or a mixture of multiple languages, where the width and height of these characters may not match.

[0060] Step S304: Select a first font that matches the original font from all fonts supported by the local application, according to predetermined rules related to the character type of the target text.

[0061] In this example, the first font is determined based on the rules corresponding to the character type of the target text, and this will be explained below using Examples 3, 4, 5, and 6.

[0062] Example 3 for determining the first font: Selecting a first font that matches the original font from all fonts supported by the local application may involve steps S402 to S406.

[0063] Step S402: Character measurement data for candidate fonts is obtained, and the candidate fonts are fonts supported by the local application.

[0064] Step S404: Determine the typesetting direction of the target text.

[0065] Step S406: If the target text is typeset horizontally, the candidate font whose character width is closest to the original font's character width is selected as the first font. If the target text is typeset vertically, the candidate font whose character height is closest to the original font's character height is selected as the first font.

[0066] If the target text is typeset in landscape orientation, the difference between the character width in the original font and the character width in the candidate font is calculated as the first difference. The smaller the absolute value of the first difference, the closer the character width of the candidate font is to the character width of the original font. The candidate font with the smallest absolute value of the first difference is selected as the first font.

[0067] If the target text is typeset in portrait orientation, the difference between the character height in the original font and the character height in the candidate font is calculated as the second difference. The smaller the absolute value of the second difference, the closer the character height of the candidate font is to the character height of the original font. The candidate font with the smallest absolute value of the second difference is selected as the first font.

[0068] Example 3 applies when the character type of the target text is the first type and / or the second type. In other words, whether the target text contains only kanji characters or contains alphabets and Roman letters, the method in Example 3 can be applied to determine the first font.

[0069] Example 4 for determining the first font: Selecting a first font that matches the original font from all fonts supported by the local application may include steps S502-S508.

[0070] Step S502: Obtain the font attributes of the original font and the font attributes of the candidate fonts. The candidate fonts are fonts supported by the local application.

[0071] Font attributes are inherent attributes of the font itself, and they can express the style of that font. Font attributes may include one or more of the following: font weight, blackness, slant, etc.

[0072] For example, the font thickness can have three attribute values: "bold," "normal," and "thin," ranging from bold to thin. For example, the font blackening can have two attribute values: "blackened" and "not blackened." For example, the font slant can have two attribute values: "slant" and "not slant."

[0073] For example, regarding the three fonts "Song type", "Huawen Thin Black", and "Fangzheng Bold Black Song Simplified Type", the font attributes for "Song type" are "thin" for thickness, "no blackening", and "no slant", the font attributes for "Huawen Thin Black" are "thin" for thickness, "blackened", and "no slant", and the font attributes for "Fangzheng Bold Black Song Simplified Type" are "bold" for thickness, "blackened", and "no slant".

[0074] For example, regarding the two fonts "Times New Roman" and "Forte," the font attributes for "Times New Roman" are "thin" for weight, "no blackening" for blackening, and "no slant" for slant, while the font attributes for "Forte" are "bold" for weight, "blackened" for blackening, and "slant" for slant.

[0075] In step S504, a candidate font whose font attributes are the same as those of the original font is selected as the target font, and character measurement data for the target font is obtained.

[0076] For example, if the font attributes of a font include only the font weight, and both the candidate font and the original font are "bold," or both are "normal," or both are "thin," then the attributes of the candidate font and the original font are considered to be the same.

[0077] In one example, the font attributes of a font include the font weight, blackness, and slant. If the weight, blackness, and slant values ​​of all three attributes match between the candidate font and the original font, then the attributes of the candidate font and the original font are considered to be the same.

[0078] Step S506: Determine the typesetting direction of the target text.

[0079] Step S508: If the target text is typeset in landscape orientation, the target font whose character width is closest to the character width of the original font is determined as the first font. If the target text is typeset in portrait orientation, the target font whose character height is closest to the character height of the original font is determined as the first font.

[0080] The method for realizing step S508 may be similar to that of step S406 described above, and a detailed explanation will be omitted here.

[0081] Example 4 applies when the character type of the target text is the first type and / or the second type. In other words, whether the target text contains only kanji or contains alphabets and Roman letters, the method in Example 4 can be applied to determine the first font.

[0082] In this example, candidate fonts whose font attributes differ from those of the original font are filtered from all candidate fonts, candidate fonts whose font attributes are the same as those of the original font are kept as target fonts, and a first font is determined from the target font based on the character measurement data of the original font. As a result, the style of the selected first font and the style of the original font are basically matched, and the target text displayed with the first font supported by the local application is brought closer to the style of the target text in the original font.

[0083] In Example 5 for determining the first font, selecting a first font that matches the original font from all fonts supported by the local application, according to predetermined rules related to the character type of the target text, may involve the terminal device sending a font identifier of a candidate font to the server, the server then sending a font identifier of the first font to the terminal device, and the terminal device receiving the font identifier of the first font from the server, so that the server determines the first font from the candidate fonts based on the font attributes of the original font and the width of a predetermined string in the original font. Here, the font identifier may be a name or number, etc., for identifying the font.

[0084] Alternatively, in Example 6 for determining the first font, selecting a first font that matches the original font from all fonts supported by the local application, according to predetermined rules related to the character type of the target text, may involve the terminal device obtaining the font attributes of the original font and a predetermined string width in the original font from the server, and determining the first font from candidate fonts based on the font attributes of the original font and the predetermined string width in the original font.

[0085] Here, the candidate font is a font supported by the local application, and the predetermined character string includes a plurality of different predetermined characters. The predetermined characters in the predetermined character string are preferably representative in terms of either character width or character height. For example, an arbitrary Kanji character and "w", "z", and "i" having representative English character widths may be selected to form the predetermined character string. Here, "w", "z", and "i" represent English characters of three different widths, and the predetermined character string may be "明WwZzIi".

[0086] Examples 5 and 6 are applied when the character type of the target text is the second type. That is, when the target text includes characters such as alphabets, Roman characters, Mongolian characters, Arabic characters, etc., or when multiple languages are mixed, the methods of Examples 5 and 6 may be applied to determine the first font. For example, when the character type of the target text is an alphabet type or a multilingual mixed type (for example, when the target text includes Chinese content and English content at the same time, or when the target text includes Chinese content and Japanese content at the same time), the methods of Examples 5 and 6 may be applied to determine the first font. By determining the first font based on the width of the predetermined character string, it is suitable when the character widths of different characters are different, and the calculation amount is small, which is more efficient and faster.

[0087] In an example, the candidate fonts include a default font and a non-default font supported by the local application. A default font is preset in the local application, the default font is set when the application is installed on the terminal device, and the user can change the default font according to personal preference.

[0088] Determining the first font from the candidate fonts based on the font attribute of the original font and the width of the predetermined character string in the original font may include steps S602 to S604.

[0089] In step S602, if the font attributes of the default font supported by the local application and the original font are the same, and the similarity between the width of a given string in the default font and the width of a given string in the original font satisfies a predetermined criterion, the default font is determined to be the first font. Otherwise, step S604 is executed.

[0090] In one example, determining whether the similarity between the width of a given string in the default font and the width of a given string in the original font meets a predetermined criterion may include steps S6022 to S6026.

[0091] In step S6022, the difference between the width of a given string in the default font and the width of a given string in the original font is determined as the fourth difference.

[0092] In step S6024, the ratio of the absolute value of the fourth difference to the width of a given string in the original font is determined as the first ratio.

[0093] In step S6026, if the first ratio is less than or equal to a predetermined first threshold, it is determined that the similarity between the width of a predetermined string in the default font and the width of a predetermined string in the original font meets a predetermined standard. If the first ratio is greater than a predetermined first threshold, it is determined that the similarity between the width of a predetermined string in the default font and the width of a predetermined string in the original font does not meet a predetermined standard.

[0094] In one example, the similarity between the width and height of a given string in the default font and the width and height of a given string in the original font satisfying a predetermined criterion may include the ratio of the width of a given string in the default font to the width of a given string in the original font being between 0.95 and 1.05, that is, the first ratio being between 0 and 0.05.

[0095] In step S604, candidate fonts whose font attributes are the same as those of the original font are selected as the target font, and the first font is determined from the target font.

[0096] In step S604, from all candidate fonts (including default and non-default fonts), a candidate font whose font attributes are the same as those of the original font is selected as the target font.

[0097] In one example, determining the first font from the target font in step S604 may mean determining the target font as the first font whose width is closest to the width of a given string in the original font.

[0098] The difference between the width of a given string in the original font and its width in the target font is calculated as a third difference. The smaller the absolute value of this third difference, the closer the width of the given string in the target font is to the width of the given string in the original font. The target font with the smallest absolute value of this third difference is selected as the first font. In this way, the typesetting of the target text displayed to the user by the local application can be made closer to the original typesetting of the target text before typesetting, requiring only minor adjustments during typesetting.

[0099] In one example, determining the first font from the target font in step S604 may mean determining the target font with the smallest width for a given string as the first font.

[0100] By selecting the target font with the narrowest width for a given string as the first font, the local application can avoid overlapping or overwriting of characters when displaying the target text with the first font, making it less likely for users to experience viewing problems due to overlapping or overwriting even before typesetting.

[0101] In this example, considering the user's font usage habits, it is conceivable to prioritize the default font as the first font to replace the original font. Furthermore, if the font attributes of the default font and the original font differ, or if the similarity between the width of a given string in the default font and the width of a given string in the original font does not meet a predetermined criterion, the first font is determined from candidate fonts whose font attributes are the same as those of the original font. This takes user preferences into account, reduces computational complexity, and shortens processing time.

[0102] In Examples 2 to 6 above, which determine the first font, the implementation method for determining the similarity and match between the candidate font, target font, and original font can also be applied to determining the replacement font in the replacement font list.

[0103] In step S108, there are various methods for the terminal device to display the target text using a first font supported by the local application and to typeset the target text displayed in the first font based on the character measurement data of the original font. Examples are given below.

[0104] Typesetting Example 1: First, determine the typesetting direction of the target text, and typeset the target text displayed on the terminal device using the first font based on the target text's typesetting direction. If the target text's typesetting direction is landscape, perform a first scaling process on the target text characters so that the character width of the target text matches the character width of the original font. If the target text's typesetting direction is portrait, perform a second scaling process on the target text characters so that the character height of the target text matches the character height of the original font.

[0105] In Example 1, text scaling can be achieved by adjusting the font size.

[0106] In one embodiment, in step S108, typesetting the target text displayed on the terminal device based on character measurement data corresponding to the original font may be replaced with acquiring character measurement data corresponding to the first font and typesetting the target text displayed on the terminal device based on the character measurement data corresponding to the original font and the character measurement data corresponding to the first font.

[0107] Typesetting Example 2: First, determine the typesetting direction of the target text, and typeset the target text displayed on the terminal device using the first font based on the target text's typesetting direction. If the target text is typeset horizontally, determine the first difference, which is the difference between the character width of the original font and the character width of the first font. If the first difference is a positive value, adjust the horizontal coordinate values ​​of the target text characters. If the first difference is a negative value, shrink the target text characters. If the target text is typeset vertically, determine the second difference, which is the difference between the character height of the original font and the character height of the first font. If the second difference is a positive value, adjust the vertical coordinate values ​​of the target text characters. If the second difference is a negative value, shrink the target text characters.

[0108] In this example, the reduction in font size can be achieved by adjusting the font size.

[0109] The following explanation uses the example of the target text being typeset in landscape orientation.

[0110] As shown in Figure 3(a), the character width of each character in the original font is approximately W1. As shown in Figure 3(b), the character width of each character in the first font is approximately W2. The difference between W1 and W2, DW (=W1-W2), is calculated as the first difference.

[0111] If the first difference DW is a positive value, it indicates that the character width of the first font is smaller than that of the original font. In this case, the horizontal coordinate values ​​of each character in the target text in the first font need to be adjusted.

[0112] As shown in Figure 4, the target text is a single line of content containing the 10 characters "Good morning, it's a beautiful day". In the original font, the horizontal coordinate values ​​of the 10 characters are X1, X2, ..., X 10 Therefore, after typesetting, the horizontal coordinate values ​​of the 10 characters are X1', X2', ..., X 10 'That is, X1' = X1 + 0.5 * DW, X2' = X2 + (2-1)*DW + 0.5*DW, ... X n '=X n +(n-1)*DW+0.5*DW, ... X 10 '=X 10 +(10-1)*DW+0.5*DW This is the result.

[0113] However, n is an integer, and 1 ≤ n ≤ 10.

[0114] It can be seen that adjusting the horizontal coordinate values ​​of each character in the content of this line in the first font is equivalent to adjusting the spacing between adjacent characters in the content of this line.

[0115] If the first difference DW is a negative value, it indicates that the character width of the first font is greater than that of the original font. Adjusting the coordinate values ​​may cause overlapping of characters, so the font size of the target text displayed in the first font by the terminal device needs to be reduced. In one example, the font size of the target text displayed in the first font by the terminal device is reduced based on the ratio of W1 / W2, while maintaining the original position (coordinate value) of the target text in the first font. For example, if W1 / W2 = R1 and the original font size of this content is U1, the font size of this content is adjusted to U2, so U2 = R1 * U1. In this text, the font size is measured in points, which is a method of measuring printing typefaces well known to those skilled in the art, and examples include 5 points, 12 points, etc.

[0116] The following explanation uses the example of the target text being typeset in portrait orientation.

[0117] As shown in Figure 3(a), the character height of each character in the original font is H1. As shown in Figure 3(b), the character height of each character in the first font is H2. The difference between H1 and H2, DH (=H1-H2), is calculated as the second difference.

[0118] If the second difference DH is a positive value, it indicates that the character height of the first font is smaller than the character height of the original font. In this case, the vertical coordinate values ​​of each character in the first font are adjusted.

[0119] The target text in the original font has a total of M lines of content, with the vertical coordinate values ​​of the characters in each line being the same, and the vertical coordinate values ​​of the characters from line 1 to line M being Y1, Y2, ..., Y M And after typesetting, the vertical coordinate values ​​of the characters from line 1 to line M are Y1', Y2', ..., Y M 'That is, Y1' = Y1 + 0.5 * DH, Y2’=Y2+(2-1)*DH+0.5*DH, ... Y m ’=Y m +(m-1)*DH+0.5*DH, ... Y M ’=Y M +(M-1)*DH+0.5*DH is obtained.

[0120] Here, m is an integer, and 1≦m≦M.

[0121] It can be seen that adjusting the coordinate value of the ordinate of each character of the target text in the first font is equivalent to adjusting the line spacing of adjacent lines of the target text.

[0122] If the second difference DH is a negative value, it indicates that the character height of the first font is greater than the character height of the original font, and adjusting the coordinate value may cause characters to overlap, so it is necessary for the terminal device to reduce the font size of the target text displayed in the first font. In one example, the font size of the target text displayed in the first font by the terminal device is reduced based on the ratio of H1 / H2, and the position (coordinate value) of the original target text in the first font is maintained as it is. For example, assuming H1 / H2=R2 and the original font size of the target text is U1, the font size is adjusted to U2, and U2=R2*U1.

[0123] Typesetting Example 3: First, determine the typesetting direction of the target text, and typeset the target text displayed on the terminal device in the first font based on the typesetting direction of the target text. If the typesetting direction of the target text is landscape, adjust the font size of the target text to the first font size, which is the font size in which the character width is closest to the character width of the original font. Determine the first difference, which is the difference between the character width of the original font and the character width of the first font. If the first difference is a positive value, adjust the horizontal coordinate value of the characters in the target text; if the first difference is a negative value, shrink the characters in the target text. If the typesetting direction of the target text is portrait, the font size of the target text is adjusted to a second font size, which is the font size whose character height is closest to the character height of the original font. A second difference is determined, which is the difference between the character height of the original font and the character height of the first font. If the second difference is a positive value, the vertical coordinate values ​​of the characters in the target text are adjusted. If the second difference is a negative value, the characters in the target text are reduced in size.

[0124] In other words, if the target text is typeset in landscape orientation, and the terminal device adjusts the font size of the target text in the first font to the first font size, if the character width is still greater than the character width in the original font, the font size is reduced by one unit to shrink the characters and avoid situations where characters overwrite each other.

[0125] Similarly, if the target text is typeset in portrait orientation, and the terminal device adjusts the font size of the target text in the first font to the second font size, if the character height is still greater than the character height in the original font, the font size should be reduced by one unit to shrink the characters and avoid situations where characters overlap.

[0126] In this example, the reduction in font size can be achieved by adjusting the font size.

[0127] After the terminal device typesset the displayed target text, the typeset display of the target text is closer to the typeset display of the target text in the original font. As shown in Figure 4, for the target text "Good morning, it's a nice day," the total width of this content in the original font is wider than that in the first font. After typesetting in step S108, the total width of this content displayed by the terminal device in the first font is closer to the total width of this content in the original font. In this way, it can be guaranteed that content on the same line in the original font will not be split when displayed in the first font.

[0128] Typesetting example 4: Typesetting the target text based on character measurement data of the original font may include steps S1085 to S1087.

[0129] Step S1085: Divide the target text into words.

[0130] Step S1086: The difference between the width of each character in the word in the first font and the width in the original font is accumulated to obtain the adjustment amount.

[0131] In step S1087, the ratio of the adjustment amount to the number of character spaces in a word is calculated as a second ratio, and the character spaces in a word are adjusted based on this second ratio so that the character spaces in the word are the same.

[0132] For example, one word in the target text has a total of T characters, and the number of character spaces is G, where G = T-1. Here, the difference between the width of each character in the T characters in the first font and the width in the original font is, in order, O1, O2, ..., O T O1, O2, ..., O TThe adjustment amount is obtained by accumulating the values, and a second ratio is calculated between the adjustment amount and the number of character spaces. If the second ratio is positive, it indicates that the adjustment amount is positive and that the character spaces in the word need to be reduced. In this case, the second ratio is subtracted from the character spaces in the word. If the second ratio is negative, it indicates that the adjustment amount is negative and that the character spaces in the word need to be increased. In this case, the second ratio is subtracted from the character spaces in the word, i.e., the absolute value of the second ratio is added.

[0133] This allows for consistent spacing between characters within the same word, resulting in a more uniform display. It can be applied to the second type of target text, and even when different characters have varying widths, it allows for a more uniform display of characters within the same word. Typesetting example 4 may be performed after any of the typesetting examples mentioned above.

[0134] In one example, the local application first typesets the width and height of the target text characters, and then adjusts the character height of the target text characters according to the character height values ​​corresponding to the original font.

[0135] One beneficial effect of the embodiments of the present invention is that, if a local application on a terminal device does not support the original font of the target text, the local application can display the target text using a first font it supports and typeset the target text based on the character measurement data of the original font, thereby maintaining consistency between the document typesetting and the original typesetting even when the original font is missing from the local application.

[0136] As shown in Figure 5, an embodiment of the present invention provides a method for typesetting text. The method includes steps S702 to S706. Steps S702 to S706 may be performed by a server.

[0137] Step S702: The terminal device receives the font identifier of the original font of the target text sent by the terminal device.

[0138] Step S704: Based on the font identifier of the original font, the character measurement data of the original font is searched.

[0139] Step S706: The terminal device receives character measurement data of the original font so that it can typeset the target text displayed in a first font supported by its local application, based on the character measurement data of the original font.

[0140] In one example, the server pre-stores the font attributes of each font and character measurement data for each font size. The character measurement data may include the height and width of the characters. The character measurement data may further include the rise value of the characters. Font attributes are the unique attributes of the font itself and can express the style of that font. Font attributes may include one or more of the following: font weight, blackness, slant, etc.

[0141] In one example, before the terminal device displays the target text in a first font supported by its local application, the method further includes the step of obtaining a list of replacement fonts for the original font based on the font identifier of the original font. Candidate fonts are determined from the replacement fonts in the list of replacement fonts, and these candidate fonts are fonts supported by the terminal device's local application. The candidate font in the list of replacement fonts that best matches the original font is determined to be the first font. The identifier of the first font is sent to the terminal device.

[0142] In one example, before the terminal device displays the target text in a first font supported by its local application, the method further includes sending the font attributes of an original font and the width of a predetermined string in the original font to the terminal device so that the terminal device determines the first font from candidate fonts based on the font attributes of the original font and the width of a predetermined string in the original font. Here, the candidate font is a font supported by the terminal device's local application, and the predetermined string includes a plurality of different predetermined characters.

[0143] In one example, before the terminal device displays the target text in a first font supported by its local application, the method further includes determining a first font from candidate fonts based on the font attributes of the original font and the width of a predetermined string in the original font, and sending the font identifier of the first font to the terminal device. Here, the candidate fonts are fonts supported by the terminal device's local application, and the predetermined string includes several different predetermined characters.

[0144] In one example, candidate fonts include both default and non-default fonts supported by the local application.

[0145] In one example, determining a first font from candidate fonts based on the font attributes of the original font and the width of a predetermined string in the original font includes determining the default font as the first font if the font attributes of the default font and the original font are the same, and the similarity between the width of a predetermined string in the default font and the width of a predetermined string in the original font satisfies a predetermined criterion. Otherwise, a candidate font whose font attributes are the same as those of the original font is designated as the target font, and the first font is determined from the target font.

[0146] In one example, determining whether the similarity between the width of a given string in the default font and the width of a given string in the original font meets a predetermined criterion includes determining the difference between the width of the given string in the default font and the width of the given string in the original font as a fourth difference. The ratio of the absolute value of the fourth difference to the width of the given string in the original font is determined as a first ratio. If the first ratio is less than or equal to a predetermined first threshold, it is determined that the similarity between the width of the given string in the default font and the width of the given string in the original font meets a predetermined criterion. If the first ratio is greater than a predetermined first threshold, it is determined that the similarity between the width of the given string in the default font and the width of the given string in the original font does not meet a predetermined criterion.

[0147] In one example, determining a first font from a target font includes determining the target font whose width is closest to the width of a given string in the original font as the first font, or determining the target font whose width of a given string is smallest as the first font.

[0148] One beneficial effect of the embodiment of the present invention is that, if the local application on the terminal device does not support the original font of the target text, the server provides the terminal device with character measurement data for the original font so that the terminal device can typeset the target text displayed in a first font supported by the local application based on character measurement data corresponding to the original font. This allows consistency between the document typesetting and the original typesetting to be maintained even when the original font is missing from the local application. <Examples of devices>

[0149] Embodiments of the present invention provide a text typesetting apparatus, which includes the following modules.

[0150] The first decision module is used to determine the original font to be used for the target text.

[0151] The second decision module is used to determine whether the local application supports the original font.

[0152] The acquisition module retrieves character measurement data for the original font if the local application does not support the original font.

[0153] The typesetting module is used to typeset target text displayed in a first font supported by the terminal device's local application, based on the character measurement data of the original font.

[0154] In one example, obtaining character measurement data for an original font includes either searching for character measurement data for an original font in the terminal device's local cache, or, if character measurement data for an original font is not found in the terminal device's local cache, obtaining character measurement data for an original font from a server and storing it in the local cache.

[0155] In one example, before displaying the target text in a first font supported by the local application, the local application further includes selecting a first font that matches the original font from all fonts supported by the local application, and then displaying the target text in the selected first font.

[0156] In one example, selecting a first font that matches the original font from all fonts supported by the local application includes obtaining a list of replacement fonts for the original font. Candidate fonts are determined from the replacement fonts in the replacement font list, and these candidate fonts are fonts supported by the local application. The font with the highest degree of match to the original font among the candidate fonts is determined to be the first font.

[0157] In one example, displaying target text in a first font supported by the local application includes determining the character type of the target text. According to predetermined rules related to the character type of the target text, the local application selects a first font from all supported fonts that matches the original font, and then displays the target text in the selected first font.

[0158] In one example, the character measurement data for the original font includes the character width and character height of the original font. Selecting a first font that matches the original font from all fonts supported by the local application includes obtaining character measurement data for candidate fonts, where the candidate fonts are fonts supported by the local application. Determine the typesetting direction of the target text. If the typesetting direction of the target text is landscape, the candidate font whose character width is closest to the character width of the original font is determined as the first font. If the typesetting direction of the target text is portrait, the candidate font whose character height is closest to the character height of the original font is determined as the first font.

[0159] In one example, the character measurement data for the original font includes the character width and character height of the original font.

[0160] Selecting a first font that matches the original font from all fonts supported by the local application involves obtaining the font attributes of the original font and the candidate fonts, where the candidate fonts are fonts supported by the local application. The candidate font whose font attributes are the same as those of the original font is determined as the target font, and character measurement data for the target font is obtained. The typesetting direction of the target text is determined. If the typesetting direction of the target text is landscape, the target font whose character width is closest to the character width of the original font is determined as the first font. If the typesetting direction of the target text is portrait, the target font whose character height is closest to the character height of the original font is determined as the first font.

[0161] In one example, if the character type of the target text is an alphabetic type or a multilingual mixed type, selecting a first font that matches the original font from all fonts supported by the local application based on predetermined rules related to the type includes sending the font identifier of the candidate fonts to the server and receiving the font identifier of the first font from the server, so that the server determines the first font from the candidate fonts based on the font attributes of the original font and the width of a predetermined string in the original font. Alternatively, the font attributes of the original font and the width of a predetermined string in the original font are obtained from the server, and the first font is determined from the candidate fonts based on the font attributes of the original font and the width of a predetermined string in the original font. Here, the candidate fonts are fonts supported by the local application, and the predetermined string contains multiple different predetermined characters.

[0162] In one example, candidate fonts include both default and non-default fonts supported by the local application.

[0163] Determining a first font from candidate fonts based on the font attributes of the original font and the width of a predetermined string in the original font includes determining the default font as the first font if the font attributes of the default font and the original font are the same, and the similarity between the width of a predetermined string in the default font and the width of a predetermined string in the original font satisfies a predetermined criterion. Otherwise, a candidate font whose font attributes are the same as those of the original font is designated as the target font, and the first font is determined from the target font.

[0164] In one example, determining whether the similarity between the width of a given string in the default font and the width of a given string in the original font meets a predetermined criterion includes determining the difference between the width of the given string in the default font and the width of the given string in the original font as a fourth difference. The ratio of the absolute value of the fourth difference to the width of the given string in the original font is determined as a first ratio. If the first ratio is less than or equal to a predetermined first threshold, it is determined that the similarity between the width of the given string in the default font and the width of the given string in the original font meets a predetermined criterion.

[0165] In one example, determining a first font from a target font includes determining the target font whose width is closest to the width of a given string in the original font as the first font, or determining the target font whose width of a given string is smallest as the first font.

[0166] In one example, the character measurement data for the original font includes the character width and character height of the original font.

[0167] Typesetting target text based on character measurement data of the original font includes determining the typesetting direction of the target text. If the typesetting direction of the target text is landscape, a first difference is determined, which is the difference between the character width of the target text characters in the original font and the character width in the first font. If the first difference is a positive value, the horizontal coordinate values ​​of the target text characters displayed in the first font are adjusted. If the first difference is a negative value, the target text characters displayed in the first font are scaled down. If the typesetting direction of the target text is portrait, a second difference is determined, which is the difference between the character height of the target text characters in the original font and the character height in the first font. If the second difference is a positive value, the vertical coordinate values ​​of the target text characters displayed in the first font are adjusted. If the second difference is a negative value, the target text characters displayed in the first font are scaled down.

[0168] In one example, the character measurement data for the original font includes the character width of the original font.

[0169] Typesetting target text based on character measurement data of the original font includes dividing the target text into words. The difference between the width of each character in the first font and the width in the original font is accumulated to obtain an adjustment amount. The ratio of the adjustment amount to the number of character spaces in the word is calculated as a second ratio, and the character spaces in the word are adjusted based on the second ratio so that the character spaces in the word are the same.

[0170] Embodiments of the present invention provide a text typesetting apparatus, which includes the following modules.

[0171] The receiving module is used to receive the font identifier of the original font of the target text transmitted by the terminal device.

[0172] The search module is used to retrieve character measurement data for the original font based on the font identifier of the original font.

[0173] The transmission module is used to transmit character measurement data of the original font to the terminal device so that the terminal device typesset the target text displayed in a first font supported by the terminal device's local application based on the character measurement data of the original font.

[0174] In one example, displaying target text in a first font supported by a terminal device's local application involves obtaining a list of replacement fonts for the original font based on the font identifier of the original font. Candidate fonts are determined from the replacement fonts in the list of replacement fonts, and these candidate fonts are fonts supported by the local application. The candidate font sorted highest in the list of replacement fonts is determined to be the first font. The identifier of the first font is sent to the terminal device, and the target text is displayed in the selected first font.

[0175] In one example, the system further includes transmitting the font attributes of an original font and the width of a predetermined string in the original font to a terminal device so that the terminal device determines a first font from among candidate fonts based on the font attributes of the original font and the width of a predetermined string in the original font. Alternatively, the system determines a first font from among candidate fonts based on the font attributes of the original font and the width of a predetermined string in the original font, and transmits the font identifier of the first font to the terminal device. Here, the candidate fonts are fonts supported by the local application, and the predetermined string contains multiple different predetermined characters.

[0176] In one example, candidate fonts include both default and non-default fonts supported by the local application.

[0177] Determining a first font from candidate fonts based on the font attributes of the original font and the width of a predetermined string in the original font includes determining the default font as the first font if the font attributes of the default font and the original font are the same, and the similarity between the width of a predetermined string in the default font and the width of a predetermined string in the original font satisfies a predetermined criterion. Otherwise, a candidate font whose font attributes are the same as those of the original font is designated as the target font, and the first font is determined from the target font.

[0178] In one example, determining whether the similarity between the width of a given string in the default font and the width of a given string in the original font meets a predetermined criterion includes determining the difference between the width of the given string in the default font and the width of the given string in the original font as a fourth difference. The ratio of the absolute value of the fourth difference to the width of the given string in the original font is determined as a first ratio. If the first ratio is less than or equal to a predetermined first threshold, it is determined that the similarity between the width of the given string in the default font and the width of the given string in the original font meets a predetermined criterion.

[0179] In one example, determining a first font from a target font includes determining the target font whose width is closest to the width of a given string in the original font as the first font, or determining the target font whose width of a given string is smallest as the first font.

[0180] Figure 6 is a schematic diagram of the hardware structure of an electronic device according to one embodiment.

[0181] As shown in Figure 6, the electronic device 800 includes a processor 801 and a memory 802, the memory 802 is used to store an executable computer program, and the processor 801 executes the computer program to perform the text typesetting method of any of the above embodiment.

[0182] The electronic device 800 may be a computer, mobile phone, tablet computer, or other device.

[0183] In one example, the electronic device in question is the aforementioned terminal device.

[0184] Figure 7 is a schematic diagram of the server hardware structure according to one embodiment.

[0185] As shown in Figure 7, the server 900 includes a processor 901 and a memory 902, the memory 902 is used to store an executable computer program, and the processor 901 executes the computer program to perform the text typesetting method of any of the above embodiment. <Computer-readable storage medium>

[0186] Embodiments of the present invention further provide a computer-readable storage medium storing a computer program, wherein, when the computer program is executed by a processor, a text typesetting method according to any of the above embodiment of the method is performed.

[0187] The present invention may also be a system, method, and / or a computer program product. The computer program product may include a computer-readable storage medium storing computer-readable program instructions for causing a processor to implement each aspect of the present invention.

[0188] A computer-readable storage medium may be a tangible device capable of holding and storing instructions used by an instruction execution device. A computer-readable storage medium may be, but is not limited to, an electromemory device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the above. More specific examples (a non-exhaustive list) of computer-readable storage media include portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disk read-only memory (CD-ROM), digital multifunction disks (DVDs), memory sticks, floppy disks, machine coding devices such as punch cards or grooved projection structures on which instructions are stored, and any suitable combination of the above. The computer-readable storage medium used herein is not interpreted as transient signals themselves, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., optical pulses through optical fiber cables), or electrical signals transmitted through wires.

[0189] The computer-readable program instructions described herein may be downloaded from a computer-readable storage medium to each computing / processing device, or they may be downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network may include copper transmission cables, optical fiber transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter or network interface in each computing / processing device receives computer-readable program instructions from the network and transfers them for storage in a computer-readable storage medium in each computing / processing device.

[0190] The computer program instructions for performing the operation of the present invention may be assembler instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, status setting data, or source code or object code written in any combination of one or more programming languages, the programming languages ​​including object-oriented programming languages ​​such as Smalltalk and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The computer-readable program instructions may be executed entirely on the user computer, partially on the user computer, as independent software packets, partially on the user computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user computer via any type of network, including a local area network (LAN) or wide area network (WAN), or it may be connected to an external computer (for example, connected via the Internet using an Internet service provider). In some embodiments, state information of computer-readable program instructions is used to personalize electronic circuits, such as programmable logic circuits, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), so that the electronic circuits can execute computer-readable program instructions, thereby realizing various aspects of the present invention.

[0191] Herein, various aspects of the present invention have been described with reference to flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present invention. Each block in the flowcharts and / or block diagrams, and each combination of blocks in the flowcharts and / or block diagrams, can be realized by computer-readable program instructions.

[0192] These computer-readable program instructions are provided to a processor of a general-purpose computer, a dedicated computer, or other programmable data processing device to produce a machine, which, when executed by the processor of the computer or other programmable data processing device, generates a device that performs the functions / operations specified in one or more blocks in a flowchart and / or block diagram. These computer-readable program instructions may be stored in a computer-readable storage medium, which, in order to operate a computer, a programmable data processing device, and / or other device in a particular manner, contains a single product containing instructions that perform each aspect of the functions / operations specified in one or more blocks in a flowchart and / or block diagram.

[0193] A computer-readable program instruction is loaded into a computer, another programmable data processing device, or other device, and a series of operational steps are executed on the computer, another programmable data processing device, or other device to generate a process realized by the computer, the other programmable data processing device, or other device, thereby realizing a function / operation specified in one or more blocks in a flowchart and / or block diagram.

[0194] The flowcharts and block diagrams in the attached drawings illustrate system architectures, functions, and operations that can be realized by systems, methods, and computer program products according to multiple embodiments of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, instruction segment, or part of an instruction containing one or more executable instructions for realizing a specified logical function. In some alternative implementations, the functions described in the blocks may occur in an order different from the order shown in the drawings. For example, two consecutive blocks may actually be executed essentially in parallel, or in reverse order, depending on the functions involved. Each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, may be realized by a system based on dedicated hardware that performs the specified function or operation, or by a combination of dedicated hardware and computer instructions. It is well known to those skilled in the art that hardware implementation, software implementation, and implementation by a combination of software and hardware are all equivalent.

[0195] While embodiments of the present invention have been described above, the above description is illustrative and not exhaustive, and is not limited to the embodiments disclosed. Many modifications and changes can be readily conceived by those skilled in the art without departing from the scope and spirit of the embodiments described. The choice of terms used herein is intended to best interpret the principles, practical applications, or improvements to commercially available technologies of each embodiment, or to enable those skilled in the art to understand the embodiments disclosed of the present invention. The scope of the present invention is limited by the appended claims.

Claims

1. A method of typesetting text performed by a terminal device, The steps include determining the original font to be used for the target text, The steps include determining whether the local application on the terminal device supports the original font, If the local application does not support the original font, the steps include obtaining character measurement data for the original font, The steps include displaying the target text using a first font supported by the local application, The step of typesetting the displayed target text based on the character measurement data of the original font is included, The step of displaying the target text using a first font supported by the local application is: A step of determining the character type of the target text, wherein the character type includes a first type and a second type, the first type being a type in which the width and height of each character match, and the second type being a type in which the width and / or height of each character do not match perfectly. The steps include selecting a first font that matches the original font from all fonts supported by the local application, according to predetermined rules related to the character type of the target text, The steps include displaying the target text in the selected first font, A text typesetting method characterized by the following.

2. The step of obtaining character measurement data for the aforementioned original font is: The steps include: searching for character measurement data of the original font in the local cache of the terminal device; If character measurement data for the original font is not found in the local cache of the terminal device, the device includes the step of obtaining character measurement data for the original font from a server. The method according to feature 1.

3. The steps include selecting a first font that matches the original font from all the fonts supported by the local application, The further step includes displaying the target text in the selected first font, The method according to feature 1.

4. The step of selecting a first font that matches the original font from all fonts supported by the local application is: The steps include obtaining a list of replacement fonts for the aforementioned original font, A step of determining a candidate font from the replacement fonts in the replacement font list, wherein the candidate font is a font supported by the local application; The step includes determining the font with the highest degree of match to the original font from among the candidate fonts as the first font, The method according to feature 3.

5. The character measurement data of the original font includes the character width and character height of the original font, and the step of selecting a first font that matches the original font from all fonts supported by the local application is: A step of obtaining character measurement data for a candidate font, wherein the candidate font is a font supported by the local application, The steps include determining the typesetting direction of the target text, If the typesetting direction of the target text is horizontal, the step of determining the candidate font whose character width is closest to the character width of the original font as the first font, If the typesetting direction of the target text is vertical, the step of determining the candidate font whose character height is closest to the character height of the original font as the first font is included. The method according to 1 or 3, characterized by the above.

6. The character measurement data of the original font includes the character width and character height of the original font, and the step of selecting a first font that matches the original font from all fonts supported by the local application is: A step of obtaining the font attributes of the original font and the font attributes of a candidate font, wherein the candidate font is a font supported by the local application, The steps include: determining a candidate font as the target font whose font attributes are the same as those of the original font; The steps include obtaining character measurement data for the target font, The steps include determining the typesetting direction of the target text, If the typesetting direction of the target text is horizontal, the step of determining the target font whose character width is closest to the character width of the original font is the first font, If the typesetting direction of the target text is vertical, the step of determining the target font whose character height is closest to the character height of the original font is the first font is included. The method according to 1 or 3, characterized by the above.

7. If the character type of the target text is of the second type, the step of selecting a first font that matches the original font from all fonts supported by the local application, according to predetermined rules related to the character type of the target text, is: Sending a font identifier of a candidate font to the server and receiving the font identifier of the first font from the server, so that the server determines the first font from the candidate fonts based on the font attributes of the original font and the width of a predetermined string in the original font, or, The steps include obtaining the font attributes of the original font and the width of a predetermined string in the original font from the server, and determining the first font from the candidate fonts based on the font attributes of the original font and the width of a predetermined string in the original font, The candidate font is a font supported by the local application, and the predetermined string contains multiple different predetermined characters. The method according to feature 1.

8. The candidate fonts include default and non-default fonts supported by the local application, and the step of determining the first font from the candidate fonts based on the font attributes of the original font and the width of a predetermined string in the original font is as follows: If the font attributes of the default font and the original font are the same, and the similarity between the width of a predetermined string in the default font and the width of a predetermined string in the original font satisfies a predetermined criterion, the default font is determined to be the first font. Otherwise, the process includes the step of selecting a candidate font whose font attributes are the same as those of the original font as the target font, and determining the first font from the target font, The method according to feature 7.

9. The determination of whether the similarity between the width of a predetermined string in the default font and the width of a predetermined string in the original font satisfies a predetermined criterion is as follows: The steps include determining the difference between the width of a predetermined string in the default font and the width of a predetermined string in the original font as a fourth difference, The steps include determining the ratio of the absolute value of the fourth difference to the width of a predetermined string in the original font as the first ratio, The process includes the step of determining that, if the first ratio is less than or equal to a predetermined first threshold, the similarity between the width of a predetermined string in the default font and the width of a predetermined string in the original font satisfies a predetermined criterion. The method according to feature 8.

10. The step of determining the first font from the target font is: The step of determining the target font as the first font, which has a width that is closest to the width of a predetermined string in the original font, or The process includes the step of determining the target font with the smallest width of a given string as the first font, The method according to feature 8.

11. The character measurement data of the original font includes the character width and character height of the original font, and the step of typesetting the displayed target text based on the character measurement data of the original font is: The steps include determining the typesetting direction of the target text, If the typesetting direction of the aforementioned target text is landscape orientation, A step of determining a first difference, wherein the first difference is the difference between the character width of the target text character in the original font and the character width in the first font, If the first difference is a positive value, the steps include adjusting the horizontal coordinate values ​​of the characters of the target text displayed in the first font, If the first difference is a negative value, the steps include reducing the size of the characters of the target text displayed in the first font, If the typesetting direction of the target text is vertical, A step of determining a second difference, wherein the second difference is the difference between the character height of the target text character in the original font and the character height in the first font, If the second difference is a positive value, the steps include adjusting the vertical coordinate values ​​of the characters of the target text displayed in the first font, If the second difference is a negative value, the process includes reducing the size of the characters in the target text displayed in the first font. The method according to feature 1.

12. The character measurement data of the original font includes the character width of the original font, and the step of typesetting the target text based on the character measurement data of the original font is: The steps include dividing the aforementioned target text into words, The steps include: accumulating the difference between the width of each character in the word in the first font and the width in the original font, and obtaining an adjustment amount; A step of calculating the ratio of the adjustment amount to the number of character spaces in the word as a second ratio, The process includes the step of adjusting the spacing between letters in the word so that the spacing between letters in the word is the same, based on the second ratio described above. The method according to 1 or 11, characterized by the features described above.

13. A text typesetting device, A first decision module for determining the original font to be used for the target text, A second decision module for determining whether a local application supports the original font, If the local application does not support the original font, an acquisition module for obtaining character measurement data for the original font is provided. Includes a typesetting module for typesetting the target text displayed in a first font supported by a local application on a terminal device, based on the character measurement data of the original font, Before the typesetting module typesets the target text displayed in the first font supported by the terminal device's local application, based on the character measurement data of the original font, it further: Determine the character type of the target text, In accordance with predetermined rules relating to the character type of the target text, the local application selects a first font that matches the original font from all fonts it supports. Used to display the target text in the selected first font, The character type includes a first type and a second type, the first type being a type in which the width and height of each character are the same, and the second type being a type in which the width and / or height of each character are not exactly the same. A text typesetting apparatus characterized by the following.

14. An electronic device comprising memory and a processor, wherein the memory is used to store a computer program, and the processor is used to execute the computer program and carry out the method according to any one of claims 1 to 12. An electronic device characterized by the following features.

15. A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 12 is performed. A computer-readable storage medium characterized by the following features.

Citation Information

Patent Citations

  • Method and system for displaying webpage applied in mobile terminal

    CN102663137A

  • Method and device for acquiring font files of target characters in document files

    CN103425631A

  • Processor for allocating characters

    JP2001005985A

  • Methods, systems, and programs for generating and displaying subpixel-optimized images and digital content containing such images.

    JP2004532430A

  • Document editing device to check whether the font applied to the document is a supported font and operating method thereof

    KR1020210060808A