bug-gnustep
[Top][All Lists]
Advanced

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

Re: Fix: RTFConsumer, -currentFont


From: Nicola Pero
Subject: Re: Fix: RTFConsumer, -currentFont
Date: Thu, 5 Sep 2002 11:10:52 +0100 (BST)

> > 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).
> 
> The class method [NSFont fontWithName:size:] (and matrix) is implemented  
> independant of [NSFont -initWithName:matrix:].

Is it ?

Hmmm .... are we looking at the same code ? :-)

On my CVS I've got the following - which definitely creates the fonts
using -initWithName:matrix: -

+ (NSFont*) fontWithName: (NSString*)aFontName 
                  matrix: (const float*)fontMatrix
{
  NSFont *font;
  NSString *nameWithMatrix;

  nameWithMatrix = [NSString stringWithFormat:
                             @"%@ %.3f %.3f %.3f %.3f %.3f %.3f",
                             aFontName,
                             fontMatrix[0], fontMatrix[1], fontMatrix[2], 
                             fontMatrix[3], fontMatrix[4], fontMatrix[5]];

  /* Check whether the font is cached */
  font = [globalFontDictionary objectForKey: nameWithMatrix];
  if(font == nil)
    {
      font = AUTORELEASE([[NSFontClass alloc] initWithName: aFontName
                                       matrix: fontMatrix]);
      /* Cache the font for later use */
      [globalFontDictionary setObject: font forKey: nameWithMatrix];
    }

  return font;
}

since -initWithName:matrix: will never return nil, fontWithName:matrix:
will never know if the font is available or not, and can't return nil.

Or maybe you were meaning something else, which I didn't get :-)

 
> > 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.
> >
> > We then need to update all callers for the new semantics ... which
> > hopefully should not be too many.
> >
> > I think it is exactly what you were proposing.
> 
> Yup.

Ok





reply via email to

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