> 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/cs/clanky-do-hloubky/39-step-3-replacing-latex-s-default-fonts-with-variable-fonts.md).

# Krok 3: Nahrazení výchozích písem LaTeXu proměnnými fonty

[Úvod](https://www.overleaf.com/learn/latex/Articles/How_to_use_OpenType_variable_fonts_with_LaTeX?preview=true) [Krok 1](https://www.overleaf.com/learn/latex/Articles/Step_1:_Setting_up_an_Overleaf_project_to_use_variable_fonts?preview=true) [Krok 2](https://www.overleaf.com/learn/latex/Articles/Step_2:_An_introduction_to_LaTeX_fonts?preview=true) [Krok 3](https://www.overleaf.com/learn/latex/Articles/Step_3:_Replacing_LaTeX’s_default_fonts_with_variable_fonts?preview=true) [Krok 4](https://www.overleaf.com/learn/latex/Articles/Step_4:_How_to_configure_an_italic_variable_font_using_fontspec?preview=true) [Krok 5](https://www.overleaf.com/learn/latex/Articles/Step_5:_LaTeX_font_weights_and_named_instances_of_variable_fonts?preview=true) [Krok 6](https://www.overleaf.com/learn/latex/Articles/Step_6:_Using_variable_fonts_to_add_bold_fonts_to_an_Overleaf_project?preview=true) [Krok 7](https://www.overleaf.com/learn/latex/Articles/Step_7:_Using_Noto_Sans_and_Roboto_Mono_variable_fonts_with_LaTeX?preview=true) [Krok 8](https://www.overleaf.com/learn/latex/Articles/Step_8:_How_to_create_a_simple_LaTeX_package_to_configure_your_variable_fonts?preview=true) [Příklady a projekty](https://www.overleaf.com/learn/latex/Articles/Overleaf_projects_showing_how_to_use_variable_fonts_with_LaTeX?preview=true)

V tomto kroku představíme tři příkazy z balíčku fontspec, které se použijí k nahrazení výchozích fontů LaTeXu variabilními fonty.

## Použití fontspec k úpravě výchozích fontů LaTeXu

K nahrazení výchozích fontů LaTeXu variabilními fonty podle našeho výběru použijeme následující příkazy balíčku fontspec:

* `\setmainfont{⟨font⟩}[⟨font features⟩]` nastavuje font použitý pro hlavní text dokumentu.
* `\setsansfont{⟨font⟩}[⟨font features⟩]` nastavuje bezpatkový font.
* `\setmonofont{⟨font⟩}[⟨font features⟩]` nastavuje neproporcionální font.

Každý z těchto příkazů má dvě části:

* `⟨font⟩`: povinný argument, uzavřený do složených závorek `{...}`, který určuje font, který chceme použít, zadaný jako název fontu nebo jako název souboru s fontem.
* `⟨font features⟩`: volitelný argument, uzavřený do hranatých závorek `[...]`, používaný k aktivaci funkcí specifických pro daný font, včetně nastavení variabilních fontů.

Tyto příkazy budou podrobněji vysvětleny později v tutoriálu.

## Jak aktivovat variabilní fonty v projektu tutoriálu

Podle následujících kroků aktivujte a použijte variabilní fonty projektu.

1. Otevřete úvodní tutoriálový projekt a upravte jej vložením následujícího kódu do preambule dokumentu — vložte jej za řádek `\usepackage{fontspec}`.

```latex
% Document family main text font
\setmainfont{NotoSerif-VariableFont-wdth-wght.ttf}
% Bezpatkové písmo rodiny dokumentu
\setsansfont{NotoSans-VariableFont-wdth-wght.ttf}
% Monospace písmo rodiny dokumentu
\setmonofont{RobotoMono-VariableFont-wght.ttf}
```

![Obrázek ukazující, kam vložit kód LaTeXu do preambule dokumentu](/files/76b319808631f27546751433a5c3eb3b256273c4)

4. Znovu zkompilujte aktualizovaný projekt, aby se vysázel s použitím variabilních fontů. Měli byste si všimnout následujících problémů:

* Vysázený dokument už neobsahuje žádný tučný ani kurzivní text.
* Jsou zde tři varování „undefined font shapes“:

![Obrázek zobrazující varování LaTeXu o chybějících fontech.](/files/85f345bc6e75e9db9f44874d28ba93e43bccae9f)

## Proč vidím varování „undefined shape“?

Naše počáteční nastavení variabilních fontů je *velmi* základní a povoluje pouze vzpřímené fonty střední tloušťky. V důsledku toho LaTeX vypisuje varování „undefined shape“, které vás upozorňuje, že již nemá přístup k fontům pro sazbu tučného, tučného kurzívou a běžného kurzivního textu použitého v našem dokumentu.

## Porozumění varováním LaTeXu o „undefined shape“

Jak bylo vysvětleno v kroku 2, LaTeX klasifikuje každý textový font podle pěti atributů: kódování, rodina, řada, tvar a velikost. Pokud se pokusíte použít font, jehož kombinace atributů — kódování, rodina, řada a tvar — neodpovídá žádnému známému „skutečnému“ fontu, LaTeX vydá varování „missing shape“. Tomuto varování lze zabránit konfigurací fontu s požadovanými atributy.

### Struktura těchto varování

Každé varování má strukturu

``Tvar fontu `*kódování/název rodiny/řada/tvar*' není definován``

jak je znázorněno na tomto obrázku:

![Obrázek ukazující strukturu varování LaTeXu o chybějícím tvaru](/files/c71533f93b4223cfc8bf42f51510f3943f42a21e)

### Co nám tato varování říkají?

Každé z následujících varování je vysvětleno níže.

![Obrázek zobrazující varování LaTeXu o chybějících fontech.](/files/85f345bc6e75e9db9f44874d28ba93e43bccae9f)

1. **``Tvar fontu `TU/NotoSerif-VariableFont-wdth-wght.ttf(0)/b/n' není definován``**

LaTeX nemá přístup k fontu s následující kombinací atributů:

* *kódování*: **`TU`** (Unicode).
* *rodina*: `**NotoSerif-VariableFont-wdth-wght.ttf(0)**`—dlouhé jméno rodiny vytvořené balíčkem fontspec při použití příkazu \setmainfont. Jména rodin probereme později v sérii.
* *řada*: **`b`** → **b**tučný *hmotnost*, **m**střední *width* (to **m** je vypuštěno).
* tvar: **`n`** → **n**normální (vzpřímený) *tvar.*

LaTeXu chybí **b**tučná tloušťka, **m**střední šířka (řada) a **n**font s normálním (vzpřímeným) tvarem v `NotoSerif-VariableFont-wdth-wght.ttf(0)` rodině.

4. **``Tvar fontu `TU/NotoSerif-VariableFont-wdth-wght.ttf(0)/b/it' není definován``**

LaTeX nemá přístup k fontu s následující kombinací atributů:

* *kódování*: **`TU`** (Unicode).
* *rodina*: `**NotoSerif-VariableFont-wdth-wght.ttf(0)**`*.*
* *řada*: `**b**` → **b**tučná tloušťka, **m**střední šířka (ta **m** je vypuštěno).
* *tvar*: it → kurzivní tvar.

LaTeXu chybí **b**tučná tloušťka, **m**střední šířka (řada) **it**kurzivní (tvar) font v rodině `NotoSerif-VariableFont-wdth-wght.ttf(0)` rodině.

8. ``**Tvar fontu `TU/NotoSerif-VariableFont-wdth-wght.ttf(0)/m/it' není definován**``

LaTeX nemá přístup k fontu s následující kombinací parametrů:

* kódování: TU (Unicode)
* rodina: NotoSerif-VariableFont-wdth-wght.ttf(0)
* řada: m → střední tloušťka, střední šířka (všimněte si použití jediného m)
* tvar: it → kurzivní tvar

LaTeXu chybí kurzivní font se střední tloušťkou a střední šířkou (řada) v rodině NotoSerif-VariableFont-wdth-wght.ttf(0).

## V dalším kroku

V krocích 4 až 6 tato varování opravíme konfigurací našich variabilních fontů tak, aby poskytovaly chybějící tvary fontů.

[Úvod](https://www.overleaf.com/learn/latex/Articles/How_to_use_OpenType_variable_fonts_with_LaTeX?preview=true) [Krok 1](https://www.overleaf.com/learn/latex/Articles/Step_1:_Setting_up_an_Overleaf_project_to_use_variable_fonts?preview=true) [Krok 2](https://www.overleaf.com/learn/latex/Articles/Step_2:_An_introduction_to_LaTeX_fonts?preview=true) [Krok 3](https://www.overleaf.com/learn/latex/Articles/Step_3:_Replacing_LaTeX’s_default_fonts_with_variable_fonts?preview=true) [Krok 4](https://www.overleaf.com/learn/latex/Articles/Step_4:_How_to_configure_an_italic_variable_font_using_fontspec?preview=true) [Krok 5](https://www.overleaf.com/learn/latex/Articles/Step_5:_LaTeX_font_weights_and_named_instances_of_variable_fonts?preview=true) [Krok 6](https://www.overleaf.com/learn/latex/Articles/Step_6:_Using_variable_fonts_to_add_bold_fonts_to_an_Overleaf_project?preview=true) [Krok 7](https://www.overleaf.com/learn/latex/Articles/Step_7:_Using_Noto_Sans_and_Roboto_Mono_variable_fonts_with_LaTeX?preview=true) [Krok 8](https://www.overleaf.com/learn/latex/Articles/Step_8:_How_to_create_a_simple_LaTeX_package_to_configure_your_variable_fonts?preview=true) [Příklady a projekty](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/cs/clanky-do-hloubky/39-step-3-replacing-latex-s-default-fonts-with-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.
