You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement adjustsFontSizeToFit property for Text in Fabric (#14519)
* Implementation of adjustFontSizeToFit
* Final Changes using TextLayout
* Lint Issue Fixes
* Change files
* prop change detection added
* review Changes and E2E test cases added
* Lint and Format Changes added
* Test Cases Fix added
* Update SnapShot
* Removed the additional Check for resizing Font
* Updated SnapShot
* Review Changes
* Lint and Format Changes
---------
Co-authored-by: Vineeth K <[email protected]>
Copy file name to clipboardExpand all lines: packages/@react-native-windows/tester/src/js/examples/Text/TextExample.windows.js
+70Lines changed: 70 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1926,6 +1926,76 @@ const examples = [
1926
1926
);
1927
1927
},
1928
1928
},
1929
+
{
1930
+
title: 'AdjustFontSize according to the Width, Height and LinesCount',
1931
+
name: 'adjustFontSizeToFit',
1932
+
render: function(): React.Node{
1933
+
return(
1934
+
<View>
1935
+
<RNTesterText
1936
+
style={{
1937
+
width: 500,
1938
+
height: 100,
1939
+
fontSize: 20,
1940
+
backgroundColor: 'lightcoral',
1941
+
padding: 10,
1942
+
marginBottom: 10,
1943
+
}}
1944
+
testID="text-adjustfontsizetofit-default-a">
1945
+
{`Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore Ut enim ad minim veniam.With AdjustFontSize width: 800, height: 100, fontSize: 20`}
1946
+
</RNTesterText>
1947
+
<RNTesterText
1948
+
adjustsFontSizeToFit
1949
+
style={{
1950
+
width: 500,
1951
+
height: 100,
1952
+
fontSize: 20,
1953
+
backgroundColor: 'lightcoral',
1954
+
padding: 10,
1955
+
marginBottom: 10,
1956
+
}}
1957
+
testID="text-adjustfontsizetofit-default-b">
1958
+
{`Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore Ut enim ad minim veniam.With AdjustFontSize width: 800, height: 100, fontSize: 20`}
1959
+
</RNTesterText>
1960
+
{[
1961
+
{width: 500,height: 80,lineCount: 3},
1962
+
{width: 475,height: 120,lineCount: 5},
1963
+
{width: 450,height: 160,lineCount: 0},
1964
+
].map((item,index)=>(
1965
+
<React.Fragmentkey={index}>
1966
+
<RNTesterText
1967
+
testID={`text-adjustfontsizetofit-${index}-a`}
1968
+
numberOfLines={item.lineCount}
1969
+
adjustsFontSizeToFit
1970
+
style={{
1971
+
width: item.width,
1972
+
height: item.height,
1973
+
fontSize: 40,
1974
+
backgroundColor: '#A0C782',
1975
+
padding: 10,
1976
+
marginBottom: 10,
1977
+
}}>
1978
+
{`Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore. With AdjustFontSize height:${item.height},width:${item.width},lineCount:${item.lineCount},fontSize:40`}
1979
+
</RNTesterText>
1980
+
<RNTesterText
1981
+
testID={`text-adjustfontsizetofit-${index}-b`}
1982
+
numberOfLines={item.lineCount}
1983
+
style={{
1984
+
width: item.width,
1985
+
height: item.height,
1986
+
fontSize: 40,
1987
+
backgroundColor: 'lightblue',
1988
+
padding: 10,
1989
+
marginBottom: 10,
1990
+
}}>
1991
+
{`Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore. Without AdjustFontSize height:${item.height},width:${item.width},lineCount:${item.lineCount},fontSize:40`}
Copy file name to clipboardExpand all lines: packages/e2e-test-app-fabric/test/__snapshots__/TextComponentTest.test.ts.snap
+192Lines changed: 192 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,198 @@ exports[`Text Tests Padding can be added to Text 1`] = `
24
24
}
25
25
`;
26
26
27
+
exports[`Text Tests Text can adjust its fontsize according to its limitations, case 0 a 1`] =`
28
+
{
29
+
"Automation Tree": {
30
+
"AutomationId": "text-adjustfontsizetofit-0-a",
31
+
"ControlType": 50020,
32
+
"LocalizedControlType": "text",
33
+
"Name": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore. With AdjustFontSize height:80,width:500,lineCount:3,fontSize:40",
34
+
"TextRangePattern.GetText": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore. With AdjustFontSize height:80,width:500,lineCount:3,fontSize:40",
exports[`Text Tests Text can adjust its fontsize according to its limitations, case 0 b 1`] =`
52
+
{
53
+
"Automation Tree": {
54
+
"AutomationId": "text-adjustfontsizetofit-0-b",
55
+
"ControlType": 50020,
56
+
"LocalizedControlType": "text",
57
+
"Name": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore. Without AdjustFontSize height:80,width:500,lineCount:3,fontSize:40",
58
+
"TextRangePattern.GetText": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore. Without AdjustFontSize height:80,width:500,lineCount:3,fontSize:40",
exports[`Text Tests Text can adjust its fontsize according to its limitations, case 1 a 1`] =`
76
+
{
77
+
"Automation Tree": {
78
+
"AutomationId": "text-adjustfontsizetofit-1-a",
79
+
"ControlType": 50020,
80
+
"LocalizedControlType": "text",
81
+
"Name": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore. With AdjustFontSize height:120,width:475,lineCount:5,fontSize:40",
82
+
"TextRangePattern.GetText": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore. With AdjustFontSize height:120,width:475,lineCount:5,fontSize:40",
exports[`Text Tests Text can adjust its fontsize according to its limitations, case 1 b 1`] =`
100
+
{
101
+
"Automation Tree": {
102
+
"AutomationId": "text-adjustfontsizetofit-1-b",
103
+
"ControlType": 50020,
104
+
"LocalizedControlType": "text",
105
+
"Name": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore. Without AdjustFontSize height:120,width:475,lineCount:5,fontSize:40",
106
+
"TextRangePattern.GetText": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore. Without AdjustFontSize height:120,width:475,lineCount:5,fontSize:40",
exports[`Text Tests Text can adjust its fontsize according to its limitations, case 2 a 1`] =`
124
+
{
125
+
"Automation Tree": {
126
+
"AutomationId": "text-adjustfontsizetofit-2-a",
127
+
"ControlType": 50020,
128
+
"LocalizedControlType": "text",
129
+
"Name": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore. With AdjustFontSize height:160,width:450,lineCount:0,fontSize:40",
130
+
"TextRangePattern.GetText": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore. With AdjustFontSize height:160,width:450,lineCount:0,fontSize:40",
exports[`Text Tests Text can adjust its fontsize according to its limitations, case 2 b 1`] =`
148
+
{
149
+
"Automation Tree": {
150
+
"AutomationId": "text-adjustfontsizetofit-2-b",
151
+
"ControlType": 50020,
152
+
"LocalizedControlType": "text",
153
+
"Name": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore. Without AdjustFontSize height:160,width:450,lineCount:0,fontSize:40",
154
+
"TextRangePattern.GetText": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore. Without AdjustFontSize height:160,width:450,lineCount:0,fontSize:40",
"Name": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore Ut enim ad minim veniam.With AdjustFontSize width: 800, height: 100, fontSize: 20",
178
+
"TextRangePattern.GetText": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore Ut enim ad minim veniam.With AdjustFontSize width: 800, height: 100, fontSize: 20",
"Name": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore Ut enim ad minim veniam.With AdjustFontSize width: 800, height: 100, fontSize: 20",
202
+
"TextRangePattern.GetText": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore Ut enim ad minim veniam.With AdjustFontSize width: 800, height: 100, fontSize: 20",
0 commit comments