asciidoctor / asciidoctor-pdf

:page_with_curl: Asciidoctor PDF: A native PDF converter for AsciiDoc based on Asciidoctor and Prawn, written entirely in Ruby.
https://docs.asciidoctor.org/pdf-converter/latest/
MIT License
1.14k stars 501 forks source link

Font style(bold, italic, bold_italic) does not apply to table titles and headers when using fallback fonts #2423

Closed jayliaoo closed 1 year ago

jayliaoo commented 1 year ago

I'm a user of this repo from China who needs to use English and Chinese in single documents. My theme file is as below:

extends: default-sans
font:
  catalog:
    merge: true
    Noto Sans CN:
      normal: NotoSansSCRegular.ttf
      bold: NotoSansSCBold.ttf
      italic: 江城斜黑体 400W.ttf
      bold_italic: 江城斜黑体 700W.ttf
  fallbacks:
    - Noto Sans CN
    - Noto Emoji

My adoc file is as below:

*粗体中文(Bold Chinese)*

_斜体中文(Italic Chinese)_

*_粗斜体中文(Bold Italic Chinese)_*

.A table with a title 中文
|===
|Column 1, header row 中文

|Cell in column 1, row 2 中文
|===

The output is like this: WX20230522-145011@2x As we can see, Chinese is not italic in the table title and is not bold in the table header.

mojavelinux commented 1 year ago

Your observation is correct. A fallback font is just that, a fallback font. There are no styles for the fallback font. The first font in which the glyph is found is used. The purpose of the fallback font is to catch a missing glyph so at least the character appears in the rendered document. If you want the character to be displayed in the style that you want, then it needs to be in the main font.

If you need further assistance, please ask in the project chat at https://chat.asciidoctor.org.

jayliaoo commented 1 year ago

but it applies to inline bold, italic, and bold_italic text. Here is an example:

*粗体中文(Bold Chinese)*

_斜体中文(Italic Chinese)_

*_粗斜体中文(Bold Italic Chinese)_*

The output is like this: WX20230522-150527@2x They are formatted properly.

mojavelinux commented 1 year ago

It must be the case that it is using a different font in that case that provides those characters (so the fallback font is not used). I assure you that the fallback font will not show up in bold, italic, or bold italic because there is no such font in the distribution.