> 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/vi/bai-viet-chuyen-sau/37-step-1-setting-up-an-overleaf-project-to-use-variable-fonts.md).

# Bước 1: Thiết lập dự án Overleaf để dùng phông chữ biến đổi

[Giới thiệu](https://www.overleaf.com/learn/latex/Articles/How_to_use_OpenType_variable_fonts_with_LaTeX?preview=true) [Bước 1](https://www.overleaf.com/learn/latex/Articles/Step_1:_Setting_up_an_Overleaf_project_to_use_variable_fonts?preview=true) [Bước 2](https://www.overleaf.com/learn/latex/Articles/Step_2:_An_introduction_to_LaTeX_fonts?preview=true) [Bước 3](https://www.overleaf.com/learn/latex/Articles/Step_3:_Replacing_LaTeX’s_default_fonts_with_variable_fonts?preview=true) [Bước 4](https://www.overleaf.com/learn/latex/Articles/Step_4:_How_to_configure_an_italic_variable_font_using_fontspec?preview=true) [Bước 5](https://www.overleaf.com/learn/latex/Articles/Step_5:_LaTeX_font_weights_and_named_instances_of_variable_fonts?preview=true) [Bước 6](https://www.overleaf.com/learn/latex/Articles/Step_6:_Using_variable_fonts_to_add_bold_fonts_to_an_Overleaf_project?preview=true) [Bước 7](https://www.overleaf.com/learn/latex/Articles/Step_7:_Using_Noto_Sans_and_Roboto_Mono_variable_fonts_with_LaTeX?preview=true) [Bước 8](https://www.overleaf.com/learn/latex/Articles/Step_8:_How_to_create_a_simple_LaTeX_package_to_configure_your_variable_fonts?preview=true) [Ví dụ và dự án](https://www.overleaf.com/learn/latex/Articles/Overleaf_projects_showing_how_to_use_variable_fonts_with_LaTeX?preview=true)

Để bắt đầu hướng dẫn này, hãy mở [dự án Overleaf đi kèm](https://www.overleaf.com/8438931911svtqtnmfvsrp#28008d) chứa các phông chữ biến thể sau:

* [Noto Serif](https://fonts.google.com/noto/specimen/Noto+Serif/tester) (văn bản chính của tài liệu)
* [Noto Sans](https://fonts.google.com/noto/specimen/Noto+Sans/tester) (phông chữ sans serif)
* [Roboto Mono](https://fonts.google.com/specimen/Roboto+Mono/tester) (phông chữ đơn cách)

Các phông chữ này هنوز chưa được cấu hình để sử dụng. Ban đầu, khi bạn biên dịch [dự án Overleaf đi kèm](https://www.overleaf.com/8438931911svtqtnmfvsrp#28008d), các phông chữ văn bản chuẩn (mặc định) của LaTeX sẽ được áp dụng. Trong suốt hướng dẫn này, bạn sẽ học cách thay thế các phông chữ mặc định này bằng các phông chữ biến thể được cung cấp trong thư mục dự án có tên `VariableFonts`.

Nếu bạn muốn dùng các phông chữ biến thể khác, chỉ cần làm theo các hướng dẫn bên dưới. Nếu không, hãy tiếp tục tới [Bước 2](https://www.overleaf.com/learn/latex/Articles/Step_2:_An_introduction_to_LaTeX_fonts?preview=true) phần hướng dẫn này.

## (Tùy chọn) Cách chọn và tải lên các phông chữ biến thể của riêng bạn

Hãy làm theo các bước sau để tải lên các phông chữ biến thể mà bạn chọn.

### 1. Lấy phông chữ biến thể từ Google Fonts

[Google Fonts](https://fonts.google.com/) là một nguồn tài nguyên tuyệt vời. Nó cung cấp [tài liệu hướng dẫn hữu ích](https://fonts.google.com/knowledge/introducing_type/introducing_variable_fonts) và nhiều [phông chữ biến thể miễn phí để sử dụng](https://fonts.google.com/?vfonly=true) có thể được tải lên Overleaf và cấu hình để sử dụng trong các dự án của bạn.

* **MẸO**: Hãy dùng các bộ lọc của Google Fonts để tìm phông chữ biến thể. Đặt bộ lọc *Technology* thành *Variable* để chỉ hiển thị các phông chữ biến thể. Dùng thêm các bộ lọc khác, chẳng hạn như *Serif*, để tinh chỉnh thêm tìm kiếm của bạn.

![Hình ảnh hiển thị các bộ lọc tìm kiếm của Google Fonts](/files/242d9e267f16245902dbf0e994de512fbc9133d5)

* **MẸO**: Bạn có thể duyệt các phông chữ biến thể dựa trên các trục thiết kế mà chúng hỗ trợ: xem <https://fonts.google.com/variablefonts>. Google cũng cung cấp các định nghĩa về các trục thiết kế của phông chữ biến thể: xem <https://fonts.google.com/variablefonts#axis-definitions>.
* Sau khi xác định được bất kỳ phông chữ biến thể nào bạn muốn dùng, hãy tải chúng về thiết bị cục bộ của bạn và đổi tên bất kỳ tệp nào chứa các ký tự gây lỗi.
* Một số phông chữ biến thể gồm hai `.ttf` tệp: một cho dạng thẳng (thường) và, nếu có, một cho dạng nghiêng. Hãy chắc chắn kiểm tra điều này đối với từng phông chữ bạn tải xuống.

### 2. Đổi tên các tên tệp phông chữ Google có vấn đề

Cách đặt tên tệp phông chữ biến thể của Google bao gồm các trục thiết kế của phông chữ, được phân tách bằng dấu phẩy. Tiếc là cách đặt tên đó gây ra vấn đề cho fontspec, một gói cần thiết để dùng phông chữ biến thể với LuaLaTeX. Ví dụ, Noto Serif cung cấp các trục độ rộng và độ đậm, và được cung cấp dưới dạng hai tệp—một cho phông chữ thẳng và một cho phông chữ nghiêng:

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

Các dấu phẩy trong các tên tệp này sẽ gây lỗi khi được dùng trong lệnh `\setmainfont` của fontspec. Ví dụ, viết

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

sẽ tạo ra các lỗi bao gồm

```
! 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.
```

Để giải quyết vấn đề này, bạn cần đổi tên các tệp phông chữ để loại bỏ dấu phẩy (và dấu gạch dưới '\_'), thay chúng bằng một ký tự “an toàn”, chẳng hạn như dấu gạch nối ('-'), và đảm bảo không thêm ký tự khoảng trắng. Ví dụ, bạn có thể đổi tên:

* NotoSans-VariableFont\_wdth,wght.ttf

sang

* NotoSans-VariableFont-wdth-wght.ttf

Bước đổi tên đơn giản này sẽ giúp tránh xung đột và đảm bảo việc tích hợp các phông chữ biến thể trong tài liệu LaTeX của bạn diễn ra suôn sẻ.

### 3. Tạo một dự án Overleaf mới

* Tạo một dự án Overleaf mới và [đặt trình biên dịch thành LuaLaTeX](/latex/vi/co-so-tri-thuc/026-changing-compiler.md) vì đó là trình biên dịch duy nhất hỗ trợ phông chữ biến thể.
* Thêm `fontspec` gói vào phần mở đầu của tài liệu của bạn bằng cách viết `\usepackage{fontspec}`.
* Chọn biểu tượng tải tệp lên (![Image displaying Overleaf file-upload icon](/files/5b29f08c78eba33582e1654d3283db62c7e11e16)) để thêm các tệp phông chữ biến thể đã đổi tên cục bộ vào dự án mới của bạn:

![Hình ảnh minh họa cách tải tệp lên một dự án Overleaf](/files/b54f33a744e9c70204490cb140e560cda1408959)

### 4. (Tùy chọn) sắp xếp các tệp phông chữ của dự án

Nếu bạn muốn thử nghiệm với nhiều phông chữ khác nhau, chẳng hạn khi kiểm tra các thiết kế tài liệu, thì việc sắp xếp các tệp phông chữ bằng các thư mục dự án sẽ rất hữu ích. Tuy nhiên, khi biên dịch, LaTeX sẽ không tự động tìm kiếm phông chữ trong các thư mục dự án của bạn; bạn sẽ cần hỗ trợ LaTeX bằng cách dùng một tệp cấu hình cục bộ có tên [latexmkrc](/latex/vi/bai-viet-chuyen-sau/28-how-to-use-latexmkrc-with-overleaf.md). Chúng tôi sẽ không đi vào chi tiết ở đây, nhưng khuyên bạn nên tạo một thư mục dự án có tên `VariableFonts` và sao chép `latexmkrc` tệp được dùng trong [dự án đi kèm](https://www.overleaf.com/8438931911svtqtnmfvsrp#28008d).

## Trong bước tiếp theo

Bước 2 giới thiệu mô hình chọn phông chữ của LaTeX: New Font Selection Scheme, cung cấp thông tin nền quan trọng được dùng xuyên suốt phần còn lại của hướng dẫn này.

[Giới thiệu](https://www.overleaf.com/learn/latex/Articles/How_to_use_OpenType_variable_fonts_with_LaTeX?preview=true) [Bước 1](https://www.overleaf.com/learn/latex/Articles/Step_1:_Setting_up_an_Overleaf_project_to_use_variable_fonts?preview=true) [Bước 2](https://www.overleaf.com/learn/latex/Articles/Step_2:_An_introduction_to_LaTeX_fonts?preview=true) [Bước 3](https://www.overleaf.com/learn/latex/Articles/Step_3:_Replacing_LaTeX’s_default_fonts_with_variable_fonts?preview=true) [Bước 4](https://www.overleaf.com/learn/latex/Articles/Step_4:_How_to_configure_an_italic_variable_font_using_fontspec?preview=true) [Bước 5](https://www.overleaf.com/learn/latex/Articles/Step_5:_LaTeX_font_weights_and_named_instances_of_variable_fonts?preview=true) [Bước 6](https://www.overleaf.com/learn/latex/Articles/Step_6:_Using_variable_fonts_to_add_bold_fonts_to_an_Overleaf_project?preview=true) [Bước 7](https://www.overleaf.com/learn/latex/Articles/Step_7:_Using_Noto_Sans_and_Roboto_Mono_variable_fonts_with_LaTeX?preview=true) [Bước 8](https://www.overleaf.com/learn/latex/Articles/Step_8:_How_to_create_a_simple_LaTeX_package_to_configure_your_variable_fonts?preview=true) [Ví dụ và dự án](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/vi/bai-viet-chuyen-sau/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.
