Working with Fonts
From GMod Wiki
The default font used in most functions won't serve for many of your uses. Often there will be a need to use a different one so that the text is possible to see for a player, or has the impact that you want it to. You can either use an existing font or import one into the game with surface.CreateFont. In this article is a list of the default fonts and images of what they look like in game.
Here is a list of the functions and methods that allow you to change fonts:
- Panel:SetFont on the following controls:
Below is a list of fonts that exist by default in Garry's Mod:
DebugFixed DebugFixedSmall DefaultFixedOutline MenuItem Default TabLarge DefaultBold DefaultUnderline DefaultSmall DefaultSmallDropShadow DefaultVerySmall DefaultLarge UiBold MenuLarge ConsoleText Marlett Trebuchet18 Trebuchet19 Trebuchet20 Trebuchet22 Trebuchet24 HUDNumber HUDNumber1 HUDNumber2 HUDNumber3 HUDNumber4 HUDNumber5 HudHintTextLarge HudHintTextSmall CenterPrintText HudSelectionText DefaultFixed DefaultFixedDropShadow CloseCaption_Normal CloseCaption_Bold CloseCaption_BoldItalic TitleFont TitleFont2 ChatFont TargetID TargetIDSmall HL2MPTypeDeath BudgetLabel
surface.CreateFont( "akbar", 48, 500, true, true, "MyFont" )
This will create a font called "MyFont". Custom fonts persist even if the game server (local or network) is reloaded, so if the font "MyFont" already exists then nothing will be created. However, you can call the console command gm_clearfonts to clear all of the known custom fonts. This is a developer console command and should never be called from a mod/gamemode. If you make a change to a surface.CreateFont function in a script while the game is running, you will need to run gm_clearfonts in order for the changes to your font(s) to show.
To use a font, self made or otherwise, simply use the name of it in place of the 'font' argument, such as:
draw.SimpleText( "Hello!", "MyFont", 100, 100, color_white )
- There doesn't seem to be code in place to warn a user if they used an invalid font in a function, particularly in panels. If your font doesn't show up or shows up as the default font, then make sure that you entered the correct name and that the font you're using actually exists.