@@ -368,15 +368,16 @@ export class Label extends LabelBase {
368
368
return inset ;
369
369
}
370
370
371
- _requestLayoutOnTextChanged ( ) : void {
371
+ _requestLayoutOnTextChanged ( ) {
372
372
if ( this . mFixedSize === FixedSize . BOTH ) {
373
- return ;
373
+ return false ;
374
374
}
375
375
if ( this . mFixedSize === FixedSize . WIDTH && ! this . textWrap && this . getMeasuredHeight ( ) > 0 ) {
376
376
// Single line label with fixed width will skip request layout on text change.
377
- return ;
377
+ return false ;
378
378
}
379
379
super . _requestLayoutOnTextChanged ( ) ;
380
+ return true ;
380
381
}
381
382
382
383
private _measureNativeView (
@@ -414,6 +415,11 @@ export class Label extends LabelBase {
414
415
415
416
const height = Utils . layout . getMeasureSpecSize ( heightMeasureSpec ) ;
416
417
const heightMode = Utils . layout . getMeasureSpecMode ( heightMeasureSpec ) ;
418
+
419
+ this . mFixedSize =
420
+ ( widthMode === Utils . layout . EXACTLY ? FixedSize . WIDTH : FixedSize . NONE ) |
421
+ ( heightMode === Utils . layout . EXACTLY ? FixedSize . HEIGHT : FixedSize . NONE ) ;
422
+
417
423
let resetFont ;
418
424
// reset insent or it will taken into account for measurement
419
425
if ( this . autoFontSize ) {
@@ -727,11 +733,10 @@ export class Label extends LabelBase {
727
733
}
728
734
// no need to update veticalAlignment or autoSize as we ask for a layout
729
735
// will be done in onMeasure and onLayout
730
- // this.updateVerticalAlignment();
731
- // if (this.autoFontSize) {
732
- // this.updateAutoFontSize({ textView: this.nativeTextViewProtected, force: true });
733
- // }
734
- this . _requestLayoutOnTextChanged ( ) ;
736
+
737
+ if ( ! this . _requestLayoutOnTextChanged ( ) && this . autoFontSize ) {
738
+ this . updateAutoFontSize ( { textView : this . nativeTextViewProtected , force : true } ) ;
739
+ }
735
740
}
736
741
737
742
setTextDecorationAndTransform ( ) {
@@ -917,8 +922,8 @@ export class Label extends LabelBase {
917
922
return currentFont ;
918
923
}
919
924
const textViewSize = NSLabelUtils . insetWithRectUIEdgeInsets ( textView . bounds , textView . padding ) . size ;
920
- const fixedWidth = Math . floor ( width !== undefined ? width : textViewSize . width ) ;
921
- const fixedHeight = Math . floor ( height !== undefined ? height : textViewSize . height ) ;
925
+ const fixedWidth = Math . ceil ( width !== undefined ? width : textViewSize . width ) ;
926
+ const fixedHeight = Math . ceil ( height !== undefined ? height : textViewSize . height ) ;
922
927
if ( fixedWidth === 0 || fixedHeight === 0 ) {
923
928
return currentFont ;
924
929
}
@@ -992,8 +997,9 @@ export class Label extends LabelBase {
992
997
if ( ! onlyMeasure ) {
993
998
this . fontSizeRatio = expectFont . pointSize / fontSize ;
994
999
}
995
-
996
- this . updateVerticalAlignment ( ) ;
1000
+ if ( ! onlyMeasure ) {
1001
+ this . updateVerticalAlignment ( ) ;
1002
+ }
997
1003
}
998
1004
return currentFont ;
999
1005
}
0 commit comments