With the paint's typeface set to Typeface.DEFAULT with a text size of 40, the following code results in a rectangle significantly wider than the text being drawn:
rect = new Rect (originX, originY - this.rect.height (), originX + (int) paint.measureText (new String (chars)), originY); paint.setStyle (Paint.Style.STROKE); canvas.drawRect (rect, paint);
In addition, increasing originX by the measured width for each individual ASCII character (which should not have complex shaping requirements) and then drawing the characters individually, increasing originX by the measured width each time, leads to the characters being drawn to the left of where they end up when drawn at once with drawText. If measureText is not the way to measure the advancement of the glyph corresponding to each ASCII character in a typeface (like the documentation seems to imply), then what is?
Description
paint.setTextSize (fontObject.pixelSize);
paint.setColor (immutableGC.foreground | 0xff000000);
paint.setTypeface (fontObject.typeface.typeface);
paint.setAntiAlias (true);
canvas.drawText (chars, 0, chars.length, originX, originY, paint);
paint.setAntiAlias (false);
rect = new Rect (originX, originY - this.rect.height (),
originX + (int) paint.measureText (new String (chars)),
originY);
paint.setStyle (Paint.Style.STROKE);
canvas.drawRect (rect, paint);
In addition, increasing originX by the measured width for each individual ASCII character (which should not have complex shaping requirements) and then drawing the characters individually, increasing originX by the measured width each time, leads to the characters being drawn to the left of where they end up when drawn at once with drawText. If measureText is not the way to measure the advancement of the glyph corresponding to each ASCII character in a typeface (like the documentation seems to imply), then what is?
This is on RQ3A.211001.011.
Thanks.