Showing posts with label Devanāgarī. Show all posts
Showing posts with label Devanāgarī. Show all posts

Saturday, June 17, 2017

Expanded Devanāgarī font comparison

In 2012 I posted a comparison of some Devanāgarī fonts that were around at the time.

Here's an update, with some more fonts and more concise TeX code:

\documentclass{article}
\usepackage{polyglossia}
\defaultfontfeatures{Script=Devanagari,Language=Sanskrit}

% set up a font, print its name, and typeset the test text:
\newcommand{\FontTrial}[1]{ %
    \setmainfont[Mapping=RomDev]{#1}
    \newfontfamily\eng{#1}
    % print the font name:
    {\eng #1} \TestText }

\newcommand{\TestText}{ = शक्ति, kārtsnyam ṣaṭtriṃśad;
{\addfontfeatures{Language=Hindi} Hindī =
        शक्ति कार्त्स्न्यम्}\par}

\begin{document}

\FontTrial{FreeSerif}
\FontTrial{FreeSans}
\FontTrial{Sanskrit 2003}

\setmainfont[FakeStretch=1.08,Mapping=RomDev]{Sanskrit 2003}
\newfontfamily\eng[FakeStretch=1.08,Language=English]{Sanskrit 2003}
{\eng Sanskrit 2003+} \TestText

\FontTrial{Nakula}
\FontTrial{Sahadeva}
\FontTrial{Murty Hindi}
\FontTrial{Murty Sanskrit}
\FontTrial{Shobhika}
% ... etcetera

\end{document}

Output:


Lessons learned:
  • Only Sanskrit 2003, Murty Sanskrit, Chandas, Uttara, Siddhanta, and Shobhika do a full conjunct consonant in ṣaṭtriṃśad.  The others fake it with a virāma.
  • Akshar Unicode's "prasanna" has a lazy horizontal conjunct.
  • Free Sans and Free Serif are the only fonts that distinguish Sanskrit and Hindi (see kārtsnyam).
  • Nakula, Sahadeva, Murty Hindi, Shobhika, Annapurna, Akshar Unicode, Kalimati, and Santipur do a lazy, horizontal conjunct consonant in kārtsnyam.
  • There's a special issue affecting FreeSans and FreeSerif.  I described this in a post in 2012.  The publicly distributed version of the fonts fails to make some important conjunct consonants, like त्रि and प्र correctly.  Unfortunately this issue has not changed in the intervening five years. The examples shown here use a fresh compilation of the fonts, based on downloading and compiling the development version at the Savannah repository (June 2017).  (Here's a link to my compiled fonts.)  This Savannah development version works better for  Devanagari, but has problems elsewhere, according to their author Stevan White.

Tuesday, December 16, 2014

Gnu-Freefont fonts and XeLaTeX

The problem

There's been a long-standing issue about using the Gnu-Freefont fonts with XeLaTeX.  The fonts are "Free Serif", "Free Sans" "Free Mono", and each has normal, italic, bold and bold-italic versions.  
These fonts are maintained by Stevan White, who has done a lot of support and maintenance work on them.  
These fonts are of special interest to people who type Indian languages because they include nice, and rather complete Devanāgarī character sets in addition to glyphs for
  • Bengali
  • Gujarati
  • Gurmukhi
  • Oriya
  • Sinhala
  • Tamil
    and
  • Malayalam
The Gnu Freefonts are excellent for an exceptionally wide range of scripts and languages, as well as symbols.  See the coverage chart.

At the time of writing this blog, December 2014, the release version of the fonts is 4-beta, dated May 2012.  This is the release that's distributed with TeXLive 2014, and is generally available with other programs that include or require the FreeFonts.

But the 2012 release of the FreeFonts causes problems with the current versions of XeTeX.  Basically, the Devanagari conjunct consonants in the 2012 fonts are incompatible with the current XeTeX compositing engine. (For the technical: Up to TL 2012 XeTeX used ICU; since TL 2013 it's used HarfBuzz.)

In the last couple of years, Stevan has done a great deal of work on the Devanagari parts of the FreeFonts, and he has solved these problems.  But his improvements and developments are only available in the Subversion repository.   For technically-able users, it's not hard to download and compile this pre-release version of the fonts.  But then to make sure that XeTeX calls the right version of the FreeFonts, it's also necessary to weed out the 2012 version of the fonts that's distributed with TeX Live 2014.  And that's a bit hard.  In short, things get fiddly.

Now, Norbert Preining has created a special TeX Live repository for the Subversion version of the FreeFonts.  TeX Live 2014 users can now just invoke that repo and sit back and enjoy the correct Devanagari typesetting.

New warning June 2017: 
the procedure below is no longer supported.  Don't do it.

WARNING
Be warned that the version distributed here is a development version, not meant for production. Expect severe breakage. You need to know what you are doing!
END WARNING

Here follow Norbert's instructions (as of Dec 2014).  Remember to use sudo if you have TeX Live installed system-wide.

The solution. A new TeX Live repository for the pre-release Gnu FreeFonts

Norbert says (Dec 2014):

Here we go: Please do:
tlmgr repository add http://www.tug.org/~preining/tlptexlive/ tlptexlive
tlmgr pinning add tlptexlive gnu-freefont
tlmgr install --reinstall gnu-freefont
You should see something like:  
[~] tlmgr install --reinstall gnu-freefont
...
[1/1, ??:??/??:??] reinstall: gnu-freefont @tlptexlive [12311k]
...
Note the
@tlptexlive
After that you can do  
tlmgr info gnu-freefont
and should see: 
Package installed:   Yes
revision:    3007
sizes:       src: 27157k, doc: 961k, run: 19769k
relocatable: No
collection:  collection-fontsextra
Note the
revision: 3007
which corresponds to the freefont subversion revision!!!

From now on, after the pinning action, updates for gnu-freefont will
always be pulled from tlptexlive (see man page of tlmgr).
 

Reverting the change:

In case you ever want to return to the versions as distributed in TeX Live, please do
tlmgr pinning remove tlptexlive gnu-freefont
tlmgr install --reinstall gun-freefont


Thank you, Norbert!

Wednesday, July 24, 2013

Minimal example of XeLaTeX with Velthuis input mapping



\documentclass{article}

\usepackage{polyglossia}

\newfontfamily
  \sanskritfont [Script=Devanagari,Mapping=velthuis-sanskrit]{Sanskrit 2003}

\begin{document}

\sanskritfont
\noindent\huge

aasiidraajaa nalo naama viirasenasuto balii|\\
upapannairgu.nairi.s.tai ruupavaana"svakovida.h||

\end{document}

Monday, May 27, 2013

XeLaTeX for Sanskrit: update

In a post on 5 July 2010, I gave an example of how to use XeLaTeX with various fonts and various ways of inputting text.   Some time later, the commands in the Fontspec and Polyglossia packages were updated, and my example didn't work as advertised any more.  Here is an update that works again.

Thursday, May 24, 2012

Two more good Devanāgarī fonts

I have posted an update to this post with some new material.

Steve White has recently done a great deal of work updating the FreeSerif and FreeSans Unicode fonts (that are, er, free).   He has done especially important work on the Devanagari characters in the font, as well as several other Indian writing systems.  See here for a listing of what has changed. Steve's work means that the Devanāgarī in the Free* fonts now works not only with Xe(La)TeX but also in Firefox, LibreOffice and other programs.  Thanks, Steve!

Zdeněk Wagner recently announced (here) that,
A few days ago version 20120503 of GNU FreeFont was released. This (OpenType as well as TrueType) version contains working Devanagari. FreeSans is based on Gargi with bugs fixed and positions of matras fine-tuned (and changes were reported back to the Gargi developers), FreeSerif is based on Velthuis fonts. Both fonts contain the Indian Rupee sign. In XeLaTeX, conjuncts in FreeSerif can be switched on/off according to the language.
Zdeněk provided an example file showing FreeSans and FreeSerif, and demonstrating the different conjuncts of Sanskrit and Hindī.  I have taken the liberty of expanding his file to compare some of the other leading Unicode fonts that contain both Devanāgarī and Latin typefaces in the same font:

XeLaTeX Input:
\documentclass{article}
\usepackage{polyglossia}

\defaultfontfeatures{Mapping=RomDev,Script=Devanagari,Language=Sanskrit}
\newfontfamily\eng[Mapping=tex-text]{TeX Gyre Pagella}
\begin{document}
\setmainfont{FreeSerif} \newfontfamily\eng[Mapping=tex-text]{FreeSerif}
{\eng FreeSerif} = शक्ति, kārtsnyam {\addfontfeatures{Language=Hindi} Hindī = शक्ति}
\setmainfont{FreeSans} \newfontfamily\eng[Mapping=tex-text]{FreeSans}
{\eng FreeSans} = शक्ति, kārtsnyam {\addfontfeatures{Language=Hindi} Hindī = शक्ति}
\setmainfont{Sanskrit 2003} \newfontfamily\eng[Mapping=tex-text]{Sanskrit 2003}
{\eng Sanskrit 2003} = शक्ति, kārtsnyam {\addfontfeatures{Language=Hindi} Hindī = शक्ति}
\setmainfont[FakeStretch=1.08]{Sanskrit 2003}
{\eng Sanskrit 2003+} = शक्ति, kārtsnyam {\addfontfeatures{Language=Hindi} Hindī = शक्ति}
\setmainfont{Nakula} \newfontfamily\eng[Mapping=tex-text]{Nakula}
{\eng Nakula} = शक्ति, kārtsnyam {\addfontfeatures{Language=Hindi} Hindī = शक्ति}
\setmainfont{Sahadeva} \newfontfamily\eng[Mapping=tex-text]{Sahadeva}
{\eng Sahadeva} = शक्ति, kārtsnyam {\addfontfeatures{Language=Hindi} Hindī = शक्ति}
\end{document}
Output:
(click to enlarge)

Note the use of the RomDev mapping to get "कार्त्स्न्यम्" out of "kārtsnyam", just for fun.  I've included Sanskrit 2003 twice, the second time with a bit of horizontal stretch, that I think makes it look nicer.
The official web page of the newly-updated FreeSans and FreeSerif fonts is:
As Zdeněk adds, ``Hopefully the font will soon appear in TeX Live and (some) Linux distributions. If you install it independently, be sure that you do not have font conflicts."

Be sure to delete all earlier versions of FreeSerif and FreeSans that might be lurking on your hard drive.  Then install the new version.  If you find the conjuncts aren't working as promised, you probably have an old FreeSerif or Sans lurking in a directory somewhere that you have forgotten about.

Friday, January 13, 2012

ibus bug fix

Typing Sanskrit in Ubuntu Linux is normally very convenient, using the built-in ibus and m17n systems.  You can write देवनागरी or romanisation (devanāgarī) with just a switch of the keyboard input method. (Thansiang's input method for romanisation input is effective and convenient, but has to be added manually because it isn't included in the main m17n distribution.)

However, with the update to Ubuntu 11.10 in October 2011, a bug was introduced that spoiled typing for several Asian languages, for users of the standard Ubuntu Unity and Gnome windows managers.  The symptom was that as you typed a space, the letters around the cursor jumped into the wrong order. 

The November solution by fujiwarat fixed things.  But it hasn't yet made its way into the standard Ubuntu updates.  At the time of writing, you have to update your ibus installation to version 1.4.0 manually. One way to do it is here, kindly provided by Alex Lee.

March 2012 Update (gnome-shell)

Brandon Schaefer has fixed this ibus/unity bug (thanks!), but the fix will only be released in Ubuntu 12.04 Precise Panglin.  Schaefer asks Oneiric users to wait a couple of months, since,
The changes would be to large and would require changes 
in both unityand nux. 
This is good for the future, but isn't great news for anyone who needs to type in an Asian language during the next two months.

And since ibus and the patch have moved along since the posting above, on 14 Jan, Alex Lee's instructions don't work any more.

The deb files that I made for myself in January, following Alex Lee's instructions are available here for a few months:
Fetch the six files, put them in a directory, and run the following two commands in a terminal, in the directory containing the deb files:
  • sudo apt-get remove ibus 
  • sudo dpkg -i *.deb
  • sudo apt-get install m17n
Log out and in for good measure, though it may not always be necessary.

Hope it works for you.  No guarantees, and no further help available from me, I'm afraid.   There has been a post suggesting that this does not work under unity (see here).  More testing required.  But it works fine for me under gnome-shell, and probably the other non-unity interfaces.

April 2012 update

All the above problems are solved in the 12.04 Precise Pangolin release of Ubuntu.  Just go with the defaults.
Furthermore, Pangolin's release now includes the input of Sanskrit roman transliteration as standard, using the IAST standard.  It's very nice.

Tuesday, October 04, 2011

Simplest Sanskrit XeLaTeX file

Input:

\documentclass{article}
\usepackage{polyglossia}
\setmainfont[Script=Devanagari]{Nakula}

\begin{document}
Your Devanāgarī looks like this:  आसीद्राजा नलो नाम and your romanized stuff looks like this: āsīd rājā nalo nāma.  
\end{document}

Output:






You can get the Nakula font (and its twin, Sahadeva) from John Smith's website, http://bombay.indology.info

Wednesday, September 01, 2010

XeLaTeX, Velthuis encoding, and palatal nasals

When using the Velthuis input coding for Devanāgarī, and wanting to have it handled by XeLaTeX, one finds the palatal ñ disappears in the Nāgarī.

input: sa~njaya

output: स न्जय


That's because the Velthuis input code for ञ् is ~n, and the "~" is a special code in TeX, meaning "hard space".

Here's the workaround. I define a font-switching command \dev that will turn Velthuis into Devanāgarī. \dev is mostly made up of "\textsanskrit" which is set up using the standard XeLaTeX/polyglossia \newfontfamily commands. \textsanskrit does the work of invoking the mapping-conversion (from XeTeX's velthuis-sanskrit.tec file).

But just before \textsanskrit, we change tilde into a normal character. And after \textsanskrit, we turn tilde back into an "active" hard space. We use the \aftergroup command so that the "active" version of tilde is activated after the closing of the group that contains the Devanāgarī.

Here's the code:


\newfontfamily\textsanskrit [Script=Devanagari,Mapping=velthuis-sanskrit]{Nakula}


% Make the tilde into a normal letter of the alphabet
\def\maketildeletter{\catcode`\~=11 }


% Return tilde to being the default TeX "active" character for hard space
\def\maketildeactive{\catcode`\~=13 }

\def\dev{\maketildeletter\textsanskrit \aftergroup\maketildeactive}


Here's how you use it:

input: {\dev sa~njaya uvaaca}. What did Dr~Sañjaya say?

output: सञ्जय उवाच. What did Dr Sañjaya say?

where that space betwen "Dr" and "Sañjaya" is hard, and you can't break a line there.

Enjoy.