Skip to content

Commit bccd3a5

Browse files
BezrukovMyulian-gaponenko
authored andcommitted
Font provider get shipped fonts update
DEVSIX-5267
1 parent f6e8d93 commit bccd3a5

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

src/main/java/com/itextpdf/html2pdf/resolver/font/DefaultFontProvider.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ This file is part of the iText (R) project.
4747
import com.itextpdf.io.util.StreamUtil;
4848
import com.itextpdf.layout.font.Range;
4949
import com.itextpdf.layout.font.RangeBuilder;
50+
import com.itextpdf.layout.renderer.TypographyUtils;
5051
import com.itextpdf.styledxmlparser.resolver.font.BasicFontProvider;
5152
import org.slf4j.LoggerFactory;
5253

5354
import java.io.InputStream;
54-
import java.lang.reflect.Method;
5555
import java.util.ArrayList;
5656
import java.util.List;
5757
import 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

Comments
 (0)