TeX - LaTeX Asked by Hrishikesh on July 29, 2020
I want to type text that may contain both Devanagari or Roman script, and I don’t want to change language mid sentence every time. Is it possible to merge two fonts, one which supports Devanagari glyphs, and one which supports Roman glyphs into one language?
Currently, I am doing
setdefaultlanguage{sanskrit}
newfontfamilysanskritfont[Script=Devanagari]{NotoSansDevanagari-Regular}
And since NotoSansDevangari-Regular
does not have glyphs for roman characters, it renders the line
The ending हल् letter of an उपदेश is called 'इत्'.
as
��� ������ हल् ������ �� �� उपदेश �� ������ 'इत्'.
Is it possible to somehow add NotoSans-Regular
alongwith NotoSansDevanagari-Regular
in the language so that it can render both scripts properly without having to explicitly do begin{english}end{english}
?
Seems like you are using XeLaTeX.
If so, as @kongo09 mentions in this question, a package called ucharclasses
works. Here is the MWE:
documentclass[xelatex]{article}
usepackage{fontspec}
newfontfamily{defaultfont}{Times New Roman}
newfontfamily{latinfont}{Times New Roman}
newfontfamily{devanagarifont}{NotoSansDevanagari-Regular}
usepackage[Latin, Devanagari]{ucharclasses}
setDefaultTransitions{defaultfont}{}
setTransitionsForLatin{latinfont}{}
setTransitionTo{Devanagari}{devanagarifont}
begin{document}
The ending हल् letter of an उपदेश is called 'इत्'.
end{document}
Answered by domperor on July 29, 2020
It is possible to do this with babel
. This new preamble should work with your document, so long as you used textenglish
and begin{sanskrit}
instead of devanagarifont
. It requires luahbtex (lualatex in TeX Live 2020 works), but has a bug with xetex (as of July 2020).
documentclass{article}
tracinglostchars=2
usepackage{iftex} % For ifluahbtex, ifxetex, etc.
usepackage[paperwidth=10cm]{geometry} % Format the MWR for TeX.SX
pagestyle{empty}
ifluahbtex
usepackage[bidi=basic,main=english]{babel}
usepackage{fontspec}
defaultfontfeatures{ Renderer=HarfBuzz,
Scale=MatchLowercase,
Ligatures=TeX }
usepackage{microtype}
else
% The only other engine that works, as of 2020, is XeTeX.
usepackage[bidi=default,main=english]{babel}
usepackage{fontspec}
defaultfontfeatures{ Scale=MatchLowercase,
Ligatures=TeX }
fi
babelprovide[onchar=ids fonts]{sanskrit-devanagari}
babelfont{rm}
[Ligatures=Common, Scale=1.0,Language=Default]{Noto Serif}
babelfont{sf}
[Ligatures=Common,Language=Default]{Noto Sans}
babelfont[sanskrit-devanagari]{rm}
{Noto Serif Devanagari}
babelfont[sanskrit-devanagari]{sf}
[Language=Default]{Noto Sans Devanagari}
babelfont{tt}
[Language=Default]{Noto Sans Devanagari UI}
babeltags{sanskrit=sanskrit-devanagari} % Add textsanskrit, begin{sanskrit}
babeltags{english=english} % Add textenglish, begin{englisn}
begin{document}
sffamily
The ending हल् letter of an उपदेश is called `इत्'.
end{document}
Recall that quotes in TeX are
`foo ``bar" baz' or ‘foo “bar” baz’
Answered by Davislor on July 29, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP