CN113641369A - Font loading method and device, electronic equipment and storage medium - Google Patents

Font loading method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113641369A
CN113641369A CN202110931213.6A CN202110931213A CN113641369A CN 113641369 A CN113641369 A CN 113641369A CN 202110931213 A CN202110931213 A CN 202110931213A CN 113641369 A CN113641369 A CN 113641369A
Authority
CN
China
Prior art keywords
directory
font
font file
uri
program
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
CN202110931213.6A
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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information 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 Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202110931213.6A priority Critical patent/CN113641369A/en
Publication of CN113641369A publication Critical patent/CN113641369A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/955Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The application discloses a font loading method and device, electronic equipment and a storage medium. The method comprises the following steps: a first program of the electronic equipment caches a font file under a first directory of the electronic equipment to a preset second directory of the electronic equipment; the font file under the first directory contains Native font resources of the first program; the first program acquires the font file under the second directory by using at least one preset URI (Uniform resource identifier), and loads Native fonts on the Flutter page by using the font file under the second directory; each URI corresponds to at least one font file under the second directory.

Description

Font loading method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a data processing method and apparatus, an electronic device, and a storage medium.
Background
More and more cross-platform solutions have emerged for the development of application programs (APP). Among them, the Flutter technology is a cross-platform development framework derived from Google (Google), and has great advantages in performance, adaptability and other aspects. There are generally two modes of APP development based on Flutter technology:
1) carrying out APP development based on the newly-built Flutter project;
2) embedding a flute page in Native engineering to carry out hybrid development of APP.
Due to the fact that business logic in most of native APPs is relatively complex, if the Flutter technology is adopted to reconstruct the APPs, the period is long, and the risk is high; furthermore, the Flutter technique is not yet mature as a new technique. Therefore, APP development is generally performed by using the second mode (i.e., embedding a flute page in Native engineering for hybrid development of APP).
However, in the related art, for APP developed based on a mixture of Native technology and Flutter technology, the Native page and the Flutter page cannot share font resources.
Disclosure of Invention
In order to solve the related technical problems, embodiments of the present application provide a font loading method and apparatus, an electronic device, and a storage medium.
The technical scheme of the embodiment of the application is realized as follows:
the embodiment of the application provides a font loading method, which is applied to electronic equipment and comprises the following steps:
a first program of the electronic equipment caches a font file under a first directory of the electronic equipment to a preset second directory of the electronic equipment; the font file under the first directory contains Native font resources of the first program;
the first program obtains the font file under the second directory by using at least one preset Uniform Resource Identifier (URI), and loads Native fonts on a Flutter page by using the font file under the second directory; each URI corresponds to at least one font file under the second directory.
In the foregoing solution, the caching the font file in the first directory of the electronic device to the preset second directory of the electronic device includes:
the first program detects whether the second directory has cached font files or not when being started;
and the first program caches the font files in the first directory to the second directory when the second directory does not detect the cached font files.
In the foregoing scheme, the obtaining the font file in the second directory by using at least one preset URI includes:
the first program detects whether the second directory has a font file corresponding to a corresponding URI or not for each URI in the at least one URI; and under the condition that the font file corresponding to the corresponding URI exists in the second directory, acquiring the font file corresponding to the corresponding URI.
In the scheme, each URI also corresponds to a cloud downloading address of the font file; the obtaining of the font file under the second directory by using at least one preset URI includes:
the first program detects whether the second directory has a font file corresponding to a corresponding URI or not for each URI in the at least one URI; downloading the font file corresponding to the corresponding URI to the second directory by using the cloud downloading address corresponding to the corresponding URI under the condition that the font file corresponding to the corresponding URI does not exist in the second directory; and obtaining the font file corresponding to the corresponding URI.
In the foregoing solution, the loading Native fonts on the Flutter page by using the font files in the second directory includes:
the first program checks the validity of each font file in the second directory; and under the condition that the validity check of the corresponding font file passes, loading the corresponding Native font on the flute page by using the corresponding font file.
In the foregoing solution, the loading, by using the corresponding font file, the corresponding Native font on the Flutter page when the validity check of the corresponding font file passes includes:
and the first program decrypts the corresponding font file under the condition that the validity check of the corresponding font file passes, and loads the corresponding Native font on the Flutter page by using the decrypted font file.
In the above scheme, the method further comprises:
and the first program loads a preset system font on a Flutter page under the condition that Native fonts cannot be successfully loaded by using the font file in the second directory.
The embodiment of the present application further provides a font loading apparatus, which is disposed on an electronic device, and includes:
the first program unit is used for caching the font files under the first directory of the electronic equipment to a preset second directory of the electronic equipment; acquiring a font file under the second directory by using at least one preset URI (Uniform resource identifier), and loading Native fonts on a Flutter page by using the font file under the second directory; the font file under the first directory contains Native font resources of the first program unit; each URI corresponds to at least one font file under the second directory.
An embodiment of the present application further provides an electronic device, including: a processor and a memory for storing a computer program capable of running on the processor,
wherein the processor is configured to perform the steps of any of the above methods when running the computer program.
Embodiments of the present application also provide a storage medium having a computer program stored thereon, where the computer program is executed by a processor to implement the steps of any one of the above methods.
According to the font loading method and device, the electronic equipment and the storage medium provided by the embodiment of the application, a first program of the electronic equipment caches the font file under a first directory of the electronic equipment to a preset second directory of the electronic equipment; the font file under the first directory contains Native font resources of the first program; the first program acquires the font file under the second directory by using at least one preset URI (Uniform resource identifier), and loads Native fonts on the Flutter page by using the font file under the second directory; each URI corresponds to at least one font file under the second directory. According to the scheme of the embodiment of the application, a first program caches a font file under a first directory containing Native font resources to a preset second directory, and Native fonts are loaded on a flute page by utilizing the font file under the second directory; so, to the APP based on Native technique and the hybrid development of flute technique, Native page and flute page can share one Native typeface resource (the typeface file under the first catalogue), in other words, need not deposit two the same typeface resources at the installation package of APP to Native page and flute page respectively, and only need deposit one typeface resource at the installation package of APP, thereby can effectively reduce the volume of the installation package of APP, and then improve the efficiency that the user downloaded and installed APP, promote user experience.
Drawings
FIG. 1 is a schematic flow chart illustrating a font loading method according to an embodiment of the present application;
FIG. 2 is a schematic flowchart of font loading according to an embodiment of the present application;
FIG. 3 is a schematic structural diagram of a font loading apparatus according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples.
In the correlation technique, for the APP based on the hybrid development of the Native technology and the Flutter technology, if the Flutter page needs to load the custom font, the corresponding font resource needs to be built in the project (i.e. the installation package of the APP is stored), so that the custom font can be presented when the Flutter page displays the text by adding the parameter setting mode. However, because the storage positions (i.e. storage paths) of the font resources corresponding to the Native page and the Flutter page are different, the Native page and the Flutter page cannot share the font resources.
In actual application, in order to solve the problem that the Native page and the Flutter page cannot share font resources, two identical font resources can be stored in the APP installation package respectively for the Native page and the Flutter page. However, this results in waste of font resources built-in (i.e., saved) by the APP and adds extra volume to the APP's installation package.
Based on this, in various embodiments of the present application, a first program (APP) installed in an electronic device caches a font file in a first directory containing Native font resources to a preset second directory, and loads a Native font on a Flutter page by using the font file in the second directory; so, to the APP based on Native technique and the hybrid development of flute technique, Native page and flute page can share one Native typeface resource (the typeface file under the first catalogue), in other words, need not deposit two the same typeface resources at the installation package of APP to Native page and flute page respectively, and only need deposit one typeface resource at the installation package of APP, thereby can effectively reduce the volume of the installation package of APP, and then improve the efficiency that the user downloaded and installed APP, promote user experience.
An embodiment of the present application provides a font loading method applied to an electronic device, and as shown in fig. 1, the method includes:
step 101: a first program of the electronic equipment caches a font file under a first directory of the electronic equipment to a preset second directory of the electronic equipment;
here, the first program is implemented based on Native technology and Flutter technology; the font file under the first directory contains Native font resources of the first program;
step 102: the first program acquires the font file under the second directory by using at least one preset URI (Uniform resource identifier), and loads Native fonts on the Flutter page by using the font file under the second directory; each URI corresponds to at least one font file under the second directory.
In practical applications, the electronic device may include a Personal Computer (PC), a mobile phone, a wearable device, and the like; the PC may include a desktop computer, a notebook computer, a tablet computer, a vehicle-mounted computer, and the like.
In actual application, the first directory can be understood as a storage path of Native font resources of the first program; the second directory can be understood as a font resource cache path corresponding to the Flutter page of the first program; the caching of the font file in the first directory to the second directory may be understood as copying the font file in the first directory to a designated cache path (i.e., the second directory). Here, the first directory and the second directory may be preset according to a requirement; the first directory and the second directory may be generated during installation of the first program by the electronic device.
In step 101, in actual application, since the font files cached in the second directory may be cleared under specific conditions, for example, a user actively deletes the font files, and the cache management software clears the cache of the first program, in order to ensure that the Flutter page can load Native fonts, the first program needs to detect whether there are cached font files in the second directory at start-up, and cache the font files in the first directory to the second directory if the second directory does not detect the cached font files.
Based on this, in an embodiment, the caching the font file under the first directory of the electronic device to a preset second directory of the electronic device may include:
the first program detects whether the second directory has cached font files or not when being started;
and the first program caches the font files in the first directory to the second directory when the second directory does not detect the cached font files.
Here, the first program may execute the step 102 if the second directory detects a cached font file.
In actual application, when the first program is started for the first time after the first program is installed in the electronic device, since the font file in the first directory is not cached in the second directory, the first program may directly cache the font file in the first directory in the second directory without detecting whether the second directory has the cached font file. And under the condition of subsequent starting such as second starting, the first program detects whether the second directory has the cached font file, and determines whether caching operation needs to be executed or not based on the detection result.
Since the first program does not detect whether the second directory has the cached font file only when the first program is started, the first program may separately start a preset thread (hereinafter referred to as a first thread) to cache the font file in the first directory in the second directory when the first program is started. Under the condition of subsequent starting such as second starting, the first program detects whether the cached font file exists in the second directory through other preset threads (denoted as second threads in subsequent description), and caches the font file in the first directory to the second directory through the first thread under the condition that the cached font file is not detected in the second directory through the second threads.
In actual Application, when the first program is started, whether the second directory has the cached font file may be detected through an Application Programming Interface (API) provided by an operating system of the electronic device.
In step 102, in actual application, since the font files cached in the second directory may be cleared at any time, in order to ensure that the Flutter page can load Native fonts, the first program needs to detect whether the font files corresponding to the URIs exist in the second directory again in the process of acquiring the font files in the second directory by using at least one preset URI, and acquire the font files corresponding to the URIs in the second directory when it is determined that the font files corresponding to the URIs exist in the second directory.
Based on this, in an embodiment, the obtaining the font file under the second directory by using the preset at least one URI may include:
the first program detects whether the second directory has a font file corresponding to a corresponding URI or not for each URI in the at least one URI; and under the condition that the font file corresponding to the corresponding URI exists in the second directory, acquiring the font file corresponding to the corresponding URI.
In actual application, under the condition that the first program needs to acquire the font file in the second directory by using at least one preset URI, the font file in the second directory may already be cleared, so that to further ensure that the Flutter page can load Native fonts, the font file may be stored in the cloud server in advance, and a cloud download address capable of downloading a corresponding font file from the cloud server is preset for each URI; therefore, under the condition that the font file corresponding to the corresponding URI does not exist in the second directory, the first program can download the font file corresponding to the corresponding URI to the second directory by using the cloud downloading address corresponding to the corresponding URI, so that the Native font can be loaded on the Flutter page.
Based on this, in an embodiment, each URI may further correspond to a cloud download address of a font file; the obtaining the font file in the second directory by using the preset at least one URI may include:
the first program detects whether the second directory has a font file corresponding to a corresponding URI or not for each URI in the at least one URI; downloading the font file corresponding to the corresponding URI to the second directory by using the cloud downloading address corresponding to the corresponding URI under the condition that the font file corresponding to the corresponding URI does not exist in the second directory; and obtaining the font file corresponding to the corresponding URI.
In practical application, the format of each URI in the at least one URI may be set according to requirements. Illustratively, each URI may contain a "native font: font name "; at this time, when detecting whether the second directory has the font file corresponding to the corresponding URI, the first program may obtain the font name corresponding to the corresponding URI through the URI, and then detect whether the second directory has the font file corresponding to the font name through an API provided by an operating system of the electronic device.
In actual application, in order to further ensure that Native fonts can be loaded on the Flutter page, the number N of times of retry permission (where N is an integer greater than 0) can be preset when the file download fails, that is, the first program can perform N +1 times of download operations on the font file corresponding to the corresponding URI by using the cloud download address corresponding to the corresponding URI. Here, the value of N may be set as required. For example, N may be equal to the number of Internet Protocol (IP) address lists corresponding to cloud download addresses corresponding to corresponding URIs after domain name resolution.
In practical application, in the process of loading Native fonts on the Flutter page by using the font files in the second directory, in order to avoid malicious falsification of the font files, the data security of a user is guaranteed, and validity verification can be performed on the font files.
Based on this, in an embodiment, the loading Native fonts on the Flutter page by using the font file in the second directory may include:
the first program checks the validity of each font file in the second directory; and under the condition that the validity check of the corresponding font file passes, loading the corresponding Native font on the flute page by using the corresponding font file.
In actual application, the first program may check validity of the font file corresponding to the corresponding URI based on a preset first policy. The first policy may be set according to a requirement, for example, an MD5 Message Digest Algorithm (english may be expressed as Message Digest Algorithm 5) is used to check validity of a font file corresponding to the corresponding URI.
In practical application, in order to further prevent the font files from being maliciously falsified so as to ensure the data security of the user, each font file may be encrypted in advance, and accordingly, the first program may decrypt the corresponding font file and load the corresponding Native font on the Flutter page by using the decrypted font file.
Based on this, in an embodiment, in a case that the validity check of the corresponding font file passes, loading the corresponding Native font on the Flutter page by using the corresponding font file may include:
and the first program decrypts the corresponding font file under the condition that the validity check of the corresponding font file passes, and loads the corresponding Native font on the Flutter page by using the decrypted font file.
In actual application, the first program may decrypt the corresponding font file based on a preset second policy. The second policy may be set according to requirements, for example, font editing software such as fontfreator and FontForge may be used to decrypt a corresponding font file.
In actual application, in order to ensure that the Flutter page can be normally displayed, the system font loaded under the condition that the Flutter page cannot successfully load the Native font may be preset, that is, the first program may load the preset system font on the Flutter page under the condition that the font file under the second directory cannot successfully load the Native font.
Based on this, in an embodiment, the method may further include:
and the first program loads a preset system font on a Flutter page under the condition that Native fonts cannot be successfully loaded by using the font file in the second directory.
In practical applications, the case that Native fonts cannot be successfully loaded by using the font files in the second directory may include one of the following cases:
the font file corresponding to the corresponding URI cannot be downloaded to the second directory by using the cloud downloading address corresponding to the corresponding URI;
the corresponding font file fails to pass validity check;
the corresponding font file cannot be successfully decrypted.
In actual application, the first program and another program (hereinafter referred to as a second program) of the electronic device may also share the same font resource by using the at least one URI, that is, the second program may obtain the font file in the second directory by using the at least one URI, and load Native fonts on the Flutter page and/or the Native page by using the font file in the second directory; it is to be understood that the first program and the second program each have access to the second directory.
According to the font loading method provided by the embodiment of the application, a first program of the electronic equipment caches a font file under a first directory of the electronic equipment to a preset second directory of the electronic equipment; the font file under the first directory contains Native font resources of the first program; the first program acquires the font file under the second directory by using at least one preset URI (Uniform resource identifier), and loads Native fonts on the Flutter page by using the font file under the second directory; each URI corresponds to at least one font file under the second directory. According to the scheme of the embodiment of the application, a first program caches a font file under a first directory containing Native font resources to a preset second directory, and Native fonts are loaded on a flute page by utilizing the font file under the second directory; so, to the APP based on Native technique and the hybrid development of flute technique, Native page and flute page can share one Native typeface resource (the typeface file under the first catalogue), in other words, need not deposit two the same typeface resources at the installation package of APP to Native page and flute page respectively, and only need deposit one typeface resource at the installation package of APP, thereby can effectively reduce the volume of the installation package of APP, and then improve the efficiency that the user downloaded and installed APP, promote user experience.
The present application will be described in further detail with reference to the following application examples.
In this embodiment of the application, after the APP (i.e., the first program) is started for the first time, the existing Native built-in font resources (i.e., the Native font resources stored in the installation package of the APP) are stored in the specified directory (i.e., the second directory) in advance in a cache manner, and the Native font resources are shared to the Flutter end (i.e., the Flutter page) of the APP or shared to other APPs (e.g., the second program) for use in a URI loading manner.
In the embodiment of the application, the APP comprises a font preloading module, a font URI analyzing module and a cloud loading module; wherein,
the font preloading module is configured to, when the APP is started for the first time, process a caching operation of a font file including Native font resources by starting a preset separate thread (i.e., the first thread), so as to cyclically cache the Native font resources in a specified cache directory of the disk (i.e., the second directory of the electronic device). Here, the cycle means: when the cached font file is deleted under a specific condition (for example, the user actively deletes the cache, the cache management software clears the APP cache, and the like), the APP checks whether the cached font file exists in the cache directory after the next startup, and automatically caches the font file containing the Native font resource to the cache directory when the cached font file does not exist.
And the font URI analysis module is used for checking whether a corresponding font file exists in the cache directory or not when the flute page needs to load Native fonts according to the URI parameter information (namely the preset at least one URI) configured in the font display component. Here, the URI parameter information may include "native font: and the font URI analysis module can check whether a font file corresponding to the font name exists in the cache directory according to the font name contained in the URI parameter information. In addition, each built-in Native font can correspond to the font file at the cloud end one by one, namely, the font URI analysis module can inform the cloud end loading module when the local font file cannot be loaded normally so as to pull the font file at the cloud end for loading.
The cloud loading module is used for analyzing corresponding cloud font downloading addresses through the URI parameter information, in other words, each URI corresponds to one cloud font downloading address, and the cloud loading module can perform domain name analysis on the cloud font downloading addresses and download corresponding font files by using the IP addresses obtained through analysis. Here, the font file download failure may allow retry N times (N represents the number of corresponding IP address lists after domain name resolution), that is, at most, N +1 times of font file download operations may be performed.
In this application embodiment, the APP can carry out validity check on the font file acquired from the local or cloud, and the font file is prevented from being maliciously falsified to influence the use of a user. In addition, the font file may be encrypted in advance, that is, the APP may load the corresponding Native font after decrypting the font file.
In this application embodiment, as shown in fig. 2, a font loading process of an APP may specifically include the following steps:
step 201: the font preloading module checks whether the font file is cached successfully; if not, go to step 202; if yes, go to step 203;
step 202: caching a font file; then step 203 is executed;
step 203: opening a flute page and loading Native fonts; then step 204 is executed;
step 204: the font URI analysis module detects whether a font file corresponding to the URI exists or not; if yes, go to step 207; if not, go to step 205;
step 205: the cloud loading module downloads a font file corresponding to the URI; then step 206 is executed;
step 206: judging whether the font file is downloaded successfully; if yes, go to step 207; if not, go to step 208;
step 207: judging whether the font file passes validity check; if yes, go to step 209; if not, go to step 208;
step 208: the Flutter page displays system fonts;
step 209: judging whether the font file is decrypted successfully or not; if yes, go to step 210; if not, go to step 208;
step 210: the flute page displays Native fonts.
In the embodiment of the application, when the APP is started for the first time, the font file containing Native font resources is cached; after the APP is started next time, the font cache file is checked, and if the cached font file is not detected, the Native font file is automatically cached to the specified cache directory; the Flutter page of the APP can load a specified Native font through URI parameter information configured in the font display component.
In the embodiment of the application, the rule for loading the Native font includes: the font name that obtains is linked to the utilization analysis URI, the font file of local cache is loaded to the priority, every font file again with high in the clouds font file one-to-one (also can understand as every Native typeface and high in the clouds font file one-to-one), when the font file of local cache can't normally load, APP can draw the font file in the clouds to load in order to show Native typeface, when APP from high in the clouds download font file fails, APP acquiesces for default and shows appointed system font at the flute page.
During actual application, in the process of rendering Native fonts on the Flutter page of the APP, the APP can first pre-load the font files cached locally, that is, check whether the locally cached font files exist and are available (that is, validity check), and if the locally cached font files are valid, the APP can directly read the font files from the cache directory and display corresponding custom Native fonts.
The scheme provided by the application embodiment optimizes and improves the Native font loading mode of the Flutter page, and has the following advantages:
1) the flute page and the Native page can share the same font resource;
2) the volume of the installation package of the APP is effectively reduced;
3) multiple APPs may share the same font resource.
In order to implement the method of the embodiment of the present application, an embodiment of the present application further provides a font loading apparatus, as shown in fig. 3, a font loading apparatus 302 is disposed on an electronic device 301, and the apparatus includes:
a first program unit 303, configured to cache a font file in a first directory of the electronic device 301 to a preset second directory of the electronic device 301; acquiring a font file under the second directory by using at least one preset URI (Uniform resource identifier), and loading Native fonts on a Flutter page by using the font file under the second directory; the first program unit 303 is implemented based on Native technology and Flutter technology; the font file in the first directory contains Native font resources of the first program unit 303; each URI corresponds to at least one font file under the second directory.
In an embodiment, the first program unit 303 is specifically configured to:
detecting whether the second directory has a cached font file or not when the second directory is started;
and caching the font files in the first directory to the second directory when the second directory does not detect the cached font files.
In an embodiment, the first program unit 303 is further configured to, for each URI of the at least one URI, detect whether a font file corresponding to the corresponding URI exists in the second directory; and under the condition that the font file corresponding to the corresponding URI exists in the second directory, acquiring the font file corresponding to the corresponding URI.
In one embodiment, each URI further corresponds to a cloud download address of a font file; the first program unit 303 is further configured to detect, for each URI in the at least one URI, whether a font file corresponding to the corresponding URI exists in the second directory; downloading the font file corresponding to the corresponding URI to the second directory by using the cloud downloading address corresponding to the corresponding URI under the condition that the font file corresponding to the corresponding URI does not exist in the second directory; and obtaining the font file corresponding to the corresponding URI.
In an embodiment, the first program unit 303 is further configured to check validity of each font file in the second directory; and under the condition that the validity check of the corresponding font file passes, loading the corresponding Native font on the flute page by using the corresponding font file.
In an embodiment, the first program unit 303 is further configured to decrypt the corresponding font file when the validity check of the corresponding font file passes, and load a Native font on the Flutter page by using the decrypted font file.
In an embodiment, the first program unit 303 is further configured to load a preset system font on a Flutter page if a Native font cannot be successfully loaded by using the font file in the second directory.
Here, the function of the first program unit 303 is equivalent to the functions of the font preloading module, the font URI parsing module and the cloud loading module in the above application embodiments.
In practice, the first program unit 303 may be implemented by a processor in the font loading apparatus.
It should be noted that: the font loading apparatus provided in the above embodiment is only illustrated by the division of the program modules when loading the font, and in practical application, the processing allocation may be completed by different program modules according to needs, that is, the internal structure of the apparatus is divided into different program modules to complete all or part of the processing described above. In addition, the font loading device and the font loading method provided by the above embodiments belong to the same concept, and specific implementation processes thereof are described in the method embodiments in detail and are not described herein again.
Based on the hardware implementation of the program module, and in order to implement the method according to the embodiment of the present application, an embodiment of the present application further provides an electronic device, as shown in fig. 4, where the electronic device 400 includes:
the communication interface 401 can perform information interaction with other electronic equipment;
the processor 402 is connected with the communication interface 401 to realize information interaction with other electronic devices, and is used for executing the method provided by one or more technical schemes when running a computer program;
a memory 403 storing a computer program capable of running on the processor 402.
Specifically, the processor 402 is configured to:
by operating the first program stored in the memory 403, caching the font file in the first directory of the electronic device 400 to a preset second directory of the electronic device 400; the first program is realized based on Native technology and Flutter technology; the font file under the first directory contains Native font resources of the first program;
obtaining font files under the second directory by using at least one preset URI (Uniform resource identifier) through running the first program, and loading Native fonts on a Flutter page by using the font files under the second directory; each URI corresponds to at least one font file under the second directory.
In an embodiment, the processor 402 is specifically configured to:
by running the first program, detecting whether the second directory has a cached font file when the first program is started;
and caching the font files in the first directory to the second directory by running the first program under the condition that the second directory does not detect the cached font files.
In an embodiment, the processor 402 is further configured to execute the first program, and for each URI of the at least one URI, detect whether a font file corresponding to the corresponding URI exists in the second directory; and under the condition that the font file corresponding to the corresponding URI exists in the second directory, acquiring the font file corresponding to the corresponding URI.
In one embodiment, each URI further corresponds to a cloud download address of a font file; the processor 402 is further configured to, by running the first program, detect, for each URI of the at least one URI, whether a font file corresponding to the corresponding URI exists in the second directory; downloading the font file corresponding to the corresponding URI to the second directory by using the cloud downloading address corresponding to the corresponding URI under the condition that the font file corresponding to the corresponding URI does not exist in the second directory; and obtaining the font file corresponding to the corresponding URI.
In an embodiment, the processor 402 is further configured to check validity of each font file in the second directory by running the first program; and under the condition that the validity check of the corresponding font file passes, loading the corresponding Native font on the flute page by using the corresponding font file.
In an embodiment, the processor 402 is further configured to decrypt the corresponding font file by running the first program, and load the corresponding Native font on the Flutter page by using the decrypted font file, when the validity check of the corresponding font file passes.
In an embodiment, the processor 402 is further configured to load a preset system font on a Flutter page by running the first program, where Native fonts cannot be successfully loaded by using the font file in the second directory.
It should be noted that: the process of the processor 402 specifically executing the above operations is detailed in the method embodiment, and is not described here again.
Of course, in practice, the various components in the electronic device 400 are coupled together by a bus system 404. It is understood that the bus system 404 is used to enable communications among the components. The bus system 404 includes a power bus, a control bus, and a status signal bus in addition to a data bus. For clarity of illustration, however, the various buses are labeled as bus system 404 in FIG. 4.
The memory 403 in the embodiments of the present application is used to store various types of data to support the operation of the electronic device 400. Examples of such data include: any computer program for operating on the electronic device 400.
The method disclosed in the embodiments of the present application may be applied to the processor 402 or implemented by the processor 402. The processor 402 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in the form of software in the processor 402. The Processor 402 may be a general purpose Processor, a Digital Signal Processor (DSP), or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like. Processor 402 may implement or perform the methods, steps, and logic blocks disclosed in the embodiments of the present application. A general purpose processor may be a microprocessor or any conventional processor or the like. The steps of the method disclosed in the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium located in memory 403, and the processor 402 reads the information in memory 403 and performs the steps of the aforementioned methods in conjunction with its hardware.
In an exemplary embodiment, the electronic Device 400 may be implemented by one or more Application Specific Integrated Circuits (ASICs), DSPs, Programmable Logic Devices (PLDs), Complex Programmable Logic Devices (CPLDs), Field Programmable Gate Arrays (FPGAs), general purpose processors, controllers, Micro Controllers (MCUs), microprocessors (microprocessors), or other electronic components for performing the foregoing methods.
It is understood that the memory 403 of the embodiments of the present application may be either volatile memory or nonvolatile memory, and may include both volatile and nonvolatile memory. Among them, the nonvolatile Memory may be a Read Only Memory (ROM), a Programmable Read Only Memory (PROM), an Erasable Programmable Read-Only Memory (EPROM), an Electrically Erasable Programmable Read-Only Memory (EEPROM), a magnetic random access Memory (FRAM), a Flash Memory (Flash Memory), a magnetic surface Memory, an optical disk, or a Compact Disc Read-Only Memory (CD-ROM); the magnetic surface storage may be disk storage or tape storage. Volatile Memory can be Random Access Memory (RAM), which acts as external cache Memory. By way of illustration and not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), Enhanced Synchronous Dynamic Random Access Memory (Enhanced DRAM), Synchronous Dynamic Random Access Memory (SLDRAM), Direct Memory (DRmb Access), and Random Access Memory (DRAM). The memories described in the embodiments of the present application are intended to comprise, without being limited to, these and any other suitable types of memory.
In an exemplary embodiment, the present application further provides a storage medium, i.e. a computer storage medium, in particular a computer readable storage medium, for example, including a memory 403 storing a computer program, which can be executed by a processor 402 of the electronic device 400 to perform the steps of the foregoing method. The computer readable storage medium may be Memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface Memory, optical disk, or CD-ROM.
It should be noted that: "first," "second," and the like are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
The technical means described in the embodiments of the present application may be arbitrarily combined without conflict.
The above description is only a preferred embodiment of the present application, and is not intended to limit the scope of the present application.

Claims (10)

1. A font loading method is applied to electronic equipment and comprises the following steps:
a first program of the electronic equipment caches a font file under a first directory of the electronic equipment to a preset second directory of the electronic equipment; the font file under the first directory contains Native font resources of the first program;
the first program obtains the font file under the second directory by using at least one preset Uniform Resource Identifier (URI), and loads Native fonts on the Flutter page by using the font file under the second directory; each URI corresponds to at least one font file under the second directory.
2. The method of claim 1, wherein caching the font files under the first directory of the electronic device to a preset second directory of the electronic device comprises:
the first program detects whether the second directory has cached font files or not when being started;
and the first program caches the font files in the first directory to the second directory when the second directory does not detect the cached font files.
3. The method according to claim 1, wherein the obtaining the font file under the second directory by using the preset at least one URI comprises:
the first program detects whether the second directory has a font file corresponding to a corresponding URI or not for each URI in the at least one URI; and under the condition that the font file corresponding to the corresponding URI exists in the second directory, acquiring the font file corresponding to the corresponding URI.
4. The method of claim 1, wherein each URI further corresponds to a cloud download address of a font file; the obtaining of the font file under the second directory by using at least one preset URI includes:
the first program detects whether the second directory has a font file corresponding to a corresponding URI or not for each URI in the at least one URI; downloading the font file corresponding to the corresponding URI to the second directory by using the cloud downloading address corresponding to the corresponding URI under the condition that the font file corresponding to the corresponding URI does not exist in the second directory; and obtaining the font file corresponding to the corresponding URI.
5. The method according to any one of claims 1 to 4, wherein the loading Native fonts on the Flutter page by using the font files under the second directory comprises:
the first program checks the validity of each font file in the second directory; and under the condition that the validity check of the corresponding font file passes, loading the corresponding Native font on the flute page by using the corresponding font file.
6. The method according to claim 5, wherein, in the case that the validity check of the corresponding font file passes, loading the corresponding Native font on the Flutter page by using the corresponding font file comprises:
and the first program decrypts the corresponding font file under the condition that the validity check of the corresponding font file passes, and loads the corresponding Native font on the Flutter page by using the decrypted font file.
7. The method according to any one of claims 1 to 4, further comprising:
and the first program loads a preset system font on a Flutter page under the condition that Native fonts cannot be successfully loaded by using the font file in the second directory.
8. A font loading apparatus, provided on an electronic device, includes:
the first program unit is used for caching the font files under the first directory of the electronic equipment to a preset second directory of the electronic equipment; acquiring a font file under the second directory by using at least one preset URI (Uniform resource identifier), and loading Native fonts on a Flutter page by using the font file under the second directory; the font file under the first directory contains Native font resources of the first program unit; each URI corresponds to at least one font file under the second directory.
9. An electronic device, comprising: a processor and a memory for storing a computer program capable of running on the processor,
wherein the processor is adapted to perform the steps of the method of any one of claims 1 to 7 when running the computer program.
10. A storage medium having a computer program stored thereon, the computer program, when being executed by a processor, performing the steps of the method of any one of claims 1 to 7.
CN202110931213.6A 2021-08-13 2021-08-13 Font loading method and device, electronic equipment and storage medium Pending CN113641369A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110931213.6A CN113641369A (en) 2021-08-13 2021-08-13 Font loading method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110931213.6A CN113641369A (en) 2021-08-13 2021-08-13 Font loading method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113641369A true CN113641369A (en) 2021-11-12

Family

ID=78421493

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110931213.6A Pending CN113641369A (en) 2021-08-13 2021-08-13 Font loading method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113641369A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103440143A (en) * 2013-08-02 2013-12-11 安徽科大讯飞信息科技股份有限公司 System and method for upgrading mobile web application
US20140033219A1 (en) * 2012-07-24 2014-01-30 Mstar Semiconductor, Inc. Method, apparatus and computer for loading resource file for game engine
US20170048319A1 (en) * 2015-08-11 2017-02-16 Oracle International Corporation Asynchronous pre-caching of synchronously loaded resources
CN106886419A (en) * 2017-03-28 2017-06-23 武汉斗鱼网络科技有限公司 Network picture loading method and device
CN108549556A (en) * 2018-04-16 2018-09-18 腾讯科技(深圳)有限公司 A kind of application program accelerated method, device, terminal and storage medium
CN109144619A (en) * 2017-06-14 2019-01-04 阿里巴巴集团控股有限公司 Icon font information processing method, apparatus and system
CN110168539A (en) * 2017-01-13 2019-08-23 微软技术许可有限责任公司 Fast Page load in mixing application

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140033219A1 (en) * 2012-07-24 2014-01-30 Mstar Semiconductor, Inc. Method, apparatus and computer for loading resource file for game engine
CN103440143A (en) * 2013-08-02 2013-12-11 安徽科大讯飞信息科技股份有限公司 System and method for upgrading mobile web application
US20170048319A1 (en) * 2015-08-11 2017-02-16 Oracle International Corporation Asynchronous pre-caching of synchronously loaded resources
CN110168539A (en) * 2017-01-13 2019-08-23 微软技术许可有限责任公司 Fast Page load in mixing application
CN106886419A (en) * 2017-03-28 2017-06-23 武汉斗鱼网络科技有限公司 Network picture loading method and device
CN109144619A (en) * 2017-06-14 2019-01-04 阿里巴巴集团控股有限公司 Icon font information processing method, apparatus and system
CN108549556A (en) * 2018-04-16 2018-09-18 腾讯科技(深圳)有限公司 A kind of application program accelerated method, device, terminal and storage medium

Similar Documents

Publication Publication Date Title
EP3441876B1 (en) Patch upgrade-based file processing method and device, terminal, and storage medium
CN108108205B (en) Application page surface treatment method and apparatus
JP6248153B2 (en) Activate trust level
WO2020253061A1 (en) Page generating method and apparatus, computer device, and storage medium
CN108229112B (en) Protection application program, and running method and device of application program
WO2019201039A1 (en) Method and system for updating application and application server
US20150012924A1 (en) Method and Device for Loading a Plug-In
US20160070812A1 (en) Secure Document Sharing
CN110333868B (en) Method and system for generating installation packages of sub-applications
WO2021164462A1 (en) Data encryption method, data decryption method, computer device, and medium
US9513762B1 (en) Static content updates
CN112667246B (en) Application function expansion method and device and electronic equipment
KR20040105794A (en) Memory managing unit, code verifying device, and code decoder
CN104036194A (en) Vulnerability detection method and device for revealing private data in application program
US20180097817A1 (en) Generating short-term signatures for accessing cloud storage
CN111382425B (en) Application installation management method under multi-signature mechanism, intelligent terminal and storage medium
CN114048169A (en) Document access method, device, server and storage medium
Votipka et al. Passe-partout: A general collection methodology for Android devices
Huber et al. A flexible framework for mobile device forensics based on cold boot attacks
US10853057B1 (en) Software library versioning with caching
CN113641369A (en) Font loading method and device, electronic equipment and storage medium
CN114462101A (en) Processing system, method and device for application apk packet
CN115150392A (en) Remote file copying method, system, computing equipment and storage medium
US11379653B2 (en) Rendering method for on-demand loading of PDF file on network
US10044728B1 (en) Endpoint segregation to prevent scripting attacks

Legal Events

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