PLEASE USE NEW VERSION https://github.com/life888888/asciidocfx-pdf-fop-cjk-patch
Display of Chinese, Japanese, and Korean characters in AsciidocFX exported PDF and automatic setting of Bold Italic Italic Bold Bold Italic.
Asciidoc FX PDF CJK Patch is to set the font and style settings of CJK (Chinese, Japanese, Korean) that display as #
when CJK text cannot be displayed when Asciidoc FX produces PDF. To avoid the common problem of AsciidocFX outputting PDF, Chinese characters are not displayed normally. After executing this Asciidoc FX PDF CJK Patch, AsciidocFX should be able to generate PDFs with Chinese characters normally.
If you use AsciidocFX 1.7.6+ and want to use ASCIIDOCTOR instead to generate PDF, you can refer to https://github.com/life888888/asciidoctor-pdf-cjk-ext#asciidocfx
The following is translated from Chinese to English using Google Translate.
-
Automatically download fonts
-
Automatic settings font and style settings
-
supports italics
-
support italic bold
Please go to Release to download
-
asciidocfx-pdf-cjk-patch-all.zip (TW , CN , JP , KR all in one)
Important
|
Important
|
After unpacking asciidocfx-pdf-cjk-patch-all.zip , copy the src
directory contents to your AsciidocFX directory.
The directory structure is as follows: Please make sure the location is correct
AsciidocFX
|-- AsciidocFX
|-- AsciidocFX.vmoptions
|-- pdf-cjk-patch-TW.sh <- Add
|-- pdf-cjk-patch-CN.sh <- Add
|-- pdf-cjk-patch-JP.sh <- Add
|-- pdf-cjk-patch-KR.sh <- Add
`-- pdf-cjk-patch (Directory) <- Add
Please choose one of the following according to your needs:
Please replace /yourPath/AscidocFX
with the actual installation path of your AsciidocFX
cd /yourPath/AsciidocFX
./pdf-cjk-patch-TW.sh
cd /yourPath/AsciidocFX
./pdf-cjk-patch-CN.sh
cd /yourPath/AsciidocFX
./pdf-cjk-patch-JP.sh
cd /yourPath/AsciidocFX
./pdf-cjk-patch-KR.sh
AsciidocFX
|-- conf
|-- docbook-config
│ |-- fo-pdf.xsl (modified)
│ |-- fo-pdf.xsl.org (Copy backup original file: fo-pdf.xsl )
│ |-- fop.xconf.xml (modified)
│ `-- fop.xconf.xml.org (Copy backup original file: fop.xconf.xml)
`-- fonts
`-- KaiGenGothic (create)
|-- KaiGenGothicXX-Bold-Italic.ttf (Download)
|-- KaiGenGothicXX-Bold-Italic.xml (Copy)
|-- KaiGenGothicXX-Bold.ttf (Download)
|-- KaiGenGothicXX-Bold.xml (Copy)
|-- KaiGenGothicXX-Regular-Italic.ttf (Download)
|-- KaiGenGothicXX-Regular-Italic.xml (Copy)
|-- KaiGenGothicXX-Regular.ttf (Download)
`-- KaiGenGothicXX-Regular.xml (Copy)
Where XX should be your own language such as TW , CN , JP , KR
Warning
|
WARNING
The modification is completed, in order to avoid some problems, please delete the AsciidocFX setting directory in your home directory first.
|
The project provides some files for testing. After you complete the settings, you can test it immediately.
Execute AsciidocFX. Open the AsciidocFX/pdf-cjk-patch/testdoc directory:
Select the corresponding test file:
-
PDF-CJK-TEST_TW.adoc - Used to test Traditional Chinese
-
PDF-CJK-TEST_CN.adoc - Used to test Simplified Chinese
-
PDF-CJK-TEST_JP.adoc - Used to test Japanese (this is produced by Google Translate)
-
PDF-CJK-TEST_KR.adoc - No, because I didn’t do it.
If the setting is successful, your PDF will see Chinese(or your language), and there are bold, italic, italic bold Chinese.
-
❏ Whether all Chineseor your language fonts are displayed.
-
❏ Whether the general font is displayed normally?
-
❏ Whether the bold font is displayed normally?
-
❏ Whether italic fonts are displayed normally?
-
❏ Is italic bold font displayed normally?
-
❏ Whether the second-level title, the third-level title, and the fourth-level title are officially displayed?
-
❏ Open the PDF, click Properties, check the font, and see if the embedded font name corresponds to the CJK font you set. ( KaiGenGothicXX , KaiGenGothicXX-Bold , KaiGenGothicXX-BoldItalic , KaiGenGothicXX-Italic )
AsciidocFX/conf/docbook-config has backups of original configuration files ( fo-pdf.xsl.org and fop.xconf.xml.org)
-
Please overwrite fo-pdf.xsl with fo-pdf.xsl.org
-
Please overwrite fop.xconf.xml with fop.xconf.xml.org
Warning
|
WARNING
After the modification is completed, in order to avoid some problems, please delete the AsciidocFX setting directory in your home directory first.
|
AsciidocFX - PDF CJK Patch using Linux shell script
Related Linux programs:
-
wget
-
md5sum
-
patch
Fonts:
-
KaiGen Gothic 懷源黑體 https://github.com/chloerei/asciidoctor-pdf-cjk-kai_gen_gothic
Q: If not Asciidoc FX 1.7.4 will it also work?
-
I have only tested .sh automation on Asciidoc FX 1.7.4 / 1.6.0
-
Other versions may also be able to apply .sh automation
-
Depends on whether the content of
fop.xconf.xml
andfo-pdf.xsl
inAscidocFX/conf/docbook-config/
is consistent with the content of 1.7.4.
-
-
If other versions can’t automate apply, but you can still manually modify the settings file.
Q: Why use this KaiGen Gothic font?
-
Since Asciidoctor PDF - CJK also uses , there should be no licensing issues.
-
In addition, it is currently Open Source that provides italic, italic bold CJK fonts.
Q: Can I use another font?
-
Other ttf and ttc fonts can be used, but are not provided in this project.
-
However, if there is no italic, the corresponding font of italic bold will cause the text that should be displayed in italic and italic bold when generating PDF, and will be displayed in the normal style.
Q: Starting from AsciidocFX 1.7.6, with this modification, the output of Chinese PDF fails again?
Because starting from AsciidocFX 1.7.6, its default pdf output is set using the asciidoctor-pdf module.
So we have to manually modulate the settings to use the fop module settings for the original old version.
If you want to continue using FOP to generate PDF.
① Please click on the right tab Settings
② Then click on the upper tab PDF Settings
③ Click the drop-down menu in PDF Converter
or PDF Engine
Drop-down menu, click on the FOP
option
Click Done and click Save
. Then click Load
.
On AsciidocFX, the problem that Chinese characters in PDF cannot be displayed:
-
Chinese characters cannot be displayed and become
#
.
The easiest setting is to add fonts.
AsciidocFX/conf/docbook-config/fop-config.xml
<fonts>
<directory>C:\Windows\Fonts</directory>
<auto-detect/>
</fonts>
You may find that AsciidocFX may be able to produce PDFs containing Chinese characters.
But the next problem occurs:
-
It still cannot be displayed properly when encountering a third-level title or setting text with italics
The third-level title cannot display Chinese normally and the italic font setting text cannot display Chinese normally. It is the same problem.
AsciidocFX can’t get the corresponding italic font. Therefore, the parts that need to use italics (such as third-level headings) will not be able to display Chinese properly.
Because general Chinese fonts do not have italic or bold italic fonts,
So to solve this problem:
-
Method 1: Install Chinese fonts, including four styles of fonts (normal, bold, italic, bold italic)
-
Method 2: Modify the settings of AsciidocFX/conf/docbook-config/fop.xconf.xml of AsciidocFX
-
deceive the system, tell the system
-
Italic also uses normal style fonts
-
Bold italic also uses bold font
-
-
Method 2 Advantages: Chinese can be displayed normally. Disadvantage: Italics will only be displayed in normal style, bold italics will only be displayed in bold.
If your file has a special definition for italics, after converting it to PDF through method 2, there will be no italics.