/** * Creates a font record key. * * @return the font record key. */ public BaseFontRecordKey createKey() { if ( key == null ) { key = new BaseFontRecordKey( getFileName(), getEncoding(), isEmbedded() ); } return key; }
/** * Stores a record in the cache. * * @param record the record. */ private void putToCache( final BaseFontRecord record ) { final BaseFontRecordKey key = record.createKey(); putToCache( key, record ); }
public static synchronized ITextFontRegistry getFontRegistry() { if ( fontRegistry == null ) { fontRegistry = new ITextFontRegistry(); fontRegistry.initialize(); } return fontRegistry; }
public ITextBuiltInFontRegistry() { families = new HashMap(); families.put( "Symbol", createSymbolFamily() ); families.put( "ZapfDingbats", createZapfDingbatsFamily() ); families.put( "Times", createTimesFamily() ); families.put( "Courier", createCourierFamily() ); families.put( "Helvetica", createHelveticaFamily() ); familyNames = new String[] { "Symbol", "ZapfDingbats", "Times", "Courier", "Helvetica" }; }
/** * Returns a BaseFont which can be used to represent the given AWT Font * * @param font the font to be converted * @return a BaseFont which has similar properties to the provided Font */ public BaseFont awtToPdf( final Font font ) { // this has to be defined in the element, an has to set as a default... final boolean embed = isEmbedFonts(); final String encoding = getDefaultEncoding(); try { return createBaseFont( font.getName(), font.isBold(), font.isItalic(), encoding, embed ); } catch ( Exception e ) { // unable to handle font creation exceptions properly, all we can // do is throw a runtime exception and hope the best .. throw new BaseFontCreateException( "Unable to create font: " + font, e ); } }
public ITextFontStorage( final ITextFontRegistry registry, final String encoding ) { ArgumentNullException.validate( "registry", registry ); ArgumentNullException.validate( "encoding", encoding ); this.lookupKey = new EncodingFontKey(); this.knownMetrics = new FirstLevelFontCache( registry.getSecondLevelCache() ); this.registry = registry; this.defaultEncoding = encoding; this.metricsFactory = (ITextFontMetricsFactory) registry.createMetricsFactory(); }
public long getMaxHeight() { return getMaxAscent() + getMaxDescent() + getLeading(); }
public long getStrikeThroughPosition() { return getMaxAscent() - (long) ( LibFontsDefaults.DEFAULT_STRIKETHROUGH_POSITION * getXHeight() ); }
/** * Creates a iText-BaseFont for an font. If no basefont could be created, an BaseFontCreateException is thrown. * * @param logicalName the name of the font (null not permitted). * @param bold a flag indicating whether the font is rendered as bold font. * @param italic a flag indicating whether the font is rendered as italic or cursive font. * @param encoding the encoding. * @param embedded a flag indicating whether to embed the font glyphs in the generated documents. * @return the base font record. * @throws BaseFontCreateException if there was a problem setting the font for the target. */ public BaseFont createBaseFont( final String logicalName, final boolean bold, final boolean italic, final String encoding, final boolean embedded ) throws BaseFontCreateException { return createBaseFontRecord( logicalName, bold, italic, encoding, embedded ).getBaseFont(); }
public ITextFontRegistry() { addRegistry( new ITextBuiltInFontRegistry() ); addRegistry( new TrueTypeFontRegistry() ); addRegistry( new AfmFontRegistry() ); addRegistry( new PfmFontRegistry() ); }
private FontFamily createTimesFamily() { final DefaultFontFamily fontFamily = new DefaultFontFamily( "Times" ); fontFamily.addFontRecord( new ITextBuiltInFontRecord( fontFamily, BaseFont.TIMES_ROMAN, false, false, false ) ); fontFamily.addFontRecord( new ITextBuiltInFontRecord( fontFamily, BaseFont.TIMES_BOLD, true, false, false ) ); fontFamily.addFontRecord( new ITextBuiltInFontRecord( fontFamily, BaseFont.TIMES_ITALIC, false, true, false ) ); fontFamily.addFontRecord( new ITextBuiltInFontRecord( fontFamily, BaseFont.TIMES_BOLDITALIC, true, true, false ) ); return fontFamily; }
public FontMetricsFactory createMetricsFactory() { return new ITextFontMetricsFactory( this ); } }
public ITextFontMetricsFactory( final ITextFontRegistry registry ) { this.baseFontSupport = new BaseFontSupport( registry ); }
public void close() { this.baseFontSupport.close(); }
public FontCache getSecondLevelCache() { return internalGetSecondLevelCache(); }
public RTFOutputProcessorMetaData( final int paginationMode ) { super( new ITextFontStorage( BaseFontModule.getFontRegistry() ) ); this.paginationMode = paginationMode; }
private FontFamily createHelveticaFamily() { final DefaultFontFamily fontFamily = new DefaultFontFamily( "Helvetica" ); fontFamily.addFontRecord( new ITextBuiltInFontRecord( fontFamily, BaseFont.HELVETICA, false, false, false ) ); fontFamily.addFontRecord( new ITextBuiltInFontRecord( fontFamily, BaseFont.HELVETICA_BOLD, true, false, false ) ); fontFamily.addFontRecord( new ITextBuiltInFontRecord( fontFamily, BaseFont.HELVETICA_OBLIQUE, false, true, true ) ); fontFamily .addFontRecord( new ITextBuiltInFontRecord( fontFamily, BaseFont.HELVETICA_BOLDOBLIQUE, true, true, true ) ); return fontFamily; }
private FontFamily createCourierFamily() { final DefaultFontFamily fontFamily = new DefaultFontFamily( "Courier" ); fontFamily.addFontRecord( new ITextBuiltInFontRecord( fontFamily, BaseFont.COURIER, false, false, false ) ); fontFamily.addFontRecord( new ITextBuiltInFontRecord( fontFamily, BaseFont.COURIER_BOLD, true, false, false ) ); fontFamily.addFontRecord( new ITextBuiltInFontRecord( fontFamily, BaseFont.COURIER_OBLIQUE, false, true, true ) ); fontFamily .addFontRecord( new ITextBuiltInFontRecord( fontFamily, BaseFont.COURIER_BOLDOBLIQUE, true, true, true ) ); return fontFamily; }
private FontFamily createZapfDingbatsFamily() { final DefaultFontFamily fontFamily = new DefaultFontFamily( "ZapfDingbats" ); fontFamily.addFontRecord( new ITextBuiltInFontRecord( fontFamily, BaseFont.ZAPFDINGBATS, false, false, false ) ); return fontFamily; }
private FontFamily createSymbolFamily() { final DefaultFontFamily fontFamily = new DefaultFontFamily( "Symbol" ); fontFamily.addFontRecord( new ITextBuiltInFontRecord( fontFamily, BaseFont.SYMBOL, false, false, false ) ); return fontFamily; }