CN100504850C - Method and device drafting character string at targeted area - Google Patents

Method and device drafting character string at targeted area Download PDF

Info

Publication number
CN100504850C
CN100504850C CNB2007101638965A CN200710163896A CN100504850C CN 100504850 C CN100504850 C CN 100504850C CN B2007101638965 A CNB2007101638965 A CN B2007101638965A CN 200710163896 A CN200710163896 A CN 200710163896A CN 100504850 C CN100504850 C CN 100504850C
Authority
CN
China
Prior art keywords
size
reference type
character
target area
character string
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.)
Active
Application number
CNB2007101638965A
Other languages
Chinese (zh)
Other versions
CN101127035A (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.)
Kingdee Software China Co Ltd
Original Assignee
Kingdee Software China 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 Kingdee Software China Co Ltd filed Critical Kingdee Software China Co Ltd
Priority to CNB2007101638965A priority Critical patent/CN100504850C/en
Publication of CN101127035A publication Critical patent/CN101127035A/en
Application granted granted Critical
Publication of CN100504850C publication Critical patent/CN100504850C/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Controls And Circuits For Display Device (AREA)

Abstract

The utility model discloses a method of rendering character strings within object regions. The method is as follows: a font size variation range is preset; character strings are rendered according to reference font sizes within the object regions; whether the rendered character strings exceed the size of the object regions is judged; if yes, the reference font sizes replace the upper limit of the variable font sizes when the reference font sizes are smaller than the upper limit of the variable font sizes, and the reference font sizes are reduced according to a first preset rule; if no, the reference font sizes replace the lower limit of the variable font sizes when the reference font sizes are bigger than the lower limit of the variable font sizes, and the reference font sizes are enlarged according to a second preset rule; whether the reduced or enlarged reference font sizes are within the variation range of the font sizes is judged; if yes, the character strings are re-rendered within the object regions. The utility model can simultaneously realize line wrap and font reduction filling within object regions, while ensuring the efficiency of rendering character strings.

Description

The method of drafting character string and device in the target area
Technical field
The present invention relates to literal and draw process field, particularly a kind of in the target area method and the device of drafting character string.
Background technology
In existing webpage or application program, owing to interface drafting, copy editor, printout etc. need, require system to have in the target area, for example, in the cell, export the function of the character string of uncertain length.When the length of described character string surpasses the length of this target area,, " line feed automatically " and " filling decreases font size " two kinds of solutions are provided in the prior art except by the length of user's manual adjustment font size with the character down string.
" line feed automatically " is meant when the string length in the target area surpasses this regional width, the character string of this peak width will be surpassed in the zone, change to next line and show that usually in this case, system can change the height of this target area automatically to hold described character string; " filling decreases font size " is meant when the width of content displayed in the target area surpasses this regional width, automatically decrease font size, under the situation that does not change this peak width, content all is presented in this zone, and the character boundary in this zone can be adjusted automatically according to this regional width.
Because the output of line feed is not change font size automatically, converting character string to multirow shows, and the output of filling that decreases font size is to change font size, character string is shown in delegation, thereby in the prior art, these two kinds of solutions can not be carried out simultaneously, that is to say, the user can only select the function of " line feed automatically " or " filling decreases font size " in the prior art in one the mode of selecting.For example, in existing EXCEL, these two kinds of functions can not be used simultaneously.
Yet, if the content of drafting character string is more in the target area, often both needed the processing that enters a new line of the character string in the target area, need again the processing that decreases font size of these characters, in this case, because prior art can not realize the function of " line feed automatically " and " filling decreases font size " simultaneously, thereby its processing can only be by user's processing that earlier character in the target area decreased font size, carry out line feed operation automatically then or force the line feed operation to realize, obviously, such operation is too complicated, thereby causes user experience relatively poor.And, under the content of target string can not predetermined situation, the mode of this artificial setting even can't realize.
So those skilled in the art press for develops a kind of can the assurance under the prerequisite of efficiency of rendering character strings, realizing simultaneously in the target area enters a new line automatically and decrease font size fills rendering character strings method and the device of handling.
Summary of the invention
Technical matters to be solved by this invention provide a kind of in the target area method of drafting character string, can not in the target area, realize simultaneously entering a new line automatically and decrease font size to fill in the prior art handling in order to solve, and can't guarantee the efficiency of rendering character strings problem.
The present invention also provide a kind of in the target area device of drafting character string, in order to guarantee realization and application in practice.
For solving the problems of the technologies described above, the embodiment of the invention discloses a kind of in the target area method of drafting character string, comprising:
Default font size mobility scale, described font size mobility scale are variable font size lower limit and variable font size upper limit institute restricted portion;
In the target area according to the reference type size drafting character string;
Judge whether the character string of being drawn surpasses the size of described target area;
If, then described reference type size less than described variable font size in limited time, described reference type size is replaced the described variable font size upper limit; And, dwindle described reference type size according to first presetting rule;
If not, then described reference type size greater than described variable font size under in limited time, described reference type size is replaced described variable font size lower limit; And, amplify described reference type size according to second presetting rule;
Judge that the described reference type size that dwindles or amplify is whether in described font size mobility scale, if then repaint described character string according to the described reference type size that dwindles or amplify in described target area; If not, then preserve rendering character strings result in the described target area.
Preferably, the described step of judging that whether character string surpasses the size of described target area further comprises:
When the character of being drawn is the line feed identifier, perhaps, when the displacement of institute's draw characters surpasses the width of described target area, then be moved to capable high this character of drawing of the next one of described target area;
Judge that whether the height of institute's drafting character string surpasses the height of described target area, if, then be the size that the character string of being drawn surpasses described target area, if not, then be the size that the character string of being drawn surpasses described target area.
Preferably, described method before the rendering character strings step, also comprises:
Adjust described reference type size.
Preferably, adjust described reference type size by following substep:
Judge whether described reference type size is less than or equal to 0, if, then described reference type size is put 0, if not, the overall width and the row that then obtain character string are high;
According to the overall width of described character string and the mean breadth of actual characters number calculating character;
Mean breadth and the high average unit area of calculating described character of row according to described character;
Calculate the total area of target area, the average unit area of the described total area and described character is compared, obtain the held character number of described target area;
Judge that whether the described character number that holds is more than or equal to described actual characters number, if then keep described reference type size; If not, then hold character number and actual characters number generation adjustment coefficient according to described, and according to the described reference type size of described adjustment coefficient adjustment.
Preferably, described step of dwindling reference type size comprises:
According to the actual characters number of described character string and the draw characters number calculate coefficient of reduction;
Described reference type size is dwindled according to described coefficient of reduction.
Preferably, the step of described amplification reference type size comprises:
According to the height of described target area and the high computational amplification coefficient of institute's drafting character string;
Described reference type size is amplified according to described amplification coefficient.
The embodiment of the invention also discloses a kind of in the target area device of drafting character string, comprising:
Default unit is used for default font size mobility scale, and described font size mobility scale is variable font size lower limit and variable font size upper limit institute restricted portion;
Drawing unit is used in the target area according to the reference type size drafting character string;
First judging unit is used to judge whether the character string of being drawn surpasses the size of described target area, if then trigger first adjustment unit; If not, then trigger second adjustment unit;
First adjustment unit, be used for described reference type size less than described variable font size in limited time, described reference type size is replaced the described variable font size upper limit; And, dwindle described reference type size according to first presetting rule;
Second adjustment unit, be used for described reference type size greater than described variable font size under in limited time, described reference type size is replaced described variable font size lower limit; And, amplify described reference type size according to second presetting rule;
Second judging unit is used to judge that the described reference type size that dwindles or amplify is whether in described font size mobility scale, if then trigger described drawing unit and repaint described character string according to the described reference type size that dwindles or amplify in described target area; If not, then trigger the preservation unit;
Preserve the unit, be used to preserve the rendering character strings result in the described target area.
Preferably, described first judging unit further comprises:
The line feed subelement is used for being the line feed identifier at the character of being drawn, and perhaps, when the displacement of institute's draw characters surpasses the width of described target area, is moved to capable high this character of drawing of the next one of described target area;
The height judgment sub-unit, be used to judge whether the height of institute's drafting character string surpasses the height of described target area, if then be the size that the character string of being drawn surpasses described target area, if not, then be the size that the character string of being drawn surpasses described target area.
Preferably, described device also comprises:
Adjustment unit is used to adjust described reference type size.
Preferably, described adjustment unit comprises:
The initial decision subelement is used to judge whether described reference type size is less than or equal to 0, if then trigger the zero setting subelement; If not, then subelement is obtained in triggering;
The zero setting subelement is used for described reference type size is put 0;
Obtain subelement, be used to obtain the overall width and the row height of character string;
The mean breadth computation subunit is used for according to the overall width of described character string and the mean breadth of actual characters number calculating character;
The unit area computation subunit is used for mean breadth and the high average unit area of calculating described character of row according to described character;
Can hold the character computation subunit, be used to calculate the total area of target area, the average unit area of the described total area and described character is compared, obtain the held character number of described target area;
Subelement determined in font size, is used to judge that whether the described character number that holds is more than or equal to described actual characters number, if then keep described reference type size; If not, then hold character number and actual characters number generation adjustment coefficient according to described, and according to the described reference type size of described adjustment coefficient adjustment.
Compared with prior art, the embodiment of the invention has the following advantages:
At first, the present invention attempts drawing between the variable font size lower limit and the variable font size upper limit by font size, and brings in constant renewal in the described variable font size lower limit and the variable font size upper limit, thereby has effectively improved the drafting efficient that obtains the character string of target font size;
And the present invention has further effectively improved drafting efficient as long as judging current font size whether in this mobility scale, can determine the initiation and the end of drawing process, thereby reduce the unnecessary wasting of resources of drawing process;
Moreover the present invention makes reference type size more near the target font size by adjusting reference type size in advance in order to draw, and has reduced and has attempted the number of times of drafting, thereby further effectively improved drafting efficient;
In addition, the present invention has realized automatic line feed and has decreased font size filling the parallel processing of function by analyzing the position relation of character in the target area automatically;
At last, the technology of the present invention realizes simple, and no technology barrier does not have special secret algorithm, and cost and risk is lower.
Description of drawings
Fig. 1 be of the present invention a kind of in the target area process flow diagram of the method embodiment of drafting character string;
Fig. 2 is the process flow diagram of a kind of font size method of adjustment of the present invention;
Fig. 3 uses the process flow diagram that the preferred embodiments of the present invention are carried out the rendering character strings in the target area;
Fig. 4 is that in the example of the present invention draws synoptic diagram;
Fig. 5 is another drafting synoptic diagram in the example of the present invention;
Fig. 6 be of the present invention a kind of in the target area structured flowchart of the device embodiment of drafting character string.
Embodiment
For above-mentioned purpose of the present invention, feature and advantage can be become apparent more, the present invention is further detailed explanation below in conjunction with the drawings and specific embodiments.
One of core idea of the embodiment of the invention is, adopts a certain font size drafting character string earlier, if the character string of being drawn in the size of target area, is then thought this font size " suitably ", otherwise is " inappropriate ".In this case, the purpose that the present invention adjusts font size is, constantly attempts drawing, up to the maximum appropriate value that finds to be no more than initial font size.The process of attempting drawing makes font size attempt drawing between the variable font size lower limit and the variable font size upper limit exactly, and brings in constant renewal in the described variable font size lower limit and the variable font size upper limit, dwindles its scope.Make font size not in this scope between variable font size lower limit and the variable font size upper limit when once adjusting, to get final product the ends drawing process, to obtain suitable font size.
With reference to figure 1, show of the present invention a kind of in the target area process flow diagram of the method embodiment of drafting character string, specifically can may further comprise the steps:
Step 101, default font size mobility scale, described font size mobility scale are variable font size lower limit and variable font size upper limit institute restricted portion;
Step 102, in the target area according to the reference type size drafting character string;
Whether the character string that step 103, judgement are drawn surpasses the size of described target area; If then execution in step 104; If not, execution in step 105 then;
Step 104, described reference type size less than described variable font size in limited time, described reference type size is replaced the described variable font size upper limit; And, dwindle described reference type size according to first presetting rule;
Step 105, described reference type size greater than described variable font size under in limited time, described reference type size is replaced described variable font size lower limit; And, amplify described reference type size according to second presetting rule;
Step 106, judge that the described reference type size that dwindles or amplify is whether in described font size mobility scale, if then return step 102 and repaint described character string according to the described reference type size that dwindles or amplify in described target area; If not, execution in step 107 then;
Rendering character strings result in step 107, the described target area of preservation.
Font size described in the present invention is the attribute of a font descriptor in the various computer systems, also can be called font size, font generally includes font name (being called for short font usually, as the Song typeface, regular script etc.), font size, pattern information such as (runic, italics).The unit of font size is pt (pound), and 1pt equals 1/72 inch, and in the reality, to define such as a word, No. two words etc., this " * word " can convert to pt is the numerical value of unit to Chinese usually, and for example, No. five words are 10.5pt.In the present embodiment, font size, the font size of system default or the font size of other initial setting up etc. that described reference type size can preset for the user at first, in the process of repeatedly drawing, described reference type size can also be adjusted font size, for example, when dwindling font size for the second time, it is the primary font size that dwindles as the reference type size that dwindles foundation.
In the present embodiment, described target area can be the Drawing Object of creating in buffer memory, and the height and the width of this Drawing Object are fixed.When attempting drawing according to various font sizes, can create the drafting that such buffer memory Drawing Object is used for character string at every turn; When upgrading variable font size lower limit (being current optimal criteria font size), also can remain corresponding buffer memory Drawing Object, so that when output string, directly use the result of this buffer memory Drawing Object.
In described target area, in the drafting character string, promptly can be regarded as in the corresponding coordinate position of described Drawing Object draw characters, for example, a kind of in the target area process of drafting character string be:
Create the buffer memory Drawing Object of a specified altitude assignment and width, it is 0 that the X coordinate is set, and the Y coordinate is ascent, during drafting, gets i character in the character string successively, X displacement character duration; If the character of being drawn is the line feed identifier, perhaps, when the displacement of institute's draw characters surpasses the width of described Drawing Object, then X is put 0 again, it is high that Y is moved to next row; If Y+descent has surpassed the height of this Drawing Object, then the size of the expression character string of being drawn has surpassed the size of this Drawing Object, has promptly exceeded the magnitude range of target area.
Wherein, ascent and descent are the attributes that each character all has, and ascent is that character exceeds the distance on the baseline (baseline); Descent is that character exceeds the following distance of baseline.Baseline is meant that (x, when y) locating, the placement of this character can make its invocation point (specific location point that standard is provided with) also be placed on this position when program is placed on certain coordinate with character.Invocation point specifies a horizontal line promptly to be called the baseline of character, and character keeps horizontal alignment by baseline.Row is high: the height that a line character is shared.It is mensurable to be distance between the baseline of adjacent line of text.It is the summation of standard line space (leading), ascent, descent.For font of determining and font size, ascent, descent are the maximal values of determining, the row height also can be determined thereupon.
Thereby in the present embodiment, described determining step 102 may further include following substep:
If the character that substep A1 drew is the line feed identifier, then be moved to capable high this character of drawing of the next one of described target area;
Substep A2, judge that whether the height of institute's drafting character string surpasses the height of described target area, if, judge that then the character string of being drawn surpasses the size of described target area, if not, judge that then the character string of being drawn does not surpass the size of described target area.
Perhaps, can comprise following substep:
If the displacement of substep B1 institute draw characters surpasses the width of described target area, then be moved to capable high this character of drawing of the next one of described target area;
Substep B2, judge that whether the height of institute's drafting character string surpasses the height of described target area, if, judge that then the character string of being drawn surpasses the size of described target area, if not, judge that then the character string of being drawn does not surpass the size of described target area.
Certainly, those skilled in the art as required or the experience character string that adopts other determination methods to judge the to be drawn size that whether surpasses described target area all be feasible, the present invention does not need this to limit.
Be understandable that,, in the target area, all can occupy a fritter area for each character, thereby, one of another design in the embodiment of the invention is, generates the rule that font size is adjusted by the calculating to area, and described regulation rule comprises the rule of dwindling font size and amplifying font size.Particularly, for font size f, the width of each character fluctuates at D, and f and D are directly proportional (may have error owing to reason such as rounding) substantially, and there is similar relation in font size too with the row height.To this, can think that for font size f, each character can occupy D 2Area.
In this case, the length of supposing character string is n, and this is changeless.So, press
Figure C200710163896D0012095924QIETU
The shared total area drawn in font size is nD 2In the character drawing process, width always immobilizes, so can obtain nD 1 2/ h 1=nD 2 2/ h 2, i.e. f 1 2/ h 1=f 2 2/ h 2, font size square with highly be directly proportional.
Based on above-mentioned analysis, in the process of attempt drawing, when the size of target area enough put down in all character strings have the character of this font size the time, the rule of amplifying font size can be shown in following formula:
newSize=oldSize*sqrt(height/y)
Wherein, the target font size of newSize for amplifying; OldSize is current reference type size, and for example, if amplify font size for the first time, then reference type size may be the font size of user's initial setting up; If amplify font size for the second time, then reference type size is the font size after amplifying for the first time; Sqrt () is the function of extraction of square root; Height is the height of target area; Y is the displacement on the Y coordinate, is equivalent to the height that takies when drawing by oldSize.Height is greater than Y, so the font size that calculates is to become big.In addition, for ease of calculating, can also round up to result of calculation.
Correspondingly, in the process of attempt drawing, when the size of target area was not enough, Y approached to equal height, and, may be certain character (being assumed to be i) that is plotted to character string and the traversal circulation is forced to interrupt.In this case, can think then that i character occupied Y,, continue to draw that n character will occupy height H=y/i*n altogether according to this font size if highly do not limit, i.e. y/H=i/n, aspect ratio is similar to the character number ratio.Therefore, can obtain dwindling the rule of font size, shown in following formula:
newSize=oldSize*sqrt(i/n)
Wherein, the target font size of newSize for amplifying; OldSize is current reference type size, and for example, if amplify font size for the first time, then reference type size may be the font size of user's initial setting up; If amplify font size for the second time, then reference type size is the font size after amplifying for the first time; Sqrt () is the function of extraction of square root; I is the number of institute's draw characters; N is the actual characters number of described character string.Simultaneously, can also round downwards the result.
Thereby in the present embodiment, described step of dwindling reference type size can comprise following substep:
Substep C1, according to the actual characters number of described character string and the draw characters number calculate coefficient of reduction;
Substep C2, described reference type size is dwindled according to described coefficient of reduction.
The step of described amplification reference type size can comprise following substep:
Substep D1, according to the height of described target area and the high computational amplification coefficient of institute's drafting character string;
Substep D2, described reference type size is amplified according to described amplification coefficient.
Before drafting, according to the design that above-mentioned area calculates, can obtain one equally and connect and be bordering on the font size of target, attempt the number of times drawn to reduce.Thereby, before trial is drawn, can also comprise step:
Adjust described reference type size.
By carrying out described step, can do once estimation process fast to reference type size, thereby obtain an approaching relatively target font size, method for described adjustment, by any employing of those skilled in the art all is feasible, for example, the fixing coefficient of adjusting is set, each adjustment all reduces a font size; Perhaps, according to the size of target area and the length of character string the adjustment coefficient being set, all is feasible by this this reference type size of adjustment coefficient adjustment etc., and the present invention does not need this to limit.
Preferably, in the present embodiment, can adjust described reference type size by following substep:
Substep S101, judge whether described reference type size is less than or equal to 0, if then carry out substep S102; If not, then from substep S103 execution subsequent step;
Substep S102, described reference type size is put 0;
Substep S103, the overall width that obtains character string and row are high;
The capable height of the overall width of described character string and described reference type size may pass through JDK (JavaDevelopment Kit, the Java developing instrument) API (application programming interfaces, ApplicationProgramming Interface) obtains, can adopt other method of the prior art to obtain, the present invention does not limit this yet.
Substep S104, according to the overall width of described character string and the mean breadth of actual characters number calculating character;
Substep S105, according to the mean breadth of described character and the high average unit area of calculating described character of row;
Substep S106, calculate the total area of target area, the average unit area of the described total area and described character is compared, obtain the held character number of described target area;
Substep S107, judge that whether the described character number that holds is more than or equal to described actual characters number, if then carry out substep S108; If not, then carry out substep S109;
Substep S108, keep described reference type size;
Substep S109, generate and adjust coefficient according to described character number and the actual characters number held, and according to the described reference type size of described adjustment coefficient adjustment.
In the present embodiment, for realizing the purpose of Fast estimation, the adjustment process of described reference type size is for only turning uncomfortable big unidirectional adjustment process down, in addition, high consuming time of the width of the API calculating character string by adopting JDK and row is very little, can effectively economize on resources.Certainly, those skilled in the art as required or experience to adopt other method of adjusting font size all be feasible, the present invention does not need this to limit.
For making those skilled in the art understand the present invention better, below specify the process of described adjustment reference type size by way of example:
The size in hypothetical target zone is 80*60, and the number of character string is 10, and reference type size is 24; The first step is judged described reference type size greater than 0, and then to obtain the overall width of described character string be 240 to the API by JDK, and the row height is 27.375;
In second step, the mean breadth that calculates character is: 240/10=24;
In the 3rd step, the average unit area that calculates character is: 24*27.375=657;
In the 4th step, the total area that calculates the target area is 80*60:4800;
In the 5th step, the average unit area of the described total area and described character is compared: 4800/657 ≈ 7;
In the 6th step, the held character that obtains in the described target area is 7;
The 7th step, judge the described character number 7 that holds less than described actual characters number 10, then according to described character number and the actual characters number generation adjustment coefficient that holds be: sqrt (7/10) ≈ 0.84;
The 8th step, according to the described reference type size of described adjustment coefficient 0.84 adjustment be: 24*0.84 ≈ 20.
Very little when the target area, so that can't hold an average word when wide, or when failing to lay down delegation, can also in above-mentioned adjustment process, increase scaled step, with reference to figure 2, show the process flow diagram of another kind of font size method of adjustment of the present invention, specifically can may further comprise the steps:
Whether step 201, judgment standard font size size are less than or equal to 0, if, then size is changed to 0, if not, then carry out next step;
Step 202, the average character duration avgW of calculating;
The overall width of described average character duration avgW=character string/actual characters number;
Step 203, judge that described average character duration avgW is whether greater than the width width of target area, if, then adjust described reference type size size, the formula of adjusting calculating is: size=size*width/avgW, return step 201 then, estimate described adjusted reference type size again; If not, then carry out next step;
Step 204, judge character string the high lineH of row whether greater than the height height of target area, if, then adjust described reference type size, the formula of adjusting calculating is: size=size*height/lineH, return step 201 then, estimate described adjusted reference type size again; If not, then carry out next step;
Step 205, be provided with the row high coefficient lineCount=height/lineH;
Step 206, calculating can be held character number accept=width/avgW*lineCount;
Step 207, judge and can hold character number accept whether less than the actual characters number n of character string, if, then carry out next step, if not, then current reference type size size is as adjusted reference type size size;
Step 208, adjust described reference type size, return step 201 then and estimate described adjusted font size again according to adjusting formula: size=size*sqrt (accept/n).
For further specifying the present invention, with reference to figure 3, show and use the process flow diagram that the preferred embodiments of the present invention are carried out the rendering character strings in the target area, specifically can may further comprise the steps:
Step 301, adjustment reference type size;
Step 302, put font size mobility scale initial value: toTry=true; Variable font size lower limit=-1; The variable font size upper limit=MAX;
Step 303, judge whether attempt to draw, if then carry out next step; If not, then draw the buffer memory Drawing Object of the optimal criteria font size that obtains;
High wide buffer memory Drawing Object is specified in step 304, one of establishment, and the x coordinate puts 0, and the y coordinate is Ascent; At this moment, toTry=false; BreakLoop=false;
Step 305, judge that whether rendering character strings finishes, if then carry out next step; If not, execution in step 314 then;
Step 306, get i character, x displacement character duration successively;
Step 307, judge whether to run into newline or x exceeds peak width, if then carry out next step; If not, then in (x, y) the position draw characters of buffer memory Drawing Object;
Step 308, x return 0, and row of y displacement is high;
Step 309, judge y+Descent's and whether surpass region height, if then carry out next step; If not, then in (x, y) the position draw characters of buffer memory Drawing Object;
Step 310, whether judge current reference type size less than the described variable font size upper limit, if then execution in step 311, if not, then execution in step 312;
Step 311, upgrade the value of the described variable font size upper limit, continue to carry out next step with the value of current reference type size;
Step 312, dwindle current reference type size;
Step 313, judge variable font size lower limit<dwindle font size<variable font size upper limit whether to set up, judge that promptly current reference type size is whether in the font size mobility scale, if then initiate the request that repaints; If not, then interrupt circulation;
Whether step 314, judgement circulation are interrupted, and breakLoop==false is if then carry out next step; If not, then the expression circulation is interrupted, returns step 303 and rejudges;
Step 315, judge that whether current reference type size is greater than variable font size lower limit, if then execution in step 316; If not, execution in step 317 then;
Step 316, upgrade described variable font size lower limit, and write down corresponding buffer memory Drawing Object, continue to carry out next step with the value of current reference type size;
Step 317, whether judge current reference type size less than the initial baseline font size, and y less than the zone high 90%, if then execution in step 318; If not, then returning step 303 rejudges;
Step 318, amplify current reference type size, and carry out next step;
Step 319, judge whether variable font size lower limit<amplification font size<variable font size upper limit is set up, judge that promptly current reference type size is whether in the font size mobility scale, if then initiate the request that repaints; If not, then returning step 303 rejudges.
As can be seen, the present invention is drawing initially from last example, can do once estimation fast earlier, to adjust reference type size, makes the ideal font size of its relatively more approaching final acquisition; The loop structure of each character of traversal character string has two outlets, and primary outlet is normal loop ends, and second outlet is for forcing to finish outlet.In drawing process, the condition of amplifying font size can also be set, height in the last example takes 90% and whether only is used for for example, it all is feasible that those skilled in the art are provided with any condition, the present invention does not limit this, this condition setting can reduce the number of times of attempting drafting effectively, thereby effectively improves the drafting efficient of character string.
For making those skilled in the art understand the present invention better, below preferred embodiment by instantiation explanation the present invention drafting character string in the target area.
The hypothetical target area size is: 80*60; The character string content is: one two three four five six seven eight nine ten, and length is 10; Reference type size is: 24;
(1) estimation fast, adjust reference type size:
(1) API by JDK tries to achieve the character string width and is: 240;
(2) API by JDK tries to achieve capable height and is: 27.375;
(3) the average word of calculating is wide: 240/10=24;
(4) calculating can be held character number: the total area/single area=(80*60)/(24*27.375)=7;
(5) adjusted reference type size is: 24*sqrt (7/10)=20.
(2) font size mobility scale initial value is set, wherein, is limited to-1 under the variable font size, be limited to MAX on the variable font size;
(3) according to font size 20, row high 22.8125 carries out the first time to be drawn, and draws synoptic diagram as shown in Figure 4;
As can be seen from Figure 4, the 9th character failed to lay down the character number i=8 that is then drawn;
(4) be limited to 20 on the variable font size of record;
(5) dwindling font size is: 20*sqrt (8/10)=17;
(6) judge the too big font size of font size<minimum of variable font size lower limit<after dwindling, promptly-1<17<20, judge and set up, then carry out next step;
(7) according to font size 17, row high 19.39 is drawn, and the synoptic diagram after the drafting as shown in Figure 5;
Wherein, y=55.78.
(8) be limited to 17 under the variable font size of record;
(9) judge y/60=0.9269〉90%, do not need to repaint, keep this Drawing Object.
The present invention attempts drawing between the variable font size lower limit and the variable font size upper limit by font size, and brings in constant renewal in the described variable font size lower limit and the variable font size upper limit, thereby has effectively improved the drafting efficient that obtains the character string of target font size; And the present invention has further effectively improved drafting efficient as long as judging current font size whether in this mobility scale, can determine the initiation and the end of drawing process, thereby reduce the unnecessary wasting of resources of drawing process; Moreover the present invention makes reference type size more near the target font size by adjusting reference type size in advance in order to draw, and has reduced and has attempted the number of times of drafting, thereby further effectively improved drafting efficient; In addition, the present invention has realized automatic line feed and has decreased font size filling the parallel processing of function by analyzing the position relation of character in the target area automatically; At last, the technology of the present invention realizes simple, and no technology barrier does not have special secret algorithm, and cost and risk is lower.
With reference to figure 6, show of the present invention a kind of in the target area structured flowchart of the device embodiment of drafting character string, specifically can comprise with lower unit:
Default unit 601 is used for default font size mobility scale, and described font size mobility scale is variable font size lower limit and variable font size upper limit institute restricted portion;
Drawing unit 602 is used in the target area according to the reference type size drafting character string;
First judging unit 603 is used to judge whether the character string of being drawn surpasses the size of described target area, if then trigger first adjustment unit 604; If not, then trigger second adjustment unit 605;
First adjustment unit 604, be used for described reference type size less than described variable font size in limited time, described reference type size is replaced the described variable font size upper limit; And, dwindle described reference type size according to first presetting rule;
Second adjustment unit 605, be used for described reference type size greater than described variable font size under in limited time, described reference type size is replaced described variable font size lower limit; And, amplify described reference type size according to second presetting rule;
Second judging unit 606, be used to judge that the described reference type size that dwindles or amplify is whether in described font size mobility scale, if then trigger described drawing unit 602 and in described target area, repaint described character string according to the described reference type size that dwindles or amplify; If not, then trigger preservation unit 607;
Preserve unit 607, be used to preserve the rendering character strings result in the described target area.
Preferably, described first judging unit further comprises following subelement:
The line feed subelement is used for being the line feed identifier at the character of being drawn, and perhaps, when the displacement of institute's draw characters surpasses the width of described target area, is moved to capable high this character of drawing of the next one of described target area;
The height judgment sub-unit, be used to judge whether the height of institute's drafting character string surpasses the height of described target area, if then be the size that the character string of being drawn surpasses described target area, if not, then be the size that the character string of being drawn surpasses described target area.
Preferably, in the present embodiment, can also comprise adjustment unit, be used to adjust described reference type size.
Particularly, described adjustment unit can comprise following subelement:
The initial decision subelement is used to judge whether described reference type size is less than or equal to 0, if then trigger the zero setting subelement; If not, then subelement is obtained in triggering;
The zero setting subelement is used for described reference type size is put 0;
Obtain subelement, be used to obtain the overall width and the row height of character string;
The mean breadth computation subunit is used for according to the overall width of described character string and the mean breadth of actual characters number calculating character;
The unit area computation subunit is used for mean breadth and the high average unit area of calculating described character of row according to described character;
Can hold the character computation subunit, be used to calculate the total area of target area, the average unit area of the described total area and described character is compared, obtain the held character number of described target area;
Subelement determined in font size, is used to judge that whether the described character number that holds is more than or equal to described actual characters number, if then keep described reference type size; If not, then hold character number and actual characters number generation adjustment coefficient according to described, and according to the described reference type size of described adjustment coefficient adjustment.
For device embodiment, because it is substantially corresponding to method embodiment, so description is fairly simple, relevant part gets final product referring to the part explanation of method embodiment, and the present invention does not give unnecessary details at this.
Be understandable that the present invention can be used in numerous general or special purpose computingasystem environment or the configuration.For example: personal computer, server computer, handheld device or portable set, plate equipment, multicomputer system, the system based on microprocessor, set top box, programmable consumer-elcetronics devices, network PC, small-size computer, mainframe computer, comprise distributed computing environment of above any system or equipment or the like.
The present invention can describe in the general context of the computer executable instructions of being carried out by computing machine, for example program module.Usually, program module comprises the routine carrying out particular task or realize particular abstract, program, object, assembly, data structure or the like.Also can in distributed computing environment, put into practice the present invention, in these distributed computing environment, by by communication network connected teleprocessing equipment execute the task.In distributed computing environment, program module can be arranged in the local and remote computer-readable storage medium that comprises memory device.
More than to provided by the present invention a kind of in the target area method of drafting character string, and a kind of in the target area device of drafting character string be described in detail, used specific case herein principle of the present invention and embodiment are set forth, the explanation of above embodiment just is used for helping to understand method of the present invention and core concept thereof; Simultaneously, for one of ordinary skill in the art, according to thought of the present invention, the part that all can change in specific embodiments and applications, in sum, this description should not be construed as limitation of the present invention.

Claims (8)

1, a kind of in the target area method of drafting character string, it is characterized in that, comprising:
Default font size mobility scale, described font size mobility scale are variable font size lower limit and variable font size upper limit institute restricted portion;
In the target area according to the reference type size drafting character string;
When the character of being drawn is the line feed identifier, perhaps, when the displacement of institute's draw characters surpasses the width of described target area, then be moved to capable high this character of drawing of the next one of described target area;
Judge that whether the height of institute's drafting character string surpasses the height of described target area, if then be the size that the character string of being drawn surpasses described target area; If not, then be the size that the character string of being drawn surpasses described target area;
If the character string of being drawn surpasses the size of described target area, then described reference type size less than described variable font size in limited time, described reference type size is replaced the described variable font size upper limit; And, dwindle described reference type size according to first presetting rule;
If the character string of being drawn surpasses the size of described target area, then described reference type size greater than described variable font size under in limited time, described reference type size is replaced described variable font size lower limit; And, amplify described reference type size according to second presetting rule;
Judge that the described reference type size that dwindles or amplify is whether in described font size mobility scale, if then repaint described character string according to the described reference type size that dwindles or amplify in described target area; If not, then preserve rendering character strings result in the described target area.
2, the method for claim 1 is characterized in that, before the rendering character strings step, also comprises:
Adjust described reference type size.
3, method as claimed in claim 2 is characterized in that, adjusts described reference type size by following substep:
Judge whether described reference type size is less than or equal to 0, if, then described reference type size is put 0, if not, the overall width and the row that then obtain character string are high;
According to the overall width of described character string and the mean breadth of actual characters number calculating character;
Mean breadth and the high average unit area of calculating described character of row according to described character;
Calculate the total area of target area, the average unit area of the described total area and described character is compared, obtain the held character number of described target area;
Judge that whether the described character number that holds is more than or equal to described actual characters number, if then keep described reference type size; If not, then hold character number and actual characters number generation adjustment coefficient according to described, and according to the described reference type size of described adjustment coefficient adjustment.
4, the method for claim 1 is characterized in that, described step of dwindling reference type size comprises:
According to the actual characters number of described character string and the draw characters number calculate coefficient of reduction;
Described reference type size is dwindled according to described coefficient of reduction.
5, as claim 1 or 4 described methods, it is characterized in that the step of described amplification reference type size comprises:
According to the height of described target area and the high computational amplification coefficient of institute's drafting character string;
Described reference type size is amplified according to described amplification coefficient.
6, a kind of in the target area device of drafting character string, it is characterized in that, comprising:
Default unit is used for default font size mobility scale, and described font size mobility scale is variable font size lower limit and variable font size upper limit institute restricted portion;
Drawing unit is used in the target area according to the reference type size drafting character string;
First judging unit is used to judge whether the character string of being drawn surpasses the size of described target area, if then trigger first adjustment unit; If not, then trigger second adjustment unit; Wherein, described first judging unit further comprises: the line feed subelement is used for being the line feed identifier at the character of being drawn, perhaps, when the displacement of institute's draw characters surpasses the width of described target area, be moved to capable high this character of drawing of the next one of described target area; The height judgment sub-unit, be used to judge whether the height of institute's drafting character string surpasses the height of described target area, if then be the size that the character string of being drawn surpasses described target area, if not, then be the size that the character string of being drawn surpasses described target area.
First adjustment unit, be used for described reference type size less than described variable font size in limited time, described reference type size is replaced the described variable font size upper limit; And, dwindle described reference type size according to first presetting rule;
Second adjustment unit, be used for described reference type size greater than described variable font size under in limited time, described reference type size is replaced described variable font size lower limit; And, amplify described reference type size according to second presetting rule;
Second judging unit is used to judge that the described reference type size that dwindles or amplify is whether in described font size mobility scale, if then trigger described drawing unit and repaint described character string according to the described reference type size that dwindles or amplify in described target area; If not, then trigger the preservation unit;
Preserve the unit, be used to preserve the rendering character strings result in the described target area.
7, device as claimed in claim 6 is characterized in that, also comprises:
Adjustment unit is used to adjust described reference type size.
8, device as claimed in claim 7 is characterized in that, described adjustment unit comprises:
The initial decision subelement is used to judge whether described reference type size is less than or equal to 0, if then trigger the zero setting subelement; If not, then subelement is obtained in triggering;
The zero setting subelement is used for described reference type size is put 0;
Obtain subelement, be used to obtain the overall width and the row height of character string;
The mean breadth computation subunit is used for according to the overall width of described character string and the mean breadth of actual characters number calculating character;
The unit area computation subunit is used for mean breadth and the high average unit area of calculating described character of row according to described character;
Can hold the character computation subunit, be used to calculate the total area of target area, the average unit area of the described total area and described character is compared, obtain the held character number of described target area;
Subelement determined in font size, is used to judge that whether the described character number that holds is more than or equal to described actual characters number, if then keep described reference type size; If not, then hold character number and actual characters number generation adjustment coefficient according to described, and according to the described reference type size of described adjustment coefficient adjustment.
CNB2007101638965A 2007-10-11 2007-10-11 Method and device drafting character string at targeted area Active CN100504850C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2007101638965A CN100504850C (en) 2007-10-11 2007-10-11 Method and device drafting character string at targeted area

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2007101638965A CN100504850C (en) 2007-10-11 2007-10-11 Method and device drafting character string at targeted area

Publications (2)

Publication Number Publication Date
CN101127035A CN101127035A (en) 2008-02-20
CN100504850C true CN100504850C (en) 2009-06-24

Family

ID=39095067

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2007101638965A Active CN100504850C (en) 2007-10-11 2007-10-11 Method and device drafting character string at targeted area

Country Status (1)

Country Link
CN (1) CN100504850C (en)

Families Citing this family (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101976177B1 (en) * 2012-07-09 2019-05-08 엘지전자 주식회사 Mobile terminal and method for controlling of the same
CN105659201B (en) * 2013-10-18 2019-12-03 三菱电机株式会社 Character string display device
CN105786901B (en) * 2014-12-23 2019-11-15 广州市动景计算机科技有限公司 A kind of method and device adjusting webpage font size
CN104657339B (en) * 2015-02-09 2017-08-11 深圳市联新移动医疗科技有限公司 The method shown in lines in medical system
CN104994312A (en) * 2015-07-15 2015-10-21 北京金山安全软件有限公司 Video generation method and device
CN105159868A (en) * 2015-09-01 2015-12-16 广东欧珀移动通信有限公司 Text display method and system
CN106873925A (en) * 2015-12-10 2017-06-20 北京国双科技有限公司 The display methods and device of label text
CN106997292A (en) * 2016-01-26 2017-08-01 北京国双科技有限公司 The method and apparatus for handling rectangle tree graph
JP2020537244A (en) 2017-10-09 2020-12-17 華為技術有限公司Huawei Technologies Co.,Ltd. Display processing method and electronic device
CN109325215B (en) * 2018-12-04 2023-02-10 万兴科技股份有限公司 Word text output method and device
CN109756696B (en) * 2019-01-18 2020-11-06 苏州科达科技股份有限公司 Station caption adding method, video conference image generating method, system, device and medium
CN110126458B (en) * 2019-04-01 2021-01-05 桂林市朗谷科技有限公司 Automatic PCB screen printing adjusting method and device and storage medium
CN112233206B (en) * 2019-07-15 2024-03-22 浙江宇视科技有限公司 Character image generation method, device, equipment and storage medium
CN113705156A (en) * 2021-08-30 2021-11-26 上海哔哩哔哩科技有限公司 Character processing method and device
CN114063959A (en) * 2021-11-18 2022-02-18 得力集团有限公司 Calculator circulation decimal display control method and calculator

Also Published As

Publication number Publication date
CN101127035A (en) 2008-02-20

Similar Documents

Publication Publication Date Title
CN100504850C (en) Method and device drafting character string at targeted area
CN102929603B (en) Interface control arrangement device and interface control arrangement method
CN106020967B (en) A kind of automatic expansion method of hybrid cloud resource
CN101158940A (en) Method and device for dwindling character stuffing in target region
CN110837617A (en) Webpage self-adaptive layout method, server and computer readable storage medium
KR100964792B1 (en) System and method of content adaptation for mobile web conditions
CN106339226A (en) Webpage page display method and page display plug-in
CN104820589A (en) Method and device for dynamically adapting webpage
EP1861797A1 (en) Content optimization for receiving terminals
CN110675471B (en) Node connection line generation method, device, equipment and storage medium
CN103176700A (en) Method and terminal for quickly displaying status information of application program
CN113095995A (en) Webpage watermark adding method and device, electronic equipment and storage medium
CN107450928A (en) A kind of mixed developing method based on caching technology
US20110128291A1 (en) Program generation device, program generation method, and computer-readable storage medium
CN103354990A (en) System and method for processing virtual machine in cloud platform
CN115174406B (en) Container application expansion and contraction method and device, computer equipment and storage medium
EP2449456A2 (en) Vector-based magnified pointer
CN104834715A (en) Website generating method and system based on components and container
CN114595494A (en) Auxiliary design tool kit based on AutoCAD software and construction method
CN108287707B (en) JSX file generation method and device, storage medium and computer equipment
CN106294305A (en) Android smart machine carries out, to html web page content, the method that segmentation shows
CN109582401B (en) Promotion picture generation method and device, storage medium and computer equipment
CN112632917B (en) Online document processing method and device, electronic equipment and storage medium
CN109684577A (en) A kind of configuration method of web page contents, system and electronic equipment
CN113360266A (en) Task processing method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant