> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/ar/alkhtwt/03-xelatex.md).

# دعم الخطوط الحديثة باستخدام XƎLaTeX

## مقدمة

[XeTeX](https://tug.org/xetex/) هو محرك تنضيد مشتق من برنامج TeX الأصلي لدونالد كنوث. ومع ذلك، وعلى عكس برنامج كنوث الأصلي، يقرأ XeTeX مباشرةً (يدخل) نص Unicode المشفّر بـ UTF-8، وبمساعدة من محركه المدمج [HarfBuzz](https://harfbuzz.github.io/) لمحرك تشكيل الحروف، يدعم صيغ الخطوط الحديثة مثل [OpenType (OTF)](https://docs.microsoft.com/en-us/typography/opentype/) و [تقنية الخط Graphite التابعة لـ SIL](https://scripts.sil.org/cms/scripts/page.php?site_id=projects\&item_id=graphite_home). ويُسمّى مُصرّف LaTeX المقابل [المُصرّف](/latex/ar/mzyd-mn-almwdhwaat/08-choosing-a-latex-compiler.md) على Overleaf `xelatex`. قد يرغب أي شخص مهتم بفهم تطور محركات TeX المختلفة بشكل أفضل في قراءة مقال Overleaf [ما في الاسم: دليل إلى الأنواع العديدة من TeX](/latex/ar/mqalat-mtamqh/55-what-s-in-a-name-a-guide-to-the-many-flavours-of-tex.md).

## الأساسيات: Times New Roman

Times New Roman خط شائع الاستخدام، وهنا مثال على استخدامه في Overleaf عبر مُصرّف XeLaTeX. في هذا المثال، يتم ضبط خط المستند باستخدام `\usemainfont{Times New Roman}`، حيث إن الأمر `\usemainfont{...}` يوفّره الحزمة `fontspec`.

```latex
\documentclass[12pt]{article}
\usepackage{fontspec}

\setmainfont{Times New Roman}
\title{Sample font document}
\author{Overleaf}
\date{\today}

\begin{document}
\maketitle

هذا \textit{مثال} على مستند تمّت ترجمته
باستخدام \textbf{XeLaTeX}. ينبغي أن يعمل LuaLaTeX أيضًا.

\end{document}
```

[افتح مثال Times New Roman باستخدام XeLaTeX في Overleaf](https://www.overleaf.com/docs?engine=xelatex\&snip_name=Times+New+Roman+%28via+XeLaTeX%29\&snip=%5Cdocumentclass%5B12pt%5D%7Barticle%7D%0A%5Cusepackage%7Bfontspec%7D%0A+%0A%5Csetmainfont%7BTimes+New+Roman%7D%0A%5Ctitle%7BSample+font+document%7D%0A%5Cauthor%7BOverleaf%7D%0A%5Cdate%7B%5Ctoday%7D%0A+++%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0A+++++%0AThis+is+an+%5Ctextit%7Bexample%7D+of+a+document+compiled+%0Awith+%5Ctextbf%7BXeLaTeX%7D.+LuaLaTeX+should+also+work+too.%0A%0A%5Cend%7Bdocument%7D)

ينتج هذا المثال المخرجات التالية:

![XeLaTeXOverleaf.png](/files/83c8f1478bc8500a50dfbfea00b62ce8b29b96f3)

يمكنك أيضًا [استخدام LuaLaTeX لتشغيل الشفرة نفسها](https://www.overleaf.com/docs?engine=lualatex\&snip_name=Times+New+Roman+%28via+LuaLaTeX%29\&snip=%5Cdocumentclass%5B12pt%5D%7Barticle%7D%0A%5Cusepackage%7Bfontspec%7D%0A+%0A%5Csetmainfont%7BTimes+New+Roman%7D%0A%5Ctitle%7BSample+font+document%7D%0A%5Cauthor%7BOverleaf%7D%0A%5Cdate%7B%5Ctoday%7D%0A+++%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0A+++++%0AThis+is+an+%5Ctextit%7Bexample%7D+of+a+document+compiled+%0Awith+%5Ctextbf%7BLuaLaTeX%7D.%0A%0A%5Cend%7Bdocument%7D) .

## ضبط الخطوط لعناصر LaTeX المختلفة

تُنسَّق العناصر المختلفة في مستند LaTeX بخطوط مختلفة؛ فعلى سبيل المثال، في `verbatim` تُعرض النصوص باستخدام نمط الآلة الكاتبة. ويمكن ضبط أنماط خطوط مختلفة لكل سياق:

```latex
\documentclass[12pt]{article}
\usepackage{fontspec}

%-----------------------------------------------------------------------
\setmainfont{Times New Roman}
\setsansfont{Arial}
\setmonofont[Color={0019D4}]{Courier New}
%-----------------------------------------------------------------------

\title{Sample font document}
\author{Overleaf}
\date{\today}
\begin{document}

\maketitle

هذا \textit{مثال} على مستند تمّت ترجمته باستخدام
مُصرّف \textbf{XeLaTeX}. إذا كان عليك كتابة بعض الشيفرة فيمكنك
استخدام بيئة \texttt{verbatim}:

    \begin{verbatim}
    عادةً ما تُستخدم هذه البيئة لعرض الشيفرة،
    إذًا إليك برنامج C بسيط.

    #include <stdio.h>
    #define NUMYAYS 10

    int main()
    {
        int i;
        for (i = 0; i <= NUMYAYS; i++)
        {
            printf("Yay! Overleaf is Awesome!\n");
        }
        return 0;
    }
    \end{verbatim}
    {\sffamily هذا نص نموذجي في \textbf{Sans Serif Font Typeface}}

\end{document}
```

[لرؤية النتيجة، افتح مثال XeLaTeX هذا على Overleaf](https://www.overleaf.com/docs?engine=xelatex\&snip_name=Document+formatted+with+different+fonts\&snip=%5Cdocumentclass%5B12pt%5D%7Barticle%7D%0A%5Cusepackage%7Bfontspec%7D%0A%0A%25-----------------------------------------------------------------------%0A%5Csetmainfont%7BTimes+New+Roman%7D%0A%5Csetsansfont%7BArial%7D%0A%5Csetmonofont%5BColor%3D%7B0019D4%7D%5D%7BCourier+New%7D%0A%25-----------------------------------------------------------------------%0A%0A%5Ctitle%7BSample+font+document%7D%0A%5Cauthor%7BOverleaf%7D%0A%5Cdate%7B%5Ctoday%7D%0A%5Cbegin%7Bdocument%7D%0A++++%0A%5Cmaketitle%0A+++++%0AThis+an+%5Ctextit%7Bexample%7D+of+document+compiled+with+the++%0A%5Ctextbf%7BXeLaTeX%7D+compiler.+If+you+have+to+write+some+code+you+can+%0Ause+the+%5Ctexttt%7Bverbatim%7D+environment%3A%0A%0A++++%5Cbegin%7Bverbatim%7D%0A++++Usually+this+environment+is+used+to+display+code%2C+%0A++++so+here%27s+a+simple+C+program.%0A%0A++++%23include+%3Cstdio.h%3E%0A++++%23define+NUMYAYS+10%0A++++++%0A++++int+main%28%29%0A++++%7B%0A++++++++int+i%3B+++%0A++++++++for+%28i+%3D+0%3B+i+%3C%3D+NUMYAYS%3B+i%2B%2B%29+%0A++++++++%7B%0A++++++++++++printf%28%22Yay%21+Overleaf+is+Awesome%21%5Cn%22%29%3B%0A++++++++%7D%0A++++++++return+0%3B%0A++++%7D%0A++++%5Cend%7Bverbatim%7D%0A++++%7B%5Csffamily+This+is+a+sample+text+in+%5Ctextbf%7BSans+Serif+Font+Typeface%7D%7D%0A+++++++%0A%5Cend%7Bdocument%7D)

في المثال السابق استُخدمت ثلاثة خطوط مختلفة، وتحدّد الأسطر التالية العناصر التي ستستخدم هذه الخطوط:

**\setmainfont{Times New Roman}**

هذا هو الخط العادي المستخدم في معظم المستند، وهو Times New Roman في المثال.

**\setsansfont{Arial}**

العناصر التي تتطلب خط sans، والمُعلن عنها صراحةً بواسطة \ssfamily في المثال، ستُنسَّق بخط Arial.

**\setmonofont{Courier New}**

كل ما سيُنسَّق بخط أحادي العرض (شبيه بآلة كاتبة) سيستخدم خط Courier New. يحتوي هذا الأمر على معامل اختياري إضافي داخل الأقواس المعقوفة:

**Color={0019D4}**

يؤدي هذا إلى ضبط لون النص باستخدام قيمة Color= وفق صيغة HTML السداسية عشرية. يمكن أن يكون الاستخدام الانتقائي والحذر للون النص مفيدًا عند إعداد عرض تقديمي.

## الخطوط في Overleaf

هناك [عدد كبير من الخطوط المثبّتة على Overleaf](/latex/ar/alaselh-walajwbh/85-which-otf-or-ttf-fonts-are-supported-via-fontspec.md) يمكنك استخدامها في مشروعك، وبأسهل طريقة عبر `fontspec`. تعرض الأمثلة التالية استخدام الخطوط المضمنة على خوادم Overleaf، مثل Google Noto، إلى جانب الخطوط التي تحتاج إلى رفعها من [Google Fonts](https://fonts.google.com/).

### الخطوط المثبّتة على خوادم Overleaf: خطوط Google Noto

لأن [TeX Live](https://www.tug.org/texlive/)—الذي يستخدمه Overleaf—يتضمن [خطوط Google Noto](https://www.google.com/get/noto/) يمكنك استخدامها عبر `fontspec` الحزمة، داخل مشاريع Overleaf المترجمة باستخدام مُصرّفي XeLaTeX أو LuaLaTeX. إليك مشروعًا نموذجيًا يستخدم [`noto` الحزمة](https://ctan.org/pkg/noto?lang=en) لتهيئة مستندك للتنضيد باستخدام عائلات الخطوط NotoSerif وNotoSans وNotoSansMono. يمكن العثور على توثيق الحزمة في `noto` الحزمة في [ملف readme على CTAN](http://mirrors.ctan.org/fonts/noto/README).

```latex
\documentclass{article}
\usepackage{xcolor}
\usepackage{noto}
\usepackage{hyperref}
\title{استخدام خطوط Google Noto}
\author{Overleaf}
\date{أبريل 2021}

\begin{document}

\maketitle

\section{Introduction}
يستخدم هذا المشروع النموذجي الحزمة \href{https://ctan.org/pkg/noto?lang=en}{\color{blue}\texttt{noto}} لتنضيد مستندك باستخدام خطوط Noto الخاصة بـ Google\footnote{\url{https://www.google.com/get/noto/}}:
\begin{itemize}
\item \verb|\textbf{bold}| ينتج \textbf{bold}
\item \verb|\textit{italic}| ينتج \textit{italic}
\item \verb|\textbf{\textit{bold italic}}| ينتج \textbf{\textit{bold italic}}
\item \verb|\emph{emphasis}| ينتج \emph{emphasis}
\item \verb|\textbf{\emph{bold italic}}| ينتج \textbf{\emph{bold italic}}
\end{itemize}

\subsection{الخطوط أحادية العرض}
يمكنك استخدام الخطوط أحادية العرض الخاصة بـ Noto للنص أحادي العرض \texttt{regular} و\texttt{\textbf{bold}}.

\subsection{خطوط Sans Serif}
إليك بعض \textsf{هذا النص مُنسَّق بخط sans serif} إلى جانب \textbf{\textsf{هذا النص مُنسَّق بخط sans serif عريض}}.

\section{قراءة إضافية}
يمكن العثور على توثيق حزمة \texttt{noto} في \href{http://mirrors.ctan.org/fonts/noto/README}{\color{blue}\texttt{readme} الخاص بها على CTAN}.

\end{document}
```

[افتح مثال XeLaTeX هذا على Overleaf لاستكشاف خطوط Noto](https://www.overleaf.com/docs?engine=xelatex\&snip_name=Using+Google+Noto+fonts\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bxcolor%7D%0A%5Cusepackage%7Bnoto%7D%0A%5Cusepackage%7Bhyperref%7D%0A%5Ctitle%7BUsing+Google+Noto+fonts%7D%0A%5Cauthor%7BOverleaf%7D%0A%5Cdate%7BApril+2021%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0A%5Cmaketitle%0A%0A%5Csection%7BIntroduction%7D%0AThis+example+project+uses+the+%5Chref%7Bhttps%3A%2F%2Fctan.org%2Fpkg%2Fnoto%3Flang%3Den%7D%7B%5Ccolor%7Bblue%7D%5Ctexttt%7Bnoto%7D%7D+package+to+typeset+your+document+using+Google%27s+Noto+fonts%5Cfootnote%7B%5Curl%7Bhttps%3A%2F%2Fwww.google.com%2Fget%2Fnoto%2F%7D%7D%3A%0A%5Cbegin%7Bitemize%7D%0A%5Citem+%5Cverb%7C%5Ctextbf%7Bbold%7D%7C+produces+%5Ctextbf%7Bbold%7D%0A%5Citem+%5Cverb%7C%5Ctextit%7Bitalic%7D%7C+produces+%5Ctextit%7Bitalic%7D%0A%5Citem+%5Cverb%7C%5Ctextbf%7B%5Ctextit%7Bbold+italic%7D%7D%7C+produces+%5Ctextbf%7B%5Ctextit%7Bbold+italic%7D%7D%0A%5Citem+%5Cverb%7C%5Cemph%7Bemphasis%7D%7C+produces+%5Cemph%7Bemphasis%7D%0A%5Citem+%5Cverb%7C%5Ctextbf%7B%5Cemph%7Bbold+italic%7D%7D%7C+produces+%5Ctextbf%7B%5Cemph%7Bbold+italic%7D%7D%0A%5Cend%7Bitemize%7D%0A%0A%5Csubsection%7BMonospaced+fonts%7D%0AYou+can+use+Noto%27s+monospaced+fonts+for+%5Ctexttt%7Bregular%7D+and+%5Ctexttt%7B%5Ctextbf%7Bbold%7D%7D+monospaced+text.%0A%0A%5Csubsection%7BSans+serif+fonts%7D%0AHere+is+some+%5Ctextsf%7Btext+is+typeset+in+a+sans+serif+font%7D+together+with+%5Ctextbf%7B%5Ctextsf%7Btext+typeset+in+bold+sans+serif%7D%7D.%0A%0A%5Csection%7BFurther+reading%7D%0ADocumentation+for+the+%5Ctexttt%7Bnoto%7D+package+can+be+found+in+its+%5Chref%7Bhttp%3A%2F%2Fmirrors.ctan.org%2Ffonts%2Fnoto%2FREADME%7D%7B%5Ccolor%7Bblue%7D%5Ctexttt%7Breadme%7D+file+on+CTAN%7D.%0A%0A%5Cend%7Bdocument%7D)

![استخدام خطوط Google Noto لتنضيد مستند LaTeX](/files/a065d8e2cd0ddac930b046e00c467a3428737c0a)

### استخدام خطوط غير مثبتة على خوادم Overleaf: مثال Google Fonts

لاستخدام خطوط OpenType غير المثبتة على خوادم Overleaf، يجب أولًا رفع ملفات الخطوط إلى مشروعك في Overleaf — شريطة أن تسمح تراخيص الخطوط بذلك. بعد رفع خطوط OpenType، اضبط مُصرّف المشروع على XƎLaTeX (أو LuaLaTeX) واستخدم `fontspec` لتهيئة خطوطك.

يوضح المشروع النموذجي الموضح أدناه كيفية إنشاء مجلدات، ورفع الخطوط، وتهيئتها باستخدام `fontspec`. في مثالنا سنستخدم الاختيار التالي من الخطوط من [Google Fonts](https://fonts.google.com/):

* خط Serif: [Brygada1918](https://fonts.google.com/specimen/Brygada+1918)
* خط Sans Serif: [Asap](https://fonts.google.com/specimen/Asap)
* خط أحادي العرض: [JetBrains Mono](https://fonts.google.com/specimen/JetBrains+Mono)

ملاحظة: لا نقول إن هذا المثال يقدّم توليفة متناغمة طباعيًا من الأنماط، بل يوضّح فقط كيفية رفع الخطوط وتهيئتها واستخدامها حسب اختيارك.

لكل عائلة خط، تحتاج إلى تنزيل عائلة الخط من Google Fonts:

![GoogleDownload.png](/files/d34d8ae90fe1e749b3c46b6603b0b53900900d43)

ملاحظة: بعض خطوط Google متاحة كخطوط OpenType "ثابتة" وما يُسمّى خطوط OpenType "متغيرة". إذا احتوى ملف ZIP الذي تم تنزيله على مجلد باسم "static" فيجب رفع الخطوط الموجودة في ذلك المجلد، وليس إصدارات الخطوط المتغيرة:

![OpenTypeStatic.png](/files/c8f6f2755b9b22de4050a6f7e693ed233d521493)

بعد ذلك، تحتاج إلى رفع ملفات الخطوط إلى مشروعك، ولكن لأن عائلات الخطوط تحتوي على عدة ملفات خط، فقد ترغب في إنشاء مجلدات منفصلة في مشروع Overleaf لتحتوي على الملفات — باستخدام مجلد واحد لكل عائلة خط. يوضح الفيديو التالي كيفية القيام بذلك. لاحقًا، سنحتاج إلى إخبار XƎLaTeX بمكان العثور على خطوط مشروعك — لأنها ليست مثبتة مسبقًا على خوادم Overleaf.

{% embed url="<https://videos.ctfassets.net/nrgyaltdicpt/4lQFkZ1Ni1FHFdHJUJSNH4/4aee7c5bafeb021a6f21b4637d0fe6ec/UploadingGoogleFonts.mp4>" %}

### تهيئة fontspec لاستخدام الخطوط

بعد رفع ملفات عائلة الخط إلى مجلدات مشروع Overleaf يمكننا تهيئتها للاستخدام عبر `fontspec`. في شيفرة LaTeX التالية، لاحظ كيف استخدمنا `المسار` المعامل لإخبار `fontspec` أن ملفات الخط موجودة في مجلد محلي داخل نظام ملفات مشروعنا:

```latex
\setmainfont{Brygada1918}[
    Path=./BrygadaFontFiles/,
    Extension = .ttf,
    UprightFont=*-Regular,
    BoldFont=*-Bold,
    ItalicFont=*-Italic,
    BoldItalicFont=*-BoldItalic
    ]

\setsansfont{Asap}[
    Path=./AsapFontFiles/,
    Scale=0.9,
    Extension = .ttf,
    UprightFont=*-Regular,
    BoldFont=*-Bold,
    ItalicFont=*-Italic,
    BoldItalicFont=*-BoldItalic
    ]

\setmonofont{JetBrainsMono}[
    Path=./JetbrainsFontFiles/,
    Scale=0.85,
    Extension = .ttf,
    UprightFont=*-Regular,
    BoldFont=*-Bold,
    ItalicFont=*-Italic,
    BoldItalicFont=*-BoldItalic
    ]
```

![FontSpecPathUpdated.png](/files/551ddb3e482520b5bc6f19ac94c5ce60e36fee60)

[افتح العرض التجريبي لـ XeLaTeX وGoogle Fonts على Overleaf](https://www.overleaf.com/project/new/template/31226?id=835225587\&templateName=XeLaTeX+font+demo+with+Google+Fonts\&latexEngine=xelatex\&texImage=texlive-full%3A2022.1\&mainFile=)

ال [`fontspec` الحزمة](https://ctan.org/pkg/fontspec?lang=en) يوفّر مجموعة واسعة من الخيارات لتهيئة خطوط OpenType لاستخدامها مع LuaLaTeX أو XƎLaTeX— [توثيقه الممتاز](http://mirrors.ctan.org/macros/unicodetex/latex/fontspec/fontspec.pdf) يحتوي على أمثلة عديدة يمكنك استكشافها لضبط تصميم مستنداتك وتنضيدها بدقة.

## قراءة إضافية

لمزيد من المعلومات، انظر:

* [الخط العريض والمائل والتحته خط](/latex/ar/asasyat-latex/03-bold-italics-and-underlining.md)
* [أحجام الخطوط، والعائلات، والأنماط](/latex/ar/alkhtwt/01-font-sizes-families-and-styles.md)
* [وجوه الخطوط](/latex/ar/alkhtwt/02-font-typefaces.md)
* [تنسيق الفقرات](/latex/ar/altnsyq/04-articles-how-to-change-paragraph-spacing-in-latex.md)
* [فواصل الأسطر والمسافات الفارغة](/latex/ar/altnsyq/05-line-breaks-and-blank-spaces.md)
* [محاذاة النص](/latex/ar/altnsyq/06-text-alignment.md)
* [أعمدة متعددة](/latex/ar/altnsyq/09-multiple-columns.md)
* [الإدارة في مشروع كبير](/latex/ar/bnyh-almstnd/07-management-in-a-large-project.md)
* [مشاريع LaTeX متعددة الملفات](/latex/ar/bnyh-almstnd/08-multi-file-latex-projects.md)
* [دعم اللغات الدولية](/latex/ar/allghat/03-international-language-support.md)
* [اختيار مُصرّف LaTeX](/latex/ar/mzyd-mn-almwdhwaat/08-choosing-a-latex-compiler.md)
* [قائمة خطوط OTF وTTF المثبتة على Overleaf](/latex/ar/alaselh-walajwbh/85-which-otf-or-ttf-fonts-are-supported-via-fontspec.md)
* [مجموعة خطوط Google](http://www.google.com/fonts/)
* [`fontspec` دليل الحزمة](http://tug.ctan.org/tex-archive/macros/latex/contrib/fontspec/fontspec.pdf)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/ar/alkhtwt/03-xelatex.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
