> 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/id/font/03-xelatex.md).

# Mendukung font modern dengan XƎLaTeX

## Pendahuluan

[XeTeX](https://tug.org/xetex/) adalah sebuah mesin penyusunan huruf yang diturunkan dari perangkat lunak TeX asli milik Donald Knuth. Namun, tidak seperti program asli Knuth, XeTeX secara native membaca teks Unicode ber-enkode UTF-8 dan, dengan bantuan dari [HarfBuzz](https://harfbuzz.github.io/) mesin pembentukan, mendukung format font modern seperti [OpenType (OTF)](https://docs.microsoft.com/en-us/typography/opentype/) dan [teknologi font Graphite milik SIL](https://scripts.sil.org/cms/scripts/page.php?site_id=projects\&item_id=graphite_home). LaTeX yang sesuai [kompiler](/latex/id/topik-lainnya/08-choosing-a-latex-compiler.md) di Overleaf disebut `xelatex`. Siapa pun yang ingin lebih memahami evolusi berbagai mesin TeX mungkin ingin membaca artikel Overleaf [What's in a Name: Panduan untuk Beragam Varian TeX](/latex/id/artikel-mendalam/55-what-s-in-a-name-a-guide-to-the-many-flavours-of-tex.md).

## Dasar-dasar: Times New Roman

Times New Roman adalah font yang umum digunakan dan berikut ini contoh penggunaannya di Overleaf melalui kompiler XeLaTeX. Dalam contoh ini, font dokumen diatur menggunakan `\usemainfont{Times New Roman}`, di mana perintah `\usemainfont{...}` disediakan oleh paket `fontspec`.

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

\setmainfont{Times New Roman}
\title{Contoh dokumen font}
\author{Overleaf}
\date{\today}

\begin{document}
\maketitle

Ini adalah \textit{contoh} dari dokumen yang dikompilasi
dengan \textbf{XeLaTeX}. LuaLaTeX juga seharusnya bisa bekerja.

\end{document}
```

[Contoh Open Times New Roman menggunakan XeLaTeX di 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)

Contoh ini menghasilkan keluaran berikut:

![XeLaTeXOverleaf.png](/files/93f1f0d51799266ae717c2b385276774713492d9)

Anda juga dapat [menggunakan LuaLaTeX untuk menjalankan kode yang sama](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) .

## Mengatur font untuk elemen LaTeX yang berbeda

Elemen-elemen berbeda dalam dokumen LaTeX diformat dengan font yang berbeda; misalnya, dalam sebuah `verbatim` lingkungan teks ditampilkan menggunakan gaya mesin ketik. Gaya font yang berbeda dapat diatur untuk setiap konteks:

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

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

\title{Contoh dokumen font}
\author{Overleaf}
\date{\today}
\begin{document}

\maketitle

Ini adalah \textit{contoh} dokumen yang dikompilasi dengan
kompiler \textbf{XeLaTeX}. Jika Anda harus menulis kode, Anda dapat
menggunakan lingkungan \texttt{verbatim}:

    \begin{verbatim}
    Biasanya lingkungan ini digunakan untuk menampilkan kode,
    jadi berikut ini program C sederhana.

    #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 Ini adalah teks contoh dalam \textbf{Sans Serif Font Typeface}}

\end{document}
```

[Untuk melihat hasilnya, buka contoh XeLaTeX ini di 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)

Pada contoh sebelumnya digunakan tiga font berbeda, baris berikut menentukan elemen yang akan menggunakan font ini:

**\setmainfont{Times New Roman}**

Ini adalah font normal yang digunakan di sebagian besar dokumen, Times New Roman dalam contoh.

**\setsansfont{Arial}**

Elemen yang memerlukan font sans, yang secara eksplisit dinyatakan oleh \ssfamily dalam contoh, akan disusun dengan font Arial.

**\setmonofont{Courier New}**

Semua yang akan diformat dengan font monospasi (seperti mesin ketik) akan menggunakan font Courier New. Perintah ini memiliki parameter opsional tambahan di dalam kurung kurawal:

**Color={0019D4}**

Ini menetapkan warna teks, menggunakan nilai Color= dengan format heksadesimal HTML. Penggunaan warna teks yang selektif dan hati-hati dapat berguna saat membuat presentasi.

## Font di Overleaf

Ada [sejumlah besar font yang terpasang di Overleaf](/latex/id/pertanyaan-and-jawaban/85-which-otf-or-ttf-fonts-are-supported-via-fontspec.md) yang dapat Anda gunakan dalam proyek Anda, paling mudah melalui `fontspec`. Contoh berikut menunjukkan penggunaan font yang disertakan di server Overleaf, seperti Google Noto, bersama dengan font yang perlu Anda unggah dari [Google Fonts](https://fonts.google.com/).

### Font yang terpasang di server Overleaf: font Google Noto

Karena [TeX Live](https://www.tug.org/texlive/)—yang digunakan oleh Overleaf—mencakup [font Google Noto](https://www.google.com/get/noto/) Anda dapat menggunakannya, melalui `fontspec` paket, di dalam proyek Overleaf yang dikompilasi menggunakan kompiler XeLaTeX atau LuaLaTeX. Berikut adalah proyek contoh yang menggunakan [`noto` ke preambel dokumen Anda (seperti disarankan](https://ctan.org/pkg/noto?lang=en) untuk mengonfigurasi dokumen Anda agar disusun dengan keluarga font NotoSerif, NotoSans, dan NotoSansMono. Dokumentasi tentang `noto` paket dapat ditemukan dalam [berkas readme di CTAN](http://mirrors.ctan.org/fonts/noto/README).

```latex
\documentclass{article}
\usepackage{xcolor}
\usepackage{noto}
\\usepackage{hyperref}
\title{Menggunakan font Google Noto}
\author{Overleaf}
\date{April 2021}

\begin{document}

\maketitle

\section{Pendahuluan}
Proyek contoh ini menggunakan paket \href{https://ctan.org/pkg/noto?lang=en}{\color{blue}\texttt{noto}} untuk menyusun dokumen Anda menggunakan font Noto milik Google\footnote{\url{https://www.google.com/get/noto/}}:
\begin{itemize}
\item \verb|\textbf{bold}| menghasilkan \textbf{bold}
\item \verb|\textit{italic}| menghasilkan \textit{italic}
\item \verb|\textbf{\textit{bold italic}}| menghasilkan \textbf{\textit{bold italic}}
\item \verb|\emph{emphasis}| menghasilkan \emph{emphasis}
\item \verb|\textbf{\emph{bold italic}}| menghasilkan \textbf{\emph{bold italic}}
\end{itemize}

\subsection{Font monospasi}
Anda dapat menggunakan font monospasi Noto untuk teks monospasi \texttt{regular} dan \texttt{\textbf{bold}}.

\subsection{Font sans serif}
Berikut ini ada \textsf{teks yang disusun dengan font sans serif} bersama dengan \textbf{\textsf{teks yang disusun dalam sans serif tebal}}.

\section{Bacaan lanjutan}
Dokumentasi untuk paket \texttt{noto} dapat ditemukan dalam \href{http://mirrors.ctan.org/fonts/noto/README}{\color{blue}\texttt{readme} file di CTAN}.

\end{document}
```

[Buka contoh XeLaTeX ini di Overleaf untuk menjelajahi font 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)

![Menggunakan font Google Noto untuk menyusun dokumen LaTeX](/files/e46e70bb0641ba18f093f48de9929c9671813f38)

### Menggunakan font yang tidak terpasang di server Overleaf: contoh Google Fonts

Untuk menggunakan font OpenType yang tidak terpasang di server Overleaf, Anda harus terlebih dahulu mengunggah file font ke proyek Overleaf Anda—dengan syarat lisensi font mengizinkan hal ini. Setelah font OpenType diunggah, atur kompiler proyek ke XƎLaTeX (atau LuaLaTeX) dan gunakan `fontspec` untuk mengonfigurasi font Anda.

Proyek contoh yang diuraikan di bawah ini menunjukkan cara membuat folder, mengunggah font, dan mengonfigurasinya dengan `fontspec`. Untuk contoh ini kita akan menggunakan pilihan font berikut dari [Google Fonts](https://fonts.google.com/):

* Font serif: [Brygada1918](https://fonts.google.com/specimen/Brygada+1918)
* Font sans serif: [Asap](https://fonts.google.com/specimen/Asap)
* Font monospasi: [JetBrains Mono](https://fonts.google.com/specimen/JetBrains+Mono)

Catatan: Kami tidak menyarankan bahwa contoh ini memberikan kombinasi gaya huruf yang harmonis secara tipografis; ini hanya menunjukkan cara mengunggah, mengonfigurasi, dan menggunakan font pilihan Anda.

Untuk setiap typeface, Anda perlu mengunduh keluarga font dari Google Fonts:

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

Catatan: Beberapa font Google tersedia sebagai font OpenType "statis" dan font OpenType yang disebut "variabel". Jika berkas ZIP yang diunduh memiliki folder bernama "static", Anda harus mengunggah font di folder itu, bukan versi font variabelnya:

![OpenTypeStatic.png](/files/69301a0e6f11c472703f84a3fd4868e5df941f49)

Selanjutnya, Anda perlu mengunggah berkas font ke proyek Anda, tetapi karena keluarga font berisi beberapa berkas font, Anda mungkin ingin membuat folder proyek Overleaf terpisah untuk menampung berkas-berkas tersebut—dengan satu folder per keluarga font. Video berikut menunjukkan cara melakukannya. Nanti, kita perlu memberi tahu XƎLaTeX di mana menemukan font proyek Anda—karena font tersebut tidak terpasang sebelumnya di server Overleaf.

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

### Mengonfigurasi fontspec untuk menggunakan font

Setelah mengunggah berkas-berkas keluarga font ke folder proyek Overleaf, kita dapat mengonfigurasinya untuk digunakan melalui `fontspec`. Pada kode LaTeX berikut, perhatikan bagaimana kita menggunakan `Path` parameter untuk memberi tahu `fontspec` bahwa berkas font terletak di folder lokal di dalam sistem berkas proyek kami:

```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/f70095b0969c7758ede3707f5b8081d3faedefee)

[Buka demo XeLaTeX dan Google Fonts di 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=)

Fitur [`fontspec` ke preambel dokumen Anda (seperti disarankan](https://ctan.org/pkg/fontspec?lang=en) menyediakan banyak opsi untuk mengonfigurasi font OpenType agar dapat digunakan dengan LuaLaTeX atau XƎLaTeX— [dokumentasi yang sangat baik](http://mirrors.ctan.org/macros/unicodetex/latex/fontspec/fontspec.pdf) berisi banyak contoh yang dapat Anda jelajahi untuk menyempurnakan desain dan penyusunan dokumen Anda.

## Bacaan lanjutan

Untuk informasi lebih lanjut lihat:

* [Huruf tebal, miring, dan garis bawah](/latex/id/dasar-dasar-latex/03-bold-italics-and-underlining.md)
* [Ukuran font, keluarga font, dan gaya](/latex/id/font/01-font-sizes-families-and-styles.md)
* [Jenis huruf](/latex/id/font/02-font-typefaces.md)
* [Pemformatan paragraf](/latex/id/pemformatan/04-articles-how-to-change-paragraph-spacing-in-latex.md)
* [Pemisah baris dan spasi kosong](/latex/id/pemformatan/05-line-breaks-and-blank-spaces.md)
* [Perataan teks](/latex/id/pemformatan/06-text-alignment.md)
* [Beberapa kolom](/latex/id/pemformatan/09-multiple-columns.md)
* [Pengelolaan dalam proyek besar](/latex/id/struktur-dokumen/07-management-in-a-large-project.md)
* [Proyek LaTeX multi-berkas](/latex/id/struktur-dokumen/08-multi-file-latex-projects.md)
* [Dukungan bahasa internasional](/latex/id/bahasa/03-international-language-support.md)
* [Memilih Kompiler LaTeX](/latex/id/topik-lainnya/08-choosing-a-latex-compiler.md)
* [Daftar font OTF dan TTF yang terpasang di Overleaf](/latex/id/pertanyaan-and-jawaban/85-which-otf-or-ttf-fonts-are-supported-via-fontspec.md)
* [koleksi font Google](http://www.google.com/fonts/)
* [`fontspec` manual paket](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/id/font/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.
