Skip to content

Commit 22a757a

Browse files
committed
PDFBOX-4668: use font name when comparing fonts
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1925172 13f79535-47bb-0310-9956-ffa450edef68
1 parent 01dad9a commit 22a757a

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -562,13 +562,18 @@ protected void writePage() throws IOException
562562

563563
// Resets the average character width when we see a change in font
564564
// or a change in the font size
565-
if (lastPosition != null &&
566-
(position.getFont() != lastPosition.getTextPosition().getFont() ||
567-
Float.compare(position.getFontSize(),lastPosition.getTextPosition().getFontSize()) != 0))
565+
if (lastPosition != null)
568566
{
569-
previousAveCharWidth = -1;
567+
TextPosition lastTextPosition = lastPosition.getTextPosition();
568+
boolean fontHasChanged = !position.getFont().getName()
569+
.equals(lastTextPosition.getFont().getName());
570+
boolean fontSizeChanged = Float.compare(position.getFontSize(),
571+
lastTextPosition.getFontSize()) != 0;
572+
if (fontHasChanged || fontSizeChanged)
573+
{
574+
previousAveCharWidth = -1;
575+
}
570576
}
571-
572577
float positionX;
573578
float positionY;
574579
float positionWidth;

0 commit comments

Comments
 (0)