@@ -42,6 +42,7 @@ This file is part of the iText (R) project.
42
42
*/
43
43
package com .itextpdf .layout ;
44
44
45
+ import com .itextpdf .io .LogMessageConstant ;
45
46
import com .itextpdf .io .font .PdfEncodings ;
46
47
import com .itextpdf .io .font .constants .StandardFontFamilies ;
47
48
import com .itextpdf .io .font .constants .StandardFonts ;
@@ -62,6 +63,8 @@ This file is part of the iText (R) project.
62
63
import com .itextpdf .layout .font .RangeBuilder ;
63
64
import com .itextpdf .layout .property .Property ;
64
65
import com .itextpdf .test .ExtendedITextTest ;
66
+ import com .itextpdf .test .annotations .LogMessage ;
67
+ import com .itextpdf .test .annotations .LogMessages ;
65
68
import com .itextpdf .test .annotations .type .IntegrationTest ;
66
69
import org .junit .Assert ;
67
70
import org .junit .BeforeClass ;
@@ -121,7 +124,6 @@ public void cyrillicAndLatinGroup() throws Exception {
121
124
}
122
125
123
126
@ Test
124
- // TODO DEVSIX-2120 The font-family name of Puritan2.otf is 'Puritan 2.0' but this name doesn't match font-family name pattern
125
127
public void cyrillicAndLatinGroup2 () throws Exception {
126
128
String fileName = "cyrillicAndLatinGroup2" ;
127
129
String outFileName = destinationFolder + fileName + ".pdf" ;
@@ -147,6 +149,61 @@ public void cyrillicAndLatinGroup2() throws Exception {
147
149
Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder , "diff" + fileName ));
148
150
}
149
151
152
+ @ Test
153
+ public void cyrillicAndLatinGroup3 () throws Exception {
154
+ String fileName = "cyrillicAndLatinGroup3" ;
155
+ String outFileName = destinationFolder + fileName + ".pdf" ;
156
+ String cmpFileName = sourceFolder + "cmp_" + fileName + ".pdf" ;
157
+
158
+ FontProvider sel = new FontProvider ();
159
+
160
+ Assert .assertTrue (sel .addFont (fontsFolder + "FreeSans.ttf" ));
161
+ Assert .assertTrue (sel .addFont (fontsFolder + "NotoSans-Regular.ttf" ));
162
+ Assert .assertTrue (sel .addFont (fontsFolder + "Puritan2.otf" ));
163
+
164
+
165
+ String s = "Hello world! Здравствуй мир! Hello world! Здравствуй мир!" ;
166
+ PdfDocument pdfDoc = new PdfDocument (new PdfWriter (new FileOutputStream (outFileName )));
167
+ Document doc = new Document (pdfDoc );
168
+
169
+ doc .setFontProvider (sel );
170
+ doc .setFontFamily (Arrays .asList ("Puritan 2.0" , "Noto Sans" ));
171
+ Text text = new Text (s ).setBackgroundColor (ColorConstants .LIGHT_GRAY );
172
+ Paragraph paragraph = new Paragraph (text );
173
+ doc .add (paragraph );
174
+ doc .close ();
175
+
176
+ Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder , "diff" + fileName ));
177
+ }
178
+
179
+ @ Test
180
+ @ LogMessages (messages = @ LogMessage (messageTemplate = LogMessageConstant .FONT_PROPERTY_OF_STRING_TYPE_IS_DEPRECATED_USE_STRINGS_ARRAY_INSTEAD ))
181
+ public void cyrillicAndLatinGroupDeprecatedFontAsStringValue () throws Exception {
182
+ String fileName = "cyrillicAndLatinGroupDeprecatedFontAsStringValue" ;
183
+ String outFileName = destinationFolder + fileName + ".pdf" ;
184
+ String cmpFileName = sourceFolder + "cmp_" + fileName + ".pdf" ;
185
+
186
+ FontProvider sel = new FontProvider ();
187
+
188
+ Assert .assertTrue (sel .addFont (fontsFolder + "FreeSans.ttf" ));
189
+ Assert .assertTrue (sel .addFont (fontsFolder + "NotoSans-Regular.ttf" ));
190
+ Assert .assertTrue (sel .addFont (fontsFolder + "Puritan2.otf" ));
191
+
192
+
193
+ String s = "Hello world! Здравствуй мир! Hello world! Здравствуй мир!" ;
194
+ PdfDocument pdfDoc = new PdfDocument (new PdfWriter (new FileOutputStream (outFileName )));
195
+ Document doc = new Document (pdfDoc );
196
+
197
+ doc .setFontProvider (sel );
198
+ doc .setProperty (Property .FONT , "'Puritan', \" FreeSans\" " );
199
+ Text text = new Text (s ).setBackgroundColor (ColorConstants .LIGHT_GRAY );
200
+ Paragraph paragraph = new Paragraph (text );
201
+ doc .add (paragraph );
202
+ doc .close ();
203
+
204
+ Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder , "diff" + fileName ));
205
+ }
206
+
150
207
@ Test
151
208
public void latinAndNotdefGroup () throws Exception {
152
209
String fileName = "latinAndNotdefGroup" ;
0 commit comments