NSFonts that have ASCII characters

154 Views Asked by At

I'm making my own font dialogue, but it's embedded within WebKit. It's working pretty much how I want it to, except for one part. It's showing fonts that can not be written using standard ASCII characters. They appear in standard Latin characters, such as below. (note I'm setting the menu font using CSS)

Wingdings is not showing in Wingdings

This occurs with fonts such as Wingdings and fonts for languages such as Chinese. From what I've read, this is because there is no mapping between the ASCII characters to the font's characters.

I'd essentially like to filter out these fonts so only fonts that can actually be written with and are distinct appear. It should be possible, Pages manages to do it.

I've attempted to something like this, but it sometimes removes fonts that it shouldn't and leaves fonts that it should remove.

NSArray *availableFontFamilies = [[NSFontManager sharedFontManager] availableFontFamilies];
NSMutableArray *fontFamilies = [NSMutableArray array];

for (NSString *family in availableFontFamilies) {
    NSFontDescriptor *fontDescriptor = [NSFontDescriptor fontDescriptorWithName: family size:16];
    if ([fontDescriptor symbolicTraits] != 0 && ([fontDescriptor symbolicTraits] & NSFontSymbolicClass) == 0) {
        [fontFamilies addObject: family];
    }
}

NSLog(@"Families: %@", fontFamilies);
0

There are 0 best solutions below