none
Receiving runtime error in my .NET application because certain fonts are no longer included in the Windows Server Core 2019 base image RRS feed

  • Question

  • I originally opened an issue on GitHub for this problem https://github.com/Microsoft/dotnet-framework-docker/issues/217. Under the guidance of Michael Simons, I am reposting this question here. Any help or insight would be greatly appreciated.

    It appears that all of the windows fonts except lucon.ttf have been eliminated in the server core 2019 base images. My .NET application no longer runs using the latest microsoft/dotnet-framework:4.7.2-runtime. I receive the exception: System.InvalidOperationException: Cannot read the file for font: Arial
    I am using GrapeCity Active Reports 12 to generate a pdf. When I swap fonts in my Active Reports code to Lucida Console, the pdf will generate. If I specify 1803 as my base image, the application will work; however, this doesn't seem like a good long term solution.

    Has anyone else run into a similar problem?

    Does anyone have a suggestion for registering the fonts?

    I have attempted several methods for registering the fonts:
    http://code.kliu.org/misc/fontreg/
    https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-windows-containers-custom-fonts
    https://www.itprotoday.com/powershell/trick-installing-fonts-vbscript-or-powershell-script

    None of these have worked for me.


    Matt Christensen

    Thursday, February 14, 2019 1:49 AM

All replies

  • Greetings,

    Do you have some error output when following line is executed?

    RUN ${source:-obj/Docker/publish/InstallFont.ps1}


    Sic Parvis Magna

    Thursday, February 14, 2019 2:50 AM
  • I used this script for install font with powershell.

    https://blogs.technet.microsoft.com/deploymentguys/2010/12/04/adding-and-removing-fonts-with-windows-powershell/

    Then build docker image with RUN installfont script.
    For fonts folder just put all ttf file inside.

    FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8
    WORKDIR  c:/inetpub/wwwroot
    ADD installfont.ps1 .
    ADD fonts ./fonts
    RUN powershell ./installfont.ps1 ./fonts





    • Edited by ToomMan Monday, June 24, 2019 7:09 PM
    Monday, June 24, 2019 6:56 PM
  • This not help for me at servercore:lts2019
    Wednesday, June 26, 2019 1:12 AM
  • Hi,

    Did you find a solution by any chance ?

    I have the same problem...

    I am trying to use textcontrol.com's control in MVC ASP.net And I only have Lucida Console.

    I tried most of the tests you did before finding your post and like you, had no success...

    Hope you found a way since february.

    Thanks in advance

    Wednesday, August 14, 2019 9:01 PM
  • Hmmm I finally found a way to do this...

    Hope it will help someone else:

    Credits should go to this guy as it contains the solution: https://4sysops.com/archives/install-fonts-with-a-powershell-script/

    I copied all ".ttf" files from c:\windows\fonts to a "Fonts" directory in my Docker Folder. I excluded the lucon.ttf file since it's already included in the image.

    In My dockerfile, I have this:

    SHELL ["powershell"]

    ## Copy fonts as the servercore image has none ##
    ## I copied all files from c:\windows\fonts but had to remove lucon.ttf ##
    COPY Fonts/* /Temp/Fonts/
    COPY Scripts/* /Temp/
    RUN c:\temp\FontsInstall.ps1

    Here is my simplified version of the script for docker:

    $sFontsFolder = "C:\Temp\Fonts";
    $sRegPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts";

    $objShell = New-Object -ComObject Shell.Application;

    $objFolder = $objShell.namespace($sFontsFolder);

    foreach ($objFile in $objFolder.items()) {
        
        $objFileType = $($objFolder.getDetailsOf($objFile, 2));
        $sFontName = $($objFolder.getDetailsOf($objFile, 21));
        $sRegKeyName = $sFontName, "(Open Type)" -join " ";
        $sRegKeyValue = $objFile.Name;

        Copy-Item $objFile.Path "c:\windows\fonts";
        $null = New-ItemProperty -Path $sRegPath -Name $sRegKeyName -Value $sRegKeyValue -PropertyType String -Force;
    }

    Worked like a charm for me...

    Wednesday, August 14, 2019 10:58 PM