Skip to content

Commit 998fe1f

Browse files
committed
FOP-2855: apply patch from Juan for fixing letter spacing of spaces inside white-space=pre text
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1863872 13f79535-47bb-0310-9956-ffa450edef68
1 parent 8ad89db commit 998fe1f

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,15 @@ public List getNextKnuthElements(final LayoutContext context, final int alignmen
844844
font.mapChar(ch);
845845
// preserved space or non-breaking space:
846846
// create the GlyphMapping object
847-
mapping = new GlyphMapping(nextStart, nextStart + 1, 1, 0, wordSpaceIPD, false, true,
848-
breakOpportunity, spaceFont, level, null);
847+
MinOptMax areaIPD;
848+
if (prevMapping != null && prevMapping.isSpace) {
849+
areaIPD = wordSpaceIPD.minus(letterSpaceIPD);
850+
} else {
851+
areaIPD = wordSpaceIPD;
852+
}
853+
854+
mapping = new GlyphMapping(nextStart, nextStart + 1, 1, 0, areaIPD, false, true,
855+
breakOpportunity, spaceFont, level, null);
849856
thisStart = nextStart + 1;
850857
} else if (CharUtilities.isFixedWidthSpace(ch) || CharUtilities.isZeroWidthSpace(ch)) {
851858
// create the GlyphMapping object
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
<testcase>
19+
<info>
20+
<p>
21+
This test checks block level letter-spacing when having white-spaces.
22+
</p>
23+
</info>
24+
<fo>
25+
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
26+
<fo:layout-master-set>
27+
<fo:simple-page-master master-name="A4" page-height="297mm" page-width="210mm" margin="20mm">
28+
<fo:region-body/>
29+
</fo:simple-page-master>
30+
</fo:layout-master-set>
31+
<fo:page-sequence master-reference="A4">
32+
<fo:flow flow-name="xsl-region-body">
33+
<fo:block letter-spacing="0.5pt" white-space="pre">A A A A A A A A x<fo:inline font-size="70%" vertical-align="top">2</fo:inline></fo:block>
34+
<fo:block letter-spacing="0.5pt" white-space="pre">A A A A x<fo:inline font-size="70%" vertical-align="top">2</fo:inline></fo:block>
35+
<fo:block letter-spacing="0.5pt" white-space="pre"> x<fo:inline font-size="70%" vertical-align="top">2</fo:inline></fo:block>
36+
</fo:flow>
37+
</fo:page-sequence>
38+
</fo:root>
39+
</fo>
40+
<checks>
41+
<eval expected="105220" xpath="//flow/block[1]/lineArea/text/@ipd"/>
42+
<eval expected="86548" xpath="//flow/block[2]/lineArea/text/@ipd"/>
43+
<eval expected="68376" xpath="//flow/block[3]/lineArea/text/@ipd"/>
44+
</checks>
45+
</testcase>

0 commit comments

Comments
 (0)