Font switching method and device, storage medium and program product
By obtaining and analyzing font lists on the web page, detecting and processing non-copyright fonts, the problem of font copyright in web page text editing is solved, and accurate detection of fonts used by users is achieved and copyright compliance reminders and processing are realized.
Patent Information
- Application Number
- CN202411814411.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-04-04
Smart Images

Figure CN119761305A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of web page design, and in particular to a font switching method, device, storage medium and program product. Background Art
[0002] The copyright issue of web fonts is an important issue in the digital age. When users edit web texts, they usually use multiple fonts, and the use of fonts will involve corresponding copyright issues. Therefore, how to effectively avoid font copyright issues when users edit web texts has become an urgent problem to be solved. Summary of the invention
[0003] Multiple aspects of the present application provide a font switching method, device, storage medium and program product for more accurately detecting whether a user uses a non-copyrighted font, thereby more efficiently helping the user avoid font copyright issues.
[0004] The embodiment of the present application provides a font switching method, comprising: in response to a loading instruction of a target page, obtaining a font list and storing it in a resource document of the target page; the font list comprises: attribute information of each of a plurality of fonts; the plurality of fonts are divided into a copyright type and a non-copyright type according to their respective attribute information; the target page is associated with a font selection control; in response to a text editing operation on the target page using at least one font, obtaining text information added based on the text editing operation, and adding the text information to the resource document, the text information comprising at least one text segment, the at least one text segment being obtained by performing text editing using the at least one font; in the case where it is determined according to the attribute information of the at least one font that there is a first font of the non-copyright type in the at least one font, determining a target text segment corresponding to the first font from the text information in the resource document, and outputting copyright prompt information to remind a user to switch the font for the target text segment; in response to a trigger operation on the font selection control, determining a second font of the copyright type selected by the user from the font list, and switching the first font of the target text segment in the resource document to the second font.
[0005] Optionally, obtaining a font list and storing it in a resource document of the target page includes: obtaining attribute information and storage path information of each of the multiple fonts; generating corresponding font rule information for the multiple fonts based on the attribute information and storage path information of each of the multiple fonts, and adding the font rule information of the multiple fonts to the font list; creating a custom font tag in the header area of the resource document, and adding the font list under the custom font tag.
[0006] Optionally, the font list also includes: storage path information of each of the multiple fonts; in response to a text editing operation on the target page using at least one font, obtaining text information added based on the text editing operation, including: in response to a triggering operation on the font selection control, determining any font selected by the user; in response to an editing operation using any of the fonts, adding text information using any of the fonts on a layer corresponding to the target page according to the storage path information of any of the fonts; and adding the text information to the resource document.
[0007] Optionally, the target page is also associated with a save control; adding the text information to the resource document includes: in response to a trigger operation on the save control, serializing the text information using any one of the fonts into structured data; adding the structured data to a corresponding position in the resource document, and the structured data is used to deserialize to obtain the text information.
[0008] Optionally, the target page is associated with a serialization interface, which points to a serialization function module; serializing the text information using any one of the fonts into structured data includes: calling the serialization interface, sending the text information using any one of the fonts to the serialization function module pointed to by the serialization interface, so that the serialization function module serializes the text information using any one of the fonts into structured data.
[0009] Optionally, it also includes: adding the attribute information of each of the at least one font of the copyright type to the first set; adding the attribute information of each of the at least one font of the non-copyright type to the second set; and determining that there is a first font of the non-copyright type in the at least one font based on the attribute information of the at least one font, including: traversing the attribute information of the at least one font, and determining that there is a first font of the non-copyright type in the at least one font when the traversed attribute information appears in the second set.
[0010] Optionally, switching the first font of the target text fragment in the resource document to the second font includes: modifying the attribute information of the first font of the target text fragment to the attribute information of the second font, and rendering the target text fragment to the target page according to the modified attribute information of the target text fragment.
[0011] Optionally, the target page includes: a web page, an application page or a mini-program page.
[0012] An embodiment of the present application also provides an electronic device, comprising: a memory and a processor; wherein the memory is used to: store one or more computer instructions; the processor is used to execute the one or more computer instructions to: execute the steps in the font switching method.
[0013] The embodiment of the present application also provides a computer-readable storage medium, which, when the computer program is executed by a processor, enables the processor to implement the steps in the font switching method.
[0014] An embodiment of the present application further provides a computer program product, including a computer program / instruction. When the computer program / instruction is executed by a processor, the processor is enabled to implement the steps in the font switching method.
[0015] In this embodiment, in response to the loading instruction of the target page, the font list can be obtained and stored in the resource document of the target page; in response to the text editing operation of the target page with at least one font, each text segment obtained by text editing with any font is added to the resource document; in the case where it is determined that there is a first font of a non-copyright type in at least one font according to the attribute information of at least one font, the target text segment corresponding to the first font is determined from the text information in the resource document, and the copyright prompt information is output to remind the user to switch the font for the target text segment; the first font of the target text segment in the resource document is switched to the second font of the copyright type. In this way, it is possible to more accurately detect whether the user uses a non-copyright font, thereby more efficiently avoiding font copyright issues for the user. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0017] Figure 1 A flowchart of a font switching method provided by an exemplary embodiment of the present application;
[0018] Figure 2 A schematic diagram of a page display after adding text segments corresponding to different fonts provided by an exemplary embodiment of the present application;
[0019] Figure 3 A schematic diagram of a pop-up window effect provided by an exemplary embodiment of the present application;
[0020] Figure 4 A schematic diagram of font modification provided for an exemplary embodiment of the present application;
[0021] Figure 5A schematic diagram of a page for re-rendering a page provided by an exemplary embodiment of the present application;
[0022] Figure 6 A schematic diagram of an electronic device provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0023] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0024] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation portals for users to choose to authorize or refuse. In addition, the various models involved in this application (including but not limited to language models or large models) are in compliance with relevant laws and standards.
[0025] The copyright issue of web fonts is an important issue in the digital age. When users edit web texts, they usually use multiple fonts, and the use of fonts will involve corresponding copyright issues. Therefore, how to effectively avoid font copyright issues when users edit web texts has become an urgent problem to be solved.
[0026] In response to the above technical problems, in an embodiment of the present application, when a user edits text on a target page using at least one font, it can be more accurately determined whether there is a first font of a non-copyright type in at least one font based on the attribute information of the at least one font, and copyright prompt information can be output to remind the user to switch the font for the target text segment edited using the first font; then, in response to a trigger operation on a font selection control, a second font of a copyright type selected by the user can be determined from a font list, and the first font of the target text segment in the resource document can be switched to the second font, so as to more efficiently avoid font copyright issues for users.
[0027] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0028] Figure 1 The font switching method provided by the exemplary embodiment of the present application is as follows: Figure 1 As shown, the method may include the following steps:
[0029] Step 11, responding to the loading instruction of the target page, obtaining the font list and storing it in the resource document of the target page; the font list includes: attribute information of each of the multiple fonts; the multiple fonts are divided into copyright type and non-copyright type according to their respective attribute information; the target page is associated with a font selection control.
[0030] Step 12, in response to a text editing operation on a target page using at least one font, obtain text information added based on the text editing operation, and add the text information to a resource document, wherein the text information includes at least one text fragment, and the at least one text fragment is obtained by text editing using at least one font.
[0031] Step 13: When it is determined that a first font of a non-copyright type exists in at least one font based on the attribute information of at least one font, a target text segment corresponding to the first font is determined from the text information in the resource document, and copyright prompt information is output to remind the user to switch the font for the target text segment.
[0032] Step 14: In response to the triggering operation on the font selection control, determine the second font of the copyright type selected by the user from the font list, and switch the first font of the target text segment in the resource document to the second font.
[0033] The execution subject in this embodiment can be any electronic device, such as a server or a terminal device. The terminal device can be a mobile phone, a tablet computer, a computer, etc. This embodiment does not limit the specific implementation method of the electronic device.
[0034] In this embodiment, the target page can be any one of a web page, an application page, or a mini-program page, and this embodiment does not limit this. The target page loading instruction can be generated in response to the user's opening operation on the target page, or can be generated according to a timed page loading event, and this embodiment does not limit this.
[0035] In response to the loading instruction of the target page, a font list can be obtained and stored in the resource document of the target page. The font list includes: attribute information of each of the multiple fonts, and the attribute information is used to describe the inherent attributes of the font, such as font type, name, identification number, size and thickness, etc. In this embodiment, the multiple fonts are divided into copyright type and non-copyright type according to their respective attribute information, wherein the copyright type refers to the font type that has obtained the copyright of the font developer in advance, and the non-copyright type refers to the font type that has not obtained the copyright of the font developer. The resource document of the target page is used to construct the target page, which can be understood as a collection of information resources related to the target page. For example, when the target page is a web page, the resource document of the target page can be an HTML (Hyper Text Markup Language) document.
[0036] In this embodiment, the target page can be displayed to the user, and the user can edit the text of the target page in at least one font; correspondingly, in response to the text editing operation on the target page in at least one font, the text information added based on the text editing operation can be obtained, and the text information can be added to the resource document. The text information may include at least one text segment, and the at least one text segment is respectively obtained by text editing in at least one font.
[0037] For example, the user can use font U1 to input "123" on the target page, and use font U2 to input "456" on the target page. Correspondingly, in response to the above-mentioned text editing operations on the target page using font U1 and font U2, the text information "123456" added based on the text editing operations can be obtained. The text information includes text fragment P1 "123" and text fragment P2 "456". Text fragment P1 is obtained by text editing using font U1, and text fragment P2 is obtained by text editing using font U2.
[0038] Afterwards, it can be determined whether there is a non-copyrighted first font in at least one font based on the attribute information of at least one font, wherein the first font refers to a non-copyrighted font in at least one font. In the case where it is determined that there is a non-copyrighted first font in at least one font based on the attribute information of at least one font, a target text segment corresponding to the first font can be determined from the text information in the resource document, and copyright prompt information can be output to remind the user to switch the font for the target text segment. The target text segment refers to a text segment corresponding to a non-copyrighted font in at least one text segment of the text information.
[0039] This embodiment does not limit the number of first fonts, which can be one or more. Correspondingly, the number of target text segments can also be one or more, depending on the situation in the actual scene. For example, the user can use font U10, font U11, font U12 and font U13 to perform text editing operations on the target page. The non-copyright types of fonts U10, font U11, font U12 and font U13 are font U11 and font U12. Correspondingly, the target text segments can be text segments obtained by text editing with font U11 and text segments obtained by text editing with font U12.
[0040] This embodiment does not limit the specific implementation method of outputting the copyright prompt information, which may be in the form of a pop-up window or a floating layer, in the form of a prompt sound, or in the form of highlighting the target text segment, etc.
[0041] The user can trigger the font selection control associated with the target page according to the copyright prompt information. Correspondingly, in response to the triggering operation on the font selection control, a second font of the copyright type selected by the user can be determined from the font list, and the first font of the target text segment in the resource document can be switched to the second font.
[0042] In this embodiment, in response to the loading instruction of the target page, the font list can be obtained and stored in the resource document of the target page; in response to the text editing operation of the target page with at least one font, each text segment obtained by text editing with any font is added to the resource document; in the case where it is determined that there is a first font of a non-copyright type in at least one font according to the attribute information of at least one font, the target text segment corresponding to the first font is determined from the text information in the resource document, and the copyright prompt information is output to remind the user to switch the font for the target text segment; the first font of the target text segment in the resource document is switched to the second font of the copyright type. In this way, it is possible to more accurately detect whether the user uses a non-copyright font, thereby more efficiently avoiding font copyright issues for the user.
[0043] In some optional embodiments, step 11 of the aforementioned embodiment, "obtaining a font list and storing it in a resource document of a target page", can be implemented based on the following steps:
[0044] Step 111, obtain the attribute information and storage path information of each of the multiple fonts. The storage path information of the font is used for the storage location where the font file is stored, which can be implemented as a TTF (TrueTypeFont, font) file path, such as: YEFONTAoYeHei.ttf, or as a URL (Uniform Resource Locator, Uniform Resource Locator System) corresponding to the font. Optionally, the attribute information and storage path information of each of the multiple fonts can be obtained from other terminal devices, servers or other arbitrary devices, and this embodiment does not limit this. Optionally, after obtaining the attribute information and storage path information of each of the multiple fonts, a font loader can be used to load the multiple fonts, such as FontFaceObserver (a font loader and monitor).
[0045] Step 112: Generate corresponding font rule information for the multiple fonts according to the attribute information and storage path information of the multiple fonts, and add the font rule information of the multiple fonts to the font list. The attribute information and storage path information of any font can be used as the font rule information corresponding to any font.
[0046] Step 113, create a custom font tag in the head area of the resource document, and add the font list to the custom font tag. The tag creation method can be called to create the custom font tag in the head area of the resource document, such as the document.createElement('style') method; then the list addition method can be called to add the font list to the custom font tag, such as the document.head.appendChild method. In this way, when the resource document is loaded, the custom font tag in the head area can be loaded first, thereby loading the font list first.
[0047] Based on the above steps 111 to 113 , the font list can be obtained more efficiently and stored in the header area of the resource document of the target page, so as to load the font list preferentially.
[0048] In some optional embodiments, the font list may further include: storage path information of each of the multiple fonts. Based on this, step 12 in the aforementioned embodiment, "responding to a text editing operation on the target page using at least one font, obtaining text information added based on the text editing operation", may be implemented based on the following steps:
[0049] Step 121: respond to the triggering operation of the font selection control and determine any font selected by the user. In which, in response to the triggering operation of the font selection control, a font list may be displayed to the user for the user to select a font.
[0050] Step 122: In response to the editing operation using any font, text information using any font is added to the layer corresponding to the target page according to the storage path information of any font. In response to the editing operation using any font, the storage path information of any font can be determined from the resource document, and the font file of the font can be called according to the storage path information of any font, and the text information using any font is added to the layer corresponding to the target page based on the font file of the font.
[0051] Step 123: Add text information to the resource document.
[0052] Among them, after the user selects any font for editing, the save control associated with the target page can be triggered to save the currently edited target page. Correspondingly, in response to the triggering operation of the save control, the text information using any font can be serialized into structured data. Among them, structured data refers to data with a clear format and organizational form, which can be Json (JavaScript Object Notation) data or other data, and this embodiment does not limit it. This step can be understood as: after the user edits the text of the target page on the front end, the structured data corresponding to the text editing operation has not been generated in the resource document on the back end; when the user triggers the save control, the corresponding structured data can be generated on the back end, that is, the text information using any font is serialized into structured data.
[0053] The serialization process here refers to the process of converting text information in any font into structured data that can be stored in a resource document. The structured data obtained by serialization can be used to describe the text information and its corresponding font.
[0054] Specifically, the target page may be associated with a serialization interface, which may point to a serialization function module. Based on this, the serialization interface may be called to send text information in any font to the serialization function module pointed to by the serialization interface, so that the serialization function module serializes the text information in any font into structured data.
[0055] Step 124, adding the structured data to the corresponding position in the resource document, and the structured data is used for deserialization to obtain text information. Among them, the structured data can be added to the corresponding position in the resource document according to the preset correspondence between the structured data and the resource document position. Different from the aforementioned serialization, the deserialization process here is opposite to the serialization process, and refers to the process of converting the serialized structured data back into text information using any font. In other words, when the target page is displayed to the user based on the structured data, the structured data can be deserialized to obtain the text information and display it on the target page.
[0056] Based on the above steps 121 to 124, in response to a text editing operation on a target page using at least one font, text information using any font can be added to a layer corresponding to the target page on the front end; and text information using any font can be more efficiently converted into structured data on the back end and stored in a resource document.
[0057] In some optional embodiments, after obtaining the font list in response to the load instruction of the target page, the attribute information of at least one copyrighted font can be added to the first set; and the attribute information of at least one non-copyrighted font can be added to the second set. The set can be implemented in any form such as an array or a hash table, which is not limited in this embodiment.
[0058] Based on this, when determining that a first font of a non-copyright type exists in at least one font according to the attribute information of at least one font, the attribute information of at least one font can be traversed, and when the traversed attribute information appears in the second set, it is determined that a first font of a non-copyright type exists in at least one font.
[0059] In this way, it is possible to more accurately determine whether there is a non-copyrighted first font in at least one font based on the attribute information of at least one font.
[0060] In some optional embodiments, when the first font of the target text segment in the resource document is switched to the second font, the attribute information of the first font of the target text segment can be modified to the attribute information of the second font, and the target text segment can be rendered to the target page according to the modified attribute information of the target text segment. In this way, the first font of the target text segment in the resource document can be switched to the second font more efficiently, thereby completing the modification of the resource document and the page visualization of the modified font.
[0061] The following will further explain the font switching method in combination with actual application scenarios.
[0062] In actual scenarios, taking the target page as a web page and the resource document as an HTML document as an example, the execution subject can be the Leafer UI (User Interface) development tool running on the electronic device, where Leafer UI is a colorful UI drawing framework developed based on Leafer, which can perform AI drawing and generate interfaces. Among them, Leafer is a Canvas engine, and Canvas is an element provided by HTML5 for drawing graphics, animations, etc. Through Canvas, JavaScript (an advanced, interpreted programming language) can be used to dynamically draw graphics, process images, create animations, and achieve various visual effects.
[0063] The Leafer UI development tool can obtain a variety of fonts including non-copyright fonts and copyright fonts through the back-end interface, and store the attribute information and storage path information of the non-copyright fonts and copyright fonts in the first set and the second set respectively. Taking the collection as an array as an example, the non-copyright fonts can be added to the fontRisk array, and the copyright fonts can be added to the fontNoRisk array. The attribute information may include the data name fontName, the font identification number, and the font display title. For example, the data name may be "YEFONTAoYeHei-Regular", the font identification number may be 2, and the font display title may be: Big Black Bold. For example, the storage path information may be a ttf file path, such as: YEFONTAoYeHei.ttf.
[0064] Afterwards, the fontRisk array and fontNoRisk array can be traversed, and FontFaceObserver can be used to load all fonts once according to all elements in the array. Then, a style tag (i.e., a custom font tag) can be created on the header tag (i.e., the tag in the head area) of the HTML document using the DOM method, and the attribute of the custom font tag is set to data-fonts=true, and the attribute information and storage path information of each font can be stored in the custom font tag.
[0065] The above process can be implemented based on the following code:
[0066]
[0067]
[0068] Through the above code, after the attribute information and storage path information of each font are stored in the custom font tag, the code in the HTML document is as follows:
[0069]
[0070]
[0071] After that, the user can select the font. Correspondingly, you can use Leafer's api add method to load the following Json data to display the corresponding text, where fontFamily is the font selected by the user.
[0072] The Json data is as follows:
[0073]
[0074] After the user adds multiple text fragments corresponding to different fonts based on the above method, the page display can be as follows Figure 2 shown.
[0075] Figure 2 The Json data corresponding to the content shown in can be shown as follows. The data of tag=text in the Json data is the font data, and the fontfamily field is the selected font:
[0076]
[0077]
[0078]
[0079] Based on the above steps, after the user uses multiple fonts to edit text, he can use Leafer's apito JSON method to obtain web page data, and use the find method to traverse the Json data in the HTML document to obtain the text information in the web page, and output the text information as an array, recorded as texts.
[0080] Traverse the texts array and initialize an array risk = [] to read the fontFamily attribute (i.e. attribute information) in the texts array. If the traversed attribute information exists in the array fontRisk corresponding to the non-copyright font, the traversed attribute information can be stored in the array risk. After traversing all the data, it can be displayed as follows Figure 3 The pop-up effect shown.
[0081] like Figure 4 As shown, the user can click on the non-copyright font and change it to the copyright font, record the non-copyright font as fontFamilyBefore, record the modified copyright font as fontFamilyAfter, use the fontfaceObserver method to load the selected copyright font, and after loading, traverse the texts array to obtain the text fragment whose fontfamily attribute information in the array is the same as the fontFamilyBefore attribute, and change the attribute information of the text fragment to fontFamilyAfter.
[0082] Based on the above steps, you can further use Leafer's forceUpdate and forceRender methods to re-render the page, the effect is as follows Figure 5 As shown. In Leafer, the forceUpdate and forceRender methods can be used to control the update and rendering behavior of components or objects.
[0083] Through the above method, Leafer UI can be used as the basis, displayed on Canvas, and fonts can be loaded using FontFaceObserver to complete the functions of loading and modifying custom fonts. The above method can be applied to any editor.
[0084] It should be noted that the execution subject of each step of the method provided in the above embodiment can be the same device, or the method can be executed by different devices. For example, the execution subject of steps 11 to 14 can be device A; for another example, the execution subject of steps 11 to 12 can be device A, and the execution subject of steps 13 to 14 can be device B; and so on.
[0085] In addition, in some of the processes described in the above embodiments and the accompanying drawings, multiple operations appearing in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this document or may be executed in parallel, and the sequence numbers of the operations, such as 12, 13, etc., are only used to distinguish between different operations, and the sequence numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel.
[0086] It should be noted that the descriptions such as “first” and “second” in this article are used to distinguish different messages, devices, modules, etc., and do not represent the order of precedence, nor do they limit “first” and “second” to different types.
[0087] Figure 6 is a schematic diagram of the structure of an electronic device provided by an exemplary embodiment of the present application. The electronic device is applicable to the font switching method provided by the aforementioned embodiment. Figure 6 As shown, the electronic device may include: a memory 601 , a processor 602 , and a communication component 603 .
[0088] The memory 601 is used to store computer programs and can be configured to store various other data to support operations on the electronic device. Examples of such data include instructions for any application or method operating on the electronic device, contact data, phone book data, messages, pictures, videos, etc.
[0089] In some exemplary embodiments, the processor 602 is coupled to the memory 601 and is used to execute a computer program in the memory 601, so as to: in response to a loading instruction of a target page, obtain a font list and store it in a resource document of the target page; the font list includes: attribute information of each of a plurality of fonts; the plurality of fonts are divided into a copyright type and a non-copyright type according to their respective attribute information; the target page is associated with a font selection control; in response to a text editing operation on the target page using at least one font, obtain text information added based on the text editing operation, and add the text information to the resource document, the text information including at least one text segment, and the at least one text segment is obtained by performing text editing using the at least one font; in the case that it is determined according to the attribute information of the at least one font that there is a first font of the non-copyright type in the at least one font, determine a target text segment corresponding to the first font from the text information in the resource document, and output copyright prompt information to remind the user to switch the font for the target text segment; in response to a trigger operation on the font selection control, determine a second font of the copyright type selected by the user from the font list, and switch the first font of the target text segment in the resource document to the second font.
[0090] Optionally, when the memory 601 obtains the font list and stores it in the resource document of the target page, it is specifically used to: obtain the attribute information and storage path information of each of the multiple fonts; generate corresponding font rule information for the multiple fonts based on the attribute information and storage path information of each of the multiple fonts, and add the font rule information of the multiple fonts to the font list; create a custom font tag in the header area of the resource document, and add the font list under the custom font tag.
[0091] Optionally, the font list also includes: storage path information of each of the multiple fonts; when the memory 601 responds to a text editing operation on the target page using at least one font and obtains text information added based on the text editing operation, it is specifically used to: respond to a triggering operation on the font selection control to determine any font selected by the user; respond to an editing operation using any of the fonts, and add text information using any of the fonts on a layer corresponding to the target page according to the storage path information of any of the fonts; and add the text information to the resource document.
[0092] Optionally, the target page is also associated with a save control; when the memory 601 adds the text information to the resource document, it is specifically used to: respond to a trigger operation on the save control, serialize the text information using any one of the fonts into structured data; add the structured data to a corresponding position in the resource document, and the structured data is used to deserialize and obtain the text information.
[0093] Optionally, the target page is associated with a serialization interface, which points to a serialization function module; when the memory 601 serializes the text information using any one of the fonts into structured data, it is specifically used to: call the serialization interface, and send the text information using any one of the fonts to the serialization function module pointed to by the serialization interface, so that the serialization function module serializes the text information using any one of the fonts into structured data.
[0094] Optionally, the memory 601 is also used to: add the attribute information of each of the at least one font of the copyright type to the first set; add the attribute information of each of the at least one font of the non-copyright type to the second set; and determine, based on the attribute information of the at least one font, that there is a first font of the non-copyright type in the at least one font, including: traversing the attribute information of the at least one font, and determining that there is a first font of the non-copyright type in the at least one font when the traversed attribute information appears in the second set.
[0095] Optionally, when the memory 601 switches the first font of the target text fragment in the resource document to the second font, it is specifically used to: modify the attribute information of the first font of the target text fragment to the attribute information of the second font, and render the target text fragment to the target page according to the modified attribute information of the target text fragment.
[0096] Optionally, the target page includes: a web page, an application page or a mini-program page.
[0097] Further, if Figure 6 As shown, the electronic device also includes: a display 604, a power supply component 605, an audio component 606 and other components. Figure 6 Only some components are shown schematically, which does not mean that the electronic device only includes Figure 6 Components shown.
[0098] The embodiment of the present application also provides a computer-readable storage medium, which enables the processor to implement the steps in the font switching method when the computer program is executed by the processor.
[0099] The embodiment of the present application further provides a computer program product, including a computer program / instruction. When the computer program / instruction is executed by a processor, the steps in the font switching method are executed.
[0100] In this embodiment, in response to the loading instruction of the target page, the font list is obtained and stored in the resource document of the target page; in response to the text editing operation of the target page with at least one font, each text segment obtained by text editing with any font is added to the resource document; in the case where it is determined that there is a first font of a non-copyright type in at least one font according to the attribute information of at least one font, the target text segment corresponding to the first font is determined from the text information in the resource document, and the copyright prompt information is output to remind the user to switch the font for the target text segment; the first font of the target text segment in the resource document is switched to the second font of the copyright type. In this way, it is possible to more accurately detect whether the user uses a non-copyright font, thereby more efficiently avoiding font copyright issues for the user.
[0101] The above-mentioned memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read only memory (EEPROM), erasable programmable read only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.
[0102] The above-mentioned communication component is configured to facilitate wired or wireless communication between the device where the communication component is located and other devices. The device where the communication component is located can access a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G / LTE, 5G and other mobile communication networks, or a combination thereof. In an exemplary embodiment, the communication component receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be based on Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra Wide Band (UWB) technology, Bluetooth (BT) technology and other technologies.
[0103] The above-mentioned display includes a screen, and the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.
[0104] The power supply assembly provides power to various components of the device where the power supply assembly is located. The power supply assembly may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device where the power supply assembly is located.
[0105] The above-mentioned audio component can be configured to output and / or input audio signals. For example, the audio component includes a microphone (Microphone, MIC), and when the device where the audio component is located is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in a memory or sent via a communication component. In some embodiments, the audio component also includes a speaker for outputting an audio signal.
[0106] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-readable storage media (including but not limited to disk storage, compact disc read-only memory (Compact Disc Read-Only Memory, CD-ROM), optical storage, etc.) containing computer-usable program code.
[0107] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0108] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0109] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0110] In a typical configuration, a computing device includes one or more processors (Central Processing Unit, CPU), input / output interface, network interface and memory.
[0111] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0112] Computer readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase-change random access memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0113] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0114] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A font switching method, characterized in that: include: In response to a loading instruction of a target page, obtain a font list and store it in a resource document of the target page; The font list includes: attribute information of each of the multiple fonts; the multiple fonts are divided into copyright types and non-copyright types according to their respective attribute information; the target page is associated with a font selection control; In response to a text editing operation on the target page using at least one font, acquiring text information added based on the text editing operation, and adding the text information to the resource document, the text information including at least one text segment, the at least one text segment being respectively obtained by text editing using the at least one font; In the case where it is determined according to the attribute information of the at least one font that there is a first font of a non-copyright type in the at least one font, determining a target text segment corresponding to the first font from the text information in the resource document, and outputting copyright prompt information to remind the user to switch the font for the target text segment; In response to a trigger operation on the font selection control, a second font of the copyright type selected by the user is determined from the font list, and the first font of the target text segment in the resource document is switched to the second font.
2. The method according to claim 1, characterized in that Get the font list and store it in the resource document of the target page, including: Acquire attribute information and storage path information of each of the multiple fonts; Generate corresponding font rule information for the multiple fonts according to the attribute information and storage path information of each of the multiple fonts, and add the font rule information of the multiple fonts to the font list; A custom font tag is created in the head area of the resource document, and the font list is added under the custom font tag.
3. The method according to claim 1, characterized in that The font list also includes: storage path information of each of the multiple fonts; in response to a text editing operation on the target page using at least one font, obtaining text information added based on the text editing operation, including: In response to a triggering operation on the font selection control, determining any font selected by the user; In response to an editing operation using any one of the fonts, text information using any one of the fonts is added to a layer corresponding to the target page according to storage path information of the any one of the fonts; The text information is added to the resource document.
4. The method according to claim 3, characterized in that The target page is also associated with a save control; Adding the text information to the resource document includes: In response to a triggering operation on the save control, the text information in any one of the fonts is serialized into structured data; The structured data is added to a corresponding position in the resource document, and the structured data is used for deserialization to obtain the text information.
5. The method according to claim 4, characterized in that The target page is associated with a serialization interface, and the serialization interface points to a serialization function module; Serialize the text information using any of the above fonts into structured data, including: The serialization interface is called to send the text information in any one of the fonts to the serialization function module pointed to by the serialization interface, so that the serialization function module serializes the text information in any one of the fonts into structured data.
6. The method according to claim 1, characterized in that Also includes: adding attribute information of at least one font of the copyright type to the first set; adding attribute information of each of the at least one font of the non-copyright type to the second set; Determining, according to the attribute information of the at least one font, that there is a first font of a non-copyrighted type in the at least one font includes: The attribute information of the at least one font is traversed, and when the traversed attribute information appears in the second set, it is determined that there is a first font of a non-copyright type in the at least one font.
7. The method according to claim 1, characterized in that Switching the first font of the target text segment in the resource document to the second font includes: The attribute information of the first font of the target text segment is modified to the attribute information of the second font, and the target text segment is rendered to the target page according to the modified attribute information of the target text segment.
8. The method according to any one of claims 1 to 7, characterized in that: The target page includes: a web page, an application page or a mini-program page.
9. An electronic device, characterized in that: include: A memory and a processor; wherein the memory is used to: store one or more computer instructions; The processor is configured to execute the one or more computer instructions to perform the steps of the method according to any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that: When the computer program is executed by a processor, the processor is enabled to implement the steps in the method according to any one of claims 1 to 8.
11. A computer program product, characterized in that The method comprises a computer program / instruction, which, when executed by a processor, enables the processor to implement the steps of the method according to any one of claims 1 to 8.