DLL Issues on Mac OS

Hey All,

Bit of a pickle here. I am porting my project to Mac and have an issue with System.Drawing.
The library must be present on the Mac somewhere because when I add a reference to the mcs.rsp file, visual studio can pickup on sub classes of the library like System.Drawing.FONT.

//mcs.rsp file
-r:System.Drawing.dll
//Tried
-r:/Library/Frameworks/Mono.framework/Versions/5.16.0/lib/libgdiplus.0.dylib -target:framework System.Drawing

The error is related to libgdiplus.dylib, which to my knowledge is the mono port of system.drawing.
I have tried adding references to the gdiplus lib, even installed with HomeBrew. Nothing has worked.

For the sake of not fully understanding the problem Im facing, below is a code snip of what causes the error, and the error itself. Sorry for a big error dump, but its just there as Im not sure whats going wrong :face_with_spiral_eyes:

private void LoadFontFile(string path){
    fontCollection = new System.Drawing.Text.PrivateFontCollection();
    fontCollection.AddFontFile(path);
    font = new System.Drawing.Font(fontCollection.Families[0], fontRenderSize);
    ...
}
DllNotFoundException: /Users/builduser/buildslave/mono/build/external/buildscripts/add_to_build_results/monodistribution/lib/libgdiplus.dylib
System.Drawing.GDIPlus..cctor () (at <db84b41d92194c43bc99091ea8fb22ce>:0)
Rethrow as TypeInitializationException: The type initializer for 'System.Drawing.GDIPlus' threw an exception.
System.Drawing.Text.PrivateFontCollection..ctor () (at <db84b41d92194c43bc99091ea8fb22ce>:0)
CatalogueItemManager_Font.LoadFontFile (System.String path) (at Assets/Scripts/CatalogueItemManager_Font.cs:265)
..........

Note: I have also tried copying libgdiplus.dylib into the plugins folder and that didn’t do anything.

Im only borrowing a mates Mac, so I need to fix this today so I can build the app before having to give it back :(:frowning:

*Resolved

I found this earlier but overlooked.

Ended up being the fix.

1 Like

I’m trying to do something like this. Can you tell me how you fixed this? LINK

Hey, following the steps in the solution I linked kinda fixed the issue. Just gott do it correctly. Keep in mind Mono has not done the best port, I submitted a bug but never got a reply.

So I got the dll ported, and could do the above. But when I went on to rendering text it would always default Ariel no matter what font I chose

I tried your steps but its not woking for WebGl or Mobile Devices. I want to load some fonts to render mathml and its
loaded using System.Drawing.Text.PrivateFontCollection which is in .net version of system.drawing.text.
How do I solve this ?

Hey, do you have a mac you can test to see if it works on desktop? I have not done it for WebGL so I cannot give you any advice really. It may be possible that WebGl does not support it or needs steps to get working.