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 500 forks source link

List markers are wrongly positioned with default-with-fallback-font #2540

Closed wrandelshofer closed 3 weeks ago

wrandelshofer commented 3 weeks ago

I use a theme that extends from default-with-fallback-font. The theme uses a TrueType font, for example Arial.ttf (but the problem occurs with other fonts too). When my document contains list items with anchors, then the list markers (numbers and bullet points) are offset vertically.

I noticed, that the problem does not occur, when the theme extends from default. However, I need fallback fonts, because my documents contain characters that are not in the TrueType font.

Here is my theme.yml file:

extends: default-with-font-fallbacks

base:
  font-family: Arial

font:
  catalog:
    merge: true
    Arial:
      normal: ./Arial.ttf
      bold: ./Arial Bold.ttf
      italic: ./Arial Italic.ttf
      bold_italic: ./Arial Bold Italic.ttf

Here is may document.adoc file:

:pdf-theme: ./theme.yml
:pdf-fontsdir: /System/Library/Fonts/Supplemental

==== List items with anchors

List items have vertically shifted markers when
the theme extends `default-with-font-fallbacks`.

List items have properly placed markers when
the theme extends `default`.

An ordered list:

. [[A1]]First list item
. [[A2]]Second list item
.. [[A3]]First Sub Item
.. [[A4]]Second Sub Item
... [[A5]]First Sub-Sub Item
... [[A6]]Second Sub-Sub Item

An unordered list:

* [[B1]]First list item
* [[B2]]Second list item
** [[B3]]First Sub Item
** [[B4]]Second Sub Item

==== List items without anchors

List items without anchors always have properly placed markers.

An ordered list:

. First list item
. Second list item
.. First Sub Item
.. Second Sub Item
... First Sub-Sub Item
... Second Sub-Sub Item

An unordered list:

* First list item
* Second list item
** First Sub Item
** Second Sub Item

I am generating the PDF with the following commands:

% gem which asciidoctor-pdf        
/usr/local/lib/ruby/gems/3.3.0/gems/asciidoctor-pdf-2.3.18/lib/asciidoctor-pdf.rb
% asciidoctor-pdf document.adoc    

Screenshot of the generated document.pdf file. Notice the marker placement (numbers and bullets):

document-pdf
mojavelinux commented 3 weeks ago

When using a custom theme and font, you must use the line-height property on the marker to position it. There is no other way to ensure the marker is positioned where you expect it as there is no universal definition for the middle of a line (particularly in Prawn).

If you need assistance customizing your theme, please ask in the project chat at https://chat.asciidoctor.org. The issue tracker is not a support forum.