Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
cpdf_bafontmap_unittest.cpp
Go to the documentation of this file.
1
// Copyright 2022 The PDFium Authors
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
"core/fpdfdoc/cpdf_bafontmap.h"
6
7
#
include
<
utility
>
8
9
#
include
"build/build_config.h"
10
#
include
"constants/annotation_common.h"
11
#
include
"core/fpdfapi/font/cpdf_font.h"
12
#
include
"core/fpdfapi/page/test_with_page_module.h"
13
#
include
"core/fpdfapi/parser/cpdf_dictionary.h"
14
#
include
"core/fpdfapi/parser/cpdf_name.h"
15
#
include
"core/fpdfapi/parser/cpdf_string.h"
16
#
include
"core/fpdfapi/parser/cpdf_test_document.h"
17
18
using
BAFontMapTest
=
TestWithPageModule
;
19
20
TEST_F
(
BAFontMapTest
,
DefaultFont
) {
21
// Without any font resources, CPDF_BAFontMap generates a default font.
22
CPDF_TestDocument
doc;
23
24
auto
annot_dict =
pdfium
::MakeRetain<
CPDF_Dictionary
>();
25
annot_dict->SetNewFor<CPDF_Name>(
pdfium
::
annotation
::
kSubtype
,
"Widget"
);
26
annot_dict->SetNewFor<CPDF_String>(
"DA"
,
"0 0 0 rg /F1 12 Tf"
);
27
28
CPDF_BAFontMap font_map(&doc,
std
::move(annot_dict),
"N"
);
29
#
if
!
BUILDFLAG
(
IS_WIN
)
30
// TODO(thestig): Figure out why this does not work on Windows.
31
EXPECT_EQ(font_map.GetPDFFontAlias(0),
"Helvetica_00"
);
32
#
endif
33
RetainPtr
<
CPDF_Font
> font = font_map.GetPDFFont(0);
34
ASSERT_TRUE(font);
35
EXPECT_TRUE(font->IsType1Font());
36
EXPECT_EQ(font->GetBaseFontName(),
"Helvetica"
);
37
}
38
39
TEST_F
(
BAFontMapTest
,
Bug853238
) {
40
CPDF_TestDocument
doc;
41
auto
root_dict =
pdfium
::MakeRetain<
CPDF_Dictionary
>();
42
auto
acroform_dict = root_dict->SetNewFor<
CPDF_Dictionary
>(
"AcroForm"
);
43
auto
annot_dr_dict = acroform_dict->SetNewFor<
CPDF_Dictionary
>(
"DR"
);
44
auto
annot_font_dict = annot_dr_dict->SetNewFor<
CPDF_Dictionary
>(
"Font"
);
45
auto
annot_font_f1_dict = annot_font_dict->SetNewFor<
CPDF_Dictionary
>(
"F1"
);
46
annot_font_f1_dict->SetNewFor<CPDF_Name>(
"Type"
,
"Font"
);
47
annot_font_f1_dict->SetNewFor<CPDF_Name>(
"Subtype"
,
"Type1"
);
48
annot_font_f1_dict->SetNewFor<CPDF_Name>(
"BaseFont"
,
"Times-Roman"
);
49
doc
.
SetRoot
(
root_dict
)
;
50
51
auto
annot_dict =
pdfium
::MakeRetain<
CPDF_Dictionary
>();
52
annot_dict->SetNewFor<CPDF_Name>(
pdfium
::
annotation
::
kSubtype
,
"Widget"
);
53
annot_dict->SetNewFor<CPDF_String>(
"DA"
,
"0 0 0 rg /F1 12 Tf"
);
54
55
CPDF_BAFontMap font_map(&doc,
std
::move(annot_dict),
"N"
);
56
EXPECT_EQ(font_map
.
GetPDFFontAlias
(
0
)
,
"F1"
);
57
RetainPtr
<
CPDF_Font
> font = font_map.GetPDFFont(0);
58
ASSERT_TRUE(font);
59
EXPECT_TRUE(font->IsType1Font());
60
EXPECT_EQ(font->GetBaseFontName(),
"Times-Roman"
);
61
}
CPDF_BAFontMap::GetPDFFontAlias
ByteString GetPDFFontAlias(int32_t nFontIndex) override
Definition
cpdf_bafontmap.cpp:104
CPDF_Dictionary::DictMap
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
Definition
cpdf_dictionary.h:31
CPDF_Font
Definition
cpdf_font.h:37
CPDF_TestDocument
Definition
cpdf_test_document.h:13
CPDF_TestDocument::SetRoot
void SetRoot(RetainPtr< CPDF_Dictionary > root)
Definition
cpdf_test_document.cpp:17
TestWithPageModule
Definition
test_with_page_module.h:10
fxcrt::RetainPtr
Definition
retain_ptr.h:28
pdfium::CFDETextOutLargeBitmapTest
Definition
cfde_textout_unittest.cpp:117
BAFontMapTest
TestWithPageModule BAFontMapTest
Definition
cpdf_bafontmap_unittest.cpp:18
TEST_F
TEST_F(CPDF_CIDFontTest, Bug920636)
Definition
cpdf_cidfont_unittest.cpp:19
pdfium::annotation::kSubtype
const char kSubtype[]
Definition
annotation_common.cpp:12
pdfium
Definition
annotation_common.cpp:7
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fpdfdoc
cpdf_bafontmap_unittest.cpp
Generated on
for Qt by
1.18.0