Text question Can I draw a unicode character with...
# compose
e
Text question Can I draw a unicode character without it's ascender and descenders? Let's say I want to fill a Box {} with the letter
A
but I don't want any of the white space that is there for other letters. In my real example I'm using unicode characters, all of which is of the same size, but I don't want the whitespace I'm getting I.e. can I draw the glyph itself somehow.
y
Would TextMeasurer/TextLayoutResult work. Get the bounding box? Then draw via Canvas?
e
The challenge is that when I measure it, I will get a smaller glyph than I want to. I could probably use that information and scale it, but in my case that would look pretty bad. Right now I'm doing something really hacky and scale the graphics layer, but that can easily break. I guess what I want exists but very far down in the graphics stack. However, sometimes there's an API 🙂
b
the Paint() api in skia is what you are thinking of?
Copy code
@Composable
fun GlyphCanvas() { Canvas(Modifier.fillMaxSize()) { drawIntoCanvas { canvas -> val paint = Paint().asFrameworkPaint().apply { textSize = 72f color = android.graphics.Color.BLUE isAntiAlias = true } canvas.nativeCanvas.drawText(" ", 100f, 200f, paint) } }
❤️ 1
e
Let me try that! and thanks for the suggestion 🙂 side note: I'm always down for a cup of coffee haha
@Bogdan Vladoiu Lbs That did the job!
🙌 1