|
|
|
@ -169,12 +169,15 @@ public class PdfFont implements Comparable {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
float width(String s) { |
|
|
|
|
double width = 0.0d; |
|
|
|
|
java.awt.Font font = this.getAwtFont(); |
|
|
|
|
float scale = ONE_THOUSAND / font.getSize2D(); |
|
|
|
|
java.awt.Font derivedFont = font.deriveFont(AffineTransform.getScaleInstance(scale, scale)); |
|
|
|
|
double width = derivedFont.getStringBounds(s, new FontRenderContext(new AffineTransform(), true, true)).getWidth(); |
|
|
|
|
if (derivedFont.isTransformed()){ |
|
|
|
|
width /= scale; |
|
|
|
|
if (font.getSize2D() > 0) { |
|
|
|
|
float scale = ONE_THOUSAND / font.getSize2D(); |
|
|
|
|
java.awt.Font derivedFont = font.deriveFont(AffineTransform.getScaleInstance(scale, scale)); |
|
|
|
|
width = derivedFont.getStringBounds(s, new FontRenderContext(new AffineTransform(), true, true)).getWidth(); |
|
|
|
|
if (derivedFont.isTransformed()){ |
|
|
|
|
width /= scale; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (image == null) |
|
|
|
|
return (float) width * hScale; |
|
|
|
@ -182,6 +185,7 @@ public class PdfFont implements Comparable {
|
|
|
|
|
return image.getScaledWidth(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BaseFont getFont() { |
|
|
|
|
return oriFont.getCalculatedBaseFont(false); |
|
|
|
|
} |
|
|
|
|