That's perfectly normal, text is hinted in the vertical direction by default on Android to make it more legible (and reduce glyph cache memory pressure).
On Wed, Aug 3, 2011 at 9:06 PM, guich <[email protected]> wrote: > Hi, > > If you call Paint.setTextSize and set it to a wide range, like 7 to > 40, you will note that the transition is not smooth. Sometimes it > repeats the same height. > > The code below illustrates what i mean (testing on an emulator for > android 2.2): > > Paint paint = new Paint(); > paint.setAntiAlias(antialiased); > paint.setTypeface(Typeface.SERIF); > paint.setColor(Color.BLACK); > Rect r = new Rect(); > > for (int i = 7; i < 40; i++) > { > paint.setTextSize(i); > paint.getTextBounds("Ãg_",0,3,r); > maxH = (int)(Math.abs(paint.descent()) + > Math.abs(paint.ascent())); > int realH = Math.abs(r.top - r.bottom); > println("size: "+i+", height: "+maxH+", realH: "+realH); > } > > And the output is: > > size: 7, height: 8, realH: 9 > size: 8, height: 9, realH: 10 > size: 9, height: 10, realH: 10 > size: 10, height: 11, realH: 13 > size: 11, height: 12, realH: 13 > size: 12, height: 13, realH: 15 > size: 13, height: 15, realH: 15 > size: 14, height: 16, realH: 17 > size: 15, height: 17, realH: 17 > size: 16, height: 18, realH: 19 > size: 17, height: 19, realH: 19 > size: 18, height: 20, realH: 20 > size: 19, height: 22, realH: 23 > size: 20, height: 23, realH: 23 > size: 21, height: 24, realH: 26 > size: 22, height: 25, realH: 26 > size: 23, height: 26, realH: 28 > size: 24, height: 27, realH: 28 > size: 25, height: 29, realH: 29 > size: 26, height: 30, realH: 29 > size: 27, height: 31, realH: 32 > size: 28, height: 32, realH: 32 > size: 29, height: 33, realH: 33 > size: 30, height: 34, realH: 35 > size: 31, height: 36, realH: 35 > size: 32, height: 37, realH: 38 > size: 33, height: 38, realH: 38 > size: 34, height: 39, realH: 40 > size: 35, height: 40, realH: 40 > size: 36, height: 41, realH: 42 > size: 37, height: 43, realH: 42 > size: 38, height: 44, realH: 44 > size: 39, height: 45, realH: 44 > > Am I missing something? Why the gaps between the font sizes and the > heights? For example, size=30->31 has size 34->36. How can i achieve > height 35? > > Even if i use a smaller increment for i, like 0.1 or 0.01, i don't > actually get a smooth scale for the font. > > thanks > > guich > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

