5#include "public/fpdf_sysfontinfo.h"
9#include "testing/embedder_test.h"
10#include "testing/embedder_test_environment.h"
11#include "testing/gmock/include/gmock/gmock.h"
12#include "testing/gtest/include/gtest/gtest.h"
18void FakeRelease(FPDF_SYSFONTINFO* pThis) {}
19void FakeEnumFonts(FPDF_SYSFONTINFO* pThis,
void* pMapper) {}
21void* FakeMapFont(FPDF_SYSFONTINFO* pThis,
32void* FakeGetFont(FPDF_SYSFONTINFO* pThis,
const char* face) {
37unsigned long FakeGetFontData(FPDF_SYSFONTINFO* pThis,
40 unsigned char* buffer,
41 unsigned long buf_size) {
45unsigned long FakeGetFaceName(FPDF_SYSFONTINFO* pThis,
48 unsigned long buf_size) {
52int FakeGetFontCharset(FPDF_SYSFONTINFO* pThis,
void* hFont) {
56void FakeDeleteFont(FPDF_SYSFONTINFO* pThis,
void* hFont) {}
60class FPDFUnavailableSysFontInfoEmbedderTest :
public EmbedderTest {
62 FPDFUnavailableSysFontInfoEmbedderTest() =
default;
63 ~FPDFUnavailableSysFontInfoEmbedderTest() override =
default;
65 void SetUp() override {
79 void TearDown() override {
88 FPDF_SYSFONTINFO font_info_;
93 FPDFSysFontInfoEmbedderTest() =
default;
94 ~FPDFSysFontInfoEmbedderTest() override =
default;
96 void SetUp() override {
99 ASSERT_TRUE(font_info_);
103 void TearDown() override {
116 FPDF_SYSFONTINFO* font_info_;
122 ASSERT_TRUE(OpenDocument(
"bug_972518.pdf"));
123 ASSERT_EQ(1, FPDF_GetPageCount(document()));
125 FPDF_PAGE page = LoadPage(0);
131 ASSERT_TRUE(OpenDocument(
"hello_world.pdf"));
132 ASSERT_EQ(1, FPDF_GetPageCount(document()));
134 FPDF_PAGE page = LoadPage(0);
139 ScopedFPDFBitmap bitmap = RenderPage(page);
140 ASSERT_EQ(200, FPDFBitmap_GetWidth(bitmap.get()));
141 ASSERT_EQ(200, FPDFBitmap_GetHeight(bitmap.get()));
148 static constexpr int kExpectedCharsets[] = {
154 std::vector<
int> charsets;
169 EXPECT_THAT(charsets, testing::UnorderedElementsAreArray(kExpectedCharsets));
static EmbedderTestEnvironment * GetInstance()
FPDF_EXPORT void FPDF_CALLCONV FPDF_SetSystemFontInfo(FPDF_SYSFONTINFO *pFontInfoExt)
FPDF_EXPORT const FPDF_CharsetFontMap *FPDF_CALLCONV FPDF_GetDefaultTTFMap()
FPDF_EXPORT FPDF_SYSFONTINFO *FPDF_CALLCONV FPDF_GetDefaultSystemFontInfo()
FPDF_EXPORT void FPDF_CALLCONV FPDF_FreeDefaultSystemFontInfo(FPDF_SYSFONTINFO *pFontInfo)
#define FXFONT_HANGEUL_CHARSET
#define FXFONT_EASTERNEUROPEAN_CHARSET
#define FXFONT_SHIFTJIS_CHARSET
#define FXFONT_CYRILLIC_CHARSET
#define FXFONT_ANSI_CHARSET
#define FXFONT_ARABIC_CHARSET
#define FXFONT_GB2312_CHARSET
#define FXFONT_CHINESEBIG5_CHARSET
TEST_F(FPDFUnavailableSysFontInfoEmbedderTest, Bug_972518)
TEST_F(FPDFSysFontInfoEmbedderTest, DefaultSystemFontInfo)
void(* Release)(struct _FPDF_SYSFONTINFO *pThis)
void(* DeleteFont)(struct _FPDF_SYSFONTINFO *pThis, void *hFont)
unsigned long(* GetFontData)(struct _FPDF_SYSFONTINFO *pThis, void *hFont, unsigned int table, unsigned char *buffer, unsigned long buf_size)
void *(* GetFont)(struct _FPDF_SYSFONTINFO *pThis, const char *face)
unsigned long(* GetFaceName)(struct _FPDF_SYSFONTINFO *pThis, void *hFont, char *buffer, unsigned long buf_size)
int(* GetFontCharset)(struct _FPDF_SYSFONTINFO *pThis, void *hFont)
void(* EnumFonts)(struct _FPDF_SYSFONTINFO *pThis, void *pMapper)
void *(* MapFont)(struct _FPDF_SYSFONTINFO *pThis, int weight, FPDF_BOOL bItalic, int charset, int pitch_family, const char *face, FPDF_BOOL *bExact)