/** * Creates a new TrueType font program from ttc (TrueType Collection) file. * * @param ttc location of TrueType Collection file (*.ttc) * @param ttcIndex the index of the font file from the collection to be read * @param cached true if the font comes from the cache or is added to * the cache if new, false if the font is always created new * @return returns a new {@link FontProgram} instance. This font may come from the cache but only if cached * is true, otherwise it will always be created new */ public static FontProgram createFont(String ttc, int ttcIndex, boolean cached) throws java.io.IOException { FontCacheKey fontCacheKey = FontCacheKey.create(ttc, ttcIndex); if (cached) { FontProgram fontFound = FontCache.getFont(fontCacheKey); if (fontFound != null) { return fontFound; } } FontProgram fontBuilt = new TrueTypeFont(ttc, ttcIndex); return cached ? FontCache.saveFont(fontBuilt, fontCacheKey) : fontBuilt; }
/** * Creates a new TrueType font program from ttc (TrueType Collection) file bytes. * * @param ttc the content of a TrueType Collection file (*.ttc) * @param ttcIndex the index of the font file from the collection to be read * @param cached true if the font comes from the cache or is added to * the cache if new, false if the font is always created new * @return returns a new {@link FontProgram} instance. This font may come from the cache but only if cached * is true, otherwise it will always be created new */ public static FontProgram createFont(byte[] ttc, int ttcIndex, boolean cached) throws java.io.IOException { FontCacheKey fontKey = FontCacheKey.create(ttc, ttcIndex); if (cached) { FontProgram fontFound = FontCache.getFont(fontKey); if (fontFound != null) { return fontFound; } } FontProgram fontBuilt = new TrueTypeFont(ttc, ttcIndex); return cached ? FontCache.saveFont(fontBuilt, fontKey) : fontBuilt; }
/** * Creates a new TrueType font program from ttc (TrueType Collection) file. * * @param ttc location of TrueType Collection file (*.ttc) * @param ttcIndex the index of the font file from the collection to be read * @param cached true if the font comes from the cache or is added to * the cache if new, false if the font is always created new * @return returns a new {@link FontProgram} instance. This font may come from the cache but only if cached * is true, otherwise it will always be created new */ public static FontProgram createFont(String ttc, int ttcIndex, boolean cached) throws java.io.IOException { FontCacheKey fontCacheKey = FontCacheKey.create(ttc, ttcIndex); if (cached) { FontProgram fontFound = FontCache.getFont(fontCacheKey); if (fontFound != null) { return fontFound; } } FontProgram fontBuilt = new TrueTypeFont(ttc, ttcIndex); return cached ? FontCache.saveFont(fontBuilt, fontCacheKey) : fontBuilt; }
/** * Creates a new TrueType font program from ttc (TrueType Collection) file bytes. * * @param ttc the content of a TrueType Collection file (*.ttc) * @param ttcIndex the index of the font file from the collection to be read * @param cached true if the font comes from the cache or is added to * the cache if new, false if the font is always created new * @return returns a new {@link FontProgram} instance. This font may come from the cache but only if cached * is true, otherwise it will always be created new */ public static FontProgram createFont(byte[] ttc, int ttcIndex, boolean cached) throws java.io.IOException { FontCacheKey fontKey = FontCacheKey.create(ttc, ttcIndex); if (cached) { FontProgram fontFound = FontCache.getFont(fontKey); if (fontFound != null) { return fontFound; } } FontProgram fontBuilt = new TrueTypeFont(ttc, ttcIndex); return cached ? FontCache.saveFont(fontBuilt, fontKey) : fontBuilt; }
fontProgram = Woff2Converter.convert(fontProgram); fontBuilt = new TrueTypeFont(fontProgram); } catch (Exception ignored) { } else if (".ttf".equals(fontFileExtension) || ".otf".equals(fontFileExtension)) { if (fontProgram != null) { fontBuilt = new TrueTypeFont(fontProgram); } else { fontBuilt = new TrueTypeFont(name); fontBuilt = new TrueTypeFont(fontProgram); } else { int ttcSplit = baseName.toLowerCase().indexOf(".ttc,"); String ttcName = baseName.substring(0, ttcSplit + 4); // count(.ttc) = 4 int ttcIndex = Integer.parseInt(baseName.substring(ttcSplit + 5)); // count(.ttc,) = 5) fontBuilt = new TrueTypeFont(ttcName, ttcIndex); } catch (NumberFormatException nfe) { throw new IOException(nfe.getMessage(), nfe);
fontProgram = Woff2Converter.convert(fontProgram); fontBuilt = new TrueTypeFont(fontProgram); } catch (Exception ignored) { } else if (".ttf".equals(fontFileExtension) || ".otf".equals(fontFileExtension)) { if (fontProgram != null) { fontBuilt = new TrueTypeFont(fontProgram); } else { fontBuilt = new TrueTypeFont(name); fontBuilt = new TrueTypeFont(fontProgram); } else { int ttcSplit = baseName.toLowerCase().indexOf(".ttc,"); String ttcName = baseName.substring(0, ttcSplit + 4); // count(.ttc) = 4 int ttcIndex = Integer.parseInt(baseName.substring(ttcSplit + 5)); // count(.ttc,) = 5) fontBuilt = new TrueTypeFont(ttcName, ttcIndex); } catch (NumberFormatException nfe) { throw new IOException(nfe.getMessage(), nfe);