louiscad
02/15/2024, 10:29 PMIntSize
from a ceilToIntPx()
call rather than keep the decimals in a Float
?
When text is animated (and therefore has the subpixel flag), it leads to non-pixel perfect things.romainguy
02/15/2024, 10:32 PMlouiscad
02/15/2024, 10:33 PMdrawTextOnPath
(Android's Canvas platform API) for each span.romainguy
02/15/2024, 10:34 PMdrawTextOnPath
in a while but it was horribly broken in some casesromainguy
02/15/2024, 10:35 PMlouiscad
02/15/2024, 10:39 PM1
, essentially turning the ceil
into a floor
.louiscad
02/15/2024, 10:42 PMdrawTextOnPath
as broken as what this would produce?
https://www.pushing-pixels.org/2022/02/10/drawing-text-on-a-path-in-compose-desktop-with-skia.html
No other way on Android anyway, just curiousromainguy
02/15/2024, 10:43 PMlouiscad
02/15/2024, 10:43 PMPathMeasure
to draw text character per character on a path, would it be as broken?romainguy
02/15/2024, 10:43 PMromainguy
02/15/2024, 10:43 PMromainguy
02/15/2024, 10:43 PMromainguy
02/15/2024, 10:43 PMlouiscad
02/15/2024, 10:44 PMromainguy
02/15/2024, 10:44 PMlouiscad
02/15/2024, 10:44 PMromainguy
02/15/2024, 10:44 PMromainguy
02/15/2024, 10:45 PMromainguy
02/15/2024, 10:45 PMlouiscad
02/15/2024, 10:45 PMromainguy
02/15/2024, 10:45 PMromainguy
02/15/2024, 10:45 PMlouiscad
02/15/2024, 10:45 PMromainguy
02/15/2024, 10:45 PMromainguy
02/15/2024, 10:46 PMlouiscad
02/15/2024, 10:46 PMromainguy
02/15/2024, 10:46 PMlouiscad
02/15/2024, 10:46 PMromainguy
02/15/2024, 10:46 PMlouiscad
02/15/2024, 10:46 PMlouiscad
02/15/2024, 10:46 PMlouiscad
02/15/2024, 10:47 PMromainguy
02/15/2024, 10:48 PMlouiscad
02/15/2024, 10:56 PMTextLayoutResult
though…louiscad
02/16/2024, 12:19 AMgetBoundingBox
on the TextLayoutResult
and passing the last index of the previously drawn chunks to it.
It's still not pixel perfect, but the difference is negligiblelouiscad
02/16/2024, 12:21 AMceil
operation is applied though, I can see the code of getBoundingBox
is non trivial, certainly much more expensive to compute something that was already known but couldn't be retrived because of inpenetrable API boundaries.romainguy
02/16/2024, 12:21 AMlouiscad
02/16/2024, 12:22 AMromainguy
02/16/2024, 12:23 AMlouiscad
02/16/2024, 12:23 AMromainguy
02/16/2024, 12:27 AMromainguy
02/16/2024, 12:27 AMlouiscad
02/16/2024, 12:29 AMHalil Ozercan
02/16/2024, 12:29 AMTextLayoutResult
+`getBoundingBox` direction, you might want to take a look at https://gist.github.com/halilozercan/cf09d8c1ea6ec68264c031731f8eeb38Halil Ozercan
02/16/2024, 12:31 AMlouiscad
02/16/2024, 12:36 AMlouiscad
02/16/2024, 11:47 PMgetBoundingBox
, I noticed that when I have skewX
set to something other than 0f
(e.g. Float.MIN_VALUE
, aka 1.4E-45f
), the per-character split and non-split text render (with drawTextOnPath
called for whole string vs for each char) match up perfectly. I'm not sure why, but it's good to know for me.
I still plan to look into Halil's per-glyph rendering solution because I believe it'll work best with emojis, exotic unicode stuff, and non latin text (like arabic or japanese).romainguy
02/17/2024, 12:00 AMromainguy
02/17/2024, 12:01 AMHalil Ozercan
02/17/2024, 12:57 PMgetBoundingBox
is not perfect. You may see some pixels of glyphs being left out especially for tall ascents and deep descents. getBoundingBox
is not meant to be pixel perfect though. Its main purpose is to give a good approximation of where a character/glyph is in the text layout rectangle for focus, semantics, and gestures. In those cases missing a pixel or two wouldn't hurt. However when drawing it's not acceptable to leave a pixel behind while translating, rotation a glyph.louiscad
04/16/2024, 6:01 PMnextContour()
isn't exposed in Compose's PathMeasure
API. I'm not sure why, but I think it could be helpful to have it, so I filed a feature request: https://issuetracker.google.com/issues/334977827romainguy
04/16/2024, 6:07 PMPathMeasure
has other issues anyway, I would like to swap out its implementation eventually to not rely on the platform’sromainguy
04/16/2024, 6:08 PMPath
into a list of contours (as Path
instances) and measuring them individuallylouiscad
04/16/2024, 6:09 PMPathMeasure
has?romainguy
04/16/2024, 6:10 PMromainguy
04/16/2024, 6:10 PMsqrt(2)
)louiscad
04/16/2024, 6:11 PMromainguy
04/16/2024, 6:12 PMromainguy
04/16/2024, 6:12 PMromainguy
04/16/2024, 6:12 PMromainguy
04/16/2024, 6:13 PMPathMeasure
(and probably making it faster too)louiscad
04/16/2024, 6:14 PMlouiscad
04/16/2024, 6:16 PMlouiscad
04/16/2024, 6:17 PMromainguy
04/16/2024, 6:21 PMromainguy
04/16/2024, 6:21 PM