[med-svn] [Git][java-team/libpdfbox-graphics2d-java][upstream] New upstream version 0.43

Pierre Gruet (@pgt) gitlab at salsa.debian.org
Thu Jun 15 23:16:46 BST 2023



Pierre Gruet pushed to branch upstream at Debian Java Maintainers / libpdfbox-graphics2d-java


Commits:
8be2770b by Pierre Gruet at 2023-06-15T16:19:10+02:00
New upstream version 0.43
- - - - -


6 changed files:

- README.md
- extended-tests/pom.xml
- graphics2d/pom.xml
- graphics2d/src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawer.java
- graphics2d/src/test/java/de/rototor/pdfbox/graphics2d/FontTest.java
- pom.xml


Changes:

=====================================
README.md
=====================================
@@ -324,6 +324,12 @@ graphs
 
 ## Changes
 
+Version 0.43 (not yet released):
+
+- Upgraded PDFBox to 2.0.28
+- [#50](https://github.com/rototor/pdfbox-graphics2d/issues/50): Use the Java logger API instead of System.err.
+Thanks @pmds-martins for the PR.
+
 Version 0.42:
 
 - Upgraded PDFBox to 2.0.27


=====================================
extended-tests/pom.xml
=====================================
@@ -10,14 +10,14 @@
 	<parent>
 		<groupId>de.rototor.pdfbox</groupId>
 		<artifactId>pdfboxgraphics2d-parent</artifactId>
-		<version>0.42</version>
+		<version>0.43</version>
 	</parent>
 
 	<dependencies>
 		<dependency>
 			<groupId>de.rototor.pdfbox</groupId>
 			<artifactId>graphics2d</artifactId>
-			<version>0.42</version>
+			<version>0.43</version>
 		</dependency>
 
 		<dependency>


=====================================
graphics2d/pom.xml
=====================================
@@ -10,7 +10,7 @@
 	<parent>
 		<groupId>de.rototor.pdfbox</groupId>
 		<artifactId>pdfboxgraphics2d-parent</artifactId>
-		<version>0.42</version>
+		<version>0.43</version>
 	</parent>
 
 


=====================================
graphics2d/src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawer.java
=====================================
@@ -28,11 +28,16 @@ import java.awt.*;
 import java.awt.font.FontRenderContext;
 import java.awt.font.LineMetrics;
 import java.awt.font.TextAttribute;
+import java.awt.font.TransformAttribute;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
 import java.io.*;
 import java.text.AttributedCharacterIterator;
 import java.text.CharacterIterator;
 import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import java.util.*;
 
 /**
@@ -44,6 +49,9 @@ import java.util.*;
  */
 public class PdfBoxGraphics2DFontTextDrawer implements IPdfBoxGraphics2DFontTextDrawer, Closeable
 {
+
+    private static final Logger LOGGER = Logger.getLogger(PdfBoxGraphics2DFontTextDrawer.class.getName());
+
     /**
      * Close / delete all resources associated with this drawer. This mainly means
      * deleting all temporary files. You can not use this object after a call to
@@ -172,11 +180,6 @@ public class PdfBoxGraphics2DFontTextDrawer implements IPdfBoxGraphics2DFontText
         return getClass() != PdfBoxGraphics2DFontTextDrawer.class;
     }
 
-    /**
-     * Internal Testflag ot test the not yet working text decoration code.
-     */
-    private final static boolean ENABLE_EXPERIMENTAL_TEXT_DECORATION = true;
-
     @Override
     public boolean canDrawText(AttributedCharacterIterator iterator, IFontTextDrawerEnv env)
             throws IOException, FontFormatException
@@ -204,14 +207,9 @@ public class PdfBoxGraphics2DFontTextDrawer implements IPdfBoxGraphics2DFontText
             if (iterator.getAttribute(TextAttribute.BACKGROUND) != null)
                 return false;
 
-            boolean isStrikeThrough = TextAttribute.STRIKETHROUGH_ON
-                    .equals(iterator.getAttribute(TextAttribute.STRIKETHROUGH));
-            boolean isUnderline = TextAttribute.UNDERLINE_ON
-                    .equals(iterator.getAttribute(TextAttribute.UNDERLINE));
-            boolean isLigatures = TextAttribute.LIGATURES_ON
-                    .equals(iterator.getAttribute(TextAttribute.LIGATURES));
-            if (((isStrikeThrough || isUnderline) && !ENABLE_EXPERIMENTAL_TEXT_DECORATION)
-                    || isLigatures)
+            boolean isLigatures = TextAttribute.LIGATURES_ON.equals(
+                    iterator.getAttribute(TextAttribute.LIGATURES));
+            if (isLigatures)
                 return false;
 
             run = iterateRun(iterator, sb);
@@ -270,8 +268,26 @@ public class PdfBoxGraphics2DFontTextDrawer implements IPdfBoxGraphics2DFontText
 
     private static class DrawTextDecorationState
     {
-        public float x;
         final List<ITextDecorationDrawer> drawers = new ArrayList<ITextDecorationDrawer>();
+        public Matrix currentMatrix;
+        private final PDPageContentStream contentStream;
+        public Point2D currentPoint;
+        public Point2D deltaPoint = new Point2D.Float(0, 0);
+
+        public DrawTextDecorationState(PDPageContentStream contentStream)
+        {
+            this.contentStream = contentStream;
+        }
+
+        private void setCurrentTextMatrix(AffineTransform newAT) throws IOException
+        {
+            Matrix newMatrix = new Matrix(newAT);
+            if (!newMatrix.equals(currentMatrix))
+            {
+                currentMatrix = newMatrix;
+                contentStream.setTextMatrix(currentMatrix);
+            }
+        }
     }
 
     @Override
@@ -279,23 +295,25 @@ public class PdfBoxGraphics2DFontTextDrawer implements IPdfBoxGraphics2DFontText
             throws IOException, FontFormatException
     {
         PDPageContentStream contentStream = env.getContentStream();
-        DrawTextDecorationState drawState = new DrawTextDecorationState();
+        DrawTextDecorationState drawState = new DrawTextDecorationState(contentStream);
 
-        if (ENABLE_EXPERIMENTAL_TEXT_DECORATION)
-            contentStream.saveGraphicsState();
+        contentStream.saveGraphicsState();
 
         contentStream.beginText();
 
-        Matrix textMatrix = new Matrix();
-        textMatrix.scale(1, -1);
-        contentStream.setTextMatrix(textMatrix);
+        AffineTransform identityTextMatrix = new AffineTransform();
+        identityTextMatrix.scale(1, -1);
+        boolean needMatrixResetToIdentity = true;
+        drawState.currentPoint = new Point2D.Float(0, 0);
 
         StringBuilder sb = new StringBuilder();
+        drawState.currentMatrix = null;
         boolean run = true;
         while (run)
         {
 
             Font attributeFont = (Font) iterator.getAttribute(TextAttribute.FONT);
+            boolean wasAttributeFont = attributeFont != null;
             if (attributeFont == null)
                 attributeFont = env.getFont();
 
@@ -303,17 +321,53 @@ public class PdfBoxGraphics2DFontTextDrawer implements IPdfBoxGraphics2DFontText
             if (fontSize != null)
                 attributeFont = attributeFont.deriveFont(fontSize.floatValue());
             PDFont font = applyFont(attributeFont, env);
+            Object transform = iterator.getAttribute(TextAttribute.TRANSFORM);
+            AffineTransform attributedTransform = null;
+            if (transform instanceof AffineTransform)
+                attributedTransform = (AffineTransform) transform;
+            if (transform instanceof TransformAttribute)
+                attributedTransform = ((TransformAttribute) transform).getTransform();
+
+            boolean attributeFontTransformed = attributeFont.isTransformed();
+            /*
+             * The JDK does not respect transforms on the attribute when we have
+             * a font set.
+             */
+            if ((attributedTransform != null && !wasAttributeFont) || attributeFontTransformed)
+            {
+                AffineTransform tf;
+                if (attributeFontTransformed)
+                    tf = attributeFont.getTransform();
+                else
+                    tf = attributedTransform;
+
+                AffineTransform newAT = AffineTransform.getTranslateInstance(
+                        drawState.currentPoint.getX(), drawState.currentPoint.getY());
+                newAT.concatenate(tf);
+                newAT.scale(1, -1);
+
+                drawState.setCurrentTextMatrix(newAT);
+                needMatrixResetToIdentity = true;
+            }
+            else if (needMatrixResetToIdentity)
+            {
+                AffineTransform at = AffineTransform.getTranslateInstance(
+                        drawState.currentPoint.getX(), drawState.currentPoint.getY());
+                at.scale(1, -1);
+                drawState.setCurrentTextMatrix(at);
+                needMatrixResetToIdentity = false;
+            }
 
             Paint paint = (Paint) iterator.getAttribute(TextAttribute.FOREGROUND);
             if (paint == null)
                 paint = env.getPaint();
 
-            boolean isStrikeThrough = TextAttribute.STRIKETHROUGH_ON
-                    .equals(iterator.getAttribute(TextAttribute.STRIKETHROUGH));
-            boolean isUnderline = TextAttribute.UNDERLINE_ON
-                    .equals(iterator.getAttribute(TextAttribute.UNDERLINE));
-            boolean isLigatures = TextAttribute.LIGATURES_ON
-                    .equals(iterator.getAttribute(TextAttribute.LIGATURES));
+            boolean isStrikeThrough = TextAttribute.STRIKETHROUGH_ON.equals(
+                    iterator.getAttribute(TextAttribute.STRIKETHROUGH));
+            boolean isUnderline = TextAttribute.UNDERLINE_ON.equals(
+                    iterator.getAttribute(TextAttribute.UNDERLINE));
+            boolean isLigatures = TextAttribute.LIGATURES_ON.equals(
+                    iterator.getAttribute(TextAttribute.LIGATURES));
 
             run = iterateRun(iterator, sb);
             String text = sb.toString();
@@ -330,11 +384,12 @@ public class PdfBoxGraphics2DFontTextDrawer implements IPdfBoxGraphics2DFontText
              */
             try
             {
-                showTextOnStream(env, contentStream, attributeFont, font, isStrikeThrough,
-                        isUnderline, isLigatures, drawState, paint, text);
+                showTextOnStream(env, attributeFont, font, isStrikeThrough, isUnderline,
+                        isLigatures, drawState, paint, text);
             }
             catch (IllegalArgumentException e)
             {
+                IllegalArgumentException iae = e;
                 if (font instanceof PDType1Font && !font.isEmbedded())
                 {
                     /*
@@ -349,37 +404,35 @@ public class PdfBoxGraphics2DFontTextDrawer implements IPdfBoxGraphics2DFontText
                         {
                             env.getContentStream().setFont(fallbackFontUnknownEncodings,
                                     attributeFont.getSize2D());
-                            showTextOnStream(env, contentStream, attributeFont,
-                                    fallbackFontUnknownEncodings, isStrikeThrough, isUnderline,
-                                    isLigatures, drawState, paint, text);
-                            e = null;
+                            showTextOnStream(env, attributeFont, fallbackFontUnknownEncodings,
+                                    isStrikeThrough, isUnderline, isLigatures, drawState, paint,
+                                    text);
+                            iae = null;
                         }
                     }
                     catch (IllegalArgumentException e1)
                     {
-                        e = e1;
+                        iae = e1;
                     }
                 }
 
-                if (e != null)
-                    System.err.println("PDFBoxGraphics: Can not map text " + text + " with font "
-                            + attributeFont.getFontName() + ": " + e.getMessage());
+                if (iae != null)
+                    LOGGER.log(Level.SEVERE, "PDFBoxGraphics: Can not map text " + text + 
+                            " with font " + attributeFont.getFontName() + ": " + iae.getMessage(), iae);
             }
         }
         contentStream.endText();
 
-        if (ENABLE_EXPERIMENTAL_TEXT_DECORATION)
-            contentStream.restoreGraphicsState();
+        contentStream.restoreGraphicsState();
 
         if (!drawState.drawers.isEmpty())
         {
-            contentStream.saveGraphicsState();
-            contentStream.transform(textMatrix);
             for (ITextDecorationDrawer drawer : drawState.drawers)
             {
+                contentStream.saveGraphicsState();
                 drawer.draw(contentStream);
+                contentStream.restoreGraphicsState();
             }
-            contentStream.restoreGraphicsState();
         }
     }
 
@@ -603,7 +656,7 @@ public class PdfBoxGraphics2DFontTextDrawer implements IPdfBoxGraphics2DFontText
         return null;
     }
 
-    private PDType0Font tryToLoadFont(IFontTextDrawerEnv env, File foundFontFile) throws IOException
+    private PDType0Font tryToLoadFont(IFontTextDrawerEnv env, File foundFontFile)
     {
         try
         {
@@ -611,17 +664,17 @@ public class PdfBoxGraphics2DFontTextDrawer implements IPdfBoxGraphics2DFontText
         }
         catch (IOException e)
         {
-            // The font may be have a embed restriction.
+            // The font maybe have an embed restriction.
             return null;
         }
     }
 
     private static final boolean DEBUG_BOX = false;
 
-    private void showTextOnStream(final IFontTextDrawerEnv env,
-            final PDPageContentStream contentStream, final Font attributeFont, final PDFont font,
-            final boolean isStrikeThrough, final boolean isUnderline, boolean isLigatures,
-            DrawTextDecorationState drawState, final Paint paint, String text) throws IOException
+    private void showTextOnStream(final IFontTextDrawerEnv env, final Font attributeFont,
+            final PDFont font, final boolean isStrikeThrough, final boolean isUnderline,
+            boolean isLigatures, DrawTextDecorationState drawState, final Paint paint, String text)
+            throws IOException
     {
         // noinspection StatementWithEmptyBody
         if (isLigatures)
@@ -629,17 +682,25 @@ public class PdfBoxGraphics2DFontTextDrawer implements IPdfBoxGraphics2DFontText
             /*
              * No idea how to map this ...
              */
+
         }
+        final PDPageContentStream contentStream = drawState.contentStream;
 
         contentStream.showText(text);
 
         final float stringWidth = (font.getStringWidth(text) / 1000f) * attributeFont.getSize2D();
-        if ((isStrikeThrough || isUnderline) && ENABLE_EXPERIMENTAL_TEXT_DECORATION)
+        if ((isStrikeThrough || isUnderline))
         {
-            final LineMetrics lineMetrics = attributeFont
-                    .getLineMetrics(text, env.getFontRenderContext());
+            final LineMetrics lineMetrics = attributeFont.getLineMetrics(text,
+                    env.getFontRenderContext());
 
-            final float ourX = drawState.x;
+            final Matrix currentMatrix = drawState.currentMatrix;
+            final float ourX =
+                    (float) drawState.currentPoint.getX() - currentMatrix.getTranslateX();
+            final float ourY =
+                    (float) drawState.currentPoint.getY() - currentMatrix.getTranslateY();
+            //final float ourX = ;
+            //final float ourY = ;
 
             drawState.drawers.add(new ITextDecorationDrawer()
             {
@@ -652,21 +713,23 @@ public class PdfBoxGraphics2DFontTextDrawer implements IPdfBoxGraphics2DFontText
                             font.getBoundingBox().getHeight() / 1000 * attributeFont.getSize2D();
                     float scale = pdFontHeight / height;
                     float decent = lineMetrics.getDescent();
+                    contentStream.transform(currentMatrix);
                     if (DEBUG_BOX)
                     {
                         env.applyStroke(new BasicStroke(1));
                         env.applyPaint(new Color(0x5F2F13F2),
-                                new Rectangle.Float(ourX, -decent * scale, stringWidth,
+                                new Rectangle.Float(ourX, ourY - decent * scale, stringWidth,
                                         height * scale));
 
-                        contentStream.addRect(ourX, -decent * scale, stringWidth, height / scale);
+                        contentStream.addRect(ourX, ourY - decent * scale, stringWidth,
+                                height / scale);
                         contentStream.stroke();
                     }
 
-                    env.applyPaint(paint, new Rectangle.Float(ourX, -decent * scale, stringWidth,
-                            height * scale));
-                    float baseline = lineMetrics.getBaselineOffsets()[lineMetrics
-                            .getBaselineIndex()];
+                    env.applyPaint(paint,
+                            new Rectangle.Float(ourX, ourY - decent * scale, stringWidth,
+                                    height * scale));
+                    float baseline = lineMetrics.getBaselineOffsets()[lineMetrics.getBaselineIndex()];
                     if (isStrikeThrough)
                     {
                         env.applyStroke(new BasicStroke(
@@ -674,8 +737,8 @@ public class PdfBoxGraphics2DFontTextDrawer implements IPdfBoxGraphics2DFontText
                                         attributeFont)));
                         float strikethroughOffset =
                                 scale * (baseline + lineMetrics.getStrikethroughOffset());
-                        contentStream.moveTo(ourX, -strikethroughOffset);
-                        contentStream.lineTo(ourX + stringWidth, -strikethroughOffset);
+                        contentStream.moveTo(ourX, ourY - strikethroughOffset);
+                        contentStream.lineTo(ourX + stringWidth, ourY - strikethroughOffset);
                         contentStream.stroke();
                     }
                     if (isUnderline)
@@ -685,15 +748,21 @@ public class PdfBoxGraphics2DFontTextDrawer implements IPdfBoxGraphics2DFontText
                                         attributeFont)));
                         float underlineOffset =
                                 scale * (baseline + lineMetrics.getUnderlineOffset());
-                        contentStream.moveTo(ourX, -underlineOffset);
-                        contentStream.lineTo(ourX + stringWidth, -underlineOffset);
+                        contentStream.moveTo(ourX, ourY - underlineOffset);
+                        contentStream.lineTo(ourX + stringWidth, ourY - underlineOffset);
                         contentStream.stroke();
                     }
                 }
             });
         }
 
-        drawState.x += stringWidth;
+        Point2D deltaPoint = new Point2D.Double(stringWidth, 0);
+        assert drawState.currentMatrix != null;
+        drawState.currentMatrix.transform(deltaPoint);
+        drawState.deltaPoint = deltaPoint;
+        drawState.currentPoint = new Point2D.Double(
+                drawState.currentPoint.getX() + deltaPoint.getX(),
+                drawState.currentPoint.getY() + deltaPoint.getY());
     }
 
     private float getSensibleThickness(float thickness, Font font)


=====================================
graphics2d/src/test/java/de/rototor/pdfbox/graphics2d/FontTest.java
=====================================
@@ -2,6 +2,8 @@ package de.rototor.pdfbox.graphics2d;
 
 import java.awt.*;
 import java.awt.font.TextAttribute;
+import java.awt.font.TransformAttribute;
+import java.awt.geom.AffineTransform;
 import java.io.IOException;
 import java.text.AttributedString;
 
@@ -13,7 +15,7 @@ public class FontTest extends PdfBoxGraphics2DTestBase
     public void testAntonioFont() throws IOException, FontFormatException
     {
         final Font antonioRegular = Font.createFont(Font.TRUETYPE_FONT,
-                PdfBoxGraphics2dTest.class.getResourceAsStream("antonio/Antonio-Regular.ttf"))
+                        PdfBoxGraphics2dTest.class.getResourceAsStream("antonio/Antonio-Regular.ttf"))
                 .deriveFont(15f);
         exportGraphic("fonts", "antonio", new GraphicsExporter()
         {
@@ -31,7 +33,7 @@ public class FontTest extends PdfBoxGraphics2DTestBase
     public void testStyledAttributeIterator() throws IOException, FontFormatException
     {
         final Font antonioRegular = Font.createFont(Font.TRUETYPE_FONT,
-                PdfBoxGraphics2dTest.class.getResourceAsStream("antonio/Antonio-Regular.ttf"))
+                        PdfBoxGraphics2dTest.class.getResourceAsStream("antonio/Antonio-Regular.ttf"))
                 .deriveFont(15f);
         exportGraphic("fonts", "attributed_text", new GraphicsExporter()
         {
@@ -59,7 +61,7 @@ public class FontTest extends PdfBoxGraphics2DTestBase
 
                 Font font = new Font("SansSerif", Font.PLAIN, 12);
                 Font font2 = Font.createFont(Font.TRUETYPE_FONT,
-                        PdfBoxGraphics2dTest.class.getResourceAsStream("DejaVuSerifCondensed.ttf"))
+                                PdfBoxGraphics2dTest.class.getResourceAsStream("DejaVuSerifCondensed.ttf"))
                         .deriveFont(13f);
                 str.addAttribute(TextAttribute.FONT, font);
                 gfx.drawString(str.getIterator(), 10, 100);
@@ -68,4 +70,118 @@ public class FontTest extends PdfBoxGraphics2DTestBase
             }
         });
     }
+
+    @Test
+    public void testTransformedFont() throws IOException, FontFormatException
+    {
+        final Font antonioRegular = Font.createFont(Font.TRUETYPE_FONT,
+                        PdfBoxGraphics2dTest.class.getResourceAsStream("antonio/Antonio-Regular.ttf"))
+                .deriveFont(15f);
+        exportGraphic("fonts", "transformed", new GraphicsExporter()
+        {
+            @Override
+            public void draw(Graphics2D gfx) throws IOException, FontFormatException
+            {
+                AffineTransform affineTransform = antonioRegular.getTransform();
+                affineTransform.rotate(Math.toRadians(-90), 0, 0);
+                Font rotatedFont = antonioRegular.deriveFont(affineTransform);
+                gfx.setColor(Color.BLACK);
+                gfx.setFont(rotatedFont);
+                gfx.drawString("Some sample text", 50, 150);
+
+                AffineTransform saveTF = gfx.getTransform();
+                AffineTransform at = AffineTransform.getTranslateInstance(100, 150);
+                at.rotate(Math.toRadians(-90), 0, 0);
+                gfx.setColor(Color.RED);
+                gfx.setFont(antonioRegular);
+                gfx.setTransform(at);
+                gfx.drawString("Some sample text", 0, 0);
+                gfx.setTransform(saveTF);
+            }
+        });
+    }
+
+    @Test
+    public void testFancyTransformedFont() throws IOException, FontFormatException
+    {
+        final Font antonioRegular = Font.createFont(Font.TRUETYPE_FONT,
+                        PdfBoxGraphics2dTest.class.getResourceAsStream("antonio/Antonio-Regular.ttf"))
+                .deriveFont(15f);
+        exportGraphic("fonts", "fancyTransformed", new GraphicsExporter()
+        {
+            @Override
+            public void draw(Graphics2D gfx) throws IOException, FontFormatException
+            {
+                AffineTransform affineTransform = antonioRegular.getTransform();
+                affineTransform.shear(Math.toRadians(15), Math.toRadians(-35));
+                Font rotatedFont = antonioRegular.deriveFont(affineTransform);
+                gfx.setColor(Color.BLACK);
+                gfx.setFont(rotatedFont);
+                gfx.drawString("Sheared Text", 50, 150);
+
+                affineTransform = antonioRegular.getTransform();
+                affineTransform.rotate(Math.toRadians(45), Math.toRadians(-45));
+                rotatedFont = antonioRegular.deriveFont(affineTransform);
+                gfx.setColor(Color.BLUE);
+                gfx.setFont(rotatedFont);
+                gfx.drawString("Rotated Text", 150, 150);
+
+                affineTransform = antonioRegular.getTransform();
+                affineTransform.rotate(Math.toRadians(45), Math.toRadians(-45));
+                affineTransform.shear(Math.toRadians(45), Math.toRadians(-45));
+                rotatedFont = antonioRegular.deriveFont(affineTransform);
+                gfx.setColor(Color.GREEN);
+                gfx.setFont(rotatedFont);
+                gfx.drawString("Shear & Rotated Text", 50, 250);
+            }
+        });
+    }
+
+    @Test
+    public void testStyledAttributeIteratorTransformed() throws IOException, FontFormatException
+    {
+        final Font antonioRegular = Font.createFont(Font.TRUETYPE_FONT,
+                        PdfBoxGraphics2dTest.class.getResourceAsStream("antonio/Antonio-Regular.ttf"))
+                .deriveFont(15f);
+        exportGraphic("fonts", "attributed_transformed_text", new GraphicsExporter()
+        {
+            @Override
+            public void draw(Graphics2D gfx) throws IOException, FontFormatException
+            {
+                gfx.setColor(Color.BLACK);
+                gfx.setFont(antonioRegular);
+                AttributedString str = new AttributedString(
+                        "This is some funny text with some attributes.");
+                str.addAttribute(TextAttribute.SIZE, 20f, 0, 4);
+
+                str.addAttribute(TextAttribute.FOREGROUND, Color.RED, 0, 4);
+
+                str.addAttribute(TextAttribute.FOREGROUND, Color.green, 13, 23);
+                str.addAttribute(TextAttribute.SIZE, 18f, 13, 23);
+                str.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, 13, 23);
+                str.addAttribute(TextAttribute.TRANSFORM, new TransformAttribute(
+                        AffineTransform.getRotateInstance(Math.toRadians(10))), 13, 23);
+
+                str.addAttribute(TextAttribute.FOREGROUND, Color.MAGENTA, 34, 44);
+                str.addAttribute(TextAttribute.SIZE, 22f, 34, 44);
+                str.addAttribute(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON, 34,
+                        44);
+                str.addAttribute(TextAttribute.TRANSFORM, new TransformAttribute(
+                        AffineTransform.getRotateInstance(Math.toRadians(-10))), 34, 44);
+
+                gfx.drawString(str.getIterator(), 10, 50);
+
+                Font font = new Font("SansSerif", Font.PLAIN, 12);
+                Font font2 = Font.createFont(Font.TRUETYPE_FONT,
+                                PdfBoxGraphics2dTest.class.getResourceAsStream("DejaVuSerifCondensed.ttf"))
+                        .deriveFont(13f)
+                        .deriveFont(AffineTransform.getRotateInstance(Math.toRadians(15)));
+
+                str.addAttribute(TextAttribute.FONT, font);
+                gfx.drawString(str.getIterator(), 10, 100);
+                str.addAttribute(TextAttribute.FONT, font2);
+                gfx.drawString(str.getIterator(), 10, 150);
+            }
+        });
+    }
 }


=====================================
pom.xml
=====================================
@@ -6,7 +6,7 @@
 	<description>Graphics2D Bridge for Apache PDFBox</description>
 	<groupId>de.rototor.pdfbox</groupId>
 	<artifactId>pdfboxgraphics2d-parent</artifactId>
-	<version>0.42</version>
+	<version>0.43</version>
   	<packaging>pom</packaging>
 	<url>https://github.com/rototor/pdfbox-graphics2d</url>
 
@@ -41,7 +41,7 @@
 	<scm>
 		<url>https://github.com/rototor/pdfbox-graphics2d</url>
 		<connection>scm:git:https://github.com/rototor/pdfbox-graphics2d.git</connection>
-		<tag>pdfboxgraphics2d-parent-0.42</tag>
+		<tag>pdfboxgraphics2d-parent-0.43</tag>
 	</scm>
 
 	<distributionManagement>
@@ -59,7 +59,7 @@
 		<dependency>
 			<groupId>org.apache.pdfbox</groupId>
 			<artifactId>pdfbox</artifactId>
-			<version>2.0.27</version>
+			<version>2.0.28</version>
 		</dependency>
 		<dependency>
 			<groupId>junit</groupId>



View it on GitLab: https://salsa.debian.org/java-team/libpdfbox-graphics2d-java/-/commit/8be2770bee4121c9f06b802f00887e375a2ce337

-- 
View it on GitLab: https://salsa.debian.org/java-team/libpdfbox-graphics2d-java/-/commit/8be2770bee4121c9f06b802f00887e375a2ce337
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20230615/dad9ec0c/attachment-0001.htm>


More information about the debian-med-commit mailing list