bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fix, NSFont, XGFont (was RTFConsumer)


From: Georg Fleischmann
Subject: Fix, NSFont, XGFont (was RTFConsumer)
Date: Wed, 9 Oct 2002 23:27:59 GMT

Hi Nicola,

Well, here is the long waiting change for NSFont. It's most exactly how you  
suggested.

> Looks like [NSFont -initWithName:matrix:] is our own extension, and likely
> it should return nil if the font can't be found (it now returns the
> default font if I understand correctly).
>
> In that case I suppose we need to change GSFontInfo to return nil (rather
> than a font info for a default font) if the font is not found.
>
> NSFont -initWithName:matrix: will then check the created font info, and if
> it's nil, it will destroy self and return (nil) as well.

Now, with the changes NSFontManager's -convertFont methods work as they  
should. All seems to work fine - I got no crash :-)
My suggested RTFConsumer changes work much better, too. I will send the  
RTFConsumer patch in a separate mail with some additional comments.

Georg



2002-10-09  Georg Fleischmann
        * gui/Source/NSFont.m [-initWithName:matrix:fix:]:
          return nil, if fontInfo == nil.
          This makes [NSFontManager -convertFont:...] work.
        * back/Source/x11/XGFont.m [-setupAttributes]:
          return NO, if fontName is not available



*** gui/Source/NSFont.m.old     Wed Oct  9 17:49:01 2002
--- gui/Source/NSFont.m Wed Oct  9 22:05:57 2002
***************
*** 602,607 ****
--- 602,612 ----
        matrixExplicitlySet = explicitlySet;
        fontInfo = RETAIN([GSFontInfo fontInfoForFontName: fontName
                                                 matrix: fontMatrix]);
+       if ( !fontInfo )
+         {
+           [self release];
+           return nil;
+         }
        /* Cache the font for later use */
        NSMapInsert(globalFontMap, (void*)nameWithMatrix, (void*)self);
      }



*** back/Source/xlib/XGFont.m.old       Sat Jun 29 23:33:20 2002
--- back/Source/xlib/XGFont.m   Wed Oct  9 22:09:41 2002
***************
*** 250,264 ****
    if ((xfontname == nil) ||
        (font_info = XLoadQueryFont(xdpy, [xfontname cString])) == NULL)
      {
!       NSLog(@"Selected font: %@ at %f (%@) is not available.\n"
!           @"Using system fixed font instead", fontName, matrix[0], xfontname);
!
!       // Try default font
!       if ((font_info = XLoadQueryFont(xdpy, "9x15")) == NULL)
!         {
!         NSLog(@"Unable to open fixed font");
!         return NO;
!       }
      }
    else
      NSDebugLog(@"Loaded font: %@", xfontname);
--- 250,258 ----
    if ((xfontname == nil) ||
        (font_info = XLoadQueryFont(xdpy, [xfontname cString])) == NULL)
      {
!       NSLog(@"XGFont: Selected font: %@ at %f (%@) is not available.",
!             fontName, matrix[0], xfontname);
!       return NO;
      }
    else
      NSDebugLog(@"Loaded font: %@", xfontname);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]