Browse Source

Merge pull request #123 in CORE/base-third from ~KERRY/base-third:release/10.0 to release/10.0

* commit '5b87243654a59025b4b29098e5b8b781b019e982':
  无jira任务,打包失败
final/10.0.3
ju 6 years ago
parent
commit
6488db1534
  1. 6
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfFont.java

6
fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfFont.java

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

Loading…
Cancel
Save