TransWikia.com

How to get just the visarga symbol in Devanagari

TeX - LaTeX Asked by Sundar on May 27, 2021

This is my code

documentclass[letterpaper,12pt]{article}
usepackage{fancyhdr}
usepackage{footnpag}
usepackage{fontspec}
usepackage{polyglossia}
usepackage[total={6.5in,8.75in},top=1.2in,left=1.1in]{geometry}
pagestyle{fancy}

newcommand{san}{
catcode`^=12
catcode`~=12
fontspec[Script=Devanagari,Mapping=velthuis-sanskrit]{Shobhika Bold}}

begin{document}
{san .h}
end{document}

I want to get just the visarga symbol. The output of the above code is a circle followed by a visarga symbol.
enter image description here

One Answer

Could you say why you want this? According to the rules of Devanagari a visarga by itself is not meaningful; it is intended to be attached to a consonant.

Anyway, searching for “isolated combining character” gives some results (like this and this and, more specific to XeTeX, this and this), and the suggestion of using U+00A0 No-Break Space as the base character does seem to avoid the dotted circle, with both xelatex and lualatex, at least with the font (Shobhika) mentioned in the question and a few other fonts I tried:

documentclass{article}
usepackage{fontspec}
usepackage{polyglossia}
newfontfamily{shob}{Shobhika Bold}[Script=Devanagari, Renderer=HarfBuzz]
newcommand{visarga}{shob char"00A0char"0903}
begin{document}
visarga
end{document}

output

However, note that this (as instructed) renders it with a space:

documentclass{article}
usepackage{fontspec}
usepackage{polyglossia}

newfontfamily{shob}{Shobhika Bold}[Script=Devanagari, Renderer=HarfBuzz]

newcommand{visarga}{shob char"00A0char"0903}
newcommand{ka}{shob char"0915}

begin{document}
kavisargaka
end{document}

output 2, note space

If you're trying to do something strange (probably true by definition, given the question!) and don't want the space, you may need a different solution. Perhaps all you want is simply to use char"0915 for the visarga, and let it combine with preceding consonants normally?

documentclass{article}
usepackage{fontspec}
usepackage{polyglossia}

newfontfamily{shob}{Shobhika Bold}[Script=Devanagari, Renderer=HarfBuzz]

newcommand{visarga}{char"0903}
newcommand{ka}{char"0915}

begin{document}
shob kavisargaka
end{document}

output 3

But then you can probably just .h as in the question, so you probably wouldn't have asked the question if this is acceptable. Instead, another solution is to use U+200C ZERO WIDTH NON-JOINER or U+200D ZERO WIDTH JOINER as the base character. This seems to work (typesets the visarga, without either a dotted circle or a space) and may be what you want:

documentclass{article}
usepackage{fontspec}
usepackage{polyglossia}

newfontfamily{shob}{Shobhika Bold}[Script=Devanagari, Renderer=HarfBuzz]

newcommand{visarga}{shob char"200Cchar"0903}
newcommand{ka}{shob char"0915} % Or, {san ka} as in the question.

begin{document}
kavisargaka
end{document}

output four, seems to work for all uses

Correct answer by ShreevatsaR on May 27, 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