CN112580314A - Method, device and equipment for processing words and computer readable medium - Google Patents

Method, device and equipment for processing words and computer readable medium Download PDF

Info

Publication number
CN112580314A
CN112580314A CN201910936151.0A CN201910936151A CN112580314A CN 112580314 A CN112580314 A CN 112580314A CN 201910936151 A CN201910936151 A CN 201910936151A CN 112580314 A CN112580314 A CN 112580314A
Authority
CN
China
Prior art keywords
character
text
characters
canvas
ordinate
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910936151.0A
Other languages
Chinese (zh)
Inventor
李非凡
王悦
李林森
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201910936151.0A priority Critical patent/CN112580314A/en
Publication of CN112580314A publication Critical patent/CN112580314A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/60Editing figures and text; Combining figures or text

Abstract

The invention discloses a method, a device and equipment for processing words and a computer readable medium, and relates to the technical field of computers. One embodiment of the method comprises: according to the image of the character, obtaining the highest point ordinate of the character and the lowest point ordinate of the character; based on the highest point ordinate of the characters and the lowest point ordinate of the characters, locating a central line of a character block, wherein the character block is used for filling characters; taking the center line of the character block as a canvas center line, and filling the characters in the character block on the canvas; and binding the canvas with the document object model of the character to display the character. The embodiment can set the characters to be vertically centered under the Android system.

Description

Method, device and equipment for processing words and computer readable medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a computer-readable medium for processing a word.
Background
With the popularization of mobile terminals, more and more users log on the internet by using the mobile terminals.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
in the use process of the mobile terminal network, labels and buttons are difficult to be displayed vertically and centrally in a page under an Android system, and upward deviation occurs.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method, an apparatus, a device, and a computer-readable medium for processing a word, which can set a vertical centering of the word under an Android system.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a method of processing a word, including:
according to the image of the character, obtaining the highest point ordinate of the character and the lowest point ordinate of the character;
based on the highest point ordinate of the characters and the lowest point ordinate of the characters, locating a central line of a character block, wherein the character block is used for filling characters;
taking the center line of the character block as a canvas center line, and filling the characters in the character block on the canvas;
and binding the canvas with the document object model of the character to display the character.
The image of the text is the data returned through the getImageData API.
The populating the text in the text block on the canvas includes:
setting a base line ordinate of the characters according to the highest point ordinate of the characters and the lowest point ordinate of the characters;
and aligning the characters with the base line ordinate by adopting a textBaseline API, and filling the characters into character blocks on the canvas by using a fillText API.
The setting of the base line ordinate of the characters according to the highest point ordinate of the characters and the lowest point ordinate of the characters comprises the following steps:
taking the difference value of the highest point ordinate of the character and the lowest point ordinate of the character as the height of the character block;
and setting a base line ordinate of the character according to the height of the character block.
After the character block is filled on the canvas according to the canvas midline, the method further comprises the following steps:
and adjusting the edge of the canvas according to the image of the character.
According to a second aspect of the embodiments of the present invention, there is provided an apparatus for processing a word, including:
the coordinate module is used for obtaining the highest point ordinate of the characters and the lowest point ordinate of the characters according to the images of the characters;
the positioning module is used for positioning the center line of the character block based on the highest point ordinate of the characters and the lowest point ordinate of the characters, and the character block is used for filling the characters;
the filling module is used for filling the characters in the character blocks on the canvas by taking the center line of the character blocks as the center line of the canvas;
and the display module is used for binding the canvas with the document object model of the character so as to display the character.
The image of the text is the data returned through the getImageData API.
The filling module is specifically used for setting a baseline ordinate of the character according to the highest-point ordinate of the character and the lowest-point ordinate of the character;
and aligning the characters with the base line ordinate by adopting a textBaseline API, and filling the characters into character blocks on the canvas by using a fillText API.
According to a third aspect of the embodiments of the present invention, there is provided an electronic device for processing text, including:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method as described above.
According to a fourth aspect of embodiments of the present invention, there is provided a computer readable medium, on which a computer program is stored, which when executed by a processor, implements the method as described above.
One embodiment of the above invention has the following advantages or benefits: the highest point ordinate and the lowest point ordinate of the characters are obtained according to the images of the characters; based on the highest point ordinate and the lowest point ordinate of the characters, locating the center line of the character block, wherein the character block is used for filling the characters; taking the center line of the character block as the center line of the canvas, and filling characters in the character block on the canvas; and binding the canvas with the document object model of the text to display the text. Because the central line of the character block can be used as the central line of the canvas, the character block can be displayed in the canvas in a centered mode, and therefore the character vertical centering can be set under the Android system.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a diagram illustrating text offsets in a web page according to an embodiment of the invention;
FIG. 2 is a schematic diagram of a main flow of a method for processing a word according to an embodiment of the invention;
FIG. 3 is a schematic diagram of a text placement location according to an embodiment of the invention;
FIG. 4 is a schematic diagram of displaying text according to an embodiment of the invention;
FIG. 5 is a schematic diagram of the main structure of a device for processing a word according to an embodiment of the present invention;
FIG. 6 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 7 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Referring to fig. 1, fig. 1 is a schematic diagram of text offset in a web page according to an embodiment of the present invention. Fig. 1a shows a webpage accessing a certain website under the Android system. Labeling: 5-element coupons; a button: look similar. The label and button are both biased upwardly.
FIG. 1b shows another website webpage accessed under Android. Labeling: 99+, there is also a problem of upward shift.
Fig. 1c is a page for accessing an application under the Android system. Labeling: self-help paying also has the problem of upward deviation.
At present, for the problem that labels and buttons shift upwards in an Android system, the following two ways can be adopted to solve the problem:
the first method is as follows:
for the equipment with the Android system above 7.0, a lang attribute is set on Hyper Text Markup Language (html): html lang ═ zh-cmn-Hans.
The second method comprises the following steps:
the Android style can be written separately by using a Hack method.
For the first scheme, not all Android devices are compatible, and English display is affected. For scheme two: two sets of styles need to be maintained, namely: the original writing style and the Android style are written separately, so that the development efficiency is influenced and the maintenance cost is increased.
In order to solve the technical problem that the characters in the webpage deviate upwards in the Android system, the following technical scheme in the embodiment of the invention can be adopted.
Referring to fig. 2, fig. 2 is a schematic diagram of a main flow of a method for processing a text according to an embodiment of the present invention, which locates a centerline of a text block, and fills the text block on a canvas with the centerline of the text block as the centerline of the canvas, so that the text can be centered vertically. As shown in fig. 2, the method specifically includes the following steps:
s201, according to the image of the characters, obtaining the highest point ordinate of the characters and the lowest point ordinate of the characters.
In the embodiment of the invention, the characters refer to characters related to access of a webpage, a label and/or a button under an Android system. As an example, fig. 1a tag: 5-element coupons, namely characters. As another example, FIG. 1a buttons: see similar, i.e. text.
The image of the text is an image including the text, and as an example, the image of the 5-membered ticket in fig. 1a is an area marked with a box. One or more tags or buttons are included in a web page. Then for each label or button there is a corresponding image.
In one embodiment of the invention, the image of the text may be returned through the getImageData API. Specifically, an ImageData object is returned through the getImageData API in the Canvas. The ImageData object contains all pixel point data of a rectangular image given by Canvas. That is, the ImageData object includes all pixel point data of the image of the text.
As an example, an ImageData object is returned through the getImageData API in the Canvas. The ImageData object contains the tags in FIG. 1 a: and data of all pixel points of the 5-element ticket. The data of all the pixels may include coordinates of all the pixels. It can be understood that the label or the button includes a plurality of pixel points, and the coordinates of each pixel point can be known through the getImageData API.
And circularly traversing the data of all the pixel points to obtain the highest point ordinate of the characters and the lowest point ordinate of the characters. In the embodiment of the invention, the characters can be arranged transversely. Since the text is prone to the problem of upward shift, the ordinate of the text can be set. Wherein, the difference value between the vertical coordinate of the highest point of the character and the vertical coordinate of the lowest point of the character is the height of the character.
In the embodiment of the present invention, there is no particular requirement for the type of characters. The characters can be any other characters such as Chinese, English, German, symbols and the like. That is to say, the technical solution in the embodiment of the present invention can be applied to processing different types of characters.
S202, based on the highest point ordinate of the characters and the lowest point ordinate of the characters, the central line of the character block is located, and the character block is used for filling the characters.
In the embodiment of the present invention, the region including the possible characters is used as the character block. Wherein, the vertical coordinate of the upper edge of the character block is the same as the vertical coordinate of the highest point of the character; the ordinate of the lower edge of the text block is the same as the ordinate of the lowest point of the text.
As one example, the left edge of the text block may be the smallest abscissa of the included text, and the right edge of the text block may be the largest abscissa of the included text. It is understood that a text block is the smallest area that includes text.
The text block is used to fill in text. The character block can be tightly wrapped with characters, and the central line of the characters is the central line of the character block. The centerline ordinate of the text block may be equal to (the highest point ordinate of the text and the lowest point ordinate of the text)/2.
S203, the center line of the character block is used as the center line of the canvas, and characters are filled in the character block on the canvas.
The center line of the text block is located in the middle of the text, and in order to enable the text to be displayed in the middle and avoid upward deviation, the center line of the text block can be used as the center line of the canvas.
In embodiments of the present invention, the canvas may be understood as the area where the text blocks are placed. Because the midline of the canvas coincides with the midline of the character block, the characters in the character block are necessarily in the middle position of the canvas, and the condition of deviation can not occur. As one example, the canvas may occupy as large an area as the tile, i.e., the canvas coincides with the tile. Of course, the canvas may occupy a larger area than the text.
In one embodiment of the invention, the Canvas may be a Canvas. The Canvas is a rectangular area in which each pixel can be controlled. As one example, in hypertext Markup Language (HTML 5), images can be drawn on a web page using JavaScript through canvas elements.
The text blocks may be placed on a canvas so that the text blocks on the canvas are filled with text. Therefore, the characters can be ensured to be positioned in the middle of the canvas in a canvas mode, and the situation of deviation cannot occur.
In one embodiment of the invention, the specific placement location of the text is based on a baseline placement. Referring to fig. 3, fig. 3 is a schematic diagram of a text placement position according to an embodiment of the invention.
In FIG. 3, 6 lines are referred to, the top line is the highest line of the character, the bottom line is the lowest line of the character, alphabetic is the letter baseline, handling is the hanging baseline, midle is the median line, and ideographic is the ideographic baseline.
It is understood that text may be placed over alphabetic in fig. 3. That is, after the baseline ordinate is determined, the text may be placed according to the baseline ordinate.
Since the text needs to be placed in the text block, the baseline vertical coordinate of the text needs to take into account the height of the text block. The difference value of the vertical coordinate of the highest point of the character and the vertical coordinate of the lowest point of the character, namely the height of the character block.
Then the base ordinate of the text is equal to the difference between the original base ordinate and the height of the text block. It can be seen that filling in the text block requires filling on the baseline ordinate after setting.
In one embodiment of the invention, the ordinate may be marked in pixels. As an example, if the original ordinate of the baseline is 10 pixels and the height of the text block is 5 pixels, then the baseline ordinate is set to be the difference between 10 pixels and 5 pixels, i.e. 5 pixels, then the text can be filled on the baseline with the ordinate of 5 pixels.
In an embodiment of the present invention, after the baseline ordinate of the text is set according to the highest point ordinate and the lowest point ordinate of the text, the text is aligned with the baseline ordinate specifically by using textBaseline API, and then the text is filled into the text block on the canvas by using fillText API.
For example, the text filled in the text block may be rendered from the upper edge of the text block until the edge of the text block ends the rendering process.
The central line of the character block coincides with the central line of the canvas, characters are filled in the character block, and the characters in the canvas are vertically centered.
And S204, binding the canvas and the document object model of the characters to display the characters.
The Document Object Model (DOM) is a programming interface for HTML and extensible markup language (XML) documents. It provides a structured representation of a document and defines a way in which the structure can be accessed from a program to change the structure, style and content of the document.
In the embodiment of the invention, the characters are vertically centered in the canvas through the character blocks, the canvas is bound with the DOM of the characters, and the webpage can be accessed under the Android system. Text in the labels and/or buttons involved in the web page is displayed vertically centered without offset.
In the embodiment of the invention, the central line of the text block can be used as the central line of the canvas, so that the text block can be displayed in the middle of the canvas, and after the text block is filled with the text block, the text can be vertically centered in the webpage under the Android system, and the offset is avoided.
Referring to fig. 4, fig. 4 is a schematic diagram of displaying text according to an embodiment of the invention. FIG. 4 includes 4 Chinese characters: you are good in the world. In fig. 4, there are three lines, the upper line is the upper edge of the text block, and the lower line is the lower edge of the text block. The middle line is the middle line of the text block. Wherein the checkered pattern is a canvas. The canvas centerline coincides with the centerline of the text block.
Therefore, the characters can be filled in the character blocks on the canvas, so that the characters can be vertically centered, and the offset is avoided.
In an embodiment of the present invention, when a text block on a canvas is filled with text, since the center line process of locating the text block is performed based on the highest point ordinate of the text and the lowest point ordinate of the text, an error occurring in the calculation process may cause the text to be located outside the canvas. In order to avoid the characters being located outside the canvas, the edges of the canvas may be adjusted according to the images of the characters, so that the characters are all located inside the canvas.
As one example, the calculation is based on the highest point ordinate of the text and the lowest point ordinate of the text. The ordinate of the highest point of the character is 31 pixels, the ordinate of the lowest point of the character is 10 pixels, the ordinate of the center line of the character block is (31 pixels-10 pixels)/2 is 10.5 pixels, and the minimum unit of the ordinate is a pixel in the actual calculation process, so that the ordinate of the center line of the character block is approximate to 10 pixels. Then, the height of the text box is 20 pixels, and the height of the actual text is 31 pixels-10 pixels-21 pixels. Obviously, if the height of the text box is less than the height of the actual text, then the text will be outside the canvas. Then, the canvas may be adjusted, such as: the canvas is respectively extended upwards by 1 pixel and extended downwards by 1 pixel, so that all characters can be positioned in the canvas.
Through extensive and intensive research by the applicant, the Android system is considered to be difficult to vertically and centrally display in a page, and the essential reason of the problem that the page can shift upwards is as follows: android WebView references the relevant attributes of the primfont during the typesetting of the Chinese font, which causes the text to be already shifted when rendered inside the content area. The centering scheme of the Cascading Style Sheets (CSSs) is to control the centering of the whole content area, so that it is difficult to really solve the above technical problem from the CSS level.
The Android WebView is a control for showing a web page based on a webkit engine. The method has powerful functions, and can perform powerful processing on url requests, page loading, rendering and page interaction besides the attributes and settings of common views.
In the embodiment of the invention, the problem that the Android WebView uses Canvas instead of the Android WebView to render the characters is avoided, so that the vertical centering of the characters in the Android WebView is converted into the vertical centering of the characters in the Canvas.
Fig. 5 is a schematic diagram of a main structure of a text processing apparatus according to an embodiment of the present invention, where the text processing apparatus can implement a text processing method, and as shown in fig. 5, the text processing apparatus specifically includes:
the coordinate module 501 is configured to obtain a highest point ordinate of the text and a lowest point ordinate of the text according to the image of the text.
A positioning module 502, configured to position a center line of a text block based on the highest-point ordinate of the text and the lowest-point ordinate of the text, where the text block is used for filling the text.
And a filling module 503, configured to fill the text block on the canvas with the centerline of the text block as the centerline of the canvas.
A display module 504 for binding the canvas with the document object model of the text to display the text.
In one embodiment of the invention, the image of the text is the data returned through the getImageData API.
In an embodiment of the present invention, the filling module 503 is specifically configured to set a baseline ordinate of the text according to a highest-point ordinate of the text and a lowest-point ordinate of the text;
the text is aligned to the baseline vertical using the textBaseline API and then filled into the text blocks on the canvas through the fillText API.
In an embodiment of the present invention, the filling module 503 is specifically configured to use a difference between a highest-point ordinate of the text and a lowest-point ordinate of the text as the height of the text block;
and setting a base line ordinate of the character according to the height of the character block.
In an embodiment of the invention, the presentation module 504 is further configured to adjust an edge of the canvas according to the image of the text.
Fig. 6 illustrates an exemplary system architecture 600 of a method or apparatus for processing text to which embodiments of the invention may be applied.
As shown in fig. 6, the system architecture 600 may include terminal devices 601, 602, 603, a network 604, and a server 605. The network 604 serves to provide a medium for communication links between the terminal devices 601, 602, 603 and the server 605. Network 604 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 601, 602, 603 to interact with the server 605 via the network 604 to receive or send messages or the like. The terminal devices 601, 602, 603 may have installed thereon various communication client applications, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 601, 602, 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 605 may be a server providing various services, such as a background management server (for example only) providing support for shopping websites browsed by users using the terminal devices 601, 602, 603. The backend management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (for example, target push information, product information — just an example) to the terminal device.
It should be noted that the method for processing words provided by the embodiment of the present invention is generally executed by the server 605, and accordingly, the apparatus for processing words is generally disposed in the server 605.
It should be understood that the number of terminal devices, networks, and servers in fig. 6 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 7, shown is a block diagram of a computer system 700 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 7, the computer system 700 includes a Central Processing Unit (CPU)701, which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
The following components are connected to the I/O interface 705: an input portion 706 including a keyboard, a mouse, and the like; an output section 707 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 708 including a hard disk and the like; and a communication section 709 including a network interface card such as a LAN card, a modem, or the like. The communication section 709 performs communication processing via a network such as the internet. A drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that a computer program read out therefrom is mounted into the storage section 708 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 709, and/or installed from the removable medium 711. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 701.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a transmitting unit, an obtaining unit, a determining unit, and a first processing unit. The names of these units do not in some cases constitute a limitation to the unit itself, and for example, the sending unit may also be described as a "unit sending a picture acquisition request to a connected server".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise:
according to the image of the character, obtaining the highest point ordinate of the character and the lowest point ordinate of the character;
based on the highest point ordinate of the characters and the lowest point ordinate of the characters, locating a central line of a character block, wherein the character block is used for filling characters;
taking the center line of the character block as a canvas center line, and filling the characters in the character block on the canvas;
and binding the canvas with the document object model of the character to display the character.
According to the technical scheme of the embodiment of the invention, the highest point ordinate of the characters and the lowest point ordinate of the characters are obtained according to the images of the characters; based on the highest point ordinate and the lowest point ordinate of the characters, locating the center line of the character block, wherein the character block is used for filling the characters; taking the center line of the character block as the center line of the canvas, and filling characters in the character block on the canvas; and binding the canvas with the document object model of the text to display the text. Because the central line of the character block can be used as the central line of the canvas, the character block can be displayed in the canvas in a centered mode, and therefore the character vertical centering can be set under the Android system.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for processing text, comprising:
according to the image of the character, obtaining the highest point ordinate of the character and the lowest point ordinate of the character;
based on the highest point ordinate of the characters and the lowest point ordinate of the characters, locating a central line of a character block, wherein the character block is used for filling characters;
taking the center line of the character block as a canvas center line, and filling the characters in the character block on the canvas;
and binding the canvas with the document object model of the character to display the character.
2. The method of processing text as recited in claim 1, wherein the image of the text is data returned through a getImageData API.
3. The method of processing text according to claim 1, wherein said populating the text block on the canvas with the text comprises:
setting a base line ordinate of the characters according to the highest point ordinate of the characters and the lowest point ordinate of the characters;
and aligning the characters with the base line ordinate by adopting a textBaseline API, and filling the characters into character blocks on the canvas by using a fillText API.
4. The method of claim 3, wherein said setting a baseline ordinate of said text in accordance with a highest point ordinate of said text and a lowest point ordinate of said text comprises:
taking the difference value of the highest point ordinate of the character and the lowest point ordinate of the character as the height of the character block;
and setting a base line ordinate of the character according to the height of the character block.
5. The method of processing text according to claim 1, wherein after filling the block of text on the canvas according to the canvas centerline, further comprising:
and adjusting the edge of the canvas according to the image of the character.
6. An apparatus for processing text, comprising:
the coordinate module is used for obtaining the highest point ordinate of the characters and the lowest point ordinate of the characters according to the images of the characters;
the positioning module is used for positioning the center line of the character block based on the highest point ordinate of the characters and the lowest point ordinate of the characters, and the character block is used for filling the characters;
the filling module is used for filling the characters in the character blocks on the canvas by taking the center line of the character blocks as the center line of the canvas;
and the display module is used for binding the canvas with the document object model of the character so as to display the character.
7. The apparatus for processing text according to claim 1 wherein the image of the text is data returned through a getImageData API.
8. The apparatus for processing a text according to claim 1, wherein the filling module is configured to set a baseline ordinate of the text according to a highest-point ordinate of the text and a lowest-point ordinate of the text;
and aligning the characters with the base line ordinate by adopting a textBaseline API, and filling the characters into character blocks on the canvas by using a fillText API.
9. An electronic device for processing text, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-5.
10. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-5.
CN201910936151.0A 2019-09-29 2019-09-29 Method, device and equipment for processing words and computer readable medium Pending CN112580314A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910936151.0A CN112580314A (en) 2019-09-29 2019-09-29 Method, device and equipment for processing words and computer readable medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910936151.0A CN112580314A (en) 2019-09-29 2019-09-29 Method, device and equipment for processing words and computer readable medium

Publications (1)

Publication Number Publication Date
CN112580314A true CN112580314A (en) 2021-03-30

Family

ID=75111119

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910936151.0A Pending CN112580314A (en) 2019-09-29 2019-09-29 Method, device and equipment for processing words and computer readable medium

Country Status (1)

Country Link
CN (1) CN112580314A (en)

Similar Documents

Publication Publication Date Title
US9280523B2 (en) System for conversion of website content
CN109543454B (en) Anti-crawler method and related equipment
US20140215308A1 (en) Web Page Reflowed Text
US20090085921A1 (en) Populate Web-Based Content Based on Space Availability
CN103345493B (en) Method that content of text on mobile terminal shows, Apparatus and system
CN113382083B (en) Webpage screenshot method and device
CN111294395A (en) Terminal page transmission method, device, medium and electronic equipment
CN109635223A (en) Page display method and device
CN110874251A (en) Method and device for realizing picture wooden barrel layout
CN113360106B (en) Webpage printing method and device
CN115495417A (en) Content loading method, device, equipment, medium and program product
CN111783007B (en) Display rendering method and device, electronic equipment and storage medium
CN113760283A (en) Text rendering method and device
CN113282852A (en) Method and device for editing webpage
KR102087274B1 (en) Web electric document editing apparatus for rendering object and operating method thereof
CN112580314A (en) Method, device and equipment for processing words and computer readable medium
US20140195894A1 (en) Method and system for continuous rendering of web content
CN109388920A (en) For on the mobile apparatus using the upper method and apparatus that watermark is dynamically arranged
CN111191974B (en) Medicine inventory method and device
CN112926294A (en) Template file generation method and device
CN112445478A (en) Graphic file processing method, device, equipment and medium
CN112825079B (en) Information display method and device
CN113032696A (en) Display method and display device of page picture
US20130111433A1 (en) Method and apparatus for generating application programs
CN112579080A (en) Method and device for generating user interface code

Legal Events

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