46 absl::optional<ByteString> result;
48 result = CFX_PSRenderer::GenerateType42SfntDataForTesting(
"empty", {});
49 EXPECT_FALSE(result.has_value());
51 constexpr uint8_t kOddByteCountTestData[] = {0, 32, 55};
52 static constexpr char kExpectedOddByteCountResult[] = R"(/odd_sfnts [
53<
54002037
55>
56] def
57)";
58 result = CFX_PSRenderer::GenerateType42SfntDataForTesting(
59 "odd", kOddByteCountTestData);
60 ASSERT_TRUE(result.has_value());
61 EXPECT_STREQ(kExpectedOddByteCountResult, result.value().c_str());
64 constexpr uint8_t kEvenByteCountTestData[] = {0, 32, 66, 77};
65 static constexpr char kExpectedEvenByteCountResult[] = R"(/even_sfnts [
66<
670020424D00
68>
69] def
70)";
71 result = CFX_PSRenderer::GenerateType42SfntDataForTesting(
72 "even", kEvenByteCountTestData);
73 ASSERT_TRUE(result.has_value());
74 EXPECT_STREQ(kExpectedEvenByteCountResult, result.value().c_str());
80 static constexpr char kExpected1DescendantFontResult[] = R"(8 dict begin
81/FontType 42 def
82/FontMatrix [1 0 0 1 0 0] def
83/FontName /1descendant_0 def
84/Encoding 3 array
85dup 0 /c00 put
86dup 1 /c01 put
87dup 2 /c02 put
88readonly def
89/FontBBox [1 2 3 4] def
90/PaintType 0 def
91/CharStrings 4 dict dup begin
92/.notdef 0 def
93/c00 0 def
94/c01 1 def
95/c02 2 def
96end readonly def
97/sfnts 1descendant_sfnts def
98FontName currentdict end definefont pop
996 dict begin
100/FontName /1descendant def
101/FontType 0 def
102/FontMatrix [1 0 0 1 0 0] def
103/FMapType 2 def
104/Encoding [
1050
106] def
107/FDepVector [
108/1descendant_0 findfont
109] def
110FontName currentdict end definefont pop
111%%EndResource
112)";
113 result = CFX_PSRenderer::GenerateType42FontDictionaryForTesting(
116 EXPECT_STREQ(kExpected1DescendantFontResult, result
.c_str());
118 static constexpr char kExpected2DescendantFontResult[] = R"(8 dict begin
119/FontType 42 def
120/FontMatrix [1 0 0 1 0 0] def
121/FontName /2descendant_0 def
122/Encoding 3 array
123dup 0 /c00 put
124dup 1 /c01 put
125dup 2 /c02 put
126readonly def
127/FontBBox [12 -5 34 199] def
128/PaintType 0 def
129/CharStrings 4 dict dup begin
130/.notdef 0 def
131/c00 0 def
132/c01 1 def
133/c02 2 def
134end readonly def
135/sfnts 2descendant_sfnts def
136FontName currentdict end definefont pop
1378 dict begin
138/FontType 42 def
139/FontMatrix [1 0 0 1 0 0] def
140/FontName /2descendant_1 def
141/Encoding 3 array
142dup 0 /c00 put
143dup 1 /c01 put
144readonly def
145/FontBBox [12 -5 34 199] def
146/PaintType 0 def
147/CharStrings 4 dict dup begin
148/.notdef 0 def
149/c00 3 def
150/c01 4 def
151end readonly def
152/sfnts 2descendant_sfnts def
153FontName currentdict end definefont pop
1546 dict begin
155/FontName /2descendant def
156/FontType 0 def
157/FontMatrix [1 0 0 1 0 0] def
158/FMapType 2 def
159/Encoding [
1600
1611
162] def
163/FDepVector [
164/2descendant_0 findfont
165/2descendant_1 findfont
166] def
167FontName currentdict end definefont pop
168%%EndResource
169)";
170 result = CFX_PSRenderer::GenerateType42FontDictionaryForTesting(
173 EXPECT_STREQ(kExpected2DescendantFontResult, result
.c_str());
177 static constexpr char kExpectedOutput[] = R"(
178save
179/im/initmatrix load def
180/n/newpath load def/m/moveto load def/l/lineto load def/c/curveto load def/h/closepath load def
181/f/fill load def/F/eofill load def/s/stroke load def/W/clip load def/W*/eoclip load def
182/rg/setrgbcolor load def/k/setcmykcolor load def
183/J/setlinecap load def/j/setlinejoin load def/w/setlinewidth load def/M/setmiterlimit load def/d/setdash load def
184/q/gsave load def/Q/grestore load def/iM/imagemask load def
185/Tj/show load def/Ff/findfont load def/Fs/scalefont load def/Sf/setfont load def
186/cm/concat load def/Cm/currentmatrix load def/mx/matrix load def/sm/setmatrix load def
187q
188[1 0 0 1 0 0]cm 10 2 1[10 0 0 -2 0 2]currentfile/ASCII85Decode filter false 1 colorimage
189dummya85
190Q
191
192restore
193)";
194 auto output_stream = pdfium::MakeRetain<TestWriteStream>();
197 constexpr int kWidth = 10;
198 constexpr int kHeight = 2;
200 const EncoderIface encoder_interface{&FakeA85Encode,
nullptr,
nullptr,
206 auto bitmap = pdfium::MakeRetain<CFX_DIBitmap>();
213 ByteString output(output_stream->GetSpan());
214 EXPECT_STREQ(output
.c_str(), kExpectedOutput);