3838#include " unicode/utf16.h"
3939
4040#include " third_party/skia/include/core/SkCanvas.h"
41+ #include " third_party/skia/include/core/SkFont.h"
4142#include " third_party/skia/include/core/SkMaskFilter.h"
4243#include " third_party/skia/include/core/SkPaint.h"
4344#include " third_party/skia/include/core/SkTextBlob.h"
@@ -62,10 +63,10 @@ class GlyphTypeface {
6263
6364 bool operator !=(GlyphTypeface& other) { return !(*this == other); }
6465
65- void apply (SkPaint& paint ) {
66- paint .setTypeface (typeface_);
67- paint. setFakeBoldText (fake_bold_);
68- paint. setTextSkewX (fake_italic_ ? -SK_Scalar1 / 4 : 0 );
66+ void apply (SkFont& font ) {
67+ font .setTypeface (typeface_);
68+ font. setEmbolden (fake_bold_);
69+ font. setSkewX (fake_italic_ ? -SK_Scalar1 / 4 : 0 );
6970 }
7071
7172 private:
@@ -435,11 +436,10 @@ void Paragraph::Layout(double width, bool force) {
435436 if (!ComputeBidiRuns (&bidi_runs))
436437 return ;
437438
438- SkPaint paint;
439- paint.setAntiAlias (true );
440- paint.setTextEncoding (SkPaint::kGlyphID_TextEncoding );
441- paint.setSubpixelText (true );
442- paint.setHinting (kSlight_SkFontHinting );
439+ SkFont font;
440+ font.setEdging (SkFont::Edging::kAntiAlias );
441+ font.setSubpixel (true );
442+ font.setHinting (kSlight_SkFontHinting );
443443
444444 records_.clear ();
445445 line_heights_.clear ();
@@ -507,10 +507,10 @@ void Paragraph::Layout(double width, bool force) {
507507 for (auto line_run_it = line_runs.begin (); line_run_it != line_runs.end ();
508508 ++line_run_it) {
509509 const BidiRun& run = *line_run_it;
510- minikin::FontStyle font ;
510+ minikin::FontStyle minikin_font ;
511511 minikin::MinikinPaint minikin_paint;
512- GetFontAndMinikinPaint (run.style (), &font , &minikin_paint);
513- paint. setTextSize (run.style ().font_size );
512+ GetFontAndMinikinPaint (run.style (), &minikin_font , &minikin_paint);
513+ font. setSize (run.style ().font_size );
514514
515515 std::shared_ptr<minikin::FontCollection> minikin_font_collection =
516516 GetMinikinFontCollectionForStyle (run.style ());
@@ -531,13 +531,14 @@ void Paragraph::Layout(double width, bool force) {
531531 paragraph_style_.unlimited_lines ())) {
532532 float ellipsis_width = layout.measureText (
533533 reinterpret_cast <const uint16_t *>(ellipsis.data ()), 0 ,
534- ellipsis.length (), ellipsis.length (), run.is_rtl (), font ,
534+ ellipsis.length (), ellipsis.length (), run.is_rtl (), minikin_font ,
535535 minikin_paint, minikin_font_collection, nullptr );
536536
537537 std::vector<float > text_advances (text_count);
538- float text_width = layout.measureText (
539- text_ptr, text_start, text_count, text_.size (), run.is_rtl (), font,
540- minikin_paint, minikin_font_collection, text_advances.data ());
538+ float text_width =
539+ layout.measureText (text_ptr, text_start, text_count, text_.size (),
540+ run.is_rtl (), minikin_font, minikin_paint,
541+ minikin_font_collection, text_advances.data ());
541542
542543 // Truncate characters from the text until the ellipsis fits.
543544 size_t truncate_count = 0 ;
@@ -568,7 +569,7 @@ void Paragraph::Layout(double width, bool force) {
568569 }
569570
570571 layout.doLayout (text_ptr, text_start, text_count, text_size, run.is_rtl (),
571- font , minikin_paint, minikin_font_collection);
572+ minikin_font , minikin_paint, minikin_font_collection);
572573
573574 if (layout.nGlyphs () == 0 )
574575 continue ;
@@ -585,9 +586,9 @@ void Paragraph::Layout(double width, bool force) {
585586 for (const Range<size_t >& glyph_blob : glyph_blobs) {
586587 std::vector<GlyphPosition> glyph_positions;
587588
588- GetGlyphTypeface (layout, glyph_blob.start ).apply (paint );
589+ GetGlyphTypeface (layout, glyph_blob.start ).apply (font );
589590 const SkTextBlobBuilder::RunBuffer& blob_buffer =
590- builder.allocRunPos (paint , glyph_blob.end - glyph_blob.start );
591+ builder.allocRunPos (font , glyph_blob.end - glyph_blob.start );
591592
592593 for (size_t glyph_index = glyph_blob.start ;
593594 glyph_index < glyph_blob.end ;) {
@@ -687,7 +688,7 @@ void Paragraph::Layout(double width, bool force) {
687688 if (glyph_positions.empty ())
688689 continue ;
689690 SkFontMetrics metrics;
690- paint. getFontMetrics (&metrics);
691+ font. getMetrics (&metrics);
691692 paint_records.emplace_back (run.style (), SkPoint::Make (run_x_offset, 0 ),
692693 builder.make (), metrics, line_number,
693694 layout.getAdvance ());
@@ -770,9 +771,9 @@ void Paragraph::Layout(double width, bool force) {
770771 if (paint_records.empty ()) {
771772 SkFontMetrics metrics;
772773 TextStyle style (paragraph_style_.GetTextStyle ());
773- paint .setTypeface (GetDefaultSkiaTypeface (style));
774- paint. setTextSize (style.font_size );
775- paint. getFontMetrics (&metrics);
774+ font .setTypeface (GetDefaultSkiaTypeface (style));
775+ font. setSize (style.font_size );
776+ font. getMetrics (&metrics);
776777 update_line_metrics (metrics, style);
777778 }
778779
0 commit comments