1 // Copyright 2018 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <string>
6
7 #include "core/fxge/cfx_folderfontinfo.h"
8 #include "core/fxge/cfx_fontmapper.h"
9 #include "core/fxge/fx_font.h"
10
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/utils/path_service.h"
13
TEST(FXFontTest,PDF_AdobeNameFromUnicode)14 TEST(FXFontTest, PDF_AdobeNameFromUnicode) {
15 EXPECT_STREQ("", PDF_AdobeNameFromUnicode(0x0000).c_str());
16 EXPECT_STREQ("divide", PDF_AdobeNameFromUnicode(0x00f7).c_str());
17 EXPECT_STREQ("Lslash", PDF_AdobeNameFromUnicode(0x0141).c_str());
18 EXPECT_STREQ("tonos", PDF_AdobeNameFromUnicode(0x0384).c_str());
19 EXPECT_STREQ("afii57513", PDF_AdobeNameFromUnicode(0x0691).c_str());
20 EXPECT_STREQ("angkhankhuthai", PDF_AdobeNameFromUnicode(0x0e5a).c_str());
21 EXPECT_STREQ("Euro", PDF_AdobeNameFromUnicode(0x20ac).c_str());
22 }
23
TEST(FXFontTest,ReadFontNameFromMicrosoftEntries)24 TEST(FXFontTest, ReadFontNameFromMicrosoftEntries) {
25 std::string test_data_dir;
26 PathService::GetTestDataDir(&test_data_dir);
27 ASSERT(!test_data_dir.empty());
28
29 CFX_FontMapper font_mapper(nullptr);
30
31 {
32 // |folder_font_info| has to be deallocated before the |font_mapper| or we
33 // run into UnownedPtr class issues with ASAN.
34 CFX_FolderFontInfo folder_font_info;
35 folder_font_info.AddPath(
36 (test_data_dir + PATH_SEPARATOR + "font_tests").c_str());
37
38 font_mapper.SetSystemFontInfo(SystemFontInfoIface::CreateDefault(nullptr));
39 ASSERT_TRUE(folder_font_info.EnumFontList(&font_mapper));
40 }
41
42 ASSERT_EQ(1, font_mapper.GetFaceSize());
43 ASSERT_EQ("Test", font_mapper.GetFaceName(0));
44 }
45