public static void populateDescription(String path, BaseFont font, FontDescription descr) throws IOException, NoSuchFieldException, IllegalAccessException, DocumentException { RandomAccessFileOrArray rf = null; try { rf = new RandomAccessFileOrArray(getTTCName(path)); rf = populateDescription0(path, font, descr, rf); } finally { if (rf != null) { try { rf.close(); } catch (IOException e) { // ignore } } } }
/** * Utility method which uses iText libraries to determine the family name(s) for the font at the given path. * The iText APIs seem to indicate there can be more than one name, but this method will return a set of them. * Use a name from this list when referencing the font in CSS for PDF output. Note that family names as reported * by iText may vary from those reported by the AWT Font class, e.g. "Arial Unicode MS" for iText and * "ArialUnicodeMS" for AWT. * * @param path local path to the font file * @param encoding same as what you would use for {@link #addFont(String, String, boolean)} * @param embedded same as what you would use for {@link #addFont(String, String, boolean)} * @return set of all family names for the font file, as reported by iText libraries */ public static Set getDistinctFontFamilyNames(String path, String encoding, boolean embedded) { BaseFont font = null; try { font = BaseFont.createFont(path, encoding, embedded); String[] fontFamilyNames = TrueTypeUtil.getFamilyNames(font); Set distinct = new HashSet(); for (int i = 0; i < fontFamilyNames.length; i++) { distinct.add(fontFamilyNames[i]); } return distinct; } catch (DocumentException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } }
fontFamilyNames = new String[] { fontFamilyNameOverride }; } else { fontFamilyNames = TrueTypeUtil.getFamilyNames(font); TrueTypeUtil.populateDescription(uri, afmttf, font, descr); } catch (Exception e) { throw new XRRuntimeException(e.getMessage(), e);
private static RandomAccessFileOrArray populateDescription0(String path, BaseFont font, FontDescription descr, RandomAccessFileOrArray rf) throws NoSuchFieldException, IllegalAccessException, DocumentException, IOException { Map tables = extractTables(font); descr.setStyle(guessStyle(font));
public static void populateDescription(String path, byte[] contents, BaseFont font, FontDescription descr) throws IOException, NoSuchFieldException, IllegalAccessException, DocumentException { RandomAccessFileOrArray rf = null; try { rf = new RandomAccessFileOrArray(contents); rf = populateDescription0(path, font, descr, rf); } finally { if (rf != null) { try { rf.close(); } catch (IOException e) { // ignore } } } }
BaseFont font = BaseFont.createFont(uri, encoding, embedded, false, afmttf, pfb); String fontFamilyName = TrueTypeUtil.getFamilyName(font); FontFamily fontFamily = getFontFamily(fontFamilyName); TrueTypeUtil.populateDescription(uri, afmttf, font, descr); } catch (Exception e) { throw new XRRuntimeException(e.getMessage(), e);
fontFamilyName = TrueTypeUtil.getFamilyName(font);
fontFamilyNames = new String[] { fontFamilyNameOverride }; } else { fontFamilyNames = TrueTypeUtil.getFamilyNames(font); TrueTypeUtil.populateDescription(uri, afmttf, font, descr); } catch (Exception e) { throw new XRRuntimeException(e.getMessage(), e);
private static RandomAccessFileOrArray populateDescription0(String path, BaseFont font, FontDescription descr, RandomAccessFileOrArray rf) throws NoSuchFieldException, IllegalAccessException, DocumentException, IOException { Map<String, int[]> tables = extractTables(font); descr.setStyle(guessStyle(font));
public static void populateDescription(String path, byte[] contents, BaseFont font, FontDescription descr) throws IOException, NoSuchFieldException, IllegalAccessException, DocumentException { RandomAccessFileOrArray rf = null; try { rf = new RandomAccessFileOrArray(contents); rf = populateDescription0(path, font, descr, rf); } finally { if (rf != null) { try { rf.close(); } catch (IOException e) { // ignore } } } }
BaseFont font = BaseFont.createFont(path, encoding, embedded); String fontFamilyName = TrueTypeUtil.getFamilyName(font); FontFamily fontFamily = getFontFamily(fontFamilyName); TrueTypeUtil.populateDescription(path, font, descr); } catch (Exception e) { throw new XRRuntimeException(e.getMessage(), e);
fontFamilyNames = new String[] { fontFamilyNameOverride }; } else { fontFamilyNames = TrueTypeUtil.getFamilyNames(font); TrueTypeUtil.populateDescription(path, font, descr); } catch (Exception e) { throw new XRRuntimeException(e.getMessage(), e);
public static void populateDescription(String path, BaseFont font, FontDescription descr) throws IOException, NoSuchFieldException, IllegalAccessException, DocumentException { RandomAccessFileOrArray rf = null; try { rf = new RandomAccessFileOrArray(getTTCName(path)); rf = populateDescription0(path, font, descr, rf); } finally { if (rf != null) { try { rf.close(); } catch (IOException e) { // ignore } } } }
private static RandomAccessFileOrArray populateDescription0(String path, BaseFont font, FontDescription descr, RandomAccessFileOrArray rf) throws NoSuchFieldException, IllegalAccessException, DocumentException, IOException { Map<String, int[]> tables = extractTables(font); descr.setStyle(guessStyle(font));
public static void populateDescription(String path, byte[] contents, BaseFont font, FontDescription descr) throws IOException, NoSuchFieldException, IllegalAccessException, DocumentException { RandomAccessFileOrArray rf = null; try { rf = new RandomAccessFileOrArray(contents); rf = populateDescription0(path, font, descr, rf); } finally { if (rf != null) { try { rf.close(); } catch (IOException e) { // ignore } } } }
/** * Utility method which uses iText libraries to determine the family name(s) for the font at the given path. * The iText APIs seem to indicate there can be more than one name, but this method will return a set of them. * Use a name from this list when referencing the font in CSS for PDF output. Note that family names as reported * by iText may vary from those reported by the AWT Font class, e.g. "Arial Unicode MS" for iText and * "ArialUnicodeMS" for AWT. * * @param path local path to the font file * @param encoding same as what you would use for {@link #addFont(String, String, boolean)} * @param embedded same as what you would use for {@link #addFont(String, String, boolean)} * @return set of all family names for the font file, as reported by iText libraries */ public static Set getDistinctFontFamilyNames(String path, String encoding, boolean embedded) { BaseFont font = null; try { font = BaseFont.createFont(path, encoding, embedded); String[] fontFamilyNames = TrueTypeUtil.getFamilyNames(font); Set distinct = new HashSet(); for (int i = 0; i < fontFamilyNames.length; i++) { distinct.add(fontFamilyNames[i]); } return distinct; } catch (DocumentException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } }
fontFamilyNames = new String[] { fontFamilyNameOverride }; } else { fontFamilyNames = TrueTypeUtil.getFamilyNames(font); TrueTypeUtil.populateDescription(path, font, descr); } catch (Exception e) { throw new XRRuntimeException(e.getMessage(), e);
public static void populateDescription(String path, BaseFont font, FontDescription descr) throws IOException, NoSuchFieldException, IllegalAccessException, DocumentException { RandomAccessFileOrArray rf = null; try { rf = new RandomAccessFileOrArray(getTTCName(path)); rf = populateDescription0(path, font, descr, rf); } finally { if (rf != null) { try { rf.close(); } catch (IOException e) { // ignore } } } }
private static RandomAccessFileOrArray populateDescription0(String path, BaseFont font, FontDescription descr, RandomAccessFileOrArray rf) throws NoSuchFieldException, IllegalAccessException, DocumentException, IOException { Map<String, int[]> tables = extractTables(font); descr.setStyle(guessStyle(font));
public static void populateDescription(String path, byte[] contents, BaseFont font, FontDescription descr) throws IOException, NoSuchFieldException, IllegalAccessException, DocumentException { RandomAccessFileOrArray rf = null; try { rf = new RandomAccessFileOrArray(contents); rf = populateDescription0(path, font, descr, rf); } finally { if (rf != null) { try { rf.close(); } catch (IOException e) { // ignore } } } }