Author: tilman
Date: Wed Feb 4 08:20:40 2026
New Revision: 1931700
Log:
PDFBOX-6165: revert refactoring and set font size before getting the font
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/SetFontAndSize.java
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/SetFontAndSize.java
==============================================================================
---
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/SetFontAndSize.java
Wed Feb 4 07:01:00 2026 (r1931699)
+++
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/SetFontAndSize.java
Wed Feb 4 08:20:40 2026 (r1931700)
@@ -63,13 +63,15 @@ public class SetFontAndSize extends Oper
}
COSName fontName = (COSName) base0;
float fontSize = ((COSNumber) base1).floatValue();
+ PDTextState textState = context.getGraphicsState().getTextState();
+ textState.setFontSize(fontSize);
+ // Get the font after the size has been set in case there is an
exception
+ // so that PDFBox will use a default font
PDFont font = context.getResources().getFont(fontName);
if (font == null)
{
LOG.warn("font '" + fontName.getName() + "' not found in
resources");
}
- PDTextState textState = context.getGraphicsState().getTextState();
- textState.setFontSize(fontSize);
textState.setFont(font);
}