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

add support for ligatures #2543

Closed mark-summerfield closed 2 hours ago

mark-summerfield commented 3 hours ago

asciidoctor-pdf already supports a number of Text Replacements, e.g., => to .

I think it would be helpful to add ligatures so that the following substitutions are done automatically (except as noted below). Replace ff, fi, fl, ffi, ffl, with their corresponding ligatures ff, fi, fl, ffi, ffl.

But do not do any such replacements inside any of:

<<cross-refs>>
((index terms))
`code`
``code``
#id_names
:items (e.g., include:filename.txt[])
nor within listing, literal, or indented blocks
mojavelinux commented 2 hours ago

This feature is out of scope for this project. It's something that should instead be handled by the font library. You are free to use an extended converter if you want to add something like this, or you can look into what it would take for the font library to support this directly.

mark-summerfield commented 2 hours ago

The reason I think it belongs in asccidoctor-pdf is because surely a font library can only mechanically replace each, say, fl with fl, but cannot distinguish when this should—or should not—be done.

For example, how can a font library know that

The file's name is `filename.txt`.

should become:

The file’s name is `filename.txt`.

i.e., the first "fi" should be converted to a ligature, but not the second?

mojavelinux commented 2 hours ago

I'm sorry, but it's just out of scope given the current state of this project. We aren't adding any more features to Asciidoctor PDF unless they are absolutely essential. You're welcome to use an Asciidoctor extension or extended converter to accomplish this, which is very much possible.

mark-summerfield commented 2 hours ago

I wrote a program that I run over my *.adoc files which pretty well does it, so I'll keep using that. Thanks.

mojavelinux commented 1 hour ago

If you'd like to discuss other ideas, or how to use an extension to do the replacement contextually, I'm always open to have a conversation in the chat.