Call GetGlyphWidth() fewer times in LoadCompositeFont().

If LoadCompositeFont() already knows the width for a given glyph index,
avoid calling CFX_Font::GetGlyphWidth() to calculate it again. Repeated
calls to GetGlyphWidth(), which calls FT_Load_Glyph(), can be very slow.

BUG=chromium:906338

Change-Id: Ifb3ff027f0953a34d1275fdc97a972dbe89ad473
Reviewed-on: https://pdfium-review.googlesource.com/c/47282
Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/fpdf_edittext.cpp b/fpdfsdk/fpdf_edittext.cpp
index ca4d6f7..2478c23 100644
--- a/fpdfsdk/fpdf_edittext.cpp
+++ b/fpdfsdk/fpdf_edittext.cpp
@@ -351,7 +351,8 @@
     if (currentChar > kMaxUnicode)
       break;
 
-    widths[glyphIndex] = pFont->GetGlyphWidth(glyphIndex);
+    if (!pdfium::ContainsKey(widths, glyphIndex))
+      widths[glyphIndex] = pFont->GetGlyphWidth(glyphIndex);
     to_unicode[glyphIndex] = currentChar;
     currentChar =
         FXFT_Get_Next_Char(pFont->GetFace(), currentChar, &glyphIndex);