Bug 22931 - Changing fontconfig cache location via XDG_CACHE_HOME environment variable broken in Mono 3.8
Summary: Changing fontconfig cache location via XDG_CACHE_HOME environment variable br...
Status: RESOLVED ANSWERED
Alias: None
Product: Installers
Classification: Mono
Component: General ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Chris Hamons
URL:
Depends on:
Blocks:
 
Reported: 2014-09-12 08:38 UTC by John Conners
Modified: 2017-05-16 18:48 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description John Conners 2014-09-12 08:38:00 UTC
Building a Xamarin.Mac app against Mono 3.6 if I run the following code:

Environment.SetEnvironmentVariable( "XDG_CACHE_HOME", "~/Desktop" );
using( var img = new System.Drawing.Bitmap( 100, 100 ) ) {}

The result would be a fontconfig folder would be created on the desktop and populated, then used for the app going forwards. Updating to Mono 3.8 this is now broken and if the '~/Desktop/fontconfig' folder or contents are missing it instead creates the cache folder here:

~/Library/Caches/com.xamarin.fontconfig

This is a regression and will cause problems submitting apps to the Mac App Store. The guidelines indicate you should use a cache folder of the form (which is what I'm doing in my app):

~/Library/Caches/com.mycompany.myapp

And this is no longer possible while the bug I'm reporting exists. If there's another way to change the default fontconfig cache folder then that would be a great workaround, but I've not found it.

I downgraded to Mono 3.6 and the previous behaviour returns.
Comment 1 John Conners 2014-09-13 11:37:56 UTC
On further investigation it looks like the following section in Mono.framework/Versions/3.8.0/etc/fonts/fonts.conf is causing the problem:

	<cachedir>~/Library/Caches/com.xamarin.fontconfig</cachedir>
	<cachedir prefix="xdg">fontconfig</cachedir>
	<!-- the following element will be removed in the future -->
	<cachedir>~/.fontconfig</cachedir>

Previously the first cachedir entry was an absolute path that didn't actually exist, so it would fall back to XDG_CACHE_HOME if set, then ~/.fontconfig.

Now, it looks like XDG_CACHE_HOME is ignored if set and it sticks to the first one (unless the cache directory has already been created). I can work around it by simply deleting that first cachedir entry and then XDG_CACHE_HOME is picked up, but it's definitely a change of behaviour.
Comment 2 Rodrigo Kumpera 2014-10-03 08:41:02 UTC
Chris,

This happens because of the changes we did to fontconfig to accommodate that issue with the cache not been ever created. Do you think we can handle both?
Comment 3 Chris Hamons 2017-05-16 18:48:37 UTC
So Xamarin.Mac "fixed" this by not shipping mono's System.Drawing anymore.

We push people to use https://github.com/mono/sysdrawing-coregraphics for this along with libgdiplus issues.