@@ -47,11 +47,11 @@ This file is part of the iText (R) project.
4747import com .itextpdf .io .util .StreamUtil ;
4848import com .itextpdf .layout .font .Range ;
4949import com .itextpdf .layout .font .RangeBuilder ;
50+ import com .itextpdf .layout .renderer .TypographyUtils ;
5051import com .itextpdf .styledxmlparser .resolver .font .BasicFontProvider ;
5152import org .slf4j .LoggerFactory ;
5253
5354import java .io .InputStream ;
54- import java .lang .reflect .Method ;
5555import java .util .ArrayList ;
5656import java .util .List ;
5757import java .util .Map ;
@@ -170,15 +170,9 @@ private void addShippedFonts(Range rangeToLoad) {
170170 * i.e. the unicode range that is to be rendered with any other font contained in this FontProvider
171171 */
172172 protected Range addCalligraphFonts () {
173- String methodName = "loadShippedFonts" ;
174- Class <?> klass = null ;
175- try {
176- klass = getTypographyUtilsClass ();
177- } catch (ClassNotFoundException ignored ) { }
178- if (klass != null ) {
173+ if (TypographyUtils .isPdfCalligraphAvailable ()) {
179174 try {
180- Method m = klass .getMethod (methodName );
181- Map <String , byte []> fontStreams = (Map <String , byte []>) m .invoke (null , null );
175+ Map <String , byte []> fontStreams = TypographyUtils .loadShippedFonts ();
182176 this .calligraphyFontsTempList .addAll (fontStreams .values ());
183177 // here we return a unicode range that excludes the loaded from the calligraph module fonts
184178 // i.e. the unicode range that is to be rendered with standard or shipped free fonts
@@ -189,9 +183,4 @@ protected Range addCalligraphFonts() {
189183 }
190184 return null ;
191185 }
192-
193- private static Class <?> getTypographyUtilsClass () throws ClassNotFoundException {
194- String typographyClassFullName = "com.itextpdf.typography.util.TypographyShippedFontsUtil" ;
195- return Class .forName (typographyClassFullName );
196- }
197186}
0 commit comments