Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 99deb24

Browse files
author
Yuncong Zhang
committed
Fix line height issue.
1 parent 25e63a0 commit 99deb24

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Runtime/ui/txt/paragraph.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ public LineRange(int start, int end, int endExcludingWhitespace, int endIncludin
195195
float _alphabeticBaseline;
196196
float _ideographicBaseline;
197197
float[] _lineHeights;
198+
int _lineCount;
198199
List<PaintRecord> _paintRecords = new List<PaintRecord>();
199200
List<CodeUnitRun> _codeUnitRuns = new List<CodeUnitRun>();
200201
bool _didExceedMaxLines;
@@ -211,7 +212,13 @@ public LineRange(int start, int end, int endExcludingWhitespace, int endIncludin
211212
const float kFloatDecorationSpacing = 3.0f;
212213

213214
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+
}
215222
}
216223

217224
public float minIntrinsicWidth {
@@ -524,6 +531,7 @@ void updateLineMetrics(FontMetrics metrics, float styleHeight) {
524531
}
525532
}
526533

534+
this._lineCount = lineLimit;
527535
this._maxIntrinsicWidth = 0;
528536
float lineBlockWidth = 0;
529537
for (int i = 0; i < this._lineWidths.Count; ++i) {
@@ -675,7 +683,7 @@ internal PositionWithAffinity getGlyphPositionAtCoordinate(float dx, float dy) {
675683
}
676684

677685
int yIndex;
678-
for (yIndex = 0; yIndex < this._lineHeights.Length - 1; ++yIndex) {
686+
for (yIndex = 0; yIndex < this.getLineCount() - 1; ++yIndex) {
679687
if (dy < this._lineHeights[yIndex]) {
680688
break;
681689
}
@@ -758,7 +766,7 @@ internal Range<int> getWordBoundary(int offset) {
758766
}
759767

760768
public int getLineCount() {
761-
return this._lineHeights?.Length ?? 0;
769+
return this._lineCount;
762770
}
763771

764772
void _computeLineBreak() {

0 commit comments

Comments
 (0)