Font processing method, electronic device and related products
By obtaining the target coordinate data and font types in the CAD environment, and directly rendering the font using the reference font library in the preset database, the problem of low font generation efficiency is solved and efficient font rendering performance is achieved.
Patent Information
- Application Number
- CN202111485027.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2020-12-31
- Filing Date
- 2021-12-07
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2041-12-07
AI Technical Summary
The prior art has low font generation efficiency in computer-aided design (CAD) environment, especially when the number of words is large, the drawing performance is degraded, the font library is not rich enough, making it difficult to improve the generation efficiency.
By detecting that the preset position of the CAD interface is touched, the target coordinate data and target font type are obtained, the reference font library is determined from the preset database, the target font corresponding to the target font type is obtained, and the pre-generated coordinate point data is used directly Render fonts to avoid real-time dynamic generation.
It improves font generation efficiency, improves font rendering performance in CAD environment, and reduces the front-end network bandwidth requirements and loading time.
Smart Images

Figure CN114139496B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a font processing method, electronic equipment and related products. Background Art
[0002] Computer Aided Design (CAD) refers to the use of computers and their graphics equipment to help designers perform design work. In design, computers are usually used to perform a large number of calculations, analyses and comparisons on different schemes to determine the optimal scheme; various design information, whether digital, text or graphic, can be stored in the computer's memory or external storage and can be quickly retrieved; designers usually start designing with sketches, and the heavy work of turning sketches into working drawings can be handed over to computers to complete; the design results automatically generated by the computer can quickly produce graphics, allowing designers to make judgments and modifications to the design in a timely manner; computers can be used to process graphic data related to editing, enlarging, reducing, translating, copying and rotating graphics. In the specific implementation, when drawing text on webgl, the general method is to use the context2d method on canvas to draw the text, then convert it into a picture to form a texture and paste it into the webgl scene; another method is to generate fonts through the built-in method of threejs. The disadvantages of these methods are that the font library is not rich enough, and when the number of words is relatively large, the drawing performance is relatively low. The problem of how to improve the efficiency of font generation needs to be solved urgently. Summary of the invention
[0003] The embodiments of the present application provide a font processing method, electronic device and related products, which can improve the efficiency of font generation.
[0004] In a first aspect, an embodiment of the present application provides a font processing method, which is applied to an electronic device, and the method includes:
[0005] When a preset position of the CAD interface is detected to be touched, target coordinate data corresponding to the preset position is acquired;
[0006] Obtaining a target font type corresponding to the target coordinate data;
[0007] Determine a reference font library corresponding to the preset position from a preset database, wherein the reference font library includes reference fonts of at least one font type;
[0008] A target font corresponding to the target font type is acquired from the reference font library.
[0009] In a second aspect, an embodiment of the present application provides a font processing device, which is applied to an electronic device, and the device includes: a first acquisition unit, a second acquisition unit, a determination unit, and a third acquisition unit, wherein:
[0010] The first acquisition unit is used to acquire target coordinate data corresponding to the preset position when detecting that the preset position of the CAD interface is touched;
[0011] The second acquisition unit is used to acquire the target font type corresponding to the target coordinate data;
[0012] The determining unit is used to determine a reference font library corresponding to the preset position from a preset database, wherein the reference font library includes reference fonts of at least one font type;
[0013] The third acquisition unit is configured to acquire a target font corresponding to the target font type from the reference font library.
[0014] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing the steps in the first aspect of the embodiment of the present application.
[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps described in the first aspect of the embodiment of the present application.
[0016] In a fifth aspect, an embodiment of the present application provides a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps described in the first aspect of the embodiment of the present application. The computer program product may be a software installation package.
[0017] The implementation of the embodiments of the present application has the following beneficial effects:
[0018] It can be seen that the font processing method, electronic device and related products described in the embodiments of the present application are applied to electronic devices. When it is detected that the preset position of the CAD interface is touched, the target coordinate data corresponding to the preset position is obtained, the target font type corresponding to the target coordinate data is obtained, and a reference font library corresponding to the preset position is determined from a preset database. The reference font library includes reference fonts of at least one font type. The target font corresponding to the target font type is obtained from the reference font library. In the CAD environment, the font generation efficiency can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0020] Figure 1 is a flowchart of a font processing method provided in an embodiment of the present application;
[0021] Figure 2 is a flowchart of another font processing method provided in an embodiment of the present application;
[0022] Figure 3 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application;
[0023] Figure 4 This is a block diagram of the functional units of a font processing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0025] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0026] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. 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 creative work are within the scope of protection of this application.
[0027] The electronic devices described in the embodiments of the present application may include smart phones (such as Android phones, iOS phones, Windows Phone phones, etc.), tablet computers, PDAs, laptops, video matrices, monitoring platforms, mobile Internet devices (MID, Mobile Internet Devices) or wearable devices, etc. The above are only examples and not exhaustive, including but not limited to the above devices. Of course, the above electronic devices can also be servers, for example, cloud servers.
[0028] The embodiments of the present application are described in detail below.
[0029] Figure 1 FIG. 1 is a flow chart of a font processing method provided in an embodiment of the present application. As shown in the figure, the font processing method includes:
[0030] 101. When it is detected that a preset position of a CAD interface is touched, target coordinate data corresponding to the preset position is acquired.
[0031] Among them, the preset position can be set by the user or by system default. The electronic device can perform touch detection through a touch display screen. When the electronic device detects that the preset position of the CAD interface is touched, it can obtain the target coordinate data corresponding to the preset position. The target coordinate data can be the coordinate data corresponding to an area range or a point. For example, the coordinate data of an area touched by the user can be used as the target coordinate data, or the coordinate data of the center of an area touched by the user can be used as the target coordinate data. In addition, the target coordinate data can also refer to the coordinates represented by the strokes of the font, and the corresponding contour is formed based on these coordinates. Based on the contour, the character recognition or font type recognition corresponding to the preset position can be realized. There may be characters at the preset position, or there may not be characters. If there are characters, the characters can have corresponding font types. Primitive recognition or character recognition can be realized using the target coordinate data corresponding to the preset position.
[0032] Optionally, the above step 101, obtaining the target coordinate data corresponding to the preset position, may include the following steps:
[0033] 11. Obtaining target touch parameters for the preset position;
[0034] 12. When the target touch parameter meets the preset requirement, identify the target graphic element corresponding to the preset position;
[0035] 13. Obtain the target coordinate data of the target primitive at the preset position.
[0036] The preset requirements may be preset or set by the system default. The target touch parameter may be at least one of the following: number of touches, touch area, touch force, touch duration, etc., which are not limited here. For example, the target touch parameter may be the maximum touch force when the touch area is within a preset area range. For another example, the target touch parameter may be the average touch force when the touch duration is within a preset duration range. The preset area range and the preset duration range may be set by the user or set by the system default.
[0037] In a specific implementation, the electronic device can obtain target touch parameters for a preset position. When the target touch parameters meet the preset requirements, the target graphic element corresponding to the preset position can be identified, and then the target coordinate data of the target graphic element at the preset position can be obtained. In this way, accidental touches can be prevented, and the coordinate data of the preset position can be obtained based on the touch operation.
[0038] 102. Obtain a target font type corresponding to the target coordinate data.
[0039] Among them, different coordinate data can correspond to different font types. In the embodiment of the present application, the font type can be at least one of the following: Songti, Kaiti, Lishu, Caoshu, Youyuan, etc., which are not limited here. In a specific implementation, the target font type can be realized based on the target coordinate data, that is, different fonts have different text styles or trends. It is equivalent to font file recognition, identifying whether there is a character at a preset position, or the font type of the font. The target font type can correspond to the font type of at least one character. The target coordinate data can correspond to at least one character. The target font type may include one or more font types.
[0040] Optionally, the above step 102, obtaining the target font type corresponding to the target coordinate data, may include the following steps:
[0041] A21, acquiring character data of the CAD interface according to the target coordinate data;
[0042] A22, extracting characters from the character data to obtain a plurality of characters;
[0043] A23, classifying the multiple characters to obtain at least one class;
[0044] A24, determining the number of characters in each of the at least one class to obtain at least one number of characters;
[0045] A25. Use the font type of the type of characters that appear most in the at least one character quantity as the target font type.
[0046] Among them, the electronic device can obtain character data of a partial area or the entire area of the CAD interface. For example, it can be character data of the CAD interface within a specified range centered on the target coordinate data. The specified range can be pre-set or system default. Then, characters can be extracted from the character data to obtain multiple characters. The multiple characters can also be classified according to font type to obtain at least one class. Furthermore, the electronic device can determine the number of characters in each class in at least one class to obtain at least one character number, and the font type of the class with the most characters in the at least one character number is used as the target font type. In this way, the font type required by the user can be determined based on the mainstream font type of the CAD interface.
[0047] Optionally, the above step 23, classifying the multiple characters to obtain at least one class, may include the following steps:
[0048] A231, extracting features from each of the multiple characters to obtain multiple feature sets, where each character corresponds to a feature set;
[0049] A232. Input the multiple feature sets into a preset neural network model to obtain the at least one class.
[0050] Among them, in the embodiment of the present application, the preset neural network model can be pre-set or system default, and the preset neural network model can be at least one of the following: convolutional neural network model, recurrent neural network model, fully connected neural network model, etc., which are not limited here. Each feature set may include at least one feature, and the feature may include at least one of the following: feature point, feature vector, radian, feature contour, etc., which are not limited here. In actual applications, sample feature sets of each type of font can be obtained, and each sample feature set can correspond to a category label. These sample sets are then input into the initial neural network model for training. After the initial neural network model converges, the preset neural network model can be obtained.
[0051] In a specific implementation, feature extraction can be performed on each of the multiple characters. Of course, before feature extraction, these characters can also be preprocessed, and feature extraction can be performed after preprocessing. The preprocessing can include at least one of the following: noise reduction, amplification, ghosting removal, etc., which are not limited here. Then, multiple feature sets are obtained, each character corresponds to a feature set, and the multiple feature sets are then input into a preset neural network model to obtain at least one class. In this way, intelligent classification of characters can be achieved.
[0052] Optionally, the above step 102, obtaining the target font type corresponding to the target coordinate data, may include the following steps:
[0053] B21, obtaining a screenshot of a preset range of the target coordinate data;
[0054] B22, extracting graphic elements from the screenshot to obtain at least one graphic element;
[0055] B23, extracting features from the at least one primitive to obtain a target primitive feature set;
[0056] B24. Determine the target font type corresponding to the target graphic element feature set.
[0057] Among them, the preset range can be preset or defaulted by the system. For example, the preset range can be a preset radius range with the center of the target coordinate data as the center of the circle. The primitive feature set can include at least one primitive feature. The primitive feature can include at least one of the following: primitive type, primitive number, primitive arc, number of lines, etc., which are not limited here. The mapping relationship between the preset primitive feature set and the font type can be stored in advance, and then the target font type corresponding to the target primitive feature set can be determined based on the mapping relationship. In this way, a font type suitable for the primitive can be obtained.
[0058] 103. Determine a reference font library corresponding to the preset position from a preset database, where the reference font library includes reference fonts of at least one font type.
[0059] Among them, the preset database can be pre-stored in the electronic device, and fonts of various font types and various font libraries can be stored in the preset database. Different positions can correspond to different font libraries. The mapping relationship between the position and the font library identifier can be pre-stored in the electronic device, and then the reference font library corresponding to the preset position can be determined. The preset database includes a reference font library. The reference font library can be a font library generated by coordinate point data, and the reference font library can include one or more characters, and each character can correspond to a set of coordinate point data. The target font type may be a font type that the user does not need to render, and the font type in the reference font library may be a font type that the user needs to render. The reference font library can store a limited number of characters. Of course, the reference font library can also be selected by the user, and the reference font library can be a font that the user needs to obtain a rendering effect.
[0060] Optionally, the above step 103, determining the reference font library corresponding to the preset position from the preset database, may include the following steps:
[0061] 31. Determine the target font library identifier corresponding to the preset position according to the mapping relationship between the preset position and the font library identifier;
[0062] 32. Acquire a reference font library corresponding to the target font library identifier from the preset database.
[0063] The electronic device may pre-store a mapping relationship between a preset position and a font library identifier, and then determine the target font library identifier corresponding to the preset position according to the mapping relationship, that is, obtain a reference font library corresponding to the target font library identifier from a preset database.
[0064] 104. Acquire a target font corresponding to the target font type from the reference font library.
[0065] Among them, the electronic device can obtain a target font corresponding to the target font type from a reference font library, and can also obtain content to be displayed, and display it in the target font. For example, the target font can be displayed at a preset position, or the target font can be displayed at other positions. Furthermore, the target font can be used to replace the characters corresponding to the preset position. In an embodiment of the present application, one or more characters can be rendered, so that characters of different types can have the same font type. For example, assuming that there is a character "A" at a preset position, and the A is in ttf format, it can be converted into a font type "A" consisting of a finite number of coordinate point data.
[0066] In a specific implementation, the target font can be a font composed of coordinate point data. Each coordinate point data can correspond to a coordinate point and can be represented by a dot. The dot can be solid or hollow. The size of the dot can be set by the user or by the system default. The size can be understood as the area of a solid dot or the line width of a hollow dot. The amount of coordinate point data is related to the number of points. The more coordinate point data there is, the more points there are. The color of the dot can also be set by the user or by the system default.
[0067] In a specific implementation, the target font can be prepared in advance, and when used, there is no need to load the corresponding font library, and the target font can be directly called, thereby improving rendering efficiency.
[0068] Optionally, the above step 104, obtaining a target font corresponding to the target font type from the reference font library, may include the following steps:
[0069] 41. Obtain a font index of a font corresponding to the preset position according to the target font type, use the font index of the font as a query identifier, perform a query in the reference font library, and obtain a coordinate point index identifier;
[0070] 42. Determine corresponding coordinate data according to the coordinate point index identifier, and use the coordinate data as the target font.
[0071] In a specific implementation, the font index of the font corresponding to the preset position can be obtained according to the target font type, and the font index of the font is used as a query identifier to query in the reference font library to obtain the coordinate point index identifier, that is, to find the coordinate point index of the font to be rendered, and then determine the corresponding coordinate data according to the coordinate point index identifier, and use the coordinate data as the target font. In this way, the target font type can be rendered into the font type required by the user.
[0072] Optionally, the following steps may also be included:
[0073] A1. Pre-generate a vertex sequence of at least one font as a font index, and store the vertex sequence of the at least one font in the preset database, where each vertex sequence corresponds to a font index, and each font index corresponds to a font index identifier;
[0074] A2. Establishing a mapping relationship between the font index identifier and the coordinate point index identifier.
[0075] In a specific implementation, the vertex sequence of at least one font can be pre-generated as a font index, and the vertex sequence of at least one font can be saved in a preset database, each vertex sequence corresponds to a font index, and each font index corresponds to a font index identifier. Then a mapping relationship between the font index identifier and the coordinate point index identifier is established, so that the coordinate point data of the font that needs to be rendered can be quickly found later. That is, the vertex sequence of the font is pre-generated and saved in the database, and is directly read from the database when needed, which reduces the time required for real-time dynamic generation of the vertex sequence of the font and improves the generation efficiency.
[0076] To illustrate, in a specific implementation, an electronic device can use a font generation tool library (such as opentype.js) to pre-generate font coordinate point data for the used ttf format font library (such as Songti, Heiti, etc.), and then store these data in a database. When the front end needs to render the font, it can dynamically query the database to obtain the coordinate point data of the corresponding font, saving the process of real-time dynamic generation of fonts, and can load the required fonts on demand. There is no need to download all font libraries to the front end in advance and then generate the coordinate data of the font points and lines, saving the front-end network bandwidth requirements and improving performance and efficiency.
[0077] Optionally, in step 104, after acquiring a target font corresponding to the target font type from the reference font library, the following steps may also be included:
[0078] B1. Determine the target display frame size corresponding to the preset position;
[0079] B2. Obtain the content to be displayed;
[0080] B3, determining a first display parameter of the content to be displayed according to the target display frame size;
[0081] B4. Obtaining the target background color of the preset position;
[0082] B5. Determine a second display parameter corresponding to the target background color according to a preset mapping relationship between the background color and the display parameter;
[0083] B6. Display the content to be displayed according to the first display parameter and the second display parameter.
[0084] Among them, the electronic device can determine the target display box size corresponding to the preset position, and can also obtain the content to be displayed. The content to be displayed can be pre-set or added by the user. Then, the first display parameter of the content to be displayed can be determined according to the target display box size. The first display parameter can be at least one of the following: font size, font type, line spacing, column spacing, etc., which are not limited here. In a specific implementation, the number of characters of the content to be displayed can be obtained, and then the font size, line spacing, etc. can be adjusted.
[0085] Furthermore, the electronic device may pre-store a mapping relationship between a preset background color and a display parameter. The electronic device may also obtain a target background color at a preset position, and then, according to the mapping relationship between the preset background color and the display parameter, determine a second display parameter corresponding to the target background color, the second display parameter may be at least one of the following: font color, color temperature, etc., which are not limited here, and then, the content to be displayed may be displayed according to the first display parameter and the second display parameter.
[0086] It can be seen that the font processing method described in the embodiment of the present application is applied to an electronic device. When it is detected that a preset position of a CAD interface is touched, the target coordinate data corresponding to the preset position is obtained, the target font type corresponding to the target coordinate data is obtained, and a reference font library corresponding to the preset position is determined from a preset database. The reference font library includes reference fonts of at least one font type. The target font corresponding to the target font type is obtained from the reference font library. In a CAD environment, the font generation efficiency can be improved.
[0087] With the above Figure 1 For the embodiments shown, please refer to Figure 2 , Figure 2 1 is a flow chart of a font processing method provided in an embodiment of the present application. As shown in the figure, the font processing method is applied to an electronic device. The font processing method includes:
[0088] 201. When it is detected that a preset position of a CAD interface is touched, target coordinate data corresponding to the preset position is obtained.
[0089] 202. Obtain a target font type corresponding to the target coordinate data.
[0090] 203. Determine a reference font library corresponding to the preset position from a preset database, where the reference font library includes reference fonts of at least one font type.
[0091] 204. Acquire a target font corresponding to the target font type from the reference font library.
[0092] 205. Determine a target display frame size corresponding to the preset position.
[0093] 206. Obtain content to be displayed.
[0094] 207. Determine a first display parameter of the content to be displayed according to the target display frame size.
[0095] 208. Obtain the target background color of the preset position.
[0096] 209. Determine a second display parameter corresponding to the target background color according to a preset mapping relationship between the background color and the display parameter.
[0097] 210. Display the content to be displayed according to the first display parameter and the second display parameter.
[0098] The specific description of the above steps 201 to 210 can refer to the above Figure 1 The corresponding steps of the described font processing method will not be repeated here.
[0099] It can be seen that the font processing method described in the embodiment of the present application is applied to an electronic device. When it is detected that a preset position of a CAD interface is touched, target coordinate data corresponding to the preset position is obtained, a target font type corresponding to the target coordinate data is obtained, a reference font library corresponding to the preset position is determined from a preset database, the reference font library includes a reference font of at least one font type, a target font corresponding to the target font type is obtained from the reference font library, a target display box size corresponding to the preset position of the reference font library corresponding to the preset position determined from the preset database is determined, content to be displayed is obtained, a first display parameter of the content to be displayed of the reference font library corresponding to the preset position determined from the preset database is determined according to the target display box size of the reference font library corresponding to the preset position determined from the preset database, a target background color of the preset position of the reference font library corresponding to the preset position determined from the preset database is obtained, and a second display parameter corresponding to the target background color of the reference font library corresponding to the preset position determined from the preset database is determined according to a mapping relationship between the preset background color and the display parameter, and the content to be displayed of the reference font library corresponding to the preset position determined from the preset database is displayed according to the first display parameter of the reference font library corresponding to the preset position determined from the preset database and the second display parameter of the reference font library corresponding to the preset position determined from the preset database. In a CAD environment, font generation efficiency and display efficiency can be improved.
[0100] In accordance with the above embodiment, please refer to Figure 3 , Figure 31 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. As shown in the figure, the electronic device includes a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor. In the embodiment of the present application, the program includes instructions for executing the following steps:
[0101] When a preset position of the CAD interface is detected to be touched, target coordinate data corresponding to the preset position is acquired;
[0102] Obtaining a target font type corresponding to the target coordinate data;
[0103] Determine a reference font library corresponding to the preset position from a preset database, wherein the reference font library includes reference fonts of at least one font type;
[0104] A target font corresponding to the target font type is acquired from the reference font library.
[0105] Optionally, in the aspect of acquiring the target coordinate data corresponding to the preset position, the program includes instructions for executing the following steps:
[0106] Acquire target touch parameters for the preset position;
[0107] When the target touch parameter meets the preset requirement, identifying the target graphic element corresponding to the preset position;
[0108] The target coordinate data of the target graphic element at the preset position is obtained.
[0109] Optionally, in the aspect of obtaining the target font type corresponding to the target coordinate data, the program includes instructions for executing the following steps:
[0110] Acquire character data of the CAD interface according to the target coordinate data;
[0111] Extract characters from the character data to obtain a plurality of characters;
[0112] Classifying the multiple characters to obtain at least one class;
[0113] Determining the number of characters in each of the at least one class to obtain at least one number of characters;
[0114] The font type of the character type with the most characters in the at least one character quantity is used as the target font type.
[0115] Optionally, in the aspect of determining the reference font library corresponding to the preset position from the preset database, the above program includes instructions for executing the following steps:
[0116] According to the mapping relationship between the preset position and the font library identifier, determining the target font library identifier corresponding to the preset position;
[0117] A reference font library corresponding to the target font library identifier is obtained from the preset database.
[0118] Optionally, in the aspect of acquiring the target font corresponding to the target font type from the reference font library, the program includes instructions for executing the following steps:
[0119] Acquire the font index of the font corresponding to the preset position according to the target font type, use the font index of the font as a query identifier, query the reference font library, and obtain the coordinate point index identifier;
[0120] The corresponding coordinate data is determined according to the coordinate point index identifier, and the coordinate data is used as the target font.
[0121] Optionally, the program further includes instructions for executing the following steps:
[0122] Pre-generating a vertex sequence of at least one font as a font index, and storing the vertex sequence of the at least one font in the preset database, each vertex sequence corresponds to a font index, and each font index corresponds to a font index identifier;
[0123] A mapping relationship between the font index identifier and the coordinate point index identifier is established.
[0124] Optionally, after acquiring the target font corresponding to the target font type from the reference font library, the program further includes instructions for executing the following steps:
[0125] Determine the target display frame size corresponding to the preset position;
[0126] Get the content to be displayed;
[0127] Determining a first display parameter of the content to be displayed according to the target display frame size;
[0128] Obtain the target background color of the preset position;
[0129] Determine the second display parameter corresponding to the target background color according to the mapping relationship between the preset background color and the display parameter;
[0130] The content to be displayed is displayed according to the first display parameter and the second display parameter.
[0131] It can be seen that the electronic device described in the embodiment of the present application, when detecting that the preset position of the CAD interface is touched, obtains the target coordinate data corresponding to the preset position, obtains the target font type corresponding to the target coordinate data, determines the reference font library corresponding to the preset position from the preset database, the reference font library includes reference fonts of at least one font type, and obtains the target font corresponding to the target font type from the reference font library, which can improve the font generation efficiency in the CAD environment.
[0132] Figure 4 4 is a functional unit block diagram of a font processing device 400 involved in an embodiment of the present application. The font processing device 400 is applied to an electronic device, and the device 400 includes: a first acquisition unit 401, a second acquisition unit 402, a determination unit 403 and a third acquisition unit 404, wherein:
[0133] The first acquisition unit 401 is used to acquire target coordinate data corresponding to a preset position when detecting that a preset position of the CAD interface is touched;
[0134] The second acquisition unit 402 is used to acquire the target font type corresponding to the target coordinate data;
[0135] The determining unit 403 is used to determine a reference font library corresponding to the preset position from a preset database, wherein the reference font library includes reference fonts of at least one font type;
[0136] The third acquisition unit 404 is configured to acquire a target font corresponding to the target font type from the reference font library.
[0137] Optionally, in the aspect of acquiring the target coordinate data corresponding to the preset position, the first acquiring unit 401 is specifically configured to:
[0138] Acquire target touch parameters for the preset position;
[0139] When the target touch parameter meets the preset requirement, identifying the target graphic element corresponding to the preset position;
[0140] The target coordinate data of the target graphic element at the preset position is obtained.
[0141] Optionally, in acquiring the target font corresponding to the target font type from the reference font library, the third acquiring unit 404 is specifically configured to:
[0142] Acquire the font index of the font corresponding to the preset position according to the target font type, use the font index of the font as a query identifier, query the reference font library, and obtain the coordinate point index identifier;
[0143] The corresponding coordinate data is determined according to the coordinate point index identifier, and the coordinate data is used as the target font.
[0144] Optionally, the device 400 is further specifically used for:
[0145] Pre-generating a vertex sequence of at least one font as a font index, and storing the vertex sequence of the at least one font in the preset database, each vertex sequence corresponds to a font index, and each font index corresponds to a font index identifier;
[0146] A mapping relationship between the font index identifier and the coordinate point index identifier is established.
[0147] Optionally, in the aspect of acquiring the target font type corresponding to the target coordinate data, the second acquiring unit 402 is specifically configured to:
[0148] Acquiring character data of the CAD interface;
[0149] Extract characters from the character data to obtain a plurality of characters;
[0150] Classifying the multiple characters to obtain at least one class;
[0151] Determining the number of characters in each of the at least one class to obtain at least one number of characters;
[0152] The font type of the character type with the most characters in the at least one character quantity is used as the target font type.
[0153] Optionally, in determining the reference font library corresponding to the preset position from the preset database, the determining unit 403 is specifically configured to:
[0154] According to the mapping relationship between the preset position and the font library identifier, determining the target font library identifier corresponding to the preset position;
[0155] A reference font library corresponding to the target font library identifier is obtained from the preset database.
[0156] Optionally, after acquiring the target font corresponding to the target font type from the reference font library, the apparatus 400 is further specifically configured to:
[0157] Determine the target display frame size corresponding to the preset position;
[0158] Get the content to be displayed;
[0159] Determining a first display parameter of the content to be displayed according to the target display frame size;
[0160] Obtain the target background color of the preset position;
[0161] Determine the second display parameter corresponding to the target background color according to the mapping relationship between the preset background color and the display parameter;
[0162] The content to be displayed is displayed according to the first display parameter and the second display parameter.
[0163] It can be understood that the functions of each program module of the font processing device of this embodiment can be specifically implemented according to the method in the above method embodiment. The specific implementation process can refer to the relevant description of the above method embodiment, which will not be repeated here.
[0164] An embodiment of the present application also provides a computer storage medium, wherein the computer storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps of any method described in the above method embodiments, and the above computer includes an electronic device.
[0165] The embodiment of the present application also provides a computer program product, the computer program product includes a non-transitory computer-readable storage medium storing a computer program, the computer program is operable to cause a computer to execute some or all of the steps of any method described in the method embodiment. The computer program product may be a software installation package, and the computer includes an electronic device.
[0166] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0167] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0168] In the several embodiments provided in the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the above-mentioned units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0169] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0170] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0171] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the above-mentioned methods of each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or CD-ROM and other media that can store program codes.
[0172] A person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, and the memory can include: a flash drive, a read-only memory (English: Read-Only Memory, abbreviated as: ROM), a random access memory (English: Random Access Memory, abbreviated as: RAM), a magnetic disk or an optical disk, etc.
[0173] The embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. At the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A font processing method, characterized in that: Applied to electronic equipment, the method comprises: When a preset position of the CAD interface is detected to be touched, target coordinate data corresponding to the preset position is obtained; the target coordinate data refers to the coordinates represented by the strokes of the font, a corresponding outline is formed based on these coordinates, and character recognition or font type recognition corresponding to the preset position is realized based on the outline; Acquiring a target font type corresponding to the target coordinate data, specifically: acquiring a screenshot of a preset range of the target coordinate data, performing primitive extraction on the screenshot to obtain at least one primitive, performing feature extraction on the at least one primitive to obtain a target primitive feature set, and determining the target font type corresponding to the target primitive feature set; Determine a reference font library corresponding to the preset position from a preset database, wherein the reference font library includes reference fonts of at least one font type; Obtaining a target font corresponding to the target font type from the reference font library, using the target font to replace the character corresponding to the preset position, and rendering one or more characters so that different types of characters have the same font type; the target font is prepared in advance, and when it is used, there is no need to load the corresponding font library, and the target font is directly called; Wherein, after acquiring the target font corresponding to the target font type from the reference font library, the method further comprises: Determine the target display frame size corresponding to the preset position; Get the content to be displayed; Determining a first display parameter of the content to be displayed according to the target display frame size; Obtain the target background color of the preset position; Determine the second display parameter corresponding to the target background color according to the mapping relationship between the preset background color and the display parameter; The content to be displayed is displayed according to the first display parameter and the second display parameter.
2. The method according to claim 1, characterized in that The obtaining of target coordinate data corresponding to the preset position includes: Acquire target touch parameters for the preset position; When the target touch parameter meets the preset requirement, identifying the target graphic element corresponding to the preset position; The target coordinate data of the target graphic element at the preset position is obtained.
3. The method according to claim 1 or 2, characterized in that: The acquiring a target font corresponding to the target font type from the reference font library comprises: Acquire the font index of the font corresponding to the preset position according to the target font type, use the font index of the font as a query identifier, query the reference font library, and obtain the coordinate point index identifier; The corresponding coordinate data is determined according to the coordinate point index identifier, and the coordinate data is used as the target font.
4. The method according to claim 3, characterized in that The method further comprises: Pre-generating a vertex sequence of at least one font as a font index, and storing the vertex sequence of the at least one font in the preset database, each vertex sequence corresponds to a font index, and each font index corresponds to a font index identifier; A mapping relationship between the font index identifier and the coordinate point index identifier is established.
5. The method according to claim 1 or 2, characterized in that: The determining a reference font library corresponding to the preset position from a preset database includes: According to the mapping relationship between the preset position and the font library identifier, determining the target font library identifier corresponding to the preset position; A reference font library corresponding to the target font library identifier is obtained from the preset database.
6. A font processing device, characterized in that: Applied to electronic equipment, the device comprises: a first acquisition unit, a second acquisition unit, a determination unit and a third acquisition unit, wherein: The first acquisition unit is used to acquire target coordinate data corresponding to the preset position when detecting that the preset position of the CAD interface is touched; The second acquisition unit is used to acquire the target font type corresponding to the target coordinate data, specifically: acquire a screenshot of a preset range of the target coordinate data, perform primitive extraction on the screenshot to obtain at least one primitive, perform feature extraction on the at least one primitive to obtain a target primitive feature set, and determine the target font type corresponding to the target primitive feature set; the target coordinate data refers to the coordinates represented by the strokes of the font, a corresponding outline is formed based on these coordinates, and character recognition or font type recognition corresponding to the preset position is realized based on the outline; The determining unit is used to determine a reference font library corresponding to the preset position from a preset database, wherein the reference font library includes reference fonts of at least one font type; The third acquisition unit is used to acquire a target font corresponding to the target font type from the reference font library, use the target font to replace the character corresponding to the preset position, and render one or more characters so that different types of characters have the same font type; the target font is prepared in advance, and when it is used, there is no need to load the corresponding font library, and the target font is directly called; Wherein, after acquiring the target font corresponding to the target font type from the reference font library, the device is further specifically configured to: Determine the target display frame size corresponding to the preset position; Get the content to be displayed; Determining a first display parameter of the content to be displayed according to the target display frame size; Obtain the target background color of the preset position; Determine the second display parameter corresponding to the target background color according to the mapping relationship between the preset background color and the display parameter; The content to be displayed is displayed according to the first display parameter and the second display parameter.
7. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory is used to store one or more programs and is configured to be executed by the processor, wherein the program comprises instructions for executing the steps in the method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: A computer program for electronic data exchange is stored, wherein the computer program enables a computer to execute the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Method and device for rendering fonts of user interface
CN101833542A
Improved building model with capture of as built features and experiential data
CN110546703A
Font display processing method and device
CN111353114A
Font recognition method and device, electronic equipment and storage medium
CN111626383A
Digital twin industrial simulation system based on WLAN position sensing
CN112052572A
