Incomplete workaround for: System.DLLNotFountException: Unable to load shared library 'freetype6' on MacOS Catalina when trying to use fonts.

Please bear with me, I only installed MonoGame today on my Mac, got very frustrate and came across the above error when trying to use the command:

dotnet tool run mgcb Content.mgcb

This made it impossible to render fonts as far as I know. Playing around and setting the environment value DYLD_PRINT_LIBRARIES
I discovered the libfreetype6.dylib file was broken(located under /Users//.nuget/packages/dotnet-mgcb/3.8.0.1375-develop/tools/netcoreapp3.1/any on my MacBook.

The workaround I found is very jank. I litterly did a

  • brew upgrade freetype (probably not relevant)
  • Located the following file libfreetype.6.dylib in finder
  • purged the broken libfreetype6.* files in the /tools/netcoreapp3.1/any folder and replaced the with the files asociated with libfreetype.6.dylip I found in finder
  • note the working version has a dot, I renamed the libfreetype.6.dylip file to match the old one.

These steps solved the error for me and I am able to render fonts now.

1 Like

Thanks, enabled me to render fonts and other assets also.

Thank you. Helped me with the same error. In case freetype is installed by homebrew, you can easily find a proper libfreetype.6.dylib by brew list freetype.

1 Like

I have been struggling to get my sprite font loaded for the past few days. I am using an M1 macOS laptop. I had already installed the c++ distributions for x64 that were recommended for the freeimage library to work. And, I had already gotten images to appear in game.

When I ran dotnet tool run mgcb Content.mgcb from in my project I was getting this error.

error: Processor 'FontDescriptionProcessor' had unexpected failure!
System.DllNotFoundException: Unable to load shared library 'freetype6' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libfreetype6, 0x0001): tried: 'libfreetype6' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibfreetype6' (no such file), '/usr/lib/libfreetype6' (no such file, not in dyld cache), 'libfreetype6' (no such file), '/usr/local/lib/libfreetype6' (no such file), '/usr/lib/libfreetype6' (no such file, not in dyld cache)
   at SharpFont.FT.FT_Init_FreeType(IntPtr& alibrary)
   at SharpFont.Library..ctor()
   at Microsoft.Xna.Framework.Content.Pipeline.Graphics.SharpFontImporter.Import(FontDescription options, String fontName) in /home/runner/work/MonoGame/MonoGame/MonoGame.Framework.Content.Pipeline/Graphics/Font/SharpFontImporter.cs:line 29
   at Microsoft.Xna.Framework.Content.Pipeline.Processors.FontDescriptionProcessor.ImportFont(FontDescription options, Single& lineSpacing, Int32& yOffsetMin, ContentProcessorContext context, String fontName) in /home/runner/work/MonoGame/MonoGame/MonoGame.Framework.Content.Pipeline/Processors/FontDescriptionProcessor.cs:line 194
   at Microsoft.Xna.Framework.Content.Pipeline.Processors.FontDescriptionProcessor.Process(FontDescription input, ContentProcessorContext context) in /home/runner/work/MonoGame/MonoGame/MonoGame.Framework.Content.Pipeline/Processors/FontDescriptionProcessor.cs:line 80
   at Microsoft.Xna.Framework.Content.Pipeline.ContentProcessor`2.Microsoft.Xna.Framework.Content.Pipeline.IContentProcessor.Process(Object input, ContentProcessorContext context) in /home/runner/work/MonoGame/MonoGame/MonoGame.Framework.Content.Pipeline/ContentProcessor.cs:line 60
   at MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.ProcessContent(PipelineBuildEvent pipelineEvent) in /home/runner/work/MonoGame/MonoGame/MonoGame.Framework.Content.Pipeline/Builder/PipelineManager.cs:line 717

I used brew info freetype to find where that the freetype library was installed to /opt/homebrew/Cellar/freetype/2.13.2/lib/libfreetype.6.dylib .

To solve the error above, I created a symlink from the homebrew library path to where monogame was actually looking: /usr/local/lib/libfreetype6.dylib .

The command I ran was ln -s /opt/homebrew/Cellar/freetype/2.13.2/libfreetype.6.dylib /usr/local/lib/libfreetype6.dylib/ .

Note: libfreetype.6.dylib became libfreetype6.dylib !

Note: If you get ln: /usr/local/lib/libfreetype.6.dylib: Permission denied , like I did, try running the same ln command with sudo before.

When running dotnet tool run mgcb Content.mgcb now, everything works and when I run my project I see the font displaying!