CJK support in PDF: state of the art?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

CJK support in PDF: state of the art?

craftyjon
Hi all,

I'm working on a project to move a translated documentation package to
asciidoctor (hi Marco!)

We need PDF output support with CJK characters, and I've hit a dead
end trying to get this to work.

It seems like back in 2015 this was solved by Rei's work on
asciidoctor-pdf-cjk-kai_gen_gothic, but this package is no longer
maintained and the font KaiGen Gothic seems to not be widely available
anymore, so this option seems to not be a good idea.

I assumed that using Noto Serif CJK would be a good path, as this font
family looks good, has an appropriate license, and has lots of
characters supported.

Unfortunately, I have not been able to make it work with
asciidoctor-pdf.  As it seems like people have noted before on other
threads, it causes ttfunk to crash.

I have tried various things suggested in the asciidoctor-pdf
documentation for "repairing" the font in FontForge, however FontForge
seems to have trouble dealing with this font, and none of the steps
suggested in the docs result in a font that ttfunk can use.

So, before I get into the weeds with any of the particulars of getting
Noto Serif to work, I ask the community: is anyone generating PDFs
with CJK characters using anything other than the (now-unsupported)
KaiGen Gothic gem and an openly-licensed font?  If so, can you please
advise which font you used and if you had to do any magic steps to get
ttfunk to accept it?

Best,
Jon
Reply | Threaded
Open this post in threaded view
|

Re: CJK support in PDF: state of the art?

danyill
Have you tried using https://github.com/Mogztter/asciidoctor-web-pdf?
Although this hasn't had a formal release yet (still in alpha), I've had good experience with it. 
More generally the use of web technologies generally will probably allow higher complexity than asciidoctor-pdf supports at present because of the considerable investment for i18n in browsers 

On Mon, Feb 22, 2021 at 3:50 AM craftyjon [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi all,

I'm working on a project to move a translated documentation package to
asciidoctor (hi Marco!)

We need PDF output support with CJK characters, and I've hit a dead
end trying to get this to work.

It seems like back in 2015 this was solved by Rei's work on
asciidoctor-pdf-cjk-kai_gen_gothic, but this package is no longer
maintained and the font KaiGen Gothic seems to not be widely available
anymore, so this option seems to not be a good idea.

I assumed that using Noto Serif CJK would be a good path, as this font
family looks good, has an appropriate license, and has lots of
characters supported.

Unfortunately, I have not been able to make it work with
asciidoctor-pdf.  As it seems like people have noted before on other
threads, it causes ttfunk to crash.

I have tried various things suggested in the asciidoctor-pdf
documentation for "repairing" the font in FontForge, however FontForge
seems to have trouble dealing with this font, and none of the steps
suggested in the docs result in a font that ttfunk can use.

So, before I get into the weeds with any of the particulars of getting
Noto Serif to work, I ask the community: is anyone generating PDFs
with CJK characters using anything other than the (now-unsupported)
KaiGen Gothic gem and an openly-licensed font?  If so, can you please
advise which font you used and if you had to do any magic steps to get
ttfunk to accept it?

Best,
Jon



If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/CJK-support-in-PDF-state-of-the-art-tp8529.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--

--
Private or confidential message? Public Key available here

Reply | Threaded
Open this post in threaded view
|

Re: CJK support in PDF: state of the art?

Alexander Schwartz
In reply to this post by craftyjon
That question came up related to the IntelliJ AsciiDoc plugin. I summarized some of it in the users manual here: https://intellij-asciidoc-plugin.ahus1.de/docs/users-guide/features/advanced/pdf-non-latin-languages.html

My understanding is that you need asciidoctor-pdf, TTF fonts placed in the right folder and a theme. I am not sure about the current state of OTF support.

The KaiGen Gothic fonts are available here: https://github.com/minjiex/kaigen-gothic/tree/master/dist/CN.

I can't read/write Chinese, but AFAIK the solution worked for diguage. See the link above for a working example.

A search on GitHub revealed some alternative Source Han Sans ready-build TTF fonts here: https://github.com/be5invis/source-han-sans-ttf



 
Alexander Schwartz (alexander.schwartz@gmx.net)
https://www.ahus1.de
Reply | Threaded
Open this post in threaded view
|

Re: CJK support in PDF: state of the art?

mojavelinux
Administrator
In reply to this post by craftyjon
Jon,

Asciidoctor PDF does have support for CJK languages. Many of the discussions you cited about problems with it are outdated.

The instructions for how to get the full range of support for CJK can be found in the README here: https://github.com/asciidoctor/asciidoctor-pdf#support-for-non-latin-languages, with specific steps listed here: https://github.com/asciidoctor/asciidoctor-pdf#create-a-custom-cjk-theme. If you run into problems following those steps, please report an issue and we'll fix it.

The asciidoctor-pdf-cjk-kai_gen_gothic itself is still relevant. Though all it does is download the fonts to your system. You can download the fonts anyway you choose.

I also second @danyill's point about considering Asciidoctor Web PDF. The browser normalizes nearly all the complexities of dealing with fonts, so being able to leverage that platform makes life a whole lot simpler.

Best Regards,

-Dan

--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: CJK support in PDF: state of the art?

mojavelinux
Administrator
In reply to this post by Alexander Schwartz
Alexander,

This is great information. I'd really like to keep it centralized. Would you consider submitting an update to the Asciidoctor PDF README that includes your approach, possibly replacing the one already there if you think it is going to guarantee success?

Best Regards,

-Dan

--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: CJK support in PDF: state of the art?

mojavelinux
Administrator
In reply to this post by Alexander Schwartz

Keep in mind that you don't need to redeclare any of the bundled fonts. Instead, you can configure the font catalog to merge the additional entries.

extends: default
font:
  catalog:
    merge: true
    cjk: YourCJKFontHere.ttf
base:
  font_family: cjk

Best Regards,

-Dan

--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: CJK support in PDF: state of the art?

mojavelinux
Administrator
In reply to this post by craftyjon
I forgot to say, I always start by recommending trying the built-in fallback font. It doesn't have the full range of simplified Chinese characters, but it does cover a good portion of them for occasional references.

asciidoctor-pdf -a pdf-theme=default-with-fallback-font doc.adoc

Best Regards,

-Dan

--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: CJK support in PDF: state of the art?

mojavelinux
Administrator
In reply to this post by craftyjon
> Unfortunately, I have not been able to make it work with
asciidoctor-pdf.  As it seems like people have noted before on other
threads, it causes ttfunk to crash.

You're correct that although Asciidoctor PDF now supports OTF (in the mainline branch), the Noto CJK font still does not produce the desired result. The text in the document ends up being blank. I don't know why this is. Regardless, it's outside the scope of this project. It's best to report that to ttfunk (https://github.com/prawnpdf/ttfunk). In the meantime, I recommend finding another font.

Best Regards,

-Dan

--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: CJK support in PDF: state of the art?

craftyjon
Thanks everyone for the advice.

asciidoctor-web-pdf looks very promising, I was able to install it and
generate documents with no problems.

I think I will pursue that as the first path since it does not depend
on any particular font, and if any problems come up that I can't get
past, go back to the suggestions Dan made to get things working with
ttfunk.

Best,
Jon

On Sun, Feb 21, 2021 at 5:07 PM mojavelinux [via Asciidoctor ::
Discussion] <[hidden email]> wrote:

>
> > Unfortunately, I have not been able to make it work with
> asciidoctor-pdf.  As it seems like people have noted before on other
> threads, it causes ttfunk to crash.
>
> You're correct that although Asciidoctor PDF now supports OTF (in the mainline branch), the Noto CJK font still does not produce the desired result. The text in the document ends up being blank. I don't know why this is. Regardless, it's outside the scope of this project. It's best to report that to ttfunk (https://github.com/prawnpdf/ttfunk). In the meantime, I recommend finding another font.
>
> Best Regards,
>
> -Dan
>
> --
> Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion below:
> https://discuss.asciidoctor.org/CJK-support-in-PDF-state-of-the-art-tp8529p8536.html
> To start a new topic under Asciidoctor :: Discussion, email [hidden email]
> To unsubscribe from Asciidoctor :: Discussion, click here.
> NAML
Reply | Threaded
Open this post in threaded view
|

Re: CJK support in PDF: state of the art?

mojavelinux
Administrator
Glad we got you moving, Jon,

Keep in mind that Asciidoctor Web PDF does depend on a particular font. You just get to leverage the browser for finding it ;)

Best Regards,

-Dan


--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux