File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
pdfbox/src/main/java/org/apache/pdfbox/text Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments