A font bolding method, device, electronic device and storage medium
By determining the width of the target brush thickening and using the stroke method, the problem of inconsistent display of font bolding is solved, the consistency of font bolding is achieved, and the user reading experience is improved.
Patent Information
- Application Number
- CN202010269613.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-04-08
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2040-04-08
AI Technical Summary
The same font and the same glyph are bolded and displayed inconsistently on different operating systems, which affects the user's reading experience.
By determining the width of the target brush to be bolded and using the stroke method to obtain the bolded glyph, ensure that the font bold is not affected by the operating system and achieve consistency of font bolding.
It solves the problem of inconsistent display of font bolding, improves the user's reading experience, and ensures that the bolding display of the same font and the same glyph on different operating systems is consistent.
Smart Images

Figure CN113496110B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electronic documents, and in particular to a font bolding method, device, electronic equipment and storage medium. Background Art
[0002] At present, when editing electronic documents, the Linux platform mainly uses the standard interface for bolding fonts in the built-in font engine (such as freetype) to achieve bolding fonts. When bolding fonts using the above method, the line width of the bold fonts of some fonts becomes very wide, which makes the bold display of the same font and the same font on different operating systems inconsistent, thereby affecting the user's reading experience. Summary of the invention
[0003] The purpose of the embodiments of the present invention is to provide a font bolding method, device, electronic device and storage medium to solve the problem of inconsistent bolding display of the same font and the same glyph on different operating systems. The specific technical solution is as follows:
[0004] To achieve the above object, an embodiment of the present invention provides a method for bolding a font, the method comprising:
[0005] Determine the text to be bolded in the electronic document;
[0006] Obtaining the original font of the text to be bolded;
[0007] Determine the bold width of the target brush of the text to be bolded;
[0008] The target brush is used to stroke the original glyph to obtain a bold glyph corresponding to the to-be-bolded text.
[0009] Optionally, the step of determining the bold width of the target brush of the text to be bolded includes:
[0010] The bolding width of the target brush for the text to be bolded is determined according to the current pixel size of the text to be bolded in a preset direction and the pixel size per unit length of the display screen.
[0011] Optionally, the step of determining the bolding width of the target brush for the text to be bolded according to the current pixel size of the text to be bolded in a preset direction and the pixel size per unit length of the display screen includes:
[0012] The following formula is used to determine the bold width of the target brush of the text to be bolded:
[0013]
[0014] Wherein, D is the bold width of the target brush; Pixel is the current pixel size of the text to be bolded in a preset direction; and Dpi is the pixel size per unit length of the display screen in a preset direction.
[0015] Optionally, the step of obtaining the original glyph of the text to be processed includes:
[0016] The original font of the text to be processed is obtained using a standard interface of a font engine.
[0017] Optionally, determining the text to be bolded in the electronic document includes:
[0018] Acquire a selection instruction of a character in an electronic document input by a user, wherein the selection instruction includes a target character in the electronic document selected by the user;
[0019] If a bolding instruction for the target text is received, the target text is determined to be text to be bolded.
[0020] To achieve the above object, an embodiment of the present invention further provides a font bolding device, the device comprising:
[0021] A first determination module, used to determine the text to be bolded in the electronic document;
[0022] An acquisition module, used for acquiring the original font of the text to be bolded;
[0023] A second determining module is used to determine the bold width of the target brush of the text to be bolded;
[0024] The stroke module uses the target brush to stroke the original glyph to obtain a bold glyph corresponding to the to-be-bolded text.
[0025] Optionally, the second determining module is specifically configured to:
[0026] The bolding width of the target brush for the text to be bolded is determined according to the current pixel size of the text to be bolded in a preset direction and the pixel size per unit length of the display screen.
[0027] Optionally, the second determining module is specifically configured to:
[0028] The following formula is used to determine the bold width of the target brush of the text to be bolded:
[0029]
[0030] Wherein, D is the bold width of the target brush; Pixel is the current pixel size of the text to be bolded in a preset direction; and Dpi is the pixel size per unit length of the display screen in a preset direction.
[0031] Optionally, the acquisition module is specifically used for:
[0032] The original font of the text to be processed is obtained using a standard interface of a font engine.
[0033] Optionally, the first determining module includes:
[0034] An acquisition submodule, used to acquire a selection instruction of a character in an electronic document input by a user, wherein the selection instruction includes a target character in the electronic document selected by the user;
[0035] The determination submodule is used to determine that the target text is a text to be made bold if a bold instruction for the target text is received.
[0036] To achieve the above object, an embodiment of the present invention further provides an electronic device, the electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0037] Memory, used to store computer programs;
[0038] The processor is used to implement any of the above-mentioned method steps when executing the program stored in the memory.
[0039] To achieve the above objectives, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, any of the above-mentioned method steps is implemented.
[0040] To achieve the above object, an embodiment of the present invention further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the above methods.
[0041] Beneficial effects of the technical solution provided by the embodiment of the present invention:
[0042] A method and device for bolding a font provided in an embodiment of the present invention can obtain the original glyph of a text to be bolded and determine the bold width of a target brush for the text to be bolded. Afterwards, the original glyph is stroked with a brush to obtain a bold glyph corresponding to the text to be bolded. In an embodiment of the present invention, the bold glyph is obtained by stroking, which can ensure that the bolding of the font is not affected by the operating system, and ensure that the bold display of the same font and the same glyph on different operating systems is consistent, thereby solving the problem of inconsistent bold display of the same font and the same glyph on different operating systems and improving the user's reading experience.
[0043] Of course, it is not necessary to achieve all of the advantages described above at the same time to implement any product or method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the embodiments of the present invention 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 invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0045] Figure 1 A flow chart of a method for bolding a font provided by an embodiment of the present invention;
[0046] Figure 2a An effect diagram of bolding a font using a font engine universal interface under the first operating system provided by an embodiment of the present invention;
[0047] Figure 2b An effect diagram of bolding a font using a font engine universal interface under the second operating system provided by an embodiment of the present invention;
[0048] Figure 2c An effect diagram of bolding a font using the method provided by the embodiment of the present invention is provided in the embodiment of the present invention;
[0049] Figure 3 A partial flow chart of a method for bolding a font provided by an embodiment of the present invention;
[0050] Figure 4 A structural schematic diagram of a font bolding device provided by an embodiment of the present invention;
[0051] Figure 5 A schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0052] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0053] Currently, when using the standard interface for bolding fonts provided by the font engine to achieve font bolding, the line width of the glyph becomes very wide, making the bold display of the same font and the same glyph inconsistent on different operating systems, thereby affecting the user's reading experience.
[0054] In order to solve the problem of inconsistent bold display of the same font and the same glyph on different operating systems, the embodiments of the present invention provide a font bolding method, device, electronic device and storage medium. Figure 1-5 A method, device, electronic device and storage medium for bolding a font provided by an embodiment of the present invention are described in detail.
[0055] like Figure 1 As shown, Figure 1 A flowchart of a method for bolding a font provided by an embodiment of the present invention, the method comprising:
[0056] Step 101: determine the text to be bolded in the electronic document.
[0057] The text to be bolded may be any text to be bolded in the electronic document, such as a title, a keyword, etc. In the embodiment of the present invention, the user may directly select the text to be bolded by clicking, or may determine the text to be bolded by searching for text, such as searching for the text to be bolded in the electronic document content search box. The embodiment of the present invention may also determine the text to be bolded in the electronic document by other methods, which are not specifically limited.
[0058] Step 102, obtaining the original font of the text to be bolded.
[0059] The original glyphs of the characters to be bolded are the shapes of each character to be bolded, and the shapes of each character are different in different fonts. In programming languages, the glyphs of each character are symbolic descriptions of each data element or data item according to specific rules, wherein the specific rules are related to the lengths of numbers and letters.
[0060] In one embodiment, the original font of the text to be processed can be obtained by using the standard interface of the font engine. For example, the original font of the font to be bolded can be obtained through the standard interface of the font engine freetype, and then the bolded font can be processed in the next step.
[0061] Step 103, determining the bold width of the target brush for the text to be bolded.
[0062] In one embodiment, the user may directly input the bold width of the target brush for the text to be bolded.
[0063] In another embodiment, the bolding width of the target brush for bolding the text to be bolded can be determined according to the current pixel size of the text to be bolded in a preset direction and the pixel size per unit length of the display screen, and this brush is used for the subsequent bolding stroke.
[0064] In the embodiment of the present invention, the preset direction may be a horizontal direction or a vertical direction, which is not limited in the embodiment of the present invention.
[0065] In the embodiment of the present invention, the current pixel size of the text is related to the current font size of the text. The font size of the text to be bolded is different, and the pixel size of the text is also different. For example, if the current font size of the text to be bolded is size 4, the current pixel size of the text to be bolded is 18.7 pixels; if the current font size of the text to be bolded is size 5, the current pixel size of the text to be bolded is 14 pixels.
[0066] Since the pixel size of the same text to be bolded is the same in different operating systems, the bold width of the font to be bolded is determined by the current pixel size of the font to be bolded and the pixel size per unit length of the screen. This ensures that the bolding of the font is not affected by the operating system and that the bold display of the same font and the same glyph on different operating systems is consistent, thereby improving the user reading experience.
[0067] In one embodiment, the following formula may be used to determine the bold width of the target brush of the text to be bolded:
[0068]
[0069] Where D is the target bold width; Pixel is the current pixel size of the text to be bolded in the preset direction; Dpi is the pixel size per unit length of the display screen in the preset direction.
[0070] In another embodiment, the following formula may be used to determine the bold width of the target brush for the text to be bolded:
[0071]
[0072] Wherein, D is the target bold width; Pixel is the current pixel size of the text to be bolded in the preset direction; Dpi is the pixel size per unit length of the display screen in the preset direction, and δ is a preset parameter.
[0073] In the embodiment of the present invention, other methods may be used to determine the bold width, which is not specifically limited.
[0074] Step 104, using the target brush to stroke the original glyph to obtain a bold glyph corresponding to the text to be bolded.
[0075] In the embodiment of the present invention, after determining the original font of the text to be bolded and the bolding width of the target brush, the original font of the text to be bolded can be stroked with a brush to obtain the font of the bolded text.
[0076] In the embodiments of the present invention, the text to be bolded is stroked according to the original glyph of the text to be bolded, so that the bolding of the font is not affected by the operating system, and the bold display of the same font and the same glyph is consistent on different operating systems, improving the user experience.
[0077] For example, in the first operating system (such as the Microsoft system), after bolding the character "中" using the standard interface provided by the font engine for bolding fonts, the bolded font obtained is as Figure 2a the font shown. However, if in the second operating system (such as the Linux system), after bolding the character "中" using the standard interface provided by the font engine for bolding fonts, the bolded font obtained is as Figure 2b the font shown. Figure 2a The bold display of the font shown and Figure 2b the font shown is different.
[0078] In the Linux system, when using the method provided by the embodiments of the present invention to bold the character "中", the bolded font obtained is as Figure 2c shown, and the bolding effect is the same as that in 2a, that is, the bold display effects are the same in different operating systems.
[0079] The font bolding method provided by the embodiments of the present invention can adjust the bolding width of the text to be bolded according to different operating systems, so that the bold display of the same font and the same glyph is consistent on different operating systems, improving the user experience.
[0080] In one embodiment, as Figure 3 shown, step 101 can be refined into the following steps:
[0081] Step 301, obtain the selection instruction of the text in the electronic document input by the user, and the selection instruction includes the target text in the electronic document selected by the user.
[0082] In the embodiments of the present invention, the process of obtaining the selection instruction of the text in the electronic document input by the user can be to obtain the click selection operation of the user for the text to be bolded, and based on the click selection operation, determine the target text, and then generate the selection instruction of the user for the target text. It can also be to obtain the text that the user wants to bold input in the text search bar, and based on the text input by the user, determine the target text, and then generate the selection instruction of the user for the target text. In the embodiments of the present invention, the selection instruction can also be obtained through other means, and no specific limitation is made thereto.
[0083] Step 302, determine whether a bolding instruction for the target text is received. If so, execute step 303; if not, execute step 304.
[0084] Step 303, determine that the target text is the text to be bolded.
[0085] Step 304: determine that the target text is not the text to be bolded.
[0086] After the user determines the target text, the user can click the bold option on the operation page. After obtaining the user's operation of clicking the bold option, a bold instruction is generated. By determining whether the bold instruction for the target text is received, it is determined whether the target text is the text to be bolded. After determining that the target text is the text to be bolded, continue to execute step 102.
[0087] The target text in the selection instruction is obtained based on the user's selection instruction, and whether the target text is the text to be bolded is determined according to whether a bolding instruction for the target text is received. The text that the user needs to bold can be accurately determined and the text can be bolded.
[0088] To achieve the above purpose, the embodiment of the present invention also provides a font bolding device, such as Figure 4 As shown, the device comprises:
[0089] The first determining module 401 is used to determine the text to be bolded in the electronic document.
[0090] The acquisition module 402 is used to acquire the original font of the text to be bolded.
[0091] The second determining module 403 is used to determine the bold width of the target brush of the text to be bolded.
[0092] The stroke module 404 strokes the original glyph using the target brush to obtain a bold glyph corresponding to the to-be-bolded text.
[0093] In one embodiment, the second determining module 403 is specifically configured to determine the bolding width of the target brush of the text to be bolded according to the current pixel size of the text to be bolded in a preset direction and the pixel size per unit length of the display screen.
[0094] In one embodiment, the second determining module 403 is specifically configured to:
[0095] Use the following formula to determine the bold width of the target brush for the text to be bolded:
[0096]
[0097] Where D is the bold width of the target brush; Pixel is the current pixel size of the text to be bolded in the preset direction; Dpi is the pixel size per unit length of the display screen in the preset direction.
[0098] In one embodiment, the acquisition module 402 is specifically used to: use the standard interface of the font engine to acquire the original font of the text to be processed.
[0099] In one embodiment, the first determining module 401 includes:
[0100] The acquisition submodule is used to acquire a selection instruction of a word in an electronic document input by a user, wherein the selection instruction includes a target word in the electronic document selected by the user.
[0101] The determination submodule is used to determine that the target text is the text to be bolded if a bolding instruction for the target text is received.
[0102] The embodiment of the present invention further provides an electronic device, such as Figure 5 As shown, it includes a processor 501 , a communication interface 502 , a memory 503 and a communication bus 504 , wherein the processor 501 , the communication interface 502 , and the memory 503 communicate with each other via the communication bus 504 .
[0103] Memory 503, used for storing computer programs;
[0104] The processor 501 is used to execute the program stored in the memory 503, and implements the following steps:
[0105] Determine the text to be bolded in the electronic document; obtain the original font of the text to be bolded; determine the bold width of the target brush of the text to be bolded; use the target brush to stroke the original font to obtain the bold font corresponding to the text to be bolded.
[0106] The above method obtains bold text by stroking, which can ensure that the bolding of the font is not affected by the operating system, and ensure that the bolding display of the same font and the same glyph on different operating systems is consistent, thereby solving the problem of inconsistent bolding display of the same font and the same glyph on different operating systems and improving the user's reading experience.
[0107] The communication bus mentioned in the above network device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0108] The communication interface is used for communication between the above network devices and other devices.
[0109] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0110] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, and discrete hardware components.
[0111] Based on the same technical concept, an embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the above-mentioned method steps for making a font bold are implemented.
[0112] Based on the same technical concept, an embodiment of the present invention further provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the above-mentioned steps of a method for making a font bold.
[0113] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0114] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article 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, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0115] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, electronic device, storage medium and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0116] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A method for bolding a font, characterized in that: The method comprises: Determine the text to be bolded in the electronic document; Obtaining the original font of the text to be bolded; The bold width of the target brush of the text to be bolded is determined by using one of the following formulas: Wherein, D is the bold width of the target brush; Pixel is the current pixel size of the text to be bolded in a preset direction; Dpi is the pixel size per unit length of the display screen in a preset direction; δ is a preset parameter; The target brush is used to stroke the original glyph to obtain a bold glyph corresponding to the to-be-bolded text.
2. The method according to claim 1, characterized in that The step of obtaining the original font of the text to be bolded comprises: The original font of the text to be bolded is obtained using a standard interface of a font engine.
3. The method according to claim 1, characterized in that The step of determining the text to be bolded in the electronic document includes: Acquire a selection instruction of a character in an electronic document input by a user, wherein the selection instruction includes a target character in the electronic document selected by the user; If a bolding instruction for the target text is received, the target text is determined to be text to be bolded.
4. A font bolding device, characterized in that: The device comprises: A first determination module, used to determine the text to be bolded in the electronic document; An acquisition module, used for acquiring the original font of the text to be bolded; The second determination module is used to determine the bold width of the target brush of the text to be bolded by using one of the following formulas: Wherein, D is the bold width of the target brush; Pixel is the current pixel size of the text to be bolded in a preset direction; Dpi is the pixel size per unit length of the display screen in a preset direction; δ is a preset parameter; The stroke module uses the target brush to stroke the original glyph to obtain a bold glyph corresponding to the to-be-bolded text.
5. The device according to claim 4, characterized in that The acquisition module is specifically used for: The original font of the text to be bolded is obtained using a standard interface of a font engine.
6. The device according to claim 4, characterized in that The first determining module comprises: An acquisition submodule, used to acquire a selection instruction of a character in an electronic document input by a user, wherein the selection instruction includes a target character in the electronic document selected by the user; The determination submodule is used to determine that the target text is a text to be made bold if a bold instruction for the target text is received.
7. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 3 when executing a program stored in a memory.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 3 are implemented.
