Text typesetting method and device, electronic device, server and storage medium

By obtaining and using the character measurement data of the original font, the problem of document layout inconsistency caused by missing fonts in the terminal device is solved, maintaining the consistency of document layout in local applications, and reducing costs and thresholds.

CN113642289BActive Publication Date: 2024-10-22ZHUHAI KINGSOFT OFFICE SOFTWARE +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110988381.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-26
Publication Date
2024-10-22
Estimated Expiration
2041-08-26

AI Technical Summary

Technical Problem

When a terminal device uses a local application to open a document, the lack of the original font of the document may lead to differences in document layout, affecting the aesthetics and consistency of the reading experience. Existing solutions are costly and difficult to promote.

Method used

By determining the original font used by the target text, determine whether the local application supports the font. If not, obtain the character measurement data of the original font, display the text in a font supported by the local application, and perform typesetting based on the character measurement data of the original font. Ensure layout consistency.

Benefits of technology

In the absence of original fonts, supported fonts are used for typesetting, maintaining the original typesetting consistency of the document, reducing costs and simplifying the promotion process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113642289B_ABST
    Figure CN113642289B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a text typesetting method and device, an electronic device, a server and a computer-readable storage medium, and relates to the field of computer technology. The method includes: determining an original font used by a 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 typeset the target text according to 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 disclosure relates to the field of computer technology, and more specifically, to a text typesetting method and device, an electronic device, and a storage medium. Background Art

[0002] When a document is opened using a local application on a terminal device, the lack of the original font of the document may result in a large difference in the layout of the document, affecting the appearance of the document and the consistency of the reading experience. The current general practice is to install the corresponding fonts in the current environment to solve the typesetting problem. However, this method has high costs and thresholds, and requires searching, downloading, and installing fonts. Fonts may also need to be paid for separately, which makes it difficult to promote and apply on a large scale. Therefore, it is necessary to propose a new text typeset method. Summary of the invention

[0003] One purpose of the embodiments of the present disclosure is to provide a new technical solution for text typesetting, so as to maintain the consistency between the document typesetting and the original typesetting in the case of missing fonts.

[0004] According to a first aspect of the present disclosure, a text typesetting method is provided. The method comprises:

[0005] Determine the original font used by the target text;

[0006] Determining whether the local application supports the original font;

[0007] If the local application does not support the original font, obtaining character measurement data of the original font;

[0008] The target text is displayed in a first font supported by the local application and the target text is typeset according to the character measurement data of the original font.

[0009] Optionally, the acquiring character measurement data of the original font includes:

[0010] querying the local cache for character measurement data of the original font;

[0011] When the character measurement data of the original font cannot be found in the local cache, the character measurement data of the original font is obtained from the server and stored in the local cache.

[0012] Optionally, before displaying the target text in a first font supported by the local application, the method further includes:

[0013] A first font matching the character measurement data of the original font is selected from all fonts supported by the native application.

[0014] Optionally, the selecting a first font matching the character measurement data of the original font from all fonts supported by the local application comprises:

[0015] Obtain a list of alternative fonts for the original font;

[0016] Determine a candidate font from the replacement fonts in the replacement font list, wherein the candidate font is a font supported by the local application;

[0017] The candidate font that is ranked first in the replacement font list is determined as the first font.

[0018] Optionally, before displaying the target text in a first font supported by the local application, the method further includes:

[0019] Determining the character type of the target text;

[0020] According to a preset rule associated with the type, a first font matching the character measurement data of the original font is selected from all fonts supported by the local application.

[0021] Optionally, the character measurement data of the original font includes a character width of the original font and a character height of the original font;

[0022] The step of selecting a first font that matches the character measurement data of the original font from all fonts supported by the local application comprises:

[0023] Obtaining character measurement data of a candidate font, the candidate font being a font supported by the local application;

[0024] Determine the layout direction of the target text;

[0025] When the typesetting direction of the target text is horizontal typesetting, determining a candidate font whose character width is closest to the character width of the original font as the first font;

[0026] In the case that the typesetting direction of the target text is vertical typesetting, a candidate font whose character height is closest to the character height of the original font is determined as the first font.

[0027] Optionally, the character measurement data of the original font includes a character width of the original font and a character height of the original font;

[0028] The step of selecting a first font that matches the character measurement data of the original font from all fonts supported by the local application comprises:

[0029] Acquire font attributes of the original font and font attributes of a candidate font, wherein the candidate font is a font supported by the local application;

[0030] Determine a candidate font having the same font attributes as the original font as a target font, and obtain character measurement data of the target font;

[0031] Determine the layout direction of the target text;

[0032] When the typesetting direction of the target text is horizontal typesetting, determining a target font whose character width is closest to the character width of the original font as the first font;

[0033] In the case that the typesetting direction of the target text is vertical typesetting, a target font whose character height is closest to the character height of the original font is determined as the first font.

[0034] Optionally, when the character type of the target text is a letter type or a multi-language mixed type, selecting a first font matching the character measurement data of the original font from all fonts supported by the local application according to a preset rule associated with the type includes:

[0035] Sending the font identifier of the candidate font to a server, so that the server can determine the first font from the candidate fonts according to the font attribute of the original font and the width of the preset character string under the original font, and receiving the font identifier of the first font from the server; or,

[0036] Acquire the font attributes of the original font and the width of the preset character string under the original font from the server, and determine the first font from the candidate fonts according to the font attributes of the original font and the width of the preset character string under the original font;

[0037] The candidate font is a font supported by the local application, and the preset character string includes a plurality of different preset characters.

[0038] Optionally, the candidate fonts include default fonts and non-default fonts supported by the local application;

[0039] The determining the first font from the candidate fonts according to the font attribute of the original font and the width of the preset character string under the original font includes:

[0040] If the font attributes of the default font and the original font are the same and the approximation between the width of the preset character string in the default font and the width of the preset character string in the original font meets the preset standard, the default font is determined as the first font; otherwise,

[0041] A candidate font having the same font attribute as the original font is used as a target font, and the first font is determined from the target fonts.

[0042] Optionally, determining whether the approximation between the width of the preset character string in the default font and the width of the preset character string in the original font meets a preset standard includes:

[0043] Determine a difference between a width of a preset character string in the default font and a width of a preset character string in the original font;

[0044] Determine a ratio between an absolute value of the difference and a width of a preset character string in the original font;

[0045] When the ratio is less than or equal to a preset first threshold, it is determined that the approximation between the width of the preset character string in the default font and the width of the preset character string in the original font meets a preset standard.

[0046] Optionally, determining the first font from the target font includes:

[0047] The target font that is closest to the width of the preset character string under the original font is determined as the first font; or the target font that has the smallest width of the preset character string is determined as the first font.

[0048] Optionally, the character measurement data of the original font includes a character width of the original font and a character height of the original font;

[0049] The typesetting the target text according to the character measurement data of the original font comprises:

[0050] Determining the typesetting direction of the target text;

[0051] In the case where the typesetting direction of the target text is horizontal typesetting, determining a first difference value, the first difference value being the difference value between the character width of the original font and the character width of the first font; in the case where the first difference value is a positive value, adjusting the horizontal coordinate value of the character of the target text; in the case where the first difference value is a negative value, reducing the character of the target text;

[0052] When the typesetting direction of the target text is vertical typesetting, determine a second difference, which is the difference between the character height of the original font and the character height of the first font; when the second difference is a positive value, adjust the vertical coordinate value of the characters of the target text; when the second difference is a negative value, shrink the characters of the target text.

[0053] Optionally, the character measurement data of the original font includes character width of the original font;

[0054] The typesetting the target text according to the character measurement data of the original font comprises:

[0055] Segmenting the target text into words;

[0056] Accumulating the difference between the width of each character in the word in the first font and the width of the corresponding character in the original font to obtain an adjustment amount;

[0057] A ratio of the adjustment amount to the number of character gaps in the word is calculated, and the gaps between the characters in the word are adjusted according to the ratio so that the gaps between the characters in the word are the same.

[0058] According to a second aspect of the present disclosure, a text typesetting method is provided. The method comprises:

[0059] A font identifier of an original font of a target text sent by a receiving terminal device;

[0060] Querying character measurement data of the original font according to the font identifier of the original font;

[0061] The character measurement data of the original font is sent 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 according to the character measurement data of the original font.

[0062] Optionally, before the terminal device displays the target text in a first font supported by its local application, the method further includes:

[0063] Acquire a replacement font list of the original font according to the font identifier of the original font;

[0064] Determine a candidate font from the replacement fonts in the replacement font list, wherein the candidate font is a font supported by the local application;

[0065] Determine the candidate font that ranks first in the replacement font list as the first font;

[0066] The identifier of the first font is sent to the terminal device.

[0067] Optionally, before the terminal device displays the target text in a first font supported by its local application, the method further includes:

[0068] Sending the font attributes of the original font and the width of the preset character string under the original font to the terminal device, so that the terminal device determines the first font from candidate fonts according to the font attributes of the original font and the width of the preset character string under the original font; or,

[0069] determining the first font from candidate fonts according to the font attribute of the original font and the width of the preset character string under the original font, and sending the font identifier of the first font to the terminal device;

[0070] The candidate font is a font supported by the local application, and the preset character string includes a plurality of different preset characters.

[0071] Optionally, the candidate fonts include default fonts and non-default fonts supported by the local application;

[0072] The determining the first font from the candidate fonts according to the font attribute of the original font and the width of the preset character string under the original font includes:

[0073] If the font attributes of the default font and the original font are the same and the approximation between the width of the preset character string in the default font and the width of the preset character string in the original font meets the preset standard, the default font is determined as the first font; otherwise,

[0074] A candidate font having the same font attribute as the original font is used as a target font, and the first font is determined from the target fonts.

[0075] Optionally, determining whether the approximation between the width of the preset character string in the default font and the width of the preset character string in the original font meets a preset standard includes:

[0076] Determine a difference between a width of a preset character string in the default font and a width of a preset character string in the original font;

[0077] Determine a ratio between an absolute value of the difference and a width of a preset character string in the original font;

[0078] When the ratio is less than or equal to a preset first threshold, it is determined that the approximation between the width of the preset character string in the default font and the width of the preset character string in the original font meets a preset standard.

[0079] Optionally, determining the first font from the target font includes:

[0080] The target font that is closest to the width of the preset character string under the original font is determined as the first font; or the target font that has the smallest width of the preset character string is determined as the first font.

[0081] According to a third aspect of the present disclosure, a text typesetting device is provided. The device comprises:

[0082] A first determination module is used to determine the original font used by the target text;

[0083] A second determination module, used to determine whether the local application supports the original font;

[0084] An acquisition module, configured to acquire character measurement data of the original font when the local application does not support the original font;

[0085] A typesetting module is used to 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.

[0086] According to a fourth aspect of the present disclosure, a text typesetting device is provided. The device comprises:

[0087] A receiving module, used for receiving a font identifier of an original font of a target text sent by a terminal device;

[0088] A query module, used for querying the character measurement data of the original font according to the font identifier of the original font;

[0089] The sending module is used to send 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 according to the character measurement data of the original font.

[0090] According to a fifth aspect of the present disclosure, an electronic device is also provided, including a memory and a processor, wherein the memory is used to store a computer program; and the processor is used to execute the computer program to implement the method according to the first aspect of the present disclosure.

[0091] According to a sixth aspect of the present disclosure, an electronic device is also provided, including a memory and a processor, wherein the memory is used to store a computer program; and the processor is used to execute the computer program to implement the method according to the second aspect of the present disclosure.

[0092] According to the seventh aspect of the present disclosure, a computer-readable storage medium is also provided, on which a computer program is stored. When the computer program is executed by a processor, the method according to the first aspect of the present disclosure or the method according to the second aspect of the present disclosure is implemented.

[0093] One beneficial effect of the embodiments of the present disclosure is that, if the local application does not support the original font of the target document, the local application uses the first font it supports to display the target text and typesets the target text according to the character measurement data corresponding to the original font, so that the local application can still maintain the consistency of the document typesetting and the original typesetting in the absence of the original font.

[0094] Other features and advantages of the embodiments of the present disclosure will become apparent from the following detailed description of exemplary embodiments of the present disclosure with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0095] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the embodiments of the present disclosure.

[0096] Figure 1 A schematic diagram of a document processing system provided by an embodiment of the present disclosure;

[0097] Figure 2 A method flow chart of a text typesetting method provided by an embodiment of the present disclosure;

[0098] FIG3(a) and FIG3(b) are schematic diagrams of character measurement data provided by an embodiment of the present disclosure;

[0099] Figure 4 is an example diagram of a text typesetting method provided by an embodiment of the present disclosure;

[0100] Figure 5 A method flow chart of a text typesetting method provided by an embodiment of the present disclosure;

[0101] Figure 6 is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present disclosure;

[0102] Figure 7 It is a schematic diagram of the hardware structure of a server according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0103] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values ​​set forth in these embodiments do not limit the scope of the present disclosure unless otherwise specifically stated.

[0104] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present disclosure, its application, or uses.

[0105] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered as part of the specification.

[0106] In all examples shown and discussed herein, any specific values ​​should be interpreted as merely exemplary and not limiting. Therefore, other examples of the exemplary embodiments may have different values.

[0107] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.

[0108] <Text layout method>

[0109] Figure 1 is a block diagram of a document processing system provided in an embodiment of this specification. Figure 1 As shown, the document processing system includes a server 101 and a user's terminal device 103 , and the server 101 and the terminal device 103 can communicate with each other through a network 102 .

[0110] 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, for example, be capable of wired communication or wireless communication, and may specifically include WiFi communication, Bluetooth 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 also include only some of the above devices.

[0111] The terminal device 103 may be, for example, an electronic device installed with an intelligent operating system (e.g., Android, IOS, Windows, Linux, etc.), including but 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 processor) 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 may, for example, be capable of wired communication or wireless communication, and may specifically include WiFi communication, Bluetooth communication, 2G / 3G / 4G / 5G communication, etc. The GPU 1035 is used to process the image. 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 may also include only some of the above devices.

[0112] In one embodiment of the present disclosure, the user can open the target text and typeset and edit the target text through the terminal device 103. The local application is, for example, document editing software, instant messaging software, office software, browser, etc. In one example, the user pre-registers an account on the local application, and the user can use the typesetting method provided in the embodiment of the present disclosure after logging into the account.

[0113] In one example, the local application can be, for example, a native application, a web application, a hybrid application, a light application, etc. A native application refers to an application that can be directly run on the current operating system. A web application refers to a web application that needs to be run in a browser. A hybrid application is a combination of the two, usually a native application with a built-in browser. A light application is an application that can be used without downloading and installing, and users can search and use it or directly scan the code to use it.

[0114] Figure 1The document processing system shown is merely illustrative and does not in any way imply any limitation on the embodiments of this specification, its application or use. It should be understood by those skilled in the art that, although multiple devices of the server and the terminal device are described above, the embodiments of this specification may only involve some of the devices. For example, the server may only involve a processor, a memory, and a communication device, and the terminal device may only involve 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 scheme disclosed in the embodiments of this specification. How instructions control the processor to operate is a well-known technology in the art, so it will not be described in detail here.

[0115] See also Figure 2 As shown, the embodiment of the present disclosure provides a text typesetting method. The method includes steps S102-S108. Steps S102-S108 can be implemented by a terminal device.

[0116] Step S102: Determine the original font used by the target text.

[0117] In the disclosed embodiment, the target text may be any part of the text in the document. In one example, the terminal device obtains the original font information of the target text from the document, thereby determining the original font used by the target text. Generally, the original font information may be stored in the document data of the document.

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

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

[0120] The fonts supported by local applications can be determined based on the font packages installed. In one example, if a local application has installed a font package for a certain font, it means that the local application supports that font. Generally speaking, the basic data package of local applications will be pre-installed with a variety of widely used font packages and one of the fonts can be set as the default font. If the user wants to use some niche and special fonts, they need to download the corresponding font package separately.

[0121] Step S106: When the local application does not support the original font, obtain character measurement data of the original font.

[0122] The characters referred to in the embodiments of the present disclosure include words and symbols. The symbols are not limited to punctuation marks, numeric symbols, mathematical symbols, special symbols, etc., and the words are not limited to Chinese characters, letters, etc.

[0123] In the embodiments of the present disclosure, the character measurement data of a font 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 of the characters in the original font state in the target text. For the same font and at the same font size, the sizes of different characters may be designed to be the same or different. If, for the same font and at the same font size, all its characters do not adopt the same size, a mapping relationship between the characters and the width and height of the characters is established, and this mapping relationship is used as the character measurement data. According to the mapping relationship, the width and height of each character can be found out.

[0124] In one example, the character measurement data further includes the ascent and descent values of the character.

[0125] As shown in FIGS. 3(a) and 3(b), for the same Chinese character "zao", the widths and heights are different for two different fonts at the same font size, and the ascent and descent values are also different. 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 and descent value of the font shown in FIG. 3(a) is 0, that is, the font has no ascent or descent relative to the baseline. The ascent and descent value of the font shown in FIG. 3(b) is a positive value, that is, the font rises relative to the baseline. If the ascent and descent value of the font is a negative value, that is, the font descends relative to the baseline.

[0126] In one example, the character measurement data of the font is obtained by measuring the character. For example, the target text is pre-displayed in a certain font, and the character measurement data of the target text in this font is measured, so as to obtain the character measurement data of this font.

[0127] In one example, the character measurement data of various fonts at various font sizes are pre-stored in the server.

[0128] In one example, for the terminal device to obtain the character measurement data of the original font, it may query the character measurement data corresponding to the original font in the local cache of the terminal device.

[0129] In one example, for the terminal device to obtain the character measurement data of the original font, it may be: first query the character measurement data of the original font in the local cache of the terminal device. In the case where the character measurement data of the original font cannot be queried, obtain the character measurement data of the original font from the server. In this example, after the terminal device obtains the character measurement data of the original font, it can store it in the local cache, so that when the character measurement data of this font is needed again next time, it can be directly read from the local cache.

[0130] Step S108: Display the target text in the first font supported by the local application and typeset the target text according to the character measurement data of the original font.

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

[0132] Before displaying the target text in the first font supported by the local application, the method may further include a step of confirming the first font. In the embodiment of the present disclosure, the terminal device selects the first font that matches the character measurement data of the original font from all fonts supported by the local application. The following is an example:

[0133] Example 1 of determining the first font:

[0134] Selecting a first font matching the character measurement data of the original font from all fonts supported by the local application includes steps S202-S206.

[0135] Step S202: Obtain a list of replacement fonts for the original font.

[0136] In one example, for any font, the matching degree between the remaining fonts and the font is detected in advance, and the font whose matching degree reaches the matching degree threshold is selected as the replacement font of the font. In the embodiment of the present disclosure, the matching degree between the two fonts can be determined based on the character measurement data of the two fonts. For any font, a replacement font list is established based on its replacement font, and the replacement fonts in the replacement font list are sorted from high to low according to the matching degree. The terminal device can obtain the replacement font list for each font from the server.

[0137] The following uses font A as an example to explain how to determine the matching degree of the character measurement data of font B and font A:

[0138] A difference between the width of the character of the font A and the width of the character of the font B is calculated as a first difference.

[0139] The difference between the height of the characters of the font A and the height of the characters of the font B is calculated as the second difference.

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

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

[0142] 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 matching degree of the character measurement data of font B and font A is determined according to the sum, wherein the larger the sum is, the lower the matching degree of the character measurement data of font B and font A is, and the smaller the sum is, the higher the matching degree of the character measurement data of font B and font A is.

[0143] Step S204: 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.

[0144] Step S206: Determine the candidate font that is ranked first in the replacement font list as the first font.

[0145] In this example, the replacement fonts supported by the local application are screened out from the replacement fonts in the replacement font list, and then the replacement font that best matches the original font is selected from the replacement fonts supported by the local application as the first font.

[0146] Using the replacement font table to determine the first font does not require the terminal device to perform complex calculations, which is more convenient and faster.

[0147] Example 2 for determining the first font:

[0148] Selecting a first font matching the character measurement data of the original font from all fonts supported by the local application includes steps S302-S304.

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

[0150] The character types include the first type and the second type. The first type refers to the characters of the target text being Chinese characters and other block characters, and the width and height of different Chinese characters are the same. The second type refers to the characters of the target text including letters, Roman characters, Mongolian characters, Arabic characters, or a mixture of multiple languages, and the widths and heights of these characters may be inconsistent.

[0151] Step S304: Select a first font that matches the character measurement data of the original font from all fonts supported by the local application according to a preset rule associated with the type.

[0152] In this example, the first font is determined according to the character type of the target text using a corresponding rule, which is described below using Example 3, Example 4, and Example 5.

[0153] Example 3 of determining the first font:

[0154] Selecting a first font matching the character measurement data of the original font from all fonts supported by the local application includes steps S402-S406.

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

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

[0157] Step S406: When the typesetting direction of the target text is horizontal typesetting, the candidate font whose character width is closest to the character width of the original font is determined as the first font. When the typesetting direction of the target text is vertical typesetting, the candidate font whose character height is closest to the character height of the original font is determined as the first font.

[0158] When the target text is typed in horizontal direction, the difference between the character width of the target text in the original font and the character width in the candidate font is calculated as the first difference. The smaller the absolute value of the first difference is, the closer the character width of the candidate font is to the character width of the original font. The candidate font with the smallest absolute value of the first difference is selected as the first font.

[0159] When the target text is arranged in a vertical direction, the difference between the character height of the characters in the target text in the original font and the character height of the characters in the candidate font is calculated as the second difference. 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. The candidate font with the smallest absolute value of the second difference is selected as the first font.

[0160] Example 3 is applicable to the case where the character type of the target text is the first type and the character type of the target text is the second type. That is, when the target text contains only Chinese characters or contains letters and Roman characters, the first font can be determined in the manner of Example 3.

[0161] Example 4 of determining the first font:

[0162] Selecting a first font matching the character measurement data of the original font from all fonts supported by the local application includes steps S502-S508.

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

[0164] The font attributes of a font refer to the inherent attributes of the font itself, which can reflect the style of the font. The font attributes of a font include one or more of the font's thickness, boldness, and tilt.

[0165] For example, for the thickness of a font, there are three attribute values, from thick to thin, including "thick", "regular", and "thin". For example, for the blackening degree of a font, there are two attribute values, including "blackening" and "no blackening". For example, for the tilt degree of a font, there are two attribute values, including "tilt" and "no tilt".

[0166] For example, for the three fonts "Song", "Hua Wen Xi Hei" and "Fang Zheng Bold Black Song Simplified", the font properties of "Song" are: thickness "thin", blackening "no blackening", and tilt "no tilt"; the font properties of "Hua Wen Xi Hei" are: thickness "thin", blackening "darkened", and tilt "no tilt"; and the font properties of "Fang Zheng Bold Black Song Simplified" are: thickness "bold", blackening "darkened", and tilt "no tilt".

[0167] For example, for the two fonts "Times New Roman" and "Forte", the font properties of "Times New Roman" are: weight is "thin", black level is "no black", and italic level is "no italic", and the font properties of "Forte" are: weight is "bold", black level is "black", and italic level is "with italic".

[0168] Step S504: determine the candidate font whose font attributes are the same as those of the original font as the target font, and obtain character measurement data of the target font.

[0169] In one example, the font attributes of a font only include the thickness of the font. If the candidate font and the original font are both "thick", or both "regular", or both "thin", then the attributes of the candidate font and the original font are the same.

[0170] In one example, the font attributes of a font include the thickness, boldness and tilt of the font. If the attribute values ​​of the candidate font and the original font in the three aspects of the thickness, boldness and tilt are consistent, then the attributes of the candidate font and the original font are the same.

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

[0172] Step S508: When the typesetting direction of the target text is horizontal typesetting, the target font whose character width is closest to the character width of the original font is determined as the first font. When the typesetting direction of the target text is vertical typesetting, the target font whose character height is closest to the character height of the original font is determined as the first font.

[0173] The implementation of step S508 can be similar to that of the aforementioned step S406, which will not be elaborated here.

[0174] Example 4 is applicable when the character type of the target text is the first type and when the character type of the target text is the second type. That is to say, when the target text only contains Chinese characters, or when the target text contains letters and Roman characters, the method of Example 4 can be used to determine the first font.

[0175] In this example, among all the candidate fonts, filter out the candidate fonts whose font attributes are different from those of the original font, and retain the candidate fonts whose font attributes are the same as those of the original font as the target font. Confirm the first font among the target fonts, so that the style of the selected first font is consistent with the style of the original font, and the presentation style of the target text displayed in the first font locally is more similar to the target text under the original font.

[0176] Example 5 for determining the first font:

[0177] According to the preset rules associated with the type, select the first font that matches the character measurement data of the original font from all the fonts supported by the local application. It can be:

[0178] The terminal device sends the font identifier of the candidate font to the server for the server to determine the first font from the candidate fonts according to the font attributes of the original font and the width of the preset string under the original font. Then, the server sends the font identifier of the first font to the terminal device, and the terminal device receives the font identifier of the first font from the server. Or,

[0179] The terminal device obtains the font attributes of the original font and the width of the preset string under the original font from the server, and determines the first font from the candidate fonts according to the font attributes of the original font and the width of the preset string under the original font.

[0180] Among them, the candidate fonts are the fonts supported by the local application, and the preset string includes multiple different preset characters. The preset characters in the preset string should be representative characters in terms of either the character width or the character height. For example, select any Chinese character and the characters "w", "z", "i" with representative widths in English to form the preset string, and the preset string can be "MingWwZzIi".

[0181] Example 5 is applicable to the case where the character type of the target text is the second type. That is to say, when the target text includes characters such as letters, Roman characters, Mongolian, or Arabic, or is a mixture of multiple languages, the method of Example 5 can be applied to determine the first font. For example, when the character type of the target text is a letter type or a multi-language mixed type (for example, the target text contains both Chinese content and English content, for example, the target text contains both Chinese content and Japanese content), the method of Example 5 can be applied to determine the first font. Determining the first font based on the width of a preset character string can be suitable for situations where character widths are different, has a small amount of calculation, and is more efficient and fast.

[0182] In one example, the candidate fonts include default fonts and non-default fonts supported by the local application. The local application is pre-set with a default font, and the terminal device sets the default font when the application is installed. The user can modify the default font according to personal preference.

[0183] Determining a first font from candidate fonts according to the font attributes of the original font and the width of a preset character string under the original font includes steps S602-S604.

[0184] Step S602: If the font attributes of the default font and the original font are the same and the width of the preset character string in the default font and the width of the preset character string in the original font meet the preset standard, the default font is determined as the first font. Otherwise, step S604 is executed.

[0185] In one example, determining whether the approximation between the width of the preset character string in the default font and the width of the preset character string in the original font meets a preset standard includes steps S6022-S6026.

[0186] Step S6022: Determine the difference between the width of the preset character string in the default font and the width of the preset character string in the original font.

[0187] Step S6024: Determine the ratio of the absolute value of the difference to the width of the preset character string in the original font.

[0188] Step S6026: If the ratio is less than or equal to a preset first threshold, determine that the approximation between the width of the preset character string in the default font and the width of the preset character string in the original font meets the preset standard. If the ratio is greater than the preset first threshold, determine that the approximation between the width of the preset character string in the default font and the width of the preset character string in the original font does not meet the preset standard.

[0189] In an example, the approximation between the width and height of the preset character string in the default font and the width and height of the preset character string in the original font meets a preset standard, which means that the ratio of the width of the preset character string in the default font to the width of the preset character string in the original font is between 0.95 and 1.05.

[0190] Step S604: taking candidate fonts having the same font attributes as the original font as target fonts, and determining a first font from the target fonts.

[0191] In step S604, among all candidate fonts (including default fonts and non-default fonts), a candidate font having the same font attributes as the original font is selected as the target font.

[0192] In one example, step S604, determining the first font from the target fonts, may be: determining the target font that is closest to the width of the preset character string under the original font as the first font.

[0193] The difference between the width of the preset character string in the original font and the width in the target font is calculated as the third difference. The smaller the absolute value of the third difference, the closer the width of the preset character string in the target font is to the original font. The target font with the smallest absolute value of the third difference is selected as the first font. In this way, the layout of the target text presented to the user by the local application before typeset is similar to the original layout of the target text, and only fine-tuning is required during typesetting.

[0194] In one example, step S604, determining the first font from the target fonts, may be: determining the target font with the smallest width of the preset character string as the first font.

[0195] Selecting the target font with the smallest width of the preset character string as the first font can minimize the overlap of characters when the local application displays the target text in the first font. It is also not easy for overlapping to cause reading difficulties for users before typeset.

[0196] In this example, taking into account the user's font usage habits, the default font is given priority as the first font to replace the original font. If the font properties of the default font and the original font are the same and the approximation between the width of the preset string under the default font and the width of the preset string under the original font meets the preset standard, the candidate font with the same font properties as the original font is used as the target font, and the first font is determined from the target fonts. If the font properties of the default font and the original font are not the same, or the approximation between the width of the preset string under the default font and the width of the preset string under the original font does not meet the preset standard, the first font is determined from the candidate fonts with the same font properties as the original font. In this way, the user's preferences are taken into account, the amount of calculation is reduced, and processing time is saved.

[0197] In the above examples 2 to 5 of confirming the first font, the implementation method of determining the similarity and matching degree between the candidate font, the target font and the original font can also be applied to determining the replacement fonts in the replacement list.

[0198] 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 according to the character measurement data of the original font. There are many ways to do this, which are described below with examples.

[0199] Layout example 1:

[0200] First, the typesetting direction of the target text is determined, and the target text displayed in the first font on the terminal device is typeset according to the typesetting direction of the target text.

[0201] When the typesetting direction of the target text is horizontal typesetting, the characters of the target text are subjected to a first scaling process so that the character width of the target text is consistent with the character width of the original font. When the typesetting direction of the target text is vertical typesetting, the characters of the target text are subjected to a second scaling process so that the character height of the target text is consistent with the character height of the original font.

[0202] In Example 1, scaling of characters can be achieved by adjusting the font size.

[0203] In one implementation, in step S108, typeset the target text displayed on the terminal device according to the character measurement data corresponding to the original font, which may be: obtaining the character measurement data corresponding to the first font, and typeset the target text displayed on the terminal device according to the character measurement data corresponding to the original font and the character measurement data corresponding to the first font.

[0204] Layout example 2:

[0205] First, the typesetting direction of the target text is determined, and the target text displayed in the first font on the terminal device is typeset according to the typesetting direction of the target text.

[0206] When the typesetting direction of the target text is horizontal typesetting, a first difference is determined, where the first difference is the difference between the character width of the original font and the character width of the first font. When the first difference is a positive value, the horizontal coordinate value of the character of the target text is adjusted. When the first difference is a negative value, the character of the target text is reduced.

[0207] When the typesetting direction of the target text is vertical typesetting, a second difference is determined, where the second difference is the difference between the character height of the original font and the character height of the first font. When the second difference is a positive value, the ordinate value of the character of the target text is adjusted. When the second difference is a negative value, the character of the target text is reduced.

[0208] In this example, the reduction of characters can be achieved by adjusting the font size.

[0209] The following takes the target text as an example for horizontal layout:

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

[0211] If DW is a positive value, it means that the character width of the first font is smaller than the character width of the original font, and the coordinate value of the horizontal coordinate of each character of the target text in the first font needs to be adjusted.

[0212] See also Figure 4 As shown in the figure, the target text is a line of content, including the 10 characters "Good morning, today's weather is great". In the original font, the coordinate values ​​of the horizontal coordinates of the 10 characters are X1, X2, ..., X 10 After typesetting, the coordinate values ​​of the horizontal coordinates of the 10 characters are X1', X2', ..., X 10 ',but:

[0213] X1'=X1+0.5*DW

[0214] X2'=X2+(2-1)*DW+0.5*DW,

[0215] …

[0216] X n '=X n +(n-1)*DW+0.5*DW,

[0217] …

[0218] X 10 '=X 10 +(10-1)*DW+0.5*DW,

[0219] Wherein, n is an integer, 1≤n≤10.

[0220] It can be seen that adjusting the coordinate value of the horizontal coordinate of each character in the line of content under the first font is equivalent to adjusting the spacing between adjacent characters in the line of content.

[0221] If DW is a negative value, it means that the width of the characters of the first font is greater than the width of the characters of the original font. If the coordinate value is adjusted, the characters will overlap. Therefore, the font size of the target text displayed by the terminal device needs to be reduced. In one example, the font size of the target text displayed by the terminal device is reduced according to the ratio of W1 / W2, and the original position (coordinate value) of the target text is kept unchanged. For example, W1 / W2=R1, assuming that the original font size of this content is U1, the font size of this content is adjusted to U2, U2=R1*U1.

[0222] The following takes the target text as an example for horizontal layout:

[0223] 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 between H1 and H2 is calculated as the second difference.

[0224] If DH is a positive value, it means that the character height of the first font is smaller than the character height of the original font, and the coordinate value of the ordinate of each character in the first font is adjusted.

[0225] Assume that the target text in the original font has a total of M lines of content, and the ordinate values ​​of the characters in each line are the same. The ordinate values ​​of the characters from the 1st to the Mth line are Y1, Y2, ..., Y M After typesetting, the vertical coordinate values ​​of the characters from row 1 to row M are Y1', Y2', ..., Y M ',but:

[0226] Y1'=Y1+0.5*DH

[0227] Y2'=Y2+(2-1)*DH+0.5*DH,

[0228] …

[0229] Y m '=Y m +(m-1)*DH+0.5*DH,

[0230] …

[0231] Y M '=Y M +(M-1)*DH+0.5*DH,

[0232] Wherein, m is an integer, 1≤m≤M.

[0233] 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 between adjacent lines of the target text.

[0234] If DH is a negative value, it means that the height of the characters of the first font is greater than the height of the characters of the original font. If the coordinate value is adjusted, the characters will overlap. Therefore, the font size of the target text displayed by the terminal device needs to be reduced. In one example, the font size of the target text displayed by the terminal device is reduced according to the ratio of H1 / H2, and the original position (coordinate value) of the target text is kept unchanged. For example, H1 / H2=R2, assuming that the original font size of the target text is U1, the font size is adjusted to U2, U2=R2*U1.

[0235] Typesetting example three:

[0236] First, the typesetting direction of the target text is determined, and the target text displayed in the first font on the terminal device is typeset according to the typesetting direction of the target text.

[0237] When the typesetting direction of the target text is horizontal typesetting, the font size of the target text is adjusted to the first font size, and the first font size is the font size whose character width is closest to the character width of the original font. After the font size of the target text is adjusted to the first font size, a first difference is determined, and the first difference is the difference between the character width of the original font and the character width of the first font. When the first difference is a positive value, the horizontal coordinate value of the character of the target text is adjusted. When the first difference is a negative value, the character of the target text is reduced.

[0238] That is to say, when the target text is typesetting in a horizontal direction, after the terminal device adjusts the font size of the target text under the first font to the first font size, if the character width is still larger than the character width under the original font, the font size is reduced to make the characters smaller to avoid the situation where characters overlap each other.

[0239] When the typesetting direction of the target text is vertical typesetting, the font size of the target text is adjusted to a second font size, where the second font size is the font size whose character height is closest to the character height of the original font. After the font size of the target text is adjusted to the second font size, a second difference is determined, where the second difference is the difference between the character height of the original font and the character height of the first font. When the second difference is a positive value, the ordinate value of the character of the target text is adjusted. When the second difference is a negative value, the character of the target text is reduced.

[0240] That is to say, when the target text is typesetting in vertical direction, after the terminal device adjusts the font size of the target text under the first font to the second font size, if the character height is still greater than the character height under the original font, the font size is adjusted down to make the characters smaller to avoid the situation where characters overlap each other.

[0241] In this example, the reduction of characters can be achieved by adjusting the font size.

[0242] After the terminal device typesets the displayed target text, the typesetting of the displayed target text is closer to the typesetting of the target text displayed in the original font. Figure 4 As shown, for the target text "Good morning, today's weather is great", the total width of this content in the original font is wider when compared with the first font. After the typesetting in step S108, the total width of this content displayed by the terminal device using the first font is closer to the total width of this content in the original font. In this way, it can be ensured that the same line of content in the original font will not be divided into lines due to changing to the first font for display.

[0243] Typesetting example 4:

[0244] Typesetting the target text according to the character measurement data of the original font may include steps S1085-S1087.

[0245] Step S1085: divide the target text into words.

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

[0247] Step S1087, calculating the ratio of the adjustment amount to the number of character gaps in the word, and adjusting the gaps between the characters in the word according to the ratio so that the gaps between the characters in the word are the same.

[0248] For example, there are T characters in a word of the target text, and the number of character gaps is G, G = T-1. The difference between the width of each character in the T characters and the width of the corresponding character in the original font is O1, O2, ..., O T , accumulate O1, O2, ..., O T The adjustment amount is obtained, and the ratio of the adjustment amount to the number of character gaps is calculated. If the ratio is a positive value, it means that the gap should be reduced, and the gap between the characters in the word is subtracted from the ratio. If the ratio is a negative value, it means that the gap should be increased, and the gap between the characters in the word is subtracted from the ratio.

[0249] In this way, the spacing between characters in the same word can be made the same, and the display can be more uniform. This can be applied to the second type of target text. When the widths of different characters are different, the characters in the same word can still be displayed more uniformly. Typesetting Example 4 can be performed after any of the above typesetting examples.

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

[0251] One beneficial effect of the embodiments of the present disclosure is that if the local application of the terminal device does not support the original font of the target document, the local application uses the first font it supports to display the target text and typesets the target text according to the character measurement data corresponding to the original font, so that the local application can still maintain the consistency of the document layout and the original layout in the absence of the original font.

[0252] See also Figure 5 As shown, the embodiment of the present disclosure provides a text typesetting method. The method includes steps S702-S706. Steps S702-S706 can be implemented by a server.

[0253] Step S702: Receive the font identifier of the original font of the target text sent by the terminal device.

[0254] Step S704: Query the character measurement data of the original font according to the font identifier of the original font.

[0255] Step S706: Send the character measurement data of the original font to the terminal device, so that the terminal device displays the target text in the first font supported by its local application and typesets the target text according to the character measurement data of the original font.

[0256] In one example, the server pre-stores font attributes of various fonts and character measurement data at various font sizes. The character measurement data of the font includes the height and width of the character. The character measurement data of the font may also include the rise and fall values ​​of the character. The font attributes of a font refer to the inherent attributes of the font itself, which can reflect the style of the font. The font attributes of a font include one or more of the thickness, blackening, and tilt of the font.

[0257] In one example, before the terminal device displays the target text in a first font supported by its local application, the method further includes: obtaining a list of replacement fonts for the original font according to the 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 that is ranked first in the replacement font list as the first font. Sending the identifier of the first font to the terminal device.

[0258] In one example, before the terminal device displays the target text in the first font supported by its local application, the method further includes: sending the font attributes of the original font and the width of the preset character string under the original font to the terminal device, so that the terminal device determines the first font from the candidate fonts according to the font attributes of the original font and the width of the preset character string under the original font. The candidate font is a font supported by the local application, and the preset character string includes a plurality of different preset characters.

[0259] 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 the first font from candidate fonts according to the font properties of the original font and the width of the preset character string under the original font, and sending the font identifier of the first font to the terminal device. The candidate font is a font supported by the local application, and the preset character string includes a plurality of different preset characters.

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

[0261] In one example, determining the first font from candidate fonts according to the font attributes of the original font and the width of the preset character string under the original font includes: if the font attributes of the default font and the original font are the same and the approximation between the width of the preset character string under the default font and the width of the preset character string under the original font meets a preset standard, determining the default font as the first font. Otherwise, taking the candidate font with the same font attributes as the original font as the target font, and determining the first font from the target fonts.

[0262] In one example, determining whether the approximation between the width of a preset character string in a default font and the width of a preset character string in an original font meets a preset standard includes: determining the difference between the width of the preset character string in the default font and the width of the preset character string in the original font. Determining the ratio of the absolute value of the difference to the width of the preset character string in the original font. In the case where the ratio is less than or equal to a preset first threshold, determining that the approximation between the width of the preset character string in the default font and the width of the preset character string in the original font meets the preset standard. In the case where the ratio is greater than the preset first threshold, determining that the approximation between the width of the preset character string in the default font and the width of the preset character string in the original font does not meet the preset standard.

[0263] In one example, determining the first font from the target fonts includes: determining the target font closest to the width of the preset character string under the original font as the first font; or determining the target font with the smallest width of the preset character string as the first font.

[0264] One beneficial effect of the embodiments of the present disclosure is that if the local application of the terminal device does not support the original font of the target document, the server provides the measurement data of the original font to the terminal device, and the local application uses the first font it supports to display the target text and typesets the target text according to the character measurement data corresponding to the original font, so that the local application can still maintain the consistency of the document layout and the original layout in the absence of the original font.

[0265] <Equipment Embodiment>

[0266] The present disclosure provides a text typesetting device, including the following modules:

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

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

[0269] The acquisition module is used for acquiring character measurement data of the original font when the local application does not support the original font.

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

[0271] In one example, obtaining the character measurement data of the original font includes: querying the character measurement data of the original font in the local cache. If the character measurement data of the original font cannot be found in the local cache, obtaining the character measurement data of the original font from the server and storing it in the local cache.

[0272] 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 character measurement data of the original font from all fonts supported by the local application.

[0273] In one example, selecting a first font that matches the character measurement data of the original font from all fonts supported by the local application includes: obtaining a list of replacement fonts for 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, and determining the candidate font that is ranked first in the replacement font list as the first font.

[0274] In one example, before displaying the target text in a first font supported by the local application, the method further includes: determining a character type of the target text, and selecting a first font that matches the character measurement data of the original font from all fonts supported by the local application according to a preset rule associated with the type.

[0275] In one example, the character measurement data of the original font includes the character width of the original font and the character height of the original font. Selecting a first font that matches the character measurement data of the original font from all fonts supported by the local application includes: obtaining the character measurement data of a candidate font, the candidate font is a font supported by the local application. Determine the typesetting direction of the target text. When the typesetting direction of the target text is horizontal typesetting, determine the candidate font whose character width is closest to the character width of the original font as the first font. When the typesetting direction of the target text is vertical typesetting, determine the candidate font whose character height is closest to the character height of the original font as the first font.

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

[0277] Selecting a first font that matches the character measurement data of 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 the candidate font whose font attributes are the same as those of the original font as the target font, and obtaining the character measurement data of the target font. Determining the typesetting direction of the target text. When the typesetting direction of the target text is horizontal typesetting, determining the target font whose character width is closest to the character width of the original font as the first font. When the typesetting direction of the target text is vertical typesetting, determining the target font whose character height is closest to the character height of the original font as the first font.

[0278] In one example, when the character type of the target text is a letter type or a multi-language mixed type, a first font matching the character measurement data of the original font is selected from all fonts supported by the local application according to a preset rule associated with the type, including: sending a font identifier of the candidate font to a server, so that the server determines the first font from the candidate fonts according to the font properties of the original font and the width of the preset character string under the original font, and receiving the font identifier of the first font from the server. Alternatively, the font properties of the original font and the width of the preset character string under the original font are obtained from the server, and the first font is determined from the candidate fonts according to the font properties of the original font and the width of the preset character string under the original font. The candidate font is a font supported by the local application, and the preset character string includes a plurality of different preset characters.

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

[0280] The first font is determined from the candidate fonts according to the font attributes of the original font and the width of the preset character string under the original font, including: if the font attributes of the default font and the original font are the same and the approximation degree between the width of the preset character string under the default font and the width of the preset character string under the original font meets the preset standard, the default font is determined as the first font. Otherwise, the candidate font with the same font attributes as the original font is used as the target font, and the first font is determined from the target fonts.

[0281] In one example, determining whether the approximation between the width of a preset character string in a default font and the width of a preset character string in an original font meets a preset standard includes: determining the difference between the width of the preset character string in the default font and the width of the preset character string in the original font. Determining the ratio of the absolute value of the difference to the width of the preset character string in the original font. When the ratio is less than or equal to a preset first threshold, determining that the approximation between the width of the preset character string in the default font and the width of the preset character string in the original font meets the preset standard.

[0282] In one example, determining the first font from the target fonts includes: determining the target font that is closest to the width of the preset character string under the original font as the first font. Alternatively, determining the target font that has the smallest width of the preset character string as the first font.

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

[0284] Typesetting a target text according to the character measurement data of the original font includes: determining the typesetting direction of the target text. When the typesetting direction of the target text is horizontal typesetting, determining 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. When the first difference is a positive value, adjusting the horizontal coordinate value of the characters of the target text. When the first difference is a negative value, reducing the characters of the target text. When the typesetting direction of the target text is vertical typesetting, determining 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. When the second difference is a positive value, adjusting the vertical coordinate value of the characters of the target text. When the second difference is a negative value, reducing the characters of the target text.

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

[0286] The target text is typeset according to the character measurement data of the original font, including: dividing 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 the corresponding character in the original font to obtain an adjustment amount, calculating the ratio of the adjustment amount to the number of character gaps in the word, and adjusting the gaps between the characters in the word according to the ratio so that the gaps between the characters in the word are the same.

[0287] The present disclosure provides a text typesetting device, including the following modules:

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

[0289] The query module is used to query the character measurement data of the original font according to the font identifier of the original font.

[0290] The sending module is used to send the character measurement data of the original font to the terminal device, so that the terminal device can display the target text in the first font supported by its local application and typeset the target text according to the character measurement data of the original font.

[0291] In one example, before the terminal device displays the target text in a first font supported by its local application, the method further includes: obtaining a list of replacement fonts for the original font according to the 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 that is ranked first in the replacement font list as the first font. Sending the identifier of the first font to the terminal device.

[0292] In one example, before the terminal device displays the target text in the first font supported by its local application, the method further includes: sending the font attributes of the original font and the width of the preset character string under the original font to the terminal device, so that the terminal device can determine the first font from the candidate fonts according to the font attributes of the original font and the width of the preset character string under the original font. Alternatively, the first font is determined from the candidate fonts according to the font attributes of the original font and the width of the preset character string under the original font, and the font identifier of the first font is sent to the terminal device. The candidate font is a font supported by the local application, and the preset character string includes a plurality of different preset characters.

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

[0294] The first font is determined from the candidate fonts according to the font attributes of the original font and the width of the preset character string under the original font, including: if the font attributes of the default font and the original font are the same and the approximation degree between the width of the preset character string under the default font and the width of the preset character string under the original font meets the preset standard, the default font is determined as the first font. Otherwise, the candidate font with the same font attributes as the original font is used as the target font, and the first font is determined from the target fonts.

[0295] In one example, determining whether the approximation between the width of a preset character string in a default font and the width of a preset character string in an original font meets a preset standard includes: determining the difference between the width of the preset character string in the default font and the width of the preset character string in the original font. Determining the ratio of the absolute value of the difference to the width of the preset character string in the original font. When the ratio is less than or equal to a preset first threshold, determining that the approximation between the width of the preset character string in the default font and the width of the preset character string in the original font meets the preset standard.

[0296] In one example, determining the first font from the target fonts includes: determining the target font that is closest to the width of the preset character string under the original font as the first font. Alternatively, determining the target font that has the smallest width of the preset character string as the first font.

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

[0298] like Figure 6 As shown, the electronic device 800 includes a processor 801 and a memory 802, wherein the memory 802 is used to store an executable computer program, and the processor 801 is used to execute the computer program to implement the text typesetting method of any of the above method embodiments.

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

[0300] In one example, the electronic device is the aforementioned terminal device.

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

[0302] like Figure 7 As shown, the server 900 includes a processor 901 and a memory 902, wherein the memory 902 is used to store an executable computer program, and the processor 901 is used to execute the computer program to implement the text typesetting method of any of the above method embodiments.

[0303] <Computer Readable Storage Medium>

[0304] The embodiments of the present disclosure also provide a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the text typesetting method according to any of the above method embodiments is implemented.

[0305] The present disclosure may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.

[0306] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but 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 foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.

[0307] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or 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 can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.

[0308] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's 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., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.

[0309] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.

[0310] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0311] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0312] The flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of an instruction, and the module, a program segment or a part of an instruction contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of the boxes in the block diagram and / or the flowchart can be implemented by a dedicated hardware-based system that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions. It is well known to those skilled in the art that it is equivalent to implement it by hardware, implement it by software, and implement it by combining software and hardware.

[0313] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The choice of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the marketplace, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein. The scope of the present disclosure is defined by the appended claims.

Claims

1. A text typesetting method, characterized in that: include: Determine the original font used by the target text; Determining whether the local application supports the original font; In the case that the local application does not support the original font, obtaining character measurement data of the original font, wherein the character measurement data of the original font is measurement data of characters in the target text in the original font state; Displaying 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, wherein typeset the target text according to the character measurement data of the original font comprises: typeset the target text displayed in the first font according to the character measurement data of the original font; The character measurement data of the original font includes the character width of the original font; and typeset the target text according to the character measurement data of the original font, comprising: Determining the typesetting direction of the target text; When the typesetting direction of the target text is horizontal typesetting, determine a first difference, which is the difference between the character width of the original font and the character width of the first font; when the first difference is a positive value, adjust the horizontal coordinate value of the character of the target text; when the first difference is a negative value, shrink the character of the target text.

2. The method according to claim 1, characterized in that The step of obtaining the character measurement data of the original font includes: querying the local cache for character measurement data of the original font; When the character measurement data of the original font cannot be found in the local cache, the character measurement data of the original font is obtained from the server and stored in the local cache.

3. The method according to claim 1, characterized in that Before displaying the target text in a first font supported by the local application, the method further includes: A first font matching the character measurement data of the original font is selected from all fonts supported by the native application.

4. The method according to claim 3, characterized in that The step of selecting a first font that matches the character measurement data of the original font from all fonts supported by the local application comprises: Obtain a list of alternative fonts for the original font; Determine a candidate font from the replacement fonts in the replacement font list, wherein the candidate font is a font supported by the local application; The candidate font that is ranked first in the replacement font list is determined as the first font.

5. The method according to claim 1, characterized in that Before displaying the target text in a first font supported by the local application, the method further includes: Determining the character type of the target text; According to a preset rule associated with the type, a first font matching the character measurement data of the original font is selected from all fonts supported by the local application.

6. The method according to claim 3 or 5, characterized in that: The character measurement data of the original font includes a character width of the original font and a character height of the original font; The step of selecting a first font that matches the character measurement data of the original font from all fonts supported by the local application comprises: Obtaining character measurement data of a candidate font, the candidate font being a font supported by the local application; Determine the layout direction of the target text; When the typesetting direction of the target text is horizontal typesetting, determining a candidate font whose character width is closest to the character width of the original font as the first font; In the case that the typesetting direction of the target text is vertical typesetting, a candidate font whose character height is closest to the character height of the original font is determined as the first font.

7. The method according to claim 3 or 5, characterized in that: The character measurement data of the original font includes a character width of the original font and a character height of the original font; The step of selecting a first font that matches the character measurement data of the original font from all fonts supported by the local application comprises: Acquire font attributes of the original font and font attributes of a candidate font, wherein the candidate font is a font supported by the local application; Determine a candidate font having the same font attributes as the original font as a target font, and obtain character measurement data of the target font; Determine the layout direction of the target text; When the typesetting direction of the target text is horizontal typesetting, determining a target font whose character width is closest to the character width of the original font as the first font; In the case that the typesetting direction of the target text is vertical typesetting, a target font whose character height is closest to the character height of the original font is determined as the first font.

8. The method according to claim 5, characterized in that In a case where the character type of the target text is a letter type or a multi-language mixed type, selecting a first font matching the character measurement data of the original font from all fonts supported by the local application according to a preset rule associated with the type, comprises: Sending the font identifier of the candidate font to a server, so that the server can determine the first font from the candidate fonts according to the font attribute of the original font and the width of the preset character string under the original font, and receiving the font identifier of the first font from the server; or, Acquire the font attributes of the original font and the width of the preset character string under the original font from the server, and determine the first font from the candidate fonts according to the font attributes of the original font and the width of the preset character string under the original font; The candidate font is a font supported by the local application, and the preset character string includes a plurality of different preset characters.

9. The method according to claim 8, characterized in that The candidate fonts include default fonts and non-default fonts supported by the local application; The determining the first font from the candidate fonts according to the font attribute of the original font and the width of the preset character string under the original font includes: If the font properties of the default font and the original font are the same and the approximation between the width of the preset character string in the default font and the width of the preset character string in the original font meets a preset standard, determining the default font as the first font; otherwise, A candidate font having the same font attribute as the original font is used as a target font, and the first font is determined from the target fonts.

10. The method according to claim 9, characterized in that Determining whether the approximation between the width of the preset character string in the default font and the width of the preset character string in the original font meets a preset standard includes: Determine a difference between a width of a preset character string in the default font and a width of a preset character string in the original font; Determine a ratio between an absolute value of the difference and a width of a preset character string in the original font; When the ratio is less than or equal to a preset first threshold, it is determined that the approximation between the width of the preset character string in the default font and the width of the preset character string in the original font meets a preset standard.

11. The method according to claim 9, characterized in that The determining the first font from the target font comprises: The target font that is closest to the width of the preset character string under the original font is determined as the first font; or the target font that has the smallest width of the preset character string is determined as the first font.

12. The method according to claim 1, characterized in that The character measurement data of the original font further includes the character height of the original font; The typesetting the target text according to the character measurement data of the original font comprises: Determining the typesetting direction of the target text; When the typesetting direction of the target text is vertical typesetting, determine a second difference, which is the difference between the character height of the original font and the character height of the first font; when the second difference is a positive value, adjust the vertical coordinate value of the characters of the target text; when the second difference is a negative value, shrink the characters of the target text.

13. The method according to claim 1 or 12, characterized in that: The character measurement data of the original font includes the character width of the original font; The typesetting the target text according to the character measurement data of the original font comprises: 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 the corresponding character in the original font to obtain an adjustment amount; A ratio of the adjustment amount to the number of character gaps in the word is calculated, and the gaps between the characters in the word are adjusted according to the ratio so that the gaps between the characters in the word are the same.

14. A text typesetting method, characterized in that: include: A font identifier of an original font of a target text sent by a receiving terminal device; Querying the character measurement data of the original font according to the font identifier of the original font, wherein the character measurement data of the original font is the measurement data of the characters in the target text in the original font state; The character measurement data of the original font is sent 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 according to the character measurement data of the original font, wherein typeset the target text according to the character measurement data of the original font comprises: typeset the target text displayed in the first font according to the character measurement data of the original font; The character measurement data of the original font includes the character width of the original font; and typeset the target text according to the character measurement data of the original font, comprising: Determining the typesetting direction of the target text; When the typesetting direction of the target text is horizontal typesetting, determine a first difference, which is the difference between the character width of the original font and the character width of the first font; when the first difference is a positive value, adjust the horizontal coordinate value of the character of the target text; when the first difference is a negative value, shrink the character of the target text.

15. The method according to claim 14, characterized in that Before the terminal device displays the target text in a first font supported by its local application, the method further includes: Acquire a replacement font list of the original font according to the font identifier of the original font; Determine a candidate font from the replacement fonts in the replacement font list, wherein the candidate font is a font supported by the local application; Determine the candidate font that ranks first in the replacement font list as the first font; The identifier of the first font is sent to the terminal device.

16. The method according to claim 14, characterized in that Before the terminal device displays the target text in a first font supported by its local application, the method further includes: Sending the font attributes of the original font and the width of the preset character string under the original font to the terminal device, so that the terminal device determines the first font from candidate fonts according to the font attributes of the original font and the width of the preset character string under the original font; or, determining the first font from candidate fonts according to the font attribute of the original font and the width of the preset character string under the original font, and sending the font identifier of the first font to the terminal device; The candidate font is a font supported by the local application, and the preset character string includes a plurality of different preset characters.

17. The method according to claim 16, characterized in that The candidate fonts include default fonts and non-default fonts supported by the local application; The determining the first font from the candidate fonts according to the font attribute of the original font and the width of the preset character string under the original font includes: If the font properties of the default font and the original font are the same and the approximation between the width of the preset character string in the default font and the width of the preset character string in the original font meets a preset standard, determining the default font as the first font; otherwise, A candidate font having the same font attribute as the original font is used as a target font, and the first font is determined from the target fonts.

18. The method according to claim 17, characterized in that Determining whether the approximation between the width of the preset character string in the default font and the width of the preset character string in the original font meets a preset standard includes: Determine a difference between a width of a preset character string in the default font and a width of a preset character string in the original font; Determine a ratio between an absolute value of the difference and a width of a preset character string in the original font; When the ratio is less than or equal to a preset first threshold, it is determined that the approximation between the width of the preset character string in the default font and the width of the preset character string in the original font meets a preset standard.

19. The method according to claim 17, characterized in that The determining the first font from the target font comprises: The target font that is closest to the width of the preset character string under the original font is determined as the first font; or the target font that has the smallest width of the preset character string is determined as the first font.

20. A text typesetting device, characterized in that: include: A first determination module is used to determine the original font used by the target text; A second determination module, used to determine whether the local application supports the original font; an acquisition module, configured to acquire character measurement data of the original font if the local application does not support the original font, wherein the character measurement data of the original font is measurement data of characters in the target text in the original font state; A typesetting module, configured to 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, wherein the typesetting of the target text according to the character measurement data of the original font comprises: typeset the target text displayed in the first font according to the character measurement data of the original font; the character measurement data of the original font comprises the character width of the original font; the typesetting of the target text according to the character measurement data of the original font comprises: determining a typesetting direction of the target text; when the typesetting direction of the target text is horizontal typesetting, determining 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; when the first difference is a positive value, adjusting the horizontal coordinate value of the character of the target text; when the first difference is a negative value, shrinking the character of the target text.

21. A text typesetting device, characterized in that: include: A receiving module, used for receiving a font identifier of an original font of a target text sent by a terminal device; A query module, configured to query the character measurement data of the original font according to the font identifier of the original font, wherein the character measurement data of the original font is the measurement data of the characters in the target text in the original font state; A sending module, configured to send the character measurement data of the original font to a 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 according to the character measurement data of the original font, wherein typeset the target text according to the character measurement data of the original font comprises: typeset the target text displayed in the first font according to the character measurement data of the original font; the character measurement data of the original font comprises the character width of the original font; typeset the target text according to the character measurement data of the original font comprises: determining a typeset direction of the target text; determining a first difference when the typeset direction of the target text is horizontal typeset, the first difference being the difference between the character width of the original font and the character width of the first font; adjusting the horizontal coordinate value of the characters of the target text when the first difference is a positive value; and shrinking the characters of the target text when the first difference is a negative value.

22. An electronic device comprising a memory and a processor, wherein the memory is used to store a computer program; and the processor is used to execute the computer program to implement the method according to any one of claims 1 to 13.

23. A server comprising a memory and a processor, wherein the memory is used to store a computer program; and the processor is used to execute the computer program to implement the method according to any one of claims 14 to 19.

24. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 19.