From: Jeremias Maerki Date: Sun, 19 Mar 2006 11:12:44 +0000 (+0000) Subject: Bugzilla #38731: X-Git-Tag: fop-0_92-beta~67 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3df0079c8b2caceeb750ebadc32422a39642a328;p=xmlgraphics-fop.git Bugzilla #38731: More accurate font size selection. Outer transformation matrix is no longer ignored when painting text. Improvement for transparent bitmaps (effect can be seen on filters-composite-01-b and render-groups-03-t in SVG 1.1 test suite) Submitted by: Michal Sevcenko git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@386954 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java index 9a8ef1d7a..59cb6612d 100644 --- a/src/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java @@ -578,7 +578,6 @@ public class PDFGraphics2D extends AbstractGraphics2D { BitmapImage fopimg = new BitmapImage("TempImage:" + img.toString(), buf.getWidth(), buf.getHeight(), result, ref); - fopimg.setTransparent(new PDFColor(255, 255, 255)); imageInfo = pdfDoc.addImage(resourceContext, fopimg); //int xObjectNum = imageInfo.getXNumber(); @@ -1385,17 +1384,19 @@ public class PDFGraphics2D extends AbstractGraphics2D { preparePainting(); Font fontState; + AffineTransform fontTransform = null; if (ovFontState == null) { java.awt.Font gFont = getFont(); + fontTransform = gFont.getTransform(); String n = gFont.getFamily(); if (n.equals("sanserif")) { n = "sans-serif"; } - int siz = gFont.getSize(); + float siz = gFont.getSize2D(); String style = gFont.isItalic() ? "italic" : "normal"; int weight = gFont.isBold() ? Font.BOLD : Font.NORMAL; FontTriplet triplet = fontInfo.fontLookup(n, style, weight); - fontState = fontInfo.getFontInstance(triplet, siz * 1000); + fontState = fontInfo.getFontInstance(triplet, (int)(siz * 1000 + 0.5)); } else { fontState = fontInfo.getFontInstance( ovFontState.getFontTriplet(), ovFontState.getFontSize()); @@ -1465,10 +1466,18 @@ public class PDFGraphics2D extends AbstractGraphics2D { currentStream.write("BT\n"); - //currentStream.write("1 0 0 -1 0 0 Tm [" + startText); - currentStream.write("1 0 0 -1 " - + PDFNumber.doubleOut(x) + " " + PDFNumber.doubleOut(y) - + " Tm [" + startText); + AffineTransform localTransform = new AffineTransform(); + localTransform.translate(x, y); + if (fontTransform != null) { + localTransform.concatenate(fontTransform); + } + localTransform.scale(1, -1); + double[] lt = new double[6]; + localTransform.getMatrix(lt); + currentStream.write(PDFNumber.doubleOut(lt[0]) + " " + + PDFNumber.doubleOut(lt[1]) + " " + PDFNumber.doubleOut(lt[2]) + " " + + PDFNumber.doubleOut(lt[3]) + " " + PDFNumber.doubleOut(lt[4]) + " " + + PDFNumber.doubleOut(lt[5]) + " Tm [" + startText); int l = s.length();