Skip to content

Commit

Permalink
#47 Shear and rotate seems to be always a rotate on the text...
Browse files Browse the repository at this point in the history
  • Loading branch information
rototor committed Jan 8, 2023
1 parent 1195e62 commit a33e858
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,41 @@ public void draw(Graphics2D gfx) throws IOException, FontFormatException
}
});
}

@Test
public void testFanceTransformedFont() 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(45), Math.toRadians(-45));
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);

}
});
}
}

0 comments on commit a33e858

Please sign in to comment.