Skip to content

Commit 3b2d541

Browse files
genkikondofacebook-github-bot
authored andcommitted
Set textBreakStrategy default to be HighQuality
Summary: Android TextView's default for breakStrategy is BREAK_STRATEGY_HIGH_QUALITY (https://developer.android.com/reference/android/widget/TextView#setBreakStrategy(int)) RN docs also states that highQuality is default. However, on Fabric, the default is 'simple'. This diff fixes the default to be 'highQuality' Changelog: [Android][Fixed] - Set textBreakStrategy default to be 'highQuality' Reviewed By: JoshuaGross Differential Revision: D30597085 fbshipit-source-id: 3bd7531afdaf980b342cc461dd449c3d3df12cb0
1 parent 4ac42d8 commit 3b2d541

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ SharedDebugStringConvertibleList ParagraphAttributes::getDebugProps() const {
5151
debugStringConvertibleItem("maximumFontSize", maximumFontSize),
5252
debugStringConvertibleItem("includeFontPadding", includeFontPadding),
5353
debugStringConvertibleItem(
54-
"android_hyphenationFrequency",
55-
android_hyphenationFrequency)};
54+
"android_hyphenationFrequency", android_hyphenationFrequency)};
5655
}
5756
#endif
5857

ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ParagraphAttributes : public DebugStringConvertible {
4545
/*
4646
* (Android only) Break strategy for breaking paragraphs into lines.
4747
*/
48-
TextBreakStrategy textBreakStrategy{};
48+
TextBreakStrategy textBreakStrategy{TextBreakStrategy::HighQuality};
4949

5050
/*
5151
* Enables font size adjustment to fit constrained boundaries.
@@ -59,7 +59,8 @@ class ParagraphAttributes : public DebugStringConvertible {
5959
bool includeFontPadding{true};
6060

6161
/*
62-
* (Android only) Frequency of automatic hyphenation to use when determining word breaks.
62+
* (Android only) Frequency of automatic hyphenation to use when determining
63+
* word breaks.
6364
*/
6465
HyphenationFrequency android_hyphenationFrequency{};
6566

ReactCommon/react/renderer/attributedstring/conversions.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ inline std::string toString(const TextBreakStrategy &textBreakStrategy) {
9696

9797
LOG(ERROR) << "Unsupported TextBreakStrategy value";
9898
react_native_assert(false);
99-
return "simple";
99+
return "highQuality";
100100
}
101101

102102
inline void fromRawValue(
@@ -116,14 +116,14 @@ inline void fromRawValue(
116116
// sane default
117117
LOG(ERROR) << "Unsupported TextBreakStrategy value: " << string;
118118
react_native_assert(false);
119-
result = TextBreakStrategy::Simple;
119+
result = TextBreakStrategy::HighQuality;
120120
}
121121
return;
122122
}
123123

124124
LOG(ERROR) << "Unsupported TextBreakStrategy type";
125125
react_native_assert(false);
126-
result = TextBreakStrategy::Simple;
126+
result = TextBreakStrategy::HighQuality;
127127
}
128128

129129
inline void fromRawValue(

ReactCommon/react/renderer/attributedstring/primitives.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ enum class EllipsizeMode {
5555

5656
enum class TextBreakStrategy {
5757
Simple, // Simple strategy.
58-
Balanced, // Balances line lengths.
59-
HighQuality // High-quality strategy, including hyphenation.
58+
HighQuality, // High-quality strategy, including hyphenation.
59+
Balanced // Balances line lengths.
6060
};
6161

6262
enum class TextAlignment {

0 commit comments

Comments
 (0)