if (text_fill_type == GraphicsState.STROKE && lineWidth >= 1.0) {
strokeOnlyLine = scaling;
}
//get glyph to draw
PdfGlyph glyph = FontFactory.chooseGlyph(glyphType, rawglyph);
AffineTransform at = g2.getTransform();
//and also as flat values so we can test below
double[] affValues = new double[6];
at.getMatrix(affValues);
if (glyph != null) {
Stroke currentStoke = g2.getStroke();
if (lineWidth != 0) {
float w = lineWidth * (float)g2.getTransform().getScaleX();
if (w < 0)
w = -w;
g2.setStroke(new BasicStroke(w));
}
//set transform
g2.transform(glyphAT);
//type of draw operation to use
Composite comp = g2.getComposite();
/**
* Fill Text
*/
if ((text_fill_type & GraphicsState.FILL) == GraphicsState.FILL) {
fillPaint.setScaling(cropX, cropH, scaling, 0, 0);
if (customColorHandler != null) {
customColorHandler.setPaint(g2, fillPaint, pageNumber, isPrinting);
} else if (PdfDecoder.Helper != null) {
PdfDecoder.Helper.setPaint(g2, fillPaint, pageNumber, isPrinting);
} else {
g2.setPaint(fillPaint);
}
if (fillOpacity != 1f) {
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, fillOpacity));
}
if (textHighlight != null) {
if (invertHighlight) {
Color color = g2.getColor();
g2.setColor(new Color(255 - color.getRed(), 255 - color.getGreen(), 255 - color.getBlue()));
} else if (DecoderOptions.backgroundColor != null) {
g2.setColor(DecoderOptions.backgroundColor);
}
}
glyph.render(GraphicsState.FILL, g2, scaling, false);
//reset opacity
g2.setComposite(comp);
}
/**
* Stroke Text (Can be fill and stroke so not in else)
*/
if (text_fill_type == GraphicsState.STROKE) {
glyph.setStrokedOnly(true);
}
//creates shadow printing to Mac so added work around
if (PdfDecoder.isRunningOnMac && isPrinting && text_fill_type == GraphicsState.FILLSTROKE) {
} else if ((text_fill_type & GraphicsState.STROKE) == GraphicsState.STROKE) {
if (strokePaint != null) {
strokePaint.setScaling(cropX, cropH, scaling, 0, 0);
}
if (customColorHandler != null) {
customColorHandler.setPaint(g2, strokePaint, pageNumber, isPrinting);
} else if (PdfDecoder.Helper != null) {
PdfDecoder.Helper.setPaint(g2, strokePaint, pageNumber, isPrinting);
} else {
g2.setPaint(strokePaint);
}
if (strokeOpacity != 1f) {
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, strokeOpacity));
}
if (textHighlight != null) {
if (invertHighlight) {
Color color = g2.getColor();
g2.setColor(new Color(255 - color.getRed(), 255 - color.getGreen(), 255 - color.getBlue()));
} else if (DecoderOptions.backgroundColor != null) {
g2.setColor(DecoderOptions.backgroundColor);
}
}
try {
glyph.render(GraphicsState.STROKE, g2, strokeOnlyLine, false);
} catch (Exception e) {
System.out.println("Exception " + e + " rendering glyph");
e.printStackTrace();
}