I'm trying to draw multiline text into a bitmap with Latto-Reg font, and StaticLayout seems to have problems with it.
paint.setTextSize(label.fontSize); paint.setTypeface(face); StaticLayout textLayout = new StaticLayout(label.text, paint, (int)StaticLayout.getDesiredWidth(label.text, paint), Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); Bitmap bitmapAux = Bitmap.createBitmap(textLayout.getEllipsizedWidth(), textLayout.getHeight(), Bitmap.Config.ALPHA_8); canvas.setBitmap(bitmapAux); canvas.save(); canvas.translate(0, textLayout.height()); textLayout.draw(canvas); canvas.restore();
The texture is indented above and below depending on the font and size, while the text fits perfectly in the bitmap image, this is a lot of lost memory space and makes it turn off by a random amount.

I tested using a single-line drawing, and the bitmap perfectly matched the text
paint.getTextBounds(label.text, 0, label.text.length(), rect); Bitmap bitmapAux = Bitmap.createBitmap(rect.width(), rect.height(), Bitmap.Config.ALPHA_8); canvas.drawText(label.text, -rect.left, -rect.bottom, paint);

I tried to get all kinds of metrics from StaticLayout, and they all seem to be disconnected from the text: line borders 0, top line 0, last bottom line ... lead to the same filling problems.
EDIT: I solved the problem using a single-line offset based drawing. However, the StaticLayout class incorrectly drew several different non-standard fonts, and I want to know why.