Status Update
Comments
si...@google.com <si...@google.com>
si...@google.com <si...@google.com> #2
Quote from the linked chat: "Maybe it wouldn’t be a problem for us if we could specify custom Alignment value just for our font, but it’s private constructor (so we cannot emulate behaviour how I saw on your sample app with line distribution"
Also what font is the custom font?
- side note: a similar line height happened with SF font
si...@google.com <si...@google.com> #3
Note: the font descent value is smaller than the bottom (FontMetricsInt: top=-151 ascent=-113 descent=49 bottom=38 leading=0)
- head: yMax:931, yMin:-251
- hhea: ascent:1000, descent:-300
- os_2 sTypoAscender:700, sTypoDescender:-300
- os_2 usWinAscent:1000, usWinDescent:300
si...@google.com <si...@google.com> #4
From the android's perspective: the value of sTypoAscender in the font being shorter than the yMax is the issue.
If I fix the sTypoAscender in the font to be the same as others (hhea.ascent; os_2 usWinAscent:1000) the font is centered correctly.
The change I did is
os_2 sTypoAscender:700 --> os_2 sTypoAscender:1000
si...@google.com <si...@google.com> #5
Here is a screenshot with line heightstyle trim.none, align.center (after the font update)
si...@google.com <si...@google.com>
ap...@google.com <ap...@google.com> #7
Branch: androidx-main
commit eea55e5a6d2f6e243dc0728403d293c79e5a9bda
Author: siyamed <siyamed@google.com>
Date: Mon Aug 01 10:53:31 2022
Make LineHeightStyle.Alignment constructor public
Some font ascent/descent/ymin/ymax values are not "correct".
for example ascent goes over ymax; or descent goes below ymin.
This CL makes the alignment constructor public so that fine tuning
for cases such as center is possible.
RelNote: "LineHeightStyle.Alignment constructor is now
public (experimental)"
Test: Existing tests already cover
Bug: 235876330
Change-Id: I4bbbe53b2088b9b211b86919c55bf6be88572baf
M compose/ui/ui-text/api/restricted_current.txt
M compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/style/LineHeightStyle.kt
M text/text/src/main/java/androidx/compose/ui/text/android/style/LineHeightStyleSpan.kt
M compose/ui/ui-text/api/public_plus_experimental_current.txt
M text/text/src/androidTest/java/androidx/compose/ui/text/android/TextLayoutTest.kt
M text/text/src/androidTest/java/androidx/compose/ui/text/android/style/LineHeightStyleSpanTest.kt
M compose/ui/ui-text/api/current.txt
M compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/SpannableExtensions.android.kt
ai...@gmail.com <ai...@gmail.com> #8
Thanks a lot for those changes. We will try to fix font with fontTools, but I think having Alignment constructor public still can be useful for fine tuning of the font
Description
We use a custom font (developed by 3rd party company) in our app, and we found that by using the recently introduced text style setting
includeFontPadding=false
we cannot center text properly (see the attached screenshot).Example:
More information in this thread:https://kotlinlang.slack.com/archives/CJLTWPH7S/p1654746582388999?thread_ts=1617664367.220300&cid=CJLTWPH7S