public void add( final String text ) { int style = Font.NORMAL; if ( bold ) { style |= Font.BOLD; } if ( italic ) { style |= Font.ITALIC; } if ( strikethrough ) { style |= Font.STRIKETHRU; } if ( underline ) { style |= Font.UNDERLINE; } final BaseFontFontMetrics fontMetrics = metaData.getBaseFontFontMetrics( fontName, fontSize, bold, italic, "utf-8", false, false ); final BaseFont baseFont = fontMetrics.getBaseFont(); final Font font = new Font( baseFont, (float) fontSize, style, textColor ); final Chunk c = new Chunk( text, font ); if ( backgroundColor != null ) { c.setBackground( backgroundColor ); } target.add( c ); } }
.isFeatureSupported( OutputProcessorFeature.EMBED_ALL_FONTS ), false ); final FontNativeContext nativeContext = fontMetrics.getNativeContext(); lastBaseFont = fontMetrics.getBaseFont();
private Phrase createPhrase( final RenderableComplexText node ) { Phrase p = new Phrase(); RichTextSpec text = node.getRichText(); for ( RichTextSpec.StyledChunk c : text.getStyleChunks() ) { TypedMapWrapper<Attribute, Object> attributes = new TypedMapWrapper<Attribute, Object>( c.getAttributes() ); final Number size = attributes.get( TextAttribute.SIZE, 10f, Number.class ); final PdfTextSpec pdfTextSpec = computeFont( c ); final int style = computeStyle( attributes, pdfTextSpec ); final Color paint = (Color) c.getStyleSheet().getStyleProperty( ElementStyleKeys.PAINT ); // add chunks BaseFont baseFont = pdfTextSpec.getFontMetrics().getBaseFont(); Font font = new Font( baseFont, size.floatValue(), style, paint ); if ( c.getOriginatingTextNode() instanceof RenderableReplacedContentBox ) { RenderableReplacedContentBox content = (RenderableReplacedContentBox) c.getOriginatingTextNode(); com.lowagie.text.Image image = imageHandler.createImage( content ); if ( image != null ) { Chunk chunk = new Chunk( image, 0, 0 ); // chunk.setFont(font); p.add( chunk ); } } else { String textToPrint = c.getText(); Chunk chunk = new Chunk( textToPrint, font ); p.add( chunk ); } } return p; }
cb.setFontAndSize( fontMetrics.getBaseFont(), fontSize ); } else { cb = textSpec.getContentByte(); final BaseFont baseFont = baseFontRecord.getBaseFont(); final float ascent; if ( legacyLineHeightCalc ) {