Font processing method and device and server
Generating preset font library and font files through local servers solves the problem of slow loading caused by large font files, and achieves faster rendering speed and simplified font management operations, improving user experience.
Patent Information
- Application Number
- CN202410163218.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-05
- Publication Date
- 2025-08-05
AI Technical Summary
The large font file size leads to slow loading speed in poor network environments, affecting the text rendering speed and reducing user experience.
Pre-created preset font library through the local server, including only common characters, generate corresponding font files, and store them on the cloud server, and the browser loads the font files according to the storage address for rendering. If the entered text is not in the preset font library, the local server updates the preset font library and font files and determines the new storage address.
It reduces the size of font files, improves loading and rendering speed, improves user experience, and supports operating font editing and offline operations in the visual interface without modifying code.
Smart Images

Figure CN120430281A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of mobile Internet technology, and in particular to a font processing method, device, and server. Background Art
[0002] Editors in related software or platforms include text style editing, which involves font management and loading. Generally, you can generate font style data for the corresponding browser by setting up font files in advance, and then render the corresponding text after loading the font files.
[0003] However, font files are generally large in size. In a poor network environment, this will affect the font file loading speed, which will affect the text rendering speed and reduce the user experience. Summary of the Invention
[0004] In order to solve or partially solve the problems existing in the related art, the present application provides a font processing method, device and server, which can improve the font file loading speed, speed up the text rendering speed, and enhance the user experience.
[0005] In a first aspect, the present application provides a font processing method, applied to a browser, the method comprising:
[0006] If the input text belongs to a preset font library, obtaining the storage address of a font file of the preset font library, wherein the preset font library is generated by a local server in advance based on commonly used characters obtained from the input file, and the font file is generated based on the preset font library;
[0007] The font file is loaded according to the storage address of the font file to render the input text.
[0008] In one embodiment, the method further comprises:
[0009] If the input text does not belong to the preset font library, the local server is notified, and the local server adds the input text to the preset font library, generates an updated preset font library and an updated font file, and determines the storage address of the updated font file;
[0010] Obtaining the storage address of the updated font file sent by the local server;
[0011] The updated font file is loaded according to the storage address of the updated font file to render the input text.
[0012] In one embodiment, the method further comprises:
[0013] After the browser detects the font preview request, obtaining the storage address of the font preview image of the preset font library;
[0014] The font preview image is loaded and displayed according to the storage address of the font preview image.
[0015] A second aspect of the present application provides a font processing method, applied to a local server, the method comprising:
[0016] Receive a request from the browser to obtain a preset font library during the page initialization phase;
[0017] The font library information of the preset font library and the storage address of the font file are returned to the browser. If the input text belongs to the preset font library, the font file is loaded according to the storage address of the font file to render the input text. The preset font library is generated by the local server in advance based on the input file to obtain common characters, and the font file is generated based on the preset font library.
[0018] In one embodiment, the method further comprises:
[0019] If the input text does not belong to the text in the preset font library, the input text is added to the preset font library, an updated preset font library and an updated font file are generated, and a storage address of the updated font file is determined;
[0020] The updated font library information of the preset font library and the storage address of the updated font file are returned to the browser, and the browser loads the updated font file according to the storage address of the updated font file to render the input text.
[0021] In one embodiment, the preset character library is generated by a local server in advance based on commonly used characters obtained from an input file, and the font file is generated based on the preset character library, including:
[0022] The local server pre-traverses the characters in the input file uploaded by the user and / or the local server itself and obtains common character combinations to generate a preset character library, and stores the preset character library in a database;
[0023] According to the text in the preset font library, the corresponding font file is extracted from the font source file, the font file of the preset font library is obtained and uploaded to the cloud server, and the cloud server generates the storage address of the font file of the preset font library in the cloud service.
[0024] In one embodiment, the method further comprises:
[0025] The local server generates a font preview image based on the font information in the font file of the preset font library and uploads it to the cloud server. The cloud server generates a storage address of the font preview image in the cloud service so that the browser can load the font preview image according to the storage address of the font preview image for display after detecting the font preview request.
[0026] In one embodiment, adding the input text to the preset font library, generating an updated preset font library and an updated font file, and determining a storage address of the updated font file includes:
[0027] Adding the input text to the preset character library, generating an updated preset character library and storing it in a database;
[0028] According to the text in the updated preset font library, the corresponding font file is extracted from the font source file, the updated font file of the preset font library is obtained and uploaded to the cloud server, and the cloud server generates the storage address of the updated font file in the cloud service.
[0029] In one embodiment, the method further comprises:
[0030] In response to an operation instruction to edit and / or take offline the fonts of the preset font library detected on a visual interface of the local server, the editing and / or taking offline operation is performed on the fonts of the preset font library.
[0031] A third aspect of the present application provides a browser device, comprising:
[0032] an acquisition module, configured to acquire a storage address of a font file of a preset font library if the input text belongs to the preset font library, wherein the preset font library is generated by a local server in advance by acquiring common characters according to the input file, and the font file is generated according to the preset font library;
[0033] The loading and rendering module is used to load the font file according to the storage address of the font file to render the input text.
[0034] A fourth aspect of the present application provides a local server, including:
[0035] The receiving module is used to receive the request for obtaining the preset font library sent by the browser during the page initialization phase;
[0036] A sending module is used to return the font information of the preset font library and the storage address of the font file to the browser. If the input text belongs to the preset font library, the font file is loaded according to the storage address of the font file to render the input text, wherein the preset font library is generated by the local server in advance based on the input file to obtain commonly used characters, and the font file is generated based on the preset font library.
[0037] In one embodiment, the local server further includes:
[0038] an updating module for adding the input text to the preset font library if the input text does not belong to the preset font library, generating an updated preset font library and an updated font file, and determining a storage address of the updated font file;
[0039] The sending module returns the updated font library information of the preset font library and the storage address of the updated font file to the browser, and the browser loads the updated font file according to the storage address of the updated font file to render the input text.
[0040] In one embodiment, the local server further includes:
[0041] A presetting module, configured to pre-traverse the text in the input file uploaded by the user and / or the user and obtain common character combinations to generate a preset character library, and store the preset character library in a database;
[0042] According to the text in the preset font library, the corresponding font file is extracted from the font source file, the font file of the preset font library is obtained and uploaded to the cloud server, and the cloud server generates the storage address of the font file of the preset font library in the cloud service.
[0043] A fifth aspect of the present application provides a font processing system, comprising:
[0044] The browser is configured to obtain the storage address of a font file in a preset font library if the input text belongs to the preset font library; load the font file according to the storage address of the font file to render the input text;
[0045] The local server is used to obtain common characters according to the input file in advance to generate the preset character library, and send the character library information and the storage address of the font file of the preset character library to the browser.
[0046] In one embodiment, the system further comprises:
[0047] The cloud server is configured to receive the font file of the preset font library uploaded by the local server and generate a storage address of the font file of the preset font library in the cloud service;
[0048] The local server pre-traverses the text in the input file uploaded by the user and / or itself and obtains common character combinations to generate a preset font library, and stores the preset font library in a database; according to the text in the preset font library, the corresponding font file is extracted from the font source file, and the font file of the preset font library is obtained and uploaded to the cloud server.
[0049] A sixth aspect of the present application provides a server device, including:
[0050] processor; and
[0051] The memory stores executable codes thereon, and when the executable codes are executed by the processor, the processor is caused to execute the method described above.
[0052] In a seventh aspect, the present application provides a computer-readable storage medium having executable code stored thereon. When the executable code is executed by a processor of an electronic device, the processor is caused to execute the method described above.
[0053] The technical solution provided by this application may have the following beneficial effects:
[0054] The technical solution of the present application can generate a preset font library in advance by a local server based on an input file. The preset font library does not need to include all characters (such as Chinese, English, etc.), but obtains commonly used characters based on the input file to obtain a preset font library. In this way, the preset font library can reduce a lot of characters, and the size of the corresponding font file can also be greatly reduced compared to the font file in the related technology, thereby improving the font file loading speed, accelerating the text rendering speed, and improving the user experience.
[0055] Furthermore, in the present application, if the input text does not belong to the preset font library, the local server can add the input text to the preset font library, generate an updated preset font library and an updated font file, and determine the storage address of the updated font file; then load the updated font file according to the storage address of the updated font file to render the input text, thereby realizing the update processing of the preset font library and font file, and realizing dynamic loading of font files.
[0056] Furthermore, the present application can also perform editing and / or offline operations on the fonts in the preset font library in response to an operation instruction to edit and / or offline the fonts in the preset font library detected in the visual interface of the local server. In this way, compared with the defect of the related art that font information is maintained in the code logic and each update requires code modification, the present application can implement operations in the visual interface without modifying the code, thereby making the operation simpler and more convenient for users to use, further improving the user experience.
[0057] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] The above and other objects, features and advantages of the present application will become more apparent by describing in more detail exemplary embodiments of the present application in conjunction with the accompanying drawings, wherein the same reference numerals generally represent the same components in the exemplary embodiments of the present application.
[0059] Figure 1 1 is a first flow chart of a font processing method according to an embodiment of the present application;
[0060] Figure 2 2 is a second flow chart of the font processing method shown in an embodiment of the present application;
[0061] Figure 3 3 is a schematic diagram of a third flow chart of a font processing method according to an embodiment of the present application;
[0062] Figure 4 4 is a schematic diagram of a fourth flow chart of a font processing method according to an embodiment of the present application;
[0063] Figure 5 is a fifth flow chart of the font processing method shown in an embodiment of the present application;
[0064] Figure 6 is a schematic diagram of the application flow of the font processing method shown in an embodiment of the present application;
[0065] Figure 7 is a schematic diagram of a method for processing fonts in an embodiment of the present application, wherein the input file includes text;
[0066] Figure 8 Schematic diagram of offline fonts in the font processing method shown in an embodiment of the present application;
[0067] Figure 9 is a schematic structural diagram of a browser device shown in an embodiment of the present application;
[0068] Figure 10 is a schematic diagram of the structure of the local server shown in an embodiment of the present application;
[0069] Figure 11 is a structural diagram of a font processing system shown in an embodiment of the present application;
[0070] Figure 12 It is a structural diagram of a server device shown in an embodiment of the present application. DETAILED DESCRIPTION
[0071] The following describes embodiments of the present application in more detail with reference to the accompanying drawings. Although the accompanying drawings illustrate embodiments of the present application, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. Rather, these embodiments are provided to make the present application more thorough and complete, and to fully convey the scope of the present application to those skilled in the art.
[0072] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. As used in this application and the appended claims, the singular forms "a," "an," "the," and "the" are intended to include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
[0073] It should be understood that although the terms "first", "second", "third", etc. may be used in this application to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of this application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0074] In related technologies, font files are generally large in size. In poor network environments, this can affect the font file loading speed, which in turn affects the text rendering speed, reducing the user experience. To address the above issues, embodiments of the present application provide a font processing method that can increase the font file loading speed, accelerate the text rendering speed, and enhance the user experience.
[0075] The technical solutions of the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0076] Figure 1 This is a first flow chart of the font processing method shown in an embodiment of the present application.
[0077] See also Figure 1 , the method can be applied to a browser, the method comprising:
[0078] S101, if the input text belongs to the preset font library, obtain the storage address of the font file of the preset font library, wherein the preset font library is generated by a local server in advance based on the input file to obtain common characters, and the font file is generated based on the preset font library.
[0079] For example, after the browser determines that the text input in the editor belongs to the text of the preset font library, the storage address of the font file of the preset font library is obtained.
[0080] The preset font library is generated by the local server in advance by obtaining common characters according to the input file, and the font file is generated according to the preset font library, including: the local server traverses the text in the input file uploaded by the user and / or itself in advance and obtains common character combinations to generate a preset font library, and stores the preset font library in the database; according to the text in the preset font library, the corresponding font file is extracted from the font source file, and the font file of the preset font library is obtained and uploaded to the cloud server, and the cloud server generates the storage address of the font file of the preset font library in the cloud service.
[0081] In a feasible embodiment, the preset character library can be a commonly used character library obtained by screening out frequently used Chinese characters based on industry attributes. In the above step S101, if the input text belongs to the text in the preset character library, obtaining the storage address of the font file of the preset character library includes: determining the target industry attribute corresponding to the input text, and obtaining the preset character library corresponding to the target industry attribute based on the target industry attribute. Among them, the process of determining the target industry attribute corresponding to the input text may include: matching the input text with industry keywords, and determining the target industry attribute corresponding to the input text based on the matching result; or, determining the target industry attribute corresponding to the input text using a named entity model; or, determining the target industry attribute corresponding to the input text based on the user information of the current user. It should be noted that the above implementation process is only a feasible solution provided by this embodiment, and this application does not limit the implementation of determining the target industry attribute corresponding to the input text.
[0082] S102: Load the font file according to the storage address of the font file to render the input text.
[0083] When the browser learns the storage address of the font file, such as the storage address of the font file in the cloud server, it can load the font file according to the storage address and then use the font file to render the input text.
[0084] From this embodiment, it can be found that the technical solution of the present application can generate a preset font library in advance by a local server based on the input file. The preset font library does not need to include all characters (such as Chinese, English, etc.), but obtains commonly used characters based on the input file to obtain a preset font library. In this way, the preset font library can reduce a lot of characters, and the size of the corresponding font file can also be greatly reduced compared to the font file in the related technology, thereby improving the font file loading speed, accelerating the text rendering speed, and improving the user experience.
[0085] Figure 2This is a second flow chart of the font processing method shown in an embodiment of the present application.
[0086] See also Figure 2 , the method can be applied to a browser, the method comprising:
[0087] S201, determine whether the text input in the editor belongs to the preset font library. If it is the text that belongs to the preset font library, go to step S202; if it is not the text that belongs to the preset font library, go to step S204.
[0088] S202, after the browser determines that the text input in the editor belongs to the text of the preset font library, obtains the storage address of the font file of the preset font library; enters S203.
[0089] The preset font library is generated by the local server in advance by obtaining common characters according to the input file, and the font file is generated according to the preset font library, including: the local server traverses the text in the input file uploaded by the user and / or itself in advance and obtains common character combinations to generate a preset font library, and stores the preset font library in the database; according to the text in the preset font library, the corresponding font file is extracted from the font source file, and the font file of the preset font library is obtained and uploaded to the cloud server, and the cloud server generates the storage address of the font file of the preset font library in the cloud service.
[0090] S203: Load the font file according to the storage address of the font file to render the input text.
[0091] S204, after the browser determines that the text entered in the editor does not belong to the preset font library, it notifies the local server, and the local server adds the input text to the preset font library, generates an updated preset font library and an updated font file, and determines the storage address of the updated font file; enters S205.
[0092] S205, obtaining the storage address of the updated font file sent by the local server; proceed to S206.
[0093] S206: Load the updated font file according to the storage address of the updated font file to render the input text.
[0094] It should also be noted that the method may further include: after the browser detects a font preview request, obtaining a storage address of a font preview image of a preset font library; and loading the font preview image for display according to the storage address of the font preview image.
[0095] From this embodiment, it can be found that the use of a preset font library in this application can reduce a lot of text, and the size of the corresponding font file can also be greatly reduced compared to the font file in the related technology, thereby improving the font file loading speed, speeding up the text rendering speed, and improving the user experience; further, if the input text does not belong to the preset font library, the local server can add the input text to the preset font library, generate an updated preset font library and an updated font file, and determine the storage address of the updated font file; then load the updated font file according to the storage address of the updated font file to render the input text, thereby realizing the update processing of the preset font library and font file, and realizing dynamic loading of font files.
[0096] Figure 3 This is a third flow chart of the font processing method shown in the embodiment of the present application.
[0097] See also Figure 3 , the method can be applied to a local server, the method comprising:
[0098] S301, receiving a request for obtaining a preset font library sent by the browser during the page initialization phase;
[0099] S302, returns the font information of the preset font library and the storage address of the font file to the browser. If the input text belongs to the preset font library, the font file is loaded according to the storage address of the font file to render the input text, wherein the preset font library is generated by the local server in advance based on the input file to obtain common characters, and the font file is generated based on the preset font library.
[0100] For example, the font information of the preset font library and the storage address of the font file are returned to the browser. After the browser determines that the text entered in the editor belongs to the preset font library based on the font information of the preset font library, it loads the font file according to the storage address of the font file to render the input text.
[0101] Among them, the preset font library is generated by the local server in advance by obtaining common characters according to the input file, and the font file is generated according to the preset font library, including: the local server traverses the text in the input file uploaded by the user and / or itself in advance and obtains the common character combination to generate the preset font library, and stores the preset font library in the database; according to the text in the preset font library, the corresponding font file is extracted from the font source file, and the font file of the preset font library is obtained and uploaded to the cloud server, and the cloud server generates the storage address of the font file of the preset font library in the cloud service.
[0102] From this embodiment, it can be found that the local server of the present application can generate a preset font library based on the input file in advance. The preset font library does not need to include all characters (such as Chinese, English, etc.), but obtains commonly used characters based on the input file to obtain a preset font library. In this way, the preset font library can reduce a lot of characters, and the size of the corresponding font file can also be greatly reduced compared to the font file in the related technology, thereby improving the font file loading speed, speeding up the text rendering speed, and improving the user experience.
[0103] Figure 4 4 is a schematic diagram of a fourth flow chart of a font processing method according to an embodiment of the present application;
[0104] See also Figure 4 , the method can be applied to a local server, the method comprising:
[0105] S401: Receive a request for obtaining a preset font library sent by the browser during the page initialization phase.
[0106] S402, returns the font information of the preset font library and the storage address of the font file to the browser. After the browser determines that the text entered in the editor belongs to the preset font library based on the font information of the preset font library, it loads the font file according to the storage address of the font file to render the input text, wherein the preset font library is generated by the local server in advance based on the commonly used characters obtained from the input file, and the font file is generated based on the preset font library.
[0107] Among them, the preset font library is generated by the local server in advance by obtaining common characters according to the input file, and the font file is generated according to the preset font library, including: the local server traverses the text in the input file uploaded by the user and / or itself in advance and obtains the common character combination to generate the preset font library, and stores the preset font library in the database; according to the text in the preset font library, the corresponding font file is extracted from the font source file, and the font file of the preset font library is obtained and uploaded to the cloud server, and the cloud server generates the storage address of the font file of the preset font library in the cloud service.
[0108] S403, after learning that the browser determines that the input text does not belong to the preset font library, the input text is added to the preset font library, an updated preset font library and an updated font file are generated, and the storage address of the updated font file is determined.
[0109] Among them, the input text can be added to the preset font library, an updated preset font library can be generated and stored in the database; the corresponding font file can be extracted from the font source file according to the text in the updated preset font library, and the updated font file of the preset font library can be obtained and uploaded to the cloud server, and the cloud server generates the storage address of the updated font file in the cloud service.
[0110] S404. Return the font library information of the updated preset font library and the storage address of the updated font file to the browser. The browser loads the updated font file according to the storage address of the updated font file to render the input text.
[0111] It should be noted that this method may further include: The local server generates a font preview image based on the font information in the font file of the preset font library and uploads it to the cloud server. The cloud server generates the storage address of the font preview image in the cloud service, so that after the browser detects a font preview request, it can load and display the font preview image according to the storage address of the font preview image.
[0112] This method may further include: In response to an operation instruction for editing and / or taking offline the font of the preset font library detected on the visualization interface of the local server, perform the editing and / or taking offline operation on the font of the preset font library.
[0113] For example, when a certain font needs to be taken offline (for example, because the copyright validity period cannot be used anymore), a certain font can be taken offline in the background management module of the local server by means of batch replacement through the visualization interface. For example, see Figure 8 If the font "xx Jian" is about to expire and "xxx Jian" can be used continuously, then on the visualization interface, "xx Jian" can be directly selected to be taken offline, and "xxx Jian" can be specified as the replacement font. In this way, all the texts of the "xx Jian" font in the current font library or all template data will be replaced by "xxx Jian" to avoid possible risks.
[0114] Figure 5 It is the fifth process schematic diagram of the font processing method shown in the embodiments of the present application. Figure 6 It is the application process schematic diagram of the font processing method shown in the embodiments of the present application. In this embodiment, the interaction between the browser, the local server, and the cloud server is used as an example for illustration.
[0115] The font processing system of the present application may include: a browser, a local server, and a cloud server. The local server in this embodiment may be, for example, a graphic design server, and the local server may include a font database. The cloud server may be, for example, a CDN (Content Delivery Network) server or other servers, etc. CDN is a general static resource storage service.
[0116] The main functions of the local server are to provide interfaces and data storage, such as providing and maintaining font-related information and the commonly used font library (a database containing text) in the current system. The font-related information includes the font name, the corresponding Postscript (post-processing script, or page description language) value, the storage address of the font file on the cloud server, the storage address of the font preview image on the cloud server, etc. The font information can be stored in the font database of the local server. The font file can be in ttf or otf format, etc. The font file is stored on the cloud server as a static resource, and the storage address of the font file on the cloud server is stored on the local server for access by the browser. In other words, the storage address corresponding to the font file on the cloud server is stored in the font database of the local server as part of the font information.
[0117] See also Figure 5 , the method comprising:
[0118] S501: The local server receives a request for obtaining a preset font library sent by the browser during the page initialization phase.
[0119] During the page initialization phase of opening a browser page, the browser may send a request for obtaining a preset font library to the local server through an interface request, so as to obtain the current font data from the local server.
[0120] It should be noted that if the browser has cached the preset font library previously obtained from the local server, it is not necessary to send a request to the local server to obtain the preset font library.
[0121] S502: The local server returns the font information of the preset font library and the storage address of the font file to the browser.
[0122] The local server returns the font information of the preset font library and the storage address of the font file to the browser according to the browser's request.
[0123] Among them, the preset font library can be generated by the local server in advance by obtaining common characters according to the input file, and the font file is generated according to the preset font library, including: the local server traverses the text in the input file uploaded by the user and / or itself in advance and obtains common character combinations to generate a preset font library, and stores the preset font library in the database; according to the text in the preset font library, the corresponding font file is extracted from the font source file, and the font file of the preset font library is obtained and uploaded to the cloud server, and the cloud server generates the storage address of the font file of the preset font library in the cloud service.
[0124] The local server obtains common characters from the input file in advance to generate a preset font library. The process of generating a font file based on the preset font library is described as follows:
[0125] The local server can receive input files uploaded by users and / or itself. These input files can be, for example, design files, template files, etc. Figure 7 , the input file includes text. Get the text that appears in the input file and generate a preset font library. The local server extracts the corresponding font file from the font source file based on these texts to obtain the font file of the preset font library; the local server obtains the font information in the font file, stores the font information in the local server, and uploads the font file to the cloud server. The local server can also obtain the Chinese name of the font file, select the corresponding text from the font file, and splice it into a font preview image; then, obtain the name, English name, postScriptName and other information in the font information and the font preview image to form font data and store it in the font database in the local server. Among them, the font preview image can also be uploaded to the cloud server, and the cloud server generates the storage address of the font preview image and returns it to the local server.
[0126] The preset character library in this application can be, for example, a commonly used character library. The local server can have a built-in scheduled script that is executed once a day, for example, to traverse the text in the input files uploaded by the user and / or the server itself, for example, to traverse all the text in all uploaded design drafts, and to group the text that has appeared to generate a commonly used character library.
[0127] Then, the corresponding font files can be extracted from the font source files corresponding to all the fonts in the current database according to the characters in the commonly used character library, and a font file containing only the characters in the commonly used character library can be generated. Assuming that the generated font file is named V1, the font file V1 can be uploaded to the cloud server after generation, and the cloud server automatically generates the storage address of the font file V1 in the cloud server, and stores the storage address of the font file V1 in the cloud server in the local server. The timing script can be executed according to a preset cycle, for example, it can be executed once a day. If the current commonly used character library has not changed, the font file can be not updated. When the font file is updated, only the newly added font file can be updated.
[0128] The management backend interface of the local server may be provided with an upload button. When the button is detected to be triggered, the font file (with the suffix ttf or otf) may be uploaded to the local server in the form of multipart / form-data.
[0129] Multipart / form-data is a transmission format for HTTP (Hypertext Transfer Protocol) requests. The local server can set up a backend service interface, such as / addFont. After uploading the font file to the local server, this interface will be requested. After receiving the font file, the interface will parse it and read the basic information of the font file, including the font name, English name (generally used to name the font in the code), and postScriptName. The postScriptName is another code that distinguishes it from the English name. When the font is used in the image processing software, this value represents the font in the file data of the software format. The local server can then assemble these values into font data in JSON (JavaScript Object Notation) format and store it in the font database. The font file itself can be uploaded from the local server to the cloud server, and the cloud server will automatically generate the corresponding storage address of the font file on the cloud server, such as a URL (Uniform Resource Locator). This URL address is used by the browser to access the font file on the cloud server.
[0130] The local server can also extract the Chinese name of the font file. For example, if the uploaded font file is named "Han Yi Xuan Song -65S", then the corresponding styles of the characters "Han", "Yi", "Xuan", "Song", "-", "6", "5", and "S" in the font file can be extracted and combined in sequence to generate a font preview image in SVG (Scalable Vector Graphics) format and upload it to the cloud server. The cloud server automatically generates the storage address of the font preview image on the cloud server. The browser can then load the font preview image from the cloud server according to the storage address for users to preview the current font style.
[0131] S503, the browser determines whether the text input in the editor belongs to the preset font library based on the font information of the preset font library. If it is the text that belongs to the preset font library, go to step S504; if it is not the text that belongs to the preset font library, go to step S505.
[0132] S504: The browser loads the font file according to the storage address of the font file to render the input text.
[0133] The data format of the style data of the font file can be as follows but not limited to:
[0134] SCSS
[0135]
[0136] "font-family" is the English name of the font file, the URL in "src" represents the address of the font file on the cloud server, and "format" corresponds to the format of the font file. TrueType corresponds to TTF format files, and OpenType corresponds to OTF format files.
[0137] After requesting the current font data from the local server, the browser can store a cache of all currently available font data in the front-end. The browser then loads the font file from the obtained storage address to render the input text. When the font data of the input text matches the "font-family" field in the style file, the browser will correctly load the font to render the input text.
[0138] S505: The browser notifies the local server.
[0139] S506. After the local server learns that the browser determines that the input text does not belong to the preset font library, it adds the input text to the preset font library, generates an updated preset font library and an updated font file, stores the updated preset font library in the database, and uploads the updated font file to the cloud server.
[0140] When a user enters a Chinese character, the browser can compare the character with a commonly used character library. If a character is not in the commonly used character library, the browser notifies the local server, and the local server executes the following logic:
[0141] First, the text is added to the commonly used character library to generate a new version, or updated commonly used character library (which can be called a new character library). The font style used by the current text is re-screened according to the new character library to generate a font file containing all the text in the new character library. Assuming that the font file containing all the text in the new character library is named V2, font file V2 is uploaded to the cloud server. The cloud server automatically generates the storage address of font file V2 on the cloud server. The storage address of font file V2 on the cloud server is obtained and stored on the local server, which means that the address is updated in the font database of the local server.
[0142] At the same time, the storage address of the obtained font file V2 in the cloud server is returned to the browser, and the browser loads the corresponding font file V2 according to the storage address to render the input text, thereby achieving the rendering purpose. It should be noted that subsequent script execution uses the new font library as the standard to update the font files of all available fonts and update them in the database.
[0143] That is to say, when the preset font library, such as the common font library, is updated, the update logic of the font file will be triggered, and the font files corresponding to the characters newly added to the common font library need to be added to the original font file. For example: The initial common font library includes (Bo, Niao, Suan, Re, Mai, Bei, Jing, Ji, Gou, Mei, Zhe, Ren, Yi, Sheng), and the corresponding font file V1 consists of these characters at this time. When a new character "Da" is added to generate the updated common font library, a new font file V2 will be generated at this time. When the font file V2 is uploaded to the cloud server, the storage address of the font file corresponding to the cloud server is inconsistent with the storage address of the previous font file in the cloud server, and it needs to be replaced with the address of the font file V2 in the cloud server. The font information stored on the local server also needs to be updated, that is, the storage address of the font file in the font information is replaced.
[0144] S507, The cloud server generates the storage address of the updated font file in the cloud service and returns it to the local server.
[0145] S508, The local server returns the font library information of the updated preset font library and the storage address of the updated font file to the browser.
[0146] S509, The browser loads the updated font file according to the storage address of the updated font file and renders the input text.
[0147] For the above process, taking the medical aesthetics industry as an example, most of the characters that often appear in input files such as various design drafts are related to the medical aesthetics industry, such as "Hyaluronic acid", "Photorejuvenation", etc. Therefore, the local server can count the occurrence of each character in each design draft (i.e., the traversal process), and an all-occurred character set can be obtained according to the occurrence of each character. This set can be defined as the common font library, and the font file corresponding to the common font library is named V1 at this time. For example, there are two design drafts. The first design draft has two paragraphs of text (Hyaluronic acid, Hot sale), and the second design draft has three paragraphs of text (Hyaluronic acid, Beijing institution, Mei X Ren doctor). According to the statistical results, the common font library (Bo, Niao, Suan, Re, Mai, Bei, Jing, Ji, Gou, Mei, X, Ren, Yi, Sheng) will be obtained. When a new design draft is added or the text of a certain design draft is modified, for example, a new paragraph of text (Big sale) is added to the second design draft. At this time, the font library update logic will be triggered, and the character "Da" will be added to the common font library.
[0148] In the related art, font files generally cover the style data of all texts, so such files are generally large in size, and in the case of poor network, it is easy to affect the rendering speed. Therefore, the solution proposed in this application filters out frequently used Chinese characters according to industry attributes, generates a commonly used character library, and thus generates a font file that only contains commonly used characters. The size of this file can be relatively reduced a lot, thereby achieving the purpose of increasing loading speed and improving rendering effects. For example, due to the attributes of the industry, such as in the medical beauty industry, professional names are used more frequently, while various uncommon characters and characters that are not related to the industry are rarely used or almost never used. Therefore, after all font files have been processed as described above, the size of the font files can be effectively reduced, for example, by more than 50%.
[0149] In the related art, font information is maintained in the code logic. The addition and removal of fonts require manual operation, which is complicated and inefficient. Each update requires code changes. However, when updating fonts or removing fonts, the present application solution can operate in a visual interface without modifying the code, making the operation simpler.
[0150] In addition, in the embodiment of the present application, the browser can be developed in Javascript, and the backend local server can be developed in Javascript and Rust. Using Rust, due to the language characteristics of Rust, ensures that the entire request process is very fast and will not cause the entire system to crash while maintaining memory safety.
[0151] Corresponding to the aforementioned application function implementation method embodiment, the present application also provides a browser device, a local server, a font processing system, a server device and corresponding embodiments.
[0152] Figure 9 It is a structural diagram of a browser device shown in an embodiment of the present application.
[0153] See also Figure 9 The browser device 90 includes: an acquisition module 91 and a loading and rendering module 92.
[0154] The acquisition module 91 is configured to acquire the storage address of a font file in a preset font library if the input text belongs to the preset font library. The preset font library is generated by a local server based on commonly used characters in advance from an input file, and the font file is generated based on the preset font library. For example, after determining that the text input in the editor belongs to the preset font library, the storage address of the font file in the preset font library is acquired.
[0155] The loading and rendering module 92 is used to load the font file according to the storage address of the font file to render the input text.
[0156] Figure 10 It is a structural diagram of the local server shown in an embodiment of the present application.
[0157] See also Figure 10 , a local server 100 includes: a receiving module 101 and a sending module 102.
[0158] The receiving module 101 is configured to receive a request for obtaining a preset font library sent by the browser during the page initialization phase.
[0159] The sending module 102 is used to return the font library information and the storage address of the font file of the preset font library to the browser. If the input text belongs to the preset font library, the font file is loaded according to the storage address of the font file to render the input text, wherein the preset font library is generated by the local server in advance based on the input file to obtain common characters, and the font file is generated based on the preset font library. For example, the font library information and the storage address of the font file of the preset font library are returned to the browser. After the browser determines that the text entered in the editor belongs to the preset font library based on the font library information of the preset font library, the font file is loaded according to the storage address of the font file to render the input text.
[0160] The preset font library is generated by the local server in advance by obtaining common characters according to the input file, and the font file is generated according to the preset font library, including: the local server traverses the text in the input file uploaded by the user and / or itself in advance and obtains common character combinations to generate a preset font library, and stores the preset font library in the database; according to the text in the preset font library, the corresponding font file is extracted from the font source file, and the font file of the preset font library is obtained and uploaded to the cloud server, and the cloud server generates the storage address of the font file of the preset font library in the cloud service.
[0161] In one embodiment, the local server 100 further includes an update module 103 .
[0162] Update module 103 is configured to, if the input text does not belong to the preset font library, add the input text to the preset font library, generate an updated preset font library and an updated font file, and determine the storage address of the updated font file. For example, upon learning that the browser determines that the input text does not belong to the preset font library, the browser adds the input text to the preset font library, generates an updated preset font library and an updated font file, and determines the storage address of the updated font file.
[0163] The sending module 102 returns the updated font library information of the preset font library and the storage address of the updated font file to the browser, and the browser loads the updated font file according to the storage address of the updated font file to render the input text.
[0164] In one embodiment, the local server 100 further includes a pre-configuration module 104 .
[0165] A presetting module 104 is used to pre-traverse the text in the input file uploaded by the user and / or the user and obtain common character combinations to generate a preset character library, and store the preset character library in a database;
[0166] According to the text in the preset font library, the corresponding font file is extracted from the font source file, the font file of the preset font library is obtained and uploaded to the cloud server, and the cloud server generates the storage address of the font file of the preset font library in the cloud service.
[0167] Figure 11 Schematic diagram of the structure of the font processing system shown in the embodiment of the present application. Figure 11 , a font processing system 110 includes: a browser 111 and a local server 100.
[0168] The browser 111 is configured to obtain the storage address of a font file in a preset font library if the input text belongs to the preset font library; and load the font file according to the storage address to render the input text. For example, after determining that the text input in the editor belongs to the preset font library, the browser 111 obtains the storage address of the font file in the preset font library.
[0169] The local server 100 is used to obtain common characters according to an input file in advance to generate a preset character library, generate a font file of the preset character library based on the preset character library, and send the character library information of the preset character library and the storage address of the font file to the browser.
[0170] After learning that the browser has determined that the input text does not belong to the preset font library, the local server 100 adds the input text to the preset font library, generates an updated preset font library and an updated font file, and determines the storage address of the updated font file; returns the font library information of the updated preset font library and the storage address of the updated font file to the browser, and the browser loads the updated font file according to the storage address of the updated font file to render the input text.
[0171] In one embodiment, the system further includes: a cloud server 112 .
[0172] The cloud server 112 is configured to receive the font files of the preset font library uploaded by the local server and generate the storage address of the font files of the preset font library in the cloud service;
[0173] The local server 100 pre-traverses the text in the input file uploaded by the user and / or itself and obtains common character combinations to generate a preset font library, and stores the preset font library in the database; according to the text in the preset font library, the corresponding font file is extracted from the font source file to obtain the font file of the preset font library and upload it to the cloud server 112.
[0174] The modules and functions in the local server 100 can be found in Figure 10 The description in , will not be repeated here.
[0175] The technical solution provided by the embodiment of the present application uses a preset font library to reduce a lot of text, and the size of the corresponding font file can also be greatly reduced compared with the font file in the related art, thereby improving the font file loading speed, accelerating the text rendering speed, and improving the user experience; further, if the input text does not belong to the preset font library, the local server can add the input text to the preset font library, generate an updated preset font library and an updated font file, and determine the storage address of the updated font file; then load the updated font file according to the storage address of the updated font file to render the input text, thereby realizing the update processing of the preset font library and font file, and realizing dynamic loading of font files.
[0176] Regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated again here.
[0177] Figure 12 It is a structural diagram of a server device shown in an embodiment of the present application.
[0178] See also Figure 12 , the server device 1000 includes a memory 1010 and a processor 1020 .
[0179] The processor 1020 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0180] The memory 1010 may include various types of storage units, such as system memory, read-only memory (ROM), and permanent storage. ROM may store static data or instructions required by the processor 1020 or other modules of the computer. The permanent storage may be a readable and writable storage device. The permanent storage may be a non-volatile storage device that retains stored instructions and data even when the computer is powered off. In some embodiments, the permanent storage device uses a large-capacity storage device (e.g., a magnetic or optical disk, flash memory) as the permanent storage device. In other embodiments, the permanent storage device may be a removable storage device (e.g., a floppy disk, optical drive). The system memory may be a readable and writable storage device or a volatile readable and writable storage device, such as dynamic random access memory. The system memory may store some or all instructions and data required by the processor during operation. In addition, the memory 1010 may include any combination of computer-readable storage media, including various types of semiconductor memory chips (e.g., DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), and magnetic disks and / or optical disks may also be used. In some embodiments, the memory 1010 may include a readable and / or writable removable storage device, such as a compact disc (CD), a read-only digital versatile disc (e.g., DVD-ROM, double-layer DVD-ROM), a read-only Blu-ray disc, an ultra-density optical disc, a flash memory card (e.g., SD card, mini SD card, Micro-SD card, etc.), a magnetic floppy disk, etc. Computer-readable storage media do not include carrier waves and transient electronic signals transmitted wirelessly or wired.
[0181] The memory 1010 stores executable codes. When the executable codes are processed by the processor 1020 , the processor 1020 may execute part or all of the above-mentioned methods.
[0182] In addition, the method according to the present application may also be implemented as a computer program or a computer program product, which includes computer program code instructions for executing some or all of the steps in the above method of the present application.
[0183] Alternatively, the present application can also be implemented as a computer-readable storage medium (or non-transitory machine-readable storage medium or machine-readable storage medium) on which executable code (or computer program or computer instruction code) is stored. When the executable code (or computer program or computer instruction code) is executed by a processor of an electronic device (or server, etc.), the processor executes part or all of the steps of the above-mentioned method according to the present application.
[0184] The embodiments of the present application 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 terminology used herein is selected to best explain the principles of the embodiments, their practical applications, or improvements to the technology in the market, or to enable other persons skilled in the art to understand the embodiments disclosed herein.
Claims
1. A font processing method, characterized in that: Applied to a browser, the method includes: If the input text belongs to a preset font library, obtaining the storage address of a font file of the preset font library, wherein the preset font library is generated by a local server in advance based on commonly used characters obtained from the input file, and the font file is generated based on the preset font library; The font file is loaded according to the storage address of the font file to render the input text.
2. The method according to claim 1, characterized in that The method further comprises: If the input text does not belong to the preset font library, the local server is notified, and the local server adds the input text to the preset font library, generates an updated preset font library and an updated font file, and determines the storage address of the updated font file; Obtaining the storage address of the updated font file sent by the local server; The updated font file is loaded according to the storage address of the updated font file to render the input text.
3. The method according to claim 1, characterized in that The method further comprises: After the browser detects the font preview request, obtaining the storage address of the font preview image of the preset font library; The font preview image is loaded and displayed according to the storage address of the font preview image.
4. A font processing method, characterized in that: Applied to a local server, the method includes: Receive a request from the browser to obtain a preset font library during the page initialization phase; The font library information of the preset font library and the storage address of the font file are returned to the browser. If the input text belongs to the preset font library, the font file is loaded according to the storage address of the font file to render the input text. The preset font library is generated by the local server in advance based on the input file to obtain commonly used characters, and the font file is generated based on the preset font library.
5. The method according to claim 4, characterized in that The method further comprises: If the input text does not belong to the text in the preset font library, the input text is added to the preset font library, an updated preset font library and an updated font file are generated, and a storage address of the updated font file is determined; The updated font library information of the preset font library and the storage address of the updated font file are returned to the browser, and the browser loads the updated font file according to the storage address of the updated font file to render the input text.
6. The method according to claim 4, characterized in that The preset character library is generated by the local server in advance based on commonly used characters obtained from the input file, and the font file is generated based on the preset character library, including: The local server pre-traverses the characters in the input file uploaded by the user and / or the local server itself and obtains common character combinations to generate a preset character library, and stores the preset character library in a database; According to the text in the preset font library, the corresponding font file is extracted from the font source file, the font file of the preset font library is obtained and uploaded to the cloud server, and the cloud server generates the storage address of the font file of the preset font library in the cloud service.
7. The method according to claim 6, characterized in that The method further comprises: The local server generates a font preview image based on the font information in the font file of the preset font library and uploads it to the cloud server. The cloud server generates a storage address of the font preview image in the cloud service so that the browser can load the font preview image according to the storage address of the font preview image for display after detecting the font preview request.
8. The method according to claim 5, characterized in that The step of adding the input text to the preset font library, generating an updated preset font library and an updated font file, and determining a storage address of the updated font file includes: Adding the input text to the preset character library, generating an updated preset character library and storing it in a database; According to the text in the updated preset font library, the corresponding font file is extracted from the font source file, the updated font file of the preset font library is obtained and uploaded to the cloud server, and the cloud server generates the storage address of the updated font file in the cloud service.
9. A browser device, characterized in that: include: an acquisition module, configured to acquire a storage address of a font file of a preset font library if the input text belongs to the preset font library, wherein the preset font library is generated by a local server in advance by acquiring common characters according to the input file, and the font file is generated according to the preset font library; The loading and rendering module is used to load the font file according to the storage address of the font file to render the input text.
10. A local server, characterized in that: include: The receiving module is used to receive the request for obtaining the preset font library sent by the browser during the page initialization phase; A sending module is used to return the font information of the preset font library and the storage address of the font file to the browser. If the input text belongs to the preset font library, the font file is loaded according to the storage address of the font file to render the input text, wherein the preset font library is generated by the local server in advance based on the input file to obtain commonly used characters, and the font file is generated based on the preset font library.