public static void embedFonts(ITextRenderer renderer) { final PropertySet propertySet = Properties.instance().getPropertySet(); for (final String propertyName : propertySet.getPropertiesStartsWith("oxf.fr.pdf.font.path")) { final String path = StringUtils.trimToNull(propertySet.getString(propertyName)); if (path != null) { try { // Overriding the font family is optional final String family; { final String[] tokens = StringUtils.split(propertyName, '.'); if (tokens.length >= 6) { final String id = tokens[5]; family = StringUtils.trimToNull( propertySet.getString("oxf.fr.pdf.font.family" + '.' + id)); } else { family = null; } } // Add the font renderer .getFontResolver() .addFont(path, family, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, null); } catch (Exception e) { logger.warn( "Failed to load font by path: '" + path + "' specified with property '" + propertyName + "'"); } } } }
/** * Start a trace using the class from the given global property name if present. * * @param propertyName property name containing a class name * @return true iif new trace was started */ public boolean startTrace(String propertyName) { if (trace == null) { // don't create if already present final Properties properties = Properties.instance(); trace = createTraceIfNeeded(properties, propertyName); return trace != null; } else { return false; } }
private Trace createTraceIfNeeded(Properties properties, String propertyName) { if (properties != null) { final PropertySet propertySet = properties.getPropertySet(); if (propertySet != null) { final String traceClass = propertySet.getNCName(propertyName); if (traceClass != null) { return createTrace(traceClass); } } } return null; }