@@ -25,12 +25,14 @@ You should have received a copy of the GNU Affero General Public License
25
25
using iText . Kernel ;
26
26
using iText . Kernel . Pdf ;
27
27
using iText . Test ;
28
+ using iText . Test . Attributes ;
28
29
29
30
namespace iText . Kernel . Font {
30
31
public class PdfType3FontTest : ExtendedITextTest {
31
32
private const float EPS = 1e-4f ;
32
33
33
34
[ NUnit . Framework . Test ]
35
+ [ LogMessage ( iText . IO . LogMessageConstant . TYPE3_FONT_INITIALIZATION_ISSUE ) ]
34
36
public virtual void AddDifferentGlyphsInConstructorTest ( ) {
35
37
PdfDictionary dictionary = new PdfDictionary ( ) ;
36
38
dictionary . Put ( PdfName . FontMatrix , new PdfArray ( ) ) ;
@@ -41,7 +43,7 @@ public virtual void AddDifferentGlyphsInConstructorTest() {
41
43
dictionary . Put ( PdfName . Widths , new PdfArray ( ) ) ;
42
44
dictionary . Put ( PdfName . ToUnicode , PdfName . IdentityH ) ;
43
45
dictionary . Put ( PdfName . Encoding , new PdfName ( "zapfdingbatsencoding" ) ) ;
44
- PdfType3Font type3Font = new _PdfType3Font_58 ( dictionary ) ;
46
+ PdfType3Font type3Font = new _PdfType3Font_64 ( dictionary ) ;
45
47
NUnit . Framework . Assert . IsNotNull ( type3Font . GetFontProgram ( ) ) ;
46
48
int spaceGlyphCode = 32 ;
47
49
Glyph glyph = type3Font . GetFontProgram ( ) . GetGlyph ( spaceGlyphCode ) ;
@@ -51,8 +53,8 @@ public virtual void AddDifferentGlyphsInConstructorTest() {
51
53
NUnit . Framework . Assert . AreEqual ( new Glyph ( AGlyphCode , 0 , new char [ ] { 'A' } ) , glyph ) ;
52
54
}
53
55
54
- private sealed class _PdfType3Font_58 : PdfType3Font {
55
- public _PdfType3Font_58 ( PdfDictionary baseArg1 )
56
+ private sealed class _PdfType3Font_64 : PdfType3Font {
57
+ public _PdfType3Font_64 ( PdfDictionary baseArg1 )
56
58
: base ( baseArg1 ) {
57
59
}
58
60
@@ -62,14 +64,15 @@ protected internal override PdfDocument GetDocument() {
62
64
}
63
65
64
66
[ NUnit . Framework . Test ]
67
+ [ LogMessage ( iText . IO . LogMessageConstant . TYPE3_FONT_INITIALIZATION_ISSUE ) ]
65
68
public virtual void AddAlreadyExistingGlyphTest ( ) {
66
69
PdfDictionary dictionary = new PdfDictionary ( ) ;
67
70
dictionary . Put ( PdfName . FontMatrix , new PdfArray ( ) ) ;
68
71
PdfDictionary charProcs = new PdfDictionary ( ) ;
69
72
charProcs . Put ( new PdfName ( "A" ) , new PdfStream ( ) ) ;
70
73
dictionary . Put ( PdfName . CharProcs , charProcs ) ;
71
74
dictionary . Put ( PdfName . Widths , new PdfArray ( ) ) ;
72
- PdfType3Font type3Font = new _PdfType3Font_82 ( dictionary ) ;
75
+ PdfType3Font type3Font = new _PdfType3Font_89 ( dictionary ) ;
73
76
Type3Glyph type3Glyph = type3Font . AddGlyph ( 'A' , 1 , 2 , 3 , 5 , 8 ) ;
74
77
NUnit . Framework . Assert . AreEqual ( 0 , type3Glyph . GetWx ( ) , EPS ) ;
75
78
NUnit . Framework . Assert . AreEqual ( 0 , type3Glyph . GetLlx ( ) , EPS ) ;
@@ -78,8 +81,8 @@ public virtual void AddAlreadyExistingGlyphTest() {
78
81
NUnit . Framework . Assert . AreEqual ( 0 , type3Glyph . GetUry ( ) , EPS ) ;
79
82
}
80
83
81
- private sealed class _PdfType3Font_82 : PdfType3Font {
82
- public _PdfType3Font_82 ( PdfDictionary baseArg1 )
84
+ private sealed class _PdfType3Font_89 : PdfType3Font {
85
+ public _PdfType3Font_89 ( PdfDictionary baseArg1 )
83
86
: base ( baseArg1 ) {
84
87
}
85
88
@@ -89,6 +92,7 @@ protected internal override PdfDocument GetDocument() {
89
92
}
90
93
91
94
[ NUnit . Framework . Test ]
95
+ [ LogMessage ( iText . IO . LogMessageConstant . TYPE3_FONT_INITIALIZATION_ISSUE ) ]
92
96
public virtual void SetFontStretchTest ( ) {
93
97
PdfDictionary dictionary = new PdfDictionary ( ) ;
94
98
dictionary . Put ( PdfName . FontMatrix , new PdfArray ( ) ) ;
@@ -104,6 +108,7 @@ public virtual void SetFontStretchTest() {
104
108
}
105
109
106
110
[ NUnit . Framework . Test ]
111
+ [ LogMessage ( iText . IO . LogMessageConstant . TYPE3_FONT_INITIALIZATION_ISSUE ) ]
107
112
public virtual void SetPdfFontFlagsTest ( ) {
108
113
PdfDictionary dictionary = new PdfDictionary ( ) ;
109
114
dictionary . Put ( PdfName . FontMatrix , new PdfArray ( ) ) ;
@@ -118,6 +123,7 @@ public virtual void SetPdfFontFlagsTest() {
118
123
}
119
124
120
125
[ NUnit . Framework . Test ]
126
+ [ LogMessage ( iText . IO . LogMessageConstant . TYPE3_FONT_INITIALIZATION_ISSUE ) ]
121
127
public virtual void GlyphWithUnicodeBiggerThan32CannotBeEncodedTest ( ) {
122
128
PdfDictionary dictionary = new PdfDictionary ( ) ;
123
129
dictionary . Put ( PdfName . FontMatrix , new PdfArray ( ) ) ;
@@ -130,13 +136,14 @@ public virtual void GlyphWithUnicodeBiggerThan32CannotBeEncodedTest() {
130
136
}
131
137
132
138
[ NUnit . Framework . Test ]
139
+ [ LogMessage ( iText . IO . LogMessageConstant . TYPE3_FONT_INITIALIZATION_ISSUE ) ]
133
140
public virtual void ContainsGlyphTest ( ) {
134
141
PdfDictionary dictionary = new PdfDictionary ( ) ;
135
142
dictionary . Put ( PdfName . FontMatrix , new PdfArray ( ) ) ;
136
143
PdfDictionary charProcs = new PdfDictionary ( ) ;
137
144
dictionary . Put ( PdfName . CharProcs , charProcs ) ;
138
145
dictionary . Put ( PdfName . Widths , new PdfArray ( ) ) ;
139
- PdfType3Font type3Font = new _PdfType3Font_148 ( dictionary ) ;
146
+ PdfType3Font type3Font = new _PdfType3Font_159 ( dictionary ) ;
140
147
NUnit . Framework . Assert . IsFalse ( type3Font . ContainsGlyph ( 333 ) ) ;
141
148
NUnit . Framework . Assert . IsFalse ( type3Font . ContainsGlyph ( - 5 ) ) ;
142
149
NUnit . Framework . Assert . IsFalse ( type3Font . ContainsGlyph ( 32 ) ) ;
@@ -146,8 +153,8 @@ public virtual void ContainsGlyphTest() {
146
153
NUnit . Framework . Assert . IsTrue ( type3Font . ContainsGlyph ( 65 ) ) ;
147
154
}
148
155
149
- private sealed class _PdfType3Font_148 : PdfType3Font {
150
- public _PdfType3Font_148 ( PdfDictionary baseArg1 )
156
+ private sealed class _PdfType3Font_159 : PdfType3Font {
157
+ public _PdfType3Font_159 ( PdfDictionary baseArg1 )
151
158
: base ( baseArg1 ) {
152
159
}
153
160
@@ -157,6 +164,7 @@ protected internal override PdfDocument GetDocument() {
157
164
}
158
165
159
166
[ NUnit . Framework . Test ]
167
+ [ LogMessage ( iText . IO . LogMessageConstant . TYPE3_FONT_INITIALIZATION_ISSUE ) ]
160
168
public virtual void FlushExceptionTest ( ) {
161
169
NUnit . Framework . Assert . That ( ( ) => {
162
170
PdfDictionary dictionary = new PdfDictionary ( ) ;
@@ -173,6 +181,7 @@ public virtual void FlushExceptionTest() {
173
181
}
174
182
175
183
[ NUnit . Framework . Test ]
184
+ [ LogMessage ( iText . IO . LogMessageConstant . TYPE3_FONT_INITIALIZATION_ISSUE ) ]
176
185
public virtual void FillFontDescriptorTest ( ) {
177
186
PdfDictionary dictionary = new PdfDictionary ( ) ;
178
187
dictionary . Put ( PdfName . FontMatrix , new PdfArray ( ) ) ;
@@ -183,14 +192,14 @@ public virtual void FillFontDescriptorTest() {
183
192
String fontStretch = "test" ;
184
193
fontDescriptor . Put ( PdfName . FontStretch , new PdfName ( fontStretch ) ) ;
185
194
dictionary . Put ( PdfName . FontDescriptor , fontDescriptor ) ;
186
- PdfType3Font type3Font = new _PdfType3Font_189 ( dictionary ) ;
195
+ PdfType3Font type3Font = new _PdfType3Font_202 ( dictionary ) ;
187
196
NUnit . Framework . Assert . IsNotNull ( type3Font . fontProgram ) ;
188
197
NUnit . Framework . Assert . IsNotNull ( type3Font . fontProgram . GetFontNames ( ) ) ;
189
198
NUnit . Framework . Assert . AreEqual ( fontStretch , type3Font . fontProgram . GetFontNames ( ) . GetFontStretch ( ) ) ;
190
199
}
191
200
192
- private sealed class _PdfType3Font_189 : PdfType3Font {
193
- public _PdfType3Font_189 ( PdfDictionary baseArg1 )
201
+ private sealed class _PdfType3Font_202 : PdfType3Font {
202
+ public _PdfType3Font_202 ( PdfDictionary baseArg1 )
194
203
: base ( baseArg1 ) {
195
204
}
196
205
@@ -199,6 +208,54 @@ protected internal override PdfDocument GetDocument() {
199
208
}
200
209
}
201
210
211
+ [ NUnit . Framework . Test ]
212
+ [ LogMessage ( iText . IO . LogMessageConstant . TYPE3_FONT_INITIALIZATION_ISSUE ) ]
213
+ public virtual void NoCharProcsTest ( ) {
214
+ PdfDictionary dictionary = new PdfDictionary ( ) ;
215
+ dictionary . Put ( PdfName . FontMatrix , new PdfArray ( ) ) ;
216
+ dictionary . Put ( PdfName . Widths , new PdfArray ( ) ) ;
217
+ NUnit . Framework . Assert . DoesNotThrow ( ( ) => new PdfType3Font ( dictionary ) ) ;
218
+ }
219
+
220
+ [ NUnit . Framework . Test ]
221
+ [ LogMessage ( iText . IO . LogMessageConstant . TYPE3_FONT_INITIALIZATION_ISSUE ) ]
222
+ public virtual void NoEncodingTest ( ) {
223
+ PdfDictionary dictionary = new PdfDictionary ( ) ;
224
+ dictionary . Put ( PdfName . FontMatrix , new PdfArray ( ) ) ;
225
+ PdfDictionary charProcs = new PdfDictionary ( ) ;
226
+ dictionary . Put ( PdfName . CharProcs , charProcs ) ;
227
+ dictionary . Put ( PdfName . Widths , new PdfArray ( ) ) ;
228
+ NUnit . Framework . Assert . DoesNotThrow ( ( ) => new PdfType3Font ( dictionary ) ) ;
229
+ }
230
+
231
+ [ NUnit . Framework . Test ]
232
+ [ LogMessage ( iText . IO . LogMessageConstant . TYPE3_FONT_INITIALIZATION_ISSUE ) ]
233
+ public virtual void NoDifferenceTest ( ) {
234
+ PdfDictionary dictionary = new PdfDictionary ( ) ;
235
+ dictionary . Put ( PdfName . FontMatrix , new PdfArray ( ) ) ;
236
+ PdfDictionary charProcs = new PdfDictionary ( ) ;
237
+ dictionary . Put ( PdfName . CharProcs , charProcs ) ;
238
+ dictionary . Put ( PdfName . Widths , new PdfArray ( ) ) ;
239
+ PdfDictionary encoding = new PdfDictionary ( ) ;
240
+ dictionary . Put ( PdfName . Encoding , encoding ) ;
241
+ NUnit . Framework . Assert . DoesNotThrow ( ( ) => new PdfType3Font ( dictionary ) ) ;
242
+ }
243
+
244
+ [ NUnit . Framework . Test ]
245
+ public virtual void NoCharProcGlyphForDifferenceTest ( ) {
246
+ PdfDictionary font = new PdfDictionary ( ) ;
247
+ font . Put ( PdfName . FontMatrix , new PdfArray ( ) ) ;
248
+ font . Put ( PdfName . Widths , new PdfArray ( ) ) ;
249
+ font . Put ( PdfName . CharProcs , new PdfDictionary ( ) ) ;
250
+ PdfDictionary encoding = new PdfDictionary ( ) ;
251
+ PdfArray differences = new PdfArray ( ) ;
252
+ differences . Add ( 0 , new PdfNumber ( 65 ) ) ;
253
+ differences . Add ( 1 , new PdfName ( "A" ) ) ;
254
+ encoding . Put ( PdfName . Differences , differences ) ;
255
+ font . Put ( PdfName . Encoding , encoding ) ;
256
+ NUnit . Framework . Assert . DoesNotThrow ( ( ) => new PdfType3Font ( font ) ) ;
257
+ }
258
+
202
259
private class DisableEnsureUnderlyingObjectHasIndirectReference : PdfType3Font {
203
260
internal DisableEnsureUnderlyingObjectHasIndirectReference ( PdfType3FontTest _enclosing , PdfDictionary fontDictionary
204
261
)
0 commit comments