Author: tilman
Date: Wed Feb  4 08:20:48 2026
New Revision: 1931702

Log:
PDFBOX-6165: revert refactoring and set font size before getting the font

Modified:
   
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/SetFontAndSize.java

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/SetFontAndSize.java
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/SetFontAndSize.java
  Wed Feb  4 08:20:44 2026        (r1931701)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/SetFontAndSize.java
  Wed Feb  4 08:20:48 2026        (r1931702)
@@ -69,13 +69,15 @@ public class SetFontAndSize extends Oper
         COSName fontName = (COSName) base0;
         float fontSize = ((COSNumber) base1).floatValue();
         PDFStreamEngine context = getContext();
+        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);
     }
 

Reply via email to