I created a .map
file for Cyrillic to Latin transliteration as in using xetex for automatic transliteration of Cyrillic letters
I placed the cyrillic-to-latin.tec
file in the folder.
\documentclass{article}
\usepackage{fontspec}
\usepackage{ifluatex,ifxetex}
\setmainfont[Mapping=cyrillic-to-latin]{texgyreadventor-regular.otf}
\begin{document}
\ifxetex
This is XeTeX
\else\ifluatex
This is LuaTeX
\fi\fi
Hello, world
Здравствуй, Мир
\end{document}
The thing works perfectly running XeLaTeX, but the mapping system is simply ignored by LuaLaTeX.
How to force LuaLaTeX in using the desired font mapping?
Note: as @Michal.h21 asks, I put the .map file I personally use for transliteration with italian rules:
; TECkit mapping for TeX input conventions <-> Unicode characters
LHSName "Cyrillic-to-Latin"
RHSName "UNICODE"
pass(Unicode)
; ligatures from Knuth's original CMR fonts
U+002D U+002D <> U+2013 ; -- -> en dash
U+002D U+002D U+002D <> U+2014 ; --- -> em dash
U+0027 <> U+2019 ; ' -> right single quote
U+0027 U+0027 <> U+201D ; '' -> right double quote
U+0022 > U+201D ; " -> right double quote
U+0060 <> U+2018 ; ` -> left single quote
U+0060 U+0060 <> U+201C ; `` -> left double quote
U+0021 U+0060 <> U+00A1 ; !` -> inverted exclam
U+003F U+0060 <> U+00BF ; ?` -> inverted question
; additions supported in T1 encoding
U+002C U+002C <> U+201E ; ,, -> DOUBLE LOW-9 QUOTATION MARK
U+003C U+003C <> U+00AB ; << -> LEFT POINTING GUILLEMET
U+003E U+003E <> U+00BB ; >> -> RIGHT POINTING GUILLEMET
U+0410 <> U+0041 ; A
U+0411 <> U+0042 ; B
U+0412 <> U+0056 ; V
U+0413 <> U+0047 ; G
U+0414 <> U+0044 ; D
U+0415 <> U+0045 ; E
U+0416 <> U+017D ; Ž
U+0417 <> U+005A ; Z
U+0418 <> U+0049 ; I
U+041A <> U+004B ; K
U+041B <> U+004C ; L
U+041C <> U+004D ; M
U+041D <> U+004E ; N
U+041E <> U+004F ; O
U+041F <> U+0050 ; P
U+0420 <> U+0052 ; R
U+0421 <> U+0053 ; S
U+0422 <> U+0054 ; T
U+0423 <> U+0055 ; U
U+0424 <> U+0046 ; F
U+0426 <> U+0043 ; C
U+0427 <> U+010C ; Č
U+0428 <> U+0160 ; Š
U+042D <> U+0116 ; Ė
U+042E <> U+004A U+0075 ; Ju
U+042F <> U+004A U+0061 ; Ja
U+0401 <> U+00CB ; Ë
U+0430 <> U+0061 ; a
U+0431 <> U+0062 ; b
U+0432 <> U+0076 ; v
U+0433 <> U+0067 ; g
U+0434 <> U+0064 ; d
U+0435 <> U+0065 ; e
U+0436 <> U+017E ; ž
U+0437 <> U+007A ; z
U+0438 <> U+0069 ; i
U+0439 <> U+006A ; j
U+043A <> U+006B ; k
U+043B <> U+006C ; l
U+043C <> U+006D ; m
U+043D <> U+006E ; n
U+043E <> U+006F ; o
U+043F <> U+0070 ; p
U+0440 <> U+0072 ; r
U+0441 <> U+0073 ; s
U+0442 <> U+0074 ; t
U+0443 <> U+0075 ; u
U+0444 <> U+0066 ; f
U+0446 <> U+0063 ; c
U+0447 <> U+010D ; č
U+0448 <> U+0161 ; š
U+044D <> U+0117 ; ė
U+044E <> U+006A U+0075 ; ju
U+044F <> U+006A U+0061 ; ja
U+0451 <> U+00EB ; ë
U+0456 <> U+0069 ; i
U+0406 <> U+0049 ; I
U+0454 <> U+006A U+0065 ; je
U+0468 <> U+004A U+0065 ; Je
U+0425 <> U+0043 U+0068 ; Ch
U+0445 <> U+0063 U+0068 ; ch
U+0418 <> U+0049 ; I
U+0429 <> U+0160 U+010D ; Šč
U+042A <> U+0027 ; '
U+042B <> U+0059 ; Y
U+042C <> U+2019 ; '
U+0449 <> U+0161 U+010D ; šč
U+044A <> U+2019 ; '
U+044B <> U+0079 ; y
U+044C <> U+2019 ; '
Best Answer
Edit 10/2017
Here is a new version of the Lua script. It generates the code for Luaotfload, instead of the font feature file, which is not supported anymore. It has also new option
--back
, which creates mapping in the opposite direction, like from Cyrillic to Latin in our example.The script is named
maptolua.lua
:It can be executed like:
Which produces a following TeX file:
It can be used in the following way:
(Note that it is necessary to use
RawFeature=+gsub;
in the font declaration)And this is the result:
@edit added support for replacing one glyph with multiple new ones
LuaTeX doesn't support mapping files, but on the other hand it supports OpenType feature files. There is a major difference between the two, the first one works on character level and with unicode values, the other with glyph names.
I've created simple script for converting the map files to
.fea
files,maptofea.lua
:It's help message:
you can just simply use it without any options on a map file:
the converted file
cyrtolatn2.fea
:You have to request the feature file and also
gsub
opentype feature in the document:and this is the result:![]](https://i.stack.imgur.com/wH6aL.png)
Upgrade for the 2016 TeXLive distribution.
The new release does not support the inclusion of a .fea file, making obsolete this method. A workaround can be made by the use of
\directlua
as follows:The features defined above must be called in the usual way.