[Mono-osx] How to load custom font

mrgutis mrgutis at gmail.com
Thu Jun 30 05:37:52 EDT 2011


I am using
/
string urlString = NSBundle.MainBundle.PathForResource("MyFont", "otf");
NSUrl url = new NSUrl(urlString);			
NSError error = CTFontManager.RegisterFontsForUrl(url,
CTFontManagerScope.Session);/
in AppDelegate's FinishedLaunching method (while tried in different places
with no effect on stopping crashes). Now I can see that font loaded
succesfully and I can use it but application becomes unstable - draggin
and/or resizing it crashes. While resizing tends to crash more often.
I am using Mac OS X 10.6.7, MonoDevelop 2.4.2, Mono 2.10.2
Here's what i get in console on crash:

Loaded assembly:
/Users/virginijus/Projects/CrashTest/CrashTest/bin/Debug/CrashTest.app/Contents/Resources/CrashTest.exe
Loaded assembly:
/Users/virginijus/Projects/CrashTest/CrashTest/bin/Debug/CrashTest.app/Contents/Resources/MonoMac.dll
[External]
Loaded assembly:
/Library/Frameworks/Mono.framework/Versions/2.10.2/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll
[External]
Loaded assembly: ObjCImplementations [External]
Loaded assembly:
/Library/Frameworks/Mono.framework/Versions/2.10.2/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
[External]
Loaded assembly:
/Library/Frameworks/Mono.framework/Versions/2.10.2/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll
[External]
Stacktrace:

  at (wrapper managed-to-native)
MonoMac.ObjCRuntime.Messaging.void_objc_msgSend (intptr,intptr) <IL 0x00024,
0xffffffff>
  at MonoMac.Foundation.NSObject/MonoMac_Disposer.Drain
(MonoMac.Foundation.NSObject) [0x0007b] in
/cvs/monomac/src/Foundation/NSObject.cs:364
  at (wrapper dynamic-method)
object.[MonoMac.Foundation.NSObject+MonoMac_Disposer.Void
Drain(MonoMac.Foundation.NSObject)]
(MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector,MonoMac.Foundation.NSObject)
<IL 0x00011, 0x0004d>
  at (wrapper native-to-managed)
object.[MonoMac.Foundation.NSObject+MonoMac_Disposer.Void
Drain(MonoMac.Foundation.NSObject)]
(MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector,MonoMac.Foundation.NSObject)
<IL 0x000b6, 0xffffffff>
  at (wrapper managed-to-native)
MonoMac.AppKit.NSApplication.NSApplicationMain (int,string[]) <IL 0x0009d,
0xffffffff>
  at MonoMac.AppKit.NSApplication.Main (string[]) [0x00000] in
/cvs/monomac/src/AppKit/NSApplication.cs:74
  at CrashTest.MainClass.Main (string[]) [0x00005] in
/Users/virginijus/Projects/CrashTest/CrashTest/Main.cs:15
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object
(object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

Native stacktrace:

	0   CrashTest                           0x000b6ea9 0x0 + 749225
	1   CrashTest                           0x00006e0e 0x0 + 28174
	2   libSystem.B.dylib                   0x9070905b _sigtramp + 43
	3   ???                                 0xffffffff 0x0 + 4294967295
	4   ???                                 0x02ba5cf4 0x0 + 45767924
	5   ???                                 0x0172e146 0x0 + 24305990
	6   ???                                 0x01721454 0x0 + 24253524
	7   Foundation                          0x93ee0711 __NSThreadPerformPerform
+ 506
	8   CoreFoundation                      0x9654d45b __CFRunLoopDoSources0 +
1563
	9   CoreFoundation                      0x9654af1f __CFRunLoopRun + 1071
	10  CoreFoundation                      0x9654a3f4 CFRunLoopRunSpecific +
452
	11  CoreFoundation                      0x9654a221 CFRunLoopRunInMode + 97
	12  HIToolbox                           0x96e57e04
RunCurrentEventLoopInMode + 392
	13  HIToolbox                           0x96e57af5 ReceiveNextEventCommon +
158
	14  HIToolbox                           0x96e57a3e
BlockUntilNextEventMatchingListInMode + 81
	15  AppKit                              0x9416e595 _DPSNextEvent + 847
	16  AppKit                              0x9416ddd6 -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:] + 156
	17  AppKit                              0x942ef371 -[NSView
_getNextResizeEventInvalidatingLiveResizeCacheIfNecessary:] + 133
	18  AppKit                              0x942ed589 -[NSTitledFrame
resizeWithEvent:] + 597
	19  AppKit                              0x942ec3f7 -[NSTitledFrame
mouseDown:] + 142
	20  AppKit                              0x942ec35e -[NSThemeFrame
mouseDown:] + 153
	21  AppKit                              0x94283a58 -[NSWindow sendEvent:] +
5549
	22  AppKit                              0x9419c60b -[NSApplication
sendEvent:] + 6431
	23  AppKit                              0x94130253 -[NSApplication run] +
917
	24  AppKit                              0x94128289 NSApplicationMain + 574
	25  ???                                 0x026f71dc 0x0 + 40858076
	26  ???                                 0x026f6fd6 0x0 + 40857558
	27  ???                                 0x003d7ff8 0x0 + 4030456
	28  ???                                 0x003d8156 0x0 + 4030806
	29  CrashTest                           0x000112c4 0x0 + 70340
	30  CrashTest                           0x001bd83c 0x0 + 1824828
	31  CrashTest                           0x001bfe35 0x0 + 1834549
	32  CrashTest                           0x001bf21f 0x0 + 1831455
	33  CrashTest                           0x000884c2 0x0 + 558274
	34  CrashTest                           0x00003a46 0x0 + 14918

Debug info from gdb:

/tmp/mono-gdb-commands.lYvxFr:1: Error in sourced command file:
unable to debug self

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================


--
View this message in context: http://mono.1490590.n4.nabble.com/How-to-load-custom-font-tp3610794p3635208.html
Sent from the Mono - OSX mailing list archive at Nabble.com.


More information about the Mono-osx mailing list