Simplify CFX_Font's CharsetFontMap code.

- Rename the map constant kFoo.
- Simplify a #if statement for the map values.
- Simplify GetDefaultFontNameByCharset().

Change-Id: I0636d98d5d4b7a07d979a4cb5bc825ed0ff5c656
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/73091
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp
index 2de7eb8..72725f8 100644
--- a/core/fxge/cfx_font.cpp
+++ b/core/fxge/cfx_font.cpp
@@ -223,18 +223,17 @@
 
 }  // namespace
 
-const CFX_Font::CharsetFontMap CFX_Font::defaultTTFMap[] = {
+const CFX_Font::CharsetFontMap CFX_Font::kDefaultTTFMap[] = {
     {FX_CHARSET_ANSI, kDefaultAnsiFontName},
     {FX_CHARSET_ChineseSimplified, "SimSun"},
     {FX_CHARSET_ChineseTraditional, "MingLiU"},
     {FX_CHARSET_ShiftJIS, "MS Gothic"},
     {FX_CHARSET_Hangul, "Batang"},
     {FX_CHARSET_MSWin_Cyrillic, "Arial"},
-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ASMJS) || \
-    defined(OS_APPLE)
-    {FX_CHARSET_MSWin_EasternEuropean, "Arial"},
-#else
+#if defined(OS_WIN)
     {FX_CHARSET_MSWin_EasternEuropean, "Tahoma"},
+#else
+    {FX_CHARSET_MSWin_EasternEuropean, "Arial"},
 #endif
     {FX_CHARSET_MSWin_Arabic, "Arial"},
     {-1, nullptr}};
@@ -250,11 +249,9 @@
 
 // static
 ByteString CFX_Font::GetDefaultFontNameByCharset(uint8_t nCharset) {
-  int i = 0;
-  while (defaultTTFMap[i].charset != -1) {
-    if (nCharset == static_cast<uint8_t>(defaultTTFMap[i].charset))
-      return defaultTTFMap[i].fontname;
-    ++i;
+  for (size_t i = 0; i < pdfium::size(kDefaultTTFMap) - 1; ++i) {
+    if (nCharset == static_cast<uint8_t>(kDefaultTTFMap[i].charset))
+      return kDefaultTTFMap[i].fontname;
   }
   return kUniversalDefaultFontName;
 }
diff --git a/core/fxge/cfx_font.h b/core/fxge/cfx_font.h
index ea9e353..ba5c57e 100644
--- a/core/fxge/cfx_font.h
+++ b/core/fxge/cfx_font.h
@@ -124,12 +124,10 @@
     const char* fontname;  // Name of default font to use with that charset.
   };
 
-  /**
-   *    Pointer to the default character set to TT Font name map. The
-   *    map is an array of CharsetFontMap structs, with its end indicated
-   *    by a { -1, NULL } entry.
-   **/
-  static const CharsetFontMap defaultTTFMap[];
+  // Pointer to the default character set to TT Font name map. The map is an
+  // array of CharsetFontMap structs, with its end indicated by a {-1, nullptr}
+  // entry.
+  static const CharsetFontMap kDefaultTTFMap[];
 
  private:
   RetainPtr<CFX_GlyphCache> GetOrCreateGlyphCache() const;
diff --git a/fpdfsdk/fpdf_sysfontinfo.cpp b/fpdfsdk/fpdf_sysfontinfo.cpp
index 74dc3dd..c154061 100644
--- a/fpdfsdk/fpdf_sysfontinfo.cpp
+++ b/fpdfsdk/fpdf_sysfontinfo.cpp
@@ -137,7 +137,7 @@
 }
 
 FPDF_EXPORT const FPDF_CharsetFontMap* FPDF_CALLCONV FPDF_GetDefaultTTFMap() {
-  return reinterpret_cast<const FPDF_CharsetFontMap*>(CFX_Font::defaultTTFMap);
+  return reinterpret_cast<const FPDF_CharsetFontMap*>(CFX_Font::kDefaultTTFMap);
 }
 
 struct FPDF_SYSFONTINFO_DEFAULT final : public FPDF_SYSFONTINFO {