Baseline for empty text

Change-Id: I7c172bfb8f35f684030489f75cd997acdbbe3a75
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/220298
Commit-Queue: Julia Lavrova <jlavrova@google.com>
Reviewed-by: Herb Derby <herb@google.com>
diff --git a/modules/skparagraph/src/ParagraphImpl.cpp b/modules/skparagraph/src/ParagraphImpl.cpp
index 25b944a..38a8708 100644
--- a/modules/skparagraph/src/ParagraphImpl.cpp
+++ b/modules/skparagraph/src/ParagraphImpl.cpp
@@ -120,10 +120,13 @@
                           SkSpan<TextBlock>(&fTextStyles.back(), 1),
                           fFontCollection,
                           fParagraphStyle.hintingIsOn());
+        // Get the font metrics
         font.consume();
-        SkFontMetrics metrics;
-        font.currentFont().getMetrics(&metrics);
-        fHeight = LineMetrics(metrics).height();
+        LineMetrics lineMetrics(font.currentFont());
+        // Set the important values that are not zero
+        fHeight = lineMetrics.height();
+        fAlphabeticBaseline = lineMetrics.alphabeticBaseline();
+        fIdeographicBaseline = lineMetrics.ideographicBaseline();
         return;
     }
 
diff --git a/modules/skparagraph/src/Run.h b/modules/skparagraph/src/Run.h
index fcaeeda..0a4f784 100644
--- a/modules/skparagraph/src/Run.h
+++ b/modules/skparagraph/src/Run.h
@@ -212,10 +212,12 @@
         fLeading = l;
     }
 
-    LineMetrics(const SkFontMetrics& fm) {
-        fAscent = fm.fAscent;
-        fDescent = fm.fDescent;
-        fLeading = fm.fLeading;
+    LineMetrics(const SkFont& font) {
+        SkFontMetrics metrics;
+        font.getMetrics(&metrics);
+        fAscent = metrics.fAscent;
+        fDescent = metrics.fDescent;
+        fLeading = metrics.fLeading;
     }
 
     void add(Run* run) {
diff --git a/samplecode/SampleParagraph.cpp b/samplecode/SampleParagraph.cpp
index 9a9e228..8407c42 100644
--- a/samplecode/SampleParagraph.cpp
+++ b/samplecode/SampleParagraph.cpp
@@ -1292,21 +1292,7 @@
     void onDrawContent(SkCanvas* canvas) override {
         canvas->drawColor(SK_ColorWHITE);
 
-        const char* text =
-                "😀😃😄😁😆😅😂🤣☺😇🙂😍😡😟😢😻👽💩👍👎🙏👌👋👄👁👦👼👨‍🚀👨‍🚒🙋‍♂️👳👨‍👨‍👧"
-                "‍"
-                "👧"
-                "💼👡👠☂🐶🐰🐻🐼🐷🐒🐵🐔🐧🐦🐋🐟🐡🕸🐌🐴🐊🐄🐪🐘🌸🌏🔥🌟🌚🌝"
-                "💦"
-                "💧"
-                "❄🍕🍔🍟🥝🍱🕶🎩🏈⚽🚴‍♀️🎻🎼🎹🚨🚎🚐⚓🛳🚀🚁🏪🏢🖱⏰📱💾💉📉🛏"
-                "🔑"
-                "🔓"
-                "📁🗓📊❤💯🚫🔻♠♣🕓❗🏳🏁🏳️‍🌈🇮🇹🇱🇷🇺🇸🇬🇧🇨🇳"
-                "🇧"
-                "🇴";
-        text =  "🍀\0‬";
-        text = "qwerty   ";
+        const char* text = "\n";
 
         ParagraphStyle paragraph_style;
         paragraph_style.turnHintingOff();
@@ -1323,7 +1309,8 @@
 
         auto paragraph = builder.Build();
         paragraph->layout(1000);
-        auto result = paragraph->getRectsForRange(6, 10, RectHeightStyle::kTight, RectWidthStyle::kTight);
+        auto result =
+                paragraph->getRectsForRange(0, 1, RectHeightStyle::kTight, RectWidthStyle::kTight);
         SkPaint paint;
         paint.setColor(SK_ColorLTGRAY);
         canvas->drawRect(result[0].rect, paint);