# Burmese and LuaLaTeX

I am working with a project which requires LuaLaTeX (TeX Live 2018) and the Noto Serif Myanmar font. I need a few words of Burmese only. The MWE works well with XeLaTeX. But LuaLaTeX has a problem with the ligatures. Is there any way to get this to work with LuaLaTeX and the used Noto Serif Myanmar font (besides setting them with XeLaTeX and include them as graphics, e.g. with https://ctan.org/pkg/standalone)?

\documentclass[landscape]{memoir}

\usepackage{fontspec,polyglossia,url}

\newfontfamily{\burmeseFamily}{NotoSerifMyanmar-Regular.ttf}
\newfontfamily{\burmeseFamilyDecom}{MyanmarMN}
\newcommand{\burmeseTest}[1]{
{\burmeseFamily{} #1}
\hfill
{\burmeseFamilyDecom{} #1}}

\begin{document}

\burmeseTest{င်းကွန်းင်းလောင်းတော်ကြီး}

\bigskip
\burmeseTest{မ္မတီခေါင်းလောင်းကြီး}

\vfill
Might be usefull: \url{https://r12a.github.io/pickers/burmese/}
\end{document}


The RHS is just for comparison, the LHS is what I really need.

XeLaTeX (correct):

LuaLaTeX (wrong):

The website https://r12a.github.io/pickers/burmese/ might be useful for an analysis of the ligatures. Thanks to ShreevatsaR's comment below, the site https://en.wikipedia.org/wiki/Complex_text_layout might give some relevant information. If you are not familiar with the Noto fonts, you might want to read https://en.wikipedia.org/wiki/Noto_fonts.

Update. Version 2.7b (2019/02/12) of https://ctan.org/pkg/fontspec adds (experimental) support for additional rendering engines such as Harfbuzz or Graphite. I was not able to do a correct set up with those engines, yet, see also the comments on https://tex.stackexchange.com/a/441914/128553 below. Any MWE on this technique addressing my problem would be highly appreciated. How to install HarfTeX on TeXLive? might be relevant.

• At the moment, LuaTeX does not support most of the world's scripts, including Burmese and other Brahmi-derived scripts — it supports only simple scripts where characters are laid out one after the other. You just have to use XeTeX, or images, I'm afraid. (You should also ask on the LuaTeX mailing list, as a few days ago there was a claim that no one had ever asked the LuaTeX developers for support for such scripts!) Although, if you need only a few words, there may be a laborious way involving you doing the work of text-shaping (as done by Harfbuzz etc) manually (I don't know the details…) – ShreevatsaR May 13 '18 at 22:38
• @ShreevatsaR Thank you for your comment and the good explanation. Indeed I hope for a laborious way, although the inclusion of a pdf works so far with some obvious drawbacks. – CampanIgnis May 14 '18 at 21:53
• About latest edit: as there's already an indic tag, don't see the point of creating a new brahmic-scripts tag which has only this question. Please use your tag-creation powers wisely. :-) Sure, there exist many Brahmi-origin scripts that many would not call “Indic”, such as all the Southeast Asian scripts… but the question when creating tags is really “will enough questions get tagged with this, so that someone is likely to follow this tag, so that adding this tag will attract attention?” — I don't see that happening here; already many Indic questions are not tagged indic. – ShreevatsaR Jun 4 '18 at 14:43
• Technically, the feature for which support is needed here is known among other things as complex text layout; it's not specific to Indic and other scripts derived from Brahmi. But I"m not suggesting creating a complex-text-layout tag either, for the same reasons. In any case I don't see the point of keeping this question open; let me just post my comment as answer. – ShreevatsaR Jun 4 '18 at 14:51

Here is a sample using my Luatex-harfbuzz-shaper:

\documentclass[landscape]{memoir}

\usepackage{harfbuzz}
% \usepackage{fontspec,polyglossia,url}
\usepackage{url}

\font\burmeseFamily={Noto Sans Myanmar:+script=mymr;+language=mya} at 12pt
\font\burmeseFamilyDecom={Noto Sans Myanmar:+script=dflt;+language=dflt} at 12pt
\newcommand{\burmeseTest}[1]{
{\burmeseFamily{} #1}
\hfill
{\burmeseFamilyDecom{} #1}
}

\begin{document}

\burmeseTest{င်းကွန်းင်းလောင်းတော်ကြီး}

\bigskip
\burmeseTest{မ္မတီခေါင်းလောင်းကြီး}

\bigskip
Might be usefull: \url{https://r12a.github.io/pickers/burmese/}
\end{document}


Note that it expects the Noto Sans Myanmar is installed on your system. You also need to install Luaharfbuzz on your system.

This is the result:

• I have installed harfbuzz and luaharfbuzz. I downloaded the repositories luaharfbuzz-master and luatex-harfbuzz-shaper-master and made them accessible via texhash. But I have the following problem: [\directlua]:1: module 'hb_paths' not found: no field package.preload['hb_paths'] [kpse lua searcher] file not found: 'hb_paths' [kpse C searcher] file not found: 'hb_paths' Any ideas on the missing file? – CampanIgnis Jul 17 '18 at 11:01
• @CampanIgnis try to run command make make_paths in the luatex-harfbuzz-shaper directory, it should generate the needed file – michal.h21 Jul 17 '18 at 11:27
• I now have that file, unfortunately another problem arose: PANIC: unprotected error in call to Lua API (error in __gc metamethod (bad argument #1 to '?' (harfbuzz.Buffer expected, got table))) Abort In case you have the time and motivation to try to solve this problem (and perhaps some other problems to come) a chat room might be a better solution. – CampanIgnis Jul 17 '18 at 13:39
• @CampanIgnis it can be quite hard to install Luaharfbuzz correctly, it builds a binary library, which needs to be compatible with LuaTeX. For example, on my machine, Luarocks compile for Lua 5.3 by default, but LuaTeX uses Lua 5.2. So I have to use some tricks to get correct library. See this discussion. The compilation against Lua 5.2 worked for me. – michal.h21 Jul 17 '18 at 14:00
• Thank you very much for your efforts. I will try it later. – CampanIgnis Jul 17 '18 at 17:49

At the moment, LuaTeX does not support most of the world's scripts, including Burmese and other Brahmi-derived scripts. This is because it supports only simple scripts where characters are laid out one after the other; not scripts that require complex text layout.

There is some rudimentary support for Devanagari, and possibly for Malayalam, but not for Burmese as far as I know. Your options if you need to use such an “unsupported” script are:

• Just use XeTeX (or pdfTeX with a package for your script/language, if it exists), instead of LuaTeX (e.g. if you're using LaTeX, compile with xelatex instead of lualatex).

• Generate the text in another application (like XeTeX or whatever), and insert it as images into your LuaTeX document.

• Use one of the “experimental” ways of using a library (Harfbuzz) from LuaTeX, for text shaping. Some links (that you'll have to make sense of yourself): tatzetwerk/luatex-harfbuzz, deepakjois/luatex-harfbuzz, michal-h21/luatex-harfbuzz-shaper (associated mailing list post), recent article by two of the LuaTeX developers.

• Figure out how support is done in LuaTeX for Devanagari, and imitate it for Burmese (and other scripts). (I don't know how easy this is: on the one hand Harfbuzz is a long-running project with a lot of complexity; on the other hand on a cursory look the small amount of support code in LuaTeX for Devanagari seems to be adequate for some common purposes… though I haven't tested it in any detail.)

You should also ask on the LuaTeX mailing list: a couple of months ago there was a claim that no one had ever asked the LuaTeX developers for support for such scripts!

@ShreevatsaR has given some good thoughts. However, since I only needed two words, I included the words as PDF. This works reasonably and economically as I do not need to invest much time to try to make his suggestions work as I have never worked with the tools he suggested and my attempt with the other suggestions of https://tex.stackexchange.com/a/434933/128553 and https://tex.stackexchange.com/a/441914/128553 ended in failure.

In case someone is interested in the details:

We compile the following file Burmese.tex with XeLaTeX:

\documentclass[11pt,tikz,border=0ex]{standalone}

\usepackage{fontspec,polyglossia,url}

%This is necessary to scale the Burmese font.
\setmainfont{texgyrepagella-regular.otf}

%You may want to choose NotoSerifMyanmar-Medium.ttf or a different font for a better optical match
\newfontfamily{\burmeseFamily}{NotoSerifMyanmar-Regular.ttf}[Scale=MatchLowercase]
%There might be simpler ways to get equivalent results.
\newcommand{\burmeseFont}[1]{\tikz \node[inner sep=0pt] {\burmeseFamily{}#1};}

\begin{document}

\burmeseFont{င်းကွန်းင်းလောင်းတော်ကြီး}

\burmeseFont{မ္မတီခေါင်းလောင်းကြီး}

\end{document}


This gives the file Burmese.pdf with the two following pages:

We can use this file as follows:

\documentclass[11pt]{memoir}

\usepackage{fontspec,polyglossia,url,pdfpages}

\setmainfont{texgyrepagella-regular.otf}

%Lowering the PDF gives matching baselines
\newcommand{\burmeseA}
{\mbox{\lower 1.00ex\hbox{\includegraphics[page=1]{Burmese.pdf}}}}
\newcommand{\burmeseB}
{\mbox{\lower 1.00ex\hbox{\includegraphics[page=2]{Burmese.pdf}}}}

\begin{document}

Lorem ipsum \burmeseA{} dolor sit manet.

Et \burmeseB{} nil nisi colloquor.

\end{document}


To get the following result.

Matching font size and mainfont in both files are important. One can vary the font size and styles in the file Burmese.tex in case different typefaces are needed. One note: The Burmese letters in the second PDF are not copyable.

• Since you're doing exactly what @ShreevatsaR suggests in his second bullet point, it seems a bit strange that you accept your own answer instead of his. – Sverre Jul 15 '18 at 15:48
• @Sverre I beg to differ. I already wrote about that option in my question. – CampanIgnis Jul 15 '18 at 17:17