Bug 12576 - FontFamilyNotFound exception from bundled Xamarin.Mac app on OS X 10.7
Summary: FontFamilyNotFound exception from bundled Xamarin.Mac app on OS X 10.7
Status: RESOLVED FIXED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: mmp ()
Version: 1.2.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2013-06-06 11:51 UTC by Andrew
Modified: 2013-06-07 13:43 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 Developer Community or GitHub 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 FIXED

Description Andrew 2013-06-06 11:51:50 UTC
Details and diagnostic output can be found at http://forums.xamarin.com/discussion/4151/fontfamilynotfound-exception-from-bundled-xamarin-mac-app-on-os-x-10-7#latest

Getting a FontFamilyNotFound exception when trying to run an app bundled using Xamarin.Mac on a client machine running Mac OS X 10.7 .

Already using the patched version of mmp as per the private bug report at https://bugzilla.xamarin.com/show_bug.cgi?id=11351#c7

Project sources don't appear to have space in them, which I believe is another potential cause of mmp issues.
Comment 1 Sebastien Pouliot 2013-06-06 15:21:45 UTC
That's not a packaging issue. Your logs shows that both the library and symbol were found.

'/Applications/iPhoneBackupExtractor.app/Contents/MonoBundle/libgdiplus.dylib'. Mono: Searching for 'GdipGetGenericFontFamilyMonospace'. Mono: Probing 'GdipGetGenericFontFamilyMonospace'. Mono: Found as 'GdipGetGenericFontFamilyMonospace'

The stack trace shows that libgdiplus returned a FontFamilyNotFound when asked for GenericSansSerif. That's likely because the target Mac does not have the font available (it's looking for "Courrier New").

Note: with 1.4 you do not need the patched version of mmp anymore (or be worried about the spaces).
Comment 2 Andrew 2013-06-06 15:56:27 UTC
Thanks for that. Apologies if this is a thick question - I'm new to Mono and Macs in general - but is there a way to bundle the font with our application? As far as I'm aware it's a standard font that presumably comes with Mono (as when we've run the application on machines with Mono in the past we've not had to install any new fonts)

Also is 1.4 available for download yet? I used the 'check for updates' option in Xamarin Studio and that downloaded Studio version 4.0.8 but didn't say there were any Xamarin.Mac updates available.
Comment 3 Sebastien Pouliot 2013-06-07 08:41:14 UTC
I never bundled fonts but I know it's possible to do so using extra entries in the plist (similar, but not identical, to iOS). However I'm not sure if libgdiplus support them (never used it on OSX). But let's make sure this is the real (and only) issue here first.

I do not think Mono bundles any fonts - but I could be wrong, c.c. Duncan

In any case look at your systems (working and non-working) to check about the font availability. See http://support.apple.com/kb/ht2435 to locate the fonts on the systems

IIRC 1.4 was beta last week and was promoted to stable this week (Duncan?)
Comment 4 Andrew 2013-06-07 10:22:35 UTC
So I've rebuilt our app using the latest version of Xamarin Studio (on a Mac with OS X 10.8.3 and Mono 2.10.12 installed) . 

The app works fine when run on our 10.8.3 build Mac.

I then deployed to a test Mac running OS X 10.7.5 and Mono not installed (all other defaults on the Mac as per a brand new install). I'm getting a similar but slightly different FontFamilyNotFound error - this time concerned with the GenericSansSerif font family. I understand this refers to the Microsoft Sans Serif font.

I can confirm both Courier New.ttf and Microsoft Sans Serif.ttf are present in /Library/Fonts on both the 10.7 and 10.8 Macs. I wonder if there could be any connection with this bug report: https://bugzilla.xamarin.com/show_bug.cgi?id=7962

Stacktrace below:

Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.WindowsFormsSynchronizationContext ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.ThemeEngine ---> System.ArgumentException: The requested FontFamily could not be found [GDI+ status: FontFamilyNotFound]
  at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000] in <filename unknown>:0 
  at System.Drawing.FontFamily..ctor (GenericFontFamilies genericFamily) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.FontFamily:.ctor (System.Drawing.Text.GenericFontFamilies)
  at System.Drawing.FontFamily.get_GenericSansSerif () [0x00000] in <filename unknown>:0 
  at System.Drawing.Font.CreateFont (System.String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte charSet, Boolean isVertical) [0x00000] in <filename unknown>:0 
  at System.Drawing.Font..ctor (System.String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont) [0x00000] in <filename unknown>:0 
  at System.Drawing.Font..ctor (System.String familyName, Single emSize, System.String systemName) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.Font:.ctor (string,single,string)
  at System.Drawing.SystemFonts.get_DefaultFont () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Theme..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ThemeWin32Classic..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ThemeVisualStyles..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ThemeEngine..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
  at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ContainerControl..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Form..ctor () [0x00000] in <filename unknown>:0 
  at iPhoneBE.Forms.FormMain..ctor () [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) iPhoneBE.Forms.FormMain:.ctor ()
  at iPhoneBE.Program.Main () [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.WindowsFormsSynchronizationContext ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.ThemeEngine ---> System.ArgumentException: The requested FontFamily could not be found [GDI+ status: FontFamilyNotFound]
  at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000] in <filename unknown>:0 
  at System.Drawing.FontFamily..ctor (GenericFontFamilies genericFamily) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.FontFamily:.ctor (System.Drawing.Text.GenericFontFamilies)
  at System.Drawing.FontFamily.get_GenericSansSerif () [0x00000] in <filename unknown>:0 
  at System.Drawing.Font.CreateFont (System.String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte charSet, Boolean isVertical) [0x00000] in <filename unknown>:0 
  at System.Drawing.Font..ctor (System.String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont) [0x00000] in <filename unknown>:0 
  at System.Drawing.Font..ctor (System.String familyName, Single emSize, System.String systemName) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.Font:.ctor (string,single,string)
  at System.Drawing.SystemFonts.get_DefaultFont () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Theme..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ThemeWin32Classic..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ThemeVisualStyles..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ThemeEngine..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
  at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ContainerControl..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Form..ctor () [0x00000] in <filename unknown>:0 
  at iPhoneBE.Forms.FormMain..ctor () [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) iPhoneBE.Forms.FormMain:.ctor ()
  at iPhoneBE.Program.Main () [0x00000] in <filename unknown>:0
Comment 5 Sebastien Pouliot 2013-06-07 13:30:57 UTC
It's using "MS Sans Serif.ttf" not "Microsoft Sans Serif.ttf" - but that's the name provided to FontConfig library (not necessarily the file that will be used).

Otherwise it does seems identical to #7962.  It looks like there's some dependency (or configuration*) on X window (which is present once xquartz is installed).

* you might want to compare both system wrt http://en.wikipedia.org/wiki/Fontconfig#Configuration
Comment 6 Rodrigo Kumpera 2013-06-07 13:42:32 UTC
This has been fixed on master and will be part of mono 3.0.12.
Comment 7 Rodrigo Kumpera 2013-06-07 13:43:06 UTC
To clarify things, this is a bug in how we built fontconfig so a newer one needs to be used.