Fix FPDFText_GetCharBox() returning excessively tall char boxes.

In CPDF_TextPage::ProcessTextObject(), when the initial char box
calculation produces too small of a char box, the method compensates by
usng the font size for the height, and the glyph width for the width.
The height compensation code uses the font size in the wrong unit, so it
is 1000 times bigger than it needs to be. Fix this and update the
affected test case to show FPDFText_GetCharBox() no longer returns
excessively tall char boxes.

Also update a FPDFText_GetRect() test case that suffers from the same
calculation issue. Now, the second line of hello_world.pdf, which uses a
font of size 16, now has a rectangle height of ~15 instead of ~19.

Bug: pdfium:1591
Change-Id: I1641b882c11c2f06b8a610c9d1ae11c850cd5edf
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/73772
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Hui Yingst <nigi@chromium.org>
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index b355cc9..e138515 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -1075,8 +1075,7 @@
     charinfo.m_CharBox.bottom = rect.bottom * fFontSize + item.m_Origin.y;
     if (fabsf(charinfo.m_CharBox.top - charinfo.m_CharBox.bottom) <
         kSizeEpsilon) {
-      charinfo.m_CharBox.top =
-          charinfo.m_CharBox.bottom + pTextObj->GetFontSize();
+      charinfo.m_CharBox.top = charinfo.m_CharBox.bottom + fFontSize;
     }
     if (fabsf(charinfo.m_CharBox.right - charinfo.m_CharBox.left) <
         kSizeEpsilon) {
diff --git a/fpdfsdk/fpdf_text_embeddertest.cpp b/fpdfsdk/fpdf_text_embeddertest.cpp
index 56b2b27..73754ec 100644
--- a/fpdfsdk/fpdf_text_embeddertest.cpp
+++ b/fpdfsdk/fpdf_text_embeddertest.cpp
@@ -175,7 +175,7 @@
   EXPECT_NEAR(20.847, left, 0.001);
   EXPECT_NEAR(135.167, right, 0.001);
   EXPECT_NEAR(96.655, bottom, 0.001);
-  EXPECT_NEAR(116.000, top, 0.001);
+  EXPECT_NEAR(111.648, top, 0.001);
 
   // Test out of range indicies set outputs to (0.0, 0.0, 0.0, 0.0).
   left = -1.0;
@@ -1643,8 +1643,7 @@
     EXPECT_DOUBLE_EQ(86.0, left);
     EXPECT_DOUBLE_EQ(88.400001525878906, right);
     EXPECT_DOUBLE_EQ(50.0, bottom);
-    // TODO(crbug.com/pdfium/1591): The top value is too big.
-    EXPECT_DOUBLE_EQ(290.0, top);
+    EXPECT_DOUBLE_EQ(50.240001678466797, top);
     ASSERT_TRUE(
         FPDFText_GetCharBox(text_page.get(), 3, &left, &right, &bottom, &top));
     EXPECT_DOUBLE_EQ(86.010002136230469, left);