emojiasciidoctor-pdf

asciidoc-pdf doesnt convert emojis in code blocks


i write a text with asciidoc and when i convert with asciidoc-pdf it doesnt convert the emojis from this code block:

[source,java]
----
  public static void lines() {
    System.out.print("♥♥♥♥♥♥♥♥♥♥");
  }
----

the result in the pdf looks like this:

public static void lines() {
System.out.print("¬¬¬¬¬¬¬¬¬¬");
}

And yes i use a custom theme and set a fallback font too. Here is the yaml theme file:

font:
  catalog:
    PTSerif:
      normal: PTSerif-Regular.ttf
      italic: PTSerif-Italic.ttf
      bold: PTSerif-Bold.ttf
      bold_italic: PTSerif-BoldItalic.ttf
    EmojiFallback: 
      normal: EmojiFallback.ttf
      italic: EmojiFallback.ttf
      bold: EmojiFallback.ttf
      bold_italic: EmojiFallback.ttf
  fallbacks:
  - EmojiFallback
base:
  font-family: PTSerif

I hope you can help me. I am grateful for any help


Solution

  • After a long time i found someone who helped me. And give me these ways to fix it.

    The simplest way is to extend the default theme and merging in your additions to the font catalog:

    extends: default
    font:
      catalog:
        merge: true
        PTSerif:
          normal: PTSerif-Regular.ttf
          italic: PTSerif-Italic.ttf
          bold: PTSerif-Bold.ttf
          bold_italic: PTSerif-BoldItalic.ttf
        EmojiFallback: EmojiFallback.ttf
      fallbacks:
      - EmojiFallback
    base:
      font-family: PTSerif
    

    Instead of extending the default theme, you could configure the code blocks to use a TTF monospace font:

    font:
      catalog:
        PTSerif:
          normal: PTSerif-Regular.ttf
          italic: PTSerif-Italic.ttf
          bold: PTSerif-Bold.ttf
          bold_italic: PTSerif-BoldItalic.ttf
        PTMono:
          normal: PTMono-Regular.ttf
          italic: PTMono-Italic.ttf
          bold: PTMono-Bold.ttf
          bold_italic: PTMono-BoldItalic.ttf
        EmojiFallback: EmojiFallback.ttf
      fallbacks:
      - EmojiFallback
    base:
      font-family: PTSerif
    code:
      font-family: PTMono
    

    Finally, Asciidoctor PDF now provides an emoji font, which is configured in the default-with-fallback-font theme. So you could extend that theme instead:

    extends: default-with-fallback-font
    font:
      catalog:
        merge: true
        PTSerif:
          normal: PTSerif-Regular.ttf
          italic: PTSerif-Italic.ttf
          bold: PTSerif-Bold.ttf
          bold_italic: PTSerif-BoldItalic.ttf
      fallbacks: [M+ 1p Fallback, Noto Emoji]
    base:
      font-family: PTSerif