From 9f1deda220a4fab64836d99e4af2d634a5decfea Mon Sep 17 00:00:00 2001 From: Rashad Sookram Date: Thu, 17 Feb 2022 12:09:41 -0500 Subject: [PATCH] Fix unintended line break with default font scale. --- .../securesms/components/emoji/EmojiTextView.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/emoji/EmojiTextView.java b/app/src/main/java/org/thoughtcrime/securesms/components/emoji/EmojiTextView.java index c2604ed04..207c07247 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/emoji/EmojiTextView.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/emoji/EmojiTextView.java @@ -186,16 +186,16 @@ public class EmojiTextView extends AppCompatTextView { } /** - * Starting from API 30, there can be a rounding error in text layout when a non-default font - * scale is used. This causes a line break to be inserted where there shouldn't be one. Force the - * width to be larger to work around this problem. + * Starting from API 30, there can be a rounding error in text layout when a non-zero letter + * spacing is used. This causes a line break to be inserted where there shouldn't be one. Force + * the width to be larger to work around this problem. * https://issuetracker.google.com/issues/173574230 * * @param widthMeasureSpec the original measure spec passed to {@link #onMeasure(int, int)} * @return the measure spec with the workaround, or the original one. */ private int applyWidthMeasureRoundingFix(int widthMeasureSpec) { - if (Build.VERSION.SDK_INT >= 30 && Math.abs(getResources().getConfiguration().fontScale - 1f) > 0.01f) { + if (Build.VERSION.SDK_INT >= 30 && getLetterSpacing() > 0) { CharSequence text = getText(); if (text != null) { int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);