load font from bundle problem

  • hi does anyone know why i cannot use a font I load from the bundle?
    Here is my code

    CFBundleRef    myAppBundle = NULL;
    CFURLRef        myAppResourcesURL = NULL;
    FSRef          myResourceDirRef;
    FSSpec          myResourceDirSpec;
    int status;
        NSArray    *fonts;
        NSEnumerator    *enumerator;
        NSString        *font;

    //first i load my font in from the bundle

    myAppBundle = CFBundleGetMainBundle ();

    if (NULL != myAppBundle) {
      myAppResourcesURL = CFBundleCopyResourcesDirectoryURL (myAppBundle);
      if (NULL != myAppResourcesURL) {
      (void) CFURLGetFSRef (myAppResourcesURL, &myResourceDirRef);
      status = FSGetCatalogInfo (&myResourceDirRef, kFSCatInfoNone, NULL,
      NULL, &myResourceDirSpec, NULL);
      if ( noErr == status ) {
        status = FMActivateFonts (&myResourceDirSpec, NULL, NULL,
        kFMLocalActivationContext);
      }
      }
    }

    //now i dump the list of fints to nslog and mine is there

        fonts = [[NSFontManager sharedFontManager] availableFonts];

        fonts = [[[NSFontManager sharedFontManager] availableFontFamilies]
    mutableCopy];
        [fonts sortUsingSelector: @selector(compare:)];
        enumerator = [fonts objectEnumerator];

        while (nil != (font = [enumerator nextObject]))
        {
            NSLog(font);
        }

        [fonts release];

    //but.. this works.. (a system font)
    [jobNameText setFont:[NSFont fontWithName:@"American Typewriter"
    size:13]];

    //and this crashes the machine (my font i loaded)
    [feedbackField setFont:[NSFont fontWithName:@"Bank Gothic BT"
    size:13]];

    error i get:

    Uncaught exception: <NSInvalidArgumentException> *** -[NSTextView
    setFont:]: nil NSFont given.
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
previous month july 2003 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today