Aki,

Many thanks for the reply.  Taking your suggestion, I found three
possible routes to rewriting the function (given below).  All seem to
work.

One uses NSFontManager and NSFont:

    NSArray *fontNames = [[NSFontManager sharedFontManager] availableFonts];
    for (NSString *fontName in fontNames) {
        NSFont *f = [NSFont fontWithName:fontName size:0.0];
        if ([[f coveredCharacterSet] isSupersetOfSet:cset]) {
            [result addObject:f];
        }
    }

The second uses NSFontDescriptor and NSFont:

    NSArray *fonts = [[NSFontDescriptor fontDescriptorWithFontAttributes:nil]
                         matchingFontDescriptorsWithMandatoryKeys:nil];
    for (NSFontDescriptor *fd in fonts) {
        NSFont *f = [NSFont fontWithDescriptor:fd size:0.0];
        if ([[f coveredCharacterSet] isSupersetOfSet:cset]) {
            [result addObject:f];
        }
    }

The third uses NSFontManager and NSFontDescriptor, and I think is the
closest to what you suggested:

    NSArray *fontNames = [[NSFontManager sharedFontManager] availableFonts];
    for (NSString *fontName in fontNames) {
        NSFontDescriptor *fd = 
            [NSFontDescriptor fontDescriptorWithName:fontName size:0.0];
        NSCharacterSet *s = [fd objectForKey:NSFontCharacterSetAttribute];
        if ([s isSupersetOfSet:cset]) {
            [result addObject:fd];
        }
    }

Is any to be preferred over the others?  I note that the first one and
third find extra fonts: "AquaKana", "AquaKana-Bold", ".Keyboard",
"LastResort", and sometimes others, depending on the system.  

Note as well that in the third, if I replace

NSCharacterSet *s = [fd objectForKey:NSFontCharacterSetAttribute];

by

NSCharacterSet *s = 
  [[fd fontAttributes] objectForKey:NSFontCharacterSetAttribute];

then s is NULL.  Why?

And as a final note, passing "0123456789" to my original function does
indeed return a non-zero result.  In fact, my original function seems to
return exactly the same results as the second function above (except in
the special cases I mentioned in my first post).  Very curious.  Any
idea why?  Should I still file a bug report as you suggested?

Brian
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to