substitutes.put(baseName, copySubstitutes(mappedName));
/** * Sets the font service provider. */ public synchronized void setProvider(FontProvider fontProvider) { fontInfoByName = createFontInfoByName(fontProvider.getFontInfo()); this.fontProvider = fontProvider; }
/** * 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 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); } }
getProvider(); FontInfo info = getFont(format, postScriptName); if (info != null) info = getFont(format, postScriptName.replaceAll("-", "")); if (info != null) for (String substituteName : getSubstitutes(postScriptName)) info = getFont(format, substituteName); if (info != null) info = getFont(format, postScriptName.replaceAll(",", "-")); if (info != null) info = getFont(format, postScriptName + "-Regular"); if (info != null)
OpenTypeFont otf1 = (OpenTypeFont)findFont(FontFormat.OTF, baseFont); if (otf1 != null) TrueTypeFont ttf = (TrueTypeFont)findFont(FontFormat.TTF, baseFont); if (ttf != null) PriorityQueue<FontMatch> queue = getFontMatches(fontDescriptor, cidSystemInfo); FontMatch bestMatch = queue.poll(); if (bestMatch != null)
private Map<String, FontInfo> createFontInfoByName(List<? extends FontInfo> fontInfoList) { Map<String, FontInfo> map = new LinkedHashMap<>(); for (FontInfo info : fontInfoList) { for (String name : getPostScriptNames(info.getPostScriptName())) { map.put(name, info); } } return map; }
/** * Finds a font with the given PostScript name, or a suitable substitute, or null. * * @param postScriptName PostScript font name */ private FontBoxFont findFontBoxFont(String postScriptName) { Type1Font t1 = (Type1Font)findFont(FontFormat.PFB, postScriptName); if (t1 != null) { return t1; } TrueTypeFont ttf = (TrueTypeFont)findFont(FontFormat.TTF, postScriptName); if (ttf != null) { return ttf; } OpenTypeFont otf = (OpenTypeFont) findFont(FontFormat.OTF, postScriptName); if (otf != null) { return otf; } return null; }
getProvider(); FontInfo info = getFont(format, postScriptName); if (info != null) info = getFont(format, postScriptName.replaceAll("-", "")); if (info != null) for (String substituteName : getSubstitutes(postScriptName)) info = getFont(format, substituteName); if (info != null) info = getFont(format, postScriptName.replaceAll(",", "-")); if (info != null) info = getFont(format, postScriptName + "-Regular"); if (info != null)
/** * 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); } }
OpenTypeFont otf1 = (OpenTypeFont)findFont(FontFormat.OTF, baseFont); if (otf1 != null) TrueTypeFont ttf = (TrueTypeFont)findFont(FontFormat.TTF, baseFont); if (ttf != null) PriorityQueue<FontMatch> queue = getFontMatches(fontDescriptor, cidSystemInfo); FontMatch bestMatch = queue.poll(); if (bestMatch != null)
private Map<String, FontInfo> createFontInfoByName(List<? extends FontInfo> fontInfoList) { Map<String, FontInfo> map = new LinkedHashMap<String, FontInfo>(); for (FontInfo info : fontInfoList) { for (String name : getPostScriptNames(info.getPostScriptName())) { map.put(name, info); } } return map; }
/** * Finds a font with the given PostScript name, or a suitable substitute, or null. * * @param postScriptName PostScript font name */ private FontBoxFont findFontBoxFont(String postScriptName) { Type1Font t1 = (Type1Font)findFont(FontFormat.PFB, postScriptName); if (t1 != null) { return t1; } TrueTypeFont ttf = (TrueTypeFont)findFont(FontFormat.TTF, postScriptName); if (ttf != null) { return ttf; } OpenTypeFont otf = (OpenTypeFont) findFont(FontFormat.OTF, postScriptName); if (otf != null) { return otf; } return null; }
getProvider(); FontInfo info = getFont(format, postScriptName); if (info != null) info = getFont(format, postScriptName.replaceAll("-", "")); if (info != null) for (String substituteName : getSubstitutes(postScriptName)) info = getFont(format, substituteName); if (info != null) info = getFont(format, postScriptName.replaceAll(",", "-")); if (info != null) info = getFont(format, postScriptName + "-Regular"); if (info != null)
/** * 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); } }
OpenTypeFont otf1 = (OpenTypeFont)findFont(FontFormat.OTF, baseFont); if (otf1 != null) TrueTypeFont ttf = (TrueTypeFont)findFont(FontFormat.TTF, baseFont); if (ttf != null) PriorityQueue<FontMatch> queue = getFontMatches(fontDescriptor, cidSystemInfo); FontMatch bestMatch = queue.poll(); if (bestMatch != null)
/** * Sets the font service provider. */ public synchronized void setProvider(FontProvider fontProvider) { fontInfoByName = createFontInfoByName(fontProvider.getFontInfo()); this.fontProvider = fontProvider; }
private Map<String, FontInfo> createFontInfoByName(List<? extends FontInfo> fontInfoList) { Map<String, FontInfo> map = new LinkedHashMap<>(); for (FontInfo info : fontInfoList) { for (String name : getPostScriptNames(info.getPostScriptName())) { map.put(name, info); } } return map; }
/** * Finds a font with the given PostScript name, or a suitable substitute, or null. * * @param postScriptName PostScript font name */ private FontBoxFont findFontBoxFont(String postScriptName) { Type1Font t1 = (Type1Font)findFont(FontFormat.PFB, postScriptName); if (t1 != null) { return t1; } TrueTypeFont ttf = (TrueTypeFont)findFont(FontFormat.TTF, postScriptName); if (ttf != null) { return ttf; } OpenTypeFont otf = (OpenTypeFont) findFont(FontFormat.OTF, postScriptName); if (otf != null) { return otf; } return null; }