Embodiment
In order to make purpose of the present invention, technical scheme and advantage clearer, below in conjunction with drawings and Examples, the present invention is further elaborated, for convenience of explanation, only show the part relevant with the embodiment of the invention.Should be appreciated that the specific embodiment that this place is described, only be used for explaining the present invention, not in order to limit the present invention.
The present invention is by presetting the second font rank and the second font value in the second screen resolution, when getting access to the first screen resolution and the first font rank, obtain and immediate the second screen resolution of the wide high product of described the first screen resolution, obtain the first font value corresponding to described the first font rank according to the second font rank that presets in described the second screen resolution and the second font value corresponding to described the second font rank again, at last draw font in described the first screen resolution according to described the first font value.Realized the adaptive purpose of font, reduced masterplate maintenance difficulties and adaptive cost, escalation process is simple, high efficiency.Further also by the scaling between the wide high product of the first screen resolution and the wide high product of the second screen resolution described the second font value is carried out convergent-divergent, make the first font value can be according to the variation of the second font value and dynamic the variation do not need to increase the self-adaptation that the UI module can realize font.Further optimize the computing formula of scaling, can reach best font self-adaptation effect.
Embodiment one
Fig. 1 is the process flow diagram of a kind of font adaptive approach of the present invention, and described method comprises step:
S101 obtains the first screen resolution and the first font rank;
Described the first screen resolution refers to pixel wide and the pixels tall that mobile terminal screen can be supported;
Described portable terminal refers to various mobile phones and panel computer;
The interface that provides according to mobile terminal operating system obtains pixel wide, pixels tall and the first font rank that described portable terminal current display mode sub-screen can be supported.
S102 obtains and immediate the second screen resolution of the wide high product of described the first screen resolution;
Described the second screen resolution is the UI template, has wherein preset the second font rank and the second font value;
Described the first font rank or the second font rank comprise more than one font grade, the font value that each font grade is corresponding different, and the unit of described font value is pixel;
For example the second font rank comprises the first estate, the second grade, the tertiary gradient, and each grade has corresponding font value, and the unit of described font value is pixel;
Described " obtaining and immediate the second screen resolution of the wide high product of described the first screen resolution " comprising:
Obtain the wide high product of described the first screen resolution;
Obtain the wide high product with immediate second screen resolution of wide high product of described the first screen resolution;
Wide high product according to described the second screen resolution obtains the second screen resolution;
The script that the application developer can use middleware to provide presets font value corresponding to a plurality of font grades in the second screen resolution, realizes the adaptive purpose of font;
For ease of understanding, illustrate, for example the second screen resolution comprises 176x220,240x320,320x480,360x640;
Preset the second font rank in described the second screen resolution, described the second font rank comprises the first estate, the second grade, the tertiary gradient, and each grade has corresponding font value, and the unit of described font value is pixel, is specially:
The font value of the first estate is that the font value of 12 pixels, the second grade is that the font value of 16 pixels, the tertiary gradient is 20 pixels among the 176x220, and the wide high product of described the second screen resolution 176x220 is 176*220=38720;
The font value of the first estate is that the font value of 14 pixels, the second grade is that the font value of 18 pixels, the tertiary gradient is 24 pixels among the 240x320, and the wide high product of described the second screen resolution 240x320 is 240*320=76800;
The font value of the first estate is that the font value of 16 pixels, the second grade is that the font value of 22 pixels, the tertiary gradient is 28 pixels among the 320x480, and the wide high product of described the second screen resolution 320x480 is 320*480=153600;
The font value of the first estate is that the font value of 18 pixels, the second grade is that the font value of 24 pixels, the tertiary gradient is 30 pixels among the 360x640, and the wide high product of described the second screen resolution 360x640 is 360*640=230400;
Obtain the wide high product dipS of the first screen resolution, compare with the wide high product of four the second screen resolutions that preset, if the wide high product dipS of described the first screen resolution is near 38720, then the font value in described the first screen resolution shows according to the font value among the 176x220;
If disS is near 76800, then the second corresponding screen resolution is 176x220;
If disS is near 153600, then the second corresponding screen resolution is 240x320;
If disS is near 230400, then the second corresponding screen resolution is 320x480;
If disS is more than or equal to 230400, then the second corresponding screen resolution is 360x640;
S103 according to the second font rank that presets in described the second screen resolution and the second font value corresponding to described the second font rank, obtains the first font value corresponding to described the first font rank;
Continue for example, after getting access to the second screen resolution, the second font rank in corresponding described the second screen resolution of the first font rank then, if at this moment described the second font rank is the first estate, at this moment the font value that just gets access to the first estate among the 176x220 is 12 pixels, the first font value corresponding to so described the first font rank just is 12 pixels, and the font in the first screen resolution will show according to 12 pixels; In like manner, if at this moment described the second font rank is the second grade, at this moment the font value that just gets access to second level among the 176x220 is 16 pixels, the first font value corresponding to so described the first font rank just is 16 pixels, and the font in the first screen resolution will show according to 16 pixels;
Further, described " according to the second font rank that presets in described the second screen resolution and the second font value corresponding to described the second font rank, obtaining the first font value corresponding to described the first font rank " comprising:
Obtain the scaling of the wide high product of the first screen resolution and the wide high product of the second screen resolution;
Carry out convergent-divergent according to the second font value that described scaling is corresponding with the second font rank in described the second screen resolution;
Obtain the first font value corresponding to described the first font rank according to the second font value behind the convergent-divergent.
Described scaling is the ratio of the wide high product of the first screen resolution and the wide high product of the second screen resolution;
Described scaling can also be 1+ ((scaling-1)/0.5) * 0.1.Can reach best font self-adaptation effect this moment, avoids occurring font and show that the position between incomplete or font and the screen is inharmonious; Wherein, the wide high product of the wide high product of scaling=first screen resolution/second screen resolution;
Illustrate: the ratio r ate that obtains the wide high product of the first screen resolution and the wide high product of the second screen resolution, the wide high product of the wide high product of rate=the first screen resolution/second screen resolution, carry out convergent-divergent according to the second font value that described ratio is corresponding with the second font rank in described the second screen resolution, the second font value behind the convergent-divergent just is the first font value corresponding to the first font rank; Described the first font value is the even number that is not less than described the first font value, i.e. the first font value=(the first font value %2==0? the first font value: the first font value+1), represent whether the first font value equals 0 divided by 2, if then the first font value does not just need to change, then the first font value adds 1 if not;
Further specify the font value of the first estate of font value small=rate* second screen resolution of the first estate in the first font rank; The font value of the second grade of font value mid=rate* second screen resolution of the second grade in the first font rank; The font value of the tertiary gradient of font value big=rate* second screen resolution of the tertiary gradient in the first font rank;
Is wherein the font value in the first font rank got the even number that is not less than described font value, i.e. small=(small%2==0? small:small+1); Mid and big are also with the value of small;
In like manner can calculate the font value of the second grade, the tertiary gradient;
S104 draws font in described the first screen resolution according to described the first font value.
Described being plotted as according to the first font value is presented at portable terminal with the font in described the first screen resolution.
The present invention is by presetting the second font rank and the second font value in the second screen resolution, when getting access to the first screen resolution and the first font rank, obtain and immediate the second screen resolution of the wide high product of described the first screen resolution, obtain the first font value corresponding to described the first font rank according to the second font rank that presets in described the second screen resolution and the second font value corresponding to described the second font rank again, at last draw font in described the first screen resolution according to described the first font value.Realized the adaptive purpose of font, reduced masterplate maintenance difficulties and adaptive cost, escalation process is simple, high efficiency.Further also by the scaling between the wide high product of the first screen resolution and the wide high product of the second screen resolution described the second font value is carried out convergent-divergent, make the first font value can be according to the variation of the second font value and dynamic the variation do not need to increase the self-adaptation that the UI module can realize font.Further optimize the computing formula of scaling, can reach best font self-adaptation effect.
Embodiment two
Fig. 2 is the structural representation of a kind of font adaptive system the first preferred embodiment of the present invention.Described system comprises and obtains screen module, UI template, obtains font module and rendered fonts module;
The described screen module of obtaining links to each other with described UI template, is used for obtaining the first screen resolution and the first font rank;
Described the first screen resolution refers to pixel wide and the pixels tall that mobile terminal screen can be supported;
Described portable terminal refers to various mobile phones and panel computer;
The interface that provides according to mobile terminal operating system obtains pixel wide, pixels tall and the first font rank that described portable terminal current display mode sub-screen can be supported;
Described UI template is obtained screen module and is obtained font module and link to each other with described, is used for obtaining and immediate the second screen resolution of the wide high product of described the first screen resolution;
Described the second screen resolution is the UI template, has wherein preset the second font rank and the second font value; Described the first font rank or the second font rank comprise more than one font grade, the font value that each font grade is corresponding different, and the unit of described font value is pixel;
For example the second font rank comprises the first estate, the second grade, the tertiary gradient, and each grade has corresponding font value, and the unit of described font value is pixel;
The further optimization of such scheme is, described UI module comprises the first acquiring unit, second acquisition unit and the 3rd acquiring unit, is illustrated in figure 3 as the structural representation of a kind of font adaptive system the second preferred embodiment of the present invention;
Described the first acquiring unit links to each other with second acquisition unit with the described screen module of obtaining, and is used for obtaining the wide high product of described the first screen resolution;
Described second acquisition unit links to each other with the 3rd acquiring unit with described the first acquiring unit, is used for obtaining the wide high product with immediate second screen resolution of wide high product of described the first screen resolution;
Described the 3rd acquiring unit, with described second acquisition unit with obtain font module and link to each other, be used for obtaining described the second screen resolution according to the wide high product of described the second screen resolution.
The script that the application developer can use middleware to provide presets font value corresponding to a plurality of font grades in the second screen resolution, realizes the adaptive purpose of font;
For ease of understanding, illustrate, for example the second screen resolution comprises 176x220,240x320,320x480,360x640;
Preset the second font rank in described the second screen resolution, described the second font rank comprises the first estate, the second grade, the tertiary gradient, and each grade has corresponding font value, and the unit of described font value is pixel, is specially:
The font value of the first estate is that the font value of 12 pixels, the second grade is that the font value of 16 pixels, the tertiary gradient is 20 pixels among the 176x220, and the wide high product of described the second screen resolution 176x220 is 176*220=38720;
The font value of the first estate is that the font value of 14 pixels, the second grade is that the font value of 18 pixels, the tertiary gradient is 24 pixels among the 240x320, and the wide high product of described the second screen resolution 240x320 is 240*320=76800;
The font value of the first estate is that the font value of 16 pixels, the second grade is that the font value of 22 pixels, the tertiary gradient is 28 pixels among the 320x480, and the wide high product of described the second screen resolution 320x480 is 320*480=153600;
The font value of the first estate is that the font value of 18 pixels, the second grade is that the font value of 24 pixels, the tertiary gradient is 30 pixels among the 360x640, and the wide high product of described the second screen resolution 360x640 is 360*640=230400;
Obtain the wide high product dipS of the first screen resolution, compare with the wide high product of four the second screen resolutions that preset, if the wide high product dipS of described the first screen resolution is near 38720, then the font value in described the first screen resolution shows according to the font value among the 176x220;
If disS is near 76800, then the second corresponding screen resolution is 176x220;
If disS is near 153600, then the second corresponding screen resolution is 240x320;
If disS is near 230400, then the second corresponding screen resolution is 320x480;
If disS is more than or equal to 230400, then the second corresponding screen resolution is 360x640;
The described font module of obtaining, link to each other with the rendered fonts module with described UI template, for the second font rank and the second font value corresponding to described the second font rank that preset according to described the second screen resolution, obtain the first font value corresponding to described the first font rank;
Continue for example, after getting access to the second screen resolution, the second font rank in corresponding described the second screen resolution of the first font rank then, if at this moment described the second font rank is the first estate, at this moment the font value that just gets access to the first estate among the 176x220 is 12 pixels, the first font value corresponding to so described the first font rank just is 12 pixels, and the font in the first screen resolution will show according to 12 pixels; In like manner, if at this moment described the second font rank is the second grade, at this moment the font value that just gets access to second level among the 176x220 is 16 pixels, the first font value corresponding to so described the first font rank just is 16 pixels, and the font in the first screen resolution will show according to 16 pixels;
Described rendered fonts module links to each other with the described font module of obtaining, and is used for the font of drawing described the first screen resolution according to described the first font value.
Such scheme further optimized be, the described font module of obtaining comprises and obtains scaling unit, unit for scaling and obtain the font value cell, is illustrated in figure 4 as the structural representation of a kind of font adaptive system the 3rd preferred embodiment of the present invention;
The described scaling unit that obtains links to each other with unit for scaling with described the 3rd acquiring unit, is used for obtaining the scaling of the wide high product of the first screen resolution and the wide high product of the second screen resolution;
Described unit for scaling obtains the scaling unit and obtains the font value cell and link to each other with described, is used for according to described scaling described the second font value being carried out convergent-divergent;
The described font value cell that obtains links to each other with the rendered fonts module with described unit for scaling, is used for obtaining the first font value corresponding to described the first font rank according to the second font value behind the convergent-divergent.
Described scaling is the ratio of the wide high product of the first screen resolution and the wide high product of the second screen resolution;
Described scaling can also be 1+ ((scaling-1)/0.5) * 0.1.Can reach best font self-adaptation effect this moment, avoids occurring font and show that the position between incomplete or font and the screen is inharmonious; Wherein, the wide high product of the wide high product of scaling=first screen resolution/second screen resolution;
Illustrate: obtain the ratio r ate of the wide high product of the first screen resolution and the wide high product of the second screen resolution, the wide high product of the wide high product of rate=the first screen resolution/second screen resolution;
Carry out convergent-divergent according to the second font value that described ratio is corresponding with the second font rank in described the second screen resolution, the second font value behind the convergent-divergent just is the first font value corresponding to the first font rank; Described the first font value is the even number that is not less than described the first font value, i.e. the first font value=(the first font value %2==0? the first font value: the first font value+1), represent whether the first font value equals 0 divided by 2, if then the first font value does not just need to change, then the first font value adds 1 if not;
Further specify the font value of the first estate of font value small=rate* second screen resolution of the first estate in the first font rank; The font value of the second grade of font value mid=rate* second screen resolution of the second grade in the first font rank; The font value of the tertiary gradient of font value big=rate* second screen resolution of the tertiary gradient in the first font rank;
Is wherein the font value in the first font rank got the even number that is not less than described font value, i.e. small=(small%2==0? small:small+1); Mid and big are also with the value of small;
In like manner can calculate the font value of the second grade, the tertiary gradient.
The present embodiment comprises and obtains screen module, UI template, obtains font module and rendered fonts module, and the wherein said screen module of obtaining is used for obtaining the first screen resolution and the first font rank; Described UI template is used for obtaining and immediate the second screen resolution of the wide high product of described the first screen resolution; The described font module of obtaining is used for obtaining the first font value corresponding to described the first font rank according to the second font rank and the second font value corresponding to described the second font rank that described the second screen resolution presets; Described rendered fonts module is for the font of drawing described the first screen resolution according to described the first font value.Realized the adaptive purpose of font, reduced masterplate maintenance difficulties and adaptive cost, escalation process is simple, high efficiency.Further also by the scaling between the wide high product of the first screen resolution and the wide high product of the second screen resolution described the second font value is carried out convergent-divergent, make the first font value can be according to the variation of the second font value and dynamic the variation do not need to increase the self-adaptation that the UI module can realize font.Further optimize the computing formula of scaling, can reach best font self-adaptation effect.
A kind of font adaptive system provided by the present invention can be applied to needs the adaptive terminal device of font, such as mobile phone, PDA etc.
Those having ordinary skill in the art will appreciate that, all or part of step in realization above-described embodiment method can be finished by the programmed instruction related hardware, described program can be stored in the computer read/write memory medium, and described storage medium can be ROM, RAM, disk, CD etc.
The above only is preferred embodiment of the present invention, not in order to limiting the present invention, all any modifications of doing within the spirit and principles in the present invention, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.