Showing
1 changed file
with
46 additions
and
13 deletions
@@ -272,8 +272,13 @@ class RichText extends Widget { | @@ -272,8 +272,13 @@ class RichText extends Widget { | ||
272 | 272 | ||
273 | final List<_Span> _spans = <_Span>[]; | 273 | final List<_Span> _spans = <_Span>[]; |
274 | 274 | ||
275 | - double _realignLine(List<_Span> spans, double totalWidth, double wordsWidth, | ||
276 | - bool last, double baseline) { | 275 | + double _realignLine( |
276 | + List<_Span> spans, | ||
277 | + double totalWidth, | ||
278 | + double wordsWidth, | ||
279 | + bool last, | ||
280 | + double baseline, | ||
281 | + ) { | ||
277 | double delta = 0; | 282 | double delta = 0; |
278 | switch (textAlign) { | 283 | switch (textAlign) { |
279 | case TextAlign.left: | 284 | case TextAlign.left: |
@@ -359,7 +364,8 @@ class RichText extends Widget { | @@ -359,7 +364,8 @@ class RichText extends Widget { | ||
359 | constraintWidth, | 364 | constraintWidth, |
360 | offsetX - space.advanceWidth * style.wordSpacing, | 365 | offsetX - space.advanceWidth * style.wordSpacing, |
361 | false, | 366 | false, |
362 | - bottom)); | 367 | + bottom, |
368 | + )); | ||
363 | 369 | ||
364 | lineStart += wCount; | 370 | lineStart += wCount; |
365 | 371 | ||
@@ -379,12 +385,21 @@ class RichText extends Widget { | @@ -379,12 +385,21 @@ class RichText extends Widget { | ||
379 | } | 385 | } |
380 | 386 | ||
381 | final double baseline = span.baseline * textScaleFactor; | 387 | final double baseline = span.baseline * textScaleFactor; |
382 | - top = | ||
383 | - math.min(top ?? metrics.top + baseline, metrics.top + baseline); | 388 | + top = math.min( |
389 | + top ?? metrics.top + baseline, | ||
390 | + metrics.top + baseline, | ||
391 | + ); | ||
384 | bottom = math.max( | 392 | bottom = math.max( |
385 | - bottom ?? metrics.bottom + baseline, metrics.bottom + baseline); | 393 | + bottom ?? metrics.bottom + baseline, |
394 | + metrics.bottom + baseline, | ||
395 | + ); | ||
386 | 396 | ||
387 | - final _Word wd = _Word(word, style, metrics, span.annotation); | 397 | + final _Word wd = _Word( |
398 | + word, | ||
399 | + style, | ||
400 | + metrics, | ||
401 | + span.annotation, | ||
402 | + ); | ||
388 | wd.offset = PdfPoint(offsetX, -offsetY + baseline); | 403 | wd.offset = PdfPoint(offsetX, -offsetY + baseline); |
389 | 404 | ||
390 | _spans.add(wd); | 405 | _spans.add(wd); |
@@ -401,7 +416,8 @@ class RichText extends Widget { | @@ -401,7 +416,8 @@ class RichText extends Widget { | ||
401 | constraintWidth, | 416 | constraintWidth, |
402 | offsetX - space.advanceWidth * style.wordSpacing, | 417 | offsetX - space.advanceWidth * style.wordSpacing, |
403 | false, | 418 | false, |
404 | - bottom)); | 419 | + bottom, |
420 | + )); | ||
405 | 421 | ||
406 | lineStart += wCount; | 422 | lineStart += wCount; |
407 | 423 | ||
@@ -433,13 +449,22 @@ class RichText extends Widget { | @@ -433,13 +449,22 @@ class RichText extends Widget { | ||
433 | double.infinity, | 449 | double.infinity, |
434 | style.fontSize * textScaleFactor, | 450 | style.fontSize * textScaleFactor, |
435 | ))); | 451 | ))); |
436 | - final _WidgetSpan ws = _WidgetSpan(span.child, style, span.annotation); | 452 | + final _WidgetSpan ws = _WidgetSpan( |
453 | + span.child, | ||
454 | + style, | ||
455 | + span.annotation, | ||
456 | + ); | ||
437 | 457 | ||
438 | if (offsetX + ws.width > constraintWidth && wCount > 0) { | 458 | if (offsetX + ws.width > constraintWidth && wCount > 0) { |
439 | width = math.max( | 459 | width = math.max( |
440 | width, | 460 | width, |
441 | - _realignLine(_spans.sublist(lineStart), constraintWidth, offsetX, | ||
442 | - false, bottom)); | 461 | + _realignLine( |
462 | + _spans.sublist(lineStart), | ||
463 | + constraintWidth, | ||
464 | + offsetX, | ||
465 | + false, | ||
466 | + bottom, | ||
467 | + )); | ||
443 | 468 | ||
444 | lineStart += wCount; | 469 | lineStart += wCount; |
445 | 470 | ||
@@ -460,7 +485,10 @@ class RichText extends Widget { | @@ -460,7 +485,10 @@ class RichText extends Widget { | ||
460 | 485 | ||
461 | final double baseline = span.baseline * textScaleFactor; | 486 | final double baseline = span.baseline * textScaleFactor; |
462 | top = math.min(top ?? baseline, baseline); | 487 | top = math.min(top ?? baseline, baseline); |
463 | - bottom = math.max(bottom ?? ws.height + baseline, ws.height + baseline); | 488 | + bottom = math.max( |
489 | + bottom ?? ws.height + baseline, | ||
490 | + ws.height + baseline, | ||
491 | + ); | ||
464 | 492 | ||
465 | ws.offset = PdfPoint(offsetX, -offsetY + baseline); | 493 | ws.offset = PdfPoint(offsetX, -offsetY + baseline); |
466 | _spans.add(ws); | 494 | _spans.add(ws); |
@@ -474,7 +502,12 @@ class RichText extends Widget { | @@ -474,7 +502,12 @@ class RichText extends Widget { | ||
474 | width = math.max( | 502 | width = math.max( |
475 | width, | 503 | width, |
476 | _realignLine( | 504 | _realignLine( |
477 | - _spans.sublist(lineStart), constraintWidth, offsetX, true, bottom)); | 505 | + _spans.sublist(lineStart), |
506 | + constraintWidth, | ||
507 | + offsetX, | ||
508 | + true, | ||
509 | + bottom, | ||
510 | + )); | ||
478 | 511 | ||
479 | bottom ??= 0.0; | 512 | bottom ??= 0.0; |
480 | top ??= 0.0; | 513 | top ??= 0.0; |
-
Please register or login to post a comment