Skip to content

Commit 84b56ff

Browse files
1 parent 8450ea8 commit 84b56ff

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/main/java/org/apache/fop/fonts/GlyphMapping.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class GlyphMapping {
4949
public MinOptMax areaIPD;
5050
public final boolean isHyphenated;
5151
public final boolean isSpace;
52-
public final boolean isZeroWidthSpace;
52+
public final boolean isZeroWidthSpace; // to check for zero-width space (otherwise we get redundant spaces in copy-paste text from PDF)
5353
public boolean breakOppAfter;
5454
public final Font font;
5555
public final int level;

src/main/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java

+2
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ private void addWord(int startIndex, int endIndex, int wordLength) {
515515
}
516516

517517
private boolean isWordSpace(int mappingIndex) {
518+
// !getGlyphMapping(mappingIndex).isZeroWidthSpace - no need add space for zero-width space, otherwise we get redundant spaces in copy-paste text from PDF
518519
return userAgent.isAccessibilityEnabled()
519520
&& mappingIndex < mappings.size() - 1 && getGlyphMapping(mappingIndex).isSpace && !getGlyphMapping(mappingIndex).isZeroWidthSpace;
520521
}
@@ -859,6 +860,7 @@ public List getNextKnuthElements(final LayoutContext context, final int alignmen
859860
Font font = FontSelector.selectFontForCharacterInText(ch, foText, this);
860861
MinOptMax ipd = MinOptMax.getInstance(font.getCharWidth(ch));
861862

863+
// to check for zero-width space (otherwise we get redundant spaces in copy-paste text from PDF)
862864
boolean isZeroWidthSpace = (ch == CharUtilities.ZERO_WIDTH_SPACE);
863865

864866
mapping = new GlyphMapping(nextStart, nextStart + 1, 0, 0, ipd, false, true, isZeroWidthSpace,

0 commit comments

Comments
 (0)