Move the Noto font file for testing to top-level third-party directory.

This CL moves the subset font file for NotoSansSC-Regular to PDFium's
top-level third-party directory, and changes the README.pdfium file to
comply with Chromium's guideline adding_to_third_party.md.

This CL also renamed the directory name to "NotoSansCJK/" so that more
Noto CJK fonts can be added in the same directory for increasing test
coverage in PDFIum embedder tests.

Bug: pdfium:1608
Change-Id: I28d59dceaa63e66d9a537d9d1485b307b2223167
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/75930
Commit-Queue: Hui Yingst <nigi@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp
index 98f85ce..e7cda4b 100644
--- a/fpdfsdk/fpdf_edit_embeddertest.cpp
+++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
@@ -240,9 +240,8 @@
   EXPECT_TRUE(CreateEmptyDocument());
   ScopedFPDFPage page(FPDFPage_New(document(), 0, 400, 400));
   std::string font_path;
-  ASSERT_TRUE(PathService::GetTestFilePath(
-      "fonts/third_party/NotoSansSC/NotoSansSC-Regular.subset.otf",
-      &font_path));
+  ASSERT_TRUE(PathService::GetThirdPartyFilePath(
+      "NotoSansCJK/NotoSansSC-Regular.subset.otf", &font_path));
 
   size_t file_length = 0;
   std::unique_ptr<char, pdfium::FreeDeleter> font_data =
diff --git a/testing/resources/fonts/third_party/NotoSansSC/README.pdfium b/testing/resources/fonts/third_party/NotoSansSC/README.pdfium
deleted file mode 100644
index 8e07d2a..0000000
--- a/testing/resources/fonts/third_party/NotoSansSC/README.pdfium
+++ /dev/null
@@ -1,19 +0,0 @@
-Noto Sans SC Font:
-
-1. Source Origin
-Google's Internationalisation team's:
-https://github.com/googlei18n/noto-cjk
-
-2. LICENSE AND OPENSOURCE
-For license information, see the LICENSE.txt file
-
-3. Reason:
-This font file is used for the test FPDFEditEmbedderTest.EmbedNotoSansSCFont.
-The font file is included as a real-world example for testing PDFium's API to
-embed a CJK font into a PDF file, which contains multiple unicodes mapped to
-the same CID. See crbug.com/pdfium/1608 for details.
-
-Command to generate the font subset:
-$ pyftsubset NotoSansSC-Regular.otf --unicodes="U+0000884C,U+0000FA08,U+0000F906,U+000053E5,U+00008FD9,U+0000662F,U+00007B2C,U+00004E00,U+00003002,U+00004E8C,U+00002F00,U+00002F06"
-
-where pyftsubset comes from https://github.com/behdad/fonttools
diff --git a/testing/utils/path_service.cpp b/testing/utils/path_service.cpp
index 5e1ce39..97158a3 100644
--- a/testing/utils/path_service.cpp
+++ b/testing/utils/path_service.cpp
@@ -160,3 +160,35 @@
   path->append(file_name);
   return true;
 }
+
+// static
+bool PathService::GetThirdPartyFilePath(const std::string& file_name,
+                                        std::string* path) {
+  if (!GetSourceDir(path))
+    return false;
+
+  if (!EndsWithSeparator(*path))
+    path->push_back(PATH_SEPARATOR);
+
+  std::string potential_path = *path;
+  potential_path.append("third_party");
+  if (PathService::DirectoryExists(potential_path)) {
+    *path = potential_path;
+    path->append(PATH_SEPARATOR + file_name);
+    return true;
+  }
+
+  potential_path = *path;
+  potential_path.append("third_party");
+  potential_path.push_back(PATH_SEPARATOR);
+  potential_path.append("pdfium");
+  potential_path.push_back(PATH_SEPARATOR);
+  potential_path.append("third_party");
+  if (PathService::DirectoryExists(potential_path)) {
+    *path = potential_path;
+    path->append(PATH_SEPARATOR + file_name);
+    return true;
+  }
+
+  return false;
+}
diff --git a/testing/utils/path_service.h b/testing/utils/path_service.h
index 63df808..32a759a 100644
--- a/testing/utils/path_service.h
+++ b/testing/utils/path_service.h
@@ -37,5 +37,9 @@
 
   // Get the full path for a test file under the test data directory.
   static bool GetTestFilePath(const std::string& file_name, std::string* path);
+
+  // Get the full path for a file under the third-party directory.
+  static bool GetThirdPartyFilePath(const std::string& file_name,
+                                    std::string* path);
 };
 #endif  // TESTING_UTILS_PATH_SERVICE_H_
diff --git a/testing/resources/fonts/third_party/NotoSansSC/LICENSE.txt b/third_party/NotoSansCJK/LICENSE
similarity index 100%
rename from testing/resources/fonts/third_party/NotoSansSC/LICENSE.txt
rename to third_party/NotoSansCJK/LICENSE
diff --git a/testing/resources/fonts/third_party/NotoSansSC/NotoSansSC-Regular.subset.otf b/third_party/NotoSansCJK/NotoSansSC-Regular.subset.otf
similarity index 100%
rename from testing/resources/fonts/third_party/NotoSansSC/NotoSansSC-Regular.subset.otf
rename to third_party/NotoSansCJK/NotoSansSC-Regular.subset.otf
Binary files differ
diff --git a/third_party/NotoSansCJK/README.pdfium b/third_party/NotoSansCJK/README.pdfium
new file mode 100644
index 0000000..c1de98e
--- /dev/null
+++ b/third_party/NotoSansCJK/README.pdfium
@@ -0,0 +1,22 @@
+Name: Noto Sans CJK Font
+URL: https://github.com/googlefonts/noto-cjk
+Version: Noto Sans CJK V2.001
+License: SIL Open Font License v1.1
+License File: LICENSE
+
+Description:
+NotoSansSC-Regular.subset.otf constains a subset of NotoSansSC-Regular font.
+This font file is used for the test FPDFEditEmbedderTest.EmbedNotoSansSCFont,
+and it is included as a real-world example for testing PDFium's API to embed a
+CJK font into a PDF file, which contains multiple unicodes mapped to the same
+CID. See crbug.com/pdfium/1608 for details.
+
+Local Modifications:
+
+NotoSansSC-Regular.subset.otf is a subset of NotoSansSC-Regular font.
+Command to generate this font subset:
+$ pyftsubset NotoSansSC-Regular.otf --unicodes="U+0000884C,U+0000FA08, \
+U+0000F906,U+000053E5,U+00008FD9,U+0000662F,U+00007B2C,U+00004E00,U+00003002, \
+U+00004E8C,U+00002F00,U+00002F06"
+
+where pyftsubset comes from https://github.com/behdad/fonttools