Remove raw wchar_t pointers from fgas/font

-- Order CFGAS_FontMgr::LoadFont() args consistently wrt other methods.

Change-Id: I518f2ba3621783d14ea5737eedd8841603664439
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/86610
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/xfa/fgas/font/cfgas_defaultfontmanager.cpp b/xfa/fgas/font/cfgas_defaultfontmanager.cpp
index 3f0bb24..46e3854 100644
--- a/xfa/fgas/font/cfgas_defaultfontmanager.cpp
+++ b/xfa/fgas/font/cfgas_defaultfontmanager.cpp
@@ -15,17 +15,15 @@
 
 // static
 RetainPtr<CFGAS_GEFont> CFGAS_DefaultFontManager::GetFont(
-    WideStringView wsFontFamily,
+    const WideString& wsFontFamily,
     uint32_t dwFontStyles) {
-  WideString wsFontName(wsFontFamily);
   CFGAS_FontMgr* pFontMgr = CFGAS_GEModule::Get()->GetFontMgr();
-  RetainPtr<CFGAS_GEFont> pFont = pFontMgr->LoadFont(
-      wsFontName.c_str(), dwFontStyles, FX_CodePage::kFailure);
+  RetainPtr<CFGAS_GEFont> pFont =
+      pFontMgr->LoadFont(FX_CodePage::kFailure, dwFontStyles, wsFontFamily);
   if (pFont)
     return pFont;
 
-  const FGAS_FontInfo* pCurFont =
-      FGAS_FontInfoByFontName(wsFontName.AsStringView());
+  const FGAS_FontInfo* pCurFont = FGAS_FontInfoByFontName(wsFontFamily);
   if (!pCurFont || !pCurFont->pReplaceFont)
     return pFont;
 
@@ -46,8 +44,7 @@
     }
     WideString wsReplace =
         WideString::FromASCII(ByteStringView(pReplace, pNameText - pReplace));
-    pFont =
-        pFontMgr->LoadFont(wsReplace.c_str(), dwStyle, FX_CodePage::kFailure);
+    pFont = pFontMgr->LoadFont(FX_CodePage::kFailure, dwStyle, wsReplace);
     if (pFont)
       break;
 
@@ -63,9 +60,9 @@
     uint32_t dwFontStyles) {
   CFGAS_FontMgr* pFontMgr = CFGAS_GEModule::Get()->GetFontMgr();
   RetainPtr<CFGAS_GEFont> pFont =
-      pFontMgr->LoadFont(L"Arial Narrow", dwFontStyles, FX_CodePage::kFailure);
+      pFontMgr->LoadFont(FX_CodePage::kFailure, dwFontStyles, L"Arial Narrow");
   if (pFont)
     return pFont;
 
-  return pFontMgr->LoadFont(nullptr, dwFontStyles, FX_CodePage::kFailure);
+  return pFontMgr->LoadFont(FX_CodePage::kFailure, dwFontStyles, L"");
 }
diff --git a/xfa/fgas/font/cfgas_defaultfontmanager.h b/xfa/fgas/font/cfgas_defaultfontmanager.h
index bb78189..b9a4385 100644
--- a/xfa/fgas/font/cfgas_defaultfontmanager.h
+++ b/xfa/fgas/font/cfgas_defaultfontmanager.h
@@ -14,7 +14,7 @@
 
 class CFGAS_DefaultFontManager {
  public:
-  static RetainPtr<CFGAS_GEFont> GetFont(WideStringView wsFontFamily,
+  static RetainPtr<CFGAS_GEFont> GetFont(const WideString& wsFontFamily,
                                          uint32_t dwFontStyles);
   static RetainPtr<CFGAS_GEFont> GetDefaultFont(uint32_t dwFontStyles);
 
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index 8af8e70..fd075f3 100644
--- a/xfa/fgas/font/cfgas_fontmgr.cpp
+++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -153,14 +153,14 @@
   return 1;
 }
 
-std::deque<FX_FONTDESCRIPTOR> EnumGdiFonts(const wchar_t* pwsFaceName,
+std::deque<FX_FONTDESCRIPTOR> EnumGdiFonts(const WideString& pwsFaceName,
                                            wchar_t wUnicode) {
   std::deque<FX_FONTDESCRIPTOR> fonts;
   LOGFONTW lfFind;
   memset(&lfFind, 0, sizeof(lfFind));
   lfFind.lfCharSet = DEFAULT_CHARSET;
-  if (pwsFaceName) {
-    FXSYS_wcsncpy(lfFind.lfFaceName, pwsFaceName, 31);
+  if (!pwsFaceName.IsEmpty()) {
+    FXSYS_wcsncpy(lfFind.lfFaceName, pwsFaceName.c_str(), 31);
     lfFind.lfFaceName[31] = 0;
   }
   HDC hDC = ::GetDC(nullptr);
@@ -183,15 +183,15 @@
 RetainPtr<CFGAS_GEFont> CFGAS_FontMgr::GetFontByUnicodeImpl(
     wchar_t wUnicode,
     uint32_t dwFontStyles,
-    const wchar_t* pszFontFamily,
+    const WideString& wsFontFamily,
     uint32_t dwHash,
     FX_CodePage wCodePage,
     uint16_t wBitField) {
-  const FX_FONTDESCRIPTOR* pFD = FindFont(pszFontFamily, dwFontStyles, false,
+  const FX_FONTDESCRIPTOR* pFD = FindFont(wsFontFamily, dwFontStyles, false,
                                           wCodePage, wBitField, wUnicode);
-  if (!pFD && pszFontFamily) {
-    pFD =
-        FindFont(nullptr, dwFontStyles, false, wCodePage, wBitField, wUnicode);
+  if (!pFD && !wsFontFamily.IsEmpty()) {
+    pFD = FindFont(WideString(), dwFontStyles, false, wCodePage, wBitField,
+                   wUnicode);
   }
   if (!pFD)
     return nullptr;
@@ -212,7 +212,7 @@
   return pFont;
 }
 
-const FX_FONTDESCRIPTOR* CFGAS_FontMgr::FindFont(const wchar_t* pszFontFamily,
+const FX_FONTDESCRIPTOR* CFGAS_FontMgr::FindFont(const WideString& wsFontFamily,
                                                  uint32_t dwFontStyles,
                                                  bool matchParagraphStyle,
                                                  FX_CodePage wCodePage,
@@ -223,7 +223,7 @@
   params.dwUSB = dwUSB;
   params.wUnicode = wUnicode;
   params.wCodePage = wCodePage;
-  params.pwsFamily = pszFontFamily;
+  params.pwsFamily = wsFontFamily.c_str();
   params.dwFontStyles = dwFontStyles;
   params.matchParagraphStyle = matchParagraphStyle;
 
@@ -231,14 +231,14 @@
   if (pDesc)
     return pDesc;
 
-  if (!pszFontFamily)
+  if (wsFontFamily.IsEmpty())
     return nullptr;
 
   // Use a named object to store the returned value of EnumGdiFonts() instead
   // of using a temporary object. This can prevent use-after-free issues since
   // pDesc may point to one of std::deque object's elements.
   std::deque<FX_FONTDESCRIPTOR> namedFonts =
-      EnumGdiFonts(pszFontFamily, wUnicode);
+      EnumGdiFonts(wsFontFamily, wUnicode);
   params.pwsFamily = nullptr;
   pDesc = MatchDefaultFont(&params, namedFonts);
   if (!pDesc)
@@ -622,7 +622,7 @@
 
     WideString wsFaceName =
         WideString::FromDefANSI(pFontMapper->GetFaceName(i).AsStringView());
-    RegisterFaces(pFontStream, &wsFaceName);
+    RegisterFaces(pFontStream, wsFaceName);
   }
 
   return !m_InstalledFonts.empty();
@@ -635,13 +635,13 @@
 RetainPtr<CFGAS_GEFont> CFGAS_FontMgr::GetFontByUnicodeImpl(
     wchar_t wUnicode,
     uint32_t dwFontStyles,
-    const wchar_t* pszFontFamily,
+    const WideString& wsFontFamily,
     uint32_t dwHash,
     FX_CodePage wCodePage,
     uint16_t /* wBitField*/) {
   if (!m_Hash2CandidateList[dwHash].has_value()) {
     m_Hash2CandidateList[dwHash] =
-        MatchFonts(wCodePage, dwFontStyles, pszFontFamily, wUnicode);
+        MatchFonts(wCodePage, dwFontStyles, wsFontFamily, wUnicode);
   }
   for (const auto& info : m_Hash2CandidateList[dwHash].value()) {
     CFGAS_FontDescriptor* pDesc = info.pFont;
@@ -655,7 +655,7 @@
     m_Hash2Fonts[dwHash].push_back(pFont);
     return pFont;
   }
-  if (!pszFontFamily)
+  if (wsFontFamily.IsEmpty())
     m_FailedUnicodesSet.insert(wUnicode);
   return nullptr;
 }
@@ -695,7 +695,7 @@
 }
 
 void CFGAS_FontMgr::RegisterFace(RetainPtr<CFX_Face> pFace,
-                                 const WideString* pFaceName) {
+                                 const WideString& pFaceName) {
   if ((pFace->GetRec()->face_flags & FT_FACE_FLAG_SCALABLE) == 0)
     return;
 
@@ -720,8 +720,8 @@
   pFont->m_wsFamilyNames.push_back(
       WideString::FromUTF8(pFace->GetRec()->family_name));
   pFont->m_wsFaceName =
-      pFaceName
-          ? *pFaceName
+      !pFaceName.IsEmpty()
+          ? pFaceName
           : WideString::FromDefANSI(FT_Get_Postscript_Name(pFace->GetRec()));
   pFont->m_nFaceIndex = pFace->GetRec()->face_index;
   m_InstalledFonts.push_back(std::move(pFont));
@@ -729,7 +729,7 @@
 
 void CFGAS_FontMgr::RegisterFaces(
     const RetainPtr<IFX_SeekableReadStream>& pFontStream,
-    const WideString* pFaceName) {
+    const WideString& pFaceName) {
   int32_t index = 0;
   int32_t num_faces = 0;
   do {
@@ -750,9 +750,9 @@
 RetainPtr<CFGAS_GEFont> CFGAS_FontMgr::GetFontByCodePage(
     FX_CodePage wCodePage,
     uint32_t dwFontStyles,
-    const wchar_t* pszFontFamily) {
+    const WideString& wsFontFamily) {
   ByteString bsHash = ByteString::Format("%d, %d", wCodePage, dwFontStyles);
-  bsHash += FX_UTF8Encode(WideStringView(pszFontFamily));
+  bsHash += FX_UTF8Encode(wsFontFamily.AsStringView());
   uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringView());
   auto* pFontVector = &m_Hash2Fonts[dwHash];
   if (!pFontVector->empty()) {
@@ -765,7 +765,7 @@
 
 #if defined(OS_WIN)
   const FX_FONTDESCRIPTOR* pFD =
-      FindFont(pszFontFamily, dwFontStyles, true, wCodePage, 999, 0);
+      FindFont(wsFontFamily, dwFontStyles, true, wCodePage, 999, 0);
   if (!pFD)
     pFD = FindFont(nullptr, dwFontStyles, true, wCodePage, 999, 0);
   if (!pFD)
@@ -778,7 +778,7 @@
 #else   // defined(OS_WIN)
   if (!m_Hash2CandidateList[dwHash].has_value()) {
     m_Hash2CandidateList[dwHash] =
-        MatchFonts(wCodePage, dwFontStyles, WideString(pszFontFamily), 0);
+        MatchFonts(wCodePage, dwFontStyles, WideString(wsFontFamily), 0);
   }
   std::vector<CFGAS_FontDescriptorInfo>* sortedFontInfos =
       &m_Hash2CandidateList[dwHash].value();
@@ -801,7 +801,7 @@
 RetainPtr<CFGAS_GEFont> CFGAS_FontMgr::GetFontByUnicode(
     wchar_t wUnicode,
     uint32_t dwFontStyles,
-    const wchar_t* pszFontFamily) {
+    const WideString& wsFontFamily) {
   if (pdfium::Contains(m_FailedUnicodesSet, wUnicode))
     return nullptr;
 
@@ -815,7 +815,7 @@
   } else {
     bsHash = ByteString::Format("%d, %d", wCodePage, dwFontStyles);
   }
-  bsHash += FX_UTF8Encode(WideStringView(pszFontFamily));
+  bsHash += FX_UTF8Encode(wsFontFamily.AsStringView());
   uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringView());
   std::vector<RetainPtr<CFGAS_GEFont>>& fonts = m_Hash2Fonts[dwHash];
   for (auto& pFont : fonts) {
@@ -823,25 +823,26 @@
       return pFont;
   }
 
-  return GetFontByUnicodeImpl(wUnicode, dwFontStyles, pszFontFamily, dwHash,
+  return GetFontByUnicodeImpl(wUnicode, dwFontStyles, wsFontFamily, dwHash,
                               wCodePage, wBitField);
 }
 
-RetainPtr<CFGAS_GEFont> CFGAS_FontMgr::LoadFont(const wchar_t* pszFontFamily,
-                                                uint32_t dwFontStyles,
-                                                FX_CodePage wCodePage) {
+RetainPtr<CFGAS_GEFont> CFGAS_FontMgr::LoadFont(
+    FX_CodePage wCodePage,
+    uint32_t dwFontStyles,
+    const WideString& wsFontFamily) {
 #if defined(OS_WIN)
   ByteString bsHash = ByteString::Format("%d, %d", wCodePage, dwFontStyles);
-  bsHash += FX_UTF8Encode(WideStringView(pszFontFamily));
+  bsHash += FX_UTF8Encode(wsFontFamily.AsStringView());
   uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringView());
   std::vector<RetainPtr<CFGAS_GEFont>>* pFontArray = &m_Hash2Fonts[dwHash];
   if (!pFontArray->empty())
     return (*pFontArray)[0];
 
   const FX_FONTDESCRIPTOR* pFD =
-      FindFont(pszFontFamily, dwFontStyles, true, wCodePage, 999, 0);
+      FindFont(wsFontFamily, dwFontStyles, true, wCodePage, 999, 0);
   if (!pFD)
-    pFD = FindFont(pszFontFamily, dwFontStyles, false, wCodePage, 999, 0);
+    pFD = FindFont(wsFontFamily, dwFontStyles, false, wCodePage, 999, 0);
   if (!pFD)
     return nullptr;
 
@@ -854,6 +855,6 @@
   pFontArray->push_back(pFont);
   return pFont;
 #else   // defined(OS_WIN)
-  return GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily);
+  return GetFontByCodePage(wCodePage, dwFontStyles, wsFontFamily);
 #endif  // defined(OS_WIN)
 }
diff --git a/xfa/fgas/font/cfgas_fontmgr.h b/xfa/fgas/font/cfgas_fontmgr.h
index 460a0ca..27981fc 100644
--- a/xfa/fgas/font/cfgas_fontmgr.h
+++ b/xfa/fgas/font/cfgas_fontmgr.h
@@ -102,24 +102,24 @@
   bool EnumFonts();
   RetainPtr<CFGAS_GEFont> GetFontByCodePage(FX_CodePage wCodePage,
                                             uint32_t dwFontStyles,
-                                            const wchar_t* pszFontFamily);
+                                            const WideString& wsFontFamily);
   RetainPtr<CFGAS_GEFont> GetFontByUnicode(wchar_t wUnicode,
                                            uint32_t dwFontStyles,
-                                           const wchar_t* pszFontFamily);
-  RetainPtr<CFGAS_GEFont> LoadFont(const wchar_t* pszFontFamily,
+                                           const WideString& wsFontFamily);
+  RetainPtr<CFGAS_GEFont> LoadFont(FX_CodePage wCodePage,
                                    uint32_t dwFontStyles,
-                                   FX_CodePage wCodePage);
+                                   const WideString& wsFontFamily);
 
  private:
   RetainPtr<CFGAS_GEFont> GetFontByUnicodeImpl(wchar_t wUnicode,
                                                uint32_t dwFontStyles,
-                                               const wchar_t* pszFontFamily,
+                                               const WideString& wsFontFamily,
                                                uint32_t dwHash,
                                                FX_CodePage wCodePage,
                                                uint16_t wBitField);
 
 #if defined(OS_WIN)
-  const FX_FONTDESCRIPTOR* FindFont(const wchar_t* pszFontFamily,
+  const FX_FONTDESCRIPTOR* FindFont(const WideString& wsFontFamily,
                                     uint32_t dwFontStyles,
                                     bool matchParagraphStyle,
                                     FX_CodePage wCodePage,
@@ -128,9 +128,9 @@
 
 #else   // defined(OS_WIN)
   bool EnumFontsFromFontMapper();
-  void RegisterFace(RetainPtr<CFX_Face> pFace, const WideString* pFaceName);
+  void RegisterFace(RetainPtr<CFX_Face> pFace, const WideString& pFaceName);
   void RegisterFaces(const RetainPtr<IFX_SeekableReadStream>& pFontStream,
-                     const WideString* pFaceName);
+                     const WideString& pFaceName);
   std::vector<CFGAS_FontDescriptorInfo> MatchFonts(FX_CodePage wCodePage,
                                                    uint32_t dwFontStyles,
                                                    const WideString& FontName,
diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp
index 9ab418a..383ea92 100644
--- a/xfa/fgas/font/cfgas_gefont.cpp
+++ b/xfa/fgas/font/cfgas_gefont.cpp
@@ -21,17 +21,17 @@
 #include "xfa/fgas/font/fgas_fontutils.h"
 
 // static
-RetainPtr<CFGAS_GEFont> CFGAS_GEFont::LoadFont(const wchar_t* pszFontFamily,
+RetainPtr<CFGAS_GEFont> CFGAS_GEFont::LoadFont(const WideString& wsFontFamily,
                                                uint32_t dwFontStyles,
                                                FX_CodePage wCodePage) {
 #if defined(OS_WIN)
   auto pFont = pdfium::MakeRetain<CFGAS_GEFont>();
-  if (!pFont->LoadFontInternal(pszFontFamily, dwFontStyles, wCodePage))
+  if (!pFont->LoadFontInternal(wsFontFamily, dwFontStyles, wCodePage))
     return nullptr;
   return pFont;
 #else
   return CFGAS_GEModule::Get()->GetFontMgr()->GetFontByCodePage(
-      wCodePage, dwFontStyles, pszFontFamily);
+      wCodePage, dwFontStyles, wsFontFamily);
 #endif
 }
 
@@ -69,18 +69,15 @@
 CFGAS_GEFont::~CFGAS_GEFont() = default;
 
 #if defined(OS_WIN)
-bool CFGAS_GEFont::LoadFontInternal(const wchar_t* pszFontFamily,
+bool CFGAS_GEFont::LoadFontInternal(const WideString& wsFontFamily,
                                     uint32_t dwFontStyles,
                                     FX_CodePage wCodePage) {
   if (m_pFont)
     return false;
-  ByteString csFontFamily;
-  if (pszFontFamily)
-    csFontFamily = WideString(pszFontFamily).ToDefANSI();
 
+  ByteString csFontFamily = wsFontFamily.ToDefANSI();
   int32_t iWeight =
       FontStyleIsForceBold(dwFontStyles) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL;
-  m_pFont = std::make_unique<CFX_Font>();
   if (FontStyleIsItalic(dwFontStyles) && FontStyleIsForceBold(dwFontStyles))
     csFontFamily += ",BoldItalic";
   else if (FontStyleIsForceBold(dwFontStyles))
@@ -88,6 +85,7 @@
   else if (FontStyleIsItalic(dwFontStyles))
     csFontFamily += ",Italic";
 
+  m_pFont = std::make_unique<CFX_Font>();
   m_pFont->LoadSubst(csFontFamily, true, dwFontStyles, iWeight, 0, wCodePage,
                      false);
   return m_pFont->GetFaceRec() && InitFont();
@@ -241,7 +239,7 @@
       pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), wsFamily.c_str());
 #if !defined(OS_WIN)
   if (!pFont)
-    pFont = pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), nullptr);
+    pFont = pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), WideString());
 #endif
   if (!pFont || pFont == this)  // Avoids direct cycles below.
     return {0xFFFF, nullptr};
diff --git a/xfa/fgas/font/cfgas_gefont.h b/xfa/fgas/font/cfgas_gefont.h
index 4adaac0..f183905 100644
--- a/xfa/fgas/font/cfgas_gefont.h
+++ b/xfa/fgas/font/cfgas_gefont.h
@@ -31,7 +31,7 @@
  public:
   CONSTRUCT_VIA_MAKE_RETAIN;
 
-  static RetainPtr<CFGAS_GEFont> LoadFont(const wchar_t* pszFontFamily,
+  static RetainPtr<CFGAS_GEFont> LoadFont(const WideString& wsFontFamily,
                                           uint32_t dwFontStyles,
                                           FX_CodePage wCodePage);
   static RetainPtr<CFGAS_GEFont> LoadFont(const RetainPtr<CPDF_Font>& pFont);
@@ -58,7 +58,7 @@
   ~CFGAS_GEFont() override;
 
 #if defined(OS_WIN)
-  bool LoadFontInternal(const wchar_t* pszFontFamily,
+  bool LoadFontInternal(const WideString& wsFontFamily,
                         uint32_t dwFontStyles,
                         FX_CodePage wCodePage);
 #endif
diff --git a/xfa/fgas/font/fgas_fontutils.cpp b/xfa/fgas/font/fgas_fontutils.cpp
index 1d28e70..ba6ef1c 100644
--- a/xfa/fgas/font/fgas_fontutils.cpp
+++ b/xfa/fgas/font/fgas_fontutils.cpp
@@ -2446,8 +2446,9 @@
   return nullptr;
 }
 
-WideString FGAS_FontNameToEnglishName(WideStringView wsLocalName) {
-  uint32_t dwLocalNameHash = FX_HashCode_GetLoweredW(wsLocalName);
+WideString FGAS_FontNameToEnglishName(const WideString& wsLocalName) {
+  uint32_t dwLocalNameHash =
+      FX_HashCode_GetLoweredW(wsLocalName.AsStringView());
   const FGAS_FontInfo* pEnd = kXFAFontsMap + pdfium::size(kXFAFontsMap);
   const FGAS_FontInfo* pFontInfo =
       std::lower_bound(kXFAFontsMap, pEnd, dwLocalNameHash,
@@ -2456,11 +2457,11 @@
                        });
   if (pFontInfo < pEnd && pFontInfo->dwFontNameHash == dwLocalNameHash)
     return WideString::FromASCII(ByteStringView(pFontInfo->pPsName));
-  return WideString(wsLocalName);
+  return wsLocalName;
 }
 
-const FGAS_FontInfo* FGAS_FontInfoByFontName(WideStringView wsFontName) {
-  WideString wsFontNameTemp(wsFontName);
+const FGAS_FontInfo* FGAS_FontInfoByFontName(const WideString& wsFontName) {
+  WideString wsFontNameTemp = wsFontName;
   wsFontNameTemp.Remove(L' ');
   uint32_t dwCurFontNameHash =
       FX_HashCode_GetLoweredW(wsFontNameTemp.AsStringView());
diff --git a/xfa/fgas/font/fgas_fontutils.h b/xfa/fgas/font/fgas_fontutils.h
index 055d019..13aae9e 100644
--- a/xfa/fgas/font/fgas_fontutils.h
+++ b/xfa/fgas/font/fgas_fontutils.h
@@ -29,7 +29,7 @@
   FX_CodePage wCodePage;
 };
 
-WideString FGAS_FontNameToEnglishName(WideStringView wsLocalName);
-const FGAS_FontInfo* FGAS_FontInfoByFontName(WideStringView wsFontName);
+WideString FGAS_FontNameToEnglishName(const WideString& wsLocalName);
+const FGAS_FontInfo* FGAS_FontInfoByFontName(const WideString& wsFontName);
 
 #endif  // XFA_FGAS_FONT_FGAS_FONTUTILS_H_
diff --git a/xfa/fwl/theme/cfwl_fontmanager.cpp b/xfa/fwl/theme/cfwl_fontmanager.cpp
index be7106b..a4ba4ef 100644
--- a/xfa/fwl/theme/cfwl_fontmanager.cpp
+++ b/xfa/fwl/theme/cfwl_fontmanager.cpp
@@ -33,9 +33,10 @@
 
 CFWL_FontManager::~CFWL_FontManager() = default;
 
-RetainPtr<CFGAS_GEFont> CFWL_FontManager::FindFont(WideStringView wsFontFamily,
-                                                   uint32_t dwFontStyles,
-                                                   FX_CodePage wCodePage) {
+RetainPtr<CFGAS_GEFont> CFWL_FontManager::FindFont(
+    const WideString& wsFontFamily,
+    uint32_t dwFontStyles,
+    FX_CodePage wCodePage) {
   for (const auto& pData : m_FontsArray) {
     if (pData->Equal(wsFontFamily, dwFontStyles, wCodePage))
       return pData->GetFont();
@@ -52,23 +53,21 @@
 
 CFWL_FontManager::FontData::~FontData() = default;
 
-bool CFWL_FontManager::FontData::Equal(WideStringView wsFontFamily,
+bool CFWL_FontManager::FontData::Equal(const WideString& wsFontFamily,
                                        uint32_t dwFontStyles,
                                        FX_CodePage wCodePage) {
   return m_wsFamily == wsFontFamily && m_dwStyles == dwFontStyles &&
          m_dwCodePage == wCodePage;
 }
 
-bool CFWL_FontManager::FontData::LoadFont(WideStringView wsFontFamily,
+bool CFWL_FontManager::FontData::LoadFont(const WideString& wsFontFamily,
                                           uint32_t dwFontStyles,
                                           FX_CodePage dwCodePage) {
   m_wsFamily = wsFontFamily;
   m_dwStyles = dwFontStyles;
   m_dwCodePage = dwCodePage;
 
-  // TODO(tsepez): check usage of c_str() below.
-  m_pFont = CFGAS_GEFont::LoadFont(wsFontFamily.unterminated_c_str(),
-                                   dwFontStyles, dwCodePage);
+  m_pFont = CFGAS_GEFont::LoadFont(wsFontFamily, dwFontStyles, dwCodePage);
   return !!m_pFont;
 }
 
diff --git a/xfa/fwl/theme/cfwl_fontmanager.h b/xfa/fwl/theme/cfwl_fontmanager.h
index 319866c..a96a8d8 100644
--- a/xfa/fwl/theme/cfwl_fontmanager.h
+++ b/xfa/fwl/theme/cfwl_fontmanager.h
@@ -23,7 +23,7 @@
   static CFWL_FontManager* GetInstance();
   static void DestroyInstance();
 
-  RetainPtr<CFGAS_GEFont> FindFont(WideStringView wsFontFamily,
+  RetainPtr<CFGAS_GEFont> FindFont(const WideString& wsFontFamily,
                                    uint32_t dwFontStyles,
                                    FX_CodePage dwCodePage);
 
@@ -33,10 +33,10 @@
     FontData();
     ~FontData();
 
-    bool Equal(WideStringView wsFontFamily,
+    bool Equal(const WideString& wsFontFamily,
                uint32_t dwFontStyles,
                FX_CodePage wCodePage);
-    bool LoadFont(WideStringView wsFontFamily,
+    bool LoadFont(const WideString& wsFontFamily,
                   uint32_t dwFontStyles,
                   FX_CodePage wCodePage);
     RetainPtr<CFGAS_GEFont> GetFont() const;
diff --git a/xfa/fxfa/cxfa_fontmgr.cpp b/xfa/fxfa/cxfa_fontmgr.cpp
index 882b4f7..dcaf50e 100644
--- a/xfa/fxfa/cxfa_fontmgr.cpp
+++ b/xfa/fxfa/cxfa_fontmgr.cpp
@@ -23,9 +23,9 @@
 void CXFA_FontMgr::Trace(cppgc::Visitor* visitor) const {}
 
 RetainPtr<CFGAS_GEFont> CXFA_FontMgr::GetFont(CXFA_FFDoc* hDoc,
-                                              WideStringView wsFontFamily,
+                                              const WideString& wsFontFamily,
                                               uint32_t dwFontStyles) {
-  uint32_t dwHash = FX_HashCode_GetW(wsFontFamily);
+  uint32_t dwHash = FX_HashCode_GetW(wsFontFamily.AsStringView());
   ByteString bsKey = ByteString::Format("%u%u%u", dwHash, dwFontStyles, 0xFFFF);
   auto iter = m_FontMap.find(bsKey);
   if (iter != m_FontMap.end())
diff --git a/xfa/fxfa/cxfa_fontmgr.h b/xfa/fxfa/cxfa_fontmgr.h
index d905265..ba28baa 100644
--- a/xfa/fxfa/cxfa_fontmgr.h
+++ b/xfa/fxfa/cxfa_fontmgr.h
@@ -24,7 +24,7 @@
 
   void Trace(cppgc::Visitor* visitor) const;
   RetainPtr<CFGAS_GEFont> GetFont(CXFA_FFDoc* hDoc,
-                                  WideStringView wsFontFamily,
+                                  const WideString& wsFontFamily,
                                   uint32_t dwFontStyles);
 
  private:
diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp
index 1877eeb..c6c8729 100644
--- a/xfa/fxfa/cxfa_textparser.cpp
+++ b/xfa/fxfa/cxfa_textparser.cpp
@@ -363,7 +363,7 @@
   }
 
   CXFA_FontMgr* pFontMgr = doc->GetApp()->GetXFAFontMgr();
-  return pFontMgr->GetFont(doc, wsFamily.AsStringView(), dwStyle);
+  return pFontMgr->GetFont(doc, wsFamily, dwStyle);
 }
 
 float CXFA_TextParser::GetFontSize(CXFA_TextProvider* pTextProvider,
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 64bb803..188875f 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -3935,8 +3935,7 @@
 
     wsFontName = font->GetTypeface();
   }
-  return doc->GetApp()->GetXFAFontMgr()->GetFont(doc, wsFontName.AsStringView(),
-                                                 dwFontStyle);
+  return doc->GetApp()->GetXFAFontMgr()->GetFont(doc, wsFontName, dwFontStyle);
 }
 
 bool CXFA_Node::HasButtonRollover() const {