TransWikia.com

^m exists in LuxiMono Type1 but not in LuxiMono OpenType

TeX - LaTeX Asked on February 25, 2021

As pointed out by the following MCE, ^m exists in the LuxiMono Type1 fonts but not in their OpenType counterpart (the result being weirder with lualatex than with xelatex).

documentclass{article}
usepackage{iftex}
ifpdftex
usepackage[T1]{fontenc}
usepackage[scaled=0.85]{luximono}
else
usepackage{fontspec}
setmonofont[Scale=0.85]{Luxi Mono}
fi
%
pagestyle{empty}
%
begin{document}
ttfamily^m
end{document}

Is it possible to get this character with OpenType LuxiMono?

One Answer

If the Luxi Mono fonts you refer to are the ones provided by the X11 system, you can adjust the encoding for them to use a different way for typesetting the accent.

documentclass{article}
usepackage{fontspec}

makeatletter
DeclareUnicodeEncoding{luxi}{
  input{tuenc.def}
  DeclareTextCommand{^}{UnicodeEncodingName}[1]{accent"02C6relax#1}
  DeclareUnicodeComposite{^}              {}{"005E}
  DeclareUnicodeComposite{^}             {A}{"00C2}
  DeclareUnicodeComposite{^}             {E}{"00CA}
  DeclareUnicodeComposite{^}             {I}{"00CE}
  DeclareUnicodeComposite{^}             {O}{"00D4}
  DeclareUnicodeComposite{^}             {U}{"00DB}
  DeclareUnicodeComposite{^}             {a}{"00E2}
  DeclareUnicodeComposite{^}             {e}{"00EA}
  DeclareUnicodeComposite{^}             i {"00EE}
  DeclareUnicodeComposite{^}             {i}{"00EE}
  DeclareUnicodeComposite{^}             {o}{"00F4}
  DeclareUnicodeComposite{^}             {u}{"00FB}
  DeclareUnicodeComposite{^}             {C}{"0108}
  DeclareUnicodeComposite{^}             {c}{"0109}
  DeclareUnicodeComposite{^}             {G}{"011C}
  DeclareUnicodeComposite{^}             {g}{"011D}
  DeclareUnicodeComposite{^}             {H}{"0124}
  DeclareUnicodeComposite{^}             {h}{"0125}
  DeclareUnicodeComposite{^}             {J}{"0134}
  DeclareUnicodeComposite{^}             j {"0135}
  DeclareUnicodeComposite{^}             {j}{"0135}
  DeclareUnicodeComposite{^}             {S}{"015C}
  DeclareUnicodeComposite{^}             {s}{"015D}
  DeclareUnicodeComposite{^}             {W}{"0174}
  DeclareUnicodeComposite{^}             {w}{"0175}
  DeclareUnicodeComposite{^}             {Y}{"0176}
  DeclareUnicodeComposite{^}             {y}{"0177}
}
makeatother

setmonofont{luxim}[
  Path=/opt/X11/share/fonts/TTF/,% <--- adjust to your setting
  Extension=.ttf,
  NFSSEncoding=luxi,
  UprightFont=*r,
  BoldFont=*b,
  ItalicFont=*ri,
  BoldItalicFont=*bi,
  Scale=0.8,
]

pagestyle{empty}

begin{document}

^a ttfamily^m^a^j

end{document}

enter image description here

I didn't check that all precomposite glyphs actually exist.


Some experience with font encodings is necessary. We declare a new one (there are details in the manual for fontspec), called luxi. We base it on TU by loading tuenc.def, but modify it.

The first change is to redefine ^ to yield accent"02C6 (a spacing circumflex that happily seems to exist in the fonts). However, we don't want to use the accent primitive for already existing precomposed characters such as â. So we override the usage of ^ producing an accented character in case we input, say ^a.

When TeX finds ^x or ^{x} (where x is any character), it checks whether a special macro exists, which would have been defined by

DeclareUnicodeComposite{^}{x}{<slot>}

If it exists, then the character in the specified slot is typeset; otherwise TeX goes for accent"02C6relax x.

Correct answer by egreg on February 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP