Text typesetting method and device, electronic device and storage medium
By obtaining and using character size data of supported fonts, the problem of typesetting differences caused by missing fonts in online collaborative documents is solved, and the aesthetics and consistent reading experience of the document are achieved, which is suitable for online documents editing.
Patent Information
- Application Number
- CN202110990091.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-26
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2041-08-26
AI Technical Summary
In online collaborative documents, the lack of fonts will lead to differences in typesetting methods, affecting the aesthetics of the document and the consistency of reading experience. The existing solutions are costly and difficult to promote on a large scale.
Ensure consistency of typesetting by determining the original font used by the target text in the collaborative document and obtaining its character size data at the terminal that the font does not support.
In the absence of the original font, use supported fonts to type in order to maintain the consistency of online collaborative documents, and is suitable for online documents editing.
Smart Images

Figure CN113642290B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and more particularly, to a text typesetting method and device, an electronic device, and a storage medium. Background Art
[0002] Nowadays, more and more applications have introduced online collaborative document functions, such as multi-person editing and viewing of online documents. In this case, when one or more users view the same online document on different devices, if a certain font is missing, the document's layout may be significantly different, affecting the document's aesthetics and consistency in the reading experience. The current common practice is to install the corresponding fonts in the current environment to achieve the purpose of solving the typesetting problem. However, this method has high costs and thresholds, and requires searching, downloading, and installing fonts. Fonts may also need to be paid for separately, making it difficult to promote and apply on a large scale. Therefore, it is necessary to propose a new text typesetting method. Summary of the Invention
[0003] One purpose of the embodiments of the present disclosure is to provide a new technical solution for text typesetting, so as to maintain typesetting consistency of online collaborative documents in the event of missing fonts.
[0004] According to a first aspect of the present disclosure, a text typesetting method is provided. The method comprises: determining an original font used by a target text in a collaborative document;
[0005] determining whether a first terminal supports the original font, the first terminal being one of a plurality of collaborative terminals of the collaborative document;
[0006] acquiring, by the first terminal, character size data of the original font when the first terminal does not support the original font;
[0007] When the first terminal successfully obtains the character size data of the original font, the first terminal displays the target text in a first font supported by the first terminal and typesets the target text according to the character size data of the original font.
[0008] Optionally, the first terminal obtains the character size data of the original font, including:
[0009] The character size data of the original font shared by another cooperative terminal among the plurality of cooperative terminals is acquired.
[0010] Optionally, the first terminal obtains the character size data of the original font, including:
[0011] querying the character size data of the original font in the local cache of the first terminal; or,
[0012] The character size data of the original font is acquired from a second terminal, where the second terminal is a cooperative terminal that supports the original font.
[0013] Optionally, the first terminal obtains the character size data of the original font, including:
[0014] querying the character size data of the original font in the local cache of the first terminal;
[0015] When the character size data of the original font cannot be found, the character size data of the original font is acquired from a second terminal, where the second terminal is a cooperative terminal that supports the original font.
[0016] Optionally, obtaining the character size data of the original font from the second terminal includes:
[0017] broadcasting a font query request among a plurality of cooperating terminals to determine a second terminal;
[0018] A font assistance request is sent to the second terminal to obtain character size data of the original font from the second terminal.
[0019] Optionally, broadcasting the font query request among the multiple cooperative terminals to determine the second terminal includes:
[0020] broadcasting a font query request among a plurality of cooperative terminals to determine a cooperative terminal that supports the original font, and taking the cooperative terminal that supports the original font as a candidate terminal;
[0021] When the number of candidate terminals is equal to 1, determining the candidate terminal as the second terminal;
[0022] When the number of candidate terminals is greater than 1, a candidate terminal that meets a preset condition is determined as the second terminal.
[0023] Optionally, when the first terminal fails to obtain the character size data of the original font, the method further includes:
[0024] Determining whether the first terminal supports a target font, where the target font is a font determined by multiple collaborative terminals from candidate fonts based on a preset negotiation mechanism when none of the multiple collaborative terminals support the original font, and the candidate font is a font supported by any of the collaborative terminals;
[0025] The first terminal displays the target text in the target font if it supports the target font;
[0026] When the first terminal does not support the target font, it obtains the character size data of the target font from a third terminal, displays the target text in the target font, and typesets the target text according to the character size data of the target font. The third terminal is a collaborative terminal that supports the target font.
[0027] Optionally, when none of the collaborative terminals support the original font, the multiple collaborative terminals determine a target font from candidate fonts based on a preset negotiation mechanism, including:
[0028] Determine the font supported by the first collaborative terminal that issues a font query request as the target font; or
[0029] The score of each candidate font is determined, and the candidate font with the highest score is determined as the target font, where the score of the candidate font is the number of cooperative terminals that support the candidate font.
[0030] Optionally, the method further includes:
[0031] The first terminal displays the target text in the original font when supporting the original font and sends character size data of the original font to a fourth terminal that is a cooperative terminal that does not support the original font.
[0032] Optionally, the character size data of the original font includes a character width of the original font and a character height of the original font;
[0033] The first terminal typeset the target text according to the character size data of the original font, including:
[0034] determining a typesetting direction of the target text;
[0035] When the target text is in a horizontal typesetting direction, determining a first difference, the first difference being the difference between the character width of the original font and the character width of the first font; when the first difference is a positive value, adjusting the horizontal coordinate value of the character of the target text; and when the first difference is a negative value, reducing the character of the target text;
[0036] When the typesetting direction of the target text is vertical typesetting, determine a second difference, which is the difference between the character height of the original font and the character height of the first font; when the second difference is a positive value, adjust the vertical coordinate value of the character of the target text; when the second difference is a negative value, shrink the character of the target text.
[0037] Optionally, the character size data of the original font includes a character width of the original font and a character height of the original font;
[0038] The first terminal typeset the target text according to the character size data of the original font, including:
[0039] determining a typesetting direction of the target text;
[0040] When the target text is in a horizontal typesetting direction, performing a first scaling process 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;
[0041] In a case where the target text is arranged in a vertical direction, a 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.
[0042] Optionally, the character size data of the original font includes a character width of the original font and a character height of the original font;
[0043] The first terminal typeset the target text according to the character size data of the original font, including:
[0044] determining a typesetting direction of the target text;
[0045] When the target text is in a horizontal typesetting direction, the font size of the target text is adjusted to a first font size, the first font size being a font size having a character width closest to a character width of the original font; after the font size of the target text is adjusted to the first font size, a first difference is determined, the first difference being a difference between a character width of the original font and a character width of the first font; when the first difference is a positive value, the horizontal coordinate value of the character of the target text is adjusted; when the first difference is a negative value, the character of the target text is reduced in size;
[0046] When the typesetting direction of the target text is vertical typesetting, the font size of the target text is adjusted to a second font size, and the second font size is a font size whose character height is closest to the character height of the original font; after the font size of the target text is adjusted to the second font size, a second difference is determined, and the second difference is the difference between the character height of the original font and the character height of the first font; when the second difference is a positive value, the vertical coordinate value of the character of the target text is adjusted; when the second difference is a negative value, the character of the target text is reduced.
[0047] According to a second aspect of the present disclosure, a text typesetting device is provided. The device comprises:
[0048] A first determining module is used to determine the original font used by the target text in the collaborative document;
[0049] a second determining optical module, configured to determine whether a first terminal supports the original font, the first terminal being one of the plurality of collaborative terminals of the collaborative document;
[0050] an acquisition module, configured to acquire character size data of the original font if the first terminal does not support the original font;
[0051] A typesetting module is configured to, if the character size data of the original font is successfully acquired, display the target text in a first font supported by the first terminal and typeset the target text according to the character size data of the original font.
[0052] According to a third aspect of the present disclosure, an electronic device is further provided, comprising a memory and a processor, wherein the memory is configured to store a computer program, and the processor is configured to execute the computer program to implement the method of the first aspect of the present disclosure.
[0053] According to a fourth aspect of the present disclosure, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to the first aspect of the present disclosure is implemented.
[0054] One beneficial effect of the embodiments of the present disclosure is that, for a collaborative document involving multiple people working together online, if a collaborative terminal does not support the original font of the target text in the collaborative document, the target text can be displayed using the first font it supports and the target text can be typeset according to the character size data corresponding to the original font. This allows the collaborative terminal to maintain typesetting consistency with other collaborative terminals even when the original font is missing. The text typesetting method provided by the embodiments of the present disclosure is suitable for multi-person editing of online documents.
[0055] Other features and advantages of the embodiments of the present disclosure will become apparent from the following detailed description of exemplary embodiments of the present disclosure with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the embodiments of the present disclosure.
[0057] Figure 1 A schematic diagram of an online document collaboration system provided by an embodiment of the present disclosure;
[0058] Figure 2 A flow chart of a method for typesetting text provided by an embodiment of the present disclosure;
[0059] FIG3( a ) and FIG3 ( b ) are schematic diagrams of character size data provided by an embodiment of the present disclosure;
[0060] Figure 4 is an example diagram of a text typesetting method provided by an embodiment of the present disclosure;
[0061] Figure 5 is a schematic diagram of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0062] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that unless otherwise specifically stated, the relative arrangement of components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present disclosure.
[0063] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present disclosure, its application, or uses.
[0064] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered part of the specification.
[0065] In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not limiting. Therefore, other examples of the exemplary embodiments may have different values.
[0066] It should be noted that like reference numerals and letters refer to like items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0067] <Text layout method>
[0068] Figure 1 is a block diagram of an online document collaboration system provided by an embodiment of the present disclosure. Figure 1 As shown, the online document collaboration system includes multiple terminal devices, and the multiple terminal devices can communicate with each other through a network.
[0069] The terminal device may be, for example, an electronic device installed with an intelligent operating system (e.g., Android, iOS, Windows, Linux, etc.), including but not limited to laptops, desktop computers, mobile phones, tablet computers, etc. The terminal device configuration 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) 1035, a display device 1036, an input device 1037, a speaker 1038, a microphone 1039, and a camera 1030. The processor 1031 includes but is not limited to a central processing unit (CPU), a microprocessor (MCU), etc. The memory 1032 includes but is not limited to ROM (Read Only Memory), RAM (Random Access Memory), and non-volatile memory such as a hard disk. The interface device 1033 includes but is not limited to a USB interface, a serial interface, a parallel interface, etc. The communication device 1034 may be capable of wired or wireless communication, and may specifically include WiFi, Bluetooth, 2G / 3G / 4G / 5G, etc. The GPU 1035 is used to process images. The display device 1036 includes but is not limited to an LCD screen, a touch screen, etc. The input device 1037 includes but is not limited to a keyboard, a mouse, a touch screen, etc. The configuration of the terminal device may also include only some of the above devices.
[0070] In one embodiment of the present disclosure, user A can submit a collaborative document through a terminal device and select collaborators to initiate online multi-person collaboration. Afterwards, all selected collaborators and user A can view and collaboratively edit the collaborative document using their respective terminal devices. These terminal devices are referred to as the collaborative terminals for the collaborative document.
[0071] In one embodiment of the present disclosure, online multi-person collaboration is implemented within a target application. Users submit collaborative documents within the target application and view and collaborate on them within the target application. In one example, a user pre-registers an account with the target application. After opening the target application and logging into their account using a terminal device, the user can use the online multi-person collaboration feature. The target application running on the terminal device serves as the collaborative terminal for the collaborative document.
[0072] In one example, the target application is document editing software, instant messaging software, office software, a browser, etc.
[0073] In one example, the target application can be a native application, a web application, a hybrid application, a lightweight application, etc. A native application refers to an application that can run directly on the current operating system. A web application refers to a web application that needs to run in a browser. A hybrid application is a combination of the two, usually a native application with a built-in browser. A lightweight application is an application that can be used without downloading and installing, and users can use it by searching or scanning a code.
[0074] When the same account is allowed to log in to the target application on multiple devices, each device can be considered a collaborative terminal. In other words, users with the same account can use two or more collaborative terminals to view and collaboratively edit the target document.
[0075] Figure 1 The online document collaboration system shown is merely illustrative and in no way implies any limitation on the embodiments of the present disclosure, its application, or use. Those skilled in the art will appreciate that, although multiple devices of a terminal device have been described above, the embodiments of the present disclosure may only involve some of these devices. For example, 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 based on the solutions disclosed in the embodiments of the present disclosure. How instructions control the processor to operate is a well-known technique in the art and will not be described in detail here.
[0076] See also Figure 2 As shown, the embodiment of the present disclosure provides a text typesetting method, including steps S102 to S108. The steps S102 to S108 can be implemented by a first terminal, which is one of multiple collaborative terminals of a collaborative document.
[0077] Step S102: Determine the original font used by the target text in the collaborative document.
[0078] In the disclosed embodiments, the target text can be any portion of text in a collaborative document. In one example, the first terminal obtains the original font information of the target text from the collaborative document to determine the original font used by the target text. Generally, the original font information can be stored in the document data of the collaborative document.
[0079] Step S104: Determine whether the first terminal supports the original font.
[0080] In the embodiment of the present disclosure, after determining the original font used by the target text, the first terminal checks whether the original font is included in all fonts supported by the first terminal. If not, it is determined that the first terminal does not support the original font.
[0081] The fonts supported by the first terminal can be determined according to the font packages installed on it. In one example, if the first terminal installs a font package of a certain font, it means that the first terminal supports that font. Generally speaking, multiple widely used font packages are pre-installed in the basic data packets of terminal devices or applications, and one of the fonts can be set as the default font. If a user wants to use some niche and special fonts, they need to download the corresponding font packages separately.
[0082] Step S106: When the first terminal does not support the original font, the first terminal obtains the character size data of the original font.
[0083] In the embodiments of the present disclosure, the characters referred to include text and symbols. The symbols are not limited to punctuation marks, digital symbols, mathematical symbols, special symbols, emojis, etc.
[0084] In the embodiments of the present disclosure, the character size data of a font indicates the height and width of the character. The character size data of the original font includes the character width and character height of the original font, which are the width and height of the characters in the original font state in the target text. For the same font, at the same font size, the sizes of different characters may be designed to be the same or different. If, for the same font, at the same font size, all of its characters do not adopt the same size, a mapping relationship between the characters and their widths and heights is established, and this mapping relationship is used as the character size data. According to the mapping relationship, the character size of each character can be found.
[0085] Referring to FIGS. 3(a) and 3(b), for the same Chinese character "zao", the widths and heights of two different fonts are different at the same font size. The width and height of the font shown in FIG. 3(b) are both smaller than those of the font in FIG. 3(a).
[0086] In one example, the character size data of a font is obtained by measuring the size of the character. For example, among multiple cooperative terminals, if a certain cooperative terminal supports the original font, then this cooperative terminal can display the target text in the original font and measure the sizes of the characters in the target text in the original font, so as to obtain the character size data of the original font.
[0087] In another embodiment, the character size data of the original font is included in the original font information of the original font. Further, the character size data of the original font can be read from the original font information of the original font.
[0088] In one example, a first terminal obtains character size data of an original font shared by another collaborative terminal among multiple collaborative terminals. That is, based on an online multi-person collaborative relationship, if the first terminal does not support the original font, but a collaborative terminal other than the first terminal supports the original font, the collaborative terminal that supports the original font can share the character size data of the original font among the multiple collaborative terminals, thereby allowing the first terminal to obtain the original font size data.
[0089] In one example, the collaborative terminal that shares the character size data of the original font is the second terminal, and the second terminal supports the original font. The process of determining the second terminal among the multiple collaborative terminals can be referred to in the subsequent step S202.
[0090] In one example, the first terminal obtains the character size data of the original font by searching a local cache of the first terminal for the character size data corresponding to the original font.
[0091] In one example, the first terminal may obtain the character size data of the original font from the second terminal. In this example, after obtaining the character size data of the original font, the first terminal may store the data in a local cache so that the next time the character size data of the font is needed, the data can be directly read from the local cache.
[0092] In one example, a first terminal may obtain character size data for an original font by first querying the local cache of the first terminal for the character size data for the original font. If the character size data for the original font cannot be found, the first terminal may obtain the character size data for the original font from the second terminal. In this example, after obtaining the character size data for the original font, the first terminal may store the data in the local cache so that the next time the character size data for the font is needed, the first terminal can directly read the data from the local cache.
[0093] The first terminal obtains the character size data of the original font from the second terminal, which may include steps S202 to S204.
[0094] Step S202: broadcast a font query request among multiple cooperative terminals to determine a second terminal.
[0095] In one example, when a terminal becomes a collaborative terminal for a collaborative document, it broadcasts a "Join Collaboration" notification. When it exits collaboration and no longer serves as a collaborative terminal for the document, it broadcasts a "Leaving Collaboration" notification. The collaborative terminal can determine the number of collaborative terminals based on the received notification. If the first terminal does not support the original font and the number of collaborative terminals reaches two or more, the first terminal broadcasts a font query request among the multiple collaborative terminals to determine the second terminal.
[0096] The process in which the first terminal broadcasts a font query request among multiple cooperative terminals to determine the second terminal may include steps S2022 - S2024 .
[0097] Step S2022: broadcast a font query request among multiple collaborative terminals to determine collaborative terminals that support the original font, and use the collaborative terminals that support the original font as candidate terminals.
[0098] Step S2024: If the number of candidate terminals is equal to 1, determine the candidate terminal as the second terminal. If the number of candidate terminals is greater than 1, determine the candidate terminal that meets the preset condition as the second terminal.
[0099] The preset condition may include at least one of the following:
[0100] a. 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.
[0101] b. The candidate terminal that receives the least number of font assistance requests: The candidate terminal that receives the least number of font assistance requests is likely to be relatively idle, and using it as the second terminal is beneficial to improving overall efficiency.
[0102] c. The candidate terminal that submits the least font query requests.
[0103] In one example, when a first terminal discovers that it does not support the original font, that is, when the original font is missing, it creates an information queue and adds a font query request to the information queue, thereby broadcasting the font query request to the collaborative terminals of the collaborative document. Upon receiving the font query request, the collaborative terminal of the collaborative document determines whether it supports the original font. If so, it sends a first response message to the first terminal, indicating that it supports the original font. Upon receiving the first response message to the font query request sent by another collaborative terminal, the first terminal may determine that the collaborative terminal is the second terminal.
[0104] Step S204: Send a font assistance request to the second terminal to obtain character size data of the original font from the second terminal.
[0105] The first terminal sends a font assistance request to the second terminal. Upon receiving the font assistance request, the second terminal sends character size data corresponding to the original font to the first terminal. In one example, upon receiving the font assistance request, the second terminal performs a character measurement operation on the original font to obtain the character size data corresponding to the original font.
[0106] Step S108 : If the first terminal successfully obtains the character size data of the original font, the first terminal displays the target text in a first font supported by the first terminal and typesets the target text according to the character size data of the original font.
[0107] The first terminal typeset the target text displayed on the first terminal in the first font according to the character size data of the original font. There are many ways to do this, which are described below with examples.
[0108] Example 1:
[0109] First, a typesetting direction of the target text is determined, and the target text displayed in the first font on the first terminal is typeset according to the typesetting direction of the target text.
[0110] When the target text is in a horizontal typesetting direction, a 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. When the target text is in a vertical typesetting direction, a 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.
[0111] In Example 1, the scaling of characters can be achieved by adjusting the font size.
[0112] In one embodiment, in step S108, the target text displayed on the first terminal is typeset according to the character size data corresponding to the original font. This may be: obtaining the character size data corresponding to the first font, and typeset the target text displayed on the first terminal according to the character size data corresponding to the original font and the character size data corresponding to the first font.
[0113] Example 2:
[0114] First, a typesetting direction of the target text is determined, and the target text displayed in the first font on the first terminal is typeset according to the typesetting direction of the target text.
[0115] When the target text is in landscape orientation, a first difference is determined, where the first difference is the difference between the character width of the original font and the character width of the first font. If the first difference is positive, the horizontal coordinate values of the characters of the target text are adjusted. If the first difference is negative, the characters of the target text are reduced in size.
[0116] When the target text is typed in a vertical orientation, a second difference is determined, where the second difference is the difference between the character height of the original font and the character height of the first font. If the second difference is positive, the vertical coordinate values of the characters of the target text are adjusted. If the second difference is negative, the characters of the target text are reduced in size.
[0117] In Example 2, the reduction of characters can be achieved by adjusting the font size.
[0118] The following takes the target text's typesetting direction as horizontal as an example:
[0119] As shown in FIG3(a), the character width of each character in the original font is W1. As shown in FIG3(b), the character width of each character in the first font is W2. The difference DW between W1 and W2 is calculated as the first difference.
[0120] If DW is a positive value, it means that the character width of the first font is smaller than the character width of the original font, and the coordinate value of the horizontal coordinate of each character of the target text in the first font needs to be adjusted.
[0121] See also Figure 4 As shown in the figure, the target text is a line of content, including the 10 characters "Good morning, today's weather is great". In the original font, the coordinate values of the horizontal coordinates of the 10 characters are X1, X2, ..., X 10 After typesetting, the coordinate values of the horizontal coordinates of the 10 characters are X1', X2', ..., X 10 ',but:
[0122] X1'=X1+0.5*DW
[0123] X2'=X2+(2-1)*DW+0.5*DW,
[0124] …
[0125] X n '=X n +(n-1)*DW+0.5*DW,
[0126] …
[0127] X 10 '=X 10 +(10-1)*DW+0.5*DW,
[0128] Wherein, n is an integer, 1≤n≤10.
[0129] It can be seen that adjusting the coordinate value of the horizontal coordinate of each character in the line of content under the first font is equivalent to adjusting the spacing between adjacent characters in the line of content.
[0130] If DW is a negative value, it means that the width of the characters in the first font is greater than the width of the characters in the original font. If the coordinate values are adjusted, the characters will overlap. Therefore, the font size of the target text displayed on the first terminal needs to be reduced while maintaining the original position (coordinate value) of the target text. In one example, the font size of the target text displayed on the first terminal is reduced based on the ratio W1 / W2. For example, if W1 / W2 = R1, assuming the original font size of this content is U1, the font size of this content is adjusted to U2, where U2 = R1*U1.
[0131] The following takes the target text's typesetting direction as horizontal as an example:
[0132] As shown in FIG3(a), the character height of each character in the original font is H1. As shown in FIG3(b), the character height of each character in the first font is H2. The difference DH between H1 and H2 is calculated as the second difference.
[0133] If DH is a positive value, it means that the character height of the first font is smaller than the character height of the original font, and the coordinate value of the vertical coordinate of each character in the first font is adjusted.
[0134] Assume that the target text in the original font has a total of M lines of content, and the vertical coordinate values of the characters in each line are the same. The vertical coordinate values of the characters from the 1st to the Mth line are Y1, Y2, ..., Y M After typesetting, the vertical coordinate values of the characters from row 1 to row M are Y1', Y2', ..., Y M ',but:
[0135] Y1'=Y1+0.5*DH
[0136] Y2'=Y2+(2-1)*DH+0.5*DH,
[0137] …
[0138] Y m '=Y m +(m-1)*DH+0.5*DH,
[0139] …
[0140] Y M '=Y M+(M-1)*DH+0.5*DH,
[0141] Wherein, m is an integer, 1≤m≤M.
[0142] It can be seen that adjusting the coordinate value of the vertical coordinate 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.
[0143] If DH is a negative value, it means that the height of the characters in the first font is greater than that of the characters in the original font. Adjusting the coordinate values will cause overlap between the characters. Therefore, the font size of the target text displayed on the first terminal needs to be reduced. In one example, the font size of the target text displayed on the first terminal is reduced based on the ratio of H1 / H2, while maintaining the original position (coordinate value) of the target text. For example, if H1 / H2 = R2, assuming the original font size of the target text is U1, the font size is adjusted to U2, where U2 = R2*U1.
[0144] Example 3:
[0145] First, a typesetting direction of the target text is determined, and the target text displayed in the first font on the first terminal is typeset according to the typesetting direction of the target text.
[0146] If the target text is in landscape orientation, the font size of the target text is adjusted to a first font size, where the first font size is the font size whose character width is closest to the character width of the original font. After the target text is adjusted to the first font size, a first difference is determined, where the first difference is the difference between the character width of the original font and the character width of the first font. If the first difference is positive, the horizontal coordinate values of the characters of the target text are adjusted. If the first difference is negative, the characters of the target text are reduced in size.
[0147] That is to say, when the target text is arranged in a horizontal direction, after the first terminal adjusts the font size of the target text in the first font to the first font size, if the character width is still greater than the character width in the original font, the font size is adjusted down to make the character smaller to avoid the situation where characters overlap with each other.
[0148] When the target text is typed in a vertical orientation, the font size of the target text is adjusted to a second font size, where the second font size is the font size whose character height is closest to the character height of the original font. After the font size of the target text is adjusted to the second font size, a second difference is determined, where the second difference is the difference between the character height of the original font and the character height of the first font. If the second difference is a positive value, the vertical coordinate values of the characters of the target text are adjusted. If the second difference is a negative value, the characters of the target text are reduced in size.
[0149] That is to say, when the target text is arranged in a vertical direction, after the first terminal adjusts the font size of the target text in the first font to the second font size, if the character height is still greater than the character height in the original font, the font size is adjusted down to make the characters smaller to avoid overlapping between characters.
[0150] In Example 3, the reduction of characters can be achieved through the font size.
[0151] After the first terminal typeset the target text, the typesetting of the target text displayed by the terminal becomes closer to the typesetting of the target text displayed in the original font. Figure 4 As shown, for the target text "Good morning, the weather is great today," the total width of the content displayed in the original font is wider than that displayed in the first font. After the typesetting in step S108, the total width of the content displayed by the first terminal using the first font is closer to the total width of the content displayed in the original font. This ensures that the same line of content in the original font will not be split into lines when displayed in the first font, thereby avoiding the problem of collaborative terminals being unable to collaborate synchronously due to typesetting differences.
[0152] One beneficial effect of the embodiments of the present disclosure is that, for a collaborative document of online multi-person collaboration, if a collaborative terminal does not support the original font of the target text in the collaborative document, it can use the first font it supports to display the target text and typeset the target text according to the character size data corresponding to the original font, so that the collaborative terminal can still maintain typesetting consistency with other collaborative terminals in the absence of the original font.
[0153] In the case that the first terminal fails to obtain the character size data of the original font, the method may further include steps S902 to S904.
[0154] Step S902: Determine whether the first terminal supports the target font. The target font is a font determined by multiple collaborative terminals from candidate fonts based on a preset negotiation mechanism when none of the collaborative terminals support the original font. The candidate font is a font supported by any collaborative terminal.
[0155] For example, the font supported by the first collaborative terminal that issues a font query request is determined as the target font. For example, the score of each candidate font is determined, and the candidate font with the highest score is determined as the target font, where the score of the candidate font is the number of collaborative terminals that support the candidate font.
[0156] Step S904: If the first terminal supports the target font, the first terminal displays the target text in the target font. If the first terminal does not support the target font, the first terminal obtains character size data of the target font from a third terminal, displays the target text in the target font, and typesets the target text according to the character size data of the target font. The third terminal is a collaborative terminal that supports the target font.
[0157] 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.
[0158] One beneficial effect of the embodiments of the present disclosure is that, for collaborative documents of online multi-person collaboration, if all collaborative terminals do not support the original font of the target text in the collaborative document, a font can be determined as the target font based on a preset negotiation mechanism, and each collaborative terminal uniformly uses the target font to display the target text, so that the collaborative terminal can still maintain typesetting consistency with other collaborative terminals in the absence of the original font.
[0159] When the first terminal supports the original font, the method may further include: the first terminal displays the target text in the original font and sends character size data of the original font to a fourth terminal, where the fourth terminal is a collaborative terminal that does not support the original font.
[0160] In one example, if the first terminal supports the original font, upon receiving a font assistance request from a fourth terminal, the first terminal sends character size data corresponding to the original font to the fourth terminal. In another example, if the first terminal supports the original font, the first terminal can share the character size data of the original font among multiple collaborative terminals.
[0161] <Equipment Example>
[0162] An embodiment of the present disclosure provides a text typesetting device, which includes the following modules.
[0163] The first determining module is used to determine the original font used by the target text in the collaborative document.
[0164] The second determining module is configured to determine whether a first terminal supports the original font, where the first terminal is one of a plurality of collaborative terminals for a collaborative document.
[0165] The first acquisition module is configured to acquire character size data of the original font when the first terminal does not support the original font.
[0166] The first typesetting module is configured to display the target text in a first font supported by the first terminal and typeset the target text according to the character size data of the original font when the character size data of the original font is successfully acquired.
[0167] In one example, the first terminal obtains character size data of an original font, including: obtaining character size data of an original font shared by another collaborative terminal among multiple collaborative terminals.
[0168] In one example, the first terminal obtains the character size data of the original font, including: 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, where the second terminal is a collaborative terminal that supports the original font.
[0169] In one example, a first terminal obtains character size data of an original font, including: 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 queried, obtaining the character size data of the original font from a second terminal, where the second terminal is a collaborative terminal that supports the original font.
[0170] In one example, the first acquisition module includes a first request module and a second request module.
[0171] The first request module is configured to broadcast a font query request among a plurality of cooperative terminals to determine the second terminal.
[0172] The second request module is used 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.
[0173] The first request module broadcasts a font query request among multiple collaborative terminals to determine the second terminal, including: broadcasting a font query request among multiple collaborative terminals to determine a collaborative terminal that supports the original font, and taking the collaborative terminal that supports the original font as a candidate terminal; when the number of candidate terminals is equal to 1, determining the candidate terminal as the second terminal; when the number of candidate terminals is greater than 1, determining the candidate terminal that meets the preset conditions as the second terminal.
[0174] In one example, the first terminal further includes a third determining module, a second acquiring module, and a second typesetting module.
[0175] The third determination module is configured to determine whether the first terminal supports a target font if the first terminal fails to obtain character size data of the original font. The target font is a font determined from candidate fonts by multiple collaborative terminals based on a preset negotiation mechanism when none of the collaborative terminals support the original font. The candidate font is a font supported by any of the collaborative terminals.
[0176] The second acquisition module is configured to acquire character size data of the target font from the third terminal when the third determination module determines that the first terminal does not support the target font.
[0177] The second typesetting module is configured to display the target text in the target font if the third determination module determines that the first terminal supports the target font. Furthermore, if the third determination 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 and typeset the target text based on the character size data of the target font. The third terminal is a collaborative terminal that supports the target font.
[0178] In one example, the first terminal further includes a sending module.
[0179] 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 collaborative terminal that does not support the original font.
[0180] In one example, a first typesetting module typeset a target text based on character size data of an original font, including: determining a typesetting direction of the target text; if the typesetting direction of the target text is horizontal, determining a first difference, the first difference being the difference between the character width of the original font and the character width of the first font; if the first difference is a positive value, adjusting the horizontal coordinate values of the characters of the target text; if the first difference is a negative value, reducing the size of the characters of the target text. If the typesetting direction of the target text is vertical, determining a second difference, the second difference being the difference between the character height of the original font and the character height of the first font; if the second difference is a positive value, adjusting the vertical coordinate values of the characters of the target text; if the second difference is a negative value, reducing the size of the characters of the target text.
[0181] In one example, a first typesetting module typeset a target text according to character size data of an original font, including: determining a typesetting direction of the target text; when the typesetting direction of the target text is horizontal typesetting, performing a first scaling process 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; when the typesetting direction of the target text is vertical typesetting, performing a second scaling process 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.
[0182] In one example, a first typesetting module typeset a target text according to character size data of an original font, including: determining a typesetting direction of the target text; if the typesetting direction of the target text is horizontal typesetting, adjusting the font size of the target text to a first font size, the first font size being a font size whose character width is closest to the character width of the original font; after adjusting the font size of the target text to the first font size, determining a first difference, the first difference being a 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, adjusting the horizontal coordinate value of the character of the target text; When the first difference is a negative value, the characters of the target text are reduced in size; when the typesetting direction of the target text is vertical typesetting, the font size of the target text is adjusted to a second font size, and the second font size is a font size whose character height is closest to the character height of the original font; after the font size of the target text is adjusted to the second font size, the 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; when the second difference is a positive value, the vertical coordinate value of the characters of the target text is adjusted; when the second difference is a negative value, the characters of the target text are reduced in size.
[0183] Figure 5 is a schematic diagram of the hardware structure of an electronic device according to an embodiment.
[0184] like Figure 5 As shown, the electronic device 800 includes a processor 801 and a memory 802, wherein the memory 802 is used to store an executable computer program, and the processor 801 is used to execute the computer program to implement the text typesetting method of any of the above method embodiments.
[0185] The electronic device 800 can be a computer, a mobile phone, a tablet computer, or other devices.
[0186] <Computer-readable storage medium>
[0187] The embodiments of the present disclosure further provide a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the computer program implements the text typesetting method according to any of the above method embodiments.
[0188] The present disclosure may be a system, method and / or computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.
[0189] A computer-readable storage medium can be a tangible device that can hold and store instructions for use by an instruction execution device. A computer-readable storage medium can be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination thereof. As used herein, a computer-readable storage medium is not to be construed as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through an electrical wire.
[0190] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions to be stored in the computer-readable storage medium in each computing / processing device.
[0191] The 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 code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, and conventional procedural programming languages such as "C" language or similar programming languages. Computer-readable program instructions may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., utilizing an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be personalized by utilizing the state information of the computer-readable program instructions. The electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.
[0192] Various aspects of the present disclosure are described herein with reference to flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present disclosure. It should be understood that each block of the flowcharts and / or block diagrams, and combinations of blocks in the flowcharts and / or block diagrams, can be implemented by computer-readable program instructions.
[0193] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device is generated that implements 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, where these instructions cause the computer, programmable data processing device, and / or other device to operate in a specific manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing various aspects of the functions / actions specified in one or more blocks in the flowchart and / or block diagram.
[0194] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operational steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more blocks in the flowchart and / or block diagram.
[0195] The flowcharts and block diagrams in the accompanying drawings show the possible implementation architecture, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment or part of an instruction, and the module, program segment or part of the instruction contains one or more executable instructions for implementing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions. It is well known to those skilled in the art that implementation by hardware, implementation by software, and implementation by a combination of software and hardware are all equivalent.
[0196] The embodiments of the present disclosure have been described above. The above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terms used herein are selected to best explain the principles of the embodiments, their practical applications, or technical improvements in the marketplace, or to enable other persons skilled in the art to understand the embodiments disclosed herein. The scope of the present disclosure is defined by the appended claims.
Claims
1. A text typesetting method, characterized in that: include: Determine the original font used by the target text in the collaborative document; Determining whether a first terminal supports the original font, the first terminal being one of a plurality of collaborative terminals of the collaborative document; The first terminal acquires the character size data of the original font when the first terminal does not support the original font; When the first terminal successfully obtains the character size data of the original font, the first terminal displays the target text in a first font supported by the first terminal and typesets the target text according to the character size data of the original font. The first terminal obtains the character size data of the original font, including: querying the character size data of the original font in the local cache of the first terminal; or, acquiring character size data of the original font from a second terminal, the second terminal being a cooperative terminal supporting the original font, The step of obtaining the character size data of the original font from the second terminal includes: broadcasting a font query request among a plurality of cooperative terminals to determine a second terminal; sending a font assistance request to the second terminal to obtain character size data of the original font from the second terminal, When the first terminal fails to obtain the character size data of the original font, the method further includes: Determine whether the first terminal supports a target font, wherein the target font is a font determined from 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 first terminal displays the target text in the target font when supporting the target font; When the first terminal does not support the target font, it obtains the character size data of the target font from a third terminal, displays the target text in the target font and typesets the target text according to the character size data of the target font, and the third terminal is a collaborative terminal that supports the target font.
2. The method according to claim 1, characterized in that The first terminal obtains the character size data of the original font, including: Acquire character size data of the original font shared by another cooperative terminal among a plurality of cooperative terminals.
3. The method according to claim 1, characterized in that The first terminal obtains the character size data of the original font, including: querying the character size data of the original font in the local cache of the first terminal; When the character size data of the original font cannot be found, the character size data of the original font is acquired from a second terminal, where the second terminal is a cooperative terminal that supports the original font.
4. The method according to claim 1, characterized in that The broadcasting of the font query request among the plurality of cooperative terminals to determine the second terminal includes: Broadcasting a font query request among a plurality of cooperative terminals to determine cooperative terminals that support the original font, and taking the cooperative terminals that support the original font as candidate terminals; When the number of candidate terminals is equal to 1, determining the candidate terminal as the second terminal; When the number of candidate terminals is greater than 1, a candidate terminal that meets a preset condition is determined as the second terminal.
5. The method according to claim 1, characterized in that When none of the multiple cooperative terminals supports the original font, the multiple cooperative terminals determine a target font from candidate fonts based on a preset negotiation mechanism, including: Determine the font supported by the first collaborative terminal that issues a font query request as the target font; or, The score of each candidate font is determined, and the candidate font with the highest score is determined as the target font, wherein the score of the candidate font is the number of cooperative terminals that support the candidate font.
6. The method according to claim 1, characterized in that The method further comprises: The first terminal, in the case of supporting the original font, displays the target text in the original font and sends character size data of the original font to a fourth terminal, the fourth terminal being a cooperative terminal that does not support the original font.
7. The method according to claim 1, characterized in that The character size data of the original font includes the character width of the original font and the character height of the original font; The first terminal typeset the target text according to the character size data of the original font, including: Determining the typesetting direction of the target text; In the case where the typesetting direction of the target text is horizontal typesetting, determining a first difference value, the first difference value being the difference value between the character width of the original font and the character width of the first font; in the case where the first difference value is a positive value, adjusting the horizontal coordinate value of the character of the target text; in the case where the first difference value is a negative value, reducing the character of the target text; When the typesetting direction of the target text is vertical typesetting, determine a second difference, which is the difference between the character height of the original font and the character height of the first font; when the second difference is a positive value, adjust the vertical coordinate value of the characters of the target text; when the second difference is a negative value, shrink the characters of the target text.
8. The method according to claim 1, characterized in that The character size data of the original font includes the character width of the original font and the character height of the original font; The first terminal typeset the target text according to the character size data of the original font, including: Determining the typesetting direction of the target text; When the typesetting direction of the target text is horizontal typesetting, performing a first scaling process 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; In the case that the typesetting direction of the target text is vertical typesetting, a second scaling process is performed on the characters of the target text so that the character height of the target text is consistent with the character height of the original font.
9. The method according to claim 1, characterized in that: The character size data of the original font includes the character width of the original font and the character height of the original font; The first terminal typeset the target text according to the character size data of the original font, including: Determining the typesetting direction of the target text; When the typesetting direction of the target text is horizontal typesetting, the font size of the target text is adjusted to a first font size, the first font size being a font size whose character width is closest to the character width of the original font; after the font size of the target text is adjusted to the first font size, a first difference is determined, the first difference being the difference between the character width of the original font and the character width of the first font; when the first difference is a positive value, the horizontal coordinate value of the character of the target text is adjusted; when the first difference is a negative value, the character of the target text is reduced; When the typesetting direction of the target text is vertical typesetting, the font size of the target text is adjusted to a second font size, and the second font size is a font size whose character height is closest to the character height of the original font; after the font size of the target text is adjusted to the second font size, a second difference is determined, and the second difference is the difference between the character height of the original font and the character height of the first font; when the second difference is a positive value, the vertical coordinate value of the characters of the target text is adjusted; when the second difference is a negative value, the characters of the target text are reduced.
10. A text typesetting device, characterized in that: include: A first determination module, used to determine the original font used by the target text in the collaborative document; A second determination optical module is used to determine whether a first terminal supports the original font, the first terminal being one of a plurality of collaboration terminals of the collaboration document; An acquisition module, configured to acquire character size data of the original font when the first terminal does not support the original font; a typesetting module, configured to display the target text in a first font supported by the first terminal and typeset the target text according to the character size data of the original font when the character size data of the original font is successfully acquired, Wherein, when acquiring the character size data of the original font, the acquisition module is specifically used to: query the character size data of the original font in the local cache of the first terminal; or acquire the character size data of the original font from the second terminal, where the second terminal is a collaborative terminal that supports the original font, The acquisition module includes a first request module and a second request module, wherein the first request module is used to broadcast a font query request among a plurality of cooperative terminals to determine a second terminal; The second request module is used to send a font assistance request to the second terminal to obtain the character size data of the original font from the second terminal. The first terminal further includes a third determination module, a second acquisition module and a second layout module. The third determination module is used to determine whether the first terminal supports a target font when the first terminal fails to obtain the character size data of the original font, wherein the target font is a font determined from 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 acquisition module is used for acquiring the character size data of the target font from the third terminal when the third determination module determines that the first terminal does not support the target font; The second typesetting module is used to display the target text in the target font when the third determination module determines that the first terminal supports the target font; and to display the target text in the target font and typeset the target text according to the character size data of the target font when the third determination module determines that the first terminal does not support the target font, and the third terminal is a collaborative terminal that supports the target font.
11. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory is used to store a computer program; and the processor is used to execute the computer program to implement the method described in any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
