https://kotlinlang.org logo
#compose
Title
# compose
m

Matthew Feinberg

03/26/2024, 12:14 PM
Hi everyone 👋 I'm looking for a multiplatform equivalent of Android's `Paint.getTextPath()`: Basically, I need to get a vector path from the outline of text. I looked in the
TextMeasurer
,
Paint
and
Canvas
APIs, but couldn't find anything. I thought about making an expect/actual implementation for iOS and Android (the platforms I care about at the moment), but I couldn't find anything in
NativePaint
or
NativeCanvas
that does what I want. Of course, there are Swift APIs that will give me this, but they use the iOS text rendering framework, so there are likely to be subtle differences between the platforms. Before I go down that route, I was just wondering if there was something obvious I was missing.
At a deeper level, there are two reasons what I want this: 1. Short-term: I'm doing off-screen rendering to an ImageBitmap in a non-UI thread, and a bug in how Compose caches SkTextStyle objects is causing concurrent modification exceptions (the WeakKeysCache that is used for the cache appears to not be threadsafe, so when the UI recomposes at the same time, it crashes...). I will file a bug report on this in YouTrack (Android is correctly threadsafe for this, but iOS is not...) 2. Long-term: I will eventually need to do paint-on animations of the stroke of the text. This isn't an immediate need, but eventually even if the bug I mentioned in #1 is solved, I'll still eventually end up needing a solution.
z

Zach Klippenstein (he/him) [MOD]

03/26/2024, 5:03 PM
Please file a feature request
👍 1
5 Views