Browse Source

REPORT-8403 这边用其他方式获取宽度

10.0
kerry 7 years ago
parent
commit
a7b707fc32
  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