Flutter Engine
Loading...
Searching...
No Matches
line_metrics.h
Go to the documentation of this file.
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#ifndef FLUTTER_TXT_SRC_TXT_LINE_METRICS_H_
6
#define FLUTTER_TXT_SRC_TXT_LINE_METRICS_H_
7
8
#include <map>
9
#include <vector>
10
11
#include "
run_metrics.h
"
12
13
namespace
txt
{
14
15
class
LineMetrics
{
16
public
:
17
// The following fields are used in the layout process itself.
18
19
// The indexes in the text buffer the line begins and ends.
20
size_t
start_index
= 0;
21
size_t
end_index
= 0;
22
size_t
end_excluding_whitespace
= 0;
23
size_t
end_including_newline
= 0;
24
bool
hard_break
=
false
;
25
26
// The following fields are tracked after or during layout to provide to
27
// the user as well as for computing bounding boxes.
28
29
// The final computed ascent and descent for the line. This can be impacted by
30
// the strut, height, scaling, as well as outlying runs that are very tall.
31
//
32
// The top edge is `baseline - ascent` and the bottom edge is `baseline +
33
// descent`. Ascent and descent are provided as positive numbers. Raw numbers
34
// for specific runs of text can be obtained in run_metrics_map. These values
35
// are the cumulative metrics for the entire line.
36
double
ascent
= 0.0;
37
double
descent
= 0.0;
38
double
unscaled_ascent
= 0.0;
39
// Total height of the paragraph including the current line.
40
//
41
// The height of the current line is `round(ascent + descent)`.
42
double
height
= 0.0;
43
// Width of the line.
44
double
width
= 0.0;
45
// The left edge of the line. The right edge can be obtained with `left +
46
// width`
47
double
left
= 0.0;
48
// The y position of the baseline for this line from the top of the paragraph.
49
double
baseline
= 0.0;
50
// Zero indexed line number.
51
size_t
line_number
= 0;
52
53
// Mapping between text index ranges and the FontMetrics associated with
54
// them. The first run will be keyed under start_index. The metrics here
55
// are before layout and are the base values we calculate from.
56
std::map<size_t, RunMetrics>
run_metrics
;
57
58
LineMetrics
() =
default
;
59
60
LineMetrics
(
size_t
start,
61
size_t
end
,
62
size_t
end_excluding_whitespace
,
63
size_t
end_including_newline
,
64
bool
hard_break
)
65
:
start_index
(
start
),
66
end_index
(
end
),
67
end_excluding_whitespace
(
end_excluding_whitespace
),
68
end_including_newline
(
end_including_newline
),
69
hard_break
(
hard_break
) {}
70
};
71
72
}
// namespace txt
73
74
#endif
// FLUTTER_TXT_SRC_TXT_LINE_METRICS_H_
txt::LineMetrics
Definition
line_metrics.h:15
txt::LineMetrics::baseline
double baseline
Definition
line_metrics.h:49
txt::LineMetrics::line_number
size_t line_number
Definition
line_metrics.h:51
txt::LineMetrics::end_including_newline
size_t end_including_newline
Definition
line_metrics.h:23
txt::LineMetrics::height
double height
Definition
line_metrics.h:42
txt::LineMetrics::LineMetrics
LineMetrics(size_t start, size_t end, size_t end_excluding_whitespace, size_t end_including_newline, bool hard_break)
Definition
line_metrics.h:60
txt::LineMetrics::end_index
size_t end_index
Definition
line_metrics.h:21
txt::LineMetrics::LineMetrics
LineMetrics()=default
txt::LineMetrics::width
double width
Definition
line_metrics.h:44
txt::LineMetrics::start_index
size_t start_index
Definition
line_metrics.h:20
txt::LineMetrics::descent
double descent
Definition
line_metrics.h:37
txt::LineMetrics::end_excluding_whitespace
size_t end_excluding_whitespace
Definition
line_metrics.h:22
txt::LineMetrics::ascent
double ascent
Definition
line_metrics.h:36
txt::LineMetrics::run_metrics
std::map< size_t, RunMetrics > run_metrics
Definition
line_metrics.h:56
txt::LineMetrics::left
double left
Definition
line_metrics.h:47
txt::LineMetrics::unscaled_ascent
double unscaled_ascent
Definition
line_metrics.h:38
txt::LineMetrics::hard_break
bool hard_break
Definition
line_metrics.h:24
txt
Definition
paragraph_builder_skia.cc:15
txt::TextAlign::end
@ end
run_metrics.h
start
const size_t start
Definition
tessellator_libtess.cc:62
txt
src
txt
line_metrics.h
Generated on Thu Nov 6 2025 16:11:30 for Flutter Engine by
1.9.8