asciidocfx / AsciidocFX

Asciidoc Editor and Toolchain written with JavaFX 21 (Build PDF, Epub, Mobi and HTML books, documents and slides)
http://www.asciidocfx.com/
Apache License 2.0
1.88k stars 295 forks source link

How to export PDF with chinese fonts #512

Closed tbs575 closed 3 years ago

tbs575 commented 3 years ago

I using asciidocFX v1.7.3 on windows 7, can not export PDF with chinese character. chinese character became #### in PDF.

rahmanusta commented 3 years ago

Hi, probably to setup correct fonts for chinese characters. You can see font selections in https://github.com/asciidocfx/AsciidocFX/blob/master/conf/docbook-config/fo-pdf.xsl . You may need to change your local fo-pdf.xsl.

tbs575 commented 3 years ago

thanks, fixed

tbs575 commented 3 years ago

@rahmanusta Hi, as URL add chinese fonts, export PDF OK, but met new issue. Level 3 Section Title chinese can not export correctly. see pic.

modified fo-pdf.xsl


<xsl:template name="pickfont-sans">
    <xsl:text>SimHei,Sans-serif,Arial,Arial Unicode MS,Helvetica,serif,Georgia,Times New Roman</xsl:text>
</xsl:template>

<xsl:template name="pickfont-serif">
    <xsl:text>SimHei,Sans-serif,Arial,Arial Unicode MS,Helvetica,serif,Georgia,Times New Roman</xsl:text>
</xsl:template>

<xsl:template name="pickfont-mono">
    <xsl:text>SimHei,Liberation Mono,Lucida Console,Monaco,Consolas,Courier New,Courier,monospace,Arial Unicode MS,Lucida Sans Unicode</xsl:text>
</xsl:template>

<xsl:template name="pickfont-dingbat">
    <xsl:call-template name="pickfont-sans"/>
</xsl:template>

<xsl:template name="pickfont-symbol">
    <xsl:text>SimHei,Symbol,ZapfDingbats</xsl:text>
</xsl:template>

<xsl:template name="pickfont-math">
    <xsl:text>Liberation Serif,Sans-serif,serif,Times-Roman</xsl:text>
</xsl:template>

in editor is right. image

but error in export PDF image

rahmanusta commented 3 years ago

You can find the solution here https://github.com/asciidocfx/AsciidocFX/issues/287

Index: conf/docbook-config/fo-pdf.xsl
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/conf/docbook-config/fo-pdf.xsl b/conf/docbook-config/fo-pdf.xsl
--- a/conf/docbook-config/fo-pdf.xsl    (revision 07679a892bde5098e7a9b0e94fe832a1456c5846)
+++ b/conf/docbook-config/fo-pdf.xsl    (date 1618985193766)
@@ -854,37 +854,26 @@

     <xsl:attribute-set name="section.title.level1.properties">
         <xsl:attribute name="font-size">12pt</xsl:attribute>
-        <xsl:attribute name="font-weight">bold</xsl:attribute>
     </xsl:attribute-set>

     <xsl:attribute-set name="section.title.level2.properties">
         <xsl:attribute name="font-size">12pt</xsl:attribute>
-        <xsl:attribute name="font-style">italic</xsl:attribute>
-        <xsl:attribute name="font-weight">bold</xsl:attribute>
     </xsl:attribute-set>

     <xsl:attribute-set name="section.title.level3.properties">
         <xsl:attribute name="font-size">12pt</xsl:attribute>
-        <xsl:attribute name="font-style">italic</xsl:attribute>
-        <xsl:attribute name="font-weight">bold</xsl:attribute>
     </xsl:attribute-set>

     <xsl:attribute-set name="section.title.level4.properties">
         <xsl:attribute name="font-size">12pt</xsl:attribute>
-        <xsl:attribute name="font-style">italic</xsl:attribute>
-        <xsl:attribute name="font-weight">bold</xsl:attribute>
     </xsl:attribute-set>

     <xsl:attribute-set name="section.title.level5.properties">
         <xsl:attribute name="font-size">12pt</xsl:attribute>
-        <xsl:attribute name="font-style">italic</xsl:attribute>
-        <xsl:attribute name="font-weight">bold</xsl:attribute>
     </xsl:attribute-set>

     <xsl:attribute-set name="section.title.level6.properties">
         <xsl:attribute name="font-size">12pt</xsl:attribute>
-        <xsl:attribute name="font-style">italic</xsl:attribute>
-        <xsl:attribute name="font-weight">bold</xsl:attribute>
     </xsl:attribute-set>

     <xsl:attribute-set name="component.title.properties">
tbs575 commented 3 years ago

@rahmanusta thanks your help, but still issue. please see pic. more '#' (red mark), why? image

rahmanusta commented 3 years ago

Hmm, can you please send the letters? I don't know how to type such :)

tbs575 commented 3 years ago

@rahmanusta

= 第一级

== 第二级

=== 第三级

==== 第四级

rahmanusta commented 3 years ago

I don't have this,

do you have there some hidden character ? Could you please share your asciidoc file ?

image

tbs575 commented 3 years ago

@rahmanusta thanks your help, I change chineses font, Using 'Microsoft YaHei', issue gone. I am not sure that is font files issue or more configure with fo-pdf.xsl