Skip to content

Commit 6922728

Browse files
committed
PDFBOX-5660: optimize, as suggested by Valery Bokov; clarify code; closes #394
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1931254 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3d37a48 commit 6922728

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/SetFontAndSize.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.apache.pdfbox.cos.COSName;
3333
import org.apache.pdfbox.cos.COSNumber;
3434
import org.apache.pdfbox.pdmodel.font.PDFont;
35+
import org.apache.pdfbox.pdmodel.graphics.state.PDTextState;
3536

3637
/**
3738
* Tf: Set text font and size.
@@ -68,13 +69,14 @@ public void process(Operator operator, List<COSBase> arguments) throws IOExcepti
6869
COSName fontName = (COSName) base0;
6970
float fontSize = ((COSNumber) base1).floatValue();
7071
PDFStreamEngine context = getContext();
71-
context.getGraphicsState().getTextState().setFontSize(fontSize);
7272
PDFont font = context.getResources().getFont(fontName);
7373
if (font == null)
7474
{
7575
LOG.warn("font '{}' not found in resources", fontName.getName());
7676
}
77-
context.getGraphicsState().getTextState().setFont(font);
77+
PDTextState textState = context.getGraphicsState().getTextState();
78+
textState.setFontSize(fontSize);
79+
textState.setFont(font);
7880
}
7981

8082
@Override

0 commit comments

Comments
 (0)