Custom Font with VSTGUI4

Hi Friends,

Is it possible to use custom font (added as say a …ttf or .otf resource) for controls say for CTextLabel ?
Could not find anything in the documentation.

Thanks a lot

I found some reference here… Problems with fonts - VSTGUI - Steinberg Forums

1 Like

there’s partial support in the latest release. It’s working for macOS, Linux and the latest Windows 10 version, Windows 7 is not supported. For Windows, you need to use at least the Windows 10 Creator Update SDK for compilation.
After that, you just need to place your fonts into a subfolder named “Fonts” inside your Resource directory (so you need to use the package structure for your plug-in). And then you can use these fonts by name in VSTGUI.



What needs to be done specifically to get custom fonts working without the user having to install them in their system?

1 Like

The font must be in a subfolder of the resources folder:


Have you confirmed that this really works on Linux? Because it doesn’t for us and we suspect a problem in the sdk.

Last time I checked it worked perfectly. You can check this yourself by building the standalone lib and its examples. The “Standalone” example loads a custom font and displays it.

It looks like that issue we had was fixed with Font rendering using Pango on X11 by jpcima · Pull Request #192 · steinbergmedia/vstgui · GitHub

I have used the following way in Windows:
Add in the *.rc file the following entry the name of your font,
such as DS-DIGIB.TTF.

#define digitalfont 2010
digitalfont FONT “DS-DIGIB.TTF”

The number 2010 is any resource id number.

Then double-click the font file so that Windows opens it for you and note the INTERNAL font file name, once done enter the
the following entries in your uidescription file :

< fonts >
< font font-name=“DS-Digital” name=“digitalfont50” size=“50”/ >
< font font-name=“DS-Digital” name=“digitalfont30” size=“30”/ >
< font font-name=“DS-Digital” name=“digitalfont25” size=“20”/ >
< font font-name=“DS-Digital” name=“digitalfont10” size=“10”/ >
< /fonts >

where DS-Digital is the internal font name.

The above is a method of using different font sizes of the same font and they can be used directly as font=“digitalfont10” wherever a font name is required.

1 Like

Hi Arne, I wish to know how I can do the following please…
I want whenever the mouse-pointer enters my control then the control size to change the size, like to be double its size (cause I don’t see very well) and the VSTGUI should allow the normal usage of fiddling with the control and when the mouse leaves the control then it should revert to its original size.

Ttf yes
otf no.


I am sorry to say that the above method works only for custom fonts that have already been installed in the system (Windows) but not for private fonts embedded as resources and for such cases please watch this space as I work that out and will provide the method here soon.


Microsoft Windows specific.

Definition of terms.

  1. System fonts.
    These come pre-existing with Windows, like Arial, MS Serrif, etc.

  2. User fonts.
    These are fonts the user has installed and they can be seen by all
    processes like Notepad. For our purposes these become the same as System fonts.

  3. Custom fonts. These are fonts embedded as resources in a PECOFF file, such as a dll.

Font file name: DS-DIGIB.TTF
Font face name: DS-Digital

For cases 1 and 2 nothing needs to be added to the resource file (*.rc)
and our uidescription file need only have the following entry for fonts
where each line specifies the desired size of the same font:

This is the ui-description file font node:
< fonts>
< font font-name=“DS-Digital” name=“digitalfont90” size=“90”/>
< font font-name=“DS-Digital” name=“digitalfont50” size=“50”/>
< font font-name=“DS-Digital” name=“digitalfont30” size=“30”/>
< font font-name=“DS-Digital” name=“digitalfont25” size=“20”/>
< font font-name=“DS-Digital” name=“digitalfont10” size=“10”/>
< /fonts>

The 3rd case would require a resource file whose contents can be just
the following few lines.:

// myXFont.rc
#include <windows.h>
#include “version.h”

VSTGUI.UIDESC DATA “./resources/vstgui.uidesc”

#define digitalfont 2010
digitalfont FONT “resources/DS-DIGIB.TTF”
#define techfont 2040
techfont FONT “resources/TECHNCLI.TTF”
// end of myXFont.rc

The uidescription file remains the same and the only changes are the
following which I inserted in the Controller::initialize(FUnknown* context)
because after all the font is used by the controller.
The code is self-explanatory, of which we needn’t have to use had the GDI function
AddFontMemResourceEx been better designed.

// start of code
/// custom font stuff
// these constants are here just for simplicity, you can put them in a header file.
#define digitalfont 2010
#define techfont 2040

// find the resource
if (HRSRC hResInfo = FindResource((HMODULE)moduleHandle, MAKEINTRESOURCE(digitalfont), RT_FONT))
// found. load it
HGLOBAL mem = LoadResource((HMODULE)moduleHandle, hResInfo);

if (mem)
	// loaded. lock it
	void* data = LockResource(mem);

	// get its size
	size_t len = SizeofResource((HMODULE)moduleHandle, hResInfo);

	// a dummy file name
	wchar_t myCustFontFileName[] = L"myCustFontFileName.ttf\0";


	// create a temporary file. ideally this should be a memory file, FILE_ATTRIBUTE_TEMPORARY,
	// but for now whatever suffices will do
	HANDLE hFile =

	if (hFile)
		OutputDebugString(L"PASS CreateFile\n");

		DWORD NumOfBytesWrit = 0;

		// write our font resource into the temp file
		if (WriteFile(hFile, data, len, &NumOfBytesWrit, NULL))
			OutputDebugString(L"PASS WriteFile\n");

			// save the contents

			// ideally we should have used AddFontMemResourceEx
			if (AddFontResource(myCustFontFileName))
				OutputDebugString(L"PASS AddFontResource\n");
				OutputDebugString(L"FAIL AddFontResource\n");
			OutputDebugString(L"FAIL WriteFile\n");
			//formatmessage(L"FAIL WriteFile", GetLastError());
		OutputDebugString(L"FAIL CreateFile\n");
	OutputDebugString(L"Could NOT LoadResource\n");

else OutputDebugString(L"Resource NOT found\n");
// end of code

The embedded font is now usable and the ui-description parser will see it.
The code does not show how to remove the font, or delete the temporary file, that is an exercise for you.

Do not forget to include the following line to your controller.cpp
extern void* moduleHandle; // for font

More examples of custom fonts…