3

This is a follow-up to this question about typesetting Bengali.

As explained in both answers there, XeLaTeX can typeset Bengali given a suitable font using polyglossia and fontspec. For example,

\documentclass[a4paper]{article}
\usepackage{geometry,fontspec,polyglossia}
\setmainlanguage[variant=british]{english}
\setotherlanguage{bengali}
\newfontfamily\bengalifont{Noto Sans Bengali}[Script=Bengali]
\begin{document}
x, y, z whatever\dots

\begin{bengali}
  আমি
\end{bengali}
\end{document}

produces

output

[Note that XeTeX is required. LuaTeX does not give correct results.]

As I explain in my answer, the font I used in this example actually offers two different versions of Bengali script, which correspond to two different OpenType scripts for Bengali:

beng            Bengali
bng2            Bengali v.2

As shown above, using the first one is straightforward.

What about the second? As Arun Debray explains in discussion following his answer, there are posts elsewhere suggesting this is possible, but the example which would have shown how to realise this possibility is no longer available at the sign-posted location. That is, the trail goes cold at this point.

Hence, Arun Debray and I thought this question worth asking:

How should the second be used?

Disclaimer: I know nothing whatsoever about Bengali. I am told that the sample above is Bengali and that the output is correct. However, if I was not told this, it could as easily be Psyptizamen and I would never know the difference.


Though this question is about Bengali, several other scripts (e.g. Devanagari, Tamil) have two OpenType versions, so whatever difference there is between these is not specific to just Bengali.

  • Thank you for writing up this question! I did make a few changes: I replaced bengali with indic, since the former doesn't seem to exist and several other Indic scripts have two OpenType versions. – Arun Debray Jan 2 '16 at 4:29
  • I found a possible answer, but it doesn't seem to change anything, so I'll wait to post it as an answer until I understand the differences between the two versions, or someone finds a different approach. In §9.18.2 (p. 36) of the fontspec documentation, it suggests \newfontscript{Bengali2}{bng2} and \newfontfamily\bengalifont[Script=Bengali2]{Noto Sans Bengali} to switch versions. However, when I tried this on a paragraph of Bengali text, I could see no difference, so maybe this doesn't actually change anything. – Arun Debray Jan 2 '16 at 4:34
  • Thanks for editing. I almost tagged it indic but then wasn't confident enough that I understood the relationships between the languages involved and decided to play it safe and just say bengali. You should definitely answer, though it would be good to know what difference it is supposed to make, at least. – cfr Jan 2 '16 at 20:27
  • 1
    You can always define your own with \newfontscript – Will Robertson Jan 24 '16 at 0:07
  • 1
    @cfr Oh my, I let this slip. I'm sorry. I never learned the difference between the two versions, so maybe I'm not the best source. – Arun Debray Mar 6 '17 at 23:38
1

This has been answered in the comments on the question by Arun Debray (also at the other question) and by Will Robertson, fontspec developer; just turning it into an "answer" to get this question off the unanswered list.

Briefly, in the command

\newfontfamily\bengalifont{Noto Sans Bengali}[Script=Bengali]

the Script=Bengali is just a convenience, part of fontspec's pre-defined mapping of common names to OpenType script tags. As documented in section "Defining new scripts and languages" of the fontspec manual, you can define your own scripts with \newfontscript.

Thus, if you wish, you can forget about the default fontspec-defined Script=Bengali and define your own explicitly:

\documentclass[a4paper]{article}
\usepackage{geometry,fontspec,polyglossia}
\setmainlanguage[variant=british]{english}
\setotherlanguage{bengali}
\newfontscript{BengaliOpenTypeOld}{beng}
\newfontscript{BengaliOpenTypeNew}{bng2}
\newfontfamily\bengalifont{Noto Sans Bengali}[Script=BengaliOpenTypeNew]
\begin{document}
x, y, z whatever\dots

\begin{bengali}
  আমি
\end{bengali}
\end{document}

and switch between Script=BengaliOpenTypeNew and Script=BengaliOpenTypeOld as you wish.


Aside: The rest of this answer is completely tangential, but somewhat related to the motivation for asking this question (looking at the other question): the reason XeTeX is required and LuaTeX does not give correct results (currently) is that XeTeX uses the system libraries—such as Harfbuzz—for complex text layout aka text shaping (glyph reordering, glyph positioning, etc.), while LuaTeX hopes to minimize external dependencies and implement everything in Lua code, and this (IMO highly ambitious) work has, at the moment, simply not been done for Indic scripts other than reasonable support for Devanagari script and some basic support for Malayalam script. (See font-odv.lua in ConTeXt source code.)

For example, the word "আমি" consists of three Unicode "characters" (codepoints) in this order:

aami

where the glyph for the vowel-sign needs to be placed to the left of the consonant. This is done by Harfbuzz (or on Windows, possibly DirectWrite),

with harfbuzz

but in LuaTeX the glyphs are picked from the font and simply placed one after another meaninglessly:

lualatex

  • 1
    For others who may come here: this sort of thing also happens with Tamil (and probably lots of other languages that use Indic scripts, and maybe with other complex scripts like Burmese). Among other sequences in Tamil, the sequence 'க ோ' (but without the internal space char) is supposed to be rendered 'கோ' (and is rendered that way with XeLaTeX, and indeed in Internet Explorer), but instead comes out with the first and second glyphs reversed. This kind of issue effectively makes Lua(La)TeX unusable with Indic scripts, afaict. – Mike Maxwell Mar 23 '18 at 17:39
  • @MikeMaxwell Yes indeed. (The old pdfTeX ways of using Indic scripts, involving custom processors and TeX-specific non-Unicode fonts, is the only way to get Indic scripts properly in LuaTeX.) There have been some experiments with combining LuaTeX with Harfbuzz, but that won't be in the major TeX distributions for at least the next few years it looks like. – ShreevatsaR Mar 23 '18 at 17:55
  • the experiments you refer to are these: readytext.co.uk/?p=3186, right? Or are there others? – Mike Maxwell Mar 23 '18 at 20:35
  • @MikeMaxwell I haven't been keeping track, but Google search shows this (slides), this (post), this (and the one you linked), and IIRC I heard there was something recently from the LuaTeX developers themselves, though I can't find it anywhere. (You may get an answer to the question you asked on the LuaTeX mailing list.) – ShreevatsaR Mar 23 '18 at 20:55
  • @MikeMaxwell Also, if Tamil is the only Indic script you care about currently, there are some cumbersome non-Unicode ways to get Tamil (intended for old TeX/pdfTeX, but which will also work in LuaTeX), using some custom packages and preprocessing. (Search for Tamil on this site, or ask a new one if those don't work for you.) – ShreevatsaR Mar 23 '18 at 20:56

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.