3

For some reason the russian letter ё is missing in some fonts, which leads to

warning  (file c:/Users/mishk/OneDrive/Stuff/fonts/PTSerifPro-Regular.otf) (cff
): 'seac' character deprecated in type 2 charstring
! error:  (file c:/Users/mishk/OneDrive/Stuff/fonts/PTSerifPro-Regular.otf) (cf
f): Type2 Charstring Parser: parsing charstring failed: (status=-1, stack=5)
!  ==> Fatal error occurred, no output PDF file produced!

However it is pretty always acceptable to substitute it with the letter е, but this code doesn't work:

\newunicodechar{ё}{\iffontchar\font`ё ё\else{е}\fi}
\newunicodechar{Ё}{\iffontchar\font`Ё Ё\else{Е}\fi}

Can I do the automatic substitution without declaring ё to be an active character?

Full LuaLaTeX MWE:

\documentclass{book}

\usepackage{polyglossia}

\usepackage{newunicodechar}

\setmainlanguage{russian}

\newcommand{\MyPath}{C:/Users/mishk/OneDrive/Stuff/fonts/}


\newfontfamily{\cyrillicfont}{PTSerifPro}[
    Path            =   \MyPath,
    Extension       =   .otf,
    UprightFont     =   *-Regular,
]

\newunicodechar{ё}{\iffontchar\font`ё ё\else{е}\fi}
\newunicodechar{Ё}{\iffontchar\font`Ё Ё\else{Е}\fi}

\begin{document}

    ааа еее ёёё

\end{document}
4

1 Answer 1

5

In LuaTeX you can define your own substitution rule as a font feature, see How to adjust font features in LuaTeX?

\documentclass{article}
\usepackage{fontspec}

\directlua{
fonts.handlers.otf.addfeature {
    name = "ediaeresis",
    type = "substitution",
    prepend = true,
    data = {
        ["ё"] = "e",
        ["Ё"] = "Е",
    }
}
}

\setmainfont{PT Serif}[RawFeature=+ediaeresis]

\begin{document}

ё Ё

\end{document}

enter image description here

6
  • Wow this is an amazing feature! Commented Feb 22, 2018 at 1:37
  • I tried using this technique to hunt down the source of a mysterious occurrence of ^D (U+0004) in a document, but it appears not to work for characters in that range. I used luacode* from the luacode package and added ["\x04"] = "X" to the data array, to no avail. So this is all very mysterious. Is this feature documented anywhere? I feel uncomfortable doing cargo cult programming. Commented Mar 1, 2018 at 11:51
  • @HaraldHanche-Olsen It's documented in “Fonts out of ConTeXt”. Commented Mar 1, 2018 at 20:16
  • Ah, thanks. I might not have found that in a million years. Commented Mar 1, 2018 at 21:09
  • @HenriMenke: Its possible to add \fontspec here. Like ["Ё"] = "Е", change to ["Ё"] = "\\fontspec{Free Serif}{Е}",?
    – Balaji
    Commented Nov 2, 2020 at 16:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .