asciidoctor / asciidoctor-diagram

:left_right_arrow: Asciidoctor diagram extension, with support for AsciiToSVG, BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag), Ditaa, Erd, GraphViz, Mermaid, Msc, PlantUML, Shaape, SvgBob, Syntrax, UMLet, Vega, Vega-Lite and WaveDrom.
http://asciidoctor.org
MIT License
432 stars 106 forks source link

Why text has overlapping characters #392

Closed yuto-katsuragi closed 1 year ago

yuto-katsuragi commented 1 year ago

Probrem

I tried to embed PlantUMLs diagram into pdf, but the text has overlapping characters. It text(カード) is in japanese.

image

Environments

Versions: asciidoctor - 2.0.17 asciidoctor-pdf - 2.3.0 asciidoctor-diagram - 2.2.3

Steps to reproduce

Create 'diagram.adoc'.

:encoding: utf-8
:lang: ja
:scripts: cjk
:pdf-theme: default-with-fallback-font

[plantuml,format=svg]
....
@startuml

card カード

@enduml
....

and 'patch.rb' patch file for prawn-svg.

require 'prawn-svg'

Prawn::Svg::Font::GENERIC_CSS_FONT_MAPPING.merge!(
  'sans-serif' => 'M+ 1p Fallback'
)

then run command following.

$ asciidoctor-pdf diagram.adoc -r asciidoctor-diagram -r ./patch.rb
mojavelinux commented 1 year ago

You seem to have missed this section in the documentation:

https://docs.asciidoctor.org/pdf-converter/latest/image-paths-and-formats/#svg

If you create plantuml.cfg and populate it with the following text:

skinparam defaultFontName M+ 1p Fallback

Then declare it in your document:

:plantumlconfig: plantuml.cfg

I think you'll find it does the right thing. Be sure to clear your cache so that Asciidoctor Diagram recreates the image.

mojavelinux commented 1 year ago

Alternately, you can remap sans-serif in a PDF theme:

font:
  catalog:
    merge: true
    sans-serif: GEM_FONTS_DIR/mplus1p-regular-fallback.ttf
yuto-katsuragi commented 1 year ago

This problem occurred when installing asciidoctor and others with nix-shell. I apologize for the flawed reproduction procedure I wrote. I am going to close this issue.

@mojavelinux Thanks for the documentation and the instructions I had missed.

mojavelinux commented 1 year ago

FYI, I added a test to Asciidoctor PDF to verify that the instructions provided in the docs are correct. See https://github.com/asciidoctor/asciidoctor-pdf/blob/7bd05cbe4c4db016bc30734f532639e3c2abcbd6/spec/diagram_spec.rb#L28-L51