-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sets default maximum font size for emoji to 112sp #206
Sets default maximum font size for emoji to 112sp #206
Conversation
You can test the changes on this Pull Request by downloading the APK here. |
@@ -413,11 +413,10 @@ class PhotoEditor private constructor(builder: Builder) : | |||
} | |||
txtTextEmoji.gravity = Gravity.CENTER | |||
txtTextEmoji.setLayerType(View.LAYER_TYPE_SOFTWARE, null) | |||
val maxHeight = parentView.height | |||
rootView.tvPhotoEditorText.textSize = | |||
txtTextEmoji.textSize = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A note on this: we're setting the maximum on the TextView's textSize
given internally the maximum
is also set there. To double check, see here:
override fun setTextSize(size: Float) {
maxTextSize = size
adjustTextSize()
}
and here (init block):
init {
// using the minimal recommended font size
minTextSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12f, resources.displayMetrics)
maxTextSize = textSize
For some other reasons, I'm considering probably forking the source code and reusing it, if I we end up doing that then it's probably better to make the intent explicit (with a setMaxSize()
kind of method).
@mzorz maybe I'm misunderstanding what should be working by this PR, but on my Pixel 3 (physical) and a API29 Pixel 3XL emulator, the emoji disappears once zoomed into a little. It's still there and you can make it come back by zooming out at the right place, but it seems that was supposed to have been fixed by this PR. Could you check on a 3XL emulator and confirm? Can get you a video too. |
…are layer indicator for TextView
Following our conversation over Slack, moving salient points here to keep track of it. From empirical testing on various devices and emulators with different maximum values for So I think all we can hope for is, in case this doesn't work to have a smaller maximum and then use scaling just as we were doing, but this way we should be gaining some quality regardless. In the meantime, as per my tests and following Also worth noting, the plan is to enable View's Let's test a few more and then lower the maximum if needed 👍 |
Per our conversation, this works okay ignoring the issue with the low maximum size and the strange movement behavior at max size that we already talked about and will get resolved in another PR. I did notice the default size for text was also really small now, but from testing later branches this seems to get resolved later. |
Thanks for the review! 🙇
That's right, handled in #210 |
Fixes #205
Builds on top of #204.
Inspired by
TextView
's source code here and here:this PR sets a default maximum
fontSize
of112sp
as well for emojis, given otherwise at some point these can't be rendered anymore with the error described in issue #205.Given I haven't found a way to obtain the Font Family's maximum supported font size, or even calculate this on runtime (*), I think going with
TextView
's own defaults is conservative enough as to avoid having other problems.To test:
Note: have in mind the current listener on this branch doens't support rotation or view scaling (it only changes the view's width/height to provoke
fontSize
to change accordingly). This means, rotating will not work on this branch, and that's expected.(*)EDIT also note that I've tried other approaches for calculating the maximum renderable font size, for example using the approach described here but it still fails given the error looks to be a runtime problem related to rendering on the screen rather than figuring out supported font sizes for a given font. In fact, for the algorithm run there I also get 256.0 as per the maximum renderable fontSize. Code changes with this test can be seen here on branch
issue/205-emoji-max-text-size-calculation