@@ -22,6 +22,7 @@ You should have received a copy of the GNU Affero General Public License
2222*/
2323using System ;
2424using iText . IO . Font . Otf ;
25+ using iText . IO . Util ;
2526using iText . Kernel ;
2627using iText . Kernel . Pdf ;
2728using iText . Test ;
@@ -43,7 +44,7 @@ public virtual void AddDifferentGlyphsInConstructorTest() {
4344 dictionary . Put ( PdfName . Widths , new PdfArray ( ) ) ;
4445 dictionary . Put ( PdfName . ToUnicode , PdfName . IdentityH ) ;
4546 dictionary . Put ( PdfName . Encoding , new PdfName ( "zapfdingbatsencoding" ) ) ;
46- PdfType3Font type3Font = new _PdfType3Font_64 ( dictionary ) ;
47+ PdfType3Font type3Font = new _PdfType3Font_65 ( dictionary ) ;
4748 NUnit . Framework . Assert . IsNotNull ( type3Font . GetFontProgram ( ) ) ;
4849 int spaceGlyphCode = 32 ;
4950 Glyph glyph = type3Font . GetFontProgram ( ) . GetGlyph ( spaceGlyphCode ) ;
@@ -53,8 +54,8 @@ public virtual void AddDifferentGlyphsInConstructorTest() {
5354 NUnit . Framework . Assert . AreEqual ( new Glyph ( AGlyphCode , 0 , new char [ ] { 'A' } ) , glyph ) ;
5455 }
5556
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 )
5859 : base ( baseArg1 ) {
5960 }
6061
@@ -72,7 +73,7 @@ public virtual void AddAlreadyExistingGlyphTest() {
7273 charProcs . Put ( new PdfName ( "A" ) , new PdfStream ( ) ) ;
7374 dictionary . Put ( PdfName . CharProcs , charProcs ) ;
7475 dictionary . Put ( PdfName . Widths , new PdfArray ( ) ) ;
75- PdfType3Font type3Font = new _PdfType3Font_89 ( dictionary ) ;
76+ PdfType3Font type3Font = new _PdfType3Font_90 ( dictionary ) ;
7677 Type3Glyph type3Glyph = type3Font . AddGlyph ( 'A' , 1 , 2 , 3 , 5 , 8 ) ;
7778 NUnit . Framework . Assert . AreEqual ( 0 , type3Glyph . GetWx ( ) , EPS ) ;
7879 NUnit . Framework . Assert . AreEqual ( 0 , type3Glyph . GetLlx ( ) , EPS ) ;
@@ -81,8 +82,8 @@ public virtual void AddAlreadyExistingGlyphTest() {
8182 NUnit . Framework . Assert . AreEqual ( 0 , type3Glyph . GetUry ( ) , EPS ) ;
8283 }
8384
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 )
8687 : base ( baseArg1 ) {
8788 }
8889
@@ -143,7 +144,7 @@ public virtual void ContainsGlyphTest() {
143144 PdfDictionary charProcs = new PdfDictionary ( ) ;
144145 dictionary . Put ( PdfName . CharProcs , charProcs ) ;
145146 dictionary . Put ( PdfName . Widths , new PdfArray ( ) ) ;
146- PdfType3Font type3Font = new _PdfType3Font_159 ( dictionary ) ;
147+ PdfType3Font type3Font = new _PdfType3Font_160 ( dictionary ) ;
147148 NUnit . Framework . Assert . IsFalse ( type3Font . ContainsGlyph ( 333 ) ) ;
148149 NUnit . Framework . Assert . IsFalse ( type3Font . ContainsGlyph ( - 5 ) ) ;
149150 NUnit . Framework . Assert . IsFalse ( type3Font . ContainsGlyph ( 32 ) ) ;
@@ -153,8 +154,8 @@ public virtual void ContainsGlyphTest() {
153154 NUnit . Framework . Assert . IsTrue ( type3Font . ContainsGlyph ( 65 ) ) ;
154155 }
155156
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 )
158159 : base ( baseArg1 ) {
159160 }
160161
@@ -192,14 +193,14 @@ public virtual void FillFontDescriptorTest() {
192193 String fontStretch = "test" ;
193194 fontDescriptor . Put ( PdfName . FontStretch , new PdfName ( fontStretch ) ) ;
194195 dictionary . Put ( PdfName . FontDescriptor , fontDescriptor ) ;
195- PdfType3Font type3Font = new _PdfType3Font_202 ( dictionary ) ;
196+ PdfType3Font type3Font = new _PdfType3Font_203 ( dictionary ) ;
196197 NUnit . Framework . Assert . IsNotNull ( type3Font . fontProgram ) ;
197198 NUnit . Framework . Assert . IsNotNull ( type3Font . fontProgram . GetFontNames ( ) ) ;
198199 NUnit . Framework . Assert . AreEqual ( fontStretch , type3Font . fontProgram . GetFontNames ( ) . GetFontStretch ( ) ) ;
199200 }
200201
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 )
203204 : base ( baseArg1 ) {
204205 }
205206
@@ -241,6 +242,34 @@ public virtual void NoDifferenceTest() {
241242 NUnit . Framework . Assert . DoesNotThrow ( ( ) => new PdfType3Font ( dictionary ) ) ;
242243 }
243244
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+
244273 [ NUnit . Framework . Test ]
245274 public virtual void NoCharProcGlyphForDifferenceTest ( ) {
246275 PdfDictionary font = new PdfDictionary ( ) ;
0 commit comments