You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 7, 2025. It is now read-only.
Trying to use a C# application that calls System.PrivateFontCollection.AddMemoryFont on Linux leaves a bunch of unused font files in the tmp folder, even after calling Dispose.
Most functions in Mono's PrivateFontCollection are simply wrappers to libgdiplus calls, so I guess the bug originates from here.
Digging through the source code, it seems that this piece of code here is responsible:
#ifdef WIN32
f = CreateTempFile (fontfile);
if (!f)
return FileNotFound;
if (fwrite(memory, sizeof(BYTE), length, f) != length) {
fclose (f);
return FileNotFound;
}
fclose (f);
#else
strcpy ((char *) fontfile, "/tmp/ffXXXXXX");
f = mkstemp ((char *) fontfile);
if (f == -1)
return FileNotFound;
if (write (f, memory, length) != length) {
close (f);
return FileNotFound;
}
close (f);
#endif
FcConfigAppFontAddFile (fontCollection->config, fontfile);
/* FIXME - May we delete our temporary font file or does
FcConfigAppFontAddFile just reference our file? */
/* unlink(fontfile); */
return Ok;
After research, at least on my Ubuntu 20.04 machine, FcConfigAppFontAddFile simply references that file, deleting the font makes the app crash when a new Form or Control is drawn. However, the function does not seem to save the temp files anywhere.
Trying to use a C# application that calls
System.PrivateFontCollection.AddMemoryFonton Linux leaves a bunch of unused font files in thetmpfolder, even after callingDispose.Most functions in Mono's PrivateFontCollection are simply wrappers to
libgdipluscalls, so I guess the bug originates from here.Digging through the source code, it seems that this piece of code here is responsible:
After research, at least on my Ubuntu 20.04 machine,
FcConfigAppFontAddFilesimply references that file, deleting the font makes the app crash when a new Form or Control is drawn. However, the function does not seem to save the temp files anywhere.