I’ve created a canvas. And I draw text on a canvas. But when I’m testing on different versions of android, the text looks different. Difference between version 4.х and 2.2.
Bitmap btmText = Bitmap.createBitmap(140, 90, Bitmap.Config.ARGB_4444);
Canvas cnvText = new Canvas(btmText);
Typeface tf = tf = Typeface.createFromAsset(context.getAssets(),"fonts/font.ttf");
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setSubpixelText(true);
paint.setTypeface(tf);
paint.setTextSize(50);
cnvText.drawText(text, 0, 5, 0, 55, paint);
Text look bigger on android 2.2 than android 4.0.3.
It might be because of different screen densities.
I guess
Paint.setTextSize()takes size in pixels and not in dp. To display the same size in inches across devices, you’ll have to decide the size of the text you wish to display in dp and convert that value to pixels.