From 9f1eab2f1f269299bb5ac3adb6b96a7291851327 Mon Sep 17 00:00:00 2001 From: Gary Qian Date: Mon, 26 Aug 2019 13:40:22 -0700 Subject: [PATCH] Expose LineMetrics in dart:ui (#10670) --- ci/licenses_golden/licenses_flutter | 2 + lib/ui/BUILD.gn | 2 + lib/ui/text.dart | 110 ++++++++++++++++ lib/ui/text/line_metrics.cc | 45 +++++++ lib/ui/text/line_metrics.h | 75 +++++++++++ lib/ui/text/paragraph.cc | 14 +- lib/ui/text/paragraph.h | 2 + lib/web_ui/lib/src/engine/text/paragraph.dart | 6 + lib/web_ui/lib/src/ui/text.dart | 47 +++++++ third_party/txt/src/txt/paragraph_txt.cc | 2 +- third_party/txt/src/txt/run_metrics.h | 13 +- third_party/txt/tests/paragraph_unittests.cc | 120 ++++++------------ 12 files changed, 347 insertions(+), 91 deletions(-) create mode 100644 lib/ui/text/line_metrics.cc create mode 100644 lib/ui/text/line_metrics.h diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 5a8558f02dab8..ddfd07d2a2c9a 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -320,6 +320,8 @@ FILE: ../../../flutter/lib/ui/text/asset_manager_font_provider.cc FILE: ../../../flutter/lib/ui/text/asset_manager_font_provider.h FILE: ../../../flutter/lib/ui/text/font_collection.cc FILE: ../../../flutter/lib/ui/text/font_collection.h +FILE: ../../../flutter/lib/ui/text/line_metrics.cc +FILE: ../../../flutter/lib/ui/text/line_metrics.h FILE: ../../../flutter/lib/ui/text/paragraph.cc FILE: ../../../flutter/lib/ui/text/paragraph.h FILE: ../../../flutter/lib/ui/text/paragraph_builder.cc diff --git a/lib/ui/BUILD.gn b/lib/ui/BUILD.gn index a11ed9116e8b9..36c40fffdb691 100644 --- a/lib/ui/BUILD.gn +++ b/lib/ui/BUILD.gn @@ -80,6 +80,8 @@ source_set("ui") { "text/asset_manager_font_provider.h", "text/font_collection.cc", "text/font_collection.h", + "text/line_metrics.cc", + "text/line_metrics.h", "text/paragraph.cc", "text/paragraph.h", "text/paragraph_builder.cc", diff --git a/lib/ui/text.dart b/lib/ui/text.dart index 1e640583536cb..0cd7d7d65af1f 100644 --- a/lib/ui/text.dart +++ b/lib/ui/text.dart @@ -1569,6 +1569,107 @@ enum PlaceholderAlignment { middle, } +/// [LineMetrics] stores the measurements and statistics of a single line in the +/// paragraph. +/// +/// The measurements here are for the line as a whole, and represent the maximum +/// extent of the line instead of per-run or per-glyph metrics. For more detailed +/// metrics, see [TextBox] and [Paragraph.getBoxesForRange]. +/// +/// [LineMetrics] should be obtained directly from the [Paragraph.computeLineMetrics] +/// method. +class LineMetrics { + /// Creates a [LineMetrics] object with only the specified values. + /// + /// Omitted values will remain null. [Paragraph.computeLineMetrics] produces + /// fully defined [LineMetrics] with no null values. + LineMetrics({ + this.hardBreak, + this.ascent, + this.descent, + this.unscaledAscent, + this.height, + this.width, + this.left, + this.baseline, + this.lineNumber, + }); + + @pragma('vm:entry-point') + LineMetrics._( + this.hardBreak, + this.ascent, + this.descent, + this.unscaledAscent, + this.height, + this.width, + this.left, + this.baseline, + this.lineNumber, + ); + + /// True if this line ends with an explicit line break (e.g. '\n') or is the end + /// of the paragraph. False otherwise. + final bool hardBreak; + + /// The rise from the [baseline] as calculated from the font and style for this line. + /// + /// This is the final computed ascent and can be impacted by the strut, height, scaling, + /// as well as outlying runs that are very tall. + /// + /// The [ascent] is provided as a positive value, even though it is typically defined + /// in fonts as negative. This is to ensure the signage of operations with these + /// metrics directly reflects the intended signage of the value. For example, + /// the y coordinate of the top edge of the line is `baseline - ascent`. + final double ascent; + + /// The drop from the [baseline] as calculated from the font and style for this line. + /// + /// This is the final computed ascent and can be impacted by the strut, height, scaling, + /// as well as outlying runs that are very tall. + /// + /// The y coordinate of the bottom edge of the line is `baseline + descent`. + final double descent; + + /// The rise from the [baseline] as calculated from the font and style for this line + /// ignoring the [TextStyle.height]. + /// + /// The [unscaledAscent] is provided as a positive value, even though it is typically + /// defined in fonts as negative. This is to ensure the signage of operations with + /// these metrics directly reflects the intended signage of the value. + final double unscaledAscent; + + /// Total height of the line from the top edge to the bottom edge. + /// + /// This is equivalent to `ascent + descent` + final double height; + + /// Width of the line from the left edge of the leftmost glyph to the right + /// edge of the rightmost glyph. + /// + /// This is not the same as the width of the pargraph. + /// + /// See also: + /// + /// * [Paragraph.width], the max width passed in during layout. + /// * [Paragraph.longestLine], the width of the longest line in the paragraph. + final double width; + + /// The x coordinate of left edge of the line. + /// + /// The right edge can be obtained with `left + width`. + final double left; + + /// The y coordinate of the baseline for this line from the top of the paragraph. + final double baseline; + + /// The number of this line in the overall paragraph, with the first line being + /// index zero. + /// + /// For example, the first line is line 0, second line is line 1. + final int lineNumber; +} + /// A paragraph of text. /// /// A paragraph retains the size and position of each glyph in the text and can @@ -1684,6 +1785,15 @@ class Paragraph extends NativeFieldWrapperClass2 { // in the C++ code. If we straighten out the C++ dependencies, we can remove // this indirection. void _paint(Canvas canvas, double x, double y) native 'Paragraph_paint'; + + /// Returns the full list of [LineMetrics] that describe in detail the various + /// metrics of each laid out line. + /// + /// Not valid until after layout. + /// + /// This can potentially return a large amount of data, so it is not recommended + /// to repeatedly call this. Instead, cache the results. + List computeLineMetrics() native 'Paragraph_computeLineMetrics'; } /// Builds a [Paragraph] containing text with the given styling information. diff --git a/lib/ui/text/line_metrics.cc b/lib/ui/text/line_metrics.cc new file mode 100644 index 0000000000000..11c5460764c69 --- /dev/null +++ b/lib/ui/text/line_metrics.cc @@ -0,0 +1,45 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "flutter/lib/ui/text/line_metrics.h" + +#include "flutter/fml/logging.h" +#include "third_party/tonic/dart_class_library.h" +#include "third_party/tonic/dart_state.h" +#include "third_party/tonic/logging/dart_error.h" + +using namespace flutter; + +namespace tonic { + +namespace { + +Dart_Handle GetLineMetricsType() { + DartClassLibrary& class_library = DartState::Current()->class_library(); + Dart_Handle type = + Dart_HandleFromPersistent(class_library.GetClass("ui", "LineMetrics")); + FML_DCHECK(!LogIfError(type)); + return type; +} + +} // anonymous namespace + +Dart_Handle DartConverter::ToDart( + const flutter::LineMetrics& val) { + constexpr int argc = 9; + + 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)}; + return Dart_New(GetLineMetricsType(), tonic::ToDart("_"), argc, argv); +} + +Dart_Handle DartListFactory::NewList(intptr_t length) { + return Dart_NewListOfType(GetLineMetricsType(), length); +} + +} // namespace tonic diff --git a/lib/ui/text/line_metrics.h b/lib/ui/text/line_metrics.h new file mode 100644 index 0000000000000..fc9860a0b9ab9 --- /dev/null +++ b/lib/ui/text/line_metrics.h @@ -0,0 +1,75 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FLUTTER_LIB_UI_TEXT_LINE_METRICS_H_ +#define FLUTTER_LIB_UI_TEXT_LINE_METRICS_H_ + +#include "third_party/dart/runtime/include/dart_api.h" +#include "third_party/tonic/converter/dart_converter.h" + +namespace flutter { + +struct LineMetrics { + const bool* hard_break; + + // The final computed ascent and descent for the line. This can be impacted by + // the strut, height, scaling, as well as outlying runs that are very tall. + // + // The top edge is `baseline - ascent` and the bottom edge is `baseline + + // descent`. Ascent and descent are provided as positive numbers. Raw numbers + // for specific runs of text can be obtained in run_metrics_map. These values + // are the cumulative metrics for the entire line. + const double* ascent; + const double* descent; + const double* unscaled_ascent; + // Height of the line. + const double* height; + // Width of the line. + const double* width; + // The left edge of the line. The right edge can be obtained with `left + + // width` + const double* left; + // The y position of the baseline for this line from the top of the paragraph. + const double* baseline; + // Zero indexed line number. + const size_t* line_number; + + LineMetrics(); + + LineMetrics(const bool* hard_break, + const double* ascent, + const double* descent, + const double* unscaled_ascent, + const double* height, + const double* width, + const double* left, + const double* baseline, + const size_t* line_number) + : hard_break(hard_break), + ascent(ascent), + descent(descent), + unscaled_ascent(unscaled_ascent), + height(height), + width(width), + left(left), + baseline(baseline), + line_number(line_number) {} +}; + +} // namespace flutter + +namespace tonic { +template <> +struct DartConverter { + static Dart_Handle ToDart(const flutter::LineMetrics& val); +}; + +template <> +struct DartListFactory { + static Dart_Handle NewList(intptr_t length); +}; + +} // namespace tonic + +#endif // FLUTTER_LIB_UI_TEXT_LINE_METRICS_H_ \ No newline at end of file diff --git a/lib/ui/text/paragraph.cc b/lib/ui/text/paragraph.cc index a14fe896c93f7..0025615e7f8fa 100644 --- a/lib/ui/text/paragraph.cc +++ b/lib/ui/text/paragraph.cc @@ -33,7 +33,8 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, Paragraph); V(Paragraph, getWordBoundary) \ V(Paragraph, getRectsForRange) \ V(Paragraph, getRectsForPlaceholders) \ - V(Paragraph, getPositionForOffset) + V(Paragraph, getPositionForOffset) \ + V(Paragraph, computeLineMetrics) DART_BIND_ALL(Paragraph, FOR_EACH_BINDING) @@ -133,4 +134,15 @@ Dart_Handle Paragraph::getWordBoundary(unsigned offset) { return result; } +std::vector Paragraph::computeLineMetrics() { + std::vector result; + std::vector metrics = m_paragraph->GetLineMetrics(); + for (txt::LineMetrics& line : metrics) { + result.emplace_back(&line.hard_break, &line.ascent, &line.descent, + &line.unscaled_ascent, &line.height, &line.width, + &line.left, &line.baseline, &line.line_number); + } + return result; +} + } // namespace flutter diff --git a/lib/ui/text/paragraph.h b/lib/ui/text/paragraph.h index 7787100ca8539..cdd45335d3e9e 100644 --- a/lib/ui/text/paragraph.h +++ b/lib/ui/text/paragraph.h @@ -8,6 +8,7 @@ #include "flutter/fml/message_loop.h" #include "flutter/lib/ui/dart_wrapper.h" #include "flutter/lib/ui/painting/canvas.h" +#include "flutter/lib/ui/text/line_metrics.h" #include "flutter/lib/ui/text/text_box.h" #include "flutter/third_party/txt/src/txt/paragraph.h" @@ -48,6 +49,7 @@ class Paragraph : public RefCountedDartWrappable { std::vector getRectsForPlaceholders(); Dart_Handle getPositionForOffset(double dx, double dy); Dart_Handle getWordBoundary(unsigned offset); + std::vector computeLineMetrics(); size_t GetAllocationSize() override; diff --git a/lib/web_ui/lib/src/engine/text/paragraph.dart b/lib/web_ui/lib/src/engine/text/paragraph.dart index 86c5ed5c43b82..66b1610367538 100644 --- a/lib/web_ui/lib/src/engine/text/paragraph.dart +++ b/lib/web_ui/lib/src/engine/text/paragraph.dart @@ -290,6 +290,12 @@ class EngineParagraph implements ui.Paragraph { final int end = WordBreaker.nextBreakIndex(_plainText, offset); return [start, end]; } + + @override + List computeLineMetrics() { + // TODO(flutter_web): Implement this. + return null; + } } /// The web implementation of [ui.ParagraphStyle]. diff --git a/lib/web_ui/lib/src/ui/text.dart b/lib/web_ui/lib/src/ui/text.dart index 442a033c447ad..9d8ea673ddecb 100644 --- a/lib/web_ui/lib/src/ui/text.dart +++ b/lib/web_ui/lib/src/ui/text.dart @@ -1019,6 +1019,51 @@ enum BoxWidthStyle { max, } +class LineMetrics { + LineMetrics({ + this.hardBreak, + this.ascent, + this.descent, + this.unscaledAscent, + this.height, + this.width, + this.left, + this.baseline, + this.lineNumber, + }); + + @pragma('vm:entry-point') + LineMetrics._( + this.hardBreak, + this.ascent, + this.descent, + this.unscaledAscent, + this.height, + this.width, + this.left, + this.baseline, + this.lineNumber, + ); + + final bool hardBreak; + + final double ascent; + + final double descent; + + final double unscaledAscent; + + final double height; + + final double width; + + final double left; + + final double baseline; + + final int lineNumber; +} + /// A paragraph of text. /// /// A paragraph retains the size and position of each glyph in the text and can @@ -1125,6 +1170,8 @@ abstract class Paragraph { /// Coordinates of the [TextBox] are relative to the upper-left corner of the paragraph, /// where positive y values indicate down. List getBoxesForPlaceholders(); + + List computeLineMetrics(); } /// Builds a [Paragraph] containing text with the given styling information. diff --git a/third_party/txt/src/txt/paragraph_txt.cc b/third_party/txt/src/txt/paragraph_txt.cc index 2534aa6c7dd00..1c149e96b6a3f 100644 --- a/third_party/txt/src/txt/paragraph_txt.cc +++ b/third_party/txt/src/txt/paragraph_txt.cc @@ -999,7 +999,7 @@ void ParagraphTxt::Layout(double width) { size_t run_key = run.end() - 1; line_metrics.run_metrics.emplace(run_key, &run.style()); SkFontMetrics* metrics = - &line_metrics.run_metrics.at(run_key).GetFontMetrics(); + &line_metrics.run_metrics.at(run_key).font_metrics; font.getMetrics(metrics); Range record_x_pos( diff --git a/third_party/txt/src/txt/run_metrics.h b/third_party/txt/src/txt/run_metrics.h index a51f91230f96b..9355de936ca37 100644 --- a/third_party/txt/src/txt/run_metrics.h +++ b/third_party/txt/src/txt/run_metrics.h @@ -25,17 +25,12 @@ namespace txt { // Contains the font metrics and TextStyle of a unique run. class RunMetrics { public: - RunMetrics(const TextStyle* style) : text_style_(style) {} + RunMetrics(const TextStyle* style) : text_style(style) {} RunMetrics(const TextStyle* style, SkFontMetrics& metrics) - : text_style_(style), font_metrics_(metrics) {} + : text_style(style), font_metrics(metrics) {} - SkFontMetrics& GetFontMetrics() { return font_metrics_; } - - const TextStyle& GetTextStyle() const { return *text_style_; } - - private: - const TextStyle* text_style_; + const TextStyle* text_style; // SkFontMetrics contains the following metrics: // @@ -54,7 +49,7 @@ class RunMetrics { // * UnderlinePosition underline position relative to baseline // * StrikeoutThickness strikeout thickness // * StrikeoutPosition strikeout position relative to baseline - SkFontMetrics font_metrics_; + SkFontMetrics font_metrics; }; } // namespace txt diff --git a/third_party/txt/tests/paragraph_unittests.cc b/third_party/txt/tests/paragraph_unittests.cc index 5496805da2bec..1d8ed94f5803b 100644 --- a/third_party/txt/tests/paragraph_unittests.cc +++ b/third_party/txt/tests/paragraph_unittests.cc @@ -177,50 +177,42 @@ TEST_F(ParagraphTest, LineMetricsParagraph1) { ASSERT_EQ( paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(paragraph->GetLineMetrics()[0].start_index) - ->second.GetTextStyle() - .color, + ->second.text_style->color, SK_ColorBLACK); ASSERT_EQ( paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(paragraph->GetLineMetrics()[0].start_index) - ->second.GetTextStyle() - .font_families, + ->second.text_style->font_families, std::vector(1, "Roboto")); ASSERT_FLOAT_EQ( paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(paragraph->GetLineMetrics()[0].start_index) - ->second.GetFontMetrics() - .fAscent, + ->second.font_metrics.fAscent, -12.988281); ASSERT_FLOAT_EQ( paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(paragraph->GetLineMetrics()[0].start_index) - ->second.GetFontMetrics() - .fDescent, + ->second.font_metrics.fDescent, 3.4179688); ASSERT_FLOAT_EQ( paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(paragraph->GetLineMetrics()[0].start_index) - ->second.GetFontMetrics() - .fXHeight, + ->second.font_metrics.fXHeight, 7.3964844); ASSERT_FLOAT_EQ( paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(paragraph->GetLineMetrics()[0].start_index) - ->second.GetFontMetrics() - .fLeading, + ->second.font_metrics.fLeading, 0); ASSERT_FLOAT_EQ( paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(paragraph->GetLineMetrics()[0].start_index) - ->second.GetFontMetrics() - .fTop, + ->second.font_metrics.fTop, -14.786133); ASSERT_FLOAT_EQ( paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(paragraph->GetLineMetrics()[0].start_index) - ->second.GetFontMetrics() - .fUnderlinePosition, + ->second.font_metrics.fUnderlinePosition, 1.0253906); ASSERT_EQ(paragraph->GetLineMetrics()[1].start_index, 25ull); @@ -238,50 +230,42 @@ TEST_F(ParagraphTest, LineMetricsParagraph1) { ASSERT_EQ( paragraph->GetLineMetrics()[1] .run_metrics.lower_bound(paragraph->GetLineMetrics()[1].start_index) - ->second.GetTextStyle() - .color, + ->second.text_style->color, SK_ColorBLACK); ASSERT_EQ( paragraph->GetLineMetrics()[1] .run_metrics.lower_bound(paragraph->GetLineMetrics()[1].start_index) - ->second.GetTextStyle() - .font_families, + ->second.text_style->font_families, std::vector(1, "Roboto")); ASSERT_FLOAT_EQ( paragraph->GetLineMetrics()[1] .run_metrics.lower_bound(paragraph->GetLineMetrics()[1].start_index) - ->second.GetFontMetrics() - .fAscent, + ->second.font_metrics.fAscent, -12.988281); ASSERT_FLOAT_EQ( paragraph->GetLineMetrics()[1] .run_metrics.lower_bound(paragraph->GetLineMetrics()[1].start_index) - ->second.GetFontMetrics() - .fDescent, + ->second.font_metrics.fDescent, 3.4179688); ASSERT_FLOAT_EQ( paragraph->GetLineMetrics()[1] .run_metrics.lower_bound(paragraph->GetLineMetrics()[1].start_index) - ->second.GetFontMetrics() - .fXHeight, + ->second.font_metrics.fXHeight, 7.3964844); ASSERT_FLOAT_EQ( paragraph->GetLineMetrics()[1] .run_metrics.lower_bound(paragraph->GetLineMetrics()[1].start_index) - ->second.GetFontMetrics() - .fLeading, + ->second.font_metrics.fLeading, 0); ASSERT_FLOAT_EQ( paragraph->GetLineMetrics()[1] .run_metrics.lower_bound(paragraph->GetLineMetrics()[1].start_index) - ->second.GetFontMetrics() - .fTop, + ->second.font_metrics.fTop, -14.786133); ASSERT_FLOAT_EQ( paragraph->GetLineMetrics()[1] .run_metrics.lower_bound(paragraph->GetLineMetrics()[1].start_index) - ->second.GetFontMetrics() - .fUnderlinePosition, + ->second.font_metrics.fUnderlinePosition, 1.0253906); } @@ -336,87 +320,71 @@ TEST_F(ParagraphTest, LineMetricsParagraph2) { // First run ASSERT_EQ(paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(2) - ->second.GetTextStyle() - .font_size, + ->second.text_style->font_size, 27); ASSERT_EQ(paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(2) - ->second.GetTextStyle() - .font_families, + ->second.text_style->font_families, text_style.font_families); ASSERT_FLOAT_EQ(paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(2) - ->second.GetFontMetrics() - .fAscent, + ->second.font_metrics.fAscent, -25.048828); ASSERT_FLOAT_EQ(paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(2) - ->second.GetFontMetrics() - .fDescent, + ->second.font_metrics.fDescent, 6.5917969); ASSERT_EQ(paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(21) - ->second.GetTextStyle() - .font_size, + ->second.text_style->font_size, 27); ASSERT_EQ(paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(21) - ->second.GetTextStyle() - .font_families, + ->second.text_style->font_families, text_style.font_families); ASSERT_FLOAT_EQ(paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(21) - ->second.GetFontMetrics() - .fAscent, + ->second.font_metrics.fAscent, -25.048828); ASSERT_FLOAT_EQ(paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(21) - ->second.GetFontMetrics() - .fDescent, + ->second.font_metrics.fDescent, 6.5917969); // Second run ASSERT_EQ(paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(22) - ->second.GetTextStyle() - .font_size, + ->second.text_style->font_size, 24); ASSERT_EQ(paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(22) - ->second.GetTextStyle() - .font_families, + ->second.text_style->font_families, text_style.font_families); ASSERT_FLOAT_EQ(paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(22) - ->second.GetFontMetrics() - .fAscent, + ->second.font_metrics.fAscent, -27.84); ASSERT_FLOAT_EQ(paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(22) - ->second.GetFontMetrics() - .fDescent, + ->second.font_metrics.fDescent, 7.6799998); ASSERT_EQ(paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(24) - ->second.GetTextStyle() - .font_size, + ->second.text_style->font_size, 24); ASSERT_EQ(paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(24) - ->second.GetTextStyle() - .font_families, + ->second.text_style->font_families, text_style.font_families); ASSERT_FLOAT_EQ(paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(24) - ->second.GetFontMetrics() - .fAscent, + ->second.font_metrics.fAscent, -27.84); ASSERT_FLOAT_EQ(paragraph->GetLineMetrics()[0] .run_metrics.lower_bound(24) - ->second.GetFontMetrics() - .fDescent, + ->second.font_metrics.fDescent, 7.6799998); ASSERT_EQ(paragraph->GetLineMetrics()[1].start_index, 26ull); @@ -434,45 +402,37 @@ TEST_F(ParagraphTest, LineMetricsParagraph2) { // Indexing below the line will just resolve to the first run in the line. ASSERT_EQ(paragraph->GetLineMetrics()[1] .run_metrics.lower_bound(3) - ->second.GetTextStyle() - .font_size, + ->second.text_style->font_size, 24); ASSERT_EQ(paragraph->GetLineMetrics()[1] .run_metrics.lower_bound(3) - ->second.GetTextStyle() - .font_families, + ->second.text_style->font_families, text_style.font_families); ASSERT_FLOAT_EQ(paragraph->GetLineMetrics()[1] .run_metrics.lower_bound(3) - ->second.GetFontMetrics() - .fAscent, + ->second.font_metrics.fAscent, -27.84); ASSERT_FLOAT_EQ(paragraph->GetLineMetrics()[1] .run_metrics.lower_bound(3) - ->second.GetFontMetrics() - .fDescent, + ->second.font_metrics.fDescent, 7.6799998); // Indexing within the line ASSERT_EQ(paragraph->GetLineMetrics()[1] .run_metrics.lower_bound(31) - ->second.GetTextStyle() - .font_size, + ->second.text_style->font_size, 24); ASSERT_EQ(paragraph->GetLineMetrics()[1] .run_metrics.lower_bound(31) - ->second.GetTextStyle() - .font_families, + ->second.text_style->font_families, text_style.font_families); ASSERT_FLOAT_EQ(paragraph->GetLineMetrics()[1] .run_metrics.lower_bound(31) - ->second.GetFontMetrics() - .fAscent, + ->second.font_metrics.fAscent, -27.84); ASSERT_FLOAT_EQ(paragraph->GetLineMetrics()[1] .run_metrics.lower_bound(31) - ->second.GetFontMetrics() - .fDescent, + ->second.font_metrics.fDescent, 7.6799998); }