> 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/in-depth-articles/37-step-1-setting-up-an-overleaf-project-to-use-variable-fonts.md).

# Step 1: Setting up an Overleaf project to use variable fonts

[Introduction](https://www.overleaf.com/learn/latex/Articles/How_to_use_OpenType_variable_fonts_with_LaTeX?preview=true) [Step 1](https://www.overleaf.com/learn/latex/Articles/Step_1:_Setting_up_an_Overleaf_project_to_use_variable_fonts?preview=true) [Step 2](https://www.overleaf.com/learn/latex/Articles/Step_2:_An_introduction_to_LaTeX_fonts?preview=true) [Step 3](https://www.overleaf.com/learn/latex/Articles/Step_3:_Replacing_LaTeX’s_default_fonts_with_variable_fonts?preview=true) [Step 4](https://www.overleaf.com/learn/latex/Articles/Step_4:_How_to_configure_an_italic_variable_font_using_fontspec?preview=true) [Step 5](https://www.overleaf.com/learn/latex/Articles/Step_5:_LaTeX_font_weights_and_named_instances_of_variable_fonts?preview=true) [Step 6](https://www.overleaf.com/learn/latex/Articles/Step_6:_Using_variable_fonts_to_add_bold_fonts_to_an_Overleaf_project?preview=true) [Step 7](https://www.overleaf.com/learn/latex/Articles/Step_7:_Using_Noto_Sans_and_Roboto_Mono_variable_fonts_with_LaTeX?preview=true) [Step 8](https://www.overleaf.com/learn/latex/Articles/Step_8:_How_to_create_a_simple_LaTeX_package_to_configure_your_variable_fonts?preview=true) [Examples and projects](https://www.overleaf.com/learn/latex/Articles/Overleaf_projects_showing_how_to_use_variable_fonts_with_LaTeX?preview=true)

To begin this tutorial, open the [accompanying Overleaf project](https://www.overleaf.com/8438931911svtqtnmfvsrp#28008d) which contains the following variable fonts:

* [Noto Serif](https://fonts.google.com/noto/specimen/Noto+Serif/tester) (main document text)
* [Noto Sans](https://fonts.google.com/noto/specimen/Noto+Sans/tester) (sans serif font)
* [Roboto Mono](https://fonts.google.com/specimen/Roboto+Mono/tester) (monospaced font)

These fonts are not yet configured for use. Initially, when you compile the [accompanying Overleaf project](https://www.overleaf.com/8438931911svtqtnmfvsrp#28008d), LaTeX's standard (default) text fonts will be applied. Throughout this tutorial, you will learn how to replace these default fonts with the variable fonts provided in the project folder named `VariableFonts`.

If you prefer to use different variable fonts, simply follow the instructions below. Otherwise, proceed to [Step 2](https://www.overleaf.com/learn/latex/Articles/Step_2:_An_introduction_to_LaTeX_fonts?preview=true) this tutorial.

## (Optional) How to choose and upload your own variable fonts

Follow these steps to upload variable fonts of your choice.

### 1. Obtain variable fonts from Google Fonts

[Google Fonts](https://fonts.google.com/) is an excellent resource. It provides [helpful documentation](https://fonts.google.com/knowledge/introducing_type/introducing_variable_fonts) and many [free-to-use variable fonts](https://fonts.google.com/?vfonly=true) which can be uploaded to Overleaf and configured for use in your projects.

* **TIP**: Use the Google Fonts filters to find variable fonts. Set the *Technology* filter to *Variable* to display variable fonts only. Use additional filters, such as *Serif*, to further refine your search.

![Image showing Google Fonts search filters](/files/ggm6269NMkXGIgQrPrOP)

* **TIP**: You can browse variable fonts based on the design axes they support: see <https://fonts.google.com/variablefonts>. Google also provides definitions of variable font design axes: see <https://fonts.google.com/variablefonts#axis-definitions>.
* After locating any variable fonts you want to use, download them to your local device and rename any files containing problematic characters.
* Some variable fonts consist of two `.ttf` files: one for the upright (regular) shape and, if provided, one for the italic shape. Make sure to check this for each font you download.

### 2. Rename problematic Google font-file names

Google’s scheme for naming variable-font files includes the font’s design axes, separated by commas. Unfortunately, that scheme causes problems for fontspec, a package which is essential for using variable fonts with LuaLaTeX. For instance, Noto Serif provides width and weight axes and is supplied as two files—one for the upright font and one for the italic font:

* NotoSerif-VariableFont\_wdth,wght.ttf
* NotoSerif-Italic-VariableFont\_wdth,wght.ttf

The commas in these file names trigger errors when used in fontspec’s `\setmainfont` command. For example, writing

```
\setmainfont{NotoSerif-VariableFont_wdth,wght.ttf}
[ItalicFont = NotoSerif-Italic-VariableFont_wdth,wght.ttf]
```

produces errors that include

```
! Package fontspec Error: The font "NotoSerif-Italic-VariableFont_wdth" cannot
(fontspec)                be found.

! LaTeX Error: The key 'fontspec-opentype/wght.ttf' is unknown and is being
(LaTeX)        ignored.
```

To resolve this issue, you need to rename font files to remove commas (and underscores '\_'), replacing them with a “safe” character, such as the hyphens ('-'), and ensuring no space characters are added. For example, you could rename:

* NotoSans-VariableFont\_wdth,wght.ttf

to

* NotoSans-VariableFont-wdth-wght.ttf

This simple renaming step will help avoid conflicts and ensure smooth integration of variable fonts in your LaTeX documents.

### 3. Create a new Overleaf project

* Create a new Overleaf project and [set the compiler to LuaLaTeX](/latex/knowledge-base/026-changing-compiler.md) because it is the only compiler that supports variable fonts.
* Add the `fontspec` package to your document’s preamble by writing `\usepackage{fontspec}`.
* Select the file-upload icon (![Image displaying Overleaf file-upload icon](/files/7z7A4vlr3b2JnGFwgTKw)) to add the locally reamed variable-font files to your new project:

![Image showing how to upload a file to an Overleaf project](/files/cK91FBskCM5ZzJhvVDwf)

### 4. (Optional) organize your project’s font files

If you want to experiment with a range of fonts, for example, when testing document designs, it is helpful to organize your font files using project folders. However, at compile time, LaTeX will not automatically search your project folders for fonts; you’ll need to help LaTeX by using a local configuration file called [latexmkrc](/latex/in-depth-articles/28-how-to-use-latexmkrc-with-overleaf.md). We won’t go into details here, but recommend creating a project folder called `VariableFonts` and copying the `latexmkrc` file used in the [accompanying project](https://www.overleaf.com/8438931911svtqtnmfvsrp#28008d).

## In the next Step

Step 2 introduces LaTeX’s model for selecting fonts: the New Font Selection Scheme, providing important background information used throughout the remainder of this tutorial.

[Introduction](https://www.overleaf.com/learn/latex/Articles/How_to_use_OpenType_variable_fonts_with_LaTeX?preview=true) [Step 1](https://www.overleaf.com/learn/latex/Articles/Step_1:_Setting_up_an_Overleaf_project_to_use_variable_fonts?preview=true) [Step 2](https://www.overleaf.com/learn/latex/Articles/Step_2:_An_introduction_to_LaTeX_fonts?preview=true) [Step 3](https://www.overleaf.com/learn/latex/Articles/Step_3:_Replacing_LaTeX’s_default_fonts_with_variable_fonts?preview=true) [Step 4](https://www.overleaf.com/learn/latex/Articles/Step_4:_How_to_configure_an_italic_variable_font_using_fontspec?preview=true) [Step 5](https://www.overleaf.com/learn/latex/Articles/Step_5:_LaTeX_font_weights_and_named_instances_of_variable_fonts?preview=true) [Step 6](https://www.overleaf.com/learn/latex/Articles/Step_6:_Using_variable_fonts_to_add_bold_fonts_to_an_Overleaf_project?preview=true) [Step 7](https://www.overleaf.com/learn/latex/Articles/Step_7:_Using_Noto_Sans_and_Roboto_Mono_variable_fonts_with_LaTeX?preview=true) [Step 8](https://www.overleaf.com/learn/latex/Articles/Step_8:_How_to_create_a_simple_LaTeX_package_to_configure_your_variable_fonts?preview=true) [Examples and projects](https://www.overleaf.com/learn/latex/Articles/Overleaf_projects_showing_how_to_use_variable_fonts_with_LaTeX?preview=true)


---

# 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/in-depth-articles/37-step-1-setting-up-an-overleaf-project-to-use-variable-fonts.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.
