Move PDF_{Adobe,Unicode}NameFrom{Unicode,Adobe}() to core/fxge.

They are wrappers around FXFT_ functions, and don't require anything
else from core/fpdapi/font. In turn, this allows us to break a circular
include from core/fpdfapi/parser.

Move tests to new location as well.

Change-Id: I5a23fb1e941c43ffdf0b529c4eefad595c7bd9fc
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/55190
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/font/BUILD.gn b/core/fpdfapi/font/BUILD.gn
index b3bff1c..f479ab2 100644
--- a/core/fpdfapi/font/BUILD.gn
+++ b/core/fpdfapi/font/BUILD.gn
@@ -51,7 +51,6 @@
   if (is_mac) {
     libs = [ "CoreFoundation.framework" ]
   }
-  allow_circular_includes_from = [ "../parser" ]
   visibility = [ "../../../*" ]
 }
 
@@ -59,7 +58,6 @@
   sources = [
     "cpdf_cidfont_unittest.cpp",
     "cpdf_cmapparser_unittest.cpp",
-    "cpdf_fontencoding_unittest.cpp",
     "cpdf_tounicodemap_unittest.cpp",
   ]
   deps = [
diff --git a/core/fpdfapi/font/cpdf_fontencoding.cpp b/core/fpdfapi/font/cpdf_fontencoding.cpp
index bab36cb..00f7c98 100644
--- a/core/fpdfapi/font/cpdf_fontencoding.cpp
+++ b/core/fpdfapi/font/cpdf_fontencoding.cpp
@@ -13,6 +13,7 @@
 #include "core/fpdfapi/parser/cpdf_name.h"
 #include "core/fpdfapi/parser/cpdf_number.h"
 #include "core/fpdfapi/parser/fpdf_parser_decode.h"
+#include "core/fxge/fx_font.h"
 #include "core/fxge/fx_freetype.h"
 #include "third_party/base/ptr_util.h"
 
@@ -1769,16 +1770,6 @@
   return nullptr;
 }
 
-wchar_t PDF_UnicodeFromAdobeName(const char* name) {
-  return (wchar_t)(FXFT_unicode_from_adobe_name(name) & 0x7FFFFFFF);
-}
-
-ByteString PDF_AdobeNameFromUnicode(wchar_t unicode) {
-  char glyph_name[64];
-  FXFT_adobe_name_from_unicode(glyph_name, unicode);
-  return ByteString(glyph_name);
-}
-
 const char* PDF_CharNameFromPredefinedCharSet(int encoding, uint8_t charcode) {
   if (encoding == PDFFONT_ENCODING_PDFDOC) {
     if (charcode < kPDFDocEncodingTableFirstChar)
diff --git a/core/fpdfapi/font/cpdf_fontencoding.h b/core/fpdfapi/font/cpdf_fontencoding.h
index ca98851..56904c9 100644
--- a/core/fpdfapi/font/cpdf_fontencoding.h
+++ b/core/fpdfapi/font/cpdf_fontencoding.h
@@ -26,9 +26,6 @@
 uint32_t FT_CharCodeFromUnicode(int encoding, wchar_t unicode);
 wchar_t FT_UnicodeFromCharCode(int encoding, uint32_t charcode);
 
-wchar_t PDF_UnicodeFromAdobeName(const char* name);
-ByteString PDF_AdobeNameFromUnicode(wchar_t unicode);
-
 const uint16_t* PDF_UnicodesForPredefinedCharSet(int encoding);
 const char* PDF_CharNameFromPredefinedCharSet(int encoding, uint8_t charcode);
 
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp
index 417bfd6..0fca030 100644
--- a/core/fpdfapi/parser/cpdf_document.cpp
+++ b/core/fpdfapi/parser/cpdf_document.cpp
@@ -13,7 +13,6 @@
 
 #include "build/build_config.h"
 #include "core/fpdfapi/cpdf_modulemgr.h"
-#include "core/fpdfapi/font/cpdf_fontencoding.h"
 #include "core/fpdfapi/page/cpdf_docpagedata.h"
 #include "core/fpdfapi/page/cpdf_iccprofile.h"
 #include "core/fpdfapi/page/cpdf_pagemodule.h"
diff --git a/core/fxge/BUILD.gn b/core/fxge/BUILD.gn
index 6a5d13b..b149732 100644
--- a/core/fxge/BUILD.gn
+++ b/core/fxge/BUILD.gn
@@ -200,6 +200,7 @@
     "dib/cfx_cmyk_to_srgb_unittest.cpp",
     "dib/cfx_dibitmap_unittest.cpp",
     "dib/cstretchengine_unittest.cpp",
+    "fx_font_unittest.cpp",
   ]
   deps = [
     ":fxge",
diff --git a/core/fxge/fx_font.cpp b/core/fxge/fx_font.cpp
index 4b900b0..c8eb169 100644
--- a/core/fxge/fx_font.cpp
+++ b/core/fxge/fx_font.cpp
@@ -101,3 +101,13 @@
   }
   return ByteString();
 }
+
+wchar_t PDF_UnicodeFromAdobeName(const char* name) {
+  return (wchar_t)(FXFT_unicode_from_adobe_name(name) & 0x7FFFFFFF);
+}
+
+ByteString PDF_AdobeNameFromUnicode(wchar_t unicode) {
+  char glyph_name[64];
+  FXFT_adobe_name_from_unicode(glyph_name, unicode);
+  return ByteString(glyph_name);
+}
diff --git a/core/fxge/fx_font.h b/core/fxge/fx_font.h
index 5cf1bc2..1b03a6c 100644
--- a/core/fxge/fx_font.h
+++ b/core/fxge/fx_font.h
@@ -93,4 +93,7 @@
   return !!(family & FXFONT_FF_SCRIPT);
 }
 
+wchar_t PDF_UnicodeFromAdobeName(const char* name);
+ByteString PDF_AdobeNameFromUnicode(wchar_t unicode);
+
 #endif  // CORE_FXGE_FX_FONT_H_
diff --git a/core/fpdfapi/font/cpdf_fontencoding_unittest.cpp b/core/fxge/fx_font_unittest.cpp
similarity index 86%
rename from core/fpdfapi/font/cpdf_fontencoding_unittest.cpp
rename to core/fxge/fx_font_unittest.cpp
index 62bb8d4..1f98645 100644
--- a/core/fpdfapi/font/cpdf_fontencoding_unittest.cpp
+++ b/core/fxge/fx_font_unittest.cpp
@@ -2,11 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "core/fpdfapi/font/cpdf_fontencoding.h"
+#include "core/fxge/fx_font.h"
 
 #include "testing/gtest/include/gtest/gtest.h"
 
-TEST(CPDFFontEncodingTest, PDF_AdobeNameFromUnicode) {
+TEST(FXFontTest, PDF_AdobeNameFromUnicode) {
   EXPECT_STREQ("", PDF_AdobeNameFromUnicode(0x0000).c_str());
   EXPECT_STREQ("divide", PDF_AdobeNameFromUnicode(0x00f7).c_str());
   EXPECT_STREQ("Lslash", PDF_AdobeNameFromUnicode(0x0141).c_str());