Add CFX_Font::kUntitledFontName.

Use in place of various "Untitled" strings.

Change-Id: I922bb2219e7f11ec9189d422a9fa9c52407a9a9a
Reviewed-on: https://pdfium-review.googlesource.com/c/49653
Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp
index 64423eb..9ce720d 100644
--- a/core/fxge/cfx_font.cpp
+++ b/core/fxge/cfx_font.cpp
@@ -224,7 +224,11 @@
     {-1, nullptr}};
 
 // static
+const char CFX_Font::kUntitledFontName[] = "Untitled";
+
+// static
 const char CFX_Font::kDefaultAnsiFontName[] = "Helvetica";
+
 // static
 const char CFX_Font::kUniversalDefaultFontName[] = "Arial Unicode MS";
 
@@ -504,7 +508,7 @@
 
   ByteString psName = FXFT_Get_Postscript_Name(m_Face.Get());
   if (psName.IsEmpty())
-    psName = "Untitled";
+    psName = kUntitledFontName;
   return psName;
 }
 
@@ -524,7 +528,7 @@
     ByteString style = ByteString(FXFT_Get_Face_Style_Name(m_Face.Get()));
     ByteString facename = GetFamilyName();
     if (facename.IsEmpty())
-      facename = "Untitled";
+      facename = kUntitledFontName;
     if (!style.IsEmpty() && style != "Regular")
       facename += " " + style;
     return facename;
@@ -534,7 +538,7 @@
 
 ByteString CFX_Font::GetBaseFontName(bool restrict_to_psname) const {
   ByteString psname = GetPsName();
-  if (restrict_to_psname || (!psname.IsEmpty() && psname != "Untitled"))
+  if (restrict_to_psname || (!psname.IsEmpty() && psname != kUntitledFontName))
     return psname;
   if (!m_Face && !m_pSubstFont)
     return ByteString();
@@ -542,7 +546,7 @@
     ByteString style = ByteString(FXFT_Get_Face_Style_Name(m_Face.Get()));
     ByteString facename = GetFamilyName();
     if (facename.IsEmpty())
-      facename = "Untitled";
+      facename = kUntitledFontName;
     if (IsTTFont())
       facename.Remove(' ');
     if (!style.IsEmpty() && style != "Regular")
diff --git a/core/fxge/cfx_font.h b/core/fxge/cfx_font.h
index 7e78110..8888216 100644
--- a/core/fxge/cfx_font.h
+++ b/core/fxge/cfx_font.h
@@ -31,6 +31,9 @@
   CFX_Font();
   ~CFX_Font();
 
+  // Used when the font name is empty.
+  static const char kUntitledFontName[];
+
   static const char kDefaultAnsiFontName[];
   static const char kUniversalDefaultFontName[];
   static ByteString GetDefaultFontNameByCharset(uint8_t nCharset);
diff --git a/fpdfsdk/fpdf_edittext.cpp b/fpdfsdk/fpdf_edittext.cpp
index 45749f0..9f7969b 100644
--- a/fpdfsdk/fpdf_edittext.cpp
+++ b/fpdfsdk/fpdf_edittext.cpp
@@ -271,7 +271,7 @@
       "Subtype", font_type == FPDF_FONT_TYPE1 ? "Type1" : "TrueType");
   ByteString name = pFont->GetBaseFontName(font_type == FPDF_FONT_TYPE1);
   if (name.IsEmpty())
-    name = "Untitled";
+    name = CFX_Font::kUntitledFontName;
   fontDict->SetNewFor<CPDF_Name>("BaseFont", name);
 
   uint32_t glyphIndex;
@@ -316,7 +316,7 @@
   fontDict->SetNewFor<CPDF_Name>("Encoding", encoding);
   ByteString name = pFont->GetBaseFontName(font_type == FPDF_FONT_TYPE1);
   if (name.IsEmpty())
-    name = "Untitled";
+    name = CFX_Font::kUntitledFontName;
   fontDict->SetNewFor<CPDF_Name>(
       "BaseFont", font_type == FPDF_FONT_TYPE1 ? name + "-" + encoding : name);