Skip to content

Commit 955d7d0

Browse files
committed
fix(ios): fixed autoFontSize computation when text can get bigger
1 parent 36390f1 commit 955d7d0

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

Diff for: src/label.ios.ts

+6-13
Original file line numberDiff line numberDiff line change
@@ -855,10 +855,8 @@ export class Label extends LabelBase {
855855
};
856856
size();
857857
if (expectSize.height > fixedHeight || expectSize.width > fixedWidth) {
858-
while (
859-
(expectSize.height > fixedHeight || expectSize.width > fixedWidth) &&
860-
expectFont.pointSize > (this.minFontSize || 12)
861-
) {
858+
const minFontSize = this.minFontSize || 12;
859+
while ((expectSize.height > fixedHeight || expectSize.width > fixedWidth) && expectFont.pointSize > minFontSize) {
862860
const newFont = expectFont.fontWithSize(expectFont.pointSize - stepSize);
863861
updateFontSize(newFont);
864862
size();
@@ -873,21 +871,16 @@ export class Label extends LabelBase {
873871
}
874872
}
875873
} else {
876-
while (
877-
(expectSize.height < fixedHeight || expectSize.width < fixedWidth) &&
878-
expectFont.pointSize < (this.maxFontSize || 200)
879-
) {
874+
const maxFontSize = this.maxFontSize || 200;
875+
while (expectSize.height < fixedHeight && expectSize.width < fixedWidth && expectFont.pointSize < maxFontSize) {
880876
const newFont = expectFont.fontWithSize(expectFont.pointSize + stepSize);
881877
updateFontSize(newFont);
882-
883878
size();
884-
885-
if (expectSize.height <= fixedHeight || expectSize.width <= fixedWidth) {
879+
if (expectSize.height <= fixedHeight && expectSize.width <= fixedWidth) {
886880
expectFont = newFont;
887881
} else {
888-
expectFont = newFont;
889882
if (!this.formattedText && !this.html) {
890-
textView.font = newFont;
883+
textView.font = expectFont;
891884
}
892885
break;
893886
}

0 commit comments

Comments
 (0)