0

I am trying to paste in a text in Unicode polytonic Greek where there are multiple accents on a single character. As discussed in Multiple diacritics on one character, it is totally feasible to create multiple diacritics on one character with LaTeX, but my problem is slightly different: is there a way, perhaps using Lua, to paste in polytonic Greek pre-composed, and have the correct output be produced? (The alternative is hand recomposing each glyph with two accents, which is quite annoying) I am using Arno, as purchased from Adobe, which should be capable of outputting polytonic Greek, but is failing.

MWE:

\documentclass{standalone}
\usepackage{fontspec}
\setmainfont{Arno Pro}
\begin{document}
 ἐπῐ́λογος
\end{document}

enter image description here

ezgranet
  • 564
  • The combination of breve with an acute accent isn’t a standard requirement in fonts supporting polytonic Greek. – Thérèse Jul 07 '21 at 01:16
  • @Thérèse yes—it's strange, and the "practical" (i.e., easy) answer may be to simply find and replace the characters with double accents out (although that may be a bit annoying because iota with breve and acute is not a precomposed unicode glyph). However, I suspect it may be common enough for people who have to paste Ancient Greek texts glossed and edited by others (my case), that there's some utility in asking – ezgranet Jul 07 '21 at 01:19
  • @Thérèse My instinct, which may be totally off, is to try to write some luacode that will substitute these unusual glyphs with a LaTeX friendly composition stacking as appropriate; no idea if that's the right track, but I'll try it – ezgranet Jul 07 '21 at 01:32
  • 1
    “… iota with breve and acute is not a precomposed unicode glyph” sounds to me like an issue better handled by a font that can do “mark to mark” features. – Ruixi Zhang Jul 07 '21 at 01:34
  • 2
    The issue here isn't about the combination with the breve or the pre composed input. The issue is that the used font "Arno Pro" does not contain a composable acute accent (codepoint U+0301 does not exist). If you use a font which supports this accent (e.g. Noto Serif), then it will work. You should add the [Script=Greek] option after \setmainfont though to get proper handling for greek. – Marcel Krüger Jul 07 '21 at 03:46

1 Answers1

0

This turned out to be relatively easy using code lifted from this answer (Conditional string replacements in LuaLaTeX); just a neat bit of LuaCode renders this working nicely:

\documentclass{standalone}
\DeclareRobustCommand{\combinedaccent}[2]{%
\leavevmode\vbox{\offinterlineskip
    \ialign{\hfil##\hfil\cr
      \char#1\relax\cr
      \noalign{\vskip -1.3ex}
      \noalign{\vskip 0.1ex}
      #2\cr
    }%
  }%
}
\DeclareRobustCommand{\iotafix}{\combinedaccent{180}{ῐ}}   % oxys

\usepackage{luacode} % for '\luaexec' and '\luastringN' macros \luaexec{ % set up Lua function called 'fhg_sub': function iota_sub ( s ) s = s:gsub ( "ῐ́" , "{\iotafix}") return s end } \newcommand\iotaOn{\directlua{luatexbase.add_to_callback( "process_input_buffer", iota_sub, "iota_sub" )}} \usepackage{fontspec} \setmainfont{Arno Pro} \begin{document}\iotaOn ἐπῐ́λογος \end{document}

Produces the beautiful: epilogue

ezgranet
  • 564