Skip to content

Commit

Permalink
Set textBreakStrategy default to be HighQuality
Browse files Browse the repository at this point in the history
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
  • Loading branch information
genkikondo authored and facebook-github-bot committed Aug 27, 2021
1 parent 4ac42d8 commit 3b2d541
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ SharedDebugStringConvertibleList ParagraphAttributes::getDebugProps() const {
debugStringConvertibleItem("maximumFontSize", maximumFontSize),
debugStringConvertibleItem("includeFontPadding", includeFontPadding),
debugStringConvertibleItem(
"android_hyphenationFrequency",
android_hyphenationFrequency)};
"android_hyphenationFrequency", android_hyphenationFrequency)};
}
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ParagraphAttributes : public DebugStringConvertible {
/*
* (Android only) Break strategy for breaking paragraphs into lines.
*/
TextBreakStrategy textBreakStrategy{};
TextBreakStrategy textBreakStrategy{TextBreakStrategy::HighQuality};

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

/*
* (Android only) Frequency of automatic hyphenation to use when determining word breaks.
* (Android only) Frequency of automatic hyphenation to use when determining
* word breaks.
*/
HyphenationFrequency android_hyphenationFrequency{};

Expand Down
6 changes: 3 additions & 3 deletions ReactCommon/react/renderer/attributedstring/conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ inline std::string toString(const TextBreakStrategy &textBreakStrategy) {

LOG(ERROR) << "Unsupported TextBreakStrategy value";
react_native_assert(false);
return "simple";
return "highQuality";
}

inline void fromRawValue(
Expand All @@ -116,14 +116,14 @@ inline void fromRawValue(
// sane default
LOG(ERROR) << "Unsupported TextBreakStrategy value: " << string;
react_native_assert(false);
result = TextBreakStrategy::Simple;
result = TextBreakStrategy::HighQuality;
}
return;
}

LOG(ERROR) << "Unsupported TextBreakStrategy type";
react_native_assert(false);
result = TextBreakStrategy::Simple;
result = TextBreakStrategy::HighQuality;
}

inline void fromRawValue(
Expand Down
4 changes: 2 additions & 2 deletions ReactCommon/react/renderer/attributedstring/primitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ enum class EllipsizeMode {

enum class TextBreakStrategy {
Simple, // Simple strategy.
Balanced, // Balances line lengths.
HighQuality // High-quality strategy, including hyphenation.
HighQuality, // High-quality strategy, including hyphenation.
Balanced // Balances line lengths.
};

enum class TextAlignment {
Expand Down

0 comments on commit 3b2d541

Please sign in to comment.