Text composition

The method addresses the issue of inconsistent document formatting by using character measurement data to display and format text in a compatible font, ensuring consistency when the original font is missing, thus maintaining the document's intended aesthetics.

JP2024534170AActive Publication Date: 2024-09-18BEIJING KINGSOFT OFFICE SOFTWARE INC +1
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
JP2024513144
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Priority Date
2021-08-26
Filing Date
2021-12-28
Publication Date
2024-09-18
Estimated Expiration
2041-12-28

AI Technical Summary

Technical Problem

When a document's original fonts are missing, the document is displayed with significantly different formatting, affecting aesthetics and viewing experience, and current methods require font installation, which is cumbersome and costly.

Method used

A method and apparatus for typesetting text that determines the original font, checks if the local application supports it, and uses character measurement data to display and format the text in a compatible font, maintaining original formatting consistency.

Benefits of technology

Ensures consistent document formatting even when the local application lacks the original font, by displaying and formatting the text using a supported font based on the original font's measurement data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 2024534170000001
    Figure 2024534170000001
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 field of computer technology, and more particularly to a method, an apparatus, an electronic device and a storage medium for typesetting text. [Background technology]

[0002] When a terminal device uses a local application to open a document, if the original font of the document is missing, the document may be displayed in a typesetting that is significantly different from the original typesetting, which may affect the aesthetics and viewing experience of the document. The current common method is to install the missing font in the current environment. However, such a method requires searching, downloading, and installing the font, and the font may also require an additional fee, making it difficult to popularize and apply in a large area. Therefore, it is necessary to propose a new text typesetting method. Summary of the Invention

[0003] An objective of the embodiment of the present invention is to provide a new technical solution for text typesetting, so as to maintain the consistency between document typesetting and original typesetting when fonts are missing.

[0004] According to a first aspect of the present invention, there is provided a method for typesetting text, the method comprising the steps of: determining an original font to be used for a target text, determining whether a local application supports the original font, and 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.

[0005] According to a second aspect of the present invention, there is provided a method for typesetting text, the method including the steps of: receiving a font identifier of an original font of a target text sent by a terminal device, retrieving character measurement data of the original font based on the font identifier of the original font, and sending 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] According to a third aspect of the present invention, there is provided a text typesetting apparatus, the apparatus including: a first determining module for determining an original font to be used in a target text, a second determining module for determining whether a local application supports the original font, an obtaining module for obtaining 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 of a terminal device based on the character measurement data of the original font.

[0007] According to a fourth aspect of the present invention, there is provided a text typesetting apparatus, the apparatus including: a receiving module for receiving a font identifier of an original font of a target text sent by a terminal device, a searching module for searching character measurement data of the original font based on the font identifier of the original font, and a sending module for sending the 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 there is provided an electronic device comprising a memory and a processor, the memory adapted to store a computer program and the processor adapted to execute the computer program to perform a method according to the first or second aspect of the present invention.

[0009] According to a sixth aspect of the present invention there is provided a computer readable storage medium storing a computer program which, when executed by a processor, performs a method according to the first aspect of the invention or a method according to the second aspect of the invention.

[0010] One beneficial effect of the embodiment of the present invention is that if the local application does not support the original font of the target document, the local application will display the target text using the first font it supports, and typeset the target text based on the character measurement data corresponding to the original font, thereby maintaining the consistency between the document typesetting and the original typesetting even when the original font is missing in the local application.

[0011] Other features and advantages of embodiments of the present invention will become apparent from the following detailed description of illustrative embodiments of the invention, which proceeds with reference to the accompanying drawings. [Brief description of the drawings]

[0012] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the invention and, together with the description, serve to explain the principles of embodiments of the invention. [Figure 1] 1 is a schematic diagram of a document processing system according to an embodiment of the present invention. [Diagram 2] 1 is a flowchart of a method for typesetting text according to an embodiment of the present invention. [Diagram 3] FIG. 2 is a schematic diagram of character measurement data according to an embodiment of the present invention. [Figure 4] 1 is an exemplary diagram of a method for typesetting text according to an embodiment of the present invention; [Diagram 5] 1 is a flowchart of a method for typesetting text according to an embodiment of the present invention. [Figure 6] FIG. 2 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present invention; [Figure 7] FIG. 2 is a schematic diagram of a hardware structure of a server according to an embodiment of the present invention; DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0013] Various exemplary embodiments of the present invention will be described in detail below with reference to the drawings. Note that the relative arrangement of components and steps, expressions of formulas, and values ​​described in the following embodiments do not limit the scope of the present invention unless otherwise specified.

[0014] The following description of at least one exemplary embodiment is merely exemplary in nature and is not intended to limit the invention, its application, or uses.

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

[0016] In all examples shown and described herein, any particular values ​​should be construed as merely exemplary and not limiting, and thus may be different in other examples of the exemplary embodiment.

[0017] It should be noted that in the following accompanying drawings, like reference numerals and letters indicate like items, so that once an item is defined in one drawing, no further explanation is required in subsequent drawings. <Text composition method>

[0018] 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 microprocessor MCU, etc. The memory 1012 may include, but is not limited to, a ROM (read only memory), a RAM (random access memory), a non-volatile memory such as a hard disk, etc. The interface device 1013 may include, but is not limited to, a USB interface, a serial interface, a parallel interface, etc. The communication device 1014 may perform, for example, wired communication or wireless communication, and specifically may include WiFi communication, Bluetooth (registered trademark) communication, 2G / 3G / 4G / 5G communication, etc. The input device 1015 includes, but is not limited to, a keyboard, a mouse, a touch screen, a microphone, etc. The output device 1016 includes, but is not limited to, a display screen, a speaker, etc. The configuration of the server 101 may include only some of the devices listed above.

[0020] The terminal device 103 may be, for example, 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, a portable computer, a desktop computer, a mobile phone, a tablet computer, etc. The configuration of the terminal device 103 includes, but is not limited to, a processor 1031, a memory 1032, an interface device 1033, a communication device 1034, a GPU (Graphics Processing Unit, image processing unit) 1035, a display device 1036, an input device 1037, a speaker 1038, a microphone 1039, and a 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, a ROM (read only memory), a RAM (random access memory), a 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, for example, wired communication or wireless communication, and specifically can 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 touch screen, etc. The input device 1037 includes, but is not limited to, a keyboard, a mouse, a touch screen, etc. The configuration of the terminal device 103 can also include only some of the devices in the above devices.

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

[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, a light application, etc. 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 on 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 the need for downloading, and a user can search for it and use it directly, or scan a QR code to use it directly.

[0023] The document processing system shown in FIG. 1 is merely illustrative and does not limit the embodiments, applications or uses of the present invention. Although a server and a terminal device are described above, those skilled in the art can understand that the embodiments of the present invention may relate to only some of the devices. For example, the server may relate to only a processor, a memory and a communication device, and the terminal device may relate to only a processor, a memory, a communication device, an input device and a 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 a processor to perform an operation is a well-known technique in the art, and will not be described in detail here.

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

[0025] Step S102, the original font used for the target text is determined.

[0026] In an embodiment of the present invention, the target text may be any part of text in a document. In one example, the terminal device obtains original font information of the target text from the document to determine the original font used for the target text. In general, the original font information may be stored in the document data of the document.

[0027] In an embodiment of the present invention, the font may include a font loaded in the operating system of the terminal device, a font loaded in a client (such as a browser or application) of the terminal device, or a font stored in a server, and may be a font installed in a document file. Here, the document file may be installed with a font, but a document file installed with a font usually has a relatively large amount of data. In addition, the font loaded in the operating system of the terminal device, the font loaded in the client of the terminal device, and the font installed in the document file all belong to fonts supported by the local application of the terminal device, and can be collectively referred to as a local font. The font stored in the server can be called a server font or a cloud font.

[0028] Step S104, determine whether the local application supports the original font.

[0029] After the original font used for the target text is determined, it is checked whether the original font is included in all fonts supported by the local application, and if not, it is determined that the local application does not support the original font.

[0030] The fonts supported by the local application may be determined based on the installed font packets. In one example, if the local application installs a font packet of a certain font, it means that the local application supports the font. Generally, many widely used font packets are pre-installed in the base packet of the local application, and one of the fonts can be set as the default font, and if a user wants to use a niche font, the corresponding font packet needs to be downloaded separately. For example, if the original font is loaded in the operating system or local application of the terminal device, or if the original font is stored in the target text, it is considered that the local application supports the original font, and otherwise the local application does not support the original font.

[0031] Step S106, if the local application does not support the original font, obtain character measurement data of the original font.

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

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

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

[0035] As shown in FIGS. 3(a) and 3(b), for the same Chinese character "zao", two different fonts have different widths, heights, and 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 does not rise or fall relative to the baseline. The ascent value of the font shown in FIG. 3(b) is a positive value, and the font is higher relative to the baseline. If the ascent value of the font is a negative value, it indicates that the font is lower relative to the baseline.

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

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

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

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

[0040] In one example, the terminal device obtains the character measurement data of the original font by first searching for the character measurement data of the original font in a local cache of the terminal device, and if the character measurement data of the original font is not found in the local cache, the terminal device obtains the character measurement data of the original font from the server. In this example, after obtaining the character measurement data of the original font from the server, the terminal device may store it in the local cache, so that the next time the terminal device needs to use the font, it can directly read the character measurement data of the font from the local cache.

[0041] Step S108, display the target text in a first font supported by the local application, and typeset the target text according to 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 an 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 the first font supported by the local application, the method may further include determining the first font. In an embodiment 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] Determining a First Font Example 1: Selecting a first font that matches an original font from all fonts supported by a local application may include steps S202 to S206.

[0045] In step S202, a substitute font list for the original font is obtained.

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

[0047] Hereinafter, using font A as an example, a method for determining the degree of match between font B and font A will be described.

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

[0049] A 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, a match between font B and font A is determined based on the absolute value of the first difference, where a larger absolute value of the first difference indicates a lower match between font B and font A, and a smaller absolute value of the first difference indicates a higher 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, where 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 value of the first difference and the absolute value of the second difference is calculated, and the degree of match between font B and font A is determined based on the sum, where 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] Step S204: determining a candidate font from the substitution fonts in the substitution font list, the candidate font being a font supported by the local application;

[0054] In step S206, the font that has the highest degree of match with the original font among the candidate fonts is determined 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 further, from the candidate fonts supported by the local application, the candidate font that best matches the original font (for example, the candidate font sorted highest in the replacement font list sorted in order of highest match) is selected as the first font.

[0056] Determining the first font using the candidate fonts supported by the local application in the substitution font list does not require the terminal device to perform complex calculations, which is more convenient and quicker.

[0057] Determining a First Font Example 2: Selecting a first font that matches the original font from all fonts supported by the local application may include steps S302 to S304.

[0058] Step S302, determine the character type of the target text.

[0059] The character types include a first type and a second type. The first type refers to the characters in the target text being square characters such as Chinese characters, and the width and height of different Chinese characters are approximately the same. The second type refers to the characters in the target text including characters such as alphabets, Roman characters, Mongolian characters, or Arabic characters, or a mixture of multiple languages, and the widths of these characters may not match, and the heights may not match either.

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

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

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

[0063] Step S402, obtain character measurement data of a candidate font, where the candidate font is a font supported by a local application.

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

[0065] Step S406: if the typesetting direction of the target text is landscape typesetting, determine 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 portrait typesetting, determine the candidate font whose character height is closest to the character height of the original font as the first font.

[0066] When the typesetting direction of the target text is landscape typesetting, the difference between the character width of a character in the target text in the original font and the character width of a candidate font is calculated as a first difference, and 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, and the candidate font having the smallest absolute value of the first difference is selected as the first font.

[0067] When the typesetting direction of the target text is portrait typesetting, the difference between the character height of a character in the target text in the original font and the character height of a character in the candidate font is calculated as a second difference, and the smaller the absolute value of the second difference is, the closer the character height of the candidate font is to the character height of the original font, and the candidate font having the smallest absolute value of the second difference is selected as the first font.

[0068] Example 3 is applied when the character type of the target text is the first type and / or the second type. That is, when the target text contains only Chinese characters, or when the target text contains alphabets or Roman characters, the method of Example 3 can be applied to determine the first font.

[0069] Determining a First Font Example 4: Selecting a first font that matches the original font from all fonts supported by the local application may include steps S502 to S508.

[0070] Step S502: obtain font attributes of the original font and font attributes of the candidate font, where the candidate font is a font supported by the local application.

[0071] The font attributes of a font are inherent attributes of the font itself and can represent the style of the font. The font attributes of a font can include one or more of the following: font weight, blackness, slant, etc.

[0072] For example, the degree of font thickness includes three attribute values, from thick to thin, namely "thick," "normal," and "thin." For example, the degree of font blackening includes two attribute values, "blackened" and "not blackened." For example, the degree of font slant includes two attribute values, "slant" and "not slant."

[0073] For example, for three fonts, "Song font," "Chinese thin black," and "Flat formal bold black Song Simplified font," the font attributes of "Song font" are thickness "thin," darkening degree "not darkened," and tilt degree "not tilted," the font attributes of "Chinese thin black" are thickness "thin," darkening degree "darkened," and tilt degree "not tilted," and the font attributes of "Flat formal bold black Song Simplified font" are thickness "thick," darkening degree "darkened," and tilt degree "not tilted."

[0074] For example, for two fonts, "Times New Roman" and "Forte," the font attributes of "Times New Roman" are "thin" for thickness, "no darkening," and "no tilt," while the font attributes of "Forte" are "thick" for thickness, "blackening," and "tilt."

[0075] In step S504, 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 of the target font is obtained.

[0076] In one example, the font attributes of a font include only the thickness of the font, and if the candidate font and the original font are both "bold", or both "normal", or both "light", 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's thickness, blackening, and slant, and if the three attribute values ​​of the thickness, blackening, and slant of a candidate font and an original font all match, the attributes of the candidate font and the original font are considered to be the same.

[0078] Step S506: The composition direction of the target text is determined.

[0079] Step S508, if the typesetting direction of the target text is horizontal typesetting, determine the target 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 typesetting, determine the target font whose character height is closest to the character height of the original font as the first font.

[0080] The implementation manner of step S508 may be similar to that of step S406 described above, and detailed description thereof will be omitted here.

[0081] Example 4 is applied when the character type of the target text is the first type and / or the second type. That is, when the target text contains only Chinese characters, or when the target text contains alphabets or Roman characters, the method of Example 4 can be applied to determine the first font.

[0082] In this example, from all the candidate fonts, candidate fonts whose font attributes are different from those of the original font are filtered, and candidate fonts whose font attributes are the same as those of the original font are left as target fonts, and a first font is determined from the target font based on the character measurement data of the original font, so that the style of the selected first font and the style of the original font are basically consistent, and the target text displayed in the first font supported by the local application is closer to the style of the target text in the original font.

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

[0084] Alternatively, in example 6 of determining the first font, selecting a first font that matches the original font from all fonts supported by the local application according to a predetermined rule related to the character type of the target text may be performed by the terminal device obtaining font attributes of the original font and a width of a predetermined character 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 the predetermined character string in the original font.

[0085] Here, the candidate fonts are the fonts supported by the local application, and a plurality of different predetermined characters are included in the predetermined string. The predetermined characters in the predetermined string are preferably representative in terms of either the character width or the character height. For example, select the characters "w", "z", "i" which are representative in width in any Chinese characters and English, and form a predetermined string. Here, "w", "z", "i" represent three English characters with different widths, and the predetermined string may be "MingWwZzIi".

[0086] Examples 5 and 6 are applicable when the character type of the target text is the second type. That is, when the target text contains characters such as alphabetic characters, Roman characters, Mongolian characters, Arabic characters, etc., or when multiple languages are mixed, the methods of Examples 5 and 6 can be applied to determine the first font. For example, when the character type of the target text is the alphabetic type or the multi-language mixed type (for example, the target text contains Chinese content and English content at the same time, or the target text contains Chinese content and Japanese content at the same time), the methods of Examples 5 and 6 can be applied to determine the first font. By determining the first font based on the width of the predetermined string, it is suitable for the case where the character widths of different characters are different, with less computational complexity, more efficient and faster.

[0087] In one example, the candidate fonts include the default font and non-default fonts supported by the local application. The default font is preset in the local application, and 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 preferences.

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

[0089] Step S602: if the font attributes of the default font supported by the local application are the same as those of the original font, and the similarity between the width of a predetermined character string in the default font and the width of a predetermined character string in the original font meets a predetermined criterion, determine the default font as the first font; otherwise, execute step S604.

[0090] In one example, determining whether the similarity between the width of the predetermined character string in the default font and the width of the predetermined character 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 the predetermined character string in the default font and the width of the predetermined character string in the original font is determined as a fourth difference.

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

[0093] Step S6026: if the first ratio is equal to or less than a first threshold, it is determined that the similarity between the width of the predetermined character string in the default font and the width of the predetermined character string in the original font satisfies a predetermined criterion, and if the first ratio is greater than the first threshold, it is determined that the similarity between the width of the predetermined character string in the default font and the width of the predetermined character string in the original font does not satisfy a predetermined criterion.

[0094] In one example, the similarity between the width and height of a specified string in a default font and the width and height of a specified string in an original font satisfying a specified criterion may include the ratio between the width of the specified string in the default font and the width of the specified string in the original font being between 0.95 and 1.05, i.e., the first ratio being between 0 and 0.05.

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

[0096] In step S604, from all the candidate fonts (including the default font and the 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, in step S604, determining the first font from the target font may be determining the target font in which the width of a predetermined character string is closest to the width of the predetermined character string in the original font as the first font.

[0098] A difference between the width of the predetermined character string in the original font and the width of the predetermined character string in the target font is calculated as a third difference, and the smaller the absolute value of the third difference is, the closer the width of the predetermined character string in the target font is to the width of the predetermined character string in the original font, and the target font having the smallest absolute value of the 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 before typesetting can be made closer to the original typesetting of the target text, and only fine adjustment is required during typesetting.

[0099] In one example, in step S604, determining the first font from the target font may be determining a target font having the smallest width of a predetermined string as the first font.

[0100] By selecting the target font with the smallest width for a given character string as the first font, character overlap and overwriting can be avoided when a local application displays the target text in the first font, and user viewing problems caused by overlap and overwriting are unlikely to occur even before typesetting.

[0101] In this example, a default font may be prioritized as the first font to replace the original font, taking into account the user's font usage habits. If the font attributes of the default font and the original font are different, or if the similarity between the width of a given character string in the default font and the width of a given character string in the original font does not meet a predetermined standard, the first font is determined from among candidate fonts whose font attributes are the same as those of the original font. This takes into account the user's preferences, reduces the amount of calculation, and shortens processing time.

[0102] In the above-mentioned examples 2 to 6 for determining the first font, the implementation method for determining the candidate font, the similarity between the target font and the original font, and the match degree can also be applied to determine a substitute font in the substitute font list.

[0103] In step S108, the terminal device displays the target text in a first font supported by the local application, and typesets the target text displayed in the first font based on the character measurement data of the original font in various ways, which are described below by way of examples.

[0104] Typesetting Example 1: First, the typesetting direction of a target text is determined, and the target text displayed on a terminal device in a first font is typeset based on the typesetting direction of the target text. If the typesetting direction of the target text is horizontal typesetting, a first scaling process is performed on the characters of the target text so that the character width of the target text matches the character width of the original font. If the typesetting direction of the target text is vertical typesetting, a second scaling process is performed on the characters of the target text so that the character height of the target text matches the character height of the original font.

[0105] In example 1, character scaling is achieved by adjusting the font size.

[0106] In one embodiment, in step S108, typesetting the target text displayed on the terminal device based on the character measurement data corresponding to the original font may include obtaining character measurement data corresponding to a 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, a typesetting direction of a target text is determined, and the target text displayed in a first font on a terminal device is typeset based on the typesetting direction of the target text. If the typesetting direction of the target text is horizontal typesetting, a first difference is determined, and the first difference is a difference between a character width of an original font and a character width of a first font. If the first difference is a positive value, an abscissa value of a character in the target text is adjusted. If the first difference is a negative value, a character in the target text is scaled down. If the typesetting direction of the target text is vertical typesetting, a second difference is determined, and the second difference is a difference between a character height of an original font and a character height of a first font. If the second difference is a positive value, an ordinate value of a character in the target text is adjusted. If the second difference is a negative value, a character in the target text is scaled down.

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

[0109] In the following, an example will be described in which the typesetting direction of the target text is landscape typesetting.

[0110] As shown in Fig. 3(a), the character width of each character in the original font is approximately W1. As shown in Fig. 3(b), the character width of each character in the first font is approximately W2. The difference DW (=W1-W2) between W1 and 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 the character width of the original font, in which case the coordinate value of the horizontal coordinate of each character of the target text in the first font needs to be adjusted.

[0112] As shown in Figure 4, the target text is a single line of content, containing 10 characters, "Good morning, nice weather." In the original font, the horizontal coordinate values ​​of the 10 characters are X1, X2, ..., X 10 After typesetting, the horizontal coordinates of the 10 characters are X1', X2', ..., X 10 ' and 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 It becomes.

[0113] Here, n is an integer and 1≦n≦10.

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

[0115] If the first difference DW is negative, it indicates that the character width of the first font is larger than that of the original font, and adjusting the coordinate value may cause overlapping of characters, so the font size of the target text displayed by the terminal device in the first font needs to be reduced. In one example, the font size of the target text displayed by the terminal device in the first font is reduced based on the ratio of W1 / W2, and the original position (coordinate value) of the target text in the first font is kept the same. For example, if W1 / W2=R1 and the original font size of the content is U1, the font size of the content is adjusted to U2, so that U2=R1*U1. In this document, the font size is measured in points, which is a measurement method for printed typefaces well known to those skilled in the art, such as 5 points, 12 points, etc.

[0116] In the following, an example will be described in which the typesetting direction of the target text is portrait typesetting.

[0117] As shown in Fig. 3(a), the character height of each character in the original font is H1. As shown in Fig. 3(b), the character height of each character in the first font is H2. The difference DH (=H1-H2) between H1 and 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 which case the coordinate value of the ordinate of each character in the first font is adjusted.

[0119] The target text in the original font has a total of M lines of content, and the characters in each line have the same ordinate value. The ordinate values ​​of the characters in the first to Mth lines are Y1, Y2, …, Y M After typesetting, the ordinate values ​​of the characters from the 1st line to the Mth line are Y1', Y2', ..., Y M ' and 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 It becomes.

[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 negative, it indicates that the character height of the first font is greater than that of the original font, and adjusting the coordinate values ​​may cause characters to overlap, so the font size of the target text displayed by the terminal device in the first font needs to be reduced. In one example, the font size of the target text displayed by the terminal device in the first font is reduced according to the ratio of H1 / H2, and the position (coordinate value) of the original target text in the first font is kept the same. For example, if 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 in a first font on a terminal device according to the typesetting direction of the target text. If the typesetting direction of the target text is landscape typesetting, adjust the font size of the target text to a first font size, the first font size being the font size whose character width is closest to the character width of the original font, determine a first difference, the first difference being 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 character of the target text, and if the first difference is a negative value, reduce the character of the target text. If the typesetting direction of the target text is portrait typesetting, adjust the font size of the target text to a second font size, the second font size being the font size whose character height is closest to the character height of the original font; determine a second difference, the second difference being 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 ordinate value of the character of the target text; if the second difference is a negative value, reduce the character of the target text.

[0124] That is, when the typesetting direction of the target text is landscape typesetting, after 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 the situation where the characters overwrite each other.

[0125] Similarly, when the typesetting direction of the target text is portrait typesetting, after the terminal device adjusts the font size of the target text in a first font to a second font size, if the character height is still greater than the character height in the original font, the font size is reduced by one unit to shrink the characters, and avoid the situation where the characters overwrite each other.

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

[0127] After the terminal device typessets the displayed target text, the typeset of the displayed target text is closer to the typeset of the target text displayed in the original font. As shown in FIG. 4, for the target text "Good morning, nice weather", the total width of this content in the original font is wider than that in the first font. After the typesetting in step S108, the total width of this content displayed in the first font by the terminal device is closer to the total width of this content in the original font. In this way, it can be ensured that the contents in 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 the character measurement data of the original font may include steps S1085 to S1087.

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

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

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

[0132] For example, a word in the target text has a total of T characters, and the number of character gaps 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 O1, O2, ..., O T where O1, O2, …, O Tare accumulated to obtain an adjustment amount, and a second ratio between the adjustment amount and the number of character gaps is calculated. If the second ratio is a positive value, it indicates that the adjustment amount is a positive value and the character gaps in the word need to be reduced, in which case the second ratio is subtracted from the character gaps in the word. If the second ratio is a negative value, it indicates that the adjustment amount is a negative value and the character gaps in the word need to be increased, in which case the second ratio is subtracted from the character gaps in the word, i.e., the absolute value of the second ratio is added.

[0133] This allows the spacing between characters in the same word to be the same, making them appear more uniform. It can be applied to the second type of target text, and even when the widths of different characters are different, it can make the display of characters in the same word more uniform. Typesetting example 4 may be performed after any of the previous typesetting examples.

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

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

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

[0137] Step S702, receiving a font identifier of the original font of the target text sent by the terminal device.

[0138] Step S704: retrieving character measurement data of the original font based on the font identifier of the original font.

[0139] Step S706, sending the character measurement data of the original font to the terminal device, so that the terminal device typesets the target text displayed in the first font supported by the local application according to the character measurement data of the original font.

[0140] In one example, the server pre-stores font attributes of each font and character measurement data of each font at each font size. The character measurement data of a font may include character height and width. The character measurement data of a font may further include character elevation. The font attributes of a font are inherent attributes of the font itself, and may represent the style of the font. The font attributes of a font may include one or more of the following: font thickness, blackening, slant, etc.

[0141] In one example, before the terminal device displays the target text in the first font supported by its local application, the method further includes obtaining a replacement font list for the original font based on a font identifier of the original font. Determine a candidate font from the replacement fonts in the replacement font list, where the candidate font is a font supported by the local application of the terminal device. Determine a candidate font in the replacement font list that best matches the original font as 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 font attributes of the original font and a width of the predetermined string in the original font to the terminal device, so that the terminal device determines a first font from the candidate fonts based on the font attributes of the original font and the width of the predetermined string in the original font, where the candidate fonts are fonts supported by the local application of the terminal device, 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 the candidate fonts based on font attributes of the original font and a width of a predetermined string in the original font, and sending a font identifier of the first font to the terminal device, where the candidate font is a font supported by the local application of the terminal device, and the predetermined string includes a plurality of different predetermined characters.

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

[0145] In one example, determining a first font from the candidate fonts based on the font attributes of the original font and the width of the predetermined character 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 the predetermined character string in the default font and the width of the predetermined character string in the original font meets a predetermined criterion, otherwise, determining a candidate font whose font attributes are the same as the font attributes of the original font as a target font, and determining a first font from the target font.

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

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

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

[0149] An embodiment of the present invention provides a text typesetting apparatus, which includes the following modules:

[0150] The first determination module is used to determine the original font used in the target text.

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

[0152] The acquisition module acquires character measurement data of an original font if the local application does not support the original font.

[0153] The typesetting module is used for typesetting 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.

[0154] In one example, obtaining character measurement data of the original font includes either searching for character measurement data of the original font in a local cache of the terminal device, or, if the character measurement data of the original font is not found in the local cache of the terminal device, obtaining the character measurement data of the 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 method further includes selecting a first font that matches the original font from all fonts supported by the local application, and 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 substitution font list for the original font. Determining a candidate font from the substitution fonts in the substitution font list, the candidate font being a font supported by the local application. Determining a font from the candidate fonts that matches the original font most closely as the first font.

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

[0158] In one example, the character measurement data of the original font includes a character width of the original font and a character height of the original font. Selecting a first font matching the original font from all fonts supported by the local application includes obtaining character measurement data of a candidate font, the candidate font being a font supported by the local application. Determining a typesetting direction of the target text. If the typesetting direction of the target text is landscape typesetting, determining a 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 portrait typesetting, determining a candidate font whose character height is closest to the character height of the original font as the first font.

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

[0160] Selecting a first font matching the original font from all fonts supported by the local application includes obtaining font attributes of the original font and font attributes of the candidate font, where the candidate font is a font supported by the local application. Determine the candidate font whose font attributes are the same as the font attributes of the original font as a target font, and obtain character measurement data of the target font. Determine a typesetting direction of the target text. If the typesetting direction of the target text is landscape typesetting, determine the target 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 portrait typesetting, determine the target font whose character height is closest to the character height of the original font as the first font.

[0161] In one example, when the character type of the target text is an alphabet 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 a predetermined rule related to the type includes: sending a font identifier of the candidate font to a server and receiving a font identifier of the first font from the server, so that the server determines the first font from the candidate fonts based on font attributes of the original font and a width of a predetermined string in the original font; or obtaining a font attribute of the original font and a 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 attribute of the original font and the width of the predetermined string in the original font, where the candidate font is a font supported by the local application, and the predetermined string includes a plurality of different predetermined characters.

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

[0163] Determining a first font from the candidate fonts based on the font attributes of the original font and the width of the predetermined character 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 the predetermined character string in the default font and the width of the predetermined character string in the original font meets a predetermined criterion, otherwise, determining a candidate font whose font attributes are the same as those of the original font as a target font, and determining a first font from the target font.

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

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

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

[0167] Typesetting the target text based on the character measurement data of the original font includes determining a typesetting direction of the target text. If the typesetting direction of the target text is horizontal typesetting, a first difference is determined, the first difference being a difference between a character width of the target text in the original font and a character width of the target text in the first font, and if the first difference is a positive value, an abscissa value of the character of the target text displayed in the first font is adjusted. If the first difference is a negative value, the character of the target text displayed in the first font is scaled down. If the typesetting direction of the target text is vertical typesetting, a second difference is determined, the second difference being a difference between a character height of the target text in the original font and a character height of the target text in the first font. If the second difference is a positive value, an ordinate value of the character of the target text displayed in the first font is adjusted. If the second difference is a negative value, the character of the target text displayed in the first font is scaled down.

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

[0169] Typesetting the target text based on the character measurement data of the original font includes dividing the target text into words, accumulating differences between the width of each character in the word in the first font and the width in the original font to obtain an adjustment amount, calculating a ratio between the adjustment amount and the number of character gaps in the word as a second ratio, and adjusting the character gaps in the word based on the second ratio so that the character gaps in the word are the same.

[0170] An embodiment of the present invention provides a text typesetting apparatus, which includes the following modules:

[0171] The receiving module is used for receiving a font identifier of an original font of a target text transmitted by a terminal device.

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

[0173] The sending module is used for sending 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.

[0174] In one example, displaying the target text in a first font supported by the local application on the terminal device includes obtaining a replacement font list for the original font based on a font identifier of the original font; determining a candidate font from the replacement fonts in the replacement font list, the candidate font being a font supported by the local application; determining the candidate font sorted highest in the replacement font list as a first font; sending the identifier of the first font to the terminal device; and displaying the target text in the selected first font.

[0175] In one example, the method further includes sending the font attributes of the original font and the width of the predetermined character string in the original font to the terminal device, so that the terminal device determines a first font from the candidate fonts based on the font attributes of the original font and the width of the predetermined character string in the original font. Or, determining a first font from the candidate fonts based on the font attributes of the original font and the width of the predetermined character string in the original font, and sending a font identifier of the first font to the terminal device, where the candidate font is a font supported by the local application, and the predetermined character string includes a plurality of different predetermined characters.

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

[0177] Determining a first font from the candidate fonts based on the font attributes of the original font and the width of the predetermined character 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 the predetermined character string in the default font and the width of the predetermined character string in the original font meets a predetermined criterion, otherwise, determining a candidate font whose font attributes are the same as those of the original font as a target font, and determining a first font from the target font.

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

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

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

[0181] As shown in FIG. 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 implement the text typesetting method of any of the method embodiments described above.

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

[0183] In one example, the electronic device is a terminal device as described above.

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

[0185] As shown in FIG. 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 implement the text typesetting method of any of the above method embodiments. <Computer-readable storage medium>

[0186] An embodiment of the present invention further provides a computer readable storage medium storing a computer program which, when executed by a processor, performs a method for typesetting text according to any of the method embodiments above.

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

[0188] A computer-readable storage medium may be a tangible device capable of holding and storing instructions used in an instruction execution device. A computer-readable storage medium may be, but is not limited to, an electrical storage 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 (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 versatile disk (DVD), memory stick, floppy disk, machine-encoded devices such as punch cards or slot-in-groove structures on which instructions are stored, and any suitable combination of the above. A computer-readable storage medium as used herein is not to be construed as a transient signal itself, such as an electric wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a wave guide or other transmission medium (such as, for example, a light pulse through a fiber optic cable), or an electrical signal transmitted through an electrical wire.

[0189] The computer readable program instructions described herein may be downloaded from a computer readable storage medium into each computing / processing device, or 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 transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter or network interface in each computing / processing device receives the computer readable program instructions from the network and transfers the computer readable program instructions for storage in a computer readable storage medium in each computing / processing facility.

[0190] The computer program instructions for carrying out the operations 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 or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Smalltalk, C++, and traditional procedural programming languages ​​such as "C" or similar programming languages. The computer readable program instructions may be executed entirely on the user computer, partially on the user computer, as separate 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 a wide area network (WAN), or may be connected to an external computer (e.g., connected via the Internet using an Internet Service Provider). In some embodiments, state information of the computer readable program instructions is used to personalize an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), such that the electronic circuit can execute the computer readable program instructions, thereby implementing various aspects of the present invention.

[0191] Various aspects of the present invention have been described herein with reference to flowchart and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. Each block in the flowchart and / or block diagram, and combinations of blocks in the flowchart and / or block diagram, can be implemented by computer readable program instructions.

[0192] These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, whereby, when the instructions are executed by the processor of the computer or other programmable data processing apparatus, a device is generated that implements the functions / operations specified in one or more blocks in the flowcharts and / or block diagrams. These computer readable program instructions may be stored on a computer readable storage medium, and the instructions cause a computer, programmable data processing apparatus, and / or other device to operate in a particular manner, such that the computer readable medium on which the instructions are stored includes an article of manufacture containing instructions that implement each aspect of the functions / operations specified in one or more blocks in the flowcharts and / or block diagrams.

[0193] The computer readable program instructions are loaded into a computer, other programmable data processing apparatus, or other device to cause the computer, other programmable data processing apparatus, or other device to execute a series of operational steps to generate a computer-implemented process, whereby the instructions executing on the computer, other programmable data processing apparatus, or other device implement the functions / acts specified in one or more blocks in the flowcharts and / or block diagrams.

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

[0195] Although each embodiment of the present invention has been described above, the above description is illustrative and not exhaustive, and is not limited to each disclosed embodiment. Many modifications and changes can be easily made by those skilled in the art without departing from the scope and spirit of each described embodiment. The selection of terms used in the present specification is intended to best interpret the principles, practical applications, or improvements to commercially available technology of each embodiment, or to enable those skilled in the art to understand each disclosed embodiment of the present invention. The scope of the present invention is limited by the scope of the appended claims.

Claims

1. 1. A method for typesetting text applied to a local application executed on a terminal device, comprising: determining an original font to be used for the 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 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 character measurement data of the original font. A method for typesetting text, comprising:

2. The step of obtaining character measurement data of the original font includes: retrieving character measurement data of the original font in a local cache of the terminal device; if the character measurement data of the original font is not found in the local cache of the terminal device, obtaining the character measurement data of the original font from a server.

2. The method of claim 1 .

3. Displaying the target text in a first font supported by the local application includes: selecting a first font that matches the original font from all fonts supported by the local application; displaying the target text in the selected first font; 2. The method of claim 1 .

4. The step of selecting a first font that matches the original font from all fonts supported by the local application includes: obtaining a list of substitute fonts for the original font; determining a candidate font from a substitution font in the substitution font list, the candidate font being a font supported by the local application; determining, from among the candidate fonts, a font that matches the original font most closely as the first font; 4. The method according to claim 3 .

5. Displaying the target text in a first font supported by the local application includes: determining a character type of the target text; selecting a first font that matches the original font from all fonts supported by the local application according to a predetermined rule related to a character type of the target text; displaying the target text in the selected first font.

2. The method of claim 1 .

6. The character measurement data of the original font includes a character width of the original font and a 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 includes: obtaining character measurement data for a candidate font, the candidate font being a font supported by the local application; determining a typesetting direction of the target text; determining a candidate font whose character width is closest to that of the original font as the first font when the typesetting direction of the target text is landscape typesetting; If the typesetting direction of the target text is portrait typesetting, determining a candidate font whose character height is closest to that of the original font as the first font.

6. The method according to claim 3 or 5.

7. The character measurement data of the original font includes a character width of the original font and a 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 includes: obtaining font attributes of the original font and font attributes of a candidate font, the candidate font being a font supported by the local application; determining a candidate font whose font attributes are the same as those of the original font as a target font; obtaining character measurement data for the target font; determining a typesetting direction of the target text; determining a target font having a character width closest to that of the original font as the first font when the typesetting direction of the target text is landscape typesetting; If the typesetting direction of the target text is portrait typesetting, determining a target font whose character height is closest to that of the original font as the first font.

6. The method according to claim 3 or 5.

8. When the character type of the target text is an alphabet type or a multilingual mixed type, selecting a first font that matches the original font from all fonts supported by the local application according to a predetermined rule related to the character type of the target text, includes: sending font identifiers of candidate fonts to a server and receiving a font identifier of the first font from the server, such that the server determines the first font from the candidate fonts based on font attributes of the original font and a width of a predetermined string in the original font; or acquiring font attributes of the original font and a width of a predetermined character string in the original font from a server, and determining the first font from the candidate fonts based on the font attributes of the original font and the width of the predetermined character string in the original font; the candidate font is a font supported by the local application, and the predetermined character string includes a plurality of different predetermined characters; 6. The method of claim 5 .

9. The candidate fonts include default fonts and non-default fonts supported by the local application, and the step of determining the first font from the candidate fonts based on font attributes of the original font and a width of a predetermined character string in the original font includes: determining the default font as the first font when the font attributes of the default font and the original font are the same and a similarity between a width of a predetermined character string in the default font and a width of a predetermined character string in the original font satisfies a predetermined criterion; otherwise, a candidate font having font attributes equal to those of the original font is taken as a target font, and the first font is determined from the target font.

9. The method of claim 8.

10. The determination of whether a similarity between a width of a predetermined character string in the default font and a width of a predetermined character string in the original font satisfies a predetermined criterion is performed by: determining a fourth difference between a width of the predetermined character string in the default font and a width of the predetermined character string in the original font; determining a ratio between an absolute value of the fourth difference and a width of a predetermined character string in the original font as a first ratio; determining that a similarity between a width of the predetermined character string in the default font and a width of the predetermined character string in the original font satisfies a predetermined criterion if the first ratio is equal to or less than a first predetermined threshold value; 10. The method of claim 9.

11. The step of determining the first font from the target font comprises: determining the target font as the first font, the target font having a width of a predetermined character string closest to the width of the predetermined character string in the original font; or determining a target font having a smallest width for a given character string as the first font; 10. The method of claim 9.

12. The character measurement data of the original font includes a character width of the original font and a character height of the original font, and the step of typesetting the displayed target text according to the character measurement data of the original font includes: determining a typesetting direction of the target text; If the typesetting direction of the target text is landscape typesetting, determining a first difference, the first difference being a difference between a character width in the original font and a character width in the first font of a character of a target text; adjusting abscissa values ​​of characters of the target text displayed in the first font if the first difference is a positive value; if the first difference is a negative value, shrinking characters of the target text displayed in the first font; If the typesetting direction of the target text is portrait typesetting, determining a second difference, the second difference being a difference between a character height of a character of a target text in the original font and a character height of the character in the first font; adjusting ordinate values ​​of characters of the target text displayed in the first font if the second difference is a positive value; and if the second difference is a negative value, shrinking characters of the target text displayed in the first font.

2. The method of claim 1 .

13. The character measurement data of the original font includes a character width of the original font, and the step of typesetting the target text based on the character measurement data of the original font includes: Segmenting the target text into words; accumulating the difference between the width of each character in the word in the first font and the width of each character in the original font to obtain an adjustment amount; calculating a ratio of the adjustment amount to the number of character gaps in the word as a second ratio; and adjusting the letter spacing in the words based on the second ratio so that the letter spacing in the words is the same.

13. The method according to claim 1 or 12.

14. A text typesetting method applied to a server, comprising: receiving a font identifier of an original font of a target text transmitted by a terminal device; retrieving character measurement data of the original font based on a font identifier of the original font; sending 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; A method for typesetting text, comprising:

15. 1. A text composition device comprising: a first determination module for determining an original font used in the 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; a typesetting module for typesetting the target text displayed in a first font supported by a local application of a terminal device based on character measurement data of the original font; 1. A text typesetting device comprising:

16. 1. A text composition device comprising: a receiving module for receiving a font identifier of an original font of a target text transmitted by the terminal device; a search module for searching character measurement data of the original font based on a font identifier of the original font; a sending module for sending 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; 1. A text typesetting device comprising:

17. An electronic device comprising a memory and a processor, the memory being adapted to store a computer program and the processor being adapted to execute the computer program to perform the method according to any one of claims 1 to 13.

1. An electronic device comprising:

18. A server including a memory and a processor, the memory being adapted to store a computer program, and the processor being adapted to execute the computer program to perform the method of claim 14. A server comprising:

19. A computer-readable storage medium storing a computer program, the computer program being executed by a processor to perform the method according to any one of claims 1 to 14. A computer-readable storage medium comprising:

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

  • System and method for independent font substitution of string characters

    US20090109227A1