Source SDK

Source SDK

Not enough ratings
Converting TTF ↔️ VFONT
By мяFunreal
Learn to convert TTF fonts into Source's proprietary VFONT format, and back.
Also covers how to use them in a .res file, or as entire font replacement.
   
Award
Favorite
Favorited
Unfavorite
Foreword
As you may know, Valve games can work with a VFONT format, instead of TTF.

This guide here teaches you how to convert ttf to vfont, and how to convert vfont back to ttf.
The process is simple, but the tools required aren't shipped with most games.
I managed to take them from L4D:Survivors. That Japanese Arcade game.

According to ZeqMacaw, the developer of crowbar, the conversion pretty simple.
So simple, that he considered adding font conversion right into crowbar.
Should that day come, i'll update this guide. For now, we'll use the original tools valve used.
Requirements.
Download the vfont tools here.[drive.google.com]
Unpack the zip file into your game's "Bin" folder.


I took the liberty to add a fancy icon to the vfont exe, because I could.
The decompiler has none, because it stopped working when I did that. lmao.

vfont.exe
Converts TTF to VFONT
vfont_decompiler.exe
Converts VFONT to TTF
vfont_handler.bat
The Decompiler doesn't support drag and drop, this is required as surrogate.
It handles both conversion from TTF↠VFONT, and VFONT↠TTF

Using the Tools
The usage is simple as can be, thanks to my .bat file.
Draging a .ttf onto vfont.exe would convert it to .vfont.
But the decompiler to turn .vfont to .ttf requires an additional argument (-d).
Technically the decompiler can also turn ttf into vfont, making vfont.exe kinda obsolete.

Anyways, i made a bat file that does whatever you need by dropping .ttf or .vfont onto it.

Open the "vfont_handler.bat" in a text editor and set the Gamedir at the top.


Then drag either a .ttf or a .vfont onto it and watch it convert it to the proper counterpart.
Using the Fonts
There's two ways to use fonts:
1. Making the .res files use your new vfont where needed. For when you make your own game.
2. Swapping the entire vfont file. Mods would do this because its way easier than editing the .res.

Whichever you want to do you need to find out what vfont is currently used.

Open your games used scheme file(s) in the "Resource" folder.
I'm doing it for L4D2, so I open "l4d360uischeme.res".

Depending on which game you modify, you'll have it in wildly folders, and sometimes in VPK files.
For L4D2, it would be Pak01_dir.vpk in "steamapps\common\Left 4 Dead 2\update"
For other games i'd reccomend you to check your gameinfo.txt.
The top most folder listed in the "Game" listing has the most recent files.
Check that folder, and that folders pak01_dir.vpk file for your res files.
If they're not in there, look for the second folder listed in the gameinfo and work your way down.

You'll need to scroll down to the font fields and check what font is used for what.
For example, the default font uses "Stubble bold"


Or SourceScheme.res holds all the stuff for the main source engine.
Like the line for the ingame console text file, uses Lucida Console.
But that's a windows native True Type Font.


Editing .res to load new font.
Check what name the font has.
Not the file name, but the name of the font saved within it.
Do this by double clicking the ttf file. A font preview window opens, telling you the font name.


That name is the one you'd need in the .res files "name" field.
The .res file once defines what ttf and vfont files to load, and then uses this name to pick the fonts.

To add any font, paste it in your game's "Rescource" folder, then open your game's scheme file.
Scroll to the bottom and add a new number, then define the font.
Make sure no other scheme file has the number already used for a font.
If the font file name has a space, use a - when you define it here. Or just not use spaces.


Then use the name saved inside the ttf for the .res files font definition.


Now you're done.
I used Comic Sans MS as console text. Because i'm masochistic.
Also to prove that using OS native ttf fonts also works, without even defining fonts.


Replacing Vfont Approach
Go to your game's Resource folder, find the vfont you want to swap out.
In my case, I want to swap "Stubble bold", because its the L4D2 menu font.

Make a backup of the .vfont file.
Take the font you converted from ttf to vfont and give it the name of the original.


Done. Load the game and look at your handywork.


Note:
Vfont file replacements do not work inside addon.vpk files, like a L4D2 workshop mod.
All vfont mods must be installed manually like this.


Don't forget that some Fonts do have copyright and you need to purchase a license.
Closing Words
Yeah that's pretty much it.
Only annoyance is that the tools are were so hard to come by.

Should you need help with this process, join the "Dead 4 Mods" Discord Server[discord.gg].
There's a few members, including me, who can help you out.

Please for the love of Lucifer, do not join and immediately DM me.
I've got enough people using me like google for the simplest questions.

I have my own Discord Server[discord.gg] if you'd like to hop in and chat.
I sometimes post WIP images of what i'm doing, but it's mostly memes.

I also got Paypal[paypal.me] for don't-ations.