Skip to content

Commit e6d7ee5

Browse files
committed
PDFBOX-5660: optimize, as suggested by Valery Bokov; closes #219
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1927943 13f79535-47bb-0310-9956-ffa450edef68
1 parent 97cbaa0 commit e6d7ee5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -933,19 +933,20 @@ private float calculateFontSize(PDFont font, PDRectangle contentRect) throws IOE
933933
}
934934
else
935935
{
936-
float yScalingFactor = FONTSCALE * font.getFontMatrix().getScaleY();
937-
float xScalingFactor = FONTSCALE * font.getFontMatrix().getScaleX();
936+
Matrix fontMatrix = font.getFontMatrix();
937+
float yScalingFactor = FONTSCALE * fontMatrix.getScaleY();
938+
float xScalingFactor = FONTSCALE * fontMatrix.getScaleX();
938939

939940
// fit width
940-
float width = font.getStringWidth(value) * font.getFontMatrix().getScaleX();
941+
float width = font.getStringWidth(value) * fontMatrix.getScaleX();
941942
float widthBasedFontSize = contentRect.getWidth() / width * xScalingFactor;
942943

943944
// fit height
944945
float height = (font.getFontDescriptor().getCapHeight() +
945-
-font.getFontDescriptor().getDescent()) * font.getFontMatrix().getScaleY();
946+
-font.getFontDescriptor().getDescent()) * fontMatrix.getScaleY();
946947
if (height <= 0)
947948
{
948-
height = font.getBoundingBox().getHeight() * font.getFontMatrix().getScaleY();
949+
height = font.getBoundingBox().getHeight() * fontMatrix.getScaleY();
949950
}
950951

951952
float heightBasedFontSize = contentRect.getHeight() / height * yScalingFactor;

0 commit comments

Comments
 (0)