Author: tilman
Date: Thu Aug 21 10:35:46 2025
New Revision: 1927943
Log:
PDFBOX-5660: optimize, as suggested by Valery Bokov; closes #219
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
==============================================================================
---
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
Thu Aug 21 10:35:42 2025 (r1927942)
+++
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
Thu Aug 21 10:35:46 2025 (r1927943)
@@ -933,19 +933,20 @@ class AppearanceGeneratorHelper
}
else
{
- float yScalingFactor = FONTSCALE *
font.getFontMatrix().getScaleY();
- float xScalingFactor = FONTSCALE *
font.getFontMatrix().getScaleX();
+ Matrix fontMatrix = font.getFontMatrix();
+ float yScalingFactor = FONTSCALE * fontMatrix.getScaleY();
+ float xScalingFactor = FONTSCALE * fontMatrix.getScaleX();
// fit width
- float width = font.getStringWidth(value) *
font.getFontMatrix().getScaleX();
+ float width = font.getStringWidth(value) *
fontMatrix.getScaleX();
float widthBasedFontSize = contentRect.getWidth() / width *
xScalingFactor;
// fit height
float height = (font.getFontDescriptor().getCapHeight() +
- -font.getFontDescriptor().getDescent()) *
font.getFontMatrix().getScaleY();
+ -font.getFontDescriptor().getDescent()) *
fontMatrix.getScaleY();
if (height <= 0)
{
- height = font.getBoundingBox().getHeight() *
font.getFontMatrix().getScaleY();
+ height = font.getBoundingBox().getHeight() *
fontMatrix.getScaleY();
}
float heightBasedFontSize = contentRect.getHeight() / height *
yScalingFactor;