Banner of A Step-by-Step Guide to Installing and Using Arabic Fonts in LaTeX

How to Set Up Multiple Arabic Fonts for LaTeX on Linux and Windows


Category: Latex

Date: 35 hours ago
Views: 118


How to Set Up Arabic Fonts for LaTeX on Linux and Windows

When working with Arabic text in LaTeX documents, selecting the right font can make a significant difference in the appearance of your document. In this article, we will walk you through the steps to download specific Arabic fonts from arfonts.net, install them on both Linux and Windows systems, and demonstrate how to use these fonts in a LaTeX document.

Step 1: Download the Fonts from arfonts.net

To begin, you will need to download the Arabic fonts. Follow these steps:

  • Visit https://www.arfonts.net/all/downloads.

  • Browse through the available fonts and download the desired Arabic fonts. You will typically find fonts in .zip or .rar formats.

  • Extract the downloaded file, which will usually contain .ttf (TrueType Font) files.

The fonts we will use for this demonstration are:

  • DecoType Thuluth II

  • Amiri

  • Noto Naskh Arabic

Step 2: Install the Fonts on Your System

After downloading and extracting the .ttf font files, you need to install them on your system. Below are the installation steps for both Linux and Windows.

Installing Fonts on Linux

  • Move the font files to the fonts directory:

    Copy the .ttf font files into the ~/.fonts directory (you may need to create the directory if it doesn't exist).

       
    mkdir -p ~/.fonts
    cp /path/to/downloaded/fonts/*.ttf ~/.fonts/
        
    
  • Update the font cache:

    After adding the fonts, you must update the font cache so that the system recognizes the new fonts. Run the following command in your terminal:

       
    fc-cache -fv
        
    

Installing Fonts on Windows

  • Move the font files to the Fonts directory:

    Navigate to the folder where the .ttf files were extracted. Right-click on each .ttf file and select Install from the context menu. Alternatively, you can manually move the .ttf files to the C:\Windows\Fonts directory.

  • Verify the installation:

    Open the Fonts folder (C:\Windows\Fonts) and ensure that the font files are listed.

Step 3: Use the Fonts in LaTeX

Now that you've installed the fonts, let's move on to how to use them in your LaTeX document. Below is an example LaTeX document that demonstrates how to use the DecoType Thuluth II, Amiri, and Noto Naskh Arabic fonts for Arabic text. We will also define commands to make it easier to switch between fonts.

LaTeX Example:

    

\documentclass[12pt]{article}
\usepackage[french]{babel} % Main language is French
\usepackage{fontspec} % For custom fonts
\usepackage{bidi} % For bidirectional text in a non-Arabic document

% Define Arabic fonts
\newfontfamily\arabicThuluth[Script=Arabic]{DecoType Thuluth II} % Thuluth font
\newfontfamily\arabicAmiri[Script=Arabic]{Amiri} % Amiri font
\newfontfamily\arabicNaskh[Script=Arabic]{Noto Naskh Arabic} % Naskh font

% Define commands manually
\newcommand{\thuluth}[1]{%
    \begin{RTL}%
    \begin{flushright}%
    {\arabicThuluth #1}%
    \end{flushright}%
    \end{RTL}%
}
\newcommand{\amiri}[1]{%
    \begin{RTL}%
    \begin{flushright}%
    {\arabicAmiri #1}%
    \end{flushright}%
    \end{RTL}%
}
\newcommand{\naskh}[1]{%
    \begin{RTL}%
    \begin{flushright}%
    {\arabicNaskh #1}%
    \end{flushright}%
    \end{RTL}%
}

\begin{document}

\section*{Examen Final}
Voici le texte principal en français.

\vspace{1cm}

% Arabic text in different fonts
\thuluth{
  \Huge 123
  الحمد لله الذي بنعمته تتم الصالحات.}
\amiri{
  \Huge 123
  بسم الله الرحمن الرحيم.}
\naskh{
  \Huge 123
  إن مع العسر يسرا.}

\end{document}

    

Explanation of the LaTeX Code:

  • Font Definitions: We define three different Arabic fonts using the \newfontfamily command from the fontspec package:

    • \arabicThuluth for DecoType Thuluth II.
    • \arabicAmiri for Amiri.
    • \arabicNaskh for Noto Naskh Arabic.
  • Creating Custom Commands: We create custom commands (\thuluth, \amiri, and \naskh) to simplify switching between fonts. Each command uses the corresponding Arabic font and ensures the text is displayed correctly with the RTL (Right-To-Left) environment.

  • Text Display: The Arabic text is displayed using these custom commands to demonstrate the different fonts.

Step 4: Compile the Document

To compile your LaTeX document with these fonts, you should use either XeLaTeX or LuaLaTeX, as they are both compatible with custom fonts:

  • Run the following command to compile the document:

       
    xelatex yourfile.tex
        
    

  • This will produce a PDF with Arabic text formatted using the specified fonts like this:

Latex arabic fonts example
Latex arabic fonts example

Conclusion

By following these simple steps, you can easily download and install Arabic fonts, configure them in your LaTeX documents, and use them to display beautiful Arabic text. Whether you're working on an Arabic document or simply adding a quote in Arabic, these fonts will make your document stand out.



118 views

Previous Article

0 Comments, latest

No comments yet. Be the first to Comment.