FontUtils { public static String removeUnsupportedCharacters(String text, PDDocument doc) { return replaceUnsupportedCharacters(text, doc, ""); } private  FontUtils(); static PDType1Font getStandardType1Font(StandardType1Font st1Font); static PDFont fontOrFallback(String text, PDFont font, PDDocument document); static void clearLoadedFontCache(); static void clearLoadedFontCache(PDDocument document); static PDFont loadFont(PDDocument document, FontResource font); static final PDFont findFontFor(PDDocument document, String text); static boolean isOnlyWhitespace(String text); static String removeWhitespace(String text); static boolean canDisplaySpace(PDFont font); static boolean canDisplay(String text, PDFont font); static double calculateBBoxHeight(String text, PDFont font); static boolean isBold(PDFont font); static boolean isItalic(PDFont font); static List<String> wrapLines(String rawLabel, PDFont font, float fontSize, double maxWidth,
            PDDocument document); static double getSimpleStringWidth(String text, PDFont font, double fontSize); static List<TextWithFont> resolveFonts(String label, PDFont font, PDDocument document); static String removeUnsupportedCharacters(String text, PDDocument doc); static String replaceUnsupportedCharacters(String text, PDDocument doc, String replacement); static PDFont HELVETICA; static final FontResource[] TYPE0FONTS; }
@Test public void removeUnsupportedCharsDoesNotChangeStringForRTLLanguages() { PDDocument doc = new PDDocument(); String text = "עברית"; assertEquals(text, FontUtils.removeUnsupportedCharacters(text, doc)); }
@Test public void removingUnsupportedCharacters() { PDDocument doc = new PDDocument(); String str = FontUtils.removeUnsupportedCharacters("ͷ͵ͲͲͲ Text here SǦͳͻǦʹͳͲͻ4 and here", doc); assertThat(str, is("͵ Text here SǦͻǦʹͻ4 and here")); }