Convert FX_CHARSET to an enum type.
This is complicated because charsets are exposed as ints in the public
API, so some structs and functions must remain using ints.
Change-Id: I8136dc3a79f35483e87840e73d617594019fe4bf
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/83330
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxge/android/cfpf_skiafont.cpp b/core/fxge/android/cfpf_skiafont.cpp
index 6358b41..df1139e 100644
--- a/core/fxge/android/cfpf_skiafont.cpp
+++ b/core/fxge/android/cfpf_skiafont.cpp
@@ -8,6 +8,7 @@
 
 #include <algorithm>
 
+#include "core/fxcrt/fx_codepage.h"
 #include "core/fxcrt/fx_coordinates.h"
 #include "core/fxcrt/fx_system.h"
 #include "core/fxge/android/cfpf_skiafontmgr.h"
@@ -20,7 +21,7 @@
 CFPF_SkiaFont::CFPF_SkiaFont(CFPF_SkiaFontMgr* pFontMgr,
                              const CFPF_SkiaPathFont* pFont,
                              uint32_t dwStyle,
-                             uint8_t uCharset)
+                             FX_Charset uCharset)
     : m_pFontMgr(pFontMgr),
       m_pFont(pFont),
       m_Face(m_pFontMgr->GetFontFace(m_pFont->path(), m_pFont->face_index())),
diff --git a/core/fxge/android/cfpf_skiafont.h b/core/fxge/android/cfpf_skiafont.h
index c24d9fc..8f008d1 100644
--- a/core/fxge/android/cfpf_skiafont.h
+++ b/core/fxge/android/cfpf_skiafont.h
@@ -7,6 +7,7 @@
 #ifndef CORE_FXGE_ANDROID_CFPF_SKIAFONT_H_
 #define CORE_FXGE_ANDROID_CFPF_SKIAFONT_H_
 
+#include "core/fxcrt/fx_codepage_forward.h"
 #include "core/fxcrt/fx_string.h"
 #include "core/fxcrt/fx_system.h"
 #include "core/fxcrt/retain_ptr.h"
@@ -24,7 +25,7 @@
   CFPF_SkiaFont(CFPF_SkiaFontMgr* pFontMgr,
                 const CFPF_SkiaPathFont* pFont,
                 uint32_t dwStyle,
-                uint8_t uCharset);
+                FX_Charset uCharset);
   ~CFPF_SkiaFont();
 
   bool IsValid() const { return !!m_Face; }
@@ -32,7 +33,7 @@
   ByteString GetFamilyName();
   ByteString GetPsName();
   uint32_t GetFontStyle() const { return m_dwStyle; }
-  uint8_t GetCharset() const { return m_uCharset; }
+  FX_Charset GetCharset() const { return m_uCharset; }
   int32_t GetGlyphIndex(wchar_t wUnicode);
   int32_t GetGlyphWidth(int32_t iGlyphIndex);
   int32_t GetAscent() const;
@@ -49,7 +50,7 @@
   UnownedPtr<const CFPF_SkiaPathFont> const m_pFont;
   RetainPtr<CFX_Face> const m_Face;
   const uint32_t m_dwStyle;
-  const uint8_t m_uCharset;
+  const FX_Charset m_uCharset;
 };
 
 #endif  // CORE_FXGE_ANDROID_CFPF_SKIAFONT_H_
diff --git a/core/fxge/android/cfpf_skiafontmgr.cpp b/core/fxge/android/cfpf_skiafontmgr.cpp
index d6f593b..6d5d323 100644
--- a/core/fxge/android/cfpf_skiafontmgr.cpp
+++ b/core/fxge/android/cfpf_skiafontmgr.cpp
@@ -99,37 +99,37 @@
   FPF_SKIACHARSET_OEM = 1 << 18,
 };
 
-uint32_t FPF_SkiaGetCharset(uint8_t uCharset) {
+uint32_t FPF_SkiaGetCharset(FX_Charset uCharset) {
   switch (uCharset) {
-    case FX_CHARSET_ANSI:
+    case FX_Charset::kANSI:
       return FPF_SKIACHARSET_Ansi;
-    case FX_CHARSET_Default:
+    case FX_Charset::kDefault:
       return FPF_SKIACHARSET_Default;
-    case FX_CHARSET_Symbol:
+    case FX_Charset::kSymbol:
       return FPF_SKIACHARSET_Symbol;
-    case FX_CHARSET_ShiftJIS:
+    case FX_Charset::kShiftJIS:
       return FPF_SKIACHARSET_ShiftJIS;
-    case FX_CHARSET_Hangul:
+    case FX_Charset::kHangul:
       return FPF_SKIACHARSET_Korean;
-    case FX_CHARSET_ChineseSimplified:
+    case FX_Charset::kChineseSimplified:
       return FPF_SKIACHARSET_GB2312;
-    case FX_CHARSET_ChineseTraditional:
+    case FX_Charset::kChineseTraditional:
       return FPF_SKIACHARSET_BIG5;
-    case FX_CHARSET_MSWin_Greek:
+    case FX_Charset::kMSWin_Greek:
       return FPF_SKIACHARSET_Greek;
-    case FX_CHARSET_MSWin_Turkish:
+    case FX_Charset::kMSWin_Turkish:
       return FPF_SKIACHARSET_Turkish;
-    case FX_CHARSET_MSWin_Hebrew:
+    case FX_Charset::kMSWin_Hebrew:
       return FPF_SKIACHARSET_Hebrew;
-    case FX_CHARSET_MSWin_Arabic:
+    case FX_Charset::kMSWin_Arabic:
       return FPF_SKIACHARSET_Arabic;
-    case FX_CHARSET_MSWin_Baltic:
+    case FX_Charset::kMSWin_Baltic:
       return FPF_SKIACHARSET_Baltic;
-    case FX_CHARSET_MSWin_Cyrillic:
+    case FX_Charset::kMSWin_Cyrillic:
       return FPF_SKIACHARSET_Cyrillic;
-    case FX_CHARSET_Thai:
+    case FX_Charset::kThai:
       return FPF_SKIACHARSET_Thai;
-    case FX_CHARSET_MSWin_EasternEuropean:
+    case FX_Charset::kMSWin_EasternEuropean:
       return FPF_SKIACHARSET_EeasternEuropean;
   }
   return FPF_SKIACHARSET_Default;
@@ -150,7 +150,7 @@
 
 uint32_t FPF_SKIAGetFamilyHash(ByteStringView bsFamily,
                                uint32_t dwStyle,
-                               uint8_t uCharset) {
+                               FX_Charset uCharset) {
   ByteString bsFont(bsFamily);
   if (FontStyleIsForceBold(dwStyle))
     bsFont += "Bold";
@@ -158,11 +158,11 @@
     bsFont += "Italic";
   if (FontStyleIsSerif(dwStyle))
     bsFont += "Serif";
-  bsFont += uCharset;
+  bsFont += static_cast<uint8_t>(uCharset);
   return FPF_GetHashCode_StringA(bsFont.c_str(), bsFont.GetLength());
 }
 
-bool FPF_SkiaIsCJK(uint8_t uCharset) {
+bool FPF_SkiaIsCJK(FX_Charset uCharset) {
   return FX_CharSetIsCJK(uCharset);
 }
 
@@ -255,7 +255,7 @@
 }
 
 CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(ByteStringView bsFamilyname,
-                                            uint8_t uCharset,
+                                            FX_Charset uCharset,
                                             uint32_t dwStyle) {
   uint32_t dwHash = FPF_SKIAGetFamilyHash(bsFamilyname, dwStyle, uCharset);
   auto family_iter = m_FamilyFonts.find(dwHash);
@@ -268,11 +268,11 @@
   uint32_t dwSubstSans = FPF_SkiaGetSubstFont(dwFaceName, g_SkiaSansFontMap,
                                               pdfium::size(g_SkiaSansFontMap));
   bool bMaybeSymbol = FPF_SkiaMaybeSymbol(bsFamilyname);
-  if (uCharset != FX_CHARSET_MSWin_Arabic &&
+  if (uCharset != FX_Charset::kMSWin_Arabic &&
       FPF_SkiaMaybeArabic(bsFamilyname)) {
-    uCharset = FX_CHARSET_MSWin_Arabic;
-  } else if (uCharset == FX_CHARSET_ANSI) {
-    uCharset = FX_CHARSET_Default;
+    uCharset = FX_Charset::kMSWin_Arabic;
+  } else if (uCharset == FX_Charset::kANSI) {
+    uCharset = FX_Charset::kDefault;
   }
   int32_t nExpectVal = FPF_SKIAMATCHWEIGHT_NAME1 + FPF_SKIAMATCHWEIGHT_1 * 3 +
                        FPF_SKIAMATCHWEIGHT_2 * 2;
@@ -304,7 +304,7 @@
       nFind += FPF_SKIAMATCHWEIGHT_NAME2;
       bMatchedName = true;
     }
-    if (uCharset == FX_CHARSET_Default || bMaybeSymbol) {
+    if (uCharset == FX_Charset::kDefault || bMaybeSymbol) {
       if (nFind > nMax && bMatchedName) {
         nMax = nFind;
         pBestFont = font.get();
diff --git a/core/fxge/android/cfpf_skiafontmgr.h b/core/fxge/android/cfpf_skiafontmgr.h
index 4d5c788..7db4f48 100644
--- a/core/fxge/android/cfpf_skiafontmgr.h
+++ b/core/fxge/android/cfpf_skiafontmgr.h
@@ -11,6 +11,7 @@
 #include <memory>
 #include <vector>
 
+#include "core/fxcrt/fx_codepage_forward.h"
 #include "core/fxcrt/fx_string.h"
 #include "core/fxcrt/retain_ptr.h"
 #include "core/fxge/cfx_face.h"
@@ -26,7 +27,7 @@
 
   void LoadSystemFonts();
   CFPF_SkiaFont* CreateFont(ByteStringView bsFamilyname,
-                            uint8_t uCharset,
+                            FX_Charset uCharset,
                             uint32_t dwStyle);
 
   bool InitFTLibrary();
diff --git a/core/fxge/android/cfx_androidfontinfo.cpp b/core/fxge/android/cfx_androidfontinfo.cpp
index dc25f1e..17912db 100644
--- a/core/fxge/android/cfx_androidfontinfo.cpp
+++ b/core/fxge/android/cfx_androidfontinfo.cpp
@@ -31,7 +31,7 @@
 
 void* CFX_AndroidFontInfo::MapFont(int weight,
                                    bool bItalic,
-                                   int charset,
+                                   FX_Charset charset,
                                    int pitch_family,
                                    const char* face) {
   if (!m_pFontMgr)
@@ -71,7 +71,7 @@
   return true;
 }
 
-bool CFX_AndroidFontInfo::GetFontCharset(void* hFont, int* charset) {
+bool CFX_AndroidFontInfo::GetFontCharset(void* hFont, FX_Charset* charset) {
   if (!hFont)
     return false;
 
diff --git a/core/fxge/android/cfx_androidfontinfo.h b/core/fxge/android/cfx_androidfontinfo.h
index c8b6d24..9e68e66 100644
--- a/core/fxge/android/cfx_androidfontinfo.h
+++ b/core/fxge/android/cfx_androidfontinfo.h
@@ -26,7 +26,7 @@
   bool EnumFontList(CFX_FontMapper* pMapper) override;
   void* MapFont(int weight,
                 bool bItalic,
-                int charset,
+                FX_Charset charset,
                 int pitch_family,
                 const char* face) override;
   void* GetFont(const char* face) override;
@@ -34,7 +34,7 @@
                        uint32_t table,
                        pdfium::span<uint8_t> buffer) override;
   bool GetFaceName(void* hFont, ByteString* name) override;
-  bool GetFontCharset(void* hFont, int* charset) override;
+  bool GetFontCharset(void* hFont, FX_Charset* charset) override;
   void DeleteFont(void* hFont) override;
 
  private:
diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp
index f9a1097..0021cac 100644
--- a/core/fxge/apple/fx_apple_platform.cpp
+++ b/core/fxge/apple/fx_apple_platform.cpp
@@ -43,7 +43,7 @@
   // CFX_FolderFontInfo
   void* MapFont(int weight,
                 bool bItalic,
-                int charset,
+                FX_Charset charset,
                 int pitch_family,
                 const char* family) override;
 
@@ -64,7 +64,7 @@
 
 void* CFX_MacFontInfo::MapFont(int weight,
                                bool bItalic,
-                               int charset,
+                               FX_Charset charset,
                                int pitch_family,
                                const char* cstr_face) {
   ByteString face = cstr_face;
@@ -97,23 +97,23 @@
   if (it != m_FontList.end())
     return it->second.get();
 
-  if (charset == FX_CHARSET_ANSI && FontFamilyIsFixedPitch(pitch_family))
+  if (charset == FX_Charset::kANSI && FontFamilyIsFixedPitch(pitch_family))
     return GetFont("Courier New");
 
-  if (charset == FX_CHARSET_ANSI || charset == FX_CHARSET_Symbol)
+  if (charset == FX_Charset::kANSI || charset == FX_Charset::kSymbol)
     return nullptr;
 
   switch (charset) {
-    case FX_CHARSET_ShiftJIS:
+    case FX_Charset::kShiftJIS:
       GetJapanesePreference(&face, weight, pitch_family);
       break;
-    case FX_CHARSET_ChineseSimplified:
+    case FX_Charset::kChineseSimplified:
       face = "STSong";
       break;
-    case FX_CHARSET_Hangul:
+    case FX_Charset::kHangul:
       face = "AppleMyungjo";
       break;
-    case FX_CHARSET_ChineseTraditional:
+    case FX_Charset::kChineseTraditional:
       face = "LiSong Pro Light";
   }
   it = m_FontList.find(face);
diff --git a/core/fxge/cfx_folderfontinfo.cpp b/core/fxge/cfx_folderfontinfo.cpp
index e4812ef..d4fd9e2 100644
--- a/core/fxge/cfx_folderfontinfo.cpp
+++ b/core/fxge/cfx_folderfontinfo.cpp
@@ -100,19 +100,19 @@
   return ByteString();
 }
 
-uint32_t GetCharset(int charset) {
+uint32_t GetCharset(FX_Charset charset) {
   switch (charset) {
-    case FX_CHARSET_ShiftJIS:
+    case FX_Charset::kShiftJIS:
       return CHARSET_FLAG_SHIFTJIS;
-    case FX_CHARSET_ChineseSimplified:
+    case FX_Charset::kChineseSimplified:
       return CHARSET_FLAG_GB;
-    case FX_CHARSET_ChineseTraditional:
+    case FX_Charset::kChineseTraditional:
       return CHARSET_FLAG_BIG5;
-    case FX_CHARSET_Hangul:
+    case FX_Charset::kHangul:
       return CHARSET_FLAG_KOREAN;
-    case FX_CHARSET_Symbol:
+    case FX_Charset::kSymbol:
       return CHARSET_FLAG_SYMBOL;
-    case FX_CHARSET_ANSI:
+    case FX_Charset::kANSI:
       return CHARSET_FLAG_ANSI;
     default:
       break;
@@ -268,27 +268,27 @@
     const uint8_t* p = os2.raw_str() + 78;
     uint32_t codepages = FXSYS_UINT32_GET_MSBFIRST(p);
     if (codepages & (1U << 17)) {
-      m_pMapper->AddInstalledFont(facename, FX_CHARSET_ShiftJIS);
+      m_pMapper->AddInstalledFont(facename, FX_Charset::kShiftJIS);
       pInfo->m_Charsets |= CHARSET_FLAG_SHIFTJIS;
     }
     if (codepages & (1U << 18)) {
-      m_pMapper->AddInstalledFont(facename, FX_CHARSET_ChineseSimplified);
+      m_pMapper->AddInstalledFont(facename, FX_Charset::kChineseSimplified);
       pInfo->m_Charsets |= CHARSET_FLAG_GB;
     }
     if (codepages & (1U << 20)) {
-      m_pMapper->AddInstalledFont(facename, FX_CHARSET_ChineseTraditional);
+      m_pMapper->AddInstalledFont(facename, FX_Charset::kChineseTraditional);
       pInfo->m_Charsets |= CHARSET_FLAG_BIG5;
     }
     if ((codepages & (1U << 19)) || (codepages & (1U << 21))) {
-      m_pMapper->AddInstalledFont(facename, FX_CHARSET_Hangul);
+      m_pMapper->AddInstalledFont(facename, FX_Charset::kHangul);
       pInfo->m_Charsets |= CHARSET_FLAG_KOREAN;
     }
     if (codepages & (1U << 31)) {
-      m_pMapper->AddInstalledFont(facename, FX_CHARSET_Symbol);
+      m_pMapper->AddInstalledFont(facename, FX_Charset::kSymbol);
       pInfo->m_Charsets |= CHARSET_FLAG_SYMBOL;
     }
   }
-  m_pMapper->AddInstalledFont(facename, FX_CHARSET_ANSI);
+  m_pMapper->AddInstalledFont(facename, FX_Charset::kANSI);
   pInfo->m_Charsets |= CHARSET_FLAG_ANSI;
   pInfo->m_Styles = 0;
   if (style.Contains("Bold"))
@@ -312,12 +312,12 @@
 
 void* CFX_FolderFontInfo::FindFont(int weight,
                                    bool bItalic,
-                                   int charset,
+                                   FX_Charset charset,
                                    int pitch_family,
                                    const char* family,
                                    bool bMatchName) {
   FontFaceInfo* pFind = nullptr;
-  if (charset == FX_CHARSET_ANSI && FontFamilyIsFixedPitch(pitch_family))
+  if (charset == FX_Charset::kANSI && FontFamilyIsFixedPitch(pitch_family))
     return GetFont("Courier New");
 
   ByteStringView bsFamily(family);
@@ -326,7 +326,7 @@
   for (const auto& it : m_FontList) {
     const ByteString& bsName = it.first;
     FontFaceInfo* pFont = it.second.get();
-    if (!(pFont->m_Charsets & charset_flag) && charset != FX_CHARSET_Default)
+    if (!(pFont->m_Charsets & charset_flag) && charset != FX_Charset::kDefault)
       continue;
 
     if (bMatchName && !FindFamilyNameMatch(bsFamily, bsName))
@@ -345,7 +345,7 @@
 
 void* CFX_FolderFontInfo::MapFont(int weight,
                                   bool bItalic,
-                                  int charset,
+                                  FX_Charset charset,
                                   int pitch_family,
                                   const char* family) {
   return nullptr;
@@ -404,7 +404,7 @@
   return true;
 }
 
-bool CFX_FolderFontInfo::GetFontCharset(void* hFont, int* charset) {
+bool CFX_FolderFontInfo::GetFontCharset(void* hFont, FX_Charset* charset) {
   return false;
 }
 
diff --git a/core/fxge/cfx_folderfontinfo.h b/core/fxge/cfx_folderfontinfo.h
index 05e8fb7..1c3875d 100644
--- a/core/fxge/cfx_folderfontinfo.h
+++ b/core/fxge/cfx_folderfontinfo.h
@@ -11,6 +11,7 @@
 #include <memory>
 #include <vector>
 
+#include "core/fxcrt/fx_codepage_forward.h"
 #include "core/fxcrt/unowned_ptr.h"
 #include "core/fxge/cfx_fontmapper.h"
 #include "core/fxge/systemfontinfo_iface.h"
@@ -29,11 +30,11 @@
 
   void AddPath(const ByteString& path);
 
-  // IFX_SytemFontInfo:
+  // SystemFontInfoIface:
   bool EnumFontList(CFX_FontMapper* pMapper) override;
   void* MapFont(int weight,
                 bool bItalic,
-                int charset,
+                FX_Charset charset,
                 int pitch_family,
                 const char* family) override;
   void* GetFont(const char* face) override;
@@ -42,7 +43,7 @@
                        pdfium::span<uint8_t> buffer) override;
   void DeleteFont(void* hFont) override;
   bool GetFaceName(void* hFont, ByteString* name) override;
-  bool GetFontCharset(void* hFont, int* charset) override;
+  bool GetFontCharset(void* hFont, FX_Charset* charset) override;
 
  protected:
   friend class CFX_FolderFontInfoTest;
@@ -73,7 +74,7 @@
   void* GetSubstFont(const ByteString& face);
   void* FindFont(int weight,
                  bool bItalic,
-                 int charset,
+                 FX_Charset charset,
                  int pitch_family,
                  const char* family,
                  bool bMatchName);
diff --git a/core/fxge/cfx_folderfontinfo_unittest.cpp b/core/fxge/cfx_folderfontinfo_unittest.cpp
index 2d38bc4..e416e06 100644
--- a/core/fxge/cfx_folderfontinfo_unittest.cpp
+++ b/core/fxge/cfx_folderfontinfo_unittest.cpp
@@ -43,7 +43,7 @@
 
   void* FindFont(int weight,
                  bool bItalic,
-                 int charset,
+                 FX_Charset charset,
                  int pitch_family,
                  const char* family,
                  bool bMatchName) {
@@ -69,57 +69,57 @@
 
 TEST_F(CFX_FolderFontInfoTest, TestFindFont) {
   // Find "Symbol" font
-  void* font = FindFont(/*weight=*/0, /*bItalic=*/false, FX_CHARSET_Symbol,
+  void* font = FindFont(/*weight=*/0, /*bItalic=*/false, FX_Charset::kSymbol,
                         FXFONT_FF_ROMAN, kSymbol, /*bMatchName=*/true);
   ASSERT_TRUE(font);
   EXPECT_EQ(GetFaceName(font), kSymbol);
 
   // Find "Calibri" font that is not present in the installed fonts
-  EXPECT_FALSE(FindFont(/*weight=*/0, /*bItalic=*/false, FX_CHARSET_Symbol,
+  EXPECT_FALSE(FindFont(/*weight=*/0, /*bItalic=*/false, FX_Charset::kSymbol,
                         FXFONT_FF_ROMAN, kCalibri, /*bMatchName=*/true));
 
   // Find the closest matching font to "Bookshelf" font that is present in the
   // installed fonts
-  font = FindFont(/*weight=*/0, /*bItalic=*/false, FX_CHARSET_Symbol,
+  font = FindFont(/*weight=*/0, /*bItalic=*/false, FX_Charset::kSymbol,
                   FXFONT_FF_ROMAN, kBookshelf, /*bMatchName=*/true);
   ASSERT_TRUE(font);
   EXPECT_EQ(GetFaceName(font), kBookshelfSymbol7);
 
   // Find "Book" font is expected to fail, because none of the installed fonts
   // is in the same font family.
-  EXPECT_FALSE(FindFont(/*weight=*/0, /*bItalic=*/false, FX_CHARSET_Symbol,
+  EXPECT_FALSE(FindFont(/*weight=*/0, /*bItalic=*/false, FX_Charset::kSymbol,
                         FXFONT_FF_ROMAN, kBook, /*bMatchName=*/true));
 
   // Find the closest matching font for "Tofu" in the installed fonts, which
   // has "," following the string "Tofu".
-  font = FindFont(/*weight=*/0, /*bItalic=*/false, FX_CHARSET_Symbol,
+  font = FindFont(/*weight=*/0, /*bItalic=*/false, FX_Charset::kSymbol,
                   FXFONT_FF_ROMAN, kTofu, /*bMatchName=*/true);
   ASSERT_TRUE(font);
   EXPECT_EQ(GetFaceName(font), kTofuBold);
 
   // Find the closest matching font for "Lato" in the installed fonts, which
   // has a space character following the string "Lato".
-  font = FindFont(/*weight=*/0, /*bItalic=*/false, FX_CHARSET_ANSI,
+  font = FindFont(/*weight=*/0, /*bItalic=*/false, FX_Charset::kANSI,
                   FXFONT_FF_ROMAN, kLato, /*bMatchName=*/true);
   ASSERT_TRUE(font);
   EXPECT_EQ(GetFaceName(font), kLatoUltraBold);
 
   // Find the closest matching font for "Oxygen" in the installed fonts,
   // which has "-" following the string "Oxygen".
-  font = FindFont(/*weight=*/0, /*bItalic=*/false, FX_CHARSET_ANSI,
+  font = FindFont(/*weight=*/0, /*bItalic=*/false, FX_Charset::kANSI,
                   FXFONT_FF_ROMAN, kOxygen, /*bMatchName=*/true);
   ASSERT_TRUE(font);
   EXPECT_EQ(GetFaceName(font), kOxygenSansSansBold);
 
   // Find the closest matching font for "Oxygen-Sans" in the installed fonts,
   // to test matching a family name with "-".
-  font = FindFont(/*weight=*/0, /*bItalic=*/false, FX_CHARSET_ANSI,
+  font = FindFont(/*weight=*/0, /*bItalic=*/false, FX_Charset::kANSI,
                   FXFONT_FF_ROMAN, kOxygenSans, /*bMatchName=*/true);
   ASSERT_TRUE(font);
   EXPECT_EQ(GetFaceName(font), kOxygenSansSansBold);
 
   // Find "Symbol" font when name matching is false
-  font = FindFont(/*weight=*/0, /*bItalic=*/false, FX_CHARSET_Symbol,
+  font = FindFont(/*weight=*/0, /*bItalic=*/false, FX_Charset::kSymbol,
                   FXFONT_FF_ROMAN, kSymbol, /*bMatchName=*/false);
   ASSERT_TRUE(font);
   EXPECT_EQ(GetFaceName(font), kBookshelfSymbol7);
diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp
index df2bab1..4f0e029 100644
--- a/core/fxge/cfx_font.cpp
+++ b/core/fxge/cfx_font.cpp
@@ -203,18 +203,18 @@
 }  // namespace
 
 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"},
+    {static_cast<int>(FX_Charset::kANSI), kDefaultAnsiFontName},
+    {static_cast<int>(FX_Charset::kChineseSimplified), "SimSun"},
+    {static_cast<int>(FX_Charset::kChineseTraditional), "MingLiU"},
+    {static_cast<int>(FX_Charset::kShiftJIS), "MS Gothic"},
+    {static_cast<int>(FX_Charset::kHangul), "Batang"},
+    {static_cast<int>(FX_Charset::kMSWin_Cyrillic), "Arial"},
 #if defined(OS_WIN)
-    {FX_CHARSET_MSWin_EasternEuropean, "Tahoma"},
+    {static_cast<int>(FX_Charset::kMSWin_EasternEuropean), "Tahoma"},
 #else
-    {FX_CHARSET_MSWin_EasternEuropean, "Arial"},
+    {static_cast<int>(FX_Charset::kMSWin_EasternEuropean), "Arial"},
 #endif
-    {FX_CHARSET_MSWin_Arabic, "Arial"},
+    {static_cast<int>(FX_Charset::kMSWin_Arabic), "Arial"},
     {-1, nullptr}};
 
 // static
@@ -227,63 +227,63 @@
 const char CFX_Font::kUniversalDefaultFontName[] = "Arial Unicode MS";
 
 // static
-ByteString CFX_Font::GetDefaultFontNameByCharset(uint8_t nCharset) {
+ByteString CFX_Font::GetDefaultFontNameByCharset(FX_Charset nCharset) {
   for (size_t i = 0; i < pdfium::size(kDefaultTTFMap) - 1; ++i) {
-    if (nCharset == static_cast<uint8_t>(kDefaultTTFMap[i].charset))
+    if (static_cast<int>(nCharset) == kDefaultTTFMap[i].charset)
       return kDefaultTTFMap[i].fontname;
   }
   return kUniversalDefaultFontName;
 }
 
 // static
-uint8_t CFX_Font::GetCharSetFromUnicode(uint16_t word) {
+FX_Charset CFX_Font::GetCharSetFromUnicode(uint16_t word) {
   // to avoid CJK Font to show ASCII
   if (word < 0x7F)
-    return FX_CHARSET_ANSI;
+    return FX_Charset::kANSI;
 
   // find new charset
   if ((word >= 0x4E00 && word <= 0x9FA5) ||
       (word >= 0xE7C7 && word <= 0xE7F3) ||
       (word >= 0x3000 && word <= 0x303F) ||
       (word >= 0x2000 && word <= 0x206F)) {
-    return FX_CHARSET_ChineseSimplified;
+    return FX_Charset::kChineseSimplified;
   }
 
   if (((word >= 0x3040) && (word <= 0x309F)) ||
       ((word >= 0x30A0) && (word <= 0x30FF)) ||
       ((word >= 0x31F0) && (word <= 0x31FF)) ||
       ((word >= 0xFF00) && (word <= 0xFFEF))) {
-    return FX_CHARSET_ShiftJIS;
+    return FX_Charset::kShiftJIS;
   }
 
   if (((word >= 0xAC00) && (word <= 0xD7AF)) ||
       ((word >= 0x1100) && (word <= 0x11FF)) ||
       ((word >= 0x3130) && (word <= 0x318F))) {
-    return FX_CHARSET_Hangul;
+    return FX_Charset::kHangul;
   }
 
   if (word >= 0x0E00 && word <= 0x0E7F)
-    return FX_CHARSET_Thai;
+    return FX_Charset::kThai;
 
   if ((word >= 0x0370 && word <= 0x03FF) || (word >= 0x1F00 && word <= 0x1FFF))
-    return FX_CHARSET_MSWin_Greek;
+    return FX_Charset::kMSWin_Greek;
 
   if ((word >= 0x0600 && word <= 0x06FF) || (word >= 0xFB50 && word <= 0xFEFC))
-    return FX_CHARSET_MSWin_Arabic;
+    return FX_Charset::kMSWin_Arabic;
 
   if (word >= 0x0590 && word <= 0x05FF)
-    return FX_CHARSET_MSWin_Hebrew;
+    return FX_Charset::kMSWin_Hebrew;
 
   if (word >= 0x0400 && word <= 0x04FF)
-    return FX_CHARSET_MSWin_Cyrillic;
+    return FX_Charset::kMSWin_Cyrillic;
 
   if (word >= 0x0100 && word <= 0x024F)
-    return FX_CHARSET_MSWin_EasternEuropean;
+    return FX_Charset::kMSWin_EasternEuropean;
 
   if (word >= 0x1E00 && word <= 0x1EFF)
-    return FX_CHARSET_MSWin_Vietnamese;
+    return FX_Charset::kMSWin_Vietnamese;
 
-  return FX_CHARSET_ANSI;
+  return FX_Charset::kANSI;
 }
 
 CFX_Font::CFX_Font() = default;
@@ -668,7 +668,7 @@
     uint32_t index = std::min<uint32_t>((m_pSubstFont->m_Weight - 400) / 10,
                                         kWeightPowArraySize - 1);
     int level;
-    if (m_pSubstFont->m_Charset == FX_CHARSET_ShiftJIS)
+    if (m_pSubstFont->m_Charset == FX_Charset::kShiftJIS)
       level = kWeightPowShiftJis[index] * 65536 / 36655;
     else
       level = kWeightPow[index];
@@ -717,11 +717,11 @@
 }
 
 // static
-int CFX_Font::GetWeightLevel(int charset, size_t index) {
+int CFX_Font::GetWeightLevel(FX_Charset charset, size_t index) {
   if (index >= kWeightPowArraySize)
     return -1;
 
-  if (charset == FX_CHARSET_ShiftJIS)
+  if (charset == FX_Charset::kShiftJIS)
     return kWeightPowShiftJis[index];
   return kWeightPow11[index];
 }
diff --git a/core/fxge/cfx_font.h b/core/fxge/cfx_font.h
index 57177e4..b3f2b16 100644
--- a/core/fxge/cfx_font.h
+++ b/core/fxge/cfx_font.h
@@ -36,7 +36,7 @@
  public:
   // This struct should be the same as FPDF_CharsetFontMap.
   struct CharsetFontMap {
-    int charset;           // Character Set Enum value, see FX_CHARSET_XXX.
+    int charset;           // Character Set Enum value, see FX_Charset::kXXX.
     const char* fontname;  // Name of default font to use with that charset.
   };
 
@@ -52,13 +52,13 @@
   static const char kUniversalDefaultFontName[];
 
   // Returns negative values on failure.
-  static int GetWeightLevel(int charset, size_t index);
+  static int GetWeightLevel(FX_Charset charset, size_t index);
 
   // |angle| is typically negative.
   static int GetSkewFromAngle(int angle);
 
-  static ByteString GetDefaultFontNameByCharset(uint8_t nCharset);
-  static uint8_t GetCharSetFromUnicode(uint16_t word);
+  static ByteString GetDefaultFontNameByCharset(FX_Charset nCharset);
+  static FX_Charset GetCharSetFromUnicode(uint16_t word);
 
   CFX_Font();
   ~CFX_Font();
diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp
index db28c20..fdb633d 100644
--- a/core/fxge/cfx_fontmapper.cpp
+++ b/core/fxge/cfx_fontmapper.cpp
@@ -314,7 +314,8 @@
   return bytes_read == size ? GetNameFromTT(buffer, 6) : ByteString();
 }
 
-void CFX_FontMapper::AddInstalledFont(const ByteString& name, int charset) {
+void CFX_FontMapper::AddInstalledFont(const ByteString& name,
+                                      FX_Charset charset) {
   if (!m_pFontInfo)
     return;
 
@@ -329,7 +330,7 @@
   if (bLocalized) {
     void* hFont = m_pFontInfo->GetFont(name.c_str());
     if (!hFont) {
-      hFont = m_pFontInfo->MapFont(0, 0, FX_CHARSET_Default, 0, name.c_str());
+      hFont = m_pFontInfo->MapFont(0, 0, FX_Charset::kDefault, 0, name.c_str());
       if (!hFont)
         return;
     }
@@ -425,12 +426,12 @@
   GetStandardFontName(&SubstName);
   if (SubstName == "Symbol" && !bTrueType) {
     pSubstFont->m_Family = "Chrome Symbol";
-    pSubstFont->m_Charset = FX_CHARSET_Symbol;
+    pSubstFont->m_Charset = FX_Charset::kSymbol;
     return UseInternalSubst(pSubstFont, 12, italic_angle, weight, 0);
   }
   if (SubstName == "ZapfDingbats") {
     pSubstFont->m_Family = "Chrome Dingbats";
-    pSubstFont->m_Charset = FX_CHARSET_Symbol;
+    pSubstFont->m_Charset = FX_Charset::kSymbol;
     return UseInternalSubst(pSubstFont, 13, italic_angle, weight, 0);
   }
   int iBaseFont = 0;
@@ -545,11 +546,11 @@
                             PitchFamily);
   }
 
-  int Charset = FX_CHARSET_ANSI;
+  FX_Charset Charset = FX_Charset::kANSI;
   if (code_page != FX_CodePage::kDefANSI)
     Charset = FX_GetCharsetFromCodePage(code_page);
   else if (iBaseFont == kNumStandardFonts && FontStyleIsSymbolic(flags))
-    Charset = FX_CHARSET_Symbol;
+    Charset = FX_Charset::kSymbol;
   const bool bCJK = FX_CharSetIsCJK(Charset);
   bool bItalic = FontStyleIsItalic(nStyle);
 
@@ -615,11 +616,11 @@
                                 PitchFamily);
       }
     } else {
-      if (Charset == FX_CHARSET_Symbol) {
+      if (Charset == FX_Charset::kSymbol) {
 #if defined(OS_APPLE) || defined(OS_ANDROID)
         if (SubstName == "Symbol") {
           pSubstFont->m_Family = "Chrome Symbol";
-          pSubstFont->m_Charset = FX_CHARSET_Symbol;
+          pSubstFont->m_Charset = FX_Charset::kSymbol;
           return UseInternalSubst(pSubstFont, 12, italic_angle, old_weight,
                                   PitchFamily);
         }
@@ -628,7 +629,7 @@
                              weight, italic_angle, FX_CodePage::kDefANSI,
                              pSubstFont);
       }
-      if (Charset == FX_CHARSET_ANSI) {
+      if (Charset == FX_Charset::kANSI) {
         return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight,
                                 PitchFamily);
       }
@@ -649,7 +650,7 @@
     return nullptr;
 
   m_pFontInfo->GetFaceName(hFont, &SubstName);
-  if (Charset == FX_CHARSET_Default)
+  if (Charset == FX_Charset::kDefault)
     m_pFontInfo->GetFontCharset(hFont, &Charset);
   uint32_t ttc_size = m_pFontInfo->GetFontData(hFont, kTableTTCF, {});
   uint32_t font_size = m_pFontInfo->GetFontData(hFont, 0, {});
@@ -733,7 +734,7 @@
   if (!m_pFontInfo)
     return nullptr;
 
-  void* hFont = m_pFontInfo->MapFont(0, 0, FX_CHARSET_Default, 0,
+  void* hFont = m_pFontInfo->MapFont(0, 0, FX_Charset::kDefault, 0,
                                      GetFaceName(index).c_str());
   if (!hFont)
     return nullptr;
diff --git a/core/fxge/cfx_fontmapper.h b/core/fxge/cfx_fontmapper.h
index cd200c7..7d0ea7b 100644
--- a/core/fxge/cfx_fontmapper.h
+++ b/core/fxge/cfx_fontmapper.h
@@ -57,7 +57,7 @@
   }
 
   void SetSystemFontInfo(std::unique_ptr<SystemFontInfoIface> pFontInfo);
-  void AddInstalledFont(const ByteString& name, int charset);
+  void AddInstalledFont(const ByteString& name, FX_Charset charset);
   void LoadInstalledFonts();
 
   RetainPtr<CFX_Face> FindSubstFont(const ByteString& face_name,
diff --git a/core/fxge/cfx_substfont.h b/core/fxge/cfx_substfont.h
index 46ecc0a..214ea3b 100644
--- a/core/fxge/cfx_substfont.h
+++ b/core/fxge/cfx_substfont.h
@@ -19,7 +19,7 @@
   void UseChromeSerif();
 
   ByteString m_Family;
-  int m_Charset = FX_CHARSET_ANSI;
+  FX_Charset m_Charset = FX_Charset::kANSI;
   int m_Weight = 0;
   int m_ItalicAngle = 0;
   int m_WeightCJK = 0;
diff --git a/core/fxge/cfx_unicodeencoding.cpp b/core/fxge/cfx_unicodeencoding.cpp
index 2e07cc1..94734f8 100644
--- a/core/fxge/cfx_unicodeencoding.cpp
+++ b/core/fxge/cfx_unicodeencoding.cpp
@@ -26,7 +26,7 @@
     return FT_Get_Char_Index(face, charcode);
 
   if (m_pFont->GetSubstFont() &&
-      m_pFont->GetSubstFont()->m_Charset == FX_CHARSET_Symbol) {
+      m_pFont->GetSubstFont()->m_Charset == FX_Charset::kSymbol) {
     uint32_t index = 0;
     if (FT_Select_Charmap(face, FT_ENCODING_MS_SYMBOL) == 0)
       index = FT_Get_Char_Index(face, charcode);
diff --git a/core/fxge/linux/fx_linux_impl.cpp b/core/fxge/linux/fx_linux_impl.cpp
index 5744612..b160060 100644
--- a/core/fxge/linux/fx_linux_impl.cpp
+++ b/core/fxge/linux/fx_linux_impl.cpp
@@ -83,10 +83,10 @@
   CFX_LinuxFontInfo() = default;
   ~CFX_LinuxFontInfo() override = default;
 
-  // CFX_LinuxFontInfo:
+  // CFX_FolderFontInfo:
   void* MapFont(int weight,
                 bool bItalic,
-                int charset,
+                FX_Charset charset,
                 int pitch_family,
                 const char* family) override;
 
@@ -95,7 +95,7 @@
 
 void* CFX_LinuxFontInfo::MapFont(int weight,
                                  bool bItalic,
-                                 int charset,
+                                 FX_Charset charset,
                                  int pitch_family,
                                  const char* family) {
   void* font = GetSubstFont(family);
@@ -104,7 +104,7 @@
 
   bool bCJK = true;
   switch (charset) {
-    case FX_CHARSET_ShiftJIS: {
+    case FX_Charset::kShiftJIS: {
       uint8_t index = GetJapanesePreference(family, weight, pitch_family);
       DCHECK(index < pdfium::size(g_LinuxJpFontList));
       for (const char* name : g_LinuxJpFontList[index]) {
@@ -114,7 +114,7 @@
       }
       break;
     }
-    case FX_CHARSET_ChineseSimplified: {
+    case FX_Charset::kChineseSimplified: {
       for (const char* name : g_LinuxGbFontList) {
         auto it = m_FontList.find(name);
         if (it != m_FontList.end())
@@ -122,7 +122,7 @@
       }
       break;
     }
-    case FX_CHARSET_ChineseTraditional: {
+    case FX_Charset::kChineseTraditional: {
       for (const char* name : g_LinuxB5FontList) {
         auto it = m_FontList.find(name);
         if (it != m_FontList.end())
@@ -130,7 +130,7 @@
       }
       break;
     }
-    case FX_CHARSET_Hangul: {
+    case FX_Charset::kHangul: {
       for (const char* name : g_LinuxHGFontList) {
         auto it = m_FontList.find(name);
         if (it != m_FontList.end())
diff --git a/core/fxge/systemfontinfo_iface.h b/core/fxge/systemfontinfo_iface.h
index 0aaff5e..222872b 100644
--- a/core/fxge/systemfontinfo_iface.h
+++ b/core/fxge/systemfontinfo_iface.h
@@ -7,6 +7,7 @@
 #ifndef CORE_FXGE_SYSTEMFONTINFO_IFACE_H_
 #define CORE_FXGE_SYSTEMFONTINFO_IFACE_H_
 
+#include "core/fxcrt/fx_codepage_forward.h"
 #include "core/fxge/cfx_fontmapper.h"
 #include "third_party/base/span.h"
 
@@ -20,7 +21,7 @@
   virtual bool EnumFontList(CFX_FontMapper* pMapper) = 0;
   virtual void* MapFont(int weight,
                         bool bItalic,
-                        int charset,
+                        FX_Charset charset,
                         int pitch_family,
                         const char* face) = 0;
   virtual void* GetFont(const char* face) = 0;
@@ -28,7 +29,7 @@
                                uint32_t table,
                                pdfium::span<uint8_t> buffer) = 0;
   virtual bool GetFaceName(void* hFont, ByteString* name) = 0;
-  virtual bool GetFontCharset(void* hFont, int* charset) = 0;
+  virtual bool GetFontCharset(void* hFont, FX_Charset* charset) = 0;
   virtual void DeleteFont(void* hFont) = 0;
 };
 
diff --git a/core/fxge/win32/cwin32_platform.cpp b/core/fxge/win32/cwin32_platform.cpp
index 743133c..d8e853e 100644
--- a/core/fxge/win32/cwin32_platform.cpp
+++ b/core/fxge/win32/cwin32_platform.cpp
@@ -71,7 +71,7 @@
   // CFX_FolderFontInfo:
   void* MapFont(int weight,
                 bool bItalic,
-                int charset,
+                FX_Charset charset,
                 int pitch_family,
                 const char* family) override;
 };
@@ -85,7 +85,7 @@
   bool EnumFontList(CFX_FontMapper* pMapper) override;
   void* MapFont(int weight,
                 bool bItalic,
-                int charset,
+                FX_Charset charset,
                 int pitch_family,
                 const char* face) override;
   void* GetFont(const char* face) override { return nullptr; }
@@ -93,7 +93,7 @@
                        uint32_t table,
                        pdfium::span<uint8_t> buffer) override;
   bool GetFaceName(void* hFont, ByteString* name) override;
-  bool GetFontCharset(void* hFont, int* charset) override;
+  bool GetFontCharset(void* hFont, FX_Charset* charset) override;
   void DeleteFont(void* hFont) override;
 
   bool IsOpenTypeFromDiv(const LOGFONTA* plf);
@@ -176,7 +176,7 @@
     return;
 
   if (name == m_LastFamily) {
-    m_pMapper->AddInstalledFont(name, plf->lfCharSet);
+    m_pMapper->AddInstalledFont(name, FX_GetCharsetFromInt(plf->lfCharSet));
     return;
   }
   if (!(font_type & TRUETYPE_FONTTYPE)) {
@@ -184,7 +184,7 @@
       return;
   }
 
-  m_pMapper->AddInstalledFont(name, plf->lfCharSet);
+  m_pMapper->AddInstalledFont(name, FX_GetCharsetFromInt(plf->lfCharSet));
   m_LastFamily = name;
 }
 
@@ -192,7 +192,7 @@
   m_pMapper = pMapper;
   LOGFONTA lf;
   memset(&lf, 0, sizeof(LOGFONTA));
-  lf.lfCharSet = FX_CHARSET_Default;
+  lf.lfCharSet = static_cast<int>(FX_Charset::kDefault);
   lf.lfFaceName[0] = 0;
   lf.lfPitchAndFamily = 0;
   EnumFontFamiliesExA(m_hDC, &lf, (FONTENUMPROCA)FontEnumProc, (uintptr_t)this,
@@ -219,7 +219,7 @@
 
 void* CFX_Win32FallbackFontInfo::MapFont(int weight,
                                          bool bItalic,
-                                         int charset,
+                                         FX_Charset charset,
                                          int pitch_family,
                                          const char* cstr_face) {
   void* font = GetSubstFont(cstr_face);
@@ -228,10 +228,10 @@
 
   bool bCJK = true;
   switch (charset) {
-    case FX_CHARSET_ShiftJIS:
-    case FX_CHARSET_ChineseSimplified:
-    case FX_CHARSET_ChineseTraditional:
-    case FX_CHARSET_Hangul:
+    case FX_Charset::kShiftJIS:
+    case FX_Charset::kChineseSimplified:
+    case FX_Charset::kChineseTraditional:
+    case FX_Charset::kHangul:
       break;
     default:
       bCJK = false;
@@ -309,7 +309,7 @@
 
 void* CFX_Win32FontInfo::MapFont(int weight,
                                  bool bItalic,
-                                 int charset,
+                                 FX_Charset charset,
                                  int pitch_family,
                                  const char* cstr_face) {
   ByteString face = cstr_face;
@@ -322,23 +322,23 @@
       break;
     }
   }
-  if (charset == FX_CHARSET_ANSI || charset == FX_CHARSET_Symbol)
-    charset = FX_CHARSET_Default;
+  if (charset == FX_Charset::kANSI || charset == FX_Charset::kSymbol)
+    charset = FX_Charset::kDefault;
 
   int subst_pitch_family = pitch_family;
   switch (charset) {
-    case FX_CHARSET_ShiftJIS:
+    case FX_Charset::kShiftJIS:
       subst_pitch_family = FF_ROMAN;
       break;
-    case FX_CHARSET_ChineseTraditional:
-    case FX_CHARSET_Hangul:
-    case FX_CHARSET_ChineseSimplified:
+    case FX_Charset::kChineseTraditional:
+    case FX_Charset::kHangul:
+    case FX_Charset::kChineseSimplified:
       subst_pitch_family = 0;
       break;
   }
-  HFONT hFont =
-      ::CreateFontA(-10, 0, 0, 0, weight, bItalic, 0, 0, charset,
-                    OUT_TT_ONLY_PRECIS, 0, 0, subst_pitch_family, face.c_str());
+  HFONT hFont = ::CreateFontA(-10, 0, 0, 0, weight, bItalic, 0, 0,
+                              static_cast<int>(charset), OUT_TT_ONLY_PRECIS, 0,
+                              0, subst_pitch_family, face.c_str());
   char facebuf[100];
   HFONT hOldFont = (HFONT)::SelectObject(m_hDC, hFont);
   ::GetTextFaceA(m_hDC, 100, facebuf);
@@ -359,20 +359,20 @@
       return hFont;
   }
   ::DeleteObject(hFont);
-  if (charset == FX_CHARSET_Default)
+  if (charset == FX_Charset::kDefault)
     return nullptr;
 
   switch (charset) {
-    case FX_CHARSET_ShiftJIS:
+    case FX_Charset::kShiftJIS:
       GetJapanesePreference(face, weight, pitch_family);
       break;
-    case FX_CHARSET_ChineseSimplified:
+    case FX_Charset::kChineseSimplified:
       GetGBPreference(face, weight, pitch_family);
       break;
-    case FX_CHARSET_Hangul:
+    case FX_Charset::kHangul:
       face = "Gulim";
       break;
-    case FX_CHARSET_ChineseTraditional:
+    case FX_Charset::kChineseTraditional:
       if (face.Contains("MSung")) {
         face = "MingLiU";
       } else {
@@ -380,9 +380,9 @@
       }
       break;
   }
-  hFont =
-      ::CreateFontA(-10, 0, 0, 0, weight, bItalic, 0, 0, charset,
-                    OUT_TT_ONLY_PRECIS, 0, 0, subst_pitch_family, face.c_str());
+  hFont = ::CreateFontA(-10, 0, 0, 0, weight, bItalic, 0, 0,
+                        static_cast<int>(charset), OUT_TT_ONLY_PRECIS, 0, 0,
+                        subst_pitch_family, face.c_str());
   return hFont;
 }
 
@@ -415,12 +415,12 @@
   return true;
 }
 
-bool CFX_Win32FontInfo::GetFontCharset(void* hFont, int* charset) {
+bool CFX_Win32FontInfo::GetFontCharset(void* hFont, FX_Charset* charset) {
   TEXTMETRIC tm;
   HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont);
   ::GetTextMetrics(m_hDC, &tm);
   ::SelectObject(m_hDC, hOldFont);
-  *charset = tm.tmCharSet;
+  *charset = FX_GetCharsetFromInt(tm.tmCharSet);
   return true;
 }