docx4j icon indicating copy to clipboard operation
docx4j copied to clipboard

Helvetica Bold font substitution

Open plutext opened this issue 4 years ago • 1 comments

Word substitutes Arial-BoldMT for Helvetica Bold. So we should do the same.

This is "normal" Office on Windows behaviour, coming from a Windows font substitution: see https://office-watch.com/2014/windows-s ... helvetica/ and in the registry Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes

See further https://www.docx4java.org/forums/docx-java-f6/embedded-bold-or-italic-font-problem-t2953.html

When embedded, by Word, Helvetica-bold.ttf (so-named according to the font table part) actually contains Arial-BoldMT.

plutext avatar Dec 06 '20 22:12 plutext

Should be able to address this at the FOP level with an entry in fop-substitutions.xml, something like:

      <substitution>
        <from font-family="Helvetica" font-weight="700..900"/>
        <to font-family="Arial-BoldMT"/>
      </substitution>

See https://github.com/plutext/docx4j/blob/master/docx4j-samples-resources/src/main/resources/fop-substitutions.xml

Remember to enable it in docx4j.properties; uncomment https://github.com/plutext/docx4j/blob/master/docx4j-samples-resources/src/main/resources/docx4j.properties#L136

or perhaps an entry in MicrosoftFonts.xml (not so convenient, since its embedded in docx4j-core.jar)

plutext avatar Dec 07 '20 06:12 plutext