9

I would like to add one char from otf font in xelatex as ligature. 'łł' = 'some char number in font' How make it? How tell for xelatex this char is a ligature of two letter 'ł' and 'ł'

  • This should be done in the font itself, not in LaTeX. I doubt that there is any (easy) way of getting LaTeX to do that for you. I'd recommend just inserting the character whenever you need it, e.g. Ba{\char"XXXX}a, with XXXX pointing to whichever character code this glyph has in your font. – Sverre Dec 16 '14 at 22:13
  • But in this way I must convert my text manualy. I rather would like to TeX make it for me. I write normal text and TeX convert 'łł' into my char. That working 'fi' 'fl' etc. – bardzo Dec 16 '14 at 22:27
  • It works for 'fi' etc. because those ligatures are defined in the fonts. For XeTeX, it is part of the opentype font itself. For (pdf)TeX, it is defined as part of the TeX Font Metrics. If the font licence permits it, you could edit the font, of course. – cfr Dec 16 '14 at 22:57
  • This is trouble, I canot edit font. Is any chance to define it in TeX not in font. Without modyfing font ttf/otf this is not normal ligatures. 'łł' is specyfic and not only this – bardzo Dec 16 '14 at 23:02
  • 1
    With xelatex you can create a mapping file with teckit - the endash ligature is implemented this way. – Ulrike Fischer Dec 16 '14 at 23:24
17

Find on your system the file tex-text.map and copy it in the working directory under the name bardzo.map (or whatever you want). Then append to it a line so that it looks like

; TECkit mapping for TeX input conventions <-> Unicode characters

LHSName "TeX-text"
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

; additions by Bardzo
U+0142 U+0142   <>  U+019C  ; łł -> LATIN CAPITAL LETTER TURNED M

Of course, instead of U+019C you use the code for your chosen character.

Then run

teckit_compile bardzo.map

which will create a file named bardzo.tec. Here is a test file:

\documentclass{article}

\usepackage{fontspec}

\setmainfont{Heuristica}[Mapping=bardzo]

\begin{document}

``This is an exampłe of `łł' that's transformed.''

\end{document}

If the bardzo.tec file is in the same directory, this will be the output

enter image description here

  • in my opinion \setmainfont[Mapping=bardzo]{Heuristica} and add it in any othe font for example \newfontfamily\greekfont[Script=Greek,Mapping=bardzo]{FontName} ... – bardzo Dec 18 '14 at 8:17
  • @bardzo Yes, add it to all the definitions of fonts where you need the new ligature. – egreg Dec 18 '14 at 10:17
  • in my system \setmainfont[Mapping=bardzo]{Heuristica} working \setmainfont{Heuristica}[Mapping=bardzo] not working – bardzo Dec 22 '14 at 14:57
  • Am I correct in assuming that this only works with target glyphs that are assigned some Unicode point (be it regular or PUA) in the employed font? – Wrzlprmft Sep 26 '15 at 18:14
  • @Wrzlprmft Yes, you're right – egreg Sep 26 '15 at 19:49

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.