Garry's Mod Wiki

Revision Difference

Finding_the_Font_Name#522288

<cat>Dev</cat> To use your font you need to know the name of your font to use it in <page>surface.CreateFont</page>. The font name is **not** a file name. Your file can have any name, GMod finds the font only by its real name. To use your font in game you need to know the name of your font. This is required for <page>surface.CreateFont</page>. The font name is **not** a file name of that font. Your file can have any name, GMod finds the font only by its real name. Make sure your font is .ttf, it's in your `resource/fonts/` folder and it's included for downloading. <note>It's generally good practice to keep file paths lowercase using underscores(`_`) or hyphens(`-`) for spaces. Example: `resources/fonts/arial_bold.ttf`</note> <note>It's generally good practice to keep file paths lowercase using underscores(`_`) or hyphens(`-`) for spaces, especially on Linux. Example: `resources/fonts/arial_bold.ttf`</note> # Windows 1. Right click on your font and click `Preview` or double click it <upload src="19952/8d7ac8f0fde3c86.png" size="4373" name="111.png" /> 2. In opened window find `Font name:` line <upload src="19952/8d7ac8f56346600.png" size="11641" name="fontview_HV8L4tuEW0.png" /> 3. The name goes after `Font name: ` (In this example, it's `Digital-7 Mono`) <upload src="19952/8d7ac8f88417667.png" size="6024" name="fontview_NyCOKo3ZRc.png" /> Example <page>surface.CreateFont</page>: ``` surface.CreateFont({ font = "Digital-7 Mono", size = 15 }) ``` # MacOS # Linux ## Ubuntu / Linux Mint: `GNOME Font Viewer`⤶ Ubuntu, Linux Mint, and compatible distros can use the `gnome-font-viewer` package to preview fonts easily. After opening the file you can find the font name either in the window title, preview or info section. Below is an example on Linux Mint 19.3 Cinnamon and the Arial font. ⤶ ## GNOME Font Viewer⤶ Package name: [`gnome-font-viewer`](https://snapcraft.io/gnome-font-viewer) ⤶ 1. Open the font⤶ ⤶ 2. Find the label at the center of the top menu (In this example, it's `Arial`, style is not a part of the font here)⤶ 3. Additionally you can check the font name by click `Info` on the top menu and find `Name: `⤶ <upload src="8d978/8d7acd56a1f3bec.png" size="95226" name="gnome-font-viewer_arial_example.png" /> As seen in the example image the font name is `Arial` and the style is `Regular`. GMod only needs the name⤶ Example <page>surface.CreateFont</page>: ``` surface.CreateFont({ font = "Arial", size = 15 }) ```⤶ ⤶ ## If desired GNOME Font Viewer can be installed on the below distros or derivatives ⤶ Arch, CentOS, Debian, elementary OS, Fedora, KDE Neon, Manjaro, and openSUSE⤶ ⤶ See https://snapcraft.io/gnome-font-viewer for details```