mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Update the ui.LineMetrics.height metric to be more useful to external users (#11456)
This commit is contained in:
parent
6f8565044d
commit
13ece5c7fc
@ -1641,7 +1641,9 @@ class LineMetrics {
|
||||
|
||||
/// Total height of the line from the top edge to the bottom edge.
|
||||
///
|
||||
/// This is equivalent to `ascent + descent`
|
||||
/// This is equivalent to `round(ascent + descent)`. This value is provided
|
||||
/// separately due to rounding causing sub-pixel differences from the unrounded
|
||||
/// values.
|
||||
final double height;
|
||||
|
||||
/// Width of the line from the left edge of the leftmost glyph to the right
|
||||
@ -1661,6 +1663,9 @@ class LineMetrics {
|
||||
final double left;
|
||||
|
||||
/// The y coordinate of the baseline for this line from the top of the paragraph.
|
||||
///
|
||||
/// The bottom edge of the paragraph up to and including this line may be obtained
|
||||
/// through `baseline + descent`.
|
||||
final double baseline;
|
||||
|
||||
/// The number of this line in the overall paragraph, with the first line being
|
||||
|
||||
@ -31,10 +31,13 @@ Dart_Handle DartConverter<flutter::LineMetrics>::ToDart(
|
||||
|
||||
Dart_Handle argv[argc] = {
|
||||
tonic::ToDart(*val.hard_break), tonic::ToDart(*val.ascent),
|
||||
tonic::ToDart(*val.descent), tonic::ToDart(*val.unscaled_ascent),
|
||||
tonic::ToDart(*val.height), tonic::ToDart(*val.width),
|
||||
tonic::ToDart(*val.left), tonic::ToDart(*val.baseline),
|
||||
tonic::ToDart(*val.line_number)};
|
||||
tonic::ToDart(*val.descent), tonic::ToDart(*val.unscaled_ascent),
|
||||
// We add then round to get the height. The
|
||||
// definition of height here is different
|
||||
// than the one in LibTxt.
|
||||
tonic::ToDart(round(*val.ascent + *val.descent)),
|
||||
tonic::ToDart(*val.width), tonic::ToDart(*val.left),
|
||||
tonic::ToDart(*val.baseline), tonic::ToDart(*val.line_number)};
|
||||
return Dart_New(GetLineMetricsType(), tonic::ToDart("_"), argc, argv);
|
||||
}
|
||||
|
||||
|
||||
4
third_party/txt/src/txt/line_metrics.h
vendored
4
third_party/txt/src/txt/line_metrics.h
vendored
@ -48,7 +48,9 @@ class LineMetrics {
|
||||
double ascent = 0.0;
|
||||
double descent = 0.0;
|
||||
double unscaled_ascent = 0.0;
|
||||
// Height of the line.
|
||||
// Total height of the paragraph including the current line.
|
||||
//
|
||||
// The height of the current line is `round(ascent + descent)`.
|
||||
double height = 0.0;
|
||||
// Width of the line.
|
||||
double width = 0.0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user