diff options
author | Simon Steiner <ssteiner@apache.org> | 2023-07-20 10:24:41 +0100 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2023-07-20 10:24:41 +0100 |
commit | b16022ece329197f72f47943085d45b56e26806e (patch) | |
tree | ac43474c4341ebc7cbb7a1f3215db6d4a03b4af2 /fop-core | |
parent | 6f6e58d7b89b04847f37ad887aa2b7235c2b484f (diff) | |
download | xmlgraphics-fop-b16022ece329197f72f47943085d45b56e26806e.tar.gz xmlgraphics-fop-b16022ece329197f72f47943085d45b56e26806e.zip |
FOP-3139: Add support for font-selection-strategy=character-by-character
Diffstat (limited to 'fop-core')
-rw-r--r-- | fop-core/src/main/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java index 57f790912..f44bd7bc0 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java @@ -781,6 +781,8 @@ public class TextLayoutManager extends LeafNodeLayoutManager { int level = -1; int prevLevel = -1; boolean retainControls = false; + Font lastFont = null; + int lastFontPos = -1; while (nextStart < foText.length()) { ch = foText.charAt(nextStart); level = foText.bidiLevelAt(nextStart); @@ -813,10 +815,22 @@ public class TextLayoutManager extends LeafNodeLayoutManager { + "}"); } if (inWord) { - if (breakOpportunity - || GlyphMapping.isSpace(ch) - || CharUtilities.isExplicitBreak(ch) - || ((prevLevel != -1) && (level != prevLevel))) { + boolean processWord = breakOpportunity + || GlyphMapping.isSpace(ch) + || CharUtilities.isExplicitBreak(ch) + || ((prevLevel != -1) && (level != prevLevel)); + if (!processWord && foText.getCommonFont().getFontSelectionStrategy() == EN_CHARACTER_BY_CHARACTER) { + if (lastFont == null || lastFontPos != nextStart - 1) { + lastFont = FontSelector.selectFontForCharactersInText( + foText, nextStart - 1, nextStart, foText, this); + } + Font font = FontSelector.selectFontForCharactersInText( + foText, nextStart, nextStart + 1, foText, this); + processWord = font != lastFont; + lastFont = font; + lastFontPos = nextStart; + } + if (processWord) { // this.foText.charAt(lastIndex) == CharUtilities.SOFT_HYPHEN prevMapping = processWord(alignment, sequence, prevMapping, ch, breakOpportunity, true, prevLevel, retainControls); |