Browse Source

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

* commit '233868a10a91299f4a29b24bdbfe374efdd750d3':
  REPORT-8403  这边用其他方式获取宽度
10.0
superman 7 years ago
parent
commit
a16a3bf1f4
  1. 8
      fine-itext/src/com/fr/third/v2/lowagie/text/Chunk.java

8
fine-itext/src/com/fr/third/v2/lowagie/text/Chunk.java

@ -50,6 +50,7 @@
package com.fr.third.v2.lowagie.text;
import java.awt.Color;
import java.awt.FontMetrics;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
@ -59,6 +60,7 @@ import com.fr.third.v2.lowagie.text.pdf.PdfAction;
import com.fr.third.v2.lowagie.text.pdf.PdfAnnotation;
import com.fr.third.v2.lowagie.text.pdf.PdfContentByte;
import com.fr.third.v2.lowagie.text.pdf.draw.DrawInterface;
import sun.font.FontDesignMetrics;
/**
* This is the smallest significant part of text that can be added to a
@ -394,9 +396,9 @@ public class Chunk implements Element {
if (getImage() != null) {
return getImage().getScaledWidth();
}
return font.getCalculatedBaseFont(true).getWidthPoint(getContent(),
font.getCalculatedSize())
* getHorizontalScaling();
java.awt.Font awtFont = new java.awt.Font(font.getFontName(), font.getStyle(), (int)font.getSize());
FontMetrics metrics = FontDesignMetrics.getMetrics(awtFont);
return metrics.stringWidth(getContent())* getHorizontalScaling();
}
// attributes

Loading…
Cancel
Save