CN118013146A - Method and device for supporting automatic font collection and compression - Google Patents

Method and device for supporting automatic font collection and compression Download PDF

Info

Publication number
CN118013146A
CN118013146A CN202211403705.9A CN202211403705A CN118013146A CN 118013146 A CN118013146 A CN 118013146A CN 202211403705 A CN202211403705 A CN 202211403705A CN 118013146 A CN118013146 A CN 118013146A
Authority
CN
China
Prior art keywords
font
dependency relationship
local
characters
file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211403705.9A
Other languages
Chinese (zh)
Inventor
崔传腾
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tianjin Hongen Perfect Future Education Technology Co ltd
Original Assignee
Tianjin Hongen Perfect Future Education Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tianjin Hongen Perfect Future Education Technology Co ltd filed Critical Tianjin Hongen Perfect Future Education Technology Co ltd
Priority to CN202211403705.9A priority Critical patent/CN118013146A/en
Publication of CN118013146A publication Critical patent/CN118013146A/en
Pending legal-status Critical Current

Links

Landscapes

  • Document Processing Apparatus (AREA)

Abstract

The invention provides a method and a device for supporting automatic font collection and compression, wherein the method comprises the following steps: if the opening operation of the target webpage is detected, running a font dependency relation collection script which is pre-injected into the target webpage; wherein the font dependency includes a dependency of a character and a font package name. And collecting the font dependency relationship in the target webpage in real time through the font dependency relationship collecting script and storing the font dependency relationship in the local font file. And reading the local font file, and performing font compression clipping on the font dependency relationship in the local font file. According to the embodiment of the invention, the collection and compression of fonts can be integrated in the project through the construction tool, automatic collection and cutting of fonts can be realized by introducing the tool by a developer, manual intervention is not needed, different font types in the webpage text can be automatically and accurately collected through the injected font dependency relation collection script, and the manpower resources required by cutting are saved by carrying out automatic font compression cutting on the font file.

Description

Method and device for supporting automatic font collection and compression
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for supporting automatic font collection and compression.
Background
With the popularization of internet technology and the rapid development of mobile applications, more and more users access the internet through the mobile applications, and meanwhile, the content carried by web pages is more and more abundant. The application of different fonts in the webpage can show better visual impact effect, but the volume of one Chinese commercial font package is about 3MB-4MB, and huge font resource loading affects the page loading time and reduces the user experience.
In the prior art, FSW (font-slider-walker) character spider is used for collecting Chinese characters in a file by analyzing a local file, and then the Chinese characters are dynamically extracted to generate a compressed font packet. The spider+ (Font-spider-plus) is an intelligent webpage Font WebFont compression tool, can automatically analyze the webpage fonts WebFont used by a local webpage and an online webpage and compress the webpage fonts as required, and collects characters in url links through a built-in headless browser, but cannot distinguish the Font types actually used by texts in the webpage. In addition, font compression is performed by a three-way font compression tool, and a person is also required to collect the compressed characters.
The prior art scheme mainly has two problems, namely, only the characters in the file can be extracted for compressing the fonts, the true font types used by the characters are not distinguished, and all the characters appearing in the page are required to be compressed. The spider scheme in the prior art can only extract Chinese characters in a file, and the spider plus scheme accesses an online file through a built-in browser and extracts the characters in the file, so that the Font type actually used by the text in the page cannot be distinguished. Secondly, the prior art scheme does not realize full automatic collection and compression, and the prior art scheme only provides a tool command and does not provide an integrated automation solution, and the script command needs to be manually executed to carry out font collection and compression.
The manual collection of compressed characters requires the copying and checking of used font packet names section by starting the browser debugging function, and for dynamically updated text, the manual collection is not only high in cost but also easy to miss, especially when frequently updated text is developed. The prior manual method for acquiring the font packet name and text is shown in fig. 1. In the prior art, the automatic mode is not adopted to complete the font clipping, as in the online font clipping mode shown in fig. 2, when the text is updated frequently, the manual clipping is needed to be repeated through an online tool or a script tool, and the clipped fonts are packaged in projects for use, so that the development labor cost is increased.
Disclosure of Invention
In view of the above problems, the present invention provides a method and apparatus for supporting automatic font collection and compression, which overcomes the above problems or at least partially solves the above problems, and can automatically implement the collection and compression of custom fonts, thereby improving the font collection efficiency and accuracy, and the automatically collected fonts are not easy to miss, thereby greatly facilitating the application of webpage fonts, saving the manpower resources required for clipping, and reducing the development cost.
According to an aspect of an embodiment of the present invention, there is provided a method for supporting automatic font collection and compression, including:
If the opening operation of the target webpage is detected, running a font dependency relation collection script which is pre-injected into the target webpage; wherein the font dependency relationship comprises a dependency relationship of characters and font package names;
collecting the font dependency relationship in the target webpage in real time through the font dependency relationship collecting script and storing the font dependency relationship in a local font file;
and reading the local font file, and performing font compression cutting on the font dependency relationship in the local font file.
Optionally, if the opening operation of the target webpage is detected, before running the font dependency relationship collection script pre-injected into the target webpage, the method further includes: injecting the font dependency relation collection script into the target webpage by adopting a plug-in mechanism of a code compiling tool; and/or
Collecting the font dependency relationship in the target webpage in real time through the font dependency relationship collecting script and storing the font dependency relationship in a local font file, wherein the method comprises the following steps: creating an http interface service, and collecting the font dependency relationship in the target webpage in real time through the font dependency relationship collection script; and sending the collected font dependency relationship to a local server through an http interface, and storing the font dependency relationship to a local font file by the local server.
Optionally, sending the collected font dependency relationship to a local server through the http interface, including:
Sending a report request of the font dependency relationship to the local server through the http interface at intervals of a preset time period;
And responding to the received message of the local server, and sending the font dependency relationship collected in the preset time period to the local server through the http interface.
Optionally, the collecting, by the font dependency relationship collecting script, the font dependency relationship in the target webpage in real time and storing the font dependency relationship in a local font file includes:
collecting scripts through the font dependency relationship, and monitoring DOM nodes of the target webpage in real time;
Traversing text nodes in the DOM nodes, acquiring characters of the text nodes and font packet names with dependency relations with the characters, and storing the acquired dependency relations between the characters and the font packet names into a local font file.
Optionally, traversing text nodes in the DOM nodes, and obtaining characters of the text nodes and font packet names having a dependency relationship with the characters, including: traversing text nodes in the DOM nodes, and determining effective text nodes except any one of text nodes, empty nodes and non-text nodes in the DOM nodes, the names of which do not meet the requirements of actual items; acquiring characters of the effective text nodes and font packet names with dependency relations with the characters; and/or
Traversing text nodes in the DOM nodes, and acquiring characters of the text nodes and font packet names with dependency relations with the characters, wherein the method comprises the following steps: traversing text nodes in the DOM nodes, acquiring characters of the text nodes and font packet names with dependency relations with the characters, and performing de-duplication on the acquired characters and the font packet names with the dependency relations with the characters.
Optionally, acquiring the character of the text node and the font packet name having a dependency relationship with the character, and storing the acquired dependency relationship between the character and the font packet name in a local font file, including:
acquiring characters of the text node and font packet names with dependency relations with the characters;
And taking the characters of the text node as values, taking the font packet names with the dependency relationship with the characters as keywords, and storing the dependency relationship between the characters and the font packet names into a local font file in a data format of the keywords and the corresponding values.
Optionally, the file name of the local font file is named according to a font packet name, and the reading the local font file includes:
acquiring a file storage path of a font dependency relationship, and searching a local font file with a file name consistent with a required font packet name from the file storage path;
And searching characters corresponding to the keywords in the searched local font file by taking the font packet name as the keywords.
Optionally, performing font compression clipping on the font dependency relationship in the local font file includes:
Determining a designated character required by the project;
and calling a font clipping tool to compress and clip the characters corresponding to the keywords in the searched local font file, and generating a font file containing the appointed characters.
Optionally, reading the local font file, and performing font compression clipping on the font dependency relationship in the local font file, including:
and responding to the font compiling processing module to execute the font compiling processing operation, reading the local font file, and performing font compression clipping on the font dependency relationship in the local font file.
According to another aspect of the embodiment of the present invention, there is also provided an apparatus for supporting automatic font collection and compression, including:
The operation module is suitable for operating the font dependency relation collection script which is injected into the target webpage in advance if the opening operation of the target webpage is detected; wherein the font dependency relationship comprises a dependency relationship of characters and font package names;
The collection and storage module is suitable for collecting the font dependency relationship in the target webpage in real time through the font dependency relationship collection script and storing the font dependency relationship in a local font file;
And the compression clipping module is suitable for reading the local font file and carrying out font compression clipping on the font dependency relationship in the local font file.
In the embodiment of the invention, if the opening operation of the target webpage is detected, a font dependency relation collecting script which is pre-injected into the target webpage is operated, wherein the font dependency relation comprises the dependency relation of characters and font package names. And collecting the font dependency relationship in the target webpage in real time through the font dependency relationship collecting script and storing the font dependency relationship in the local font file. And reading the local font file, and performing font compression clipping on the font dependency relationship in the local font file. According to the embodiment of the invention, the collection and compression of the self-defined fonts can be automatically realized, the project can be integrated through the construction tool, the developer can realize the automatic collection and cutting of the fonts only by introducing the construction tool, no manual intervention is needed in the whole process, different font types in the webpage text can be automatically and accurately collected through the font dependency relation collection script, the font collection efficiency and accuracy are improved, and the automatically collected fonts are not easy to miss. By carrying out automatic font compression and cutting on the font file, the application of the webpage fonts is greatly facilitated, the manpower resources required by cutting are saved, and the development cost is reduced.
The foregoing description is only an overview of the present invention, and is intended to be implemented in accordance with the teachings of the present invention in order that the same may be more clearly understood and to make the same and other objects, features and advantages of the present invention more readily apparent.
The above, as well as additional objectives, advantages, and features of the present invention will become apparent to those skilled in the art from the following detailed description of a specific embodiment of the present invention when read in conjunction with the accompanying drawings.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the invention and do not constitute a limitation on the invention. In the drawings:
FIG. 1 shows a prior art interface diagram for obtaining font names and text by debugging selected text through a browser;
FIG. 2 illustrates an interface diagram of a prior art online font clipping tool for font clipping;
FIG. 3 shows a flow diagram of a method supporting automatic collection and compression of fonts according to an embodiment of the present invention;
fig. 4 is a schematic diagram showing the construction of an apparatus for supporting automatic font collection and compression according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
To solve the above technical problem, an embodiment of the present invention provides a method for supporting automatic font collection and compression, and fig. 3 is a schematic flow chart of a method for supporting automatic font collection and compression according to an embodiment of the present invention. Referring to fig. 3, the method for supporting automatic font collection and compression includes at least steps S102 to S106.
Step S102, if the opening operation of the target webpage is detected, running a font dependency relation collection script which is pre-injected into the target webpage; wherein the font dependency includes a dependency of a character and a font package name.
In this embodiment, the dependency relationship between the character and the font package name is the correspondence relationship between the character and the package name of the used font package.
And step S104, collecting the font dependency relationship in the target webpage in real time through the font dependency relationship collecting script and storing the font dependency relationship in the local font file.
Step S106, reading the local font file, and performing font compression clipping on the font dependency relationship in the local font file.
According to the embodiment of the invention, the collection and compression of the self-defined fonts can be automatically realized, the project can be integrated through the construction tool, the developer can realize the automatic collection and cutting of the fonts only by introducing the construction tool, no manual intervention is needed in the whole process, different font types in the webpage text can be automatically and accurately collected through the font dependency relation collection script, the font collection efficiency and accuracy are improved, and the automatically collected fonts are not easy to miss. By carrying out automatic font compression and cutting on the font file, the application of the webpage fonts is greatly facilitated, the manpower resources required by cutting are saved, and the development cost is reduced.
According to the embodiment of the invention, functions such as font dependency relation collection, font dependency relation storage, font clipping and the like can be integrated through the development and construction tool webpack plug-in, and automation of the integrated functions can be realized only by installing one plug-in. webpack plug-in as a code compilation tool can compile browser-agnostic grammars into browser-agnostic grammars.
In an embodiment of the present invention, before executing step S102 and if an opening operation of the target web page is detected, a font dependency relationship collection script that is pre-injected into the target web page is executed, a plug-in mechanism of a code compiling tool may be further adopted to inject the font dependency relationship collection script into the target web page. This embodiment may use the plug-in mechanism of webpack to inject a font-dependency collection script into the HTML (Hyper Text Markup Language ) page, where the font-dependency collection script contains the code segments for font collection and reporting.
In the embodiment of the invention, after the initialization of the font dependency relationship storage service is completed, codes containing information such as service ip, port number and the like of the target webpage can be stored in the context of the construction tool. When the target webpage is opened, codes containing information such as service ip, port number and the like of the target webpage are called from the context of the construction tool, and a font dependency relation collecting script template is inserted, so that a font dependency relation collecting script of the target webpage is generated, and then the generated collecting script is inserted into the target webpage in a grammar tree mode.
The target webpage of the embodiment of the invention can be a browser webpage, and when the construction tool webpack is started, the developed plug-in creates an http interface service, and the font dependency relationship collected from the target webpage of the browser can be received through the http interface. When executing step S102, collecting the font dependency relationship in the target webpage in real time through the font dependency relationship collecting script, sending the collected font dependency relationship to a local server through an http interface, and then storing the font dependency relationship in a local font file by the local server. In the embodiment of the invention, after the target webpage is opened through the browser, the font dependency relation collecting script is automatically operated, so that the font dependency relation in the target webpage can be collected in real time. The local server may store the font dependencies in a local font file of the local directory.
Since the text and the corresponding fonts on the web page may change frequently, if the collected font dependency relationship is sent to the local server in real time, the server may be burdened. Therefore, the embodiment of the invention can carry out throttling processing when the font dependency relationship is reported to the local server. Specifically, a reporting request of the font dependency relationship can be sent to a local server through an http interface at intervals of a preset time period. And responding to the received message of the local server, sending the font dependency relationship collected in the preset time period to the local server through an http interface, and storing the font dependency relationship into a local font file by the local server. The preset time period can be customized in advance, for example, a report request of the font dependency relationship is sent to the local server every 1000 milliseconds, so that the burden of the local server can be reduced.
In an embodiment of the invention, when the font dependency relationship in the target webpage is collected in real time through the font dependency relationship collection script, the DOM node of the target webpage is monitored in real time through the font dependency relationship collection script. Then traversing text nodes in DOM nodes to obtain characters of the text nodes and font packet names with dependency relations with the characters. And the obtained dependency relationship between the characters and the font packet name can be stored in a local font file.
When the characters of the text node and the font packet names with the dependency relationship with the characters are obtained, a change observer MutationObserver (an interface for monitoring DOM structure change) monitors the change of the page content monitored by the change of the body node in the DOM, so that the characters of the text node are obtained, and the font packet names with the dependency relationship with the characters can be obtained by obtaining the font patterns of the text node and the parent label node.
The embodiment of the invention can monitor the attribute change of DOM nodes, any node can possibly change the text in the page by adding, deleting, updating and the like, and the attribute change monitoring is mainly used for monitoring class attributes which can influence the style of the tag, and different classes can set different font styles.
In an embodiment of the present invention, in order to improve the font collection efficiency, some nodes that do not meet the requirements may be automatically ignored in the process of collecting the font dependency relationship. If the text node, the empty node and the non-text node with the node names not meeting the actual project requirements are automatically ignored in the process of acquiring the characters of the text node and the font packet names with the characters in a dependency relationship. Specifically, after traversing text nodes in DOM nodes, determining effective text nodes except any one of text nodes, empty nodes and non-text nodes in the DOM nodes, wherein the names of the nodes do not meet the requirements of actual items, and acquiring characters of the effective text nodes and font packet names with dependency relations with the characters.
For example, if a vconsole debug tool is used in the target page, the nodes with tag ID vconsole may be ignored because the characters generated by the debug tool are not the characters that the actual item needs to use. Moreover, empty nodes and non-text nodes may also be ignored. After the traversed characters of the effective text nodes meeting the requirements are obtained, font packet names (fontFaily) with the dependency relationship with the characters of the effective text nodes are obtained through a getComputedStyle method. getComputedStyle is a get computation style method that can be used to get CSS (CASCADING STYLE SHEETS, cascading style sheet) styles for specified elements.
In an optional embodiment of the present invention, after obtaining the characters of the text node and the font packet names having a dependency relationship with the characters, the obtained characters and the font packet names having a dependency relationship with the characters may be further deduplicated. By de-duplicating the characters and the font packet names with the dependency relationship with the characters, the storage space can be saved, and the subsequent cutting compression efficiency of the fonts can be improved.
In an embodiment of the present invention, when the obtained dependency relationship between the characters and the font packet names of the text node is stored in the local font file, the characters of the text node and the font packet names having the dependency relationship with the characters may be obtained first, then the characters of the text node are used as the value, the font packet names having the dependency relationship with the characters are used as the key, and the dependency relationship between the characters and the font packet names is stored in the local font file in the JSON data format of the key and the corresponding value. The JSON is a lightweight data exchange format, and the embodiment of the invention stores the collected font packet names and the characters referenced by the collected font packet names in a JSON data structure, wherein the font packet names are keys, the characters are values, and the subsequent searching of the font packet names and the characters can be facilitated.
The local font file may be stored in a user local directory of the server, and the file name of the local font file may be named according to the font package name, and when the local font file is read in step S106, the file storage path of the font dependency relationship may be first obtained from the user local directory, and then the local font file whose file name is consistent with the required font package name is searched from the file storage path. Since the dependency of the character and the font packet name is stored in the local font file in JSON data format of key (font packet name) and corresponding value (character). And therefore, the font packet name is used as a keyword, and characters corresponding to the keyword are searched in the searched local font file.
In an embodiment of the present invention, when executing step S106 to perform font compression clipping on the font dependency relationship in the local font file, determining the designated character required by the project, and then invoking the font clipping tool to perform compression clipping on the searched character corresponding to the keyword in the local font file, so as to compress and clip the designated character, thereby generating the font file containing the designated character. The font clipping tool may be a font-min tool, and of course, other tools may be used to perform the font clipping process, which is not particularly limited in the embodiment of the present invention. According to the embodiment of the invention, the local font file is read in the project construction stage, the font compression cutting is completed by using the font-min tool, and the font cutting is performed in the project construction stage, so that the compiling efficiency of the development environment can be effectively improved.
In an alternative embodiment of the present invention, when executing step S106 to perform font clipping, the font compiling processing module is responsive to executing the font compiling processing operation, reading the local font file, and performing font compression clipping on the font dependency relationship in the local font file.
The font compiling processing module (loader module) is a mechanism of the construction tool webpack, and when the project is constructed, the loader module is executed when the local font file is referenced, and can read the font dependency relationship in the local font file and call the font clipping tool (such as the font-min tool) to perform font compression clipping. The Buffer generated after the font compression and clipping can be further processed by the construction tool webpack to finally generate a compressed font file, and the font compression and clipping is performed during project construction to generate a compressed new font file, so that the whole process does not need to modify the source font file.
By adopting the embodiment of the invention, the functions of automatic font dependency relation collection, font dependency relation storage and font cutting can be realized through the integration of the construction tool, the work of manually executing font collection and font cutting is not needed, the efficiency and accuracy of font collection and cutting are improved, and the manpower resource is greatly saved.
Based on the same inventive concept, the embodiment of the present invention also provides an apparatus for supporting automatic font collection and compression, and fig. 4 shows a schematic structural diagram of an apparatus for supporting automatic font collection and compression according to an embodiment of the present invention. Referring to fig. 4, the apparatus supporting automatic collection and compression of fonts includes at least a run module 410, a collection storage module 420, and a compression clipping module 430.
The operation module 410 is adapted to operate the font dependency relationship collection script pre-injected into the target webpage if the opening operation of the target webpage is detected; the font dependency relationship comprises the dependency relationship of characters and font package names;
The collection and storage module 420 is adapted to collect the font dependency relationships in the target web page in real time through the font dependency relationship collection script and store the font dependency relationships in the local font file;
The compression clipping module 430 is adapted to read the local font file and perform font compression clipping on the font dependency relationship in the local font file.
In an embodiment of the present invention, the apparatus for supporting automatic font collection and compression further includes a creation module. The creation module is adapted to, before the execution module 410 detects an opening operation of the target webpage and executes the font dependency relation collection script pre-injected into the target webpage, inject the font dependency relation collection script into the target webpage by using a plug-in mechanism of the code compiling tool.
The collection storage module 420 is further adapted to create an http interface service, and collect font dependency relationships in the target web page in real time through a font dependency relationship collection script; and sending the collected font dependency relationship to a local server through an http interface, and storing the font dependency relationship to a local font file by the local server.
In an embodiment of the present invention, the collection storage module 420 is further adapted to send a report request of the font dependency relationship to the local server through the http interface at intervals of a preset time period; and responding to the received message of the local server, and transmitting the font dependency relationship collected in the preset time period to the local server through an http interface.
In an embodiment of the present invention, the collection storage module 420 is further adapted to monitor DOM nodes of the target web page in real time through the font dependency relationship collection script; traversing text nodes in DOM nodes, acquiring characters of the text nodes and font packet names with dependency relations with the characters, and storing the obtained dependency relations between the characters and the font packet names into a local font file.
In an embodiment of the present invention, the collection storage module 420 is further adapted to traverse text nodes in DOM nodes, determine valid text nodes in DOM nodes except any one of text nodes, null nodes, and non-text nodes whose node names do not meet the actual project requirements; acquiring characters of an effective text node and font packet names with dependency relations with the characters; and/or
The collection and storage module 420 is further adapted to traverse text nodes in the DOM nodes, obtain characters of the text nodes and font packet names having a dependency relationship with the characters, and deduplicate the obtained characters and font packet names having a dependency relationship with the characters.
In an embodiment of the present invention, the collection storage module 420 is further adapted to obtain characters of the text node and font packet names having a dependency relationship with the characters; and taking the characters of the text node as values, taking the font packet names with the dependency relationship with the characters as keywords, and storing the dependency relationship between the characters and the font packet names in a data format of the keywords and the corresponding values into a local font file.
In an embodiment of the present invention, the compression clipping module 430 is further adapted to obtain a file storage path of the font dependency relationship, and find a local font file with a file name consistent with the required font package name from the file storage path; and searching the characters corresponding to the keywords in the searched local font file by taking the font packet name as the keywords.
In one embodiment of the invention, the compression clipping module 430 is further adapted to determine the specified character required for the project; and calling a font clipping tool to compress and clip the characters corresponding to the keywords in the searched local font file, and generating a font file containing the appointed characters.
In an embodiment of the present invention, the compression clipping module 430 is further adapted to, in response to the font compiling processing module performing the font compiling processing operation, read the local font file and perform font compression clipping on the font dependencies in the local font file.
Based on the same inventive concept, embodiments of the present invention also provide a computer storage medium storing computer program code which, when run on a computing device, causes the computing device to perform the method of supporting automatic collection and compression of fonts of any of the above.
Based on the same inventive concept, an embodiment of the present invention further provides a computing device, including: a processor; a memory storing computer program code; the computer program code, when executed by a processor, causes a computing device to perform any of the above methods supporting automatic collection and compression of fonts.
It will be clear to those skilled in the art that the specific working processes of the above-described systems, devices, modules and units may refer to the corresponding processes in the foregoing method embodiments, and for brevity, the description is omitted here.
In addition, each functional unit in the embodiments of the present invention may be physically independent, two or more functional units may be integrated together, or all functional units may be integrated in one processing unit. The integrated functional units may be implemented in hardware or in software or firmware.
Those of ordinary skill in the art will appreciate that: the integrated functional units, if implemented in software and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in essence or in whole or in part in the form of a software product stored in a storage medium, comprising instructions for causing a computing device (e.g., a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the embodiments of the present invention when the instructions are executed. And the aforementioned storage medium includes: a usb disk, a removable hard disk, a read-only memory (ROM), a random-access memory (RAM), a magnetic disk, or an optical disk, etc.
Or all or part of the steps of implementing the foregoing method embodiments may be implemented by hardware (such as a personal computer, a server, or a computing device such as a network device) associated with program instructions, which may be stored in a computer-readable storage medium, which when executed by a processor of the computing device, performs all or part of the steps of the method of embodiments of the present invention.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all technical features thereof can be replaced by others within the spirit and principle of the present invention; such modifications and substitutions do not depart from the scope of the invention.

Claims (10)

1. A method for supporting automatic collection and compression of fonts, comprising:
If the opening operation of the target webpage is detected, running a font dependency relation collection script which is pre-injected into the target webpage; wherein the font dependency relationship comprises a dependency relationship of characters and font package names;
collecting the font dependency relationship in the target webpage in real time through the font dependency relationship collecting script and storing the font dependency relationship in a local font file;
and reading the local font file, and performing font compression cutting on the font dependency relationship in the local font file.
2. The method of claim 1, wherein the step of determining the position of the substrate comprises,
If the opening operation of the target webpage is detected, before the font dependency relation collecting script which is pre-injected into the target webpage is operated, the method further comprises the following steps: injecting the font dependency relation collection script into the target webpage by adopting a plug-in mechanism of a code compiling tool; and/or
Collecting the font dependency relationship in the target webpage in real time through the font dependency relationship collecting script and storing the font dependency relationship in a local font file, wherein the method comprises the following steps: creating an http interface service, and collecting the font dependency relationship in the target webpage in real time through the font dependency relationship collection script; and sending the collected font dependency relationship to a local server through an http interface, and storing the font dependency relationship to a local font file by the local server.
3. The method of claim 2, wherein sending the collected font dependencies to a local server via the http interface comprises:
Sending a report request of the font dependency relationship to the local server through the http interface at intervals of a preset time period;
And responding to the received message of the local server, and sending the font dependency relationship collected in the preset time period to the local server through the http interface.
4. The method of claim 1, wherein collecting font dependencies in the target web page in real time by the font dependency collection script and storing the font dependencies in a local font file comprises:
collecting scripts through the font dependency relationship, and monitoring DOM nodes of the target webpage in real time;
Traversing text nodes in the DOM nodes, acquiring characters of the text nodes and font packet names with dependency relations with the characters, and storing the acquired dependency relations between the characters and the font packet names into a local font file.
5. The method of claim 4, wherein the step of determining the position of the first electrode is performed,
Traversing text nodes in the DOM nodes, and acquiring characters of the text nodes and font packet names with dependency relations with the characters, wherein the method comprises the following steps: traversing text nodes in the DOM nodes, and determining effective text nodes except any one of text nodes, empty nodes and non-text nodes in the DOM nodes, the names of which do not meet the requirements of actual items; acquiring characters of the effective text nodes and font packet names with dependency relations with the characters; and/or
Traversing text nodes in the DOM nodes, and acquiring characters of the text nodes and font packet names with dependency relations with the characters, wherein the method comprises the following steps: traversing text nodes in the DOM nodes, acquiring characters of the text nodes and font packet names with dependency relations with the characters, and performing de-duplication on the acquired characters and the font packet names with the dependency relations with the characters.
6. The method of claim 4, wherein obtaining the character of the text node and the font packet name having a dependency relationship with the character, storing the obtained dependency relationship of the character and font packet name in a local font file, comprising:
acquiring characters of the text node and font packet names with dependency relations with the characters;
And taking the characters of the text node as values, taking the font packet names with the dependency relationship with the characters as keywords, and storing the dependency relationship between the characters and the font packet names into a local font file in a data format of the keywords and the corresponding values.
7. The method of claim 6, wherein the file name of the local font file is named according to a font packet name, and wherein the reading the local font file comprises:
acquiring a file storage path of a font dependency relationship, and searching a local font file with a file name consistent with a required font packet name from the file storage path;
And searching characters corresponding to the keywords in the searched local font file by taking the font packet name as the keywords.
8. The method of claim 7, wherein performing font compression clipping on font dependencies in the local font file comprises:
Determining a designated character required by the project;
and calling a font clipping tool to compress and clip the characters corresponding to the keywords in the searched local font file, and generating a font file containing the appointed characters.
9. The method of any of claims 1-8, wherein reading the local font file, performing font compression clipping on font dependencies in the local font file, comprises:
and responding to the font compiling processing module to execute the font compiling processing operation, reading the local font file, and performing font compression clipping on the font dependency relationship in the local font file.
10. An apparatus for supporting automatic collection and compression of fonts, comprising:
The operation module is suitable for operating the font dependency relation collection script which is injected into the target webpage in advance if the opening operation of the target webpage is detected; wherein the font dependency relationship comprises a dependency relationship of characters and font package names;
The collection and storage module is suitable for collecting the font dependency relationship in the target webpage in real time through the font dependency relationship collection script and storing the font dependency relationship in a local font file;
And the compression clipping module is suitable for reading the local font file and carrying out font compression clipping on the font dependency relationship in the local font file.
CN202211403705.9A 2022-11-10 2022-11-10 Method and device for supporting automatic font collection and compression Pending CN118013146A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211403705.9A CN118013146A (en) 2022-11-10 2022-11-10 Method and device for supporting automatic font collection and compression

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211403705.9A CN118013146A (en) 2022-11-10 2022-11-10 Method and device for supporting automatic font collection and compression

Publications (1)

Publication Number Publication Date
CN118013146A true CN118013146A (en) 2024-05-10

Family

ID=90959129

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211403705.9A Pending CN118013146A (en) 2022-11-10 2022-11-10 Method and device for supporting automatic font collection and compression

Country Status (1)

Country Link
CN (1) CN118013146A (en)

Similar Documents

Publication Publication Date Title
US8413044B2 (en) Method and system of retrieving Ajax web page content
US20020188890A1 (en) System and method for testing an application
CN106293675B (en) System static resource loading method and device
US20120324422A1 (en) Live browser tooling in an integrated development environment
CN113051514B (en) Element positioning method and device, electronic equipment and storage medium
CN110825619A (en) Automatic generation method and device of interface test case and storage medium
CN109144567B (en) Cross-platform webpage rendering method and device, server and storage medium
CN110688307A (en) JavaScript code detection method, apparatus, device and storage medium
CN109408763B (en) Method and system for managing resume of different templates
CN114138244A (en) Method and device for automatically generating model files, storage medium and electronic equipment
JP2020126641A (en) Api mash-up exploration and recommendation
CN113419721B (en) Web-based expression editing method, device, equipment and storage medium
CN114297700B (en) Dynamic and static combined mobile application privacy protocol extraction method and related equipment
CN112269666B (en) Applet dead-link detection method and device, computing device and medium
CN114416481A (en) Log analysis method, device, equipment and storage medium
CN104778232A (en) Searching result optimizing method and device based on long query
CN116451271A (en) Automatic privacy policy extraction method for application software
CN118013146A (en) Method and device for supporting automatic font collection and compression
CN115481025A (en) Script recording method and device for automatic test, computer equipment and medium
CN109471966B (en) Method and system for automatically acquiring target data source
CN110147477B (en) Data resource modeling extraction method, device and equipment of Web system
CN110347577B (en) Page testing method, device and equipment thereof
CN117950716A (en) Webpage interface analysis method and device for browser end
US12001324B2 (en) Operation pattern generation apparatus, operation pattern generation method and program
CN114003714B (en) Intelligent knowledge pushing method for document context sensing

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination