5

I have this example

\documentclass[hyperref=unicode]{beamer}

\usepackage[english,nil,bidi=basic-r]{babel}
\babelprovide[import=ar-DZ, main]{arabic}
\babelfont{rm}{Amiri}
\babelfont{sf}{Amiri}


\begin{document}

\begin{frame}{}
\today
\end{frame}

\begin{frame}{}
\selectlanguage{english}
\today
\end{frame}

\end{document}

Compiled with lualatex I obtain this warning

Package fontspec Warning: Language 'English' not available for font 'Amiri'

What I have done wrong? or what I have missed?

  • Why this warning keep showing? – Salim Bou Mar 8 at 21:39
  • Sorry @Salim, I noticed the warning now. You are right. But I don't know. – ferahfeza Mar 8 at 21:41
6

This bugged me for a long time too. This is what is going on:

These are the scripts and languages supported by Amiri:

DFLT        Default
arab        Arabic
arab.ARA    Arabic/Arabic
arab.KSH    Arabic/Kashmiri
arab.SND    Arabic/Sindhi
arab.URD    Arabic/Urdu
latn        Latin
latn.TRK    Latin/Turkish

When you load Arabic with \babelprovide[import=ar-DZ, main]{arabic} then babel reads in babel-ar-DZ.ini.

In this file you will find (among other things):

tag.opentype = ARA
script.tag.opentype = arab

So when Algerian Arabic is the language in use, babel will load Amiri with arab.ARA script and language. This exists in the font, so all is good.

But babel-en.ini contains this:

tag.opentype = ENG
script.tag.opentype = latn

So when English is in use, babel will try and load Amiri with latn.ENG script and language. Except this combination does not exist in the font, so a warning is issued by babel:

Language 'English' not available for font 'Amiri' with script 'Latin'.

Now all we need to do is tell babel to use Language=Default with Script=Latin for English while continuing to use Language=Arabic with Script=Arabic for Algerian Arabic.

To do this, remove english from the main babel options and instead load it like this:

\babelprovide[import,language=Default]{english}

Note: babel uses language with a lowercase l as opposed to fontspec which uses Language!

babel will now load Amiri with supported options for English text and no warning is issued.

MWE

\documentclass[hyperref=unicode]{beamer}

\usepackage[nil,bidi=basic-r]{babel}
\babelprovide[import=ar-DZ, main]{arabic}
\babelprovide[import, language=Default]{english}
\babelfont{rm}{Amiri}
\babelfont{sf}{Amiri}    

\begin{document}

\begin{frame}{}
\today
\end{frame}

\begin{frame}{}
\selectlanguage{english}
\today
\end{frame}

\end{document}
5

You can set the language to default:

\documentclass[hyperref=unicode]{beamer}

\usepackage[english,nil,bidi=basic-r]{babel}
\babelprovide[import=ar-DZ, main]{arabic}
\babelfont{rm}[Language=Default]{Amiri}
\babelfont{sf}[Language=Default]{Amiri}


\begin{document}

\begin{frame}{}
\today
\end{frame}

\begin{frame}{}
\selectlanguage{english}
\today
\end{frame}

\end{document}
  • 4
    Won't that change the language for both English and Arabic to Default? ar-DZ asks for Script=Arabic and Language=Arabic. I thought it was better to drop english out of the babel options and instead add in \babelprovide[import,language=Default]{english}. This only changes the Language to Default for English text and leaves it as Arabic for Arabic text. (I'm not familiar enough with Arabic to know if this actually makes a difference in this case, but surely it would sometimes?) – David Purton Mar 9 at 6:31
  • 1
    Ulrike, David is right. This applies Language=Default to all languages, potentially breaking font features specific to some languages. – Javier Bezos Mar 9 at 8:13
3

Nothing wrong, on the contrary. These warnings are shown by fontspec, not by babel. They could be irrelevant for English, but not for many other languages, including Arabic. To remove them altogether (they are only really useful when the document format is being set up), you may pass the silent option to fontspec:

\usepackage[english,nil,bidi=basic-r]{babel}
\babelprovide[import=ar-DZ, main]{arabic}
\PassOptionsToPackage{silent}{fontspec}
\babelfont{rm}{Amiri}
\babelfont{sf}{Amiri}

Or also:

\usepackage[english,nil,bidi=basic-r]{babel}
\babelprovide[import=ar-DZ, main]{arabic}
\usepackage[silent]{fontspec}
\babelfont{rm}{Amiri}
\babelfont{sf}{Amiri}

Edit. A 3rd option is to pass silent as a class option.

  • Personally, I would only do this as a last resort. Sometimes, fontspec warns about something important. – Davislor Apr 1 at 16:47
3

First, you can ignore this warning. It’s harmless. (However, I agree that it’s good practice to suppress meaningless warnings so that you don’t miss meaningful ones.)

David Purton’s answer is very elegant, but there is one situation where you might need something more complex: if you’re loading different fonts for the same language that require different options. For example, a \babelfont[chinese-traditional]{rm} might support Language=Chinese Traditional and a \babelfont[chinese-traditional]{sf} might support CJKShape = Traditional instead. More immediately, some Arabic fonts (including Noto Sans Arabic) do not support Language=Arabic.

In this case, you need to pass different fontspec options to the \babelfont command:

\babelfont{rm}[Scale=1.0]{Amiri}
\babelfont[english]{rm}[Language=Default]{Amiri}

However, a great multilingual companion font for Khaled Hosny’s Amiri is another of his font families, Libertinus. He based Libertinus Serif on Linux Libertine and Libertinus Sans on Linux Biolinum. I’ll let him speak as to the inspiration for the Latin letters in Amiri, but they’re a close match. There is also a math font that you can select with unicode-math.

If you want to enable all the font features of these fonts, you might try the following:

\documentclass[hyperref=unicode]{beamer}

\usepackage[nil,bidi=basic-r]{babel}

\babelprovide[import=ar-DZ, main]{arabic}
\babelprovide[import=en, language=Default]{english}

\babelfont{rm}[Scale=1.0,
               Ligatures={Common, TeX},
               UprightFeatures={Ligatures=Discretionary},
               Numbers={OldStyle,Proportional}
              ]{Libertinus Serif}
\babelfont{sf}[Scale=MatchLowercase,
               Ligatures=TeX,
               UprightFeatures={Ligatures={Common, Discretionary}},
               BoldFeatures={Ligatures=Common}
             ]{Libertinus Sans}
\babelfont[arabic]{rm}[Scale=MatchLowercase,
                       Ligatures={Common, TeX},
                       Contextuals={WordInitial,WordFinal,Inner}
                      ]{Amiri}

You can use the superscripts OpenType feature with the realscripts package.

Note that, due to a bug, Babel 3.27 and below ignores \defaultfontfeatures in \babelfont. I’ve worked around the bug here, but a fix is making its way into the release tree.

At this point, because beamer uses sans-serif fonts by default, you need to define \babelfont[arabic]{sf}. You can either copy the lines for babelfont[arabic]{rm} or load a sans-serif Arabic font, e.g.:

\babelfont[arabic]{sf}[Scale=MatchLowercase,
                       Ligatures=Discretionary,
                       Language=Default
                      ]{Noto Sans Arabic}

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.