@@ -22,6 +22,7 @@ You should have received a copy of the GNU Affero General Public License
22
22
*/
23
23
using System ;
24
24
using iText . IO . Font . Otf ;
25
+ using iText . IO . Util ;
25
26
using iText . Kernel ;
26
27
using iText . Kernel . Pdf ;
27
28
using iText . Test ;
@@ -43,7 +44,7 @@ public virtual void AddDifferentGlyphsInConstructorTest() {
43
44
dictionary . Put ( PdfName . Widths , new PdfArray ( ) ) ;
44
45
dictionary . Put ( PdfName . ToUnicode , PdfName . IdentityH ) ;
45
46
dictionary . Put ( PdfName . Encoding , new PdfName ( "zapfdingbatsencoding" ) ) ;
46
- PdfType3Font type3Font = new _PdfType3Font_64 ( dictionary ) ;
47
+ PdfType3Font type3Font = new _PdfType3Font_65 ( dictionary ) ;
47
48
NUnit . Framework . Assert . IsNotNull ( type3Font . GetFontProgram ( ) ) ;
48
49
int spaceGlyphCode = 32 ;
49
50
Glyph glyph = type3Font . GetFontProgram ( ) . GetGlyph ( spaceGlyphCode ) ;
@@ -53,8 +54,8 @@ public virtual void AddDifferentGlyphsInConstructorTest() {
53
54
NUnit . Framework . Assert . AreEqual ( new Glyph ( AGlyphCode , 0 , new char [ ] { 'A' } ) , glyph ) ;
54
55
}
55
56
56
- private sealed class _PdfType3Font_64 : PdfType3Font {
57
- public _PdfType3Font_64 ( PdfDictionary baseArg1 )
57
+ private sealed class _PdfType3Font_65 : PdfType3Font {
58
+ public _PdfType3Font_65 ( PdfDictionary baseArg1 )
58
59
: base ( baseArg1 ) {
59
60
}
60
61
@@ -72,7 +73,7 @@ public virtual void AddAlreadyExistingGlyphTest() {
72
73
charProcs . Put ( new PdfName ( "A" ) , new PdfStream ( ) ) ;
73
74
dictionary . Put ( PdfName . CharProcs , charProcs ) ;
74
75
dictionary . Put ( PdfName . Widths , new PdfArray ( ) ) ;
75
- PdfType3Font type3Font = new _PdfType3Font_89 ( dictionary ) ;
76
+ PdfType3Font type3Font = new _PdfType3Font_90 ( dictionary ) ;
76
77
Type3Glyph type3Glyph = type3Font . AddGlyph ( 'A' , 1 , 2 , 3 , 5 , 8 ) ;
77
78
NUnit . Framework . Assert . AreEqual ( 0 , type3Glyph . GetWx ( ) , EPS ) ;
78
79
NUnit . Framework . Assert . AreEqual ( 0 , type3Glyph . GetLlx ( ) , EPS ) ;
@@ -81,8 +82,8 @@ public virtual void AddAlreadyExistingGlyphTest() {
81
82
NUnit . Framework . Assert . AreEqual ( 0 , type3Glyph . GetUry ( ) , EPS ) ;
82
83
}
83
84
84
- private sealed class _PdfType3Font_89 : PdfType3Font {
85
- public _PdfType3Font_89 ( PdfDictionary baseArg1 )
85
+ private sealed class _PdfType3Font_90 : PdfType3Font {
86
+ public _PdfType3Font_90 ( PdfDictionary baseArg1 )
86
87
: base ( baseArg1 ) {
87
88
}
88
89
@@ -143,7 +144,7 @@ public virtual void ContainsGlyphTest() {
143
144
PdfDictionary charProcs = new PdfDictionary ( ) ;
144
145
dictionary . Put ( PdfName . CharProcs , charProcs ) ;
145
146
dictionary . Put ( PdfName . Widths , new PdfArray ( ) ) ;
146
- PdfType3Font type3Font = new _PdfType3Font_159 ( dictionary ) ;
147
+ PdfType3Font type3Font = new _PdfType3Font_160 ( dictionary ) ;
147
148
NUnit . Framework . Assert . IsFalse ( type3Font . ContainsGlyph ( 333 ) ) ;
148
149
NUnit . Framework . Assert . IsFalse ( type3Font . ContainsGlyph ( - 5 ) ) ;
149
150
NUnit . Framework . Assert . IsFalse ( type3Font . ContainsGlyph ( 32 ) ) ;
@@ -153,8 +154,8 @@ public virtual void ContainsGlyphTest() {
153
154
NUnit . Framework . Assert . IsTrue ( type3Font . ContainsGlyph ( 65 ) ) ;
154
155
}
155
156
156
- private sealed class _PdfType3Font_159 : PdfType3Font {
157
- public _PdfType3Font_159 ( PdfDictionary baseArg1 )
157
+ private sealed class _PdfType3Font_160 : PdfType3Font {
158
+ public _PdfType3Font_160 ( PdfDictionary baseArg1 )
158
159
: base ( baseArg1 ) {
159
160
}
160
161
@@ -192,14 +193,14 @@ public virtual void FillFontDescriptorTest() {
192
193
String fontStretch = "test" ;
193
194
fontDescriptor . Put ( PdfName . FontStretch , new PdfName ( fontStretch ) ) ;
194
195
dictionary . Put ( PdfName . FontDescriptor , fontDescriptor ) ;
195
- PdfType3Font type3Font = new _PdfType3Font_202 ( dictionary ) ;
196
+ PdfType3Font type3Font = new _PdfType3Font_203 ( dictionary ) ;
196
197
NUnit . Framework . Assert . IsNotNull ( type3Font . fontProgram ) ;
197
198
NUnit . Framework . Assert . IsNotNull ( type3Font . fontProgram . GetFontNames ( ) ) ;
198
199
NUnit . Framework . Assert . AreEqual ( fontStretch , type3Font . fontProgram . GetFontNames ( ) . GetFontStretch ( ) ) ;
199
200
}
200
201
201
- private sealed class _PdfType3Font_202 : PdfType3Font {
202
- public _PdfType3Font_202 ( PdfDictionary baseArg1 )
202
+ private sealed class _PdfType3Font_203 : PdfType3Font {
203
+ public _PdfType3Font_203 ( PdfDictionary baseArg1 )
203
204
: base ( baseArg1 ) {
204
205
}
205
206
@@ -241,6 +242,34 @@ public virtual void NoDifferenceTest() {
241
242
NUnit . Framework . Assert . DoesNotThrow ( ( ) => new PdfType3Font ( dictionary ) ) ;
242
243
}
243
244
245
+ [ NUnit . Framework . Test ]
246
+ [ LogMessage ( iText . IO . LogMessageConstant . TYPE3_FONT_INITIALIZATION_ISSUE ) ]
247
+ public virtual void MissingFontMatrixTest ( ) {
248
+ PdfDictionary dictionary = new PdfDictionary ( ) ;
249
+ dictionary . Put ( PdfName . Widths , new PdfArray ( ) ) ;
250
+ dictionary . Put ( PdfName . ToUnicode , PdfName . IdentityH ) ;
251
+ dictionary . Put ( PdfName . Encoding , new PdfName ( "zapfdingbatsencoding" ) ) ;
252
+ NUnit . Framework . Assert . That ( ( ) => {
253
+ new PdfType3Font ( dictionary ) ;
254
+ }
255
+ , NUnit . Framework . Throws . InstanceOf < PdfException > ( ) . With . Message . EqualTo ( MessageFormatUtil . Format ( PdfException . MissingRequiredFieldInFontDictionary , PdfName . FontMatrix ) ) )
256
+ ;
257
+ }
258
+
259
+ [ NUnit . Framework . Test ]
260
+ [ LogMessage ( iText . IO . LogMessageConstant . TYPE3_FONT_INITIALIZATION_ISSUE ) ]
261
+ public virtual void MissingWidthsTest ( ) {
262
+ PdfDictionary dictionary = new PdfDictionary ( ) ;
263
+ dictionary . Put ( PdfName . FontMatrix , new PdfArray ( ) ) ;
264
+ dictionary . Put ( PdfName . ToUnicode , PdfName . IdentityH ) ;
265
+ dictionary . Put ( PdfName . Encoding , new PdfName ( "zapfdingbatsencoding" ) ) ;
266
+ NUnit . Framework . Assert . That ( ( ) => {
267
+ new PdfType3Font ( dictionary ) ;
268
+ }
269
+ , NUnit . Framework . Throws . InstanceOf < PdfException > ( ) . With . Message . EqualTo ( MessageFormatUtil . Format ( PdfException . MissingRequiredFieldInFontDictionary , PdfName . Widths ) ) )
270
+ ;
271
+ }
272
+
244
273
[ NUnit . Framework . Test ]
245
274
public virtual void NoCharProcGlyphForDifferenceTest ( ) {
246
275
PdfDictionary font = new PdfDictionary ( ) ;
0 commit comments