Installing Missing Fonts in Windows Server Core Docker Images

,

Visual Studio now offers very simple support for Docker. In just a few steps, you can deploy your application in a Docker container.

Mostly, Windows Server Core Docker images are used as a basis in the Dockerfile. These have the advantage of being very lean, but are limited in functionality. Among other things, fonts are missing, which are available in “normal” Windows. For example, only the Lucon font is available in the Windows Server Core 2019 image.

If you now want to deploy an application with List & Label in a Docker container, the necessary fonts for generating the reports are missing. To provide them in the container, please proceed as follows:

  • Add a folder with the required fonts to your Visual Studio project.
  • When you start your application, you can use the Windows API AddFontResource to install the fonts for the current session.

Code example for C#:

[DllImport("gdi32.dll")]
static extern int AddFontResource(string lpFilename);
AddFontResource(@"<Path to the fonts>\<Font name>.ttf");

© combit GmbH