WO2023024377A1 - 文本的排版 - Google Patents

文本的排版 Download PDF

Info

Publication number
WO2023024377A1
WO2023024377A1 PCT/CN2021/142056 CN2021142056W WO2023024377A1 WO 2023024377 A1 WO2023024377 A1 WO 2023024377A1 CN 2021142056 W CN2021142056 W CN 2021142056W WO 2023024377 A1 WO2023024377 A1 WO 2023024377A1
Authority
WO
WIPO (PCT)
Prior art keywords
font
terminal
target text
original
character
Prior art date
Application number
PCT/CN2021/142056
Other languages
English (en)
French (fr)
Inventor
曹宗华
刘欢
王文锋
Original Assignee
北京金山办公软件股份有限公司
珠海金山办公软件有限公司
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 北京金山办公软件股份有限公司, 珠海金山办公软件有限公司 filed Critical 北京金山办公软件股份有限公司
Publication of WO2023024377A1 publication Critical patent/WO2023024377A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/109Font handling; Temporal or kinetic typography
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • 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; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting

Definitions

  • a text typesetting device which is applied to multiple collaborative terminals of collaborative documents.
  • the device includes: a first determining module, configured to determine the original font used in the target text in the collaborative document; a second determining optical module, configured to determine whether the first terminal among the plurality of collaborative terminals supports the original font A font; an acquisition module, configured to acquire the character size data of the original font when the first terminal does not support the original font; a typesetting module, configured to acquire the character size data of the original font successfully In some cases, displaying the target text in a first font supported by the first terminal; and typesetting the target text displayed in the first font according to the character size data of the original font.
  • a computer-readable storage medium there is also provided a computer-readable storage medium.
  • a computer program is stored on the computer-readable storage medium, and when executed by a processor, the computer program implements the method of the first aspect of the present disclosure.
  • FIG. 3(a) and FIG. 3(b) are schematic diagrams of character size data provided by embodiments of the present disclosure.
  • FIG. 5 is a schematic diagram of an electronic device according to an embodiment of the disclosure.
  • Fig. 1 is a block diagram of an online document collaboration system provided by an embodiment of the present disclosure.
  • the online document collaboration system includes multiple terminal devices, and the multiple terminal devices can communicate through a network.
  • a terminal device may be 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 equipment 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 camera1030.
  • 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 may also only include some of the above-mentioned devices.
  • user A can submit a collaboration document through a terminal device, and select a collaborator to start the online multi-person collaboration function. After that, all selected collaborators and user A can use their respective terminal devices to view and collaboratively edit the collaborative document, and these terminal devices are the collaborative terminals of the collaborative document.
  • the online multi-person collaboration function can be implemented based on the target application, and users can submit collaborative documents on the target application and view and collaboratively edit them on the target application.
  • the user registers an account on the target application in advance. After the user uses the terminal device to open the target application and log in to the account, the online multi-person collaboration function can be used.
  • the target application running on the terminal device is the collaboration terminal of the collaborative document application.
  • each terminal device can be regarded as a collaborative terminal. That is to say, users of the same account can use two or more collaboration terminals to complete viewing and collaborative editing of the target text.
  • the embodiment of the present disclosure provides a text typesetting method, including steps S102-S108.
  • the steps S102-S108 can be implemented by the first terminal, and the first terminal is a collaborative terminal among the multiple collaborative terminals of the collaborative document.
  • Step S102 determining the original font used in the target text in the collaboration document.
  • the fonts supported by the first terminal may be determined according to the font package installed on it. In an example, if the font package of a certain font is installed on the first terminal, it means that the first terminal supports the font. Generally speaking, the operating system of the terminal device or the basic data package of the 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 niche special fonts, you need to download the corresponding font package separately.
  • Step S106 the first terminal acquires character size data of the original font when the first terminal does not support the original font.
  • the character size data of the font includes the height and width of the character.
  • the character size 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 characters and their width and height. In this way, the mapping relationship can be used as the character size data of the corresponding font, and the character size of each character in the corresponding font size can be found out according to the mapping relationship.
  • character size data for a font is obtained by taking size measurements of the characters. For example, among multiple cooperative terminals, if a certain cooperative terminal supports the original font, the cooperative terminal can display the target text in the original font, and measure the character size of the target text in the original font (it can be specifically the width and height of the character) , so as to obtain the character size data of the original font.
  • the first terminal may acquire the character size data of the original font shared by another collaborative terminal among multiple collaborative terminals. That is to say, based on the online multi-person collaboration relationship, if the first terminal does not support the original font, if a collaborative terminal other than the first terminal supports the original font, the collaborative terminal that supports the original font can The character size data of the original font is shared among the terminals, so that the first terminal obtains the size data of the original font.
  • the collaborative terminal sharing the character size data of the original font may be called a second terminal, and the second terminal supports the original font.
  • the subsequent step S202 For the process of determining the second terminal among the multiple coordinated terminals, reference may be made to the subsequent step S202.
  • the first terminal obtains the character size data of the original font from the second terminal, it can store it in the local cache of the first terminal, so that when the font needs to be used next time, it can be retrieved from the local cache Read the character size data of this font directly.
  • obtaining the character size data of the original font by the first terminal may be: first querying the character size data of the original font in a local cache of the first terminal. If the character size data of the original font cannot be found in the local cache of the first terminal, the character size data of the original font is acquired from the second terminal. In this example, after obtaining the character size data of the original font, the first terminal can store it in the local cache, so that when the font needs to be used next time, it can directly read the characters of the font from the local cache size data.
  • the acquisition of the character size data of the original font by the first terminal from the second terminal may include steps S202-S204.
  • Step S202 broadcasting a font query request about the original font among multiple cooperative terminals to determine the second terminal.
  • a terminal when a terminal becomes a collaborative terminal of a collaborative document, it will broadcast a notification message of "joining collaboration"; " notification message.
  • the collaborative terminal of the collaborative document can determine the number of collaborative terminals according to the received notification information.
  • the number of cooperating terminals is the difference between the number of received notification information of "joining cooperation” and the number of received notification information of "exiting cooperation".
  • the first terminal does not support the original font, if the number of cooperative terminals reaches 2 or more, the first terminal broadcasts a font query request among multiple cooperative terminals to determine the second terminal.
  • the process in which the first terminal broadcasts font query requests among multiple cooperative terminals to determine the second terminal may include steps S2022-S2024.
  • Step S2022 broadcasting font query requests among multiple cooperative terminals to determine a cooperative terminal supporting the original font as a candidate terminal.
  • Step S2024 when the number of candidate terminals is equal to 1, determine the candidate terminal as the second terminal.
  • the number of candidate terminals is greater than 1, a candidate terminal satisfying a preset condition is determined as the second terminal.
  • the candidate terminal with the best communication quality with the first terminal For example, the candidate terminal with the lowest network delay with the first terminal may be determined as the candidate terminal with the best communication quality.
  • the candidate terminal receiving the least number of font assistance requests is relatively idle, and it is beneficial to improve the overall efficiency to use it as the second terminal.
  • Condition c Submit the candidate terminal with the least number of font query requests.
  • the candidate terminal that submits the least number of font query requests is relatively idle, and it is beneficial to improve the overall efficiency to use it as the second terminal.
  • the first terminal sends a font assistance request to the second terminal, and the second terminal sends character size data corresponding to the original font to the first terminal when receiving the font assistance request.
  • the second terminal when receiving the font assistance request, performs a character measurement operation on the original font to obtain character size data of the original font.
  • Step S108 if the first terminal successfully acquires the character size data of the original font, display the target text in the first font supported by the first terminal and typesetting the displayed target text according to the character size data of the original font.
  • the first font may be the font that best matches the character size data of the original font among all the fonts supported by the first terminal.
  • the method for determining the first font may include: when the typesetting direction of the target text is horizontal typesetting Next, calculate the difference between the character width of the characters in the target text in the original font and the character width of each font supported by the first terminal as the first difference, the smaller the absolute value of the first difference , indicating that the character width of the corresponding font supported by the first terminal is closer to the character width of the original font, and the font supported by the first terminal 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
  • the smaller the absolute value of the second difference the closer the character height of the corresponding font supported by the first terminal is to the character height of the original font, and the font supported by the first terminal with the smallest absolute value of the second difference is selected as first font.
  • the typesetting direction of the target text is determined, and the typesetting of the target text displayed on the first terminal in the first font is performed according to the typesetting direction of the target text.
  • the first scaling process is performed on the characters of the target text in the first font so that the character width of the target text in the first font is the same as the character width in the original font. Character width is consistent.
  • the second scaling process is performed on the characters of the target text in the first font so that the character height of the target text in the first font is the same as that in the original font. The characters are highly consistent.
  • Example 1 the scaling of characters can be achieved by adjusting the font size.
  • step S108 typesetting the target text displayed on the first terminal according to the character size data corresponding to the original font may be: obtaining the character size data corresponding to the first font, and according to the character size data corresponding to the original font The size data and the character size data corresponding to the first font typesetting the target text displayed on the first terminal.
  • the typesetting direction of the target text is determined, and the typesetting of the target text displayed on the first terminal in the first font is performed according to the typesetting direction of the target text.
  • a first difference is determined, and the first difference is the difference between the character width of the target text in the original font and the character width in the first font.
  • the absc issa 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 reduction of characters can be realized by adjusting the font size.
  • the character width of each character of the target text in the original font is about W1.
  • the character width of each character of the target text 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 the 10 characters are X 1 , X 2 ,...,X 10
  • the coordinate values of the abscissa of the 10 characters are X 1 ', X 2 ',... ,X 10 ', then:
  • 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 second difference DH is a negative value, it means that the height of the characters in the first font is greater than the height of the characters in the original font. If the coordinate value is adjusted, overlapping between characters may be caused. Therefore, the first terminal needs to be reduced
  • the typesetting direction of the target text is determined, and the typesetting of the target text displayed on the first terminal in the first font is performed according to the typesetting direction of the target text.
  • the font size of the target text under the first font is adjusted to the first font size
  • the first font size is the character width of the target text under the first font and the original font size The character width closest to the font size.
  • a first difference is determined, and the first difference is the difference between the character width of the target text in the original font and the character width in 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 first terminal 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 reduce the font size by one to make the characters smaller and avoid the situation where characters overlap each other.
  • the font size of the target text under the first font is adjusted to the second font size
  • the second font size is the character height of the target text under the first font and the original font size The font size closest to the height of the characters below.
  • a second difference is determined, and the second difference is the difference between the character height of the target text in the original font and the character height in 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.
  • Example 3 the reduction of characters can be realized by adjusting the font size.
  • the typesetting of the target text displayed by the first terminal in the first font is closer to the typesetting of the target text displayed in the original font.
  • the total width of this content under the original font is wider.
  • the total width of the content displayed by the first terminal 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 the first font is used for display, thereby avoiding the problem that the collaboration terminals cannot synchronize and collaborate due to typesetting differences.
  • the method may further include steps S902-S904.
  • Step S902. Determine whether the first terminal supports the target font.
  • the target font is a font determined among candidate fonts based on a preset negotiation mechanism when multiple cooperative terminals do not support the original font.
  • the candidate font is a font supported by any cooperative terminal.
  • the font supported by the first collaborative terminal that sends out the font query request may be determined as the target font.
  • the first collaborative terminal to issue a font query request is usually relatively idle and more efficient than other collaborative terminals.
  • the score of each candidate font may be determined, and the candidate font with the highest score may be determined as the target font.
  • the score of the candidate font is the number of collaborative terminals supporting the candidate font.
  • Step S904 if the first terminal supports the target font, display the target text in the target font.
  • the first terminal does not support the target font, it obtains the character size data of the target font from the third terminal, displays the target text with the second font supported by the first terminal and uses the second font according to the character size data of the target font Typesetting is performed on the displayed target text, and the third terminal is a collaborative terminal that supports the target font.
  • the second font is a font supported by the first terminal that best matches the target font.
  • the process of determining the second font may be similar to the aforementioned process of determining the first font.
  • the second font can be the same as the first font.
  • the process of the first terminal acquiring the character size data of the target font from the third terminal is similar to the aforementioned process of the first terminal acquiring the character size data of the original font from the second terminal.
  • the first terminal if the first terminal supports the original font, if the first terminal receives a font assistance request from the fourth terminal, it sends character size data corresponding to the original font to the fourth terminal. In an example, if the first terminal supports the original font, the first terminal can share the character size data of the original font among multiple cooperative terminals.
  • the first determining module is configured to determine the original font used in the target text in the collaboration document.
  • the second determination module is configured to determine whether the first terminal among the plurality of cooperative terminals supports the original font.
  • the first acquiring module is configured to acquire the character size data of the original font when the first terminal does not support the original font.
  • the first typesetting module is configured to typeset the target text displayed in the first font according to the character size data of the original font when the character size data of the original font is obtained successfully.
  • acquiring the character size data of the original font by the first terminal includes: the first terminal acquiring the character size data of the original font shared by the second terminal among multiple cooperative terminals.
  • obtaining the character size data of the original font by the first terminal includes: querying the character size data of the original font in the local cache of the first terminal; or obtaining the character size data of the original font from the second terminal, the first
  • the second terminal is a collaborative terminal that supports original fonts among multiple writing terminals.
  • obtaining the character size data of the original font by the first terminal includes: querying the character size data of the original font in the local cache of the first terminal; the first terminal cannot query the character size data of the original font in its local cache
  • the character size data of the original font is acquired from the second terminal, and the second terminal is a cooperative terminal supporting the original font among the multiple cooperative terminals.
  • the first obtaining module includes a first requesting module and a second requesting module.
  • the first request module is used for broadcasting font query requests among multiple cooperative terminals to determine the second terminal.
  • the second request module is configured to send a font assistance request to the second terminal, so as to obtain character size data of the original font from the second terminal.
  • the first request module broadcasts a font query request among a plurality of cooperative terminals to determine a second terminal, including: broadcasting a font query request among a plurality of cooperative terminals, so as to determine a cooperative terminal supporting an original font as a candidate terminal; When the number of candidate terminals is equal to 1, the candidate terminal is determined as the second terminal; when the number of candidate terminals is greater than 1, the candidate terminal meeting the preset condition is determined as the second terminal.
  • the first terminal further includes a third determination module, a second acquisition module and a second typesetting module.
  • the third determination module is used to determine whether the first terminal supports the target font when the first terminal fails to obtain the character size data of the original font.
  • the target font is a font determined among candidate fonts based on a preset negotiation mechanism when multiple cooperative terminals do not support the original font, and the candidate font is a font supported by any cooperative terminal;
  • the second acquiring module is configured to acquire character size data of the target font from the third terminal when the third determining module determines that the first terminal does not support the target font.
  • the second typesetting module is configured to display the target text in the target font when the third determining module determines that the first terminal supports the target font. And, when the third determining module determines that the first terminal does not support the target font, display the target text with the second font supported by the first terminal, and the third terminal is a collaborative terminal supporting the target font among a plurality of cooperative terminals; And typesetting the target text displayed in the first font supported by the first terminal according to the character size data of the target font.
  • the first terminal further includes a sending module.
  • the sending module is used for displaying the target text in the original font and sending the character size data of the original font to the fourth terminal when the first terminal supports the original font.
  • the fourth terminal is a cooperative terminal that does not support the original font among the multiple cooperative terminals.
  • the first typesetting module typeset the target text displayed in the first font supported by the first terminal according to the character size data of the original font, including: determining the typesetting direction of the target text; In the case of horizontal typesetting, determine the first difference, the first difference is the difference between the character width of the target text under the original font and the character width under the first font; when the first difference is a positive value In the case of , the abscissa value of the character of the target text is adjusted; in the case of a negative value of the first difference, the character of the target text is reduced.
  • the second difference is the difference between the character height of the target text under the original font and the character height under 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 character of the target text is reduced.
  • the electronic device 800 may be a computer, a mobile phone, a tablet computer and other devices.
  • 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.

Abstract

本公开涉及文本的排版方法和装置、电子设备及存储介质,涉及计算机技术领域。该方法包括:确定协作文档中目标文本使用的原始字体;确定第一终端是否支持原始字体,第一终端是协作文档的多个协作终端中的一个;第一终端在第一终端不支持原始字体的情况下,获取原始字体的字符尺寸数据;第一终端在获取原始字体的字符尺寸数据成功的情况下,以第一终端支持的第一字体显示目标文本且根据原始字体的字符尺寸数据对以第一字体显示的目标文本进行排版。

Description

文本的排版 技术领域
本公开涉及计算机技术领域,更具体地,涉及文本的排版方法和装置、电子设备及存储介质。
背景技术
越来越多的应用推出了在线协作文档功能,例如在线文档多人编辑、查看功能。当一个或多个用户在不同设备中查看同一份在线文档时,如果缺失某种字体可能会导致该文档在不同设备中呈现出的排版方式存在较大的差异,影响文档的美观和阅读体验一致性。一般采用的做法是在当前环境下安装对应的字体。但这种方法需要搜索、下载、安装字体,并且字体可能还需要付费,比较难进行大面积推广和应用。因此,有必要提出一种新的文本的排版方法。
发明内容
本公开实施例的一个目的是提供一种文本排版的新的技术方案,以在缺失字体的情况下保持在线协作文档的排版一致性。
根据本公开的第一方面,提供了一种文本的排版方法,应用于协作文档的多个协作终端。所述方法包括:确定所述协作文档中目标文本使用的原始字体;确定所述多个协作终端中的第一终端是否支持所述原始字体;所述第一终端在所述第一终端不支持所述原始字体的情况下,获取所述原始字体的字符尺寸数据;所述第一终端在获取所述原始字体的字符尺寸数据成功的情况下,以所述第一终端支持的第一字体显示所述目标文本;且所述第一终端根据所述原始字体的字符尺寸数据对以所述第一字体显示的所述目标文本进行排版。
根据本公开的第二方面,提供了一种文本的排版装置,应用于协作文档的多个协作终端。所述装置包括:第一确定模块,用于确定所述协作文档中目标文本使用的原始字体;第二确定光模块,用于确定所述多个协作终端中的第一终端是否支持所述原始字体;获取模块,用于在所述第一终端不支持所述原始字体的情况下,获取所述原始字体的字符尺寸数据;排版模块,用于在获取所述原始字体的字符尺寸数据成功的情况下,以所述第一终端支持的第一字体显示所述目标文本;并且根据所述原始字体的字符尺寸数据对以所述第一字体显示的所述目标文本进行排版。
根据本公开的第三方面,还提供了一种电子设备。所述电子设备包括存储器和处理器,所述存储器用于存储计算机程序;所述处理器用于执行所述计算机程序,以实现本公开第一方面的方法。
根据本公开的第四方面,还提供了一种计算机可读存储介质。所述计算机可读存储介质上存储计算机程序,所述计算机程序在被处理器执行时实现本公开的第一方面的方法。
本公开实施例的一个有益效果在于,对于在线多人协作的协作文档,如果某个协作终端不支持协作文档中目标文本的原始字体,则可以使用其支持的第一字体来显示目标文本并且根据原始字体对应的字符尺寸数据对目标文本进行排版,使得该协作终端在缺失原始字体的情况下仍可以和其它协作终端保持排版一致性。本公开实施例提供的文本的排版方法,适用于在线文档多人编辑。
通过以下参照附图对本公开的示例性实施例的详细描述,本公开实施例的其它特征及其优点将会变得清楚。
附图说明
被结合在说明书中并构成说明书的一部分的附图示出了本公开的实施例,并且连同其说明一起用于解释本公开实施例的原理。
图1为本公开实施例提供的在线文档协作系统的示意图;
图2为本公开实施例提供的文本的排版方法的方法流程图;
图3(a)和图3(b)为本公开实施例提供的字符尺寸数据的示意图;
图4是本公开实施例提供的文本的排版方法的示例图;
图5是根据本公开实施例的电子设备的示意图。
具体实施方式
现在将参照附图来详细描述本公开的各种示例性实施例。应注意到:除非另外具体说明,否则在这些实施例中阐述的部件和步骤的相对布置、数字表达式和数值不限制本公开的范围。
以下对至少一个示例性实施例的描述实际上仅仅是说明性的,决不作为对本公开及其应用或使用的任何限制。
对于相关领域普通技术人员已知的技术、方法和设备可能不作详细讨论,但在适当情况下,所述技术、方法和设备应当被视为说明书的一部分。
在这里示出和讨论的所有例子中,任何具体值应被解释为仅仅是示例性的,而不是作为限制。因此,示例性实施例的其它例子可以具有不同的值。
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步讨论。
<文本的排版方法>
图1是本公开实施例提供的在线文档协作系统的框图。如图1所示,该在线文档协作系统包括多个终端设备,多个终端设备之间可以通过网络进行通信。
终端设备例如可以是安装有智能操作系统(例如安卓、IOS、Windows、Linux等)的电子设备,包括但不限于便携式电脑、台式计算机、手机、平板电脑等。终端设备的配置包括但不限于处理器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包括但不限于键盘、鼠标、触摸屏等。终端设备的配置也可以仅包括上述装置中的部分装置。
应用于本公开的一个实施例中,用户A可以通过一台终端设备提交协作文档,选取协作人员以启动在线多人协作功能。在此之后,所有被选取的协作人员和用户A可以使用各自的终端设备对该协作文档进行查看和协作编辑,这些终端设备即为该协作文档的协作终端。
应用于本公开的一个实施例中,在线多人协作功能可以基于目标应用实现,用户可在目标应用上提交协作文档并且在目标应用上进行查看和协作编辑。在一个例子中,用户预先在目标应用上注册账户,用户使用终端设备打开目标应用并登录账户后就可以使用在线多人协作功能,在终端设备上运行的目标应用即为该协作文档的协作终端应用。
在一个例子中,该目标应用例如为文档编辑软件、即时通信软件、办公软件、浏览器等。
在一个例子中,该目标应用例如可以是原生应用、Web应用、混合应用、轻应用等。原生应用指的是能直接运行于当前操作系统的应用程序。Web应用指需要在浏览器中运行的网页应用。混合应用则可以是原生应用和Web应用的结合,通常是一个原生应用内嵌了浏览器。轻应用是一种不需要下载安装即可使用的应用程序,用户可以即搜即用或者直接扫码使用。
在允许同一账户登录在多台终端设备的目标应用上的情况下,每一台终端设备可以被视为一个协作终端。也就是说,同一个账户的用户可以使用两台甚至更多的协作终端来完成对目标文本的查看、协作编辑。
图1所示的在线文档协作系统仅仅是说明性的并且不意味着对本公开实施例、其应用或使用的任何限制。本领域技术人员应当理解,尽管前面描述了终端设备的多个装置,但是,本公开实施例可以仅涉及其中的部分装置。例如,终端设备可以只涉及处理器、存储器、通信装置、输入装置、显示屏。本领域技术人员可以根据本公开实施例公开的方案设计指令。指令如何控制处理器进行操作,是本领域公知技术,故在此不再详细描述。
参见图2所示,本公开实施例提供了一种文本的排版方法,包括步骤S102-S108。该步骤S102-S108可以由第一终端实施,第一终端是协作文档的多个协作终端中的一个协作终端。
步骤S102、确定协作文档中目标文本使用的原始字体。
在本公开实施例中,目标文本可以是协作文档中的任一部分文本。在一个例子中, 第一终端从协作文档中获取目标文本的原始字体信息,从而确定目标文本使用的原始字体。一般情况,该原始字体信息可以存储在协作文档的文档数据中。在一种可能的实施例中,所述原始字体信息可以是字体的标识、名称、编码等。
在本公开实施例中,字体可以包括加载在终端设备的操作系统中的字体、加载在终端设备的客户端(例如浏览器或应用端等)中的字体或服务器中存储的字体,也可以是文档文件中携带的字体。其中,文档文件可以携带字体,但携带字体的文档文件通常具有比较大的数据量。此外,加载在终端设备的操作系统中的字体、加载在终端设备的客户端中的字体和文档文件携带的字体,都属于该终端设备能够支持的字体,可统称为本地字体。而存储在服务器中的字体,可被称为服务器字体或云字体。
步骤S104、确定第一终端是否支持原始字体。
在本公开实施例中,第一终端在确定目标文本使用的原始字体后,检查自身支持的全部字体中是否包括该原始字体,如果不包括,则确定第一终端不支持该原始字体。例如,如果第一终端的操作系统或第一终端的客户端加载有该原始字体、或目标文本(或协作文档)中储存有该原始字体,则认为第一终端支持该原始字体,否则第一终端不支持该原始字体。
第一终端支持的字体可以根据其安装的字体包确定。在一个例子中,如果第一终端安装了某种字体的字体包,说明第一终端支持该字体。通常来说,终端设备的操作系统或者应用的基础数据包中会预先安装有多种大众广为使用的字体包并且可以将其中一种字体设置为默认字体,如果用户想要使用一些小众特别的字体,则需要单独下载对应的字体包。
步骤S106、第一终端在第一终端不支持原始字体的情况下,获取原始字体的字符尺寸数据。
本公开实施例中所指的字符包括但不限于文字和符号,文字包括但不限于汉字、字母等,符号包括但不限于标点符号、数字符号、数学符号、特殊符号、表情符号等等。
本公开实施例中,字体的字符尺寸数据包括字符的高度和宽度。原始字体的字符尺寸数据包括原始字体的字符宽度和原始字体的字符高度,是目标文本中的字符在原始字体状态下的宽度和高度。对于同一种字体,在同一字号下,不同的字符的尺寸可能被设计为相同的或者不同的。如果对于同一种字体,在同一字号下,其所有字符并不采用同一种尺寸,则建立字符和字符的宽度、高度的映射关系。这样,可将该映射关系作为相应字体的字符尺寸数据,并可根据映射关系可以查找出每个字符在相应字号下的字符尺寸。
参见图3(a)和图3(b)所示,对于同一个汉字“早”,两种不同的字体在同一字号下,宽度和高度都是不同的,图3(b)所示的字体的宽度和高度都小于图3(a)的字体。
在一个例子中,字体的字符尺寸数据通过对字符进行尺寸测量获得。例如,在多个协作终端中,某个协作终端支持原始字体,则该协作终端可以以原始字体显示目标文本,测量目标文本在原始字体下的字符的尺寸(可具体为字符的宽度和高度),从而得到原 始字体的字符尺寸数据。
在又一实施例中,原始字体的原始字体信息中包括该原始字体的字符尺寸数据。进一步的,可以从原始字体的原始字体信息中读取出原始字体的字符尺寸数据。
在一个例子中,第一终端可以获取另一个协作终端在多个协作终端之间分享的原始字体的字符尺寸数据。也就是说,基于在线多人协作关系,在第一终端不支持原始字体的情况下,如果第一终端之外的某个协作终端支持原始字体,该支持原始字体的协作终端可以在多个协作终端之间分享原始字体的字符尺寸数据,从而使得第一终端获得原始字体的尺寸数据。
在一个例子中,该分享原始字体的字符尺寸数据的协作终端可称为第二终端,第二终端支持原始字体。在多个协作终端中确定第二终端的过程可以参见后续步骤S202。在一个例子中,第一终端从第二终端获取到原始字体的字符尺寸数据后,可以将其储存在第一终端的本地缓存中,以便于下次需要使用该字体时,可以从本地缓存中直接读取该字体的字符尺寸数据。
在一个例子中,第一终端获取原始字体的字符尺寸数据,可以是在第一终端的本地缓存中查询原始字体的字符尺寸数据。
在一个例子中,第一终端获取原始字体的字符尺寸数据,可以是:先在第一终端的本地缓存中查询原始字体的字符尺寸数据。在第一终端的本地缓存中查询不到原始字体的字符尺寸数据的情况下,从第二终端处获取原始字体的字符尺寸数据。在该例子中,第一终端在获取到原始字体的字符尺寸数据后,可以将其存储在本地缓存中,以便于下次需要使用该字体时,可以从本地缓存中直接读取该字体的字符尺寸数据。
第一终端从第二终端处获取原始字体的字符尺寸数据,可以包括步骤S202-S204。
步骤S202、在多个协作终端之间广播关于所述原始字体的字体查询请求以确定第二终端。
在一个例子中,当一个终端成为协作文档的协作终端时,会广播“加入协作”的通知信息;相应地,在一个终端退出协作不再作为该协作文档的协作终端时,会广播“退出协作”的通知信息。这样,协作文档的协作终端可以根据接收到的通知信息确定协作终端的数量。例如,所述协作终端的数量为收到的“加入协作”的通知信息的数量与收到的“退出协作”的通知信息的数量之差。在第一终端不支持原始字体的情况下,如果协作终端的数量达到2个或者更多个,则第一终端在多个协作终端之间广播字体查询请求以确定第二终端。
第一终端在多个协作终端之间广播字体查询请求以确定第二终端的过程可以包括步骤S2022-S2024。
步骤S2022、在多个协作终端之间广播字体查询请求以确定支持原始字体的协作终端作为候选终端。
步骤S2024、在候选终端的数量等于1的情况下,将候选终端确定为第二终端。在候选终端的数量大于1的情况下,将满足预设条件的候选终端确定为第二终端。
该预设条件可以至少包括如下条件a-c中的一项:
条件a、与第一终端之间通信质量最佳的候选终端。例如,可以将与第一终端之间的网络延迟最低的候选终端确定为通信质量最佳的候选终端。
条件b、接收字体协助请求数量最少的候选终端。接收字体协助请求数量最少的候选终端相对比较空闲,将其作为第二终端有利于提升整体效率。
条件c、提交字体查询请求数量最少的候选终端。提交字体查询请求数量最少的候选终端相对比较空闲,将其作为第二终端有利于提升整体效率。
在一个例子中,第一终端发现其不支持原始字体,也就是第一终端本地缺失原始字体时,创建信息队列将字体查询请求加入信息队列,从而在协作文档的多个协作终端之中广播字体查询请求。协作文档的每个协作终端在接收到该字体查询请求时,确定自己是否支持原始字体,在确定自己支持原始字体的情况下向第一终端发送第一响应信息,第一响应信息表征其支持原始字体。第一终端在接收到另一个协作终端发送的对字体查询请求的第一响应信息时,可以将该协作终端确定为第二终端。
步骤S204、向第二终端发送关于所述原始字体的字体协助请求,以从第二终端处获取原始字体的字符尺寸数据。
第一终端向第二终端发送字体协助请求,第二终端在接收到字体协助请求时,向第一终端发送原始字体对应的字符尺寸数据。在一个例子中,第二终端在接收到字体协助请求时,对原始字体进行字符测量操作以得到原始字体的字符尺寸数据。
步骤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的排版,第一终端使用第一字体显示的这段内容的总宽度和原始字体下的这段内容的总宽度更为接近。通过这种方式,可以保证原始字体下的同一行内容,不会因为改为使用第一字体进行显示而分行,进而避免了由于排版差异而导致的协作终端无法同步协作的问题。
本公开实施例的一个有益效果在于,对于在线多人协作的协作文档,如果某个协作终端不支持协作文档中目标文本的原始字体,则可以使用该协作终端支持的第一字体来显示目标文本并且根据原始字体对应的字符尺寸数据对该协作终端显示的目标文本进行排版,使得该协作终端在缺失原始字体的情况下仍可以和其它协作终端保持排版一致性。
第一终端在获取原始字体的字符尺寸数据失败的情况下,所述方法还可以包括步骤S902-S904。
步骤S902、确定第一终端是否支持目标字体。目标字体是多个协作终端在多个协 作终端均不支持原始字体的情况下,基于预设协商机制在候选字体中确定出的一种字体,候选字体为任一个协作终端支持的字体。
例如,可将第一个发出字体查询请求的协作终端所支持的字体确定为目标字体。第一个发出字体查询请求的协作终端通常相对空闲,相比其他协作终端效率更高。又例如,可确定每一种候选字体的分数,将分数最高的候选字体确定为目标字体。其中,候选字体的分数为支持该候选字体的协作终端的数量。
步骤S904、第一终端在支持目标字体的情况下,以目标字体显示目标文本。第一终端在不支持目标字体的情况下,从第三终端处获取目标字体的字符尺寸数据,以第一终端支持的第二字体显示目标文本并且根据目标字体的字符尺寸数据对以第二字体显示的目标文本进行排版,第三终端是支持目标字体的协作终端。其中,第二字体为第一终端支持的与目标字体最匹配的字体。第二字体的确定过程,可与前述确定第一字体的过程类似。特别地,第二字体可与第一字体相同。
第一终端从第三终端处获取目标字体的字符尺寸数据的过程,类似于前述的第一终端从第二终端处获取原始字体的字符尺寸数据的过程。
本公开实施例的一个有益效果在于,对于在线多人协作的协作文档,如果全部协作终端均不支持协作文档中目标文本的原始字体,可以基于预设协商机制确定出一种字体作为目标字体,各协作终端统一使用目标字体显示目标文本,从而使得各协作终端在缺失原始字体的情况下仍可以和其它协作终端保持排版一致性。
第一终端在支持原始字体的情况下,所述方法还可以包括:第一终端以原始字体显示目标文本并且向第四终端发送原始字体的字符尺寸数据,第四终端是不支持原始字体的协作终端。
在一个例子中,在第一终端支持原始字体的情况下,如果第一终端接收到第四终端的字体协助请求,向第四终端发送原始字体对应的字符尺寸数据。在一个例子中,在第一终端支持原始字体的情况下,第一终端可以在多个协作终端之间分享原始字体的字符尺寸数据。
<设备实施例>
本公开实施例提供了一种文本的排版装置,应用于协作文档的多个协作终端,包括以下模块。
第一确定模块,用于确定协作文档中目标文本使用的原始字体。
第二确定模块,用于确定多个协作终端中的第一终端是否支持原始字体。
第一获取模块,用于在第一终端不支持原始字体的情况下,获取原始字体的字符尺寸数据。
第一排版模块,用于在获取原始字体的字符尺寸数据成功的情况下,根据原始字体的字符尺寸数据对以所述第一字体显示的目标文本进行排版。
在一个例子中,第一终端获取原始字体的字符尺寸数据,包括:第一终端获取第二终端在多个协作终端之间分享的原始字体的字符尺寸数据。
在一个例子中,第一终端获取原始字体的字符尺寸数据,包括:在第一终端的本地缓存中查询原始字体的字符尺寸数据;或者,从第二终端处获取原始字体的字符尺寸数据,第二终端是多个写作终端中支持原始字体的协作终端。
在一个例子中,第一终端获取原始字体的字符尺寸数据,包括:在第一终端的本地缓存中查询原始字体的字符尺寸数据;所述第一终端在其本地缓存中查询不到原始字体的字符尺寸数据的情况下,从第二终端处获取原始字体的字符尺寸数据,第二终端是多个协作终端中支持原始字体的协作终端。
在一个例子中,第一获取模块包括第一请求模块和第二请求模块。
第一请求模块用于在多个协作终端之间广播字体查询请求以确定第二终端。
第二请求模块用于向第二终端发送字体协助请求,以从第二终端处获取原始字体的字符尺寸数据。
第一请求模块在多个协作终端之间广播字体查询请求以确定第二终端,包括:在多个协作终端之间广播字体查询请求,以确定支持原始字体的协作终端作为候选终端;在候选终端的数量等于1的情况下,将候选终端确定为第二终端;在候选终端的数量大于1的情况下,将满足预设条件的候选终端确定为第二终端。
在一个例子中,第一终端还包括第三确定模块、第二获取模块和第二排版模块。
第三确定模块用于在第一终端在获取原始字体的字符尺寸数据失败的情况下,确定第一终端是否支持目标字体。目标字体是多个协作终端在多个协作终端均不支持原始字体的情况下,基于预设协商机制在候选字体中确定出的一种字体,候选字体为任一个协作终端支持的字体;
第二获取模块用于在第三确定模块确定第一终端不支持目标字体的情况下,从第三终端处获取目标字体的字符尺寸数据。
第二排版模块用于在第三确定模块确定第一终端支持目标字体的情况下,以目标字体显示目标文本。以及,在第三确定模块确定第一终端不支持目标字体的情况下,以第一终端支持的第二字体显示目标文本,第三终端是多个协作终端中支持所述目标字体的协作终端;并且根据目标字体的字符尺寸数据,对以所述第一终端支持的第一字体显示的目标文本进行排版。
在一个例子中,第一终端还包括发送模块。
发送模块用于在第一终端支持原始字体的情况下,以原始字体显示目标文本并且向第四终端发送原始字体的字符尺寸数据。第四终端是多个协作终端中不支持原始字体的协作终端。
在一个例子中,第一排版模块根据原始字体的字符尺寸数据对以所述第一终端支持的第一字体显示的目标文本进行排版,包括:确定目标文本的排版方向;在目标文本的排版方向为横向排版的情况下,确定第一差值,第一差值为所述目标文本在原始字体下的字符宽度和在第一字体下的字符宽度的差值;在第一差值为正值的情况下,调整目标文本的字符的横坐标值;在第一差值为负值的情况下,对目标文本的字符进行缩小处 理。在目标文本的排版方向为竖向排版的情况下,确定第二差值,第二差值为所述目标文本在原始字体下的字符高度和在第一字体下的字符高度的差值;在第二差值为正值的情况下,调整目标文本的字符的纵坐标值;在第二差值为负值的情况下,对目标文本的字符进行缩小处理。
在一个例子中,第一排版模块根据原始字体的字符尺寸数据对以所述第一终端支持的第一字体显示的目标文本进行排版,包括:确定目标文本的排版方向;在目标文本的排版方向为横向排版的情况下,对目标文本在所述第一字体下的字符进行第一缩放处理以使得目标文本在所述第一字体下的字符宽度和在原始字体下的字符宽度一致;在目标文本的排版方向为竖向排版的情况下,对目标文本在所述第一字体下的字符进行第二缩放处理以使得目标文本在所述第一字体下的字符高度和在原始字体下的字符高度一致。
在一个例子中,第一排版模块根据原始字体的字符尺寸数据对以所述第一终端支持的第一字体显示的目标文本进行排版,包括:确定目标文本的排版方向;在目标文本的排版方向为横向排版的情况下,将目标文本在所述第一字体下的字号调整为第一字号,第一字号是所述目标文本在第一字体下的字符宽度与在原始字体下的字符宽度最接近的字号;在将目标文本的字号调整为第一字号后,确定第一差值,第一差值为所述目标文本在原始字体下的字符宽度和在第一字体下的字符宽度的差值;在第一差值为正值的情况下,调整目标文本的字符的横坐标值;在第一差值为负值的情况下,对目标文本的字符进行缩小处理;在目标文本的排版方向为竖向排版的情况下,将目标文本的字号调整为第二字号,第二字号是所述目标文本在第一字体下的字符高度与在原始字体下的字符高度最接近的字号;在将目标文本的字号调整为第二字号后,确定第二差值,第二差值为所述目标文本在原始字体下的字符高度和在第一字体下的字符高度的差值;在第二差值为正值的情况下,调整目标文本的字符的纵坐标值;在第二差值为负值的情况下,对目标文本的字符进行缩小处理。
图5是根据一个实施例的电子设备的硬件结构示意图。
如图5所示,该电子设备800包括处理器801和存储器802,该存储器802用于存储可执行的计算机程序,该处理器801用于执行所述计算机程序,以实现以上任意方法实施例的文本的排版方法。
该电子设备800可以是计算机、手机、平板电脑等设备。
<计算机可读存储介质>
本公开实施例还提供了一种计算机可读存储介质,计算机可读存储介质上存储计算机程序,计算机程序在被处理器执行时实现根据以上任意方法实施例的文本的排版方法。
本公开可以是系统、方法和/或计算机程序产品。计算机程序产品可以包括计算机可读存储介质,其上载有用于使处理器实现本公开的各个方面的计算机可读程序指令。
计算机可读存储介质可以是可以保持和存储由指令执行设备使用的指令的有形设备。计算机可读存储介质例如可以是――但不限于――电存储设备、磁存储设备、光存 储设备、电磁存储设备、半导体存储设备或者上述的任意合适的组合。计算机可读存储介质的更具体的例子(非穷举的列表)包括:便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、静态随机存取存储器(SRAM)、便携式压缩盘只读存储器(CD-ROM)、数字多功能盘(DVD)、记忆棒、软盘、机械编码设备、例如其上存储有指令的打孔卡或凹槽内凸起结构、以及上述的任意合适的组合。这里所使用的计算机可读存储介质不被解释为瞬时信号本身,诸如无线电波或者其他自由传播的电磁波、通过波导或其他传输媒介传播的电磁波(例如,通过光纤电缆的光脉冲)、或者通过电线传输的电信号。
这里所描述的计算机可读程序指令可以从计算机可读存储介质下载到各个计算/处理设备,或者通过网络、例如因特网、局域网、广域网和/或无线网下载到外部计算机或外部存储设备。网络可以包括铜传输电缆、光纤传输、无线传输、路由器、防火墙、交换机、网关计算机和/或边缘服务器。每个计算/处理设备中的网络适配卡或者网络接口从网络接收计算机可读程序指令,并转发该计算机可读程序指令,以供存储在各个计算/处理设备中的计算机可读存储介质中。
用于执行本公开操作的计算机程序指令可以是汇编指令、指令集架构(ISA)指令、机器指令、机器相关指令、微代码、固件指令、状态设置数据、或者以一种或多种编程语言的任意组合编写的源代码或目标代码,所述编程语言包括面向对象的编程语言—诸如Smalltalk、C++等,以及常规的过程式编程语言—诸如“C”语言或类似的编程语言。计算机可读程序指令可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络—包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。在一些实施例中,通过利用计算机可读程序指令的状态信息来个性化定制电子电路,例如可编程逻辑电路、现场可编程门阵列(FPGA)或可编程逻辑阵列(PLA),该电子电路可以执行计算机可读程序指令,从而实现本公开的各个方面。
这里参照根据本公开实施例的方法、装置(系统)和计算机程序产品的流程图和/或框图描述了本公开的各个方面。应当理解,流程图和/或框图的每个方框以及流程图和/或框图中各方框的组合,都可以由计算机可读程序指令实现。
这些计算机可读程序指令可以提供给通用计算机、专用计算机或其它可编程数据处理装置的处理器,从而生产出一种机器,使得这些指令在通过计算机或其它可编程数据处理装置的处理器执行时,产生了实现流程图和/或框图中的一个或多个方框中规定的功能/动作的装置。也可以把这些计算机可读程序指令存储在计算机可读存储介质中,这些指令使得计算机、可编程数据处理装置和/或其他设备以特定方式工作,从而,存储有指令的计算机可读介质则包括一个制造品,其包括实现流程图和/或框图中的一个或多个方框中规定的功能/动作的各个方面的指令。
也可以把计算机可读程序指令加载到计算机、其它可编程数据处理装置、或其它设备上,使得在计算机、其它可编程数据处理装置或其它设备上执行一系列操作步骤, 以产生计算机实现的过程,从而使得在计算机、其它可编程数据处理装置、或其它设备上执行的指令实现流程图和/或框图中的一个或多个方框中规定的功能/动作。
附图中的流程图和框图显示了根据本公开的多个实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或指令的一部分,所述模块、程序段或指令的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。对于本领域技术人员来说公知的是,通过硬件方式实现、通过软件方式实现以及通过软件和硬件结合的方式实现都是等价的。
以上已经描述了本公开的各实施例,上述说明是示例性的,并非穷尽性的,并且也不限于所披露的各实施例。在不偏离所说明的各实施例的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。本文中所用术语的选择,旨在最好地解释各实施例的原理、实际应用或对市场中的技术改进,或者使本技术领域的其它普通技术人员能理解本文披露的各实施例。本公开的范围由所附权利要求来限定。

Claims (16)

  1. 一种文本的排版方法,应用于协作文档的多个协作终端,其特征在于,包括:
    确定所述协作文档中目标文本使用的原始字体;
    确定所述多个协作终端中的第一终端是否支持所述原始字体;
    所述第一终端在所述第一终端不支持所述原始字体的情况下,获取所述原始字体的字符尺寸数据;
    所述第一终端在获取所述原始字体的字符尺寸数据成功的情况下,以所述第一终端支持的第一字体显示所述目标文本;且
    所述第一终端根据所述原始字体的字符尺寸数据对以所述第一字体显示的所述目标文本进行排版。
  2. 根据权利要求1所述的方法,其特征在于,所述第一终端获取所述原始字体的字符尺寸数据,包括:
    所述第一终端获取所述多个协作终端中的第二终端在所述多个协作终端之间分享的所述原始字体的字符尺寸数据。
  3. 根据权利要求1所述的方法,其特征在于,所述第一终端获取所述原始字体的字符尺寸数据,包括:
    在所述第一终端的本地缓存中查询所述原始字体的字符尺寸数据;或者,
    从第二终端处获取所述原始字体的字符尺寸数据,所述第二终端是所述多个协作终端中支持所述原始字体的协作终端。
  4. 根据权利要求1所述的方法,其特征在于,所述第一终端获取所述原始字体的字符尺寸数据,包括:
    在所述第一终端的本地缓存中查询所述原始字体的字符尺寸数据;
    在所述第一终端的本地缓存中查询不到所述原始字体的字符尺寸数据的情况下,从第二终端处获取所述原始字体的字符尺寸数据,所述第二终端是所述多个协作终端中支持所述原始字体的协作终端。
  5. 根据权利要求3-4任一项所述的方法,其特征在于,所述第一终端从第二终端处获取所述原始字体的字符尺寸数据,包括:
    所述第一终端在所述多个协作终端之间广播字体查询请求以确定所述第二终端;
    所述第一终端向所述第二终端发送字体协助请求,以从所述第二终端处获取所述原始字体的字符尺寸数据。
  6. 根据权利要求5所述的方法,其特征在于,所述第一终端在所述多个协作终端之间广播字体查询请求以确定所述第二终端,包括:
    在多个协作终端之间广播字体查询请求,以确定支持所述原始字体的协作终端作为候选终端;
    在候选终端的数量等于1的情况下,将所述候选终端确定为所述第二终端;
    在候选终端的数量大于1的情况下,将满足预设条件的所述候选终端确定为第二终端。
  7. 根据权利要求6所述的方法,其特征在于,所述预设条件至少包括以下任一项:
    所述候选终端与所述第一终端之间的通信质量最佳;
    所述候选终端接收到的所述字体协助请求的数量最少;
    所述候选终端提交的所述字体查询请求的数量最少。
  8. 根据权利要求1所述的方法,其特征在于,所述第一终端在获取所述原始字体的字符尺寸数据失败的情况下,所述方法还包括:
    确定所述第一终端是否支持目标字体,所述目标字体是所述多个协作终端在所述多个协作终端均不支持所述原始字体的情况下,基于预设协商机制在候选字体中确定出的一种字体,所述候选字体为任一个协作终端支持的字体;
    所述第一终端在支持所述目标字体的情况下,以所述目标字体显示所述目标文本;
    所述第一终端在不支持所述目标字体的情况下,从第三终端处获取所述目标字体的字符尺寸数据,以所述第一终端支持的第二字体显示所述目标文本,所述第三终端是所述多个协作终端中支持所述目标字体的协作终端;并且
    所述第一终端根据所述目标字体的字符尺寸数据,对以所述第二字体显示的所述目标文本进行排版。
  9. 根据权利要求8所述的方法,其特征在于,所述多个协作终端在所述多个协作终端均不支持所述原始字体的情况下,基于预设协商机制在候选字体中确定出目标字体,包括以下任一:
    将所述多个协作终端中第一个发出字体查询请求的协作终端所支持的字体确定为所述目标字体;
    确定每一种所述候选字体的分数,将分数最高的所述候选字体确定为所述目标字体,每一种所述候选字体的分数根据支持所述候选字体的协作终端的数量。
  10. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    所述第一终端在支持所述原始字体的情况下,以所述原始字体显示所述目标文本;并且
    所述第一终端向第四终端发送所述原始字体的字符尺寸数据,所述第四终端是所述多个协作终端中不支持所述原始字体的协作终端。
  11. 根据权利要求1所述的方法,其特征在于,所述原始字体的字符尺寸数据包括所述原始字体的字符宽度和所述原始字体的字符高度;
    所述第一终端根据所述原始字体的字符尺寸数据对以所述第一字体显示的所述目标文本进行排版,包括:
    确定所述目标文本的排版方向;
    在所述目标文本的排版方向为横向排版的情况下,确定第一差值,所述第一差值为所述目标文本在所述原始字体下的字符宽度和在所述第一字体下的字符宽度的差值;在所述第一差值为正值的情况下,调整所述目标文本的字符的横坐标值;在所述第一差值为负值的情况下,对所述目标文本的字符进行缩小处理;
    在所述目标文本的排版方向为竖向排版的情况下,确定第二差值,所述第二差值为所述目标文本在所述原始字体下的字符高度和在所述第一字体下的字符高度的差值;在所述第二差值为正值的情况下,调整所述目标文本的字符的纵坐标值;在所述第二差值为负值的情况下,对所述目标文本的字符进行缩小处理。
  12. 根据权利要求1所述的方法,其特征在于,所述原始字体的字符尺寸数据包括所述原始字体的字符宽度和所述原始字体的字符高度;
    所述第一终端根据所述原始字体的字符尺寸数据对以所述第一字体显示的所述目 标文本进行排版,包括:
    确定所述目标文本的排版方向;
    在所述目标文本的排版方向为横向排版的情况下,对所述目标文本在所述第一字体下的字符进行第一缩放处理以使得所述目标文本在所述第一字体下的字符宽度和在所述原始字体下的字符宽度一致;
    在所述目标文本的排版方向为竖向排版的情况下,对所述目标文本在所述第一字体下的字符进行第二缩放处理以使得所述目标文本在所述第一字体下的字符高度和在所述原始字体下的字符高度一致。
  13. 根据权利要求1所述的方法,其特征在于,所述原始字体的字符尺寸数据包括所述原始字体的字符宽度和所述原始字体的字符高度;
    所述第一终端根据所述原始字体的字符尺寸数据对以所述第一字体显示的所述目标文本进行排版,包括:
    确定所述目标文本的排版方向;
    在所述目标文本的排版方向为横向排版的情况下,将所述目标文本在第一字体下的字号调整为第一字号,所述第一字号是所述目标文本在第一字体下的字符宽度与在所述原始字体下的字符宽度最接近的字号;在将所述目标文本的字号调整为第一字号后,确定第一差值,所述第一差值为所述目标文本在所述原始字体下的字符宽度和在所述第一字体下的字符宽度的差值;在所述第一差值为正值的情况下,调整所述目标文本的字符的横坐标值;在所述第一差值为负值的情况下,对所述目标文本的字符进行缩小处理;
    在所述目标文本的排版方向为竖向排版的情况下,将所述目标文本在第一字体下的字号调整为第二字号,所述第二字号是所述目标文本在第一字体下的字符高度与在所述原始字体下的字符高度最接近的字号;在将所述目标文本的字号调整为第二字号后,确定第二差值,所述第二差值为所述目标文本在所述原始字体下的字符高度和在所述第一字体下的字符高度的差值;在所述第二差值为正值的情况下,调整所述目标文本的字符的纵坐标值;在所述第二差值为负值的情况下,对所述目标文本的字符进行缩小处理。
  14. 一种文本的排版装置,应用于协作文档的多个协作终端,其特征在于,包括:
    第一确定模块,用于确定所述协作文档中目标文本使用的原始字体;
    第二确定光模块,用于确定所述多个协作终端中的第一终端是否支持所述原始字体;
    获取模块,用于在所述第一终端不支持所述原始字体的情况下,获取所述原始字体的字符尺寸数据;
    排版模块,用于在获取所述原始字体的字符尺寸数据成功的情况下,以所述第一终端支持的第一字体显示所述目标文本并且根据所述原始字体的字符尺寸数据对以所述第一字体显示的所述目标文本进行排版。
  15. 一种电子设备,其特征在于,包括存储器和处理器,所述存储器用于存储计算机程序;所述处理器用于执行所述计算机程序,以实现权利要求1-12中任意一项所述的方法。
  16. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储计算机程序,所述计算机程序在被处理器执行时实现权利要求1-12中任意一项所述的方法。
PCT/CN2021/142056 2021-08-26 2021-12-28 文本的排版 WO2023024377A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110990091.8A CN113642290A (zh) 2021-08-26 2021-08-26 文本的排版方法和装置、电子设备及存储介质
CN202110990091.8 2021-08-26

Publications (1)

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

Family

ID=78424039

Family Applications (1)

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

Country Status (2)

Country Link
CN (1) CN113642290A (zh)
WO (1) WO2023024377A1 (zh)

Families Citing this family (2)

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

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW201243624A (en) * 2011-04-26 2012-11-01 Zeon Corp The process for solving the font missing problem
CN103699520A (zh) * 2012-09-27 2014-04-02 茵弗维尔株式会社 用于维持电子文档布局的字体处理方法
CN103902513A (zh) * 2014-03-21 2014-07-02 北京百度网讯科技有限公司 在终端设备中显示字体的方法及装置
CN111199137A (zh) * 2018-10-30 2020-05-26 广州金山移动科技有限公司 一种云端字体加载方法、装置及电子设备
CN113642290A (zh) * 2021-08-26 2021-11-12 珠海金山办公软件有限公司 文本的排版方法和装置、电子设备及存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW201243624A (en) * 2011-04-26 2012-11-01 Zeon Corp The process for solving the font missing problem
CN103699520A (zh) * 2012-09-27 2014-04-02 茵弗维尔株式会社 用于维持电子文档布局的字体处理方法
CN103902513A (zh) * 2014-03-21 2014-07-02 北京百度网讯科技有限公司 在终端设备中显示字体的方法及装置
CN111199137A (zh) * 2018-10-30 2020-05-26 广州金山移动科技有限公司 一种云端字体加载方法、装置及电子设备
CN113642290A (zh) * 2021-08-26 2021-11-12 珠海金山办公软件有限公司 文本的排版方法和装置、电子设备及存储介质

Also Published As

Publication number Publication date
CN113642290A (zh) 2021-11-12

Similar Documents

Publication Publication Date Title
JP6293142B2 (ja) データを消費型コンテンツに変換するときにバリエーションを生じさせること
US9208216B2 (en) Transforming data into consumable content
WO2023024377A1 (zh) 文本的排版
US9015578B2 (en) Dynamic optimization of available display space
US8595643B2 (en) Scrolling a subsequently displayed block with a delay from a previously displayed block
US9880989B1 (en) Document annotation service
US20100095198A1 (en) Shared comments for online document collaboration
US20160092406A1 (en) Inferring Layout Intent
US11954455B2 (en) Method for translating words in a picture, electronic device, and storage medium
US20150058708A1 (en) Systems and methods of character dialog generation
US11080322B2 (en) Search methods, servers, and systems
US10235348B2 (en) Assistive graphical user interface for preserving document layout while improving the document readability
US10121154B2 (en) Information display apparatus, distribution apparatus, information display method, and non-transitory computer readable storage medium
US10552535B1 (en) System for detecting and correcting broken words
US20140236568A1 (en) Input method to support multiple languages
US11397844B2 (en) Computer based unitary workspace leveraging multiple file-type toggling for dynamic content creation
WO2023024376A1 (zh) 文本的排版
US20140136943A1 (en) Rendering web content within documents
CN107368465B (zh) 一种用于流式文档的截图类笔记处理的系统及方法
JP2019021255A (ja) デジタル出版システム、デジタル出版方法及びコンピュータプログラム
CN105760354B (zh) 电子图书中笔记数据重定位方法与装置
GB2532822A (en) Techniques for providing a user interface incorporating sign language
CN113553123B (zh) 数据处理方法、装置、电子设备及存储介质
US20230305673A1 (en) Computer based unitary workspace leveraging multiple file-type toggling for dynamic content creation
CN115203398A (zh) 一种文档处理方法、装置、电子设备及存储介质

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: 21954892

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2021954892

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2021954892

Country of ref document: EP

Effective date: 20240228

NENP Non-entry into the national phase

Ref country code: DE