FontUtils { public static PDFont fontOrFallback(String text, PDFont font, PDDocument document) { if (!canDisplay(text, font)) { PDFont fallback = findFontFor(document, text); String fallbackName = fallback == null ? null : fallback.getName(); LOG.debug("Text '{}' cannot be written with font {}, using fallback {}", text, font.getName(), fallbackName); return fallback; } return font; } 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 testFontOrFallbackPositive() { assertEquals(HELVETICA, fontOrFallback("Chuck", HELVETICA, new PDDocument())); }
@Test public void testFontOrFallbackNegative() { assertNotNull(fontOrFallback("कसौटी", HELVETICA, new PDDocument())); }
@Test public void testFontOrFallbackNotFoundFallback() { assertNull(fontOrFallback("\u1B2A\u1B35\u1B31\u1B29\u1B2E\u1B36, \u1B29\u1B32\u1B29\u1B2E\u1B36", HELVETICA, new PDDocument())); }