List of usage examples for com.lowagie.text.pdf PdfContentByte resetRGBColorFill
public void resetRGBColorFill()
From source file:net.sf.jasperreports.engine.export.PdfGlyphGraphics2D.java
License:Open Source License
@Override public void drawGlyphVector(GlyphVector glyphVector, float x, float y) { Font awtFont = glyphVector.getFont(); Map<Attribute, Object> fontAttrs = new HashMap<Attribute, Object>(); Map<TextAttribute, ?> awtFontAttributes = awtFont.getAttributes(); fontAttrs.putAll(awtFontAttributes); //the following relies on FontInfo.getFontInfo matching the face/font name com.lowagie.text.Font currentFont = pdfExporter.getFont(fontAttrs, locale, false); boolean bold = (currentFont.getStyle() & com.lowagie.text.Font.BOLD) != 0; boolean italic = (currentFont.getStyle() & com.lowagie.text.Font.ITALIC) != 0; PdfContentByte text = pdfContentByte.getDuplicate(); text.beginText();/*from ww w .jav a2 s . c o m*/ float[] originalCoords = new float[] { x, y }; float[] transformedCoors = new float[2]; getTransform().transform(originalCoords, 0, transformedCoors, 0, 1); text.setTextMatrix(1, 0, italic ? ITALIC_ANGLE : 0f, 1, transformedCoors[0], pdfExporter.getCurrentPageFormat().getPageHeight() - transformedCoors[1]); double scaleX = awtFont.getTransform().getScaleX(); double scaleY = awtFont.getTransform().getScaleY(); double minScale = Math.min(scaleX, scaleY); text.setFontAndSize(currentFont.getBaseFont(), (float) (minScale * awtFont.getSize2D())); if (bold) { text.setTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE); text.setLineWidth(currentFont.getSize() * BOLD_STRIKE_FACTOR); text.setColorStroke(getColor()); } text.setColorFill(getColor()); //FIXME find a way to determine the characters that correspond to this glyph vector // so that we can map the font glyphs that do not directly map to a character text.showText(glyphVector); text.resetRGBColorFill(); if (bold) { text.setTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL); text.setLineWidth(1f); text.resetRGBColorStroke(); } text.endText(); pdfContentByte.add(text); }