Re: [android-developers] Problem with drawing text in scaled Canvas on Android 4.0

2012-03-05 Thread Kaloyan Donev
Hi, The measure functions are in Paint. The scale functions are in Canvas. So I can only measure text without any scale. And if I measure the width and height of some text and want to draw a rectangle around it and want to use the scale of canvas for zooming. On some zooms the text is a little

Re: [android-developers] Problem with drawing text in scaled Canvas on Android 4.0

2012-03-05 Thread Romain Guy
The Canvas scale does not apply to the font size, it applies to the vector shapes generated from the original font size. You simply cannot this: p.setTextSize(fontSize * scale) result = p.measureText(...) You must instead do this: p.setTextSize(fontSize) result = scale * p.measureText(...) On

Re: [android-developers] Problem with drawing text in scaled Canvas on Android 4.0

2012-03-05 Thread Zsolt Vasvari
And finally it is working as I expected on Android below 4.0. Why it is not working on 4.0? What is the difference? The font used, for one... -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to

[android-developers] Problem with drawing text in scaled Canvas on Android 4.0

2012-03-04 Thread Kaloyan Donev
Hi, I am using a Typeface to draw text in canvas which have scale matrix. So first I measure the width of text when scale is 1.0. Then I measure the width of text when scale is different than 1.0. And I expect that non scaled width * scale will be equal to scaled width. This is true on devices

Re: [android-developers] Problem with drawing text in scaled Canvas on Android 4.0

2012-03-04 Thread Romain Guy
Hi, This is not the proper way to measure scaled text. The font size defines the height of the font, not its width. There is no guarantee whatsoever that scaling a font size by a number S will scale the width of the text by the same number S. The proper way is to always call measureText() with