/** * Finds a font with the given PostScript name, or a suitable substitute, or null. This allows * any font to be substituted with a PFB, TTF or OTF. * * @param fontDescriptor the FontDescriptor of the font to find */ @Override public FontMapping<FontBoxFont> getFontBoxFont(String baseFont, PDFontDescriptor fontDescriptor) { FontBoxFont font = findFontBoxFont(baseFont); if (font != null) { return new FontMapping<>(font, false); } else { // fallback - todo: i.e. fuzzy match String fallbackName = getFallbackFontName(fontDescriptor); font = findFontBoxFont(fallbackName); if (font == null) { // we have to return something here as TTFs aren't strictly required on the system font = lastResortFont; } return new FontMapping<>(font, true); } }
/** * Finds a TrueType font with the given PostScript name, or a suitable substitute, or null. * * @param fontDescriptor FontDescriptor */ @Override public FontMapping<TrueTypeFont> getTrueTypeFont(String baseFont, PDFontDescriptor fontDescriptor) { TrueTypeFont ttf = (TrueTypeFont)findFont(FontFormat.TTF, baseFont); if (ttf != null) { return new FontMapping<>(ttf, false); } else { // fallback - todo: i.e. fuzzy match String fontName = getFallbackFontName(fontDescriptor); ttf = (TrueTypeFont) findFont(FontFormat.TTF, fontName); if (ttf == null) { // we have to return something here as TTFs aren't strictly required on the system ttf = lastResortFont; } return new FontMapping<>(ttf, true); } }
/** * Finds a TrueType font with the given PostScript name, or a suitable substitute, or null. * * @param fontDescriptor FontDescriptor */ @Override public FontMapping<TrueTypeFont> getTrueTypeFont(String baseFont, PDFontDescriptor fontDescriptor) { TrueTypeFont ttf = (TrueTypeFont)findFont(FontFormat.TTF, baseFont); if (ttf != null) { return new FontMapping<TrueTypeFont>(ttf, false); } else { // fallback - todo: i.e. fuzzy match String fontName = getFallbackFontName(fontDescriptor); ttf = (TrueTypeFont) findFont(FontFormat.TTF, fontName); if (ttf == null) { // we have to return something here as TTFs aren't strictly required on the system ttf = lastResortFont; } return new FontMapping<TrueTypeFont>(ttf, true); } }
/** * Finds a font with the given PostScript name, or a suitable substitute, or null. This allows * any font to be substituted with a PFB, TTF or OTF. * * @param fontDescriptor the FontDescriptor of the font to find */ @Override public FontMapping<FontBoxFont> getFontBoxFont(String baseFont, PDFontDescriptor fontDescriptor) { FontBoxFont font = findFontBoxFont(baseFont); if (font != null) { return new FontMapping<>(font, false); } else { // fallback - todo: i.e. fuzzy match String fallbackName = getFallbackFontName(fontDescriptor); font = findFontBoxFont(fallbackName); if (font == null) { // we have to return something here as TTFs aren't strictly required on the system font = lastResortFont; } return new FontMapping<>(font, true); } }
/** * Finds a font with the given PostScript name, or a suitable substitute, or null. This allows * any font to be substituted with a PFB, TTF or OTF. * * @param fontDescriptor the FontDescriptor of the font to find */ @Override public FontMapping<FontBoxFont> getFontBoxFont(String baseFont, PDFontDescriptor fontDescriptor) { FontBoxFont font = findFontBoxFont(baseFont); if (font != null) { return new FontMapping<FontBoxFont>(font, false); } else { // fallback - todo: i.e. fuzzy match String fallbackName = getFallbackFontName(fontDescriptor); font = findFontBoxFont(fallbackName); if (font == null) { // we have to return something here as TTFs aren't strictly required on the system font = lastResortFont; } return new FontMapping<FontBoxFont>(font, true); } }
/** * Finds a TrueType font with the given PostScript name, or a suitable substitute, or null. * * @param fontDescriptor FontDescriptor */ @Override public FontMapping<TrueTypeFont> getTrueTypeFont(String baseFont, PDFontDescriptor fontDescriptor) { TrueTypeFont ttf = (TrueTypeFont)findFont(FontFormat.TTF, baseFont); if (ttf != null) { return new FontMapping<>(ttf, false); } else { // fallback - todo: i.e. fuzzy match String fontName = getFallbackFontName(fontDescriptor); ttf = (TrueTypeFont) findFont(FontFormat.TTF, fontName); if (ttf == null) { // we have to return something here as TTFs aren't strictly required on the system ttf = lastResortFont; } return new FontMapping<>(ttf, true); } }