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

How to generate small caps? #1192

Closed aggsol closed 2 years ago

aggsol commented 5 years ago

How can I get small caps into the PDF? For HTML I just added font-variant: small-caps; to the css and I use a custom attribute [.smallcaps]#In small caps#. How can I get small caps in PDF.

mojavelinux commented 5 years ago

Small caps are not possible. You can use text-transform to get uppercase (and now lowercase and capitalize too), but that's the extent of the font variant that Asciidoctor PDF supports.

mojavelinux commented 4 years ago

I would imagine this would require reading information from the font library (ttfunk), which would require support from Prawn.

mojavelinux commented 2 years ago

I now understand that the small caps variant / transformation is actually a glyph replacement. While this can be handled by the font, most text processors do this by replacing lowercase latin letter with the small capital equivalent. For example, a becomes , and so forth. We can easily handle this transformation using the existing text transform mechanism. So we'll take that approach.

Part of this change includes adding all the small capital glyphs we need to the built-in fonts. That way, this transformation can be used out of the box. In doing so, I had to make a few substitutions.

Aside from those exceptions, this works as expected by setting the text-transform key to smallcaps somewhere in the theme.

role:
  smallcaps:
    text-transform: smallcaps
mcp292 commented 2 years ago

Happy to see this was added! Has the mainsite documentation been updated to demonstrate use?

Based on this thread, I have added this to my theme:

role:
  smallcaps:
    text-transform: smallcaps

and try to use it with:

[.smallcaps]#This is a test.#

It does not work.

mojavelinux commented 2 years ago

Yes, it was implemented. If you are having difficulty using the feature, please ask follow-up questions in the project chat at https://chat.asciidoctor.org. Thanks!