Flutter Engine
The Flutter Engine
third_party
txt
src
txt
line_metrics.h
Go to the documentation of this file.
1
/*
2
* Copyright 2017 Google Inc.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#ifndef LIB_TXT_SRC_LINE_METRICS_H_
18
#define LIB_TXT_SRC_LINE_METRICS_H_
19
20
#include <map>
21
#include <vector>
22
23
#include "
run_metrics.h
"
24
25
namespace
txt
{
26
27
class
LineMetrics
{
28
public
:
29
// The following fields are used in the layout process itself.
30
31
// The indexes in the text buffer the line begins and ends.
32
size_t
start_index
= 0;
33
size_t
end_index
= 0;
34
size_t
end_excluding_whitespace
= 0;
35
size_t
end_including_newline
= 0;
36
bool
hard_break
=
false
;
37
38
// The following fields are tracked after or during layout to provide to
39
// the user as well as for computing bounding boxes.
40
41
// The final computed ascent and descent for the line. This can be impacted by
42
// the strut, height, scaling, as well as outlying runs that are very tall.
43
//
44
// The top edge is `baseline - ascent` and the bottom edge is `baseline +
45
// descent`. Ascent and descent are provided as positive numbers. Raw numbers
46
// for specific runs of text can be obtained in run_metrics_map. These values
47
// are the cumulative metrics for the entire line.
48
double
ascent
= 0.0;
49
double
descent
= 0.0;
50
double
unscaled_ascent
= 0.0;
51
// Total height of the paragraph including the current line.
52
//
53
// The height of the current line is `round(ascent + descent)`.
54
double
height
= 0.0;
55
// Width of the line.
56
double
width
= 0.0;
57
// The left edge of the line. The right edge can be obtained with `left +
58
// width`
59
double
left
= 0.0;
60
// The y position of the baseline for this line from the top of the paragraph.
61
double
baseline
= 0.0;
62
// Zero indexed line number.
63
size_t
line_number
= 0;
64
65
// Mapping between text index ranges and the FontMetrics associated with
66
// them. The first run will be keyed under start_index. The metrics here
67
// are before layout and are the base values we calculate from.
68
std::map<size_t, RunMetrics>
run_metrics
;
69
70
LineMetrics
();
71
72
LineMetrics
(
size_t
start,
73
size_t
end,
74
size_t
end_excluding_whitespace
,
75
size_t
end_including_newline
,
76
bool
hard_break
)
77
:
start_index
(
start
),
78
end_index
(
end
),
79
end_excluding_whitespace
(
end_excluding_whitespace
),
80
end_including_newline
(
end_including_newline
),
81
hard_break
(
hard_break
) {}
82
};
83
84
}
// namespace txt
85
86
#endif
// LIB_TXT_SRC_LINE_METRICS_H_
txt::LineMetrics
Definition:
line_metrics.h:27
txt::LineMetrics::baseline
double baseline
Definition:
line_metrics.h:61
txt::LineMetrics::line_number
size_t line_number
Definition:
line_metrics.h:63
txt::LineMetrics::end_including_newline
size_t end_including_newline
Definition:
line_metrics.h:35
txt::LineMetrics::LineMetrics
LineMetrics()
txt::LineMetrics::height
double height
Definition:
line_metrics.h:54
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:72
txt::LineMetrics::end_index
size_t end_index
Definition:
line_metrics.h:33
txt::LineMetrics::width
double width
Definition:
line_metrics.h:56
txt::LineMetrics::start_index
size_t start_index
Definition:
line_metrics.h:32
txt::LineMetrics::descent
double descent
Definition:
line_metrics.h:49
txt::LineMetrics::end_excluding_whitespace
size_t end_excluding_whitespace
Definition:
line_metrics.h:34
txt::LineMetrics::ascent
double ascent
Definition:
line_metrics.h:48
txt::LineMetrics::run_metrics
std::map< size_t, RunMetrics > run_metrics
Definition:
line_metrics.h:68
txt::LineMetrics::left
double left
Definition:
line_metrics.h:59
txt::LineMetrics::unscaled_ascent
double unscaled_ascent
Definition:
line_metrics.h:50
txt::LineMetrics::hard_break
bool hard_break
Definition:
line_metrics.h:36
start
glong start
Definition:
fl_accessible_text_field.cc:39
end
glong glong end
Definition:
fl_accessible_text_field.cc:40
txt
Definition:
paragraph_builder_skia.cc:27
run_metrics.h
Generated on Sun Jun 23 2024 21:56:53 for Flutter Engine by
1.9.4