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
13namespace txt {
14
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;
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
70};
71
72} // namespace txt
73
74#endif // FLUTTER_TXT_SRC_TXT_LINE_METRICS_H_
size_t end_including_newline
LineMetrics(size_t start, size_t end, size_t end_excluding_whitespace, size_t end_including_newline, bool hard_break)
LineMetrics()=default
size_t end_excluding_whitespace
std::map< size_t, RunMetrics > run_metrics
const size_t start