Skip to content

Commit 4d74df2

Browse files
Remove the unused maximumFontSize paragraph attribute
1 parent 9038350 commit 4d74df2

19 files changed

Lines changed: 21 additions & 60 deletions

File tree

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ internal object TextLayoutManager {
9494
const val PA_KEY_INCLUDE_FONT_PADDING: Int = 4
9595
const val PA_KEY_HYPHENATION_FREQUENCY: Int = 5
9696
const val PA_KEY_MINIMUM_FONT_SIZE: Int = 6
97-
const val PA_KEY_MAXIMUM_FONT_SIZE: Int = 7
9897
const val PA_KEY_TEXT_ALIGN_VERTICAL: Int = 8
9998
const val PA_KEY_TEXT_WIDTH_MODE: Int = 9
10099

‎packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ bool ParagraphAttributes::operator==(const ParagraphAttributes& rhs) const {
3434
rhs.android_hyphenationFrequency,
3535
rhs.textAlignVertical) &&
3636
floatEquality(minimumFontSize, rhs.minimumFontSize) &&
37-
floatEquality(maximumFontSize, rhs.maximumFontSize) &&
3837
floatEquality(minimumFontScale, rhs.minimumFontScale);
3938
}
4039

@@ -64,10 +63,6 @@ SharedDebugStringConvertibleList ParagraphAttributes::getDebugProps() const {
6463
"minimumFontSize",
6564
minimumFontSize,
6665
paragraphAttributes.minimumFontSize),
67-
debugStringConvertibleItem(
68-
"maximumFontSize",
69-
maximumFontSize,
70-
paragraphAttributes.maximumFontSize),
7166
debugStringConvertibleItem(
7267
"includeFontPadding",
7368
includeFontPadding,

‎packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,9 @@ class ParagraphAttributes : public DebugStringConvertible {
6868
HyphenationFrequency android_hyphenationFrequency{};
6969

7070
/*
71-
* In case of font size adjustment enabled, defines minimum and maximum
72-
* font sizes.
71+
* In case of font size adjustment enabled, defines the minimum font size.
7372
*/
7473
Float minimumFontSize{std::numeric_limits<Float>::quiet_NaN()};
75-
Float maximumFontSize{std::numeric_limits<Float>::quiet_NaN()};
7674

7775
/*
7876
* Specifies the smallest possible scale a font can reach when
@@ -110,7 +108,6 @@ struct hash<facebook::react::ParagraphAttributes> {
110108
attributes.textWidthMode,
111109
attributes.adjustsFontSizeToFit,
112110
attributes.minimumFontSize,
113-
attributes.maximumFontSize,
114111
attributes.includeFontPadding,
115112
attributes.android_hyphenationFrequency,
116113
attributes.minimumFontScale,

‎packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,12 +1091,6 @@ inline ParagraphAttributes convertRawProp(
10911091
"minimumFontSize",
10921092
sourceParagraphAttributes.minimumFontSize,
10931093
defaultParagraphAttributes.minimumFontSize);
1094-
paragraphAttributes.maximumFontSize = convertRawProp(
1095-
context,
1096-
rawProps,
1097-
"maximumFontSize",
1098-
sourceParagraphAttributes.maximumFontSize,
1099-
defaultParagraphAttributes.maximumFontSize);
11001094
paragraphAttributes.includeFontPadding = convertRawProp(
11011095
context,
11021096
rawProps,
@@ -1200,7 +1194,6 @@ constexpr static MapBuffer::Key PA_KEY_ADJUST_FONT_SIZE_TO_FIT = 3;
12001194
constexpr static MapBuffer::Key PA_KEY_INCLUDE_FONT_PADDING = 4;
12011195
constexpr static MapBuffer::Key PA_KEY_HYPHENATION_FREQUENCY = 5;
12021196
constexpr static MapBuffer::Key PA_KEY_MINIMUM_FONT_SIZE = 6;
1203-
constexpr static MapBuffer::Key PA_KEY_MAXIMUM_FONT_SIZE = 7;
12041197
constexpr static MapBuffer::Key PA_KEY_TEXT_ALIGN_VERTICAL = 8;
12051198
constexpr static MapBuffer::Key PA_KEY_TEXT_WIDTH_MODE = 9;
12061199

@@ -1218,7 +1211,6 @@ inline MapBuffer toMapBuffer(const ParagraphAttributes &paragraphAttributes)
12181211
builder.putString(PA_KEY_TEXT_ALIGN_VERTICAL, toString(*paragraphAttributes.textAlignVertical));
12191212
}
12201213
builder.putDouble(PA_KEY_MINIMUM_FONT_SIZE, paragraphAttributes.minimumFontSize);
1221-
builder.putDouble(PA_KEY_MAXIMUM_FONT_SIZE, paragraphAttributes.maximumFontSize);
12221214

12231215
return builder.build();
12241216
}

‎packages/react-native/ReactCommon/react/renderer/attributedstring/tests/ParagraphAttributesTest.cpp‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace facebook::react {
1313

14-
// The three Float fields default to NaN, and NaN != NaN under IEEE-754.
14+
// The two Float fields default to NaN, and NaN != NaN under IEEE-754.
1515
// operator== must special-case NaN via floatEquality so two freshly
1616
// default-constructed ParagraphAttributes compare equal.
1717
TEST(
@@ -31,12 +31,10 @@ TEST(
3131
testOperatorEqualsFloatFieldsUseEpsilonComparison) {
3232
ParagraphAttributes a{};
3333
a.minimumFontSize = 12.0f;
34-
a.maximumFontSize = 48.0f;
3534
a.minimumFontScale = 0.5f;
3635
auto b = a;
3736

3837
b.minimumFontSize = a.minimumFontSize + 0.001f;
39-
b.maximumFontSize = a.maximumFontSize + 0.001f;
4038
b.minimumFontScale = a.minimumFontScale + 0.001f;
4139
EXPECT_TRUE(a == b);
4240

@@ -46,8 +44,8 @@ TEST(
4644
}
4745

4846
// floatEquality returns true only when *both* operands are NaN or when
49-
// *neither* is. A NaN-vs-finite mismatch in any of the three float fields
50-
// must therefore make the instances unequal, even though both operands are
47+
// *neither* is. A NaN-vs-finite mismatch in either float field must
48+
// therefore make the instances unequal, even though both operands are
5149
// "invalid" font sizes.
5250
TEST(
5351
ParagraphAttributesTest,

‎packages/react-native/ReactCommon/react/renderer/components/text/BaseParagraphProps.cpp‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,6 @@ void BaseParagraphProps::setProp(
104104
paragraphAttributes,
105105
minimumFontSize,
106106
"minimumFontSize");
107-
REBUILD_FIELD_SWITCH_CASE(
108-
paDefaults,
109-
value,
110-
paragraphAttributes,
111-
maximumFontSize,
112-
"maximumFontSize");
113107
REBUILD_FIELD_SWITCH_CASE(
114108
paDefaults,
115109
value,

‎packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/HostPlatformParagraphProps.cpp‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,6 @@ folly::dynamic HostPlatformParagraphProps::getDiffProps(
128128
result["minimumFontSize"] = paragraphAttributes.minimumFontSize;
129129
}
130130

131-
if (!floatEquality(
132-
paragraphAttributes.maximumFontSize,
133-
oldProps->paragraphAttributes.maximumFontSize)) {
134-
result["maximumFontSize"] = paragraphAttributes.maximumFontSize;
135-
}
136-
137131
if (paragraphAttributes.includeFontPadding !=
138132
oldProps->paragraphAttributes.includeFontPadding) {
139133
result["includeFontPadding"] = paragraphAttributes.includeFontPadding;

‎packages/react-native/ReactCommon/react/renderer/components/textinput/BaseTextInputProps.cpp‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,6 @@ void BaseTextInputProps::setProp(
179179
paragraphAttributes,
180180
minimumFontSize,
181181
"minimumFontSize");
182-
REBUILD_FIELD_SWITCH_CASE(
183-
paDefaults,
184-
value,
185-
paragraphAttributes,
186-
maximumFontSize,
187-
"maximumFontSize");
188182
REBUILD_FIELD_SWITCH_CASE(
189183
paDefaults,
190184
value,

‎packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,12 +395,6 @@ folly::dynamic AndroidTextInputProps::getDiffProps(
395395
result["minimumFontSize"] = paragraphAttributes.minimumFontSize;
396396
}
397397

398-
if (!floatEquality(
399-
paragraphAttributes.maximumFontSize,
400-
oldProps->paragraphAttributes.maximumFontSize)) {
401-
result["maximumFontSize"] = paragraphAttributes.maximumFontSize;
402-
}
403-
404398
if (paragraphAttributes.includeFontPadding !=
405399
oldProps->paragraphAttributes.includeFontPadding) {
406400
result["includeFontPadding"] = paragraphAttributes.includeFontPadding;

‎packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,22 @@ - (LinesMeasurements)getLinesForAttributedString:(facebook::react::AttributedStr
415415
return paragraphLines;
416416
}
417417

418+
- (CGFloat)_maximumFontSizeInAttributedString:(NSAttributedString *)attributedString
419+
{
420+
__block CGFloat maximumFontSize = 0.0;
421+
[attributedString enumerateAttribute:NSFontAttributeName
422+
inRange:NSMakeRange(0, attributedString.length)
423+
options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired
424+
usingBlock:^(id _Nullable value, NSRange range, BOOL *_Nonnull stop) {
425+
CGFloat fontSize = ((UIFont *)value).pointSize;
426+
if (fontSize > maximumFontSize) {
427+
maximumFontSize = fontSize;
428+
}
429+
}];
430+
431+
return maximumFontSize;
432+
}
433+
418434
- (NSTextStorage *)_textStorageAndLayoutManagerWithAttributesString:(NSAttributedString *)attributedString
419435
paragraphAttributes:(ParagraphAttributes)paragraphAttributes
420436
size:(CGSize)size
@@ -439,7 +455,7 @@ - (NSTextStorage *)_textStorageAndLayoutManagerWithAttributesString:(NSAttribute
439455

440456
if (paragraphAttributes.adjustsFontSizeToFit) {
441457
CGFloat minimumFontSize = !isnan(paragraphAttributes.minimumFontSize) ? paragraphAttributes.minimumFontSize : 4.0;
442-
CGFloat maximumFontSize = !isnan(paragraphAttributes.maximumFontSize) ? paragraphAttributes.maximumFontSize : 96.0;
458+
CGFloat maximumFontSize = [self _maximumFontSizeInAttributedString:attributedString];
443459
[textStorage scaleFontSizeToFitSize:size minimumFontSize:minimumFontSize maximumFontSize:maximumFontSize];
444460
}
445461

0 commit comments

Comments
 (0)