Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.5
-
None
Description
Hello, it is found in Fop 2.5 that after adding the bold configuration (simulate-style=true), the color of the Chinese font of word to pdf turns to black.
docx xml:
<?xml version="1.0" encoding="utf-8"?>
<fo:root
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
<layout-master-set
xmlns="http://www.w3.org/1999/XSL/Format"
xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"
xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml"
xmlns:w16="http://schemas.microsoft.com/office/word/2018/wordml"
xmlns:w16cex="http://schemas.microsoft.com/office/word/2018/wordml/cex"
xmlns:w16cid="http://schemas.microsoft.com/office/word/2016/wordml/cid"
xmlns:w16sdtdh="http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash"
xmlns:w16se="http://schemas.microsoft.com/office/word/2015/wordml/symex"
xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing">
<simple-page-master margin-bottom="17mm" margin-left="1.25in" margin-right="1.25in" margin-top="15mm" master-name="s1-simple" page-height="297mm" page-width="210mm">
<region-body column-count="1" column-gap="0.3in" margin-bottom="22.0pt" margin-left="0mm" margin-right="0mm" margin-top="29.0pt"/>
<region-before extent="0.0pt" region-name="xsl-region-before-simple"/>
<region-after extent="0.0pt" region-name="xsl-region-after-simple"/>
</simple-page-master>
<page-sequence-master master-name="s1">
<repeatable-page-master-alternatives>
<conditional-page-master-reference master-reference="s1-simple"/>
</repeatable-page-master-alternatives>
</page-sequence-master>
</layout-master-set>
<fo:page-sequence force-page-count="no-force" id="section_s1" format="" master-reference="s1">
<fo:static-content flow-name="xsl-footnote-separator">
<fo:block>
<fo:leader rule-thickness="0.5pt" rule-style="solid" leader-length="100%" leader-pattern="rule"/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block break-before="auto" font-size="26.0pt" text-align="center">
<inline
xmlns="http://www.w3.org/1999/XSL/Format" font-size="26.0pt" font-weight="bold">
<inline font-family="STFangsong">测试颜色 </inline>
</inline>
<inline
xmlns="http://www.w3.org/1999/XSL/Format" color="#FF0000" font-size="26.0pt" font-weight="bold">
<inline font-family="STFangsong">测试颜色</inline>
</inline>
</fo:block>
possible problems:
it was found that possible problems appeared here org.apache.fop.render.pdf.PDFPainter
private void drawTextWithDX(int x, int y, String text, FontTriplet triplet,
int letterSpacing, int wordSpacing, int[] dx) throws IFException {
.......
boolean simulateStyle = tf instanceof CustomFont && ((CustomFont) tf).getSimulateStyle();
if (simulateStyle) {
if (triplet.getWeight() == 700) {
generator.add("q\n");
// possible problems appeared here,after the change
float[] comps1 = state.getTextColor().getComponents((float[])null);
generator.add(comps1[0]" "+comps1[1]" "comps1[2]" RG\n");
generator.add("2 Tr 0.31543 w\n");
}
......
}
test docx: pr.docx