WO2023024376A1 - 文本的排版 - Google Patents

文本的排版 Download PDF

Info

Publication number
WO2023024376A1
WO2023024376A1 PCT/CN2021/142042 CN2021142042W WO2023024376A1 WO 2023024376 A1 WO2023024376 A1 WO 2023024376A1 CN 2021142042 W CN2021142042 W CN 2021142042W WO 2023024376 A1 WO2023024376 A1 WO 2023024376A1
Authority
WO
WIPO (PCT)
Prior art keywords
font
original
character
target text
width
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2021/142042
Other languages
English (en)
French (fr)
Inventor
曹宗华
刘欢
罗嘉锐
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Office Software Inc
Zhuhai Kingsoft Office Software Co Ltd
Original Assignee
Beijing Kingsoft Office Software Inc
Zhuhai Kingsoft Office Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Office Software Inc, Zhuhai Kingsoft Office Software Co Ltd filed Critical Beijing Kingsoft Office Software Inc
Priority to JP2024513144A priority Critical patent/JP2024534170A/ja
Priority to EP21954891.4A priority patent/EP4379596A4/en
Priority to US18/686,835 priority patent/US20250131181A1/en
Publication of WO2023024376A1 publication Critical patent/WO2023024376A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/109Font handling; Temporal or kinetic typography
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/106Display of layout of documents; Previewing
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present disclosure relates to the field of computer technology, and more specifically, to a method and device for text typesetting, electronic equipment, and a storage medium.
  • An object of the embodiments of the present disclosure is to provide a new technical solution for text typesetting, so as to maintain the consistency between document typesetting and original typesetting in the case of missing fonts.
  • a text typesetting method includes: determining the original font used by the target text; determining whether the local application supports the original font; if the local application does not support the original font, acquiring character measurement data of the original font; displaying the target text in the first font supported by the local application; and performing typesetting on the displayed target text according to the character measurement data of the original font.
  • a text typesetting method includes: receiving the font identification of the original font of the target text sent by the terminal device; querying the character measurement data of the original font according to the font identification of the original font; sending the character measurement data of the original font to the terminal A device for the terminal device to typesetting the target text displayed in the first font supported by the local application of the terminal device according to the character measurement data of the original font.
  • a text typesetting device includes: a first determination module, configured to determine the original font used by the target text; a second determination module, configured to determine whether the local application supports the original font; an acquisition module, configured to determine if the local application does not support the original font.
  • the typesetting module is configured to use the first font supported by the local application of the terminal device to display the target according to the character measurement data of the original font
  • the text is typeset.
  • a text typesetting device includes: a receiving module, configured to receive the font identifier of the original font of the target text sent by the 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; a sending module , 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 with the first font supported by its local application and perform the target text according to the character measurement data of the original font Typesetting.
  • an electronic device including a memory and a processor.
  • the memory is used to store the computer program; the processor is used to execute the computer program, so as to realize the method according to the first aspect or the second aspect of the present disclosure.
  • a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the method according to the first aspect of the present disclosure or the present invention is implemented.
  • the disclosed method of the second aspect is also provided.
  • An advantageous 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 typeset the target text according to the character measurement data corresponding to the original font, so that Local applications can still maintain the consistency of document typesetting and original typesetting in the absence of original fonts.
  • FIG. 1 is a schematic diagram of a document processing system provided by an embodiment of the present disclosure
  • Fig. 2 is a method flowchart of a text typesetting method provided by an embodiment of the present disclosure
  • FIG. 3(a) and FIG. 3(b) are schematic diagrams of character measurement data provided by embodiments of the present disclosure.
  • Fig. 4 is an example diagram of a text typesetting method provided by an embodiment of the present disclosure.
  • FIG. 5 is a flow chart of a text typesetting method provided by an embodiment of the present disclosure.
  • FIG. 6 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present disclosure.
  • Fig. 7 is a schematic diagram of a hardware structure of a server according to an embodiment of the present disclosure.
  • Fig. 1 is a block diagram of a document processing system provided by an embodiment of this specification.
  • the document processing system includes a server 101 and a terminal device 103 , and the server 101 and the terminal device 103 can communicate through a network 102 .
  • the configuration of the server 101 may include, but 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, and the like.
  • the memory 1012 may include, but is not limited to, ROM (Read Only Memory), RAM (Random Access Memory), nonvolatile memory such as a hard disk, and the like.
  • the interface device 1013 may include, but not limited to, a USB interface, a serial interface, a parallel interface, and the like.
  • the communication device 1014 is capable of, for example, wired communication or wireless communication, which may specifically include WiFi communication, Bluetooth communication, 2G/3G/4G/5G communication, and the like.
  • the input device 1015 includes, but is not limited to, a keyboard, a mouse, a touch screen, a microphone, and the like.
  • the output device 1016 includes, but is not limited to, a display screen, a speaker, and the like.
  • the configuration of the server 101 may also include only some of the above-mentioned devices.
  • the terminal device 103 may be, for example, an electronic device installed with a smart operating system (such as Android, IOS, Windows, Linux, etc.), including but not limited to a portable computer, a desktop computer, a mobile phone, a tablet computer, and the like.
  • 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 camera 1030.
  • the processor 1031 includes, but is not limited to, a central processing unit CPU, a microprocessor MCU, and the like.
  • the memory 1032 includes, but is not limited to, ROM (Read Only Memory), RAM (Random Access Memory), nonvolatile memory such as a hard disk, and the like.
  • the interface device 1033 includes, but is not limited to, a USB interface, a serial interface, a parallel interface, and the like.
  • the communication device 1034 is capable of, for example, wired communication or wireless communication, which may specifically include WiFi communication, Bluetooth communication, 2G/3G/4G/5G communication, and the like.
  • GPU 1035 is used for image processing.
  • the display device 1036 includes, but is not limited to, a liquid crystal screen, a touch screen, and the like.
  • the input device 1037 includes, but is not limited to, a keyboard, a mouse, a touch screen, and the like.
  • the configuration of the terminal device 103 may also include only some of the above-mentioned devices.
  • the user can open the target text through the terminal device 103 and perform typesetting and editing on the target text.
  • the local application is, for example, document editing software, instant messaging software, office software, browser, and the like.
  • the user pre-registers an account on the local application, and the user can use the typesetting method provided by the embodiment of the present disclosure after logging into the account.
  • the local application is an application that can run on the terminal device, such as a native application, a web application, a hybrid application, a light application, and the like.
  • Native applications refer to applications that can run directly on the current operating system.
  • a web application refers to a web application that needs to be run in a browser.
  • a hybrid application can be a combination of a native application and a web application, usually a native application with an embedded browser.
  • a light application is an application that can be used without downloading and installing. Users can search and use it immediately or directly scan the code to use it.
  • FIG. 1 The document processing system shown in FIG. 1 is merely illustrative and in no way implies any limitation on the embodiments of the present description, their application or use.
  • a server may only involve a processor, a memory, and a communication device
  • a 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 solutions disclosed in the embodiments of this specification. How the instruction controls the processor to operate is a well-known technology in the art, so it will not be described in detail here.
  • 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.
  • Step S102 determining the original font used by the target text.
  • the target text may be any part of text in the document.
  • the terminal device obtains the original font information of the target text from the document, so as to determine the original font used by the target text.
  • the original font information can be stored in the document data of the document.
  • the font may include the font loaded in the operating system of the terminal device, the font loaded in the client (such as a browser or application terminal, etc.) of the terminal device, or the font stored in the server, or it may be Fonts carried in document files.
  • the document file can carry fonts, but the document files carrying fonts usually have a relatively large amount of data.
  • the fonts loaded in the operating system of the terminal device, the fonts loaded in the client of the terminal device, and the fonts carried in the document file all belong to the fonts that can be supported by the local application of the terminal device, and can be collectively referred to as local fonts.
  • the fonts stored in the server can be called server fonts or cloud fonts.
  • Step S104 determine whether the local application supports the original font.
  • the original font used by the target text 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, and if not, it is determined that the original font is not supported by the local application.
  • the fonts supported by a local application can be determined according to its installed font package. In an example, if the local application installs a font package of a certain font, it means that the local application supports the font. Generally speaking, the basic data package of the local application will have a variety of widely used font packages pre-installed and one of the fonts can be set as the default font. If the user wants to use some special fonts, you need to Download the corresponding font package separately. For example, if the original font is loaded in the operating system or the local application of the terminal device, or the original font is stored in the target text, it is considered that the local application supports the original font; otherwise, the local application does not support the original font.
  • Step S106 if the local application does not support the original font, acquire character measurement data of the original font.
  • characters referred to in the embodiments of the present disclosure include words and symbols, and symbols include but not limited to punctuation marks, numeral symbols, mathematical symbols, special symbols, etc., and words include but not limited to Chinese characters, letters, and the like.
  • the character measurement data of the font includes the height and width of the character.
  • the character measurement data of the original font includes the character width of the original font and the character height of the original font, which are the width and height of the characters in the target text in the state of the original font.
  • the sizes of different characters may be designed to be the same or different. If all the characters of the same font do not use the same size under the same font size, then establish a mapping relationship between the characters under the font size and the width and height of the characters. In this way, the mapping relationship can be used as the character measurement data of the corresponding font, and the width and height of each character at the corresponding font size can be found out according to the mapping relationship.
  • the character measurement data also includes a rise and fall value of the character.
  • Fig. 3(a) and Fig. 3(b) for the same Chinese character "Zao", two different fonts have different widths and heights, and different ascending and descending values under the same font size. Both the width and height of the font shown in Fig. 3(b) are smaller than that of Fig. 3(a).
  • the elevation value of the font shown in Fig. 3(a) is 0, that is, the font has no elevation relative to the baseline.
  • the elevation value of the font shown in Fig. 3(b) is a positive value, that is, the font has an elevation relative to the baseline. If the font's lift value is a negative value, it means that the font has a drop relative to the baseline.
  • the character measurement data may also include other features used to describe the position and/or size of the character, which is not limited herein.
  • the character measurement data of the font may be obtained by measuring the characters (eg, may specifically be image models of the characters).
  • the target text is displayed in a certain font in advance, and the character measurement data of the target text in the font is measured, so as to obtain the character measurement data of the font.
  • the server may pre-store character measurement data of various fonts and font sizes.
  • the terminal device obtains the character measurement data of the original font, which may be to query the character measurement data corresponding to the original font in a local cache of the terminal device.
  • the terminal device obtains the character measurement data of the original font, which may be: firstly query the character measurement data of the original font in the local cache of the terminal device, and if the character measurement data of the original font cannot be queried in the local cache to get character measurements for the original font from the server.
  • the terminal device can store it in the local cache, so that when the font needs to be used next time, it can directly read the font from the local cache Character measurement data for .
  • Step S108 displaying the target text in the first font supported by the local application and typesetting the target text according to the character measurement data of the original font.
  • the terminal device displays the target text in the 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.
  • the method may further include a step of confirming the first font.
  • the terminal device selects the first font that matches the original font from all the fonts supported by the local application. An example is given below:
  • Example 1 of determining the first font selecting the first font matching the original font from all the fonts supported by the local application may include steps S202-S206.
  • Step S202 obtaining a list of replacement fonts of the original font.
  • the matching degree between other 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.
  • the matching degree between two fonts may be determined according to the character measurement data of the two fonts.
  • a replacement font list can be established according to its replacement font, and the replacement fonts in the replacement font list are sorted according to the matching degree from high to low.
  • the terminal device can obtain the replacement font list of each font from the server.
  • font A is an example to illustrate how to determine the matching degree between font B and font A:
  • the character C may be a single character, or a string composed of multiple characters.
  • the matching degree between font B and font A is determined according to the absolute value of the first difference, wherein the greater the absolute value of the first difference, the lower the matching degree between font B and font A, and the first difference The smaller the absolute value of , the higher the match between font B and font A.
  • the matching degree between font B and font A is determined according to the absolute value of the second difference, wherein the greater the absolute value of the second difference, the lower the matching degree between font B and font A, and the second difference The smaller the absolute value of , the higher the match between font B and font A.
  • the sum of the absolute value of the first difference and the absolute value of the second difference is calculated, and the matching degree between font B and font A is determined according to the sum, wherein the larger the sum, the greater the sum of font B and font A.
  • Step S204 determining candidate fonts from the replacement fonts in the replacement font list, where the candidate fonts are fonts supported by the local application.
  • Step S206 determining the candidate font with the highest matching degree with the original font as the first font.
  • the candidate fonts supported by the local application are screened out from the substitute fonts in the substitute font list, and then the candidate font that best matches the original font is selected from the candidate fonts supported by the local application (for example, in the aforementioned
  • the top candidate font in the replacement font list sorted from high to low) is used as the first font.
  • Using the candidate fonts supported by the local application in the replacement font list to determine the first font does not require the terminal device to perform complicated calculations, which is more convenient and faster.
  • Example 2 of determining the first font selecting the first font matching the original font from all fonts supported by the local application may include steps S302-S304.
  • Step S302 determining the character type of the target text.
  • the character types include the first type and the second type.
  • the first type means that the characters of the target text are square characters such as Chinese characters, and the width and height of different Chinese characters are basically the same.
  • the second type refers to that the characters of the target text include letters, Roman characters, Mongolian, or Arabic characters or a mixture of multiple languages, and the width and height of these characters may be inconsistent.
  • Step S304 according to the preset rule associated with the character type of the target text, select the first font matching the original font from all the fonts supported by the local application.
  • the first font is determined according to a rule corresponding to the character type of the target text.
  • the following uses examples 3, 4, 5 and 6 to illustrate.
  • Example 3 of determining the first font selecting the first font matching the original font from all fonts supported by the local application may include steps S402-S406.
  • Step S402. Obtain character measurement data of a candidate font, where the candidate font is a font supported by the local application.
  • Step S404 determining the typesetting direction of the target text.
  • Step S406 if the typesetting direction of the target text is horizontal typesetting, determine the candidate font whose character width is closest to that of the original font as the first font.
  • the typesetting direction of the target text is vertical typesetting, the candidate font whose character height is closest to that of the original font is determined as the first font.
  • the typesetting direction of the target text is horizontal typesetting, calculate the difference between the character width of the characters in the target text under the original font and the character width under the candidate font as the first difference, the absolute value of the first difference The smaller the value, the closer the character width of the candidate font is to the character width of the original font, and the candidate font with the smallest absolute value of the first difference is selected as the first font.
  • the typesetting direction of the target text is vertical typesetting
  • Example 3 is applicable to the case where the character type of the target text is the first type and/or the second type. That is to say, if the target text contains only Chinese characters, or if the target text contains letters and Roman characters, the method of Example 3 can be applied to determine the first font.
  • Example 4 of determining the first font selecting the first font matching the original font from all the fonts supported by the local application may include steps S502-S508.
  • Step S502 acquiring font attributes of the original font and font attributes of the candidate font, where the candidate font is a font supported by the local application.
  • the font properties of a font refer to the inherent properties of the font itself, which can reflect the style of the font.
  • the font properties of the font may include one or more of font thickness, blackening, and slant.
  • the blackening degree of the font includes two attribute values of “with blackening” and “without blackening”.
  • two attribute values including “with tilt” and “without tilt” are included.
  • the font attributes of “Song Type” are: the thickness is “thin”, the blackening level is “no blackening”, The inclination degree is “no inclination”; the font properties of “Chinese thin black” are: the thickness is “thin”, the blackening degree is “increased black”, and the inclination degree is “no inclination”; The font properties are: the thickness is “thick”, the blackening is “blackening”, and the inclination is “no inclination”.
  • the font properties of “Times New Roman” are: Thickness is “Thin”, Blackening is “No Blackening”, Slant is “No Slant” ";
  • the font properties of "Forte” are: the thickness is “thick”, the blackening is “blackening”, and the inclination is “slanting”.
  • Step S504 determining a candidate font whose font attribute is the same as that of the original font as the target font, and obtaining character measurement data of the target font.
  • the font properties of the 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 candidate font and the original font are considered properties are the same.
  • the font properties of a font include font thickness, blackening, and slant. If the candidate font and the original font have the same attribute values in the three aspects of thickness, blackening, and slant, the candidate font is considered to be The attributes of the candidate font and the original font are the same.
  • Step S506 determining the typesetting direction of the target text.
  • Step S508 if the typesetting direction of the target text is horizontal typesetting, determine the target font whose character width is closest to that of the original font as the first font.
  • the typesetting direction of the target text is vertical typesetting, the target font whose character height is closest to that of the original font is determined as the first font.
  • step S508 may be similar to the aforementioned step S406, and will not be described in detail here.
  • Example 4 is applicable to the case where the character type of the target text is the first type and/or the second type. That is to say, if the target text contains only Chinese characters, or if the target text contains letters and Roman characters, the method of Example 4 can be applied to determine the first font.
  • the candidate fonts whose font attributes are different from those of the original font are filtered out, and the candidate fonts whose font attributes are the same as those of the original font are reserved as the target fonts, and based on the characters of the original font
  • the measurement data confirms the first font in the target font, so that the style of the selected first font is basically consistent with the style of the original font, so that the target text displayed with the first font supported by the local application is consistent with the original font
  • the rendering style of the target text is more similar.
  • Example 5 of determining the first font, according to the preset rules associated with the character type of the target text, select the first font that matches the original font from all the fonts supported by the local application which may be: the terminal device selects the candidate font The font ID of the font is sent 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 character string under the original font; then, the server sends the font ID of the first font to the terminal For the device, the terminal device receives the font identifier of the first font from the server.
  • the font identifier may be a name or number used to identify the font.
  • the server obtains the font attribute of the original font and the width of the preset character string under the original font, and determines 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.
  • the candidate font is a font supported by the local application
  • the preset character string includes a plurality of different preset characters.
  • the preset characters in the preset character string should be representative characters in either of character width or character height. For example, select any Chinese character and "w”, “z”, and “i” with representative widths in English to form a preset string, where "w", "z", and “i” represent three different widths English characters, the preset character string can be " ⁇ WwZzIi".
  • Examples 5 and 6 are applicable to the case where the character type of the target text is the second type. That is to say, in the case that the target text includes characters such as letters, Roman characters, Mongolian, or Arabic, or is a mixture of multiple languages, the methods of Examples 5 and 6 can be applied to determine the first font. For example, when the character type of the target text is alphabetic or multilingual (for example, the target text contains both Chinese content and English content, or the target text contains both Chinese content and Japanese content), Example 5 can be applied 6. The way to determine the first font. Determining the first font based on the width of the preset character string is suitable for the case where different characters have different character widths, and the amount of calculation is small, which is more efficient and faster.
  • candidate fonts include default fonts and non-default fonts supported by the native application. Default fonts are preset for local applications, and the default fonts will be set when the terminal device installs the application. Users can modify the default fonts according to their personal preferences.
  • Determining 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 may include steps S602-S604.
  • Step S602 if the font attributes of the default font supported by the local application and the original font are the same, and the width of the preset character string under the default font and the width of the preset character string under the original font are similar to the preset standard, the default The font is determined as the first font. Otherwise, execute step S604.
  • determining whether the similarity 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 may include steps S6022-S6026.
  • 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 as the fourth difference.
  • Step S6024 Determine the ratio of the absolute value of the fourth difference to the width of the preset character string in the original font as the first ratio.
  • Step S6026 if the first ratio is less than or equal to the preset first threshold, determine that the similarity 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 first ratio is greater than the preset first threshold, it is determined that the similarity 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.
  • the width and height of the preset character string under the default font and the width and height of the preset character string under the original font are similar to the preset standard, which may include: the preset character string under the default font
  • the ratio of the width of the character string to the width of the preset character string under the original font is between 0.95 and 1.05, that is, the first ratio is between 0 and 0.05.
  • Step S604 using candidate fonts having the same font attributes as the original fonts as target fonts, and determining a first font from the target fonts.
  • step S604 among all candidate fonts (including default fonts and non-default fonts), select a candidate font with the same font attribute as the original font as the target font,
  • the typesetting of the target text presented to the user by the local application is similar to the original typesetting of the target text, and only fine-tuning is required during typesetting.
  • the default font is given priority as the first font to replace the original font.
  • the font properties of the default font and the original font are not the same, or the width of the preset character string under the default font is not similar to the width of the preset character string under the original font, it does not meet the preset standard, then from the original font
  • the first font is determined among the candidate fonts whose font attributes are the same. In this way, the preference of the user is taken into account, and the amount of computation is reduced, and the processing time is saved.
  • the implementation methods of determining the degree of similarity and matching between the candidate font, the target font and the original font can also be applied to determining the replacement font in the replacement font list.
  • step S108 the terminal device displays the target text in the 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.
  • Typesetting example 1 first determine the typesetting direction of the target text, and typesetting the target text displayed on the terminal device in the first font according to the typesetting direction of the target text.
  • the typesetting direction of the target text is horizontal typesetting
  • the first scaling process is performed on the characters of the target text so that the character width of the target text is consistent with the character width of the original font.
  • the second scaling process is performed on the characters of the target text so that the character height of the target text is consistent with the character height of the original font.
  • Example 1 the scaling of characters can be achieved by adjusting the font size.
  • step S108 typesetting the target text displayed on the terminal device according to the character measurement data corresponding to the original font may be: acquiring the character measurement data corresponding to the first font, and measuring the text according to the character measurement data corresponding to the original font The data and the character measurement data corresponding to the first font typesetting the target text displayed on the terminal device.
  • Typesetting example 2 firstly determine the typesetting direction of the target text, and typesetting the target text displayed on the terminal device in the first font according to the typesetting direction of the target text.
  • the typesetting direction of the target text is horizontal typesetting, 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. In the case that the first difference is a positive value, the abscissa value of the character of the target text is adjusted. If the first difference is a negative value, the characters of the target text are reduced.
  • the typesetting direction of the target text is vertical typesetting, a second difference is determined, and the second difference is the difference between the character height of the original font and the character height of the first font. If the second difference is a positive value, the ordinate value of the character of the target text is adjusted. If the second difference is a negative value, the characters of the target text are reduced.
  • the reduction of characters can be realized by adjusting the font size.
  • the character width of each character in the original font is about W1.
  • the character width of each character in the first font is about W2.
  • the first difference 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 abscissa of each character of the target text in the first font needs to be adjusted.
  • the target text is a line of content, including 10 characters of "good morning, today's weather is really nice".
  • the coordinate values of the abscissa of 10 characters are X 1 , X 2 ,...,X 10
  • the coordinate values of the abscissa of 10 characters are X 1 ', X 2 ',...,X 10 ', then:
  • n is an integer, 1 ⁇ n ⁇ 10.
  • adjusting the coordinate value of the abscissa 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.
  • the terminal device needs to be reduced to The font size of the target text displayed in the first font.
  • the font size described herein is a dot system, which is a method of measuring printed fonts well known to those skilled in the art, such as 5 points, 12 points, etc.
  • the character height of each character in the original font is H1.
  • the character height of each character in the first font is H2.
  • Calculate the difference DH ( H1 ⁇ H2) between H1 and H2 as the second difference.
  • the second difference 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 under the first font is adjusted.
  • the ordinate values of the characters in each line are the same, and the ordinate values of the characters from the first line to the Mth line are Y 1 , Y 2 ,...,Y M , after typesetting, the ordinate values of the characters from line 1 to line M are respectively Y 1 ', Y 2 ',...,Y M ', then:
  • n is an integer, 1 ⁇ m ⁇ M.
  • 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.
  • the terminal device needs to be reduced to The font size of the target text displayed in the first font.
  • Typesetting example 3 first determine the typesetting direction of the target text, and typesetting the target text displayed on the terminal device in the first font according to the typesetting direction of the target text.
  • the typesetting direction of the target text is horizontal typesetting, adjust the font size of the target text 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; determine the first difference value, the first difference The value is the difference between the character width of the original font and the character width of the first font; if the first difference is a positive value, adjust the abscissa value of the character of the target text; if the first difference is a negative value Next, shrink the characters of the target text.
  • the font size of the target text is adjusted to the second font size, and the second font size is the font size whose character height is the closest to the character height of the original font; determine the second difference, the second The difference is the difference between the character height of the original font and the character height of the first font; if the second difference is positive, adjust the ordinate value of the character of the target text; if the second difference is negative In the case, the characters of the target text are reduced.
  • 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 greater than the character width under the original font, then Decrease the font size by one to make the characters smaller and avoid characters overlapping each other.
  • the terminal device adjusts the font size of the target text in the first font to the second font size, if the character height is still greater than the character height in the original font, then Decrease the font size by one to make the characters smaller and avoid characters overlapping each other.
  • the reduction of characters can be realized by adjusting the font size.
  • the typesetting of the displayed target text is closer to the typesetting of the target text displayed in the original font.
  • the original font is compared with the first font, and the total width of this content under the original font is wider.
  • the total width of the content displayed by the terminal device using the first font is closer to the total width of the content in the original font. In this way, it can be ensured that the content of the same line under the original font will not be divided into lines because it is displayed in the first font.
  • Typesetting example 4 Typesetting the target text according to the character measurement data of the original font may include steps S1085-S1087.
  • Step S1085 segment the target text into words.
  • Step S1086 accumulating the difference between the width of each character in the word in the first font and the width in the original font to obtain an adjustment amount.
  • Step S1087 calculating the ratio of the adjustment amount to the number of character gaps in the word as a second ratio, and adjusting the gaps between characters in the word according to the second ratio so that the gaps between characters in the word are the same.
  • the difference between the width of each character under the first font and the width under the original font is O 1 , O 2 ,...,O T in turn, and the accumulation is O 1 , O 2 ,...,O T.
  • the adjustment amount is obtained, and the second ratio between the adjustment amount and the number of character gaps is calculated. If the second ratio is a positive value, it means that the adjustment amount is a positive value and the gap between the characters in the word should be reduced, then the gap between the characters in the word is subtracted from the second ratio.
  • the second ratio is a negative value, it means that the adjustment amount is a negative value and should increase the gap between the characters in the word, then the gap between the characters in the word is subtracted from the second ratio, that is, the absolute value of the second ratio is added. value.
  • the fourth typesetting example can be performed after any of the above-mentioned typesetting examples.
  • the local application first typesets the width and height of the characters of the target text, and then adjusts the height and height values of the characters of the target text according to the character height and height values corresponding to the original font.
  • An advantageous 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 text, the local application uses the first font it supports to display the target text and typeset the target text according to the character measurement data of the original font , so that the local application can still maintain the consistency of the document typesetting and the original typesetting in the case of missing the original font.
  • the embodiment of the present disclosure provides a text typesetting method.
  • the method includes steps S702-S706. Steps S702-S706 can be implemented by the server.
  • Step S702 receiving the font identifier of the original font of the target text sent by the terminal device.
  • Step S704 query the character measurement data of the original font according to the font identifier of the original font.
  • Step S706 sending the character measurement data of the original font to the terminal device, so that the terminal device can typesetting the target text displayed in the first font supported by its local application according to the character measurement data of the original font.
  • font attributes of various fonts and character measurement data of various fonts at various font sizes are pre-stored in the server.
  • Character measurements for a font may include the height and width of the characters.
  • a font's character measurements may also include a character's rise and fall values.
  • the font properties of a font refer to the inherent properties of the font itself, which can reflect the style of the font.
  • the font attributes of the font may include one or more of font thickness, blackening, and slant.
  • the method before the terminal device displays the target text in the first font supported by its local application, the method further includes: obtaining a replacement font list of the original font according to the font identifier of the original font.
  • a candidate font is determined from the replacement fonts in the replacement font list, where the candidate font is a font supported by a local application of the terminal device.
  • the candidate font that best matches the original font in the replacement font list is determined as the first font.
  • the method before the terminal device displays the target text in the first font supported by its local application, the method further includes: sending the font attribute of the original font and the width of the preset character string under the original font to the terminal device, to For the terminal device to 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 a local application of the terminal device
  • the preset character string includes a plurality of different preset characters.
  • the method before the terminal device displays the target text with the first font supported by its local application, the method further includes: determining 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 A font, sending the font identifier of the first font to the terminal device.
  • the candidate font is a font supported by a local application of the terminal device
  • the preset character string includes a plurality of different preset characters.
  • candidate fonts include default fonts and non-default fonts supported by the native application.
  • 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 preset character string under the default font It is assumed that the width of the character string is similar to the width of the preset character string under the original font to meet the preset standard, and the default font is determined as the first font. Otherwise, a candidate font having the same font attribute as the original font is used as the target font, and the first font is determined from the target font.
  • determining whether the similarity 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 includes: determining that the width of the preset character string under the default font is the same as The difference between the widths of the preset character strings in the original font is used as the fourth difference. A ratio of the absolute value of the fourth difference to the width of the preset character string in the original font is determined as the first ratio. In the case that the first ratio is less than or equal to the preset first threshold, it is determined that the width of the preset character string in the default font is similar to the width of the preset character string in the original font conforming to the preset standard. If the first ratio is greater than the preset first threshold, it is determined that the similarity 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.
  • determining the first font from the target fonts includes: determining the target font whose width is the closest to the original font as the first font; The target font is determined as the first font.
  • An advantageous 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 text, the server provides the character measurement data of the original font to the terminal device, so that the terminal device can use the character measurement data corresponding to the original font Typesetting the target text displayed in the first font supported by the local application, so that the local application can still maintain the consistency between the document typesetting and the original typesetting when the original font is missing.
  • An embodiment of the present disclosure provides a text typesetting device, including the following modules:
  • the first determining module is configured to determine the original font used by the target text.
  • the second determining module is used for determining whether the local application supports the original font.
  • the obtaining module is used to obtain the character measurement data of the original font when the local application does not support the original font.
  • a typesetting module configured to typeset the target text displayed in the first font supported by the local application of the terminal device according to the character measurement data of the original font.
  • obtaining the character measurement data of the original font includes any of the following: querying the character measurement data of the original font in the local cache of the terminal device; querying the character measurement data of the original font in the local cache of the terminal device In the case of character measurement data, the character measurement data of the original font is obtained from the server and stored in the local cache.
  • the method further includes: selecting a first font matching the original font from all fonts supported by the local application; using the selected first font A font displays the target text.
  • selecting a first font matching the original font from all fonts supported by the local application includes: obtaining a list of replacement fonts for the original font.
  • a candidate font is determined from the replacement fonts in the replacement font list, and the candidate font is a font supported by the local application. Determining the candidate font with the highest matching degree with the original font as the first font.
  • displaying the target text in the first font supported by the local application includes: determining a character type of the target text. Selecting a first font matching the original font from all fonts supported by the local application according to preset rules associated with the character type of the target text; displaying the target text with the selected first font .
  • the original font's character measurement data includes the original font's character width and the original font's character height.
  • Selecting the first font that matches the original font from all the fonts supported by the local application includes: acquiring character measurement data of the candidate font, where the candidate font is a font supported by the local application. Determines the typesetting direction of the target text. When the typesetting direction of the target text is horizontal typesetting, the candidate font whose character width is closest to that 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 that of the original font is determined as the first font.
  • the original font's character measurement data includes the original font's character width and the original font's character height.
  • Selecting the first font that matches the original font from all the fonts supported by the local application includes: acquiring font attributes of the original font and font attributes of the candidate font, where the candidate font is a font supported by the local application.
  • a candidate font whose font attribute is the same as that of the original font is determined as the target font, and character measurement data of the target font is obtained.
  • the typesetting direction of the target text is horizontal typesetting
  • the target font whose character width is closest to that of the original font is determined as the first font.
  • the typesetting direction of the target text is vertical typesetting, the target font whose character height is closest to that of the original font is determined as the first font.
  • the first font that matches the original font is selected from all fonts supported by the local application.
  • a font including: sending the font identification of the candidate font to the server, so that the server 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, and receive the first font from the server The font ID of the font. Or, acquire the font attribute 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 attribute 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
  • the preset character string includes a plurality of different preset characters.
  • candidate fonts include default fonts and non-default fonts supported by the native application.
  • determining whether the similarity 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 includes: determining that the width of the preset character string under the default font is the same as The difference between the widths of the preset character strings in the original font is used as the fourth difference. A ratio of the absolute value of the fourth difference to the width of the preset character string in the original font is determined as the first ratio. In the case that the first ratio is less than or equal to the preset first threshold, it is determined that the width of the preset character string in the default font is similar to the width of the preset character string in the original font conforming to the preset standard.
  • determining the first font from the target fonts includes: determining the target font whose width is the closest to the original font as the first font; The target font is determined as the first font.
  • the original font's character measurement data includes the original font's character width and the original font's character height.
  • Typesetting the target text according to the character measurement data of the original font including: determining the typesetting direction of the target text.
  • the typesetting direction of the target text is horizontal typesetting
  • determine the first difference the first difference is the difference between the character width of the character of the target text under the original font and the character width under the first font value; if the first difference is a positive value, adjust the abscissa value of the character of the target text displayed in the first font. If the first difference is a negative value, the characters of the target text displayed in the first font are reduced.
  • the typesetting direction of the target text is vertical typesetting
  • determine the second difference the second difference being the character height of the characters of the target text under the original font and the character height under the first font difference. If the second difference is a positive value, adjust the ordinate value of the character of the target text displayed in the first font. If the second difference is a negative value, the characters of the target text displayed in the first font are reduced.
  • the original font's character measurement data includes the original font's character width.
  • Typesetting the target text according to the character measurement data of the original font including: segmenting the target text into words. The difference between the width of each character in the word under the first font and the width under the original font is added to obtain an adjustment amount. The ratio of the adjustment amount to the number of character gaps in the word is calculated as a second ratio, and the gaps between characters in the word are adjusted according to the second ratio so that the gaps between characters in the word are the same.
  • An embodiment of the present disclosure provides a text typesetting device, including the following modules:
  • the receiving module is configured to receive the font identification of the original font of the target text sent by the terminal device.
  • the query module is used to query the character measurement data of the original font according to the font identifier of the original font.
  • a sending module configured to send the character measurement data of the original font to the terminal device, so that the terminal device typeset the target text displayed in the first font supported by the local application of the terminal device according to the character measurement data of the original font .
  • displaying the target text in the first font supported by the local application on the terminal device includes: obtaining a replacement font list of the original font according to the font identifier of the original font.
  • a candidate font is determined from the replacement fonts in the replacement font list, and the candidate font is a font supported by the local application.
  • the candidate font ranked first in the replacement font list is determined as the first font.
  • 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 The width of the character string determines the first font from the candidate fonts. Or, 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 send the font identifier of the first font to the terminal device.
  • the candidate font is a font supported by the local application
  • the preset character string includes a plurality of different preset characters.
  • candidate fonts include default fonts and non-default fonts supported by the native application.
  • determining whether the similarity 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 includes: determining that the width of the preset character string under the default font is the same as The difference between the widths of the preset character strings in the original font is used as the fourth difference. A ratio of the absolute value of the fourth difference to the width of the preset character string in the original font is determined as the first ratio. In the case that the first ratio is less than or equal to the preset first threshold, it is determined that the width of the preset character string in the default font is similar to the width of the preset character string in the original font conforming to the preset standard.
  • determining the first font from the target fonts includes: determining the target font closest to the width of the preset character string and the original font as the first font. Alternatively, the target font with the smallest width of the preset character string is determined as the first font.
  • Fig. 6 is a schematic diagram of a hardware structure of an electronic device according to an embodiment.
  • the electronic device 800 includes a processor 801 and a memory 802, the memory 802 is used to store an executable computer program, and the processor 801 is used to execute the computer program, so as to implement any of the above method embodiments.
  • the typesetting method of the text is used to implement any of the above method embodiments.
  • the electronic device 800 may be a computer, a mobile phone, a tablet computer and other devices.
  • the electronic device is the aforementioned terminal device.
  • Fig. 7 is a schematic diagram of a hardware structure of a server according to an embodiment.
  • the server 900 includes a processor 901 and a memory 902, the memory 902 is used to store an executable computer program, and the processor 901 is used to execute the computer program to realize the text of any of the above method embodiments typesetting method.
  • An embodiment of the present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the text typesetting method according to any of the above method embodiments is implemented.
  • the present disclosure can be a system, method and/or computer program product.
  • a computer program product may include a computer readable storage medium having computer readable program instructions thereon for causing a processor to implement various aspects of the present disclosure.
  • a computer readable storage medium may be a tangible device that can retain and store instructions for use by an instruction execution device.
  • a computer readable storage medium may be, for example, but is not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing.
  • Computer-readable storage media include: portable computer diskettes, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), or flash memory), static random access memory (SRAM), compact disc read only memory (CD-ROM), digital versatile disc (DVD), memory stick, floppy disk, mechanically encoded device, such as a printer with instructions stored thereon A hole card or a raised structure in a groove, and any suitable combination of the above.
  • RAM random access memory
  • ROM read-only memory
  • EPROM erasable programmable read-only memory
  • flash memory static random access memory
  • SRAM static random access memory
  • CD-ROM compact disc read only memory
  • DVD digital versatile disc
  • memory stick floppy disk
  • mechanically encoded device such as a printer with instructions stored thereon
  • a hole card or a raised structure in a groove and any suitable combination of the above.
  • computer-readable storage media are not to be construed as transient signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., pulses of light through fiber optic cables), or transmitted electrical signals.
  • the computer-readable program instructions described herein may be downloaded from a computer-readable storage medium to a respective computing/processing device, or downloaded to an external computer or external storage device over a network, such as the Internet, a local area network, a wide area network, and/or a wireless network.
  • the network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and/or edge servers.
  • a network adapter card or a network interface in each computing/processing device receives computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in a computer-readable storage medium in each computing/processing device .
  • Computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or Source or object code written in any combination, including object-oriented programming languages—such as Smalltalk, C++, etc., and conventional procedural programming languages—such as the “C” language or similar programming languages.
  • Computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server implement.
  • the remote computer can be connected to the user computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (such as via the Internet using an Internet service provider). connect).
  • LAN local area network
  • WAN wide area network
  • an electronic circuit such as a programmable logic circuit, field programmable gate array (FPGA), or programmable logic array (PLA)
  • FPGA field programmable gate array
  • PDA programmable logic array
  • These computer-readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine such that when executed by the processor of the computer or other programmable data processing apparatus , producing an apparatus for realizing the functions/actions specified in one or more blocks in the flowchart and/or block diagram.
  • These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause computers, programmable data processing devices and/or other devices to work in a specific way, so that the computer-readable medium storing instructions includes An article of manufacture comprising instructions for implementing various aspects of the functions/acts specified in one or more blocks in flowcharts and/or block diagrams.
  • each block in a flowchart or block diagram may represent a module, a portion of a program segment, or an instruction that includes one or more Executable instructions.
  • the functions noted in the block may occur out of the order noted in the figures. For example, two blocks in succession may, in fact, be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved.
  • each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations can be implemented by a dedicated hardware-based system that performs the specified function or action , or may be implemented by a combination of dedicated hardware and computer instructions. It is well known to those skilled in the art that implementation by means of hardware, implementation by means of software, and implementation by a combination of software and hardware are all equivalent.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Document Processing Apparatus (AREA)
  • Controls And Circuits For Display Device (AREA)

Abstract

本公开涉及用于文本的排版的方法、装置、电子设备、服务器及计算可读存储介质,涉及计算机技术领域。根据该方法的一个示例,当该方法应用于运行于终端设备的本地应用时,可包括:确定目标文本使用的原始字体;确定本地应用是否支持原始字体;在本地应用不支持原始字体的情况下,获取原始字体的字符测量数据;以本地应用支持的第一字体显示目标文本;并根据原始字体的字符测量数据对所显示目标文本进行排版。

Description

文本的排版 技术领域
本公开涉及计算机技术领域,更具体地,涉及用于文本的排版的方法和装置、电子设备及存储介质。
背景技术
在终端设备使用本地应用打开文档时,如果缺失文档的原始字体可能会导致该文档呈现出的排版方式与原始排版存在较大的差异,影响文档的美观和阅读体验。目前一般采用的做法是在当前环境下安装所缺失的字体。但这种方法需要搜索、下载、安装字体,并且字体可能还需要单独付费,比较难进行大面积推广和应用。因此,有必要提出一种新的文本的排版方法。
发明内容
本公开实施例的一个目的是提供一种文本排版的新的技术方案,以在缺失字体的情况下保持文档排版和原始排版的一致性。
根据本公开的第一方面,提供了一种文本的排版方法。所述方法包括:确定目标文本使用的原始字体;确定本地应用是否支持所述原始字体;在所述本地应用不支持所述原始字体的情况下,获取所述原始字体的字符测量数据;以所述本地应用支持的第一字体显示所述目标文本;并根据所述原始字体的字符测量数据对显示的所述目标文本进行排版。
根据本公开的第二方面,提供了一种文本的排版方法。所述方法包括:接收终端设备发送的目标文本的原始字体的字体标识;根据所述原始字体的字体标识查询出所述原始字体的字符测量数据;将所述原始字体的字符测量数据发送给终端设备,以供所述终端设备根据所述原始字体的字符测量数据对以所述终端设备的本地应用支持的第一字体显示的所述目标文本进行排版。
根据本公开的第三方面,提供了一种文本的排版装置。所述装置包括:第一确定模块,用于确定目标文本使用的原始字体;第二确定模块,用于确定本地应用是否支持所述原始字体;获取模块,用于在所述本地应用不支持所述原始字体的情况下,获取所述原始字体的字符测量数据;排版模块,用于根据所述原始字体的字符测量数据对以所述终端设备的本地应用支持的第一字体显示的所述目标文本进行排版。
根据本公开的第四方面,提供了一种文本的排版装置。所述装置包括:接收模块,用于接收终端设备发送的目标文本的原始字体的字体标识;查询模块,用于根据所述原始字体的字体标识查询出所述原始字体的字符测量数据;发送模块,用于将所述原始字体的字符测量数据发送给终端设备,以供终端设备以其本地应用支持的第一字体显示所述目标文本并根据所述原始字体的字符测量数据对所述目标文本进行排版。
根据本公开的第五方面,还提供了一种电子设备,包括存储器和处理器。其中,存储器用于存储计算机程序;处理器用于执行计算机程序,以实现根据本公开第一方面或第二方面的方法。
根据本公开的第六方面,还提供了一种计算机可读存储介质,计算机可读存储介质上存储计算机程序,计算机程序在被处理器执行时实现根据本公开的第一方面的方法或者实现本公开的第二方面的方法。
本公开实施例的一个有益效果在于,如果本地应用不支持目标文档的原始字体,本地应用使用其支持的第一字体来显示目标文本并且根据原始字体对应的字符测量数据对目标文本进行排版,使得本地应用在缺失原始字体的情况下仍然可以保持 文档排版和原始排版的一致性。
通过以下参照附图对本公开的示例性实施例的详细描述,本公开实施例的其它特征及其优点将会变得清楚。
附图说明
被结合在说明书中并构成说明书的一部分的附图示出了本公开的实施例,并且连同其说明一起用于解释本公开实施例的原理。
图1为本公开实施例提供的文档处理系统的示意图;
图2为本公开实施例提供的文本的排版方法的方法流程图;
图3(a)和图3(b)为本公开实施例提供的字符测量数据的示意图;
图4是本公开实施例提供的文本的排版方法的示例图;
图5为本公开实施例提供的文本的排版方法的方法流程图;
图6是根据本公开实施例的电子设备的硬件结构示意图;
图7是根据本公开实施例的服务器的硬件结构示意图。
具体实施方式
现在将参照附图来详细描述本公开的各种示例性实施例。应注意到:除非另外具体说明,否则在这些实施例中阐述的部件和步骤的相对布置、数字表达式和数值不限制本公开的范围。
以下对至少一个示例性实施例的描述实际上仅仅是说明性的,不应作为对本公开及其应用或使用的任何限制。
对于相关领域普通技术人员已知的技术、方法和设备可能不作详细讨论,但在适当情况下,所述技术、方法和设备应当被视为说明书的一部分。
在这里示出和讨论的所有例子中,任何具体值应被解释为仅仅是示例性的,而不是作为限制。因此,示例性实施例的其它例子可以具有不同的值。
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步讨论。
<文本的排版方法>
图1是本说明书实施例提供的文档处理系统的框图。如图1所示,该文档处理系统包括服务器101和终端设备103,服务器101和终端设备103之间可以通过网络102进行通信。
服务器101的配置可以包括但不限于处理器1011、存储器1012、接口装置1013、通信装置1014、输入装置1015、输出装置1016。处理器1011可以包括但不限于中央处理器CPU、微处理器MCU等。存储器1012可以包括但不限于ROM(只读存储器)、RAM(随机存取存储器)、诸如硬盘的非易失性存储器等。接口装置1013可以包括但不限于USB接口、串行接口、并行接口等。通信装置1014例如能够进行有线通信或无线通信,具体地可以包括WiFi通信、蓝牙通信、2G/3G/4G/5G通信等。输入装置1015包括但不限于键盘、鼠标、触摸屏、麦克风等。输出装置1016包括但不限于显示屏、扬声器等。服务器101的配置也可以仅包括上述装置中的部分装置。
终端设备103例如可以是安装有智能操作系统(例如安卓、IOS、Windows、Linux等)的电子设备,包括但不限于便携式电脑、台式计算机、手机、平板电脑等。终端设备103的配置包括但不限于处理器1031、存储器1032、接口装置1033、通信装置1034、GPU(Graphics Processing Unit,图像处理器)1035、显示装置1036、输入装置1037、扬声器1038、麦克风1039、以及相机1030。处理器1031包括但不限于中央处理器CPU、微处理器MCU等。存储器1032包括但不限于ROM(只读存储器)、RAM(随机存取存储器)、诸如硬盘的非易失性存储器等。接口装置 1033包括但不限于USB接口、串行接口、并行接口等。通信装置1034例如能够进行有线通信或无线通信,具体地可以包括WiFi通信、蓝牙通信、2G/3G/4G/5G通信等。GPU 1035用于对图像进行处理。显示装置1036包括但不限于液晶屏、触摸屏等。输入装置1037包括但不限于键盘、鼠标、触摸屏等。终端设备103的配置也可以仅包括上述装置中的部分装置。
应用于本公开的一个实施例中,用户可以通过终端设备103打开目标文本以及对目标文本进行排版、编辑。该本地应用例如为文档编辑软件、即时通信软件、办公软件、浏览器等。在一个例子中,用户在本地应用上预先注册账户,用户登录账户后就可以使用本公开实施例提供的排版方法。
在一个例子中,该本地应用为在终端设备上可以运行的应用,例如可以是原生应用、Web应用、混合应用、轻应用等。原生应用指的是能直接运行于当前操作系统的应用程序。Web应用指需要在浏览器中运行的网页应用。混合应用则可以是原生应用和Web应用的结合,通常是一个原生应用内嵌了浏览器。轻应用是一种不需要下载安装即可使用的应用程序,用户可以即搜即用或者直接扫码使用。
图1所示的文档处理系统仅仅是说明性的并且绝不意味着对本说明书实施例、其应用或使用的任何限制。本领域技术人员应当理解,尽管前面描述了服务器和终端设备的多个装置,但是,本说明书实施例可以仅涉及其中的部分装置。例如,服务器可以只涉及处理器、存储器以及通信装置,终端设备可以只涉及处理器、存储器、通信装置、输入装置、显示屏。本领域技术人员可以根据本说明书实施例所公开的方案设计指令。指令如何控制处理器进行操作,是本领域公知技术,故在此不再详细描述。
参见图2所示,本公开实施例提供了一种文本的排版方法。该方法包括步骤S102-S108。步骤S102-S108可以由终端设备实施。
步骤S102、确定目标文本使用的原始字体。
在本公开实施例中,目标文本可以是文档中的任一部分文本。在一个例子中,终端设备从文档中获取目标文本的原始字体信息,从而确定目标文本使用的原始字体。一般情况,该原始字体信息可以存储在文档的文档数据中。
在本公开实施例中,字体可以包括加载在终端设备的操作系统中的字体、加载在终端设备的客户端(例如浏览器或应用端等)中的字体或服务器中存储的字体,也可以是文档文件中携带的字体。其中,文档文件可以携带字体,但携带字体的文档文件通常具有比较大的数据量。此外,加载在终端设备的操作系统中的字体、加载在终端设备的客户端中的字体和文档文件携带的字体,都属于终端设备的本地应用能够支持的字体,可统称为本地字体。而存储在服务器中的字体,可被称为服务器字体或云字体。
步骤S104、确定本地应用是否支持原始字体。
在确定目标文本使用的原始字体后,检查本地应用支持的全部字体中是否包括该原始字体,如果不包括,则确定本地应用不支持该原始字体。
本地应用支持的字体可以根据其安装的字体包确定。在一个例子中,如果本地应用安装了某种字体的字体包,说明本地应用支持该字体。通常来说,本地应用的基础数据包中会预先安装有多种大众广为使用的字体包并且可以将其中一种字体设置为默认字体,如果用户想要使用一些小众特别的字体,则需要单独下载对应的字体包。例如,如果终端设备的操作系统或本地应用加载有该原始字体、或目标文本中储存有该原始字体,则认为本地应用支持该原始字体,否则本地应用不支持该原始字体。
步骤S106、在本地应用不支持原始字体的情况下,获取原始字体的字符测量数据。
本公开实施例中所指的字符包括文字和符号,符号包括但不限于标点符号、数字符号、数学符号、特殊符号等等,文字包括但不限于汉字、字母等。
本公开实施例中,字体的字符测量数据包括字符的高度和宽度。原始字体的字符测量数据包括原始字体的字符宽度和原始字体的字符高度,是目标文本中的字符在原始字体状态下的宽度和高度。对于同一种字体,在同一字号下,不同的字符的尺寸可能被设计为相同的或者不同的。如果对于同一种字体,在同一字号下,其所有字符并不采用同一种尺寸,则建立该字号下字符和字符的宽度、高度的映射关系。这样,可将该映射关系作为相应字体的字符测量数据,并可根据该映射关系查找出每个字符在相应字号下的宽度和高度。
在一个例子中,字符测量数据还包括字符的升降值。
参见图3(a)和图3(b)所示,对于同一个汉字“早”,两种不同的字体在同一字号下,宽度和高度都是不同的,升降值也是不同的。图3(b)所示的字体的宽度和高度都小于图3(a)的字体。图3(a)所示的字体的升降值为0,即字体相对于基线没有升降。图3(b)所示的字体的升降值为一正值,即该字体相对于基线有上升。如果字体的升降值为一负值,即表示该字体相对于基线有下降。
在一个例子中,字符测量数据还可以包括其他用于描述字符的位置和/或大小的其他特征,在本文不做限定。
在一个例子中,字体的字符测量数据可通过对字符(例如,可具体为字符的图像模型)进行测量获得。例如,预先以某种字体显示目标文本,测量目标文本在该字体下的字符测量数据,从而得到该字体的字符测量数据。
在一个例子中,服务器中可预先存储有各种字体在各字号下的字符测量数据。
在一个例子中,终端设备获取原始字体的字符测量数据,可以是在终端设备的本地缓存中查询原始字体对应的字符测量数据。
在一个例子中,终端设备获取原始字体的字符测量数据,可以是:先在终端设备的本地缓存中查询原始字体的字符测量数据,在本地缓存中查询不到原始字体的字符测量数据的情况下,从服务器处获取原始字体的字符测量数据。在该例子中,终端设备从服务器处获取到原始字体的字符测量数据后,可以将其存储在本地缓存中,以便于下次再需要使用该字体时,可以从本地缓存中直接读取该字体的字符测量数据。
步骤S108、以本地应用支持的第一字体显示目标文本并根据原始字体的字符测量数据对目标文本进行排版。
在一个例子中,终端设备按照目标文本的原字号以第一字体显示目标文本,并根据原始字体的字符测量数据对以第一字体显示的目标文本进行排版。
在以本地应用支持的第一字体显示目标文本之前,该方法还可以包括确认第一字体的步骤。在本公开实施例中,终端设备从本地应用支持的所有字体中选择出与原始字体相匹配的第一字体。下面进行举例说明:
确定第一字体的例子一:从本地应用支持的所有字体中选择出与原始字体相匹配的第一字体,可包括步骤S202-S206。
步骤S202、获取原始字体的替换字体列表。
在一个例子中,对于任一种字体,预先检测其余字体和该字体的匹配度,选取匹配度达到匹配度阈值的字体作为该字体的替换字体。在本公开实施例中,可以根据两种字体的字符测量数据确定两种字体之间的匹配度。对于任一种字体,可根据其替换字体建立替换字体列表,替换字体列表中的替换字体按照匹配度从高到低进行排序。终端设备可以从服务器处获取到每种字体的替换字体列表。
下面以字体A为例,说明如何确定字体B与字体A的匹配度:
计算字体A的字符C的宽度和字体B的字符C的宽度的差值作为第一差值。
计算字体A的字符C的高度和字体B的字符C的高度的差值作为第二差值。其中,字符C可以是单个字符,也可以是多个字符组成的字符串。
在一个例子中,根据第一差值的绝对值确定字体B与字体A的匹配度,其中,第一差值的绝对值越大,字体B与字体A的匹配度越低,第一差值的绝对值越小,字体B与字体A的匹配度越高。
在一个例子中,根据第二差值的绝对值确定字体B与字体A的匹配度,其中,第二差值的绝对值越大,字体B与字体A的匹配度越低,第二差值的绝对值越小,字体B与字体A的匹配度越高。
在一个例子中,计算第一差值的绝对值和第二差值的绝对值的和值,根据该和值确定字体B与字体A的匹配度,其中,该和值越大,字体B与字体A的匹配度越低,该和值越小,字体B与字体A的匹配度越高。
步骤S204、从替换字体列表的替换字体中确定候选字体,候选字体是本地应用支持的字体。
步骤S206、将候选字体中与原始字体的匹配度最高的确定为第一字体。
在该例子中,从替换字体列表的替换字体中筛选出本地应用支持的候选字体,再进一步从本地应用支持的候选字体中选取和原始字体最为匹配的候选字体(例如,在前述按照匹配度从高到低进行排序的替换字体列表中排序最前的候选字体)作为第一字体。
利用替换字体列表中本地应用支持的候选字体来确定第一字体,不需要终端设备进行复杂计算,更为方便快速。
确定第一字体的例子二:从本地应用支持的所有字体中选择出与原始字体相匹配的第一字体,可包括步骤S302-S304。
步骤S302、确定目标文本的字符类型。
字符类型包括第一类型、第二类型。第一类型是指目标文本的字符为汉字等方块字符,不同汉字的宽度、高度是基本上一样的。第二类型是指目标文本的字符中包括字母、罗马字、蒙古文、或阿拉伯文等字符或者是多种语言混合,这些字符的宽度可能是不一致的,高度也可能是不一致的。
步骤S304、根据与目标文本的字符类型相关联的预设规则,从本地应用支持的所有字体中选择出与原始字体相匹配的第一字体。
在该例子中,根据与目标文本的字符类型对应的规则方式来确定第一字体,下面用例子三、例子四、例子五、例子六进行说明。
确定第一字体的例子三:从本地应用支持的所有字体中选择出与原始字体相匹配的第一字体,可包括步骤S402-S406。
步骤S402、获取候选字体的字符测量数据,候选字体是本地应用支持的字体。
步骤S404、确定目标文本的排版方向。
步骤S406、在目标文本的排版方向为横向排版的情况下,将字符宽度与原始字体的字符宽度最接近的候选字体确定为第一字体。在目标文本的排版方向为竖向排版的情况下,将字符高度与原始字体的字符高度最接近的候选字体确定为第一字体。
在目标文本的排版方向为横向排版的情况下,计算目标文本中的字符在原始字体下的字符宽度和候选字体下的字符宽度之间的差值作为第一差值,第一差值的绝对值越小,表明候选字体的字符宽度与原始字体的字符宽度越接近,选取第一差值的绝对值最小的候选字体作为第一字体。
在目标文本的排版方向为竖向排版的情况下,计算目标文本中的字符在原始字体下的字符高度和候选字体下的字符高度之间的差值作为第二差值,第二差值的绝对值越小,表明候选字体的字符高度与原始字体的字符高度越接近,选取第二差值的绝对值最小的候选字体作为第一字体。
例子三适用于目标文本的字符类型为第一类型和/或第二类型的情况。也就是说,在目标文本中仅含有汉字,或者在目标文本中含有字母、罗马字符的情况下,都可以适用例子三的方式确定第一字体。
确定第一字体的例子四:从本地应用支持的所有字体中选择出与原始字体相匹配的第一字体,可包括步骤S502-S508。
步骤S502、获取原始字体的字体属性和候选字体的字体属性,候选字体是本地应用支持的字体。
字体的字体属性是指字体本身具有的固有属性,可以体现该字体的风格。字体的字体属性可包括字体的粗细程度、加黑程度、倾斜程度等中的一种或者多种。
例如,对于字体的粗细程度,按照从粗到细包括“粗”、“常规”、“细”三种属性值。例如,对于字体的加黑程度,包括“有加黑”、“无加黑”两种属性值。例如,对于字体的倾斜程度,包括“有倾斜”、“无倾斜”两种属性值。
例如,对于“宋体”、“华文细黑”、“方正粗黑宋简体”这三种字体,“宋体”的字体属性是:粗细程度为“细”,加黑程度为“无加黑”,倾斜程度为“无倾斜”;“华文细黑”的字体属性是:粗细程度为“细”,加黑程度为“加黑”,倾斜程度为“无倾斜”;“方正粗黑宋简体”的字体属性是:粗细程度为“粗”,加黑程度为“加黑”,倾斜程度为“无倾斜”。
例如,对于“Times New Roman”和“Forte”这两种字体,“Times New Roman”的字体属性是:粗细程度为“细”,加黑程度为“无加黑”,倾斜程度为“无倾斜”;“Forte”的字体属性是:粗细程度为“粗”,加黑程度为“加黑”,倾斜程度为“有倾斜”。
步骤S504、将字体属性与原始字体的字体属性相同的候选字体确定为目标字体,获取目标字体的字符测量数据。
在一个例子中,字体的字体属性仅包括字体的粗细程度,如果候选字体和原始字体均为“粗”,或者均为“常规”,或者均为“细”,则认为该候选字体和原始字体的属性相同。
在一个例子中,字体的字体属性包括字体的粗细程度、加黑程度以及倾斜程度,如果候选字体和原始字体在粗细程度、加黑程度、倾斜程度三个方面的属性值均一致,则认为该候选字体和原始字体的属性相同。
步骤S506、确定目标文本的排版方向。
步骤S508、在目标文本的排版方向为横向排版的情况下,将字符宽度与原始字体的字符宽度最接近的目标字体确定为第一字体。在目标文本的排版方向为竖向排版的情况下,将字符高度与原始字体的字符高度最接近的目标字体确定为第一字体。
步骤S508的实现方式可以类似于前述步骤S406,这里不再详细说明。
例子四适用于目标文本的字符类型为第一类型和/或第二类型的情况。也就是说,在目标文本中仅含有汉字,或者在目标文本中含有字母、罗马字符的情况下,都可以适用例子四的方式确定第一字体。
在该例子中,在全部候选字体中,过滤掉字体属性与原始字体的字体属性不相同的候选字体,保留字体属性与原始字体的字体属性相同的候选字体作为目标字体,并基于原始字体的字符测量数据在目标字体中确认第一字体,使得选取出的第一字体的风格和原始字体的风格基本上是一致的,进而使得利用本地应用支持的第一字体显示的目标文本和原始字体下的目标文本的呈现风格更为近似。
确定第一字体的例子五,根据与目标文本的字符类型相关联的预设规则,从本地应用支持的所有字体中选择出与原始字体相匹配的第一字体,可以是:终端设备将候选字体的字体标识发送给服务器,以供服务器根据原始字体的字体属性和原始字体下的预设字符串的宽度从候选字体中确定第一字体;然后,服务器将第一字体的字体标识下发给终端设备,终端设备从服务器接收第一字体的字体标识。其中, 所述字体标识可为用于标识字体的名称或编号等。
或者,确定第一字体的例子六,根据与目标文本的字符类型相关联的预设规则,从本地应用支持的所有字体中选择出与原始字体相匹配的第一字体,可以是:终端设备从服务器处获取原始字体的字体属性和原始字体下的预设字符串的宽度,根据原始字体的字体属性和原始字体下的预设字符串的宽度从候选字体中确定第一字体。
其中,候选字体是本地应用支持的字体,预设字符串中包括多个不同的预设字符。预设字符串中的预设字符应当是在字符宽度或字符高度方面中的任一个方面具有代表性的字符。例如,选取任一个汉字以及英文中宽度具有代表性的“w”、“z”、“i”组成预设字符串,其中,“w”、“z”、“i”分别代表三种不同宽度的英文字符,该预设字符串可以为“明WwZzIi”。
例子五、六适用于目标文本的字符类型为第二类型的情况。也就是说,在目标文本中包括字母、罗马字、蒙古文、或阿拉伯文等字符或者是多种语言混合的情况下,可以适用例子五、六的方式确定第一字体。例如,在目标文本的字符类型是字母类型或者多语言混合类型(例如,目标文本中同时含有中文内容和英文内容,或者目标文本中同时含有中文内容和日文内容)的情况下,可以适用例子五、六的方式确定第一字体。基于预设字符串的宽度来确定第一字体,可以适合于不同字符的字符宽度不一样的情况,运算量小,更为高效快速。
在一个例子中,候选字体包括本地应用支持的默认字体和非默认字体。本地应用预先设有默认字体,终端设备安装应用时会设置默认字体,用户可以根据个人喜好自行修改默认字体。
根据原始字体的字体属性和原始字体下的预设字符串的宽度从候选字体中确定第一字体,可包括步骤S602-S604。
步骤S602、如果本地应用支持的默认字体和原始字体的字体属性相同、并且默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度的近似程度符合预设标准,将默认字体确定为第一字体。否则,执行步骤S604。
在一个例子中,确定默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度的近似程度是否符合预设标准,可包括步骤S6022-S6026。
步骤S6022、确定默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度之间的差值作为第四差值。
步骤S6024、确定该第四差值的绝对值与原始字体下的预设字符串的宽度的比值作为第一比值。
步骤S6026、在该第一比值小于等于预设的第一阈值的情况下,确定默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度的近似程度符合预设标准。在该第一比值大于预设的第一阈值的情况下,确定默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度的近似程度不符合预设标准。
在一个例子中,默认字体下的预设字符串的宽度和高度与原始字体下的预设字符串的宽度和高度的近似程度符合预设的标准,可包括:默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度的比值在0.95~1.05之间,即所述第一比值在0~0.05之间。
步骤S604、将与原始字体的字体属性相同的候选字体作为目标字体,从目标字体中确定第一字体。
在步骤S604中,在全部候选字体中(包括默认字体和非默认字体),选取与原始字体的字体属性相同的候选字体作为目标字体,
在一个例子中,步骤S604、从目标字体中确定第一字体,可以是:将预设字符串的宽度与原始字体下的最接近的目标字体确定为第一字体。
计算预设字符串在原始字体下的宽度和目标字体下的宽度的差值作为第三差值,第三差值的绝对值越小,表明目标字体与原始字体下的预设字符串的宽度越接近,选取第三差值的绝对值最小的目标字体作为第一字体。通过这种方式,可以使得在未排版之前,本地应用呈现给用户的目标文本的排版和目标文本的原始排版比较相似,排版时只需要进行微调即可。
在一个例子中,步骤S604、从目标字体中确定第一字体,可以是:将预设字符串的宽度最小的目标字体确定为第一字体。
选取预设字符串的宽度最小的目标字体作为第一字体,可以尽量避免本地应用以第一字体显示目标文本时出现字符之间出现重叠覆盖的情况,未排版之前也不容易因出现重叠覆盖给用户造成阅读障碍。
在该例子中,考虑到用户的字体使用习惯,优先考虑将默认字体作为替换原始字体的第一字体。并且,如果默认字体和原始字体的字体属性不相同,或者默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度的近似程度不符合预设标准,则从与原始字体的字体属性相同的候选字体中确定第一字体。通过这种方式,兼顾了用户的喜好,并且降低了运算量,节省了处理时间。
上述确认第一字体的例子二到例子六中,确定候选字体、目标字体与原始字体的近似程度、匹配程度的实现方式,也可以应用于确定替换字体列表中的替换字体。
步骤S108中,终端设备以本地应用支持的第一字体显示目标文本并根据原始字体的字符测量数据对第一字体显示的目标文本进行排版,可以有多种方式,下面进行举例说明。
排版例子一:首先确定目标文本的排版方向,根据目标文本的排版方向对终端设备以第一字体显示的目标文本进行排版。在目标文本的排版方向为横向排版的情况下,对目标文本的字符进行第一缩放处理以使得目标文本的字符宽度和原始字体的字符宽度一致。在目标文本的排版方向为竖向排版的情况下,对目标文本的字符进行第二缩放处理以使得目标文本的字符高度和原始字体的字符高度一致。
在例子一中,对字符的缩放可以通过调整字号实现。
在一种实施方式中,在步骤S108中,根据原始字体对应的字符测量数据对终端设备显示的目标文本进行排版,可以是:获取第一字体对应的字符测量数据,根据原始字体对应的字符测量数据和第一字体对应的字符测量数据,对终端设备显示的目标文本进行排版。
排版例子二:首先确定目标文本的排版方向,根据目标文本的排版方向对终端设备以第一字体显示的目标文本进行排版。在目标文本的排版方向为横向排版的情况下,确定第一差值,第一差值为原始字体的字符宽度和第一字体的字符宽度的差值。在第一差值为正值的情况下,调整目标文本的字符的横坐标值。在第一差值为负值的情况下,对目标文本的字符进行缩小处理。在目标文本的排版方向为竖向排版的情况下,确定第二差值,第二差值为原始字体的字符高度和第一字体的字符高度的差值。在第二差值为正值的情况下,调整目标文本的字符的纵坐标值。在第二差值为负值的情况下,对目标文本的字符进行缩小处理。
在该例子中,对字符的缩小处理可以通过调整字号实现。
下面以目标文本的排版方向为横向排版为例进行说明:
参见图3(a)所示,在原始字体下每个字符的字符宽度约为W1。参见图3(b)所示,在第一字体下每个字符的字符宽度约为W2。计算W1与W2的差值DW(=W1-W2)作为第一差值。
如果该第一差值DW为正值,说明第一字体的字符宽度小于原始字体的字符宽度,则需要调整第一字体下目标文本的每个字符的横坐标的坐标值。
参见图4所示,目标文本是一行内容,包括“早上好今天的天气真好”这10个 字符。在原始字体下,10个字符的横坐标的坐标值为X 1,X 2,…,X 10,排版后,10个字符的横坐标的坐标值为X 1’,X 2’,…,X 10’,则:
X 1’=X 1+0.5*DW,
X 2’=X 2+(2-1)*DW+0.5*DW,
X n’=X n+(n-1)*DW+0.5*DW,
X 10’=X 10+(10-1)*DW+0.5*DW,
其中,n为整数,1≤n≤10。
可以看出,调整第一字体下这一行内容中的每个字符的横坐标的坐标值相当于调整这一行内容中的相邻字符之间的间距。
如果该第一差值DW为负值,说明第一字体的字符的宽度大于原始字体的字符的宽度,如果通过调整坐标值,则可能会造成字符之间的重叠,因此,需要缩小终端设备以第一字体显示的目标文本的字号。在一个例子中,根据W1/W2的比值缩小终端设备以第一字体显示的目标文本的字号,并保持第一字体下原来的目标文本的位置(坐标值)不变。例如,W1/W2=R1,假设这段内容的原始字号为U1,则将这段内容的字号调整为U2,U2=R1*U1。本文中所述字号为点数制,是本领域技术人员周知的印刷字体的计量方法,例如5磅、12磅等。
下面以目标文本的排版方向为竖向排版为例进行说明:
参见图3(a)所示,在原始字体下每个字符的字符高度均为H1。参见图3(b)所示,在第一字体下每个字符的字符高度均为H2。计算H1与H2的差值DH(=H1-H2)作为第二差值。
如果该第二差值DH为正值,说明第一字体的字符高度小于原始字体的字符高度,则调整第一字体下每个字符的纵坐标的坐标值。
假设原始字体下的目标文本一共有M行内容,每一行内的字符的纵坐标值是一样的,第1行到第M行的字符的纵坐标值分别为Y 1,Y 2,…,Y M,在排版后,第1行到第M行的字符的纵坐标值分别为Y 1’,Y 2’,…,Y M’,则:
Y 1’=Y 1+0.5*DH,
Y 2’=Y 2+(2-1)*DH+0.5*DH,
Y m’=Y m+(m-1)*DH+0.5*DH,
Y M’=Y M+(M-1)*DH+0.5*DH,
其中,m为整数,1≤m≤M。
可以看出,调整第一字体下目标文本的每个字符的纵坐标的坐标值相当于调整目标文本的相邻行之间的行间距。
如果该第二差值DH为负值,说明第一字体的字符的高度大于原始字体的字符的高度,如果通过调整坐标值,则可能会造成字符之间的重叠,因此,需要缩小终端设备以第一字体显示的目标文本的字号。在一个例子中,根据H1/H2的比值缩小终端设备以第一字体显示的目标文本的字号,并保持第一字体下原来的目标文本的位置(坐标值)不变。例如,H1/H2=R2,假设目标文本的原始字号为U1,则将字号调整为U2,U2=R2*U1。
排版例子三:首先确定目标文本的排版方向,根据目标文本的排版方向对终端设备以第一字体显示的目标文本进行排版。在目标文本的排版方向为横向排版的情况下,将目标文本的字号调整为第一字号,第一字号是字符宽度与原始字体的字符宽度最接近的字号;确定第一差值,第一差值为原始字体的字符宽度和第一字体的 字符宽度的差值;在第一差值为正值的情况下,调整目标文本的字符的横坐标值;在第一差值为负值的情况下,对目标文本的字符进行缩小处理。在目标文本的排版方向为竖向排版的情况下,将目标文本的字号调整为第二字号,第二字号是字符高度与原始字体的字符高度最接近的字号;确定第二差值,第二差值为原始字体的字符高度和第一字体的字符高度的差值;在第二差值为正值的情况下,调整目标文本的字符的纵坐标值;在第二差值为负值的情况下,对目标文本的字符进行缩小处理。
也就是说,在目标文本的排版方向为横向排版的情况下,终端设备在将第一字体下的目标文本的字号调整为第一字号后,如果字符宽度仍然大于原始字体下的字符宽度,则下调一个字号以使得字符缩小,避免出现字符之间互相覆盖的情况。
类似地,在目标文本的排版方向为竖向排版的情况下,终端设备在将第一字体下的目标文本的字号调整为第二字号后,如果字符高度仍然大于原始字体下的字符高度,则下调一个字号以使得字符缩小,避免出现字符之间互相覆盖的情况。
在该例子中,对字符的缩小处理可以通过调整字号实现。
终端设备对显示的目标文本进行排版后,其显示的目标文本的排版情况和以原始字体显示的目标文本的排版情况更为接近。参见图4所示,对于目标文本“早上好今天的天气真好”,原始字体下和第一字体下进行对比,原始字体下的这段内容的总宽度更宽。经过步骤S108的排版,终端设备使用第一字体显示的这段内容的总宽度和原始字体下的这段内容的总宽度更为接近。通过这种方式,可以保证原始字体下的同一行内容,不会因为改为使用第一字体进行显示而分行。
排版例子四:根据原始字体的字符测量数据对目标文本进行排版,可以包括步骤S1085-S1087。
步骤S1085、将目标文本切分成词。
步骤S1086、累加词中的每个字符在第一字体下的宽度与在原始字体下的宽度的差值,得到调节量。
步骤S1087、计算调节量与词中的字符间隙数量的比值作为第二比值,根据该第二比值调节词中的字符的间隙以使得词中的字符的间隙相同。
例如,目标文本的一个词中一共有T个字符,字符间隙数量为G个,G=T-1。其中,T个字符中每个字符在第一字体下的宽度与在原始字体下的宽度的差值依次为O 1,O 2,…,O T,累加O 1,O 2,…,O T得到调节量,计算调节量和字符间隙数量的第二比值。如果该第二比值为正值,说明调节量为正值并应该缩小词中字符的间隙,则将词中的字符的间隙减去该第二比值。如果该第二比值为负值,说明调节量为负值并应该增大词中字符的间隙,则将词中的字符的间隙减去该第二比值、也即加上该第二比值的绝对值。
通过这种方式,可以使得同一个词中字符的间隙相同,显示更为均匀。可以适用于第二类型的目标文本,在不同字符的宽度不相同的情况下,仍可以使得同一个词中的字符显示的更加均匀。排版例子四可以在前述任一排版例子之后进行。
在一个例子中,本地应用先对目标文本的字符的宽、高进行排版,然后按照原始字体对应的字符升降值调整目标文本的字符的升降值。
本公开实施例的一个有益效果在于,如果终端设备的本地应用不支持目标文本的原始字体,本地应用使用其支持的第一字体来显示目标文本并且根据原始字体的字符测量数据对目标文本进行排版,使得本地应用在缺失原始字体的情况下仍然可以保持文档排版和原始排版的一致性。
参见图5所示,本公开实施例提供了一种文本的排版方法。该方法包括步骤S702-S706。步骤S702-S706可以由服务器实施。
步骤S702、接收终端设备发送的目标文本的原始字体的字体标识。
步骤S704、根据原始字体的字体标识查询出原始字体的字符测量数据。
步骤S706、将原始字体的字符测量数据发送给终端设备,以供终端设备根据原始字体的字符测量数据对以其本地应用支持的第一字体显示的目标文本进行排版。
在一个例子中,服务器中预先存储有各种字体的字体属性、以及各种字体在各字号下的字符测量数据。字体的字符测量数据可包括字符的高度和宽度。字体的字符测量数据还可以包括字符的升降值。字体的字体属性是指字体本身具有的固有属性,可以体现该字体的风格。字体的字体属性可包括字体的粗细程度、加黑程度、倾斜程度的一种或者多种。
在一个例子中,在终端设备以其本地应用支持的第一字体显示目标文本之前,该方法还包括:根据原始字体的字体标识获取原始字体的替换字体列表。从替换字体列表的替换字体中确定候选字体,候选字体是终端设备的本地应用支持的字体。将在替换字体列表中与原始字体最匹配的候选字体确定为第一字体。将第一字体的标识发送给终端设备。
在一个例子中,在终端设备以其本地应用支持的第一字体显示目标文本之前,该方法还包括:将原始字体的字体属性和原始字体下的预设字符串的宽度发送给终端设备,以供终端设备根据原始字体的字体属性和原始字体下的预设字符串的宽度从候选字体中确定第一字体。其中,候选字体是终端设备的本地应用支持的字体,预设字符串中包括多个不同的预设字符。
在一个例子中,在终端设备以其本地应用支持的第一字体显示目标文本之前,该方法还包括:根据原始字体的字体属性和原始字体下的预设字符串的宽度从候选字体中确定第一字体,将第一字体的字体标识发送给终端设备。其中,候选字体是终端设备的本地应用支持的字体,预设字符串中包括多个不同的预设字符。
在一个例子中,候选字体包括本地应用支持的默认字体和非默认字体。
在一个例子中,根据原始字体的字体属性和原始字体下的预设字符串的宽度从候选字体中确定第一字体,包括:如果默认字体和原始字体的字体属性相同、并且默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度的近似程度符合预设标准,将默认字体确定为第一字体。否则,将与原始字体的字体属性相同的候选字体作为目标字体,并从目标字体中确定第一字体。
在一个例子中,确定默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度的近似程度是否符合预设标准,包括:确定默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度的差值作为第四差值。确定所述第四差值的绝对值与原始字体下的预设字符串的宽度的比值作为第一比值。在所述第一比值小于等于预设的第一阈值的情况下,确定默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度的近似程度符合预设标准。在所述第一比值大于预设的第一阈值的情况下,确定默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度的近似程度不符合预设标准。
在一个例子中,从目标字体中确定第一字体,包括:将预设字符串的宽度与原始字体下的最接近的目标字体确定为第一字体;或者,将预设字符串的宽度最小的目标字体确定为第一字体。
本公开实施例的一个有益效果在于,如果终端设备的本地应用不支持目标文本的原始字体,服务器将原始字体的字符测量数据提供给终端设备,以使得终端设备能够根据原始字体对应的字符测量数据对以本地应用支持的第一字体显示的目标文本进行排版,进而使得本地应用在缺失原始字体的情况下仍然可以保持文档排版和原始排版的一致性。
<设备实施例>
本公开实施例提供了一种文本的排版装置,包括以下模块:
第一确定模块,用于确定目标文本使用的原始字体。
第二确定模块,用于确定本地应用是否支持原始字体。
获取模块,用于在本地应用不支持原始字体的情况下,获取原始字体的字符测量数据。
排版模块,用于根据原始字体的字符测量数据对以所述终端设备的本地应用支持的第一字体显示的目标文本进行排版。
在一个例子中,获取原始字体的字符测量数据,包括以下任一:在所述终端设备的本地缓存中查询原始字体的字符测量数据;在所述终端设备的本地缓存中查询不到原始字体的字符测量数据的情况下,从服务器处获取原始字体的字符测量数据并存储在本地缓存中。
在一个例子中,以本地应用支持的第一字体显示目标文本,所述方法还包括:从本地应用支持的所有字体中选择出与原始字体相匹配的第一字体;以选择出的所述第一字体显示所述目标文本。
在一个例子中,从本地应用支持的所有字体中选择出与原始字体相匹配的第一字体,包括:获取原始字体的替换字体列表。从替换字体列表的替换字体中确定候选字体,候选字体是本地应用支持的字体。将所述候选字体中与所述原始字体的匹配度最高的确定为第一字体。
在一个例子中,以本地应用支持的第一字体显示目标文本,包括:确定目标文本的字符类型。根据与所述目标文本的字符类型相关联的预设规则,从本地应用支持的所有字体中选择出与原始字体相匹配的第一字体;以选择出的所述第一字体显示所述目标文本。
在一个例子中,原始字体的字符测量数据包括原始字体的字符宽度和原始字体的字符高度。从本地应用支持的所有字体中选择出与原始字体相匹配的第一字体,包括:获取候选字体的字符测量数据,候选字体是本地应用支持的字体。确定目标文本的排版方向。在目标文本的排版方向为横向排版的情况下,将字符宽度与原始字体的字符宽度最接近的候选字体确定为第一字体。在目标文本的排版方向为竖向排版的情况下,将字符高度与原始字体的字符高度最接近的候选字体确定为第一字体。
在一个例子中,原始字体的字符测量数据包括原始字体的字符宽度和原始字体的字符高度。
从本地应用支持的所有字体中选择出与原始字体相匹配的第一字体,包括:获取原始字体的字体属性和候选字体的字体属性,候选字体是本地应用支持的字体。将字体属性与原始字体的字体属性相同的候选字体确定为目标字体,获取目标字体的字符测量数据。确定目标文本的排版方向。在目标文本的排版方向为横向排版的情况下,将字符宽度与原始字体的字符宽度最接近的目标字体确定为第一字体。在目标文本的排版方向为竖向排版的情况下,将字符高度与原始字体的字符高度最接近的目标字体确定为第一字体。
在一个例子中,在目标文本的字符类型是字母类型或者多语言混合类型的情况下,根据与类型相关联的预设规则,从本地应用支持的所有字体中选择出与原始字体相匹配的第一字体,包括:将候选字体的字体标识发送给服务器,以供服务器根据原始字体的字体属性和原始字体下的预设字符串的宽度从候选字体中确定第一字体,并从服务器接收第一字体的字体标识。或者,从服务器处获取原始字体的字体属性和原始字体下的预设字符串的宽度,并根据原始字体的字体属性和原始字体下的预设字符串的宽度从候选字体中确定第一字体。其中,候选字体是本地应用支持的字体,预设字符串中包括多个不同的预设字符。
在一个例子中,候选字体包括本地应用支持的默认字体和非默认字体。
根据原始字体的字体属性和原始字体下的预设字符串的宽度从候选字体中确定第一字体,包括:如果默认字体和原始字体的字体属性相同、并且默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度的近似程度符合预设标准,将默认字体确定为第一字体。否则,将与原始字体的字体属性相同的候选字体作为目标字体,从目标字体中确定第一字体。
在一个例子中,确定默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度的近似程度是否符合预设标准,包括:确定默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度的差值作为第四差值。确定所述第四差值的绝对值与原始字体下的预设字符串的宽度的比值作为第一比值。在所述第一比值小于等于预设的第一阈值的情况下,确定默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度的近似程度符合预设标准。
在一个例子中,从目标字体中确定第一字体,包括:将预设字符串的宽度与原始字体下的最接近的目标字体确定为第一字体;或者,将预设字符串的宽度最小的目标字体确定为第一字体。
在一个例子中,原始字体的字符测量数据包括原始字体的字符宽度和原始字体的字符高度。
根据原始字体的字符测量数据对目标文本进行排版,包括:确定目标文本的排版方向。在目标文本的排版方向为横向排版的情况下,确定第一差值,第一差值为所述目标文本的字符在原始字体下的字符宽度和在第一字体下的字符宽度之间的差值;在第一差值为正值的情况下,调整以所述第一字体显示的目标文本的字符的横坐标值。在第一差值为负值的情况下,对以所述第一字体显示的目标文本的字符进行缩小处理。在目标文本的排版方向为竖向排版的情况下,确定第二差值,第二差值为所述目标文本的字符在原始字体下的字符高度和在第一字体下的字符高度之间的差值。在第二差值为正值的情况下,调整以所述第一字体显示的目标文本的字符的纵坐标值。在第二差值为负值的情况下,对以所述第一字体显示的目标文本的字符进行缩小处理。
在一个例子中,原始字体的字符测量数据包括原始字体的字符宽度。
根据原始字体的字符测量数据对目标文本进行排版,包括:将目标文本切分成词。累加词中的每个字符在第一字体下的宽度与在原始字体下的宽度的差值,得到调节量。计算所述调节量与词中的字符间隙数量的比值作为第二比值,根据所述第二比值调节词中的字符的间隙以使得词中的字符的间隙相同。
本公开实施例提供了一种文本的排版装置,包括以下模块:
接收模块,用于接收终端设备发送的目标文本的原始字体的字体标识。
查询模块,用于根据原始字体的字体标识查询出原始字体的字符测量数据。
发送模块,用于将原始字体的字符测量数据发送给终端设备,以供所述终端设备根据原始字体的字符测量数据对以所述终端设备的本地应用支持的第一字体显示的目标文本进行排版。
在一个例子中,终端设备以其本地应用支持的第一字体显示目标文本,包括:根据原始字体的字体标识获取原始字体的替换字体列表。从替换字体列表的替换字体中确定候选字体,候选字体是本地应用支持的字体。将在替换字体列表中排序最前的候选字体确定为第一字体。将第一字体的标识发送给终端设备;以选择出的所述第一字体显示所述目标文本。
在一个例子中,所述方法还包括:将原始字体的字体属性和原始字体下的预设字符串的宽度发送给终端设备,以供终端设备根据原始字体的字体属性和原始字体下的预设字符串的宽度从候选字体中确定第一字体。或者,根据原始字体的字体属性和原始字体下的预设字符串的宽度从候选字体中确定第一字体,并将第一字体的 字体标识发送给终端设备。其中,候选字体是本地应用支持的字体,预设字符串中包括多个不同的预设字符。
在一个例子中,候选字体包括本地应用支持的默认字体和非默认字体。
根据原始字体的字体属性和原始字体下的预设字符串的宽度从候选字体中确定第一字体,包括:如果默认字体和原始字体的字体属性相同并且默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度的近似程度符合预设标准,将默认字体确定为第一字体。否则,将与原始字体的字体属性相同的候选字体作为目标字体,从目标字体中确定第一字体。
在一个例子中,确定默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度的近似程度是否符合预设标准,包括:确定默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度的差值作为第四差值。确定所述第四差值的绝对值与原始字体下的预设字符串的宽度的比值作为第一比值。在所述第一比值小于等于预设的第一阈值的情况下,确定默认字体下的预设字符串的宽度与原始字体下的预设字符串的宽度的近似程度符合预设标准。
在一个例子中,从目标字体中确定第一字体,包括:将预设字符串的宽度与原始字体下的最接近的目标字体确定为第一字体。或者,将预设字符串的宽度最小的目标字体确定为第一字体。
图6是根据一个实施例的电子设备的硬件结构示意图。
如图6所示,该电子设备800包括处理器801和存储器802,该存储器802用于存储可执行的计算机程序,该处理器801用于执行所述计算机程序,以实现以上任意方法实施例的文本的排版方法。
该电子设备800可以是计算机、手机、平板电脑等设备。
在一个例子中,该电子设备为前述的终端设备。
图7是根据一个实施例的服务器的硬件结构示意图。
如图7所示,该服务器900包括处理器901和存储器902,该存储器902用于存储可执行的计算机程序,该处理器901用于执行所述计算机程序,以实现以上任意方法实施例的文本的排版方法。
<计算机可读存储介质>
本公开实施例还提供了一种计算机可读存储介质,计算机可读存储介质上存储计算机程序,计算机程序在被处理器执行时实现根据以上任意方法实施例的文本的排版方法。
本公开可以是系统、方法和/或计算机程序产品。计算机程序产品可以包括计算机可读存储介质,其上载有用于使处理器实现本公开的各个方面的计算机可读程序指令。
计算机可读存储介质可以是可以保持和存储由指令执行设备使用的指令的有形设备。计算机可读存储介质例如可以是但不限于电存储设备、磁存储设备、光存储设备、电磁存储设备、半导体存储设备或者上述的任意合适的组合。计算机可读存储介质的更具体的例子(非穷举的列表)包括:便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、静态随机存取存储器(SRAM)、便携式压缩盘只读存储器(CD-ROM)、数字多功能盘(DVD)、记忆棒、软盘、机械编码设备、例如其上存储有指令的打孔卡或凹槽内凸起结构、以及上述的任意合适的组合。这里所使用的计算机可读存储介质不被解释为瞬时信号本身,诸如无线电波或者其他自由传播的电磁波、通过波导或其他传输媒介传播的电磁波(例如,通过光纤电缆的光脉冲)、或者通过电线传输的电信号。
这里所描述的计算机可读程序指令可以从计算机可读存储介质下载到各个计 算/处理设备,或者通过网络、例如因特网、局域网、广域网和/或无线网下载到外部计算机或外部存储设备。网络可以包括铜传输电缆、光纤传输、无线传输、路由器、防火墙、交换机、网关计算机和/或边缘服务器。每个计算/处理设备中的网络适配卡或者网络接口从网络接收计算机可读程序指令,并转发该计算机可读程序指令,以供存储在各个计算/处理设备中的计算机可读存储介质中。
用于执行本公开操作的计算机程序指令可以是汇编指令、指令集架构(ISA)指令、机器指令、机器相关指令、微代码、固件指令、状态设置数据、或者以一种或多种编程语言的任意组合编写的源代码或目标代码,所述编程语言包括面向对象的编程语言—诸如Smalltalk、C++等,以及常规的过程式编程语言—诸如“C”语言或类似的编程语言。计算机可读程序指令可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络—包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。在一些实施例中,通过利用计算机可读程序指令的状态信息来个性化定制电子电路,例如可编程逻辑电路、现场可编程门阵列(FPGA)或可编程逻辑阵列(PLA),该电子电路可以执行计算机可读程序指令,从而实现本公开的各个方面。
这里参照根据本公开实施例的方法、装置(系统)和计算机程序产品的流程图和/或框图描述了本公开的各个方面。应当理解,流程图和/或框图的每个方框以及流程图和/或框图中各方框的组合,都可以由计算机可读程序指令实现。
这些计算机可读程序指令可以提供给通用计算机、专用计算机或其它可编程数据处理装置的处理器,从而生产出一种机器,使得这些指令在通过计算机或其它可编程数据处理装置的处理器执行时,产生了实现流程图和/或框图中的一个或多个方框中规定的功能/动作的装置。也可以把这些计算机可读程序指令存储在计算机可读存储介质中,这些指令使得计算机、可编程数据处理装置和/或其他设备以特定方式工作,从而,存储有指令的计算机可读介质则包括一个制造品,其包括实现流程图和/或框图中的一个或多个方框中规定的功能/动作的各个方面的指令。
也可以把计算机可读程序指令加载到计算机、其它可编程数据处理装置、或其它设备上,使得在计算机、其它可编程数据处理装置或其它设备上执行一系列操作步骤,以产生计算机实现的过程,从而使得在计算机、其它可编程数据处理装置、或其它设备上执行的指令实现流程图和/或框图中的一个或多个方框中规定的功能/动作。
附图中的流程图和框图显示了根据本公开的多个实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或指令的一部分,所述模块、程序段或指令的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。对于本领域技术人员来说公知的是,通过硬件方式实现、通过软件方式实现以及通过软件和硬件结合的方式实现都是等价的。
以上已经描述了本公开的各实施例,上述说明是示例性的,并非穷尽性的,并且也不限于所披露的各实施例。在不偏离所说明的各实施例的范围和精神的情况下, 对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。本文中所用术语的选择,旨在最好地解释各实施例的原理、实际应用或对市场中的技术改进,或者使本技术领域的其它普通技术人员能理解本文披露的各实施例。本公开的范围由所附权利要求来限定。

Claims (19)

  1. 一种文本的排版方法,应用于运行于终端设备的本地应用,其特征在于,包括:
    确定目标文本使用的原始字体;
    确定本地应用是否支持所述原始字体;
    在所述本地应用不支持所述原始字体的情况下,获取所述原始字体的字符测量数据;
    以所述本地应用支持的第一字体显示所述目标文本;并
    根据所述原始字体的字符测量数据对显示的所述目标文本进行排版。
  2. 根据权利要求1所述的方法,其特征在于,所述获取所述原始字体的字符测量数据,包括以下任一:
    在所述终端设备的本地缓存中查询所述原始字体的字符测量数据;
    在所述终端设备的本地缓存中查询不到所述原始字体的字符测量数据的情况下,从服务器处获取所述原始字体的字符测量数据。
  3. 根据权利要求1所述的方法,其特征在于,以所述本地应用支持的第一字体显示所述目标文本,包括:
    从所述本地应用支持的所有字体中选择出与所述原始字体相匹配的第一字体;
    以选择出的所述第一字体显示所述目标文本。
  4. 根据权利要求3所述的方法,其特征在于,所述从所述本地应用支持的所有字体中选择出与所述原始字体相匹配的第一字体,包括:
    获取所述原始字体的替换字体列表;
    从所述替换字体列表的替换字体中确定候选字体,所述候选字体是所述本地应用支持的字体;
    将所述候选字体中与所述原始字体的匹配度最高的确定为所述第一字体。
  5. 根据权利要求1所述的方法,其特征在于,以所述本地应用支持的第一字体显示所述目标文本,包括:
    确定所述目标文本的字符类型;
    根据与所述目标文本的字符类型相关联的预设规则,从所述本地应用支持的所有字体中选择出与所述原始字体相匹配的第一字体;
    以选择出的所述第一字体显示所述目标文本。
  6. 根据权利要求3或5所述的方法,其特征在于,所述原始字体的字符测量数据包括所述原始字体的字符宽度和所述原始字体的字符高度;所述从所述本地应用支持的所有字体中选择出与所述原始字体相匹配的第一字体,包括:
    获取候选字体的字符测量数据,所述候选字体是所述本地应用支持的字体;
    确定所述目标文本的排版方向;
    在所述目标文本的排版方向为横向排版的情况下,将字符宽度与所述原始字体的字符宽度最接近的候选字体确定为所述第一字体;
    在所述目标文本的排版方向为竖向排版的情况下,将字符高度与所述原始字体的字符高度最接近的候选字体确定为所述第一字体。
  7. 根据权利要求3或5所述的方法,其特征在于,所述原始字体的字符测量数据包括所述原始字体的字符宽度和所述原始字体的字符高度;所述从所述本地应用支持的所有字体中选择出与所述原始字体相匹配的第一字体,包括:
    获取所述原始字体的字体属性和候选字体的字体属性,所述候选字体是所述本地应用支持的字体;
    将字体属性与所述原始字体的字体属性相同的候选字体确定为目标字体,
    获取所述目标字体的字符测量数据;
    确定所述目标文本的排版方向;
    在所述目标文本的排版方向为横向排版的情况下,将字符宽度与所述原始字体的字符宽度最接近的目标字体确定为所述第一字体;
    在所述目标文本的排版方向为竖向排版的情况下,将字符高度与所述原始字体的字符高度最接近的目标字体确定为所述第一字体。
  8. 根据权利要求5所述的方法,其特征在于,在所述目标文本的字符类型是字母类型或者多语言混合类型的情况下,所述根据与所述目标文本的字符类型相关联的预设规则,从所述本地应用支持的所有字体中选择出与所述原始字体相匹配的第一字体,包括:
    将候选字体的字体标识发送给服务器,以供服务器根据所述原始字体的字体属性和所述原始字体下的预设字符串的宽度从所述候选字体中确定所述第一字体,并从所述服务器接收所述第一字体的字体标识;或者,
    从服务器处获取所述原始字体的字体属性和所述原始字体下的预设字符串的宽度,并根据所述原始字体的字体属性和所述原始字体下的预设字符串的宽度从所述候选字体中确定所述第一字体;
    其中,所述候选字体是所述本地应用支持的字体,所述预设字符串中包括多个不同的预设字符。
  9. 根据权利要求8所述的方法,其特征在于,所述候选字体包括所述本地应用支持的默认字体和非默认字体;所述根据所述原始字体的字体属性和所述原始字体下的预设字符串的宽度从所述候选字体中确定所述第一字体,包括:
    如果所述默认字体和所述原始字体的字体属性相同、并且所述默认字体下的预设字符串的宽度与所述原始字体下的预设字符串的宽度的近似程度符合预设标准,将所述默认字体确定为所述第一字体;
    否则,将与所述原始字体的字体属性相同的候选字体作为目标字体,并从所述目标字体中确定所述第一字体。
  10. 根据权利要求9所述的方法,其特征在于,确定所述默认字体下的预设字符串的宽度与所述原始字体下的预设字符串的宽度的近似程度是否符合预设标准,包括:
    确定所述默认字体下的预设字符串的宽度与所述原始字体下的预设字符串的宽度的差值作为第四差值;
    确定所述第四差值的绝对值与所述原始字体下的预设字符串的宽度的比值作为第一比值;
    在所述第一比值小于等于预设的第一阈值的情况下,确定所述默认字体下的预设字符串的宽度与所述原始字体下的预设字符串的宽度的近似程度符合预设标准。
  11. 根据权利要求9所述的方法,其特征在于,所述从所述目标字体中确定所述第一字体,包括:
    将所述预设字符串的宽度与所述原始字体下的最接近的所述目标字体确定为所述第一字体;或者,
    将所述预设字符串的宽度最小的目标字体确定为所述第一字体。
  12. 根据权利要求1所述的方法,其特征在于,所述原始字体的字符测量数据包括所述原始字体的字符宽度和所述原始字体的字符高度;所述根据所述原始字体的字符测量数据对显示的所述目标文本进行排版,包括:
    确定所述目标文本的排版方向;
    在所述目标文本的排版方向为横向排版的情况下,
    确定第一差值,所述第一差值为所述目标文本的字符在所述原始字体下的字符宽度和在所述第一字体下的字符宽度之间的差值;
    在所述第一差值为正值的情况下,调整以所述第一字体显示的所述目标文本的字符的横坐标值;
    在所述第一差值为负值的情况下,对以所述第一字体显示的所述目标文本的字符进行缩小处理;
    在所述目标文本的排版方向为竖向排版的情况下,
    确定第二差值,所述第二差值为所述目标文本的字符在所述原始字体下的字符高度和在所述第一字体下的字符高度之间的差值;
    在所述第二差值为正值的情况下,调整以所述第一字体显示的所述目标文本的字符的纵坐标值;
    在所述第二差值为负值的情况下,对以所述第一字体显示的所述目标文本的字符进行缩小处理。
  13. 根据权利要求1或者12所述的方法,其特征在于,所述原始字体的字符测量数据包括所述原始字体的字符宽度;所述根据所述原始字体的字符测量数据对所述目标文本进行排版,包括:
    将所述目标文本切分成词;
    累加所述词中的每个字符在所述第一字体下的宽度与在所述原始字体下的宽度之间的差值,得到调节量;
    计算所述调节量与所述词中的字符间隙数量的比值作为第二比值,
    根据所述第二比值调节所述词中的字符的间隙以使得所述词中的字符的间隙相同。
  14. 一种文本的排版方法,应用于服务器,其特征在于,包括:
    接收终端设备发送的目标文本的原始字体的字体标识;
    根据所述原始字体的字体标识查询出所述原始字体的字符测量数据;
    将所述原始字体的字符测量数据发送给所述终端设备,以供所述终端设备根据所述原始字体的字符测量数据对以所述终端设备的本地应用支持的第一字体显示的所述目标文本进行排版。
  15. 一种文本的排版装置,其特征在于,包括:
    第一确定模块,用于确定目标文本使用的原始字体;
    第二确定模块,用于确定本地应用是否支持所述原始字体;
    获取模块,用于在所述本地应用不支持所述原始字体的情况下,获取所述原始字体的字符测量数据;
    排版模块,用于根据所述原始字体的字符测量数据对以终端设备的本地应用支持的第一字体显示的所述目标文本进行排版。
  16. 一种文本的排版装置,其特征在于,包括:
    接收模块,用于接收终端设备发送的目标文本的原始字体的字体标识;
    查询模块,用于根据所述原始字体的字体标识查询出所述原始字体的字符测量数据;
    发送模块,用于将所述原始字体的字符测量数据发送给终端设备,以供所述终端设备根据所述原始字体的字符测量数据对以所述终端设备的本地应用支持的第一字体显示的所述目标文本进行排版。
  17. 一种电子设备,包括存储器和处理器,所述存储器用于存储计算机程序;所述处理器用于执行所述计算机程序,以实现根据权利要求1-13中任意一项所述的方法。
  18. 一种服务器,包括存储器和处理器,所述存储器用于存储计算机程序;所述处理器用于执行所述计算机程序,以实现根据权利要求14所述的方法。
  19. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储计 算机程序,所述计算机程序在被处理器执行时实现根据权利要求1-14中任意一项所述的方法。
PCT/CN2021/142042 2021-08-26 2021-12-28 文本的排版 Ceased WO2023024376A1 (zh)

Priority Applications (3)

Application Number Priority Date Filing Date Title
JP2024513144A JP2024534170A (ja) 2021-08-26 2021-12-28 テキストの組版
EP21954891.4A EP4379596A4 (en) 2021-08-26 2021-12-28 TEXT COMPOSITION
US18/686,835 US20250131181A1 (en) 2021-08-26 2021-12-28 Text typesetting

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110988381.9A CN113642289B (zh) 2021-08-26 2021-08-26 文本的排版方法和装置、电子设备、服务器及存储介质
CN202110988381.9 2021-08-26

Publications (1)

Publication Number Publication Date
WO2023024376A1 true WO2023024376A1 (zh) 2023-03-02

Family

ID=78424011

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/142042 Ceased WO2023024376A1 (zh) 2021-08-26 2021-12-28 文本的排版

Country Status (5)

Country Link
US (1) US20250131181A1 (zh)
EP (1) EP4379596A4 (zh)
JP (1) JP2024534170A (zh)
CN (1) CN113642289B (zh)
WO (1) WO2023024376A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113642289B (zh) * 2021-08-26 2024-10-22 珠海金山办公软件有限公司 文本的排版方法和装置、电子设备、服务器及存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130332824A1 (en) * 2012-06-11 2013-12-12 Beijing Founder Apabi Technology Ltd. Embedded font processing method and device
CN109992749A (zh) * 2017-12-29 2019-07-09 珠海金山办公软件有限公司 一种文字显示方法、装置、电子设备及可读存储介质
CN113051235A (zh) * 2021-04-22 2021-06-29 平安普惠企业管理有限公司 文档加载方法、装置、终端和存储介质
CN113283217A (zh) * 2021-05-28 2021-08-20 珠海金山办公软件有限公司 文档转换方法、装置、电子设备及存储介质
CN113642290A (zh) * 2021-08-26 2021-11-12 珠海金山办公软件有限公司 文本的排版方法和装置、电子设备及存储介质
CN113642289A (zh) * 2021-08-26 2021-11-12 珠海金山办公软件有限公司 文本的排版方法和装置、电子设备、服务器及存储介质

Family Cites Families (32)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4275808B2 (ja) * 1999-06-25 2009-06-10 大日本印刷株式会社 文字の割付処理装置
JP2005501310A (ja) * 2001-05-02 2005-01-13 ビットストリーム インコーポレーティッド スケーリング方法及び/又は特定方向で情報媒体を表示する方法及びシステム
WO2004031883A2 (en) * 2002-10-07 2004-04-15 Varilang Soft Ltd. A method for manipulation of objects within electronic graphic documents
US7982737B2 (en) * 2007-10-31 2011-07-19 Adobe System Incorporated System and method for independent font substitution of string characters
US8381101B2 (en) * 2009-11-16 2013-02-19 Apple Inc. Supporting platform-independent typesetting for documents
US8615709B2 (en) * 2010-04-29 2013-12-24 Monotype Imaging Inc. Initiating font subsets
US9519625B2 (en) * 2010-05-06 2016-12-13 Celartem, Inc. Accurate font activation
JP5645481B2 (ja) * 2010-05-28 2014-12-24 キヤノン株式会社 装置、方法、及びプログラム
US8947438B2 (en) * 2011-08-01 2015-02-03 Microsoft Corporation Reducing font instructions
CN102663137B (zh) * 2012-05-03 2016-06-29 北京奇虎科技有限公司 一种应用于移动终端中显示网页的方法及系统
KR101437843B1 (ko) * 2012-09-27 2014-09-04 주식회사 인프라웨어 전자문서 레이아웃 유지를 위한 폰트처리 방법, 그리고 이를 위한 폰트처리 프로그램을 기록한 컴퓨터로 판독가능한 기록매체
CN103699520A (zh) * 2012-09-27 2014-04-02 茵弗维尔株式会社 用于维持电子文档布局的字体处理方法
US20140280693A1 (en) * 2013-03-13 2014-09-18 Celartem, Inc. Font delivery service
CN103345493B (zh) * 2013-06-27 2016-12-07 广州市动景计算机科技有限公司 用于移动终端上的文本内容显示的方法、装置及系统
CN103425631A (zh) * 2013-07-19 2013-12-04 百度在线网络技术(北京)有限公司 用于获取文档文件中目标文字的字体文件的方法及装置
US20150074522A1 (en) * 2013-09-12 2015-03-12 Monotype Imaging Inc. Font Management for Editing Electronic Documents
US10055386B2 (en) * 2014-04-18 2018-08-21 Emc Corporation Using server side font preparation to achieve WYSIWYG and cross platform fidelity on web based word processor
US10115215B2 (en) * 2015-04-17 2018-10-30 Monotype Imaging Inc. Pairing fonts for presentation
US20170249292A1 (en) * 2016-02-29 2017-08-31 Microsoft Technology Licensing, Llc Conditional determination of lookups in glyph processing
US20170344519A1 (en) * 2016-05-27 2017-11-30 Microsoft Technology Licensing, Llc Multi-level font substitution control
JP6812141B2 (ja) * 2016-05-31 2021-01-13 キヤノン株式会社 情報処理装置、情報処理方法およびプログラム
US10664695B2 (en) * 2016-10-26 2020-05-26 Myscript System and method for managing digital ink typesetting
CN106844481B (zh) * 2016-12-23 2021-01-05 北京信息科技大学 字体相似度及字体替换方法
CN108172200B (zh) * 2018-01-25 2021-02-05 腾讯科技(深圳)有限公司 一种应用中文本显示的方法及终端设备
KR102300444B1 (ko) * 2019-11-19 2021-09-09 주식회사 한글과컴퓨터 문서에 적용되어 있는 글꼴이 지원되는 글꼴인지 확인이 가능한 문서 편집 장치 및 그 동작 방법
CN111507063A (zh) * 2020-02-27 2020-08-07 平安科技(深圳)有限公司 文本处理方法、装置、设备及计算机可读存储介质
CN111832253A (zh) * 2020-07-03 2020-10-27 Oppo广东移动通信有限公司 字体调节方法、装置、存储介质及电子设备
AU2021203578A1 (en) * 2021-06-01 2022-12-15 Canva Pty Ltd Systems and methods for converting embedded font text data
US20250328325A1 (en) * 2024-04-18 2025-10-23 Nvidia Corporation Optimizing compilation of program code
CN120340010B (zh) * 2025-04-02 2025-11-14 山东路网智能科技有限公司 融合多传感器数据的高速公路车牌图像识别加密算法系统
CN120612700A (zh) * 2025-05-16 2025-09-09 内蒙古工业大学 一种基于文本行识别的蒙古文文本行和词对齐语料库构建方法
CN120523868B (zh) * 2025-07-22 2025-09-19 四川省地震应急服务中心 结合地震灾情数据库的空间可视化展示方法及系统

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130332824A1 (en) * 2012-06-11 2013-12-12 Beijing Founder Apabi Technology Ltd. Embedded font processing method and device
CN109992749A (zh) * 2017-12-29 2019-07-09 珠海金山办公软件有限公司 一种文字显示方法、装置、电子设备及可读存储介质
CN113051235A (zh) * 2021-04-22 2021-06-29 平安普惠企业管理有限公司 文档加载方法、装置、终端和存储介质
CN113283217A (zh) * 2021-05-28 2021-08-20 珠海金山办公软件有限公司 文档转换方法、装置、电子设备及存储介质
CN113642290A (zh) * 2021-08-26 2021-11-12 珠海金山办公软件有限公司 文本的排版方法和装置、电子设备及存储介质
CN113642289A (zh) * 2021-08-26 2021-11-12 珠海金山办公软件有限公司 文本的排版方法和装置、电子设备、服务器及存储介质

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4379596A4 *

Also Published As

Publication number Publication date
JP2024534170A (ja) 2024-09-18
CN113642289B (zh) 2024-10-22
EP4379596A1 (en) 2024-06-05
US20250131181A1 (en) 2025-04-24
CN113642289A (zh) 2021-11-12
EP4379596A4 (en) 2025-07-30

Similar Documents

Publication Publication Date Title
US10699166B2 (en) Font attributes for font recognition and similarity
US10102182B2 (en) Indicators of text continuity
US9824304B2 (en) Determination of font similarity
US20180239995A1 (en) Font Recognition using Text Localization
US20080079730A1 (en) Character-level font linking
AU2017204297A1 (en) Visual similarity based font replacement for desktop and web applications
US11030388B2 (en) Live text glyph modifications
KR20200141539A (ko) 고정 서식 문서에서의 동아시아 레이아웃 특징들의 검출 및 재구성
BR112014017832B1 (pt) método de detecção de fórmula para identificar uma fórmula matemática, sistema para detectar uma fór-mula que aparece em um documento de formato fixo e mídia legível por computador
US20150324340A1 (en) Method for generating reflow-content electronic book and website system thereof
KR20150095658A (ko) 수정 동안 콘텐츠의 영역의 레이아웃 유지 기법
CN113515928A (zh) 电子文本生成方法、装置、设备及介质
JP7782113B2 (ja) テキストの組版
US10366142B2 (en) Identifier based glyph search
JP2019169137A (ja) タイトル推定器
WO2023024376A1 (zh) 文本的排版
US11809806B2 (en) Glyph accessibility system
US20250218083A1 (en) Systems and methods for creating editable documents
JP5715172B2 (ja) 文書表示装置、文書表示方法及び文書表示プログラム
CN113743438B (zh) 文本检测用数据集生成方法、装置和系统
KR20220060851A (ko) 글자체를 제공하는 방법 및 디바이스
CN105760354B (zh) 电子图书中笔记数据重定位方法与装置
US20250322148A1 (en) Systems and methods for extracting tables from documents
CN113377380B (zh) 用户界面组件部署方法和装置
AU2015203352B2 (en) Indicators of text continuity

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21954891

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 18686835

Country of ref document: US

Ref document number: 2024513144

Country of ref document: JP

WWE Wipo information: entry into national phase

Ref document number: 2021954891

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2021954891

Country of ref document: EP

Effective date: 20240228

NENP Non-entry into the national phase

Ref country code: DE

WWP Wipo information: published in national office

Ref document number: 18686835

Country of ref document: US