There are three digraphs in Croatian language (as in many others): dž, lj and nj. Common way of typesetting does not include usage of dedicated Unicode codepoints (which exist) - people just type them as two characters.

Assuming that font contains dedicated symbols, what would be the right way to e.g. render (two characters in source) as "dž" (single character in output)? Maybe babel/polyglossia? Is there any example of such?

Can a "fallback" to "dž" (two characters in output) be also supported in case that font does not contain dedicated symbols?

Edit 1 Thanks for the ligatures variant! This is the idea which I want to accomplish (pdflatex variant):

\usepackage{lmodern} % I know that my font has appropriate Unicode slots for digraphs...
\languageattribute{croatian}{unicodedigraphs} % ...so I will explicitly load something implemented in babel's Croatian definition file...

dž % ...and these consecutive characters will be automatically rendered as U+01C6

Can something like that be achieved? Is using and enhancing babel (pdflatex) and polyglossia (xelatex) the right approach?

Edit 2 I thought of implementing something with catcodes... Let me get back once I make progress on that.

  • 1
    With an OpenType font? It’s hard to say without knowing how the font is designed. Usually, the source should contain the individual characters, while the font’s features supply the ligature in the output (as one usually enters ‘f’ and ‘i’ in the source but gets ‘fi’ in the output). You may need to turn on discretionary ligatures or localizations, depending on the font. – Thérèse Oct 25 '17 at 9:51
  • What are the codepoints? – Thérèse Oct 25 '17 at 10:05
  • @Thérèse, I used the phrasing as Wikipedia did. Nothing special, "Unicode slots" actually. – ivankokan Oct 25 '17 at 10:21
  • OK, found them. U+01C4 and following. Agmena is a typeface that offers this as a discretionary ligature (you’d enter the components separately in your source). But I don’t think a perfectly general answer is possible, because font designers may use features differently to achieve similar results. – Thérèse Oct 25 '17 at 10:35
  • I am more interested in using Unicode slot than in ligatures, though. – ivankokan Oct 25 '17 at 11:37

Many fonts do not contain these digraphs, with the result that entering them manually in your source may lead to a PDF file with missing glyphs.

Most fonts containing the digraphs seem to replace the components with the digraphs through the liga feature (on by default), or the calt feature (on by default in xetex; be sure to turn it on in luatex), or sometimes the dlig feature (not on by default).

If you have a font which contains the digraph but provides no obvious means to use it, and if you are using luatex, you can create a feature or add to an existing feature. I haven’t yet found a freely available font which illustrates exactly the case you have in mind, but here’s the dz digraph (U+02a3) in Heuristica.

If you do nothing, you get the components or the digraph you type in your source:

dz ʣ

output of above example

Now let’s add “dz” to the default ligatures:

    name = "liga",
    type = "ligature",
    data = {
      ʣ = { "d", "z" },

output of second example

There’s the unicode glyph you want in the output, but you no longer have to enter it directly in the source. And if you want to change to a font that doesn’t have the glyph, all you need to do is delete the call to \directlua and adjust the invocation of \setmainfont (whereas if you had typed digraphs directly in your source, you would need to search for them throughout the document and replace them with their components).

The only time I type digraphs directly into my source is when the language in question sometimes requires the component characters to remain separate (e.g., in French, where some words require “œ” and others require “oe”).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.