@@ -195,6 +195,7 @@ public LineRange(int start, int end, int endExcludingWhitespace, int endIncludin
195
195
float _alphabeticBaseline ;
196
196
float _ideographicBaseline ;
197
197
float [ ] _lineHeights ;
198
+ int _lineCount ;
198
199
List < PaintRecord > _paintRecords = new List < PaintRecord > ( ) ;
199
200
List < CodeUnitRun > _codeUnitRuns = new List < CodeUnitRun > ( ) ;
200
201
bool _didExceedMaxLines ;
@@ -211,7 +212,13 @@ public LineRange(int start, int end, int endExcludingWhitespace, int endIncludin
211
212
const float kFloatDecorationSpacing = 3.0f ;
212
213
213
214
public float height {
214
- get { return this . _lineHeights ? . last ( ) ?? 0 ; }
215
+ get {
216
+ if ( this . _lineHeights == null ) {
217
+ return 0 ;
218
+ }
219
+
220
+ return this . _lineHeights [ this . getLineCount ( ) - 1 ] ;
221
+ }
215
222
}
216
223
217
224
public float minIntrinsicWidth {
@@ -524,6 +531,7 @@ void updateLineMetrics(FontMetrics metrics, float styleHeight) {
524
531
}
525
532
}
526
533
534
+ this . _lineCount = lineLimit ;
527
535
this . _maxIntrinsicWidth = 0 ;
528
536
float lineBlockWidth = 0 ;
529
537
for ( int i = 0 ; i < this . _lineWidths . Count ; ++ i ) {
@@ -675,7 +683,7 @@ internal PositionWithAffinity getGlyphPositionAtCoordinate(float dx, float dy) {
675
683
}
676
684
677
685
int yIndex ;
678
- for ( yIndex = 0 ; yIndex < this . _lineHeights . Length - 1 ; ++ yIndex ) {
686
+ for ( yIndex = 0 ; yIndex < this . getLineCount ( ) - 1 ; ++ yIndex ) {
679
687
if ( dy < this . _lineHeights [ yIndex ] ) {
680
688
break ;
681
689
}
@@ -758,7 +766,7 @@ internal Range<int> getWordBoundary(int offset) {
758
766
}
759
767
760
768
public int getLineCount ( ) {
761
- return this . _lineHeights ? . Length ?? 0 ;
769
+ return this . _lineCount ;
762
770
}
763
771
764
772
void _computeLineBreak ( ) {
0 commit comments