Uploaded image for project: 'FOP'
  1. FOP
  2. FOP-3023

[PATCH] Simulated Bold Errors in Adobe Acrobat

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 2.8
    • None
    • None
    • Patch

    Description

      In some cases, simulated bold text seems to throw an error in Adobe Acrobat. It's been erroring in every Adobe Acrobat version released in what seems like the last year, possibly more.

      The Problem

      For example (version 2021.005.20060; Windows 10.0.19042 Build 19042):

      It's hard to tell exactly why this issue occurs, but it appears to be related to the fact that simulated bold pushes (q) and pops (Q) the graphics state. Furthermore, it appears that this may cause issues only when on the last row of a table.

      You can reproduce the issue by using the following fonts:

      Along with the following FOP configuration file:

       

      <?xml version="1.0" encoding="UTF-8" standalone="no"?>
      <fop version="1.0">
      	<renderers>
      		<renderer mime="application/pdf">
      			<fonts>
      				<font embed-url="file:/C:/Open_Sans/OpenSans-Regular.ttf" kerning="yes" simulate-style="true">
      					<font-triplet name="sans-serif" style="normal" weight="normal"/>
      					<font-triplet name="sans-serif" style="normal" weight="bold"/>
      					<font-triplet name="sans-serif" style="italic" weight="normal"/>
      					<font-triplet name="sans-serif" style="italic" weight="bold"/>
      				</font>
      				<font embed-url="file:/C:/Noto_Sans/NotoSans-Regular.ttf" kerning="yes" simulate-style="true">
      					<font-triplet name="sans-serif2" style="normal" weight="normal"/>
      					<font-triplet name="sans-serif2" style="normal" weight="bold"/>
      					<font-triplet name="sans-serif2" style="italic" weight="normal"/>
      					<font-triplet name="sans-serif2" style="italic" weight="bold"/>
      				</font>
      				<font embed-url="file:/C:/Source_Code_Pro/SourceCodePro-Regular.ttf" kerning="yes" simulate-style="true">
      					<font-triplet name="sans-serif3" style="normal" weight="normal"/>
      					<font-triplet name="sans-serif3" style="normal" weight="bold"/>
      					<font-triplet name="sans-serif3" style="italic" weight="normal"/>
      					<font-triplet name="sans-serif3" style="italic" weight="bold"/>
      				</font>
      			</fonts>
      		</renderer>
      	</renderers>
      </fop>
      

       

      And using this FO file:

      <?xml version="1.0" encoding="UTF-8"?>
      <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
        <fo:layout-master-set>
          <fo:simple-page-master master-name="main-page" margin="0.5in" page-height="11.0in" page-width="8.5in">
            <fo:region-body margin-bottom="0.25in + 1mm" margin-top="0.70in + 1mm"/>
            <fo:region-before extent="0.70in"/>
            <fo:region-after extent="0.25in"/>
          </fo:simple-page-master>
        </fo:layout-master-set>
        <fo:page-sequence master-reference="main-page">
          <fo:flow flow-name="xsl-region-body">
            <fo:table table-layout="fixed" width="100%" font-size="10pt" font-family="sans-serif">
              <fo:table-column column-width="proportional-column-width(1)"/>
              <fo:table-column column-width="proportional-column-width(1)"/>
              <fo:table-header>
                <fo:table-row>
                  <fo:table-cell border="0.3mm solid #dddddd" padding="0.5mm" background-color="#eeeeee">
                    <fo:block>
                      <fo:inline font-weight="bold">Patient Name:</fo:inline> Moser, Nicholas</fo:block>
                  </fo:table-cell>
                  <fo:table-cell border="0.3mm solid #dddddd" padding="0.5mm" background-color="#eeeeee">
                    <fo:block>
                      <fo:inline font-weight="bold">Request Date/Time:</fo:inline> 8/11/2021 18:02 CDT</fo:block>
                  </fo:table-cell>
                </fo:table-row>
              </fo:table-header>
              <fo:table-body>
                <fo:table-row>
                  <fo:table-cell border="0.3mm solid #dddddd" padding="0.5mm" number-columns-spanned="2">
                    <fo:block>
                      <fo:inline font-weight="bold">Requesting Person:</fo:inline> Moser, Nicholas</fo:block>
                  </fo:table-cell>
                </fo:table-row>
                <fo:table-row>
                  <fo:table-cell border="0.3mm solid #dddddd" padding="0.5mm" number-columns-spanned="2" font-style="italic">
                    <fo:block>Release Details</fo:block>
                  </fo:table-cell>
                </fo:table-row>
                <fo:table-row>
                  <fo:table-cell border="0.3mm solid #dddddd" padding="0.5mm" number-columns-spanned="2">
                    <fo:block>
                      <fo:inline font-weight="bold">Comments:</fo:inline>
                    </fo:block>
                  </fo:table-cell>
                </fo:table-row>
              </fo:table-body>
            </fo:table>
          </fo:flow>
        </fo:page-sequence>
      </fo:root>
      

      Replace font-family="sans-serif" with font-family="sans-serif2" or font-family="sans-serif3" to test the two other fonts.

      Proposed Solution

      The actual solution here should be reaching out to Adobe to figure out why only their PDF reader seems to throw this error. I don't see the error when using Firefox, Chrome, or Foxit to view the PDF.

      With that being said, I've found a code change that seems to remove the error while maintaining the simulated styling.

      fix.patch

      Basically, instead of pushing and popping the graphics state before simulating bold, just reset the text rendering mode to 0 when done simulating bold text. I've done quite a bit of testing, and this seems to work fine. Curious to hear from others if there are any issues with this change.

      Here are some examples of before the change and after the change:

      OpenSans-before.pdf

      OpenSans-after.pdf

      NotoSans-before.pdf

      NotoSans-after.pdf

      SourceCodePro-before.pdf

      SourceCodePro-after.pdf

       

      Attachments

        1. NotoSans-before.pdf
          13 kB
          Nicholas Moser
        2. OpenSans-before.pdf
          12 kB
          Nicholas Moser
        3. NotoSans-after.pdf
          13 kB
          Nicholas Moser
        4. OpenSans-after.pdf
          12 kB
          Nicholas Moser
        5. SourceCodePro-after.pdf
          12 kB
          Nicholas Moser
        6. SourceCodePro-before.pdf
          12 kB
          Nicholas Moser
        7. fix.patch
          2 kB
          Nicholas Moser
        8. image-2021-08-12-10-10-13-731.png
          37 kB
          Nicholas Moser

        Activity

          People

            ssteiner Simon Steiner
            NicholasMoser Nicholas Moser
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: