CN111881050A - Method and device for clipping text layer and electronic equipment - Google Patents

Method and device for clipping text layer and electronic equipment Download PDF

Info

Publication number
CN111881050A
CN111881050A CN202010760906.9A CN202010760906A CN111881050A CN 111881050 A CN111881050 A CN 111881050A CN 202010760906 A CN202010760906 A CN 202010760906A CN 111881050 A CN111881050 A CN 111881050A
Authority
CN
China
Prior art keywords
layer
text
height
text layer
line
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.)
Granted
Application number
CN202010760906.9A
Other languages
Chinese (zh)
Other versions
CN111881050B (en
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 IQIYI Science and Technology Co Ltd
Original Assignee
Beijing IQIYI Science and 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 IQIYI Science and Technology Co Ltd filed Critical Beijing IQIYI Science and Technology Co Ltd
Priority to CN202010760906.9A priority Critical patent/CN111881050B/en
Publication of CN111881050A publication Critical patent/CN111881050A/en
Application granted granted Critical
Publication of CN111881050B publication Critical patent/CN111881050B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/40Document-oriented image-based pattern recognition

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Multimedia (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • General Engineering & Computer Science (AREA)
  • Controls And Circuits For Display Device (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The embodiment of the invention provides a method and a device for cutting a text layer and electronic equipment, wherein the method comprises the following steps: acquiring an application program interface to be checked; acquiring the position of each text layer in an application program interface to be checked and received, the word size, the line height and the text height of characters included in each text layer; for each text layer, determining whether the text layer only comprises one line of words; if the text layer only comprises one line of characters, determining the default height corresponding to the character number of the characters included in the text layer as the layer height of the text layer; if the text layer comprises a plurality of lines of characters, determining the difference between the line height of the characters included in the text layer and the default height corresponding to the character size of the characters as a first difference, and determining the difference between the text height corresponding to the text layer and the first difference as the layer height of the text layer; and clipping the text layer based on the position and the layer height of the text layer. By applying the embodiment of the invention, the accuracy of the acceptance application program interface can be improved.

Description

Method and device for clipping text layer and electronic equipment
Technical Field
The invention relates to the technical field of application program development, in particular to a method and a device for cutting a text layer and electronic equipment.
Background
A UI (User Interface) is an Interface through which a User interacts with an application. In the UI, a plurality of types of layers, for example, a text layer, an image layer, and the like, are generally included.
When the UI is applied to an operating system, the font of the text in the text layer included in the UI is usually the default font of the operating system, and the line height of the text in the text layer included in the UI is usually the default line height of the operating system. In order to adapt the developed UI to different operating systems, in the UI development process, the fonts of the characters in the text layer included in the UI are generally set as default fonts of the operating system, and the line heights of the characters in the text layer are set as default line heights of the operating system. Since the heights of characters with the same font size and different fonts are different, and the default line heights of different operating systems are also different, the heights of the text layers included in a UI are often inconsistent when the UI is applied to different operating systems.
In order to determine whether the developed UI meets the design requirements, the developed UI needs to be checked, and in the checking process, for each two adjacent layers, the distance between the two adjacent layers needs to be measured. For the same UI applied to different operating systems, acceptance is typically only once at the time of acceptance. Because the fonts and the line heights of the characters in the text layer are respectively the default fonts and the default line heights of the applied operating systems, when the same UI is applied to different operating systems, the heights of the same text layer are usually inconsistent, so that when the distance between the text layer and the adjacent layer is measured, the corresponding distance difference is larger when the same UI is applied to different operating systems, and further the UI interface which cannot be accurately checked, developed and completed is further caused.
Disclosure of Invention
The embodiment of the invention aims to provide a method and a device for cutting a text layer and electronic equipment, so as to improve the accuracy of an acceptance application program interface. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a method for clipping a text layer, where the method includes:
acquiring an application program interface to be checked;
acquiring the position of each text layer in the application program interface to be checked and received, the word size, the line height and the text height of characters included in each text layer, wherein the text height is the height occupied by the text in the text layer;
for each text layer, determining whether the text layer only comprises one line of words;
if the text layer only comprises one line of characters, determining the default height corresponding to the character number of the characters contained in the text layer as the layer height of the text layer;
if the text layer comprises a plurality of lines of characters, determining a difference value between the line height of the characters included in the text layer and a default height corresponding to the word size of the characters as a first difference value, and determining a difference value between the text height corresponding to the text layer and the first difference value as the layer height of the text layer;
for each text layer, the text layer is clipped based on the position and layer height of the text layer.
Optionally, the step of determining, for each text layer, whether the text layer includes only one line of words includes:
for each text layer, determining whether the text layer only comprises one line of characters or not based on the line height and the text height of the characters included in the text layer; or the like, or, alternatively,
and acquiring the layer original height of each text layer in the application program interface to be checked and received aiming at each text layer, and determining whether the text layer only comprises one line of characters or not based on the layer original height of the text layer and the default height corresponding to the word size of the included characters.
Optionally, the step of determining whether the text layer includes only one line of characters based on the layer original height of the text layer and the default height corresponding to the font size of the included characters includes:
judging whether the layer original height of the text layer is less than 2 times of the default height corresponding to the word size of the characters included in the text layer;
if yes, determining that the text layer only comprises one line of words;
if not, determining that the text layer comprises a plurality of lines of words.
Optionally, before the step of clipping the text layer based on the position and the layer height of the text layer for each text layer, the method further includes:
for each text layer, determining whether the text layer comprises non-word content;
if the text layer comprises non-character content, creating a new layer, and copying the non-character content to the new layer, wherein the position and the height of the new layer are respectively the same as the position and the original height of the text layer;
deleting the non-character content in the text layer, and executing the step of cutting the text layer according to the position and the layer height of the text layer aiming at each text layer.
Optionally, before the step of obtaining the application program interface to be checked, the method further includes:
acquiring marking information of an application program interface to be developed, wherein the marking information comprises the design layer height of each text layer included in the application program interface to be developed, and the word size and line height of characters included in the text layer;
for each text layer, determining a target line height from a preset line height table based on a target operating system corresponding to the application program interface to be developed and the word size of the text layer included in the marking information, wherein the preset line height table includes corresponding relations of operating system identification, word size and line height;
determining whether the text layer includes only one line of text;
if the text layer only comprises one line of characters, determining the layer height of the text layer as the target line height;
if the text layer comprises a plurality of lines of characters, calculating a difference value between the line height of the characters included in the text layer and the target line height to serve as a second difference value, and determining the layer height of the text layer as the difference value between the design layer height of the text layer and the second difference value;
and adjusting the labeling information of the application program interface to be developed according to the layer height of each text layer, and developing and obtaining the application program interface to be checked and accepted based on the adjusted labeling information.
In a second aspect, an embodiment of the present invention provides a device for clipping a text layer, where the device includes:
the interface acquisition module to be checked and accepted is used for acquiring an application program interface to be checked and accepted;
the height acquisition module is used for acquiring the position of each text layer in the application program interface to be checked and received, the word size, the line height and the text height of characters included in each text layer, wherein the text height is the height occupied by the text in the text layer;
the first judgment module is used for determining whether each text layer only comprises one line of characters;
the first layer height determining module is used for determining a default height corresponding to the word number of the word included in the text layer as the layer height of the text layer if the text layer only includes one line of words;
the second layer height determining module is used for determining a difference value between the line height of the characters included in the text layer and the default height corresponding to the word size of the characters as a first difference value if the text layer includes a plurality of lines of characters, and determining a difference value between the text height corresponding to the text layer and the first difference value as the layer height of the text layer;
and the clipping module is used for clipping the text layer based on the position and the layer height of the text layer aiming at each text layer.
Optionally, the first determining module includes:
the first judgment sub-module is used for determining whether each text layer only comprises one line of characters or not based on the line height and the text height of the characters contained in the text layer; or the like, or, alternatively,
and the second judgment submodule is used for acquiring the layer original height of each text layer in the application program interface to be checked and received aiming at each text layer, and determining whether the text layer only comprises one line of characters or not based on the layer original height of the text layer and the default height corresponding to the word size of the included characters.
Optionally, the second determining sub-module includes:
the judging unit is used for judging whether the layer original height of the text layer is less than 2 times of the default height corresponding to the word size of the characters included in the text layer;
the first determining unit is used for determining that the text layer only comprises one line of characters if the text layer only comprises one line of characters;
and the second determining unit is used for determining that the text layer comprises a plurality of lines of characters if the text layer does not comprise the characters.
Optionally, the apparatus further comprises:
a determining module for determining, for each text layer, whether the text layer includes non-textual content before the text layer is clipped based on a position and a layer height of the text layer for each text layer;
the image layer creating module is used for creating a new image layer and copying the non-character content to the new image layer if the text image layer comprises the non-character content, wherein the position and the height of the new image layer are respectively the same as those of the text image layer and the original height of the image layer;
and the non-character content deleting module is used for deleting the non-character content in the text layer and triggering the cutting module.
Optionally, the apparatus further comprises:
the system comprises a to-be-developed interface acquisition module, a to-be-developed application program interface acquisition module and a to-be-verified application program interface acquisition module, wherein the to-be-developed interface acquisition module is used for acquiring the label information of the to-be-developed application program interface before acquiring the to-be-verified application program interface, and the label information comprises the design layer height of each text layer included in the to-be-developed application program interface, and the word size and the line height of;
the target line height determining module is used for determining a target line height from a preset line height table aiming at each text layer based on a target operating system corresponding to the application program interface to be developed and the word size of the text layer included by the marking information, wherein the preset line height table comprises the corresponding relation of an operating system identification, the word size and the line height;
the second judgment module is used for determining whether the text layer only comprises one line of characters;
a third layer height determining module, configured to determine, if the text layer only includes one line of characters, that the layer height of the text layer is the target line height;
a fourth layer height determining module, configured to calculate, if the text layer includes multiple lines of characters, a difference between a line height of the characters included in the text layer and the target line height, as a second difference, and determine that the layer height of the text layer is a difference between a design layer height of the text layer and the second difference;
and the marking information adjusting module is used for adjusting the marking information of the application program interface to be developed according to the layer height of each text layer, and developing and obtaining the application program interface to be checked and received based on the adjusted marking information.
In a third aspect, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor and the communication interface complete communication between the memory and the processor through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing any step of the cutting method of the text layer when executing the program stored in the memory.
In the scheme provided by the embodiment of the invention, the electronic equipment can acquire the application program interface to be checked; acquiring the position of each text layer in an application program interface to be checked and received, the word size, the line height and the text height of characters included in each text layer, wherein the text height is the height occupied by the text in the text layer; for each text layer, determining whether the text layer only comprises one line of words; if the text layer only comprises one line of characters, determining the default height corresponding to the character number of the characters contained in the text layer as the layer height of the text layer; if the text layer comprises a plurality of lines of characters, determining a difference value between the line height of the characters included in the text layer and a default height corresponding to the word size of the characters as a first difference value, and determining a difference value between the text height corresponding to the text layer and the first difference value as the layer height of the text layer; for each text layer, the text layer is clipped based on the position and layer height of the text layer.
Because the default fonts and the default heights of different operating systems are different, when the same application program interface to be checked is applied to different operating systems, the height difference between the blank area above the first row of characters and the height difference between the blank area below the last row of characters in the same text layer are larger. After the electronic device cuts each text layer in the application program interface to be checked and accepted by adopting the above mode, the blank area above the first line of characters and the blank area below the last line of characters in the text layer can be removed. When the application program interface to be checked is only checked once, the distance between the cut text layer and the adjacent layer can be measured, so that the difference between the corresponding distances when the same application program interface to be checked is applied to different operating systems can be reduced, and the accuracy of the application program interface to be checked can be improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
Fig. 1 is a flowchart of a method for clipping text layers according to an embodiment of the present invention;
FIG. 2(a) is a first schematic diagram of a text layer in the embodiment shown in FIG. 1;
FIG. 2(b) is a second schematic diagram of the text layer in the embodiment shown in FIG. 1;
FIG. 2(c) is a third schematic diagram of the text layer in the embodiment shown in FIG. 1;
FIG. 3 is a detailed flowchart of a method for copying non-text content according to an embodiment of the present invention;
FIG. 4 is a detailed flowchart of an adjustment method of the annotation information in the embodiment of the present invention;
fig. 5 is a schematic structural diagram of a clipping device for text layers according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention.
In order to improve the accuracy of an acceptance application program interface, embodiments of the present invention provide a method and an apparatus for clipping a text layer, an electronic device, a computer-readable storage medium, and a computer program product.
First, a method for clipping a text layer according to an embodiment of the present invention is described below.
The method for clipping the text layer provided by the embodiment of the invention can be applied to any electronic device which needs to clip the text layer in the application program interface to be checked, for example, a computer, a processor, a server and the like, and is not limited specifically herein.
As shown in fig. 1, a method for clipping text layer, the method includes:
s101, acquiring an application program interface to be checked;
s102, acquiring the position of each text layer in the application program interface to be checked, the word size, the line height and the text height of characters included in each text layer;
and the text height is the height occupied by the text in the text layer.
S103, determining whether each text layer only comprises one line of characters; if the text layer only comprises one line of words, executing step S104; if the text layer includes a plurality of lines of words, executing step S105;
s104, determining the default height corresponding to the word size of the characters included in the text layer as the layer height of the text layer;
s105, determining a difference value between a line height of a character included in the text layer and a default height corresponding to a word size of the character as a first difference value, and determining a difference value between the text height corresponding to the text layer and the first difference value as a layer height of the text layer;
s106, aiming at each text layer, cutting the text layer based on the position and the layer height of the text layer.
Therefore, in the scheme provided by the embodiment of the invention, the electronic equipment can acquire the application program interface to be checked; acquiring the position of each text layer in an application program interface to be checked and received, the word size, the line height and the text height of characters included in each text layer, wherein the text height is the height occupied by the text in the text layer; for each text layer, determining whether the text layer only comprises one line of words; if the text layer only comprises one line of characters, determining the default height corresponding to the character number of the characters contained in the text layer as the layer height of the text layer; if the text layer comprises a plurality of lines of characters, determining a difference value between the line height of the characters included in the text layer and a default height corresponding to the word size of the characters as a first difference value, and determining a difference value between the text height corresponding to the text layer and the first difference value as the layer height of the text layer; for each text layer, the text layer is clipped based on the position and layer height of the text layer.
Because the default fonts and the default heights of different operating systems are different, when the same application program interface to be checked is applied to different operating systems, the height difference between the blank area above the first row of characters and the height difference between the blank area below the last row of characters in the same text layer are larger. After the electronic device cuts each text layer in the application program interface to be checked and accepted by adopting the above mode, the blank area above the first line of characters and the blank area below the last line of characters in the text layer can be removed. When the application program interface to be checked is only checked once, the distance between the cut text layer and the adjacent layer can be measured, so that the difference between the corresponding distances when the same application program interface to be checked is applied to different operating systems can be reduced, and the accuracy of the application program interface to be checked can be improved.
In step S101, the electronic device may obtain an application interface to be checked, where the application interface to be checked is an interface that needs to be checked and accepted in a developed application, and the application may be applied to various operating systems, for example, an android System, an IOS (apple mobile device operating System) System, and the like. The application program interface to be checked comprises at least one text layer, and the text layer is a layer comprising characters.
In order to determine the layer height of each text layer in the application program interface to be checked, after the application program interface to be checked is obtained, the electronic device may obtain the position of each text layer in the application program interface to be checked, the word size, the line height, and the text height of characters included in each text layer. The text height is a height occupied by a text in the text layer, namely a height between an upper boundary of a text line where a first line of characters is located in the text layer and a lower boundary of a text line where a last line of characters is located in the text layer. In an embodiment, the electronic device may invoke a preset view interface to analyze each text layer in the application program interface to be checked and received, and further obtain a position of each text layer, a font size, a line height, and a text height of characters included in each text layer.
For example, as shown in fig. 2(a), the text layer 200 includes a first line of text 201 and a second line of text 202, where the line height of the first line of text 201 is a height h2 between an upper boundary 203 and a lower boundary 204 of a text line in which the first line of text 201 is located, and the text height of the text layer 200 is a height h1 between the upper boundary 203 of the first line of text 201 and the lower boundary 205 of the second line of text 202. Wherein the lower boundary 204 of the line of text in which the first line of text 201 is located is the upper boundary of the line of text in which the second line of text 202 is located.
For another example, as shown in fig. 2(b), the text layer 210 includes only one line of text 211, and the line height is the height h4 between the upper boundary 212 and the lower boundary 215 of the text line in which the line of text 211 is located, and the text height of the text layer 210 is the line height h4 of the line of text 211.
The application interface to be checked out will likely include other types of layers, such as image layers, in addition to text layers. Therefore, in an embodiment, after the electronic device obtains the application program interface to be checked, the text layer may be determined according to preset type tags of each layer, where the type tags are information included in a tag file corresponding to the application program interface to be checked, and the type tags may represent types of the corresponding layers. In another embodiment, the electronic device may parse each layer in the application interface to be checked to determine a text layer.
After obtaining the word size, line height, and text height of the words included in each text layer, the electronic device may determine, for each text layer, whether the text layer includes only one line of words. In one embodiment, the electronic device may determine whether the text layer includes only one line of text according to a size relationship between a line height of text and a text height of text in the text layer.
For example, when the electronic device determines that the height of text in a text layer is greater than the height of the text in the text layer and less than 2 times the height of the text in the text layer, it may be determined that the text layer only includes one row of text; when the electronic device determines that the height of the text of a text layer is not less than 2 times the height of the text in the text layer, it may be determined that the text layer includes a plurality of lines of text.
For each text layer, when it is determined that the text layer only includes one line of text, the electronic device may determine a default height corresponding to a font size of the text included in the text layer as the layer height of the text layer.
For example, as shown in fig. 2(b), the text layer 210 includes only one line of words 211, and the electronic device may determine a default height corresponding to a font size of a word included in the text layer 210 as the layer height of the text layer 210.
For example, as shown in fig. 2(b), the default height corresponding to the font size of the text layer 210 is the height of the text included in the text layer 210, that is, the height h3 between the top line 213 and the bottom line 214 of a line of the text 211.
For each text layer, when it is determined that the text layer includes multiple lines of text, the electronic device may determine, as a first difference, a difference between a line height of a text included in the text layer and a default height corresponding to a font size of the text, and determine, as a layer height of the text layer, a difference between a text height corresponding to the text layer and the first difference.
For example, as shown in FIG. 2(c), the text layer 220 includes a first line of text 221 and a second line of text 222, the text layer 220 including text having a height h7 between the upper and lower boundaries 223, 226 of the line of text in which the first line of text 221 is located, and the height h7 between the upper and lower boundaries 226, 229 of the line of text in which the second line of text 222 is located. The text layer 220 includes words having a font size that corresponds to a default height h8 between the top line 224 and the bottom line 225 of the first row of words 221, and a height h8 between the top line 227 and the bottom line 228 of the second row of words 222. The electronic device may calculate the difference between the line height h7 and the default height h8 as a first difference, that is, the first difference is the sum of the height between the upper boundary 223 of the line of text in which the first row of text 221 is located and the top line 224 of the first row of text 221 and the height between the lower boundary 226 of the line of text in which the first row of text 221 is located and the bottom line 225 of the first row of text 221.
The text layer 220 corresponds to a text height h5 between the upper boundary 223 of the text line in which the first line of text 221 is located and the lower boundary 229 of the text line in which the second line of text 222 is located, and since the height between the lower boundary 226 of the text line in which the first line of text 221 is located and the bottom line 225 of the first line of text 221 is equal to the height between the lower boundary 229 of the text line in which the second line of text 222 is located and the bottom line 225 of the second line of text 221, the difference between the text height h5 of the text layer 220 and the first difference is h6, that is, the height between the top line 224 of the first line of text 221 and the bottom line 228 of the second line of text 222. Thus, the electronic device may determine h6 as the layer height of text layer 220.
For each text layer in the application program interface to be checked, after determining the layer height of the text layer, in order to adjust the height of the text layer to the determined layer height, the electronic device may clip the text layer for each text layer based on the position and layer height of the text layer.
Because the text layer is a rectangular layer, for each text layer, the position of the text layer may be the coordinate of the vertex at the upper left corner of the text layer in the image coordinate system of the application program interface to be checked. Because the characters included in the text layer are located in the center of the text layer, the electronic device may determine the coordinates of the clipping point of the text layer according to the coordinates of the top-left vertex of the text layer in the image coordinate system of the application program interface to be checked and received and the layer height of the text layer, then determine the clipping boundary according to the coordinates of the clipping point, and further clip the text layer according to the clipping boundary.
Specifically, the electronic device may calculate a difference between an original layer height of the text layer and the layer height, and further add a half of the difference to a vertical coordinate of a top-left vertex of the text layer as a vertical coordinate of the first clipping point, and use a horizontal coordinate of the top-left vertex as a horizontal coordinate of the first clipping point, so that the horizontal coordinate and the vertical coordinate of the first clipping point may be obtained. Further, the sum of the ordinate of the first clipping point and the layer height may be used as the ordinate of the second clipping point, and the abscissa of the vertex at the upper left corner may be used as the abscissa of the second clipping point, so as to obtain the abscissa and the ordinate of the second clipping point. The electronic device may then determine a horizontal line through the first cropping point and a horizontal line through the second cropping point, using the two lines as cropping boundaries.
For example, as shown in fig. 2(b), the coordinates of the upper left corner of the text layer 210 in the image coordinate system of the application interface to be checked are (20, 10), the layer original height of the text layer 210 is 24, and the layer height h3 has a value of 18, so that the electronic device may determine the coordinates of the clipping point 216 of the text layer 210 as (20, 13) and the coordinates of the clipping point 217 as (20, 31), and then may determine the clipping boundaries as the top line 213 and the bottom line 214 of a line of text 211 in the text layer 210, and further clip the text layer 210 according to the clipping boundaries 213 and 214. Thus, the layer height of the cropped text layer 210 is also 18.
In an embodiment, the electronic device may determine a center line of the text layer in the horizontal direction according to the coordinates of the top left corner vertex of the text layer and the original layer height of the text layer, and further determine a horizontal straight line having a height half of the layer height from the center line in the horizontal direction, as a clipping boundary, and further clip the text layer according to the clipping boundary.
For example, if the coordinates of the top left corner vertex of the text layer W × 1 are (30, 20), the layer original height of the text layer W × 1 is 20, and the layer height is 16, the electronic device may determine that the horizontal center line of the text layer W × 1 is a horizontal straight line passing through the point with the coordinates (30,30), and further, the electronic device may determine that the horizontal straight line passing through the point with the coordinates (30, 22) and the horizontal straight line passing through the point with the coordinates (30, 38) are clipping boundaries. Then, the electronic device may clip the text layer W × 1 according to the clipping boundary, so that the layer height of the clipped text layer W × 1 is 16.
After the electronic device cuts each text layer in the application program interface to be checked, blank areas above a first line of characters and blank areas below a last line of characters in the text layer can be removed. That is, after each text layer is clipped, no matter which operating system the application program interface to be checked is applied to, the layer height of the included text layer is the height between the top line of the first line of characters in the text layer and the bottom line of the last line of characters in the text layer. Therefore, the difference between the corresponding distances when the same application program interface to be accepted is applied to different operating systems can be reduced, and the accuracy of the application program interface to be accepted can be improved when the application program interface to be accepted is only accepted once.
As an implementation manner of the embodiment of the present invention, the step of determining, for each text layer, whether the text layer only includes one line of characters may include:
for each text layer, determining whether the text layer only comprises one line of characters or not based on the line height and the text height of the characters contained in the text layer; or, for each text layer, obtaining the layer original height of each text layer in the application program interface to be checked, and determining whether the text layer only includes one line of characters or not based on the layer original height of the text layer and the default height corresponding to the word size of the included characters.
In a first implementation manner, for each text layer, the electronic device may determine whether the text layer includes only one line of words according to a line height and a text height of words included in the text layer. Specifically, the electronic device may calculate a ratio between a height of a text included in the text layer and a line height, and when the ratio between the height of the text included in the text layer and the line height is smaller than 2, it indicates that the height of the text included in the text layer is smaller than 2 times of the line height, and then the text layer may only display one line of words, so the electronic device may determine that the text layer includes only one line of words; when the ratio of the height of the text included in the text layer to the height of the line is not less than 2, it is indicated that the height of the text included in the text layer is not less than 2 times the height of the line, and then the text layer may display multiple lines of words, so the electronic device may determine that the text layer includes multiple lines of words.
In a second implementation manner, in order to determine whether the text layer only includes one line of words, the electronic device may further obtain an original layer height of each text layer in the application program interface to be checked, and for each text layer, determine whether the text layer only includes one line of words according to the original layer height of the text layer and a default height corresponding to a word number of the included word. The layer original height of each text layer can be obtained simultaneously when the position of each text layer in the application program interface to be checked and received, the word size, the line height and the text height of characters included in each text layer are obtained, and the layer original height is the layer height of the text layer set when the application program interface to be checked and received is developed.
The electronic device may determine whether the text layer includes only one line of characters according to a ratio between an original height of the layer of the text layer and a default height corresponding to a font size of the included characters. Specifically, if the ratio of the original layer height of the text layer to the default height corresponding to the font size of the included text is less than 2, which indicates that only one line of text can be displayed in the text layer, the electronic device may determine that only one line of text is included in the text layer; if the ratio of the original layer height of the text layer to the default height corresponding to the font size of the included text is not less than 2, which indicates that multiple lines of text can be displayed in the text layer, the electronic device may determine that multiple lines of text are included in the text layer.
As can be seen, in the scheme provided in the embodiment of the present invention, the electronic device may determine, for each text layer, whether the text layer includes only one line of characters based on the line height and the text height of the characters included in the text layer; or, for each text layer, obtaining the layer original height of each text layer in the application program interface to be checked, and determining whether the text layer only includes one line of characters or not based on the layer original height of the text layer and the default height corresponding to the word size of the included characters. In either way, the electronic device can accurately determine whether each text layer contains a line of text.
As an implementation manner of the embodiment of the present invention, the step of determining whether the text layer includes only one line of characters based on the layer original height of the text layer and the default height corresponding to the font size of the included characters may include:
judging whether the layer original height of the text layer is less than 2 times of the default height corresponding to the word size of the characters included in the text layer; if yes, determining that the text layer only comprises one line of words; if not, determining that the text layer comprises a plurality of lines of words.
For each text layer, in order to determine whether the text layer includes only one line of characters, the electronic device may determine whether an original layer height of the text layer is less than 2 times of a default height corresponding to a font size of a character included in the text layer.
If the original height of the layer of the text layer is less than 2 times of the default height corresponding to the word size of the word included in the text layer, that the text layer can only display one line of words is indicated, the electronic equipment can determine that the text layer only includes one line of words; if the original height of the layer of the text layer is not less than 2 times of the default height corresponding to the font size of the characters included in the text layer, which indicates that a plurality of lines of characters can be displayed in the text layer, the electronic device may determine that the text layer includes a plurality of lines of characters.
In an embodiment, the electronic device may calculate a difference value between an original layer height of a text layer and 2 times of a default height corresponding to a font size of a word included in the text layer, and then determine whether the text layer includes only one row of words according to a size relationship between the difference value and a preset threshold. When a difference value between an original layer height of a text layer and 2 times of a default height corresponding to a word size of a word included in the text layer is smaller than a preset threshold value, determining that the text layer only includes one line of words; when a difference value between an original layer height of a text layer and 2 times of a default height corresponding to a font size of a character included in the text layer is not less than a preset threshold value, it can be determined that the text layer includes a plurality of lines of characters. The preset threshold is a positive real number, and may be set according to a difference between a line height of a text included in the text layer and a default height corresponding to a font size.
Therefore, in the scheme provided by the embodiment of the invention, the electronic device can judge whether the original height of the text layer is less than 2 times of the default height corresponding to the font size of the characters included in the text layer; if yes, determining that the text layer only comprises one line of words; if not, determining that the text layer comprises a plurality of lines of words. Therefore, the electronic equipment can accurately determine whether the text layer only comprises one line of characters according to the layer original height of the text layer and the default height corresponding to the character size of the characters contained in the text layer.
As an implementation manner of the embodiment of the present invention, as shown in fig. 3, before the step of clipping the text layer based on the position and the layer height of the text layer for each text layer, the method may further include:
s301, aiming at each text layer, determining whether the text layer comprises non-character content;
besides the text content, the text layer of the application program interface to be checked may also include non-text content such as background color and border. In order to ensure the display effect of the application program interface, when the text layer is cut, the non-text content in the text layer cannot be damaged, so for each text layer, before the text layer is cut, the electronic device may determine whether the text layer includes the non-text content.
If the text layer does not include non-textual content, the electronic device may clip the text layer based on the position and layer height of the text layer; if the text layer includes non-text content, the electronic device may perform step S302.
S302, if the text layer comprises non-character content, a new layer is created, and the non-character content is copied to the new layer;
when the text layer includes non-word content, in order to avoid destroying the non-word content in the text layer, the electronic device may create a new layer and then copy the non-word content in the text layer to the new layer. And the position and the height of the new layer are respectively the same as the position and the original height of the text layer. That is, only the words included in the text layer are missing in the new layer as compared to the text layer.
S303, deleting the non-character content in the text layer, and executing the step of cutting the text layer based on the position and the layer height of the text layer aiming at each text layer.
After copying the non-textual content in the text layer to a new layer, the electronic device may delete the non-textual content in the text layer and then tailor the text layer based on the position and layer height of the text layer. Therefore, the text layer does not include non-character content any more, so that the non-character content is not cut when the text layer is cut, and the non-character content is not damaged.
As can be seen, in the scheme provided in the embodiment of the present invention, before clipping the text layer based on the position and layer height of the text layer for each text layer, the electronic device may determine, for each text layer, whether the text layer includes non-text content; if the text layer comprises non-character content, creating a new layer, copying the non-character content to the new layer, further deleting the non-character content in the text layer, and executing the step of cutting the text layer based on the position and the layer height of the text layer aiming at each text layer. Therefore, when the text layer comprises the non-character content, the electronic equipment can back up the non-character content to the new layer, damage to the non-character content in the text layer is avoided, and the display effect of an application program interface is guaranteed.
As an implementation manner of the embodiment of the present invention, as shown in fig. 4, before the step of obtaining the application program interface to be checked, the method may further include:
s401, obtaining the marking information of the interface of the application program to be developed;
before the application program interface is developed, the annotation information of the application program interface to be developed can be obtained firstly. The annotation information includes data such as design layer height of each text layer included in the application program interface to be developed, word size and line height of included words, the annotation information may be information obtained by analyzing a design draft corresponding to the application program interface to be developed in advance for the electronic device, and the design layer height is the layer height of the text layer set when the design draft corresponding to the application program interface to be developed is designed.
S402, determining a target line height from a preset line height table according to a target operating system corresponding to the application program interface to be developed and the word size of the text layer included in the marking information for each text layer;
because the line heights of the characters included in the text layers in the application program interface to be developed may not be matched with the default line heights of different operating systems, after the label information of the application program interface to be developed is obtained, for each text layer, the electronic device may determine, according to the word size of the text layer included in the label information and the target operating system corresponding to the application program interface to be developed, a target line height from a preset line height table as the line height of the characters included in the text layer in the application program interface to be developed. The default line height of the operating system is the line height of characters included in a text layer in an application program interface applied to the operating system.
The preset line height table comprises the corresponding relation of operating system identification, word size and line height, and the target operating system is the operating system to be applied to the application program interface to be developed. For example, the table of the preset line heights is shown in the following table:
Figure BDA0002613043870000161
and A is an operating system identifier corresponding to the android system, and I is an operating system identifier corresponding to the IOS system. Then, the target operating system is an android system, and if the font size of the text layer included in the labeling information is No. 3, the electronic device may determine that the target line height is 16 according to the correspondence relationship between the operating system identifier, the font size, and the line height shown in the table above.
In an embodiment, the electronic device may display a target operating system selection interface, where the target operating system selection interface may include a plurality of buttons, each button corresponds to one operating system, and a user may select a target operating system by clicking a button, so that the electronic device may determine an identifier of the target operating system.
S403, determining whether the text layer only comprises one line of characters, and if the text layer only comprises one line of characters, executing the step S404; if the text layer includes a plurality of lines of text, step S405 is performed.
The text layer may include more than one line of text, and thus, to determine the height of the text layer, the electronic device may determine whether the text layer includes only one line of text after determining the target line height. The specific manner of determining whether the text layer only includes one line of text by the electronic device is the same as the determination manner in step S103, and is not described herein again.
When determining that the text layer only includes one line of text, the electronic device may perform step S404; when it is determined that the text layer includes a plurality of lines of text, the electronic device may perform step S405.
S404, determining the layer height of the text layer as the target line height;
when it is determined that the text layer includes only one line of text, the electronic device may determine that the layer height of the text layer is a target line height.
S405, calculating a difference value between the line height of the characters included in the text layer and the target line height to serve as a second difference value, and determining the layer height of the text layer as the difference value between the design layer height of the text layer and the second difference value;
when it is determined that the text layer includes a plurality of lines of characters, the electronic device may calculate a difference between a line height of the characters included in the text layer and a target line height as a second difference. Wherein, the second difference value can be a positive real number, 0 or a negative real number.
After determining the second difference value, the electronic device may calculate a difference between the design layer height of the text layer and the second difference value as the layer height of the text layer. For example, the design layer height of the text layer W1 is 20, and the second difference is-2, so that the layer height of the text layer W1 is 20- (-2) ═ 22; for another example, if the design layer height of the text layer W2 is 30 and the second difference is 4, the layer height of the text layer W2 is 30-4-26.
S406, according to the layer height of each text layer, adjusting the label information of the application program interface to be developed, and developing and obtaining the application program interface to be checked and accepted based on the adjusted label information.
After determining the layer height of each text layer, the electronic device may adjust the label information of the application program interface to be developed according to the layer height of each text layer. In this way, the layer height of each text layer included in the adjusted labeling information also meets the requirements of the target operating system.
After the adjusted annotation information is obtained, an application program interface to be developed can be developed based on each item of data included in the adjusted annotation information, so as to obtain the application program interface to be checked. Therefore, the height of the text layer in the developed application program interface to be checked can meet the requirement of the target operating system.
In one embodiment, the electronic device may display the adjusted annotation information for a developer to view, and the developer may view the adjusted annotation information and develop the application program interface to be checked according to the annotation information.
Therefore, in the scheme provided by the embodiment of the invention, the electronic equipment can obtain the application program interface to be checked through the mode. Therefore, the height of the text layer in the application program interface to be checked can meet the requirement of the operating system to be applied by the application program interface to be checked.
Corresponding to the method for clipping the text layer, the embodiment of the invention also provides a device for clipping the text layer. The following describes a clipping device for text layers according to an embodiment of the present invention.
As shown in fig. 5, a clipping apparatus for text layer, the apparatus includes:
an interface to be checked and accepted acquisition module 501, configured to acquire an application interface to be checked and accepted;
a height obtaining module 502, configured to obtain a position of each text layer in the application program interface to be checked, a word size, a line height, and a text height of a character included in each text layer;
and the text height is the height occupied by the text in the text layer.
A first determining module 503, configured to determine, for each text layer, whether the text layer only includes one line of words;
a first layer height determining module 504, configured to determine, if the text layer only includes one line of words, a default height corresponding to a word size of the words included in the text layer as a layer height of the text layer;
a second layer height determining module 505, configured to determine, if the text layer includes multiple lines of characters, a difference between a line height of a character included in the text layer and a default height corresponding to a font size of the character as a first difference, and determine, as a layer height of the text layer, a difference between a text height corresponding to the text layer and the first difference;
a cropping module 506, configured to crop each text layer based on the position and layer height of the text layer.
Therefore, in the scheme provided by the embodiment of the invention, the electronic equipment can acquire the application program interface to be checked; acquiring the position of each text layer in an application program interface to be checked and received, the word size, the line height and the text height of characters included in each text layer, wherein the text height is the height occupied by the text in the text layer; for each text layer, determining whether the text layer only comprises one line of words; if the text layer only comprises one line of characters, determining the default height corresponding to the character number of the characters contained in the text layer as the layer height of the text layer; if the text layer comprises a plurality of lines of characters, determining a difference value between the line height of the characters included in the text layer and a default height corresponding to the word size of the characters as a first difference value, and determining a difference value between the text height corresponding to the text layer and the first difference value as the layer height of the text layer; for each text layer, the text layer is clipped based on the position and layer height of the text layer.
Because the default fonts and the default heights of different operating systems are different, when the same application program interface to be checked is applied to different operating systems, the height difference between the blank area above the first row of characters and the height difference between the blank area below the last row of characters in the same text layer are larger. After the electronic device cuts each text layer in the application program interface to be checked and accepted by adopting the above mode, the blank area above the first line of characters and the blank area below the last line of characters in the text layer can be removed. When the application program interface to be checked is only checked once, the distance between the cut text layer and the adjacent layer can be measured, so that the difference between the corresponding distances when the same application program interface to be checked is applied to different operating systems can be reduced, and the accuracy of the application program interface to be checked can be improved.
As an implementation manner of the embodiment of the present invention, the first determining module 503 may include:
a first determining sub-module (not shown in fig. 5) configured to determine, for each text layer, whether the text layer includes only one row of words based on line heights and text heights of words included in the text layer; or the like, or, alternatively,
a second determining sub-module (not shown in fig. 5) configured to, for each text layer, obtain an original layer height of each text layer in the application program interface to be checked, and determine whether the text layer only includes one line of characters based on the original layer height of the text layer and a default height corresponding to a font size of the included character.
As an implementation manner of the embodiment of the present invention, the second determining submodule may include:
a determining unit (not shown in fig. 5) configured to determine whether an original layer height of the text layer is less than 2 times of a default height corresponding to a font size of a character included in the text layer;
a first determining unit (not shown in fig. 5) configured to determine that the text layer only includes one line of text if yes;
a second determining unit (not shown in fig. 5) for, if not, determining that the text layer comprises a plurality of lines of text.
As an implementation manner of the embodiment of the present invention, the apparatus may further include:
a determining module (not shown in FIG. 5) for determining, for each text layer, whether the text layer includes non-textual content prior to cropping the text layer based on the position and layer height of the text layer for each text layer;
an image layer creating module (not shown in fig. 5) configured to create a new image layer if the text image layer includes non-text content, and copy the non-text content to the new image layer;
and the position and the height of the new layer are respectively the same as the position and the original height of the text layer.
A non-text deleting module (not shown in fig. 5) configured to delete the non-text content in the text layer and trigger the cropping module 506.
As an implementation manner of the embodiment of the present invention, the apparatus may further include:
a to-be-developed interface obtaining module (not shown in fig. 5) configured to obtain the label information of the to-be-developed application program interface before obtaining the to-be-checked application program interface;
the marking information comprises the height of a design layer of each text layer included in the application program interface to be developed, and the word size and the line height of characters included in the text layer.
A target line height determining module (not shown in fig. 5) configured to determine, for each text layer, a target line height from a preset line height table based on a target operating system corresponding to the application program interface to be developed and the word size of the text layer included in the label information;
the preset line height table comprises the corresponding relation of operating system identification, word size and line height.
A second determining module (not shown in fig. 5) for determining whether the text layer includes only one line of words;
a third layer height determining module (not shown in fig. 5) configured to determine, if the text layer only includes one line of text, that the layer height of the text layer is the target line height;
a fourth layer height determining module (not shown in fig. 5), configured to, if the text layer includes multiple lines of words, calculate a difference between a line height of the words included in the text layer and the target line height, as a second difference, and determine that the layer height of the text layer is a difference between a design layer height of the text layer and the second difference;
and a label information adjusting module (not shown in fig. 5) configured to adjust label information of the application program interface to be developed according to the layer height of each text layer, and develop the application program interface to be checked and received based on the adjusted label information.
An embodiment of the present invention further provides an electronic device, as shown in fig. 6, including a processor 601, a communication interface 602, a memory 603, and a communication bus 604, where the processor 601, the communication interface 602, and the memory 603 complete mutual communication through the communication bus 604,
a memory 603 for storing a computer program;
the processor 601 is configured to implement the steps of the method for clipping text layer according to any of the embodiments described above when executing the program stored in the memory 603.
Therefore, in the scheme provided by the embodiment of the invention, the electronic equipment can acquire the application program interface to be checked; acquiring the position of each text layer in an application program interface to be checked and received, the word size, the line height and the text height of characters included in each text layer, wherein the text height is the height occupied by the text in the text layer; for each text layer, determining whether the text layer only comprises one line of words; if the text layer only comprises one line of characters, determining the default height corresponding to the character number of the characters contained in the text layer as the layer height of the text layer; if the text layer comprises a plurality of lines of characters, determining a difference value between the line height of the characters included in the text layer and a default height corresponding to the word size of the characters as a first difference value, and determining a difference value between the text height corresponding to the text layer and the first difference value as the layer height of the text layer; for each text layer, the text layer is clipped based on the position and layer height of the text layer.
Because the default fonts and the default heights of different operating systems are different, when the same application program interface to be checked is applied to different operating systems, the height difference between the blank area above the first row of characters and the height difference between the blank area below the last row of characters in the same text layer are larger. After the electronic device cuts each text layer in the application program interface to be checked and accepted by adopting the above mode, the blank area above the first line of characters and the blank area below the last line of characters in the text layer can be removed. When the application program interface to be checked is only checked once, the distance between the cut text layer and the adjacent layer can be measured, so that the difference between the corresponding distances when the same application program interface to be checked is applied to different operating systems can be reduced, and the accuracy of the application program interface to be checked can be improved.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
In another embodiment of the present invention, a computer-readable storage medium is further provided, where a computer program is stored in the computer-readable storage medium, and when executed by a processor, the computer program implements the method for clipping text layer according to any of the above embodiments.
As can be seen, in the solution provided in the embodiment of the present invention, when the computer program stored in the computer-readable storage medium is executed by the processor, the application program interface to be checked and received can be obtained; acquiring the position of each text layer in an application program interface to be checked and received, the word size, the line height and the text height of characters included in each text layer, wherein the text height is the height occupied by the text in the text layer; for each text layer, determining whether the text layer only comprises one line of words; if the text layer only comprises one line of characters, determining the default height corresponding to the character number of the characters contained in the text layer as the layer height of the text layer; if the text layer comprises a plurality of lines of characters, determining a difference value between the line height of the characters included in the text layer and a default height corresponding to the word size of the characters as a first difference value, and determining a difference value between the text height corresponding to the text layer and the first difference value as the layer height of the text layer; for each text layer, the text layer is clipped based on the position and layer height of the text layer.
Because the default fonts and the default heights of different operating systems are different, when the same application program interface to be checked is applied to different operating systems, the height difference between the blank area above the first row of characters and the height difference between the blank area below the last row of characters in the same text layer are larger. After the electronic device cuts each text layer in the application program interface to be checked and accepted by adopting the above mode, the blank area above the first line of characters and the blank area below the last line of characters in the text layer can be removed. When the application program interface to be checked is only checked once, the distance between the cut text layer and the adjacent layer can be measured, so that the difference between the corresponding distances when the same application program interface to be checked is applied to different operating systems can be reduced, and the accuracy of the application program interface to be checked can be improved.
In another embodiment of the present invention, a computer program product containing instructions is further provided, which when run on a computer causes the computer to execute the method for clipping text layer according to any one of the above embodiments.
Therefore, in the scheme provided by the embodiment of the invention, when the computer program product runs on a computer, the application program interface to be checked can be obtained; acquiring the position of each text layer in an application program interface to be checked and received, the word size, the line height and the text height of characters included in each text layer, wherein the text height is the height occupied by the text in the text layer; for each text layer, determining whether the text layer only comprises one line of words; if the text layer only comprises one line of characters, determining the default height corresponding to the character number of the characters contained in the text layer as the layer height of the text layer; if the text layer comprises a plurality of lines of characters, determining a difference value between the line height of the characters included in the text layer and a default height corresponding to the word size of the characters as a first difference value, and determining a difference value between the text height corresponding to the text layer and the first difference value as the layer height of the text layer; for each text layer, the text layer is clipped based on the position and layer height of the text layer.
Because the default fonts and the default heights of different operating systems are different, when the same application program interface to be checked is applied to different operating systems, the height difference between the blank area above the first row of characters and the height difference between the blank area below the last row of characters in the same text layer are larger. After the electronic device cuts each text layer in the application program interface to be checked and accepted by adopting the above mode, the blank area above the first line of characters and the blank area below the last line of characters in the text layer can be removed. When the application program interface to be checked is only checked once, the distance between the cut text layer and the adjacent layer can be measured, so that the difference between the corresponding distances when the same application program interface to be checked is applied to different operating systems can be reduced, and the accuracy of the application program interface to be checked can be improved.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may 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 loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (11)

1. A method for clipping text layer, the method comprising:
acquiring an application program interface to be checked;
acquiring the position of each text layer in the application program interface to be checked and received, the word size, the line height and the text height of characters included in each text layer, wherein the text height is the height occupied by the text in the text layer;
for each text layer, determining whether the text layer only comprises one line of words;
if the text layer only comprises one line of characters, determining the default height corresponding to the character number of the characters contained in the text layer as the layer height of the text layer;
if the text layer comprises a plurality of lines of characters, determining a difference value between the line height of the characters included in the text layer and a default height corresponding to the word size of the characters as a first difference value, and determining a difference value between the text height corresponding to the text layer and the first difference value as the layer height of the text layer;
for each text layer, the text layer is clipped based on the position and layer height of the text layer.
2. The method of claim 1, wherein the step of determining, for each text layer, whether the text layer includes only one line of text comprises:
for each text layer, determining whether the text layer only comprises one line of characters or not based on the line height and the text height of the characters included in the text layer; or the like, or, alternatively,
and acquiring the layer original height of each text layer in the application program interface to be checked and received aiming at each text layer, and determining whether the text layer only comprises one line of characters or not based on the layer original height of the text layer and the default height corresponding to the word size of the included characters.
3. The method according to claim 2, wherein the step of determining whether the text layer includes only one row of words based on the layer original height of the text layer and the default height corresponding to the font size of the included words comprises:
judging whether the layer original height of the text layer is less than 2 times of the default height corresponding to the word size of the characters included in the text layer;
if yes, determining that the text layer only comprises one line of words;
if not, determining that the text layer comprises a plurality of lines of words.
4. A method according to any of claims 1-3, wherein prior to the step of cropping the text layer based on its position and layer height for each text layer, the method further comprises:
for each text layer, determining whether the text layer comprises non-word content;
if the text layer comprises non-character content, creating a new layer, and copying the non-character content to the new layer, wherein the position and the height of the new layer are respectively the same as the position and the original height of the text layer;
deleting the non-character content in the text layer, and executing the step of cutting the text layer according to the position and the layer height of the text layer aiming at each text layer.
5. The method of claim 1, wherein prior to the step of obtaining an application interface to be verified, the method further comprises:
acquiring marking information of an application program interface to be developed, wherein the marking information comprises the design layer height of each text layer included in the application program interface to be developed, and the word size and line height of characters included in the text layer;
for each text layer, determining a target line height from a preset line height table based on a target operating system corresponding to the application program interface to be developed and the word size of the text layer included in the marking information, wherein the preset line height table includes corresponding relations of operating system identification, word size and line height;
determining whether the text layer includes only one line of text;
if the text layer only comprises one line of characters, determining the layer height of the text layer as the target line height;
if the text layer comprises a plurality of lines of characters, calculating a difference value between the line height of the characters included in the text layer and the target line height to serve as a second difference value, and determining the layer height of the text layer as the difference value between the design layer height of the text layer and the second difference value;
and adjusting the labeling information of the application program interface to be developed according to the layer height of each text layer, and developing and obtaining the application program interface to be checked and accepted based on the adjusted labeling information.
6. A clipping device for text layer, said device comprising:
the interface acquisition module to be checked and accepted is used for acquiring an application program interface to be checked and accepted;
the height acquisition module is used for acquiring the position of each text layer in the application program interface to be checked and received, the word size, the line height and the text height of characters included in each text layer, wherein the text height is the height occupied by the text in the text layer;
the first judgment module is used for determining whether each text layer only comprises one line of characters;
the first layer height determining module is used for determining a default height corresponding to the word number of the word included in the text layer as the layer height of the text layer if the text layer only includes one line of words;
the second layer height determining module is used for determining a difference value between the line height of the characters included in the text layer and the default height corresponding to the word size of the characters as a first difference value if the text layer includes a plurality of lines of characters, and determining a difference value between the text height corresponding to the text layer and the first difference value as the layer height of the text layer;
and the clipping module is used for clipping the text layer based on the position and the layer height of the text layer aiming at each text layer.
7. The apparatus of claim 6, wherein the first determining module comprises:
the first judgment sub-module is used for determining whether each text layer only comprises one line of characters or not based on the line height and the text height of the characters contained in the text layer; or the like, or, alternatively,
and the second judgment submodule is used for acquiring the layer original height of each text layer in the application program interface to be checked and received aiming at each text layer, and determining whether the text layer only comprises one line of characters or not based on the layer original height of the text layer and the default height corresponding to the word size of the included characters.
8. The apparatus of claim 7, wherein the second determination submodule comprises:
the judging unit is used for judging whether the layer original height of the text layer is less than 2 times of the default height corresponding to the word size of the characters included in the text layer;
the first determining unit is used for determining that the text layer only comprises one line of characters if the text layer only comprises one line of characters;
and the second determining unit is used for determining that the text layer comprises a plurality of lines of characters if the text layer does not comprise the characters.
9. The apparatus according to any one of claims 6-8, further comprising:
a determining module for determining, for each text layer, whether the text layer includes non-textual content before the text layer is clipped based on a position and a layer height of the text layer for each text layer;
the image layer creating module is used for creating a new image layer and copying the non-character content to the new image layer if the text image layer comprises the non-character content, wherein the position and the height of the new image layer are respectively the same as those of the text image layer and the original height of the image layer;
and the non-character content deleting module is used for deleting the non-character content in the text layer and triggering the cutting module.
10. The apparatus of claim 6, further comprising:
the system comprises a to-be-developed interface acquisition module, a to-be-developed application program interface acquisition module and a to-be-verified application program interface acquisition module, wherein the to-be-developed interface acquisition module is used for acquiring the label information of the to-be-developed application program interface before acquiring the to-be-verified application program interface, and the label information comprises the design layer height of each text layer included in the to-be-developed application program interface, and the word size and the line height of;
the target line height determining module is used for determining a target line height from a preset line height table aiming at each text layer based on a target operating system corresponding to the application program interface to be developed and the word size of the text layer included by the marking information, wherein the preset line height table comprises the corresponding relation of an operating system identification, the word size and the line height;
the second judgment module is used for determining whether the text layer only comprises one line of characters;
a third layer height determining module, configured to determine, if the text layer only includes one line of characters, that the layer height of the text layer is the target line height;
a fourth layer height determining module, configured to calculate, if the text layer includes multiple lines of characters, a difference between a line height of the characters included in the text layer and the target line height, as a second difference, and determine that the layer height of the text layer is a difference between a design layer height of the text layer and the second difference;
and the marking information adjusting module is used for adjusting the marking information of the application program interface to be developed according to the layer height of each text layer, and developing and obtaining the application program interface to be checked and received based on the adjusted marking information.
11. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any one of claims 1 to 5 when executing a program stored in the memory.
CN202010760906.9A 2020-07-31 2020-07-31 Text layer cutting method and device and electronic equipment Active CN111881050B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010760906.9A CN111881050B (en) 2020-07-31 2020-07-31 Text layer cutting method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010760906.9A CN111881050B (en) 2020-07-31 2020-07-31 Text layer cutting method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN111881050A true CN111881050A (en) 2020-11-03
CN111881050B CN111881050B (en) 2024-06-04

Family

ID=73204961

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010760906.9A Active CN111881050B (en) 2020-07-31 2020-07-31 Text layer cutting method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN111881050B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113778905A (en) * 2021-11-10 2021-12-10 腾讯科技(深圳)有限公司 UI design acceptance method, device, equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109492143A (en) * 2018-09-21 2019-03-19 平安科技(深圳)有限公司 Image processing method, device, computer equipment and storage medium
CN109657205A (en) * 2018-10-09 2019-04-19 阿里巴巴集团控股有限公司 The high method of adjustment of line of text and device, electronic equipment
CN109697414A (en) * 2018-12-13 2019-04-30 北京金山数字娱乐科技有限公司 A kind of text positioning method and device
WO2020097909A1 (en) * 2018-11-16 2020-05-22 北京比特大陆科技有限公司 Text detection method and apparatus, and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109492143A (en) * 2018-09-21 2019-03-19 平安科技(深圳)有限公司 Image processing method, device, computer equipment and storage medium
CN109657205A (en) * 2018-10-09 2019-04-19 阿里巴巴集团控股有限公司 The high method of adjustment of line of text and device, electronic equipment
WO2020097909A1 (en) * 2018-11-16 2020-05-22 北京比特大陆科技有限公司 Text detection method and apparatus, and storage medium
CN109697414A (en) * 2018-12-13 2019-04-30 北京金山数字娱乐科技有限公司 A kind of text positioning method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113778905A (en) * 2021-11-10 2021-12-10 腾讯科技(深圳)有限公司 UI design acceptance method, device, equipment and storage medium
CN113778905B (en) * 2021-11-10 2022-02-08 腾讯科技(深圳)有限公司 UI design acceptance method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN111881050B (en) 2024-06-04

Similar Documents

Publication Publication Date Title
US10346560B2 (en) Electronic blueprint system and method
US20190278837A1 (en) Detecting the bounds of borderless tables in fixed-format structured documents using machine learning
CN113190781B (en) Page layout method, device, equipment and storage medium
TW201617971A (en) Method and apparatus for information recognition
US11080464B2 (en) Correction techniques of overlapping digital glyphs
CN112083973A (en) Window closing method and device, electronic equipment and storage medium
CN114417226A (en) Page generation method, display method, device, electronic equipment and storage medium
CN115357155A (en) Window identification method, device, equipment and computer readable storage medium
CN109299718B (en) Character recognition method and device
CN111881050B (en) Text layer cutting method and device and electronic equipment
CN111970570B (en) Method and device for prompting video content interaction position
CN110378566B (en) Information checking method, device, storage medium and apparatus
CN112306336A (en) Document content display method and device
CN110688995A (en) Map query processing method, computer-readable storage medium and mobile terminal
CN114237468B (en) Text and picture translation method and device, electronic equipment and readable storage medium
CN110908570B (en) Image processing method, device, terminal and storage medium
US10511726B1 (en) Custom recommendations application for creating photo book cover
CN111880776A (en) Hierarchical relationship obtaining method and device and electronic equipment
CN110795922B (en) Form information display method and device for PDF document and electronic equipment
CN111815499A (en) Watermark deleting method and device
CN110019492B (en) Information display method and device
CN112784526A (en) Document page adjusting method and device
CN112799564A (en) Method, device, electronic equipment and medium for inserting control in table
CN115035527B (en) Method, device and equipment for identifying electronic signature position
CN110543624B (en) Method and device for identifying check boxes in PDF document and electronic equipment

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
GR01 Patent grant
GR01 Patent grant