Use TextGlyphPos::GetOrigin() in more places.

BUG=chromium:919635

Change-Id: I271711c11b47d6081fa86554a86eafa37b5ebe6c
Reviewed-on: https://pdfium-review.googlesource.com/c/50130
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index c061eba..0c47092 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1829,9 +1829,11 @@
           if (!glyph.m_pGlyph)
             continue;
 
-          m_pDevice->SetBitMask(glyph.m_pGlyph->GetBitmap(),
-                                glyph.m_Origin.x + glyph.m_pGlyph->left(),
-                                glyph.m_Origin.y - glyph.m_pGlyph->top(),
+          Optional<CFX_Point> point = glyph.GetOrigin({0, 0});
+          if (!point.has_value())
+            continue;
+
+          m_pDevice->SetBitMask(glyph.m_pGlyph->GetBitmap(), point->x, point->y,
                                 fill_argb);
         }
         glyphs.clear();
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp
index 4cd07e6..262731a 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -972,11 +972,14 @@
     for (const TextGlyphPos& glyph : glyphs) {
       if (!glyph.m_pGlyph)
         continue;
+
+      Optional<CFX_Point> point = glyph.GetOrigin({pixel_left, pixel_top});
+      if (!point.has_value())
+        continue;
+
       const RetainPtr<CFX_DIBitmap>& pGlyph = glyph.m_pGlyph->GetBitmap();
-      bitmap->TransferBitmap(
-          glyph.m_Origin.x + glyph.m_pGlyph->left() - pixel_left,
-          glyph.m_Origin.y - glyph.m_pGlyph->top() - pixel_top,
-          pGlyph->GetWidth(), pGlyph->GetHeight(), pGlyph, 0, 0);
+      bitmap->TransferBitmap(point->x, point->y, pGlyph->GetWidth(),
+                             pGlyph->GetHeight(), pGlyph, 0, 0);
     }
     return SetBitMask(bitmap, bmp_rect.left, bmp_rect.top, fill_color);
   }