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_RUN_METRICS_H_ |
18 | #define LIB_TXT_SRC_RUN_METRICS_H_ |
19 | |
20 | #include "text_style.h" |
21 | #include "third_party/skia/include/core/SkFontMetrics.h" |
22 | |
23 | namespace txt { |
24 | |
25 | // Contains the font metrics and TextStyle of a unique run. |
26 | class RunMetrics { |
27 | public: |
28 | RunMetrics(const TextStyle* style) : text_style(style) {} |
29 | |
30 | RunMetrics(const TextStyle* style, const SkFontMetrics& metrics) |
31 | : text_style(style), font_metrics(metrics) {} |
32 | |
33 | const TextStyle* text_style; |
34 | |
35 | // SkFontMetrics contains the following metrics: |
36 | // |
37 | // * Top distance to reserve above baseline |
38 | // * Ascent distance to reserve below baseline |
39 | // * Descent extent below baseline |
40 | // * Bottom extent below baseline |
41 | // * Leading distance to add between lines |
42 | // * AvgCharWidth average character width |
43 | // * MaxCharWidth maximum character width |
44 | // * XMin minimum x |
45 | // * XMax maximum x |
46 | // * XHeight height of lower-case 'x' |
47 | // * CapHeight height of an upper-case letter |
48 | // * UnderlineThickness underline thickness |
49 | // * UnderlinePosition underline position relative to baseline |
50 | // * StrikeoutThickness strikeout thickness |
51 | // * StrikeoutPosition strikeout position relative to baseline |
52 | SkFontMetrics font_metrics; |
53 | }; |
54 | |
55 | } // namespace txt |
56 | |
57 | #endif // LIB_TXT_SRC_RUN_METRICS_H_ |
58 | |