freetype
[Top][All Lists]
Advanced

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

[Freetype] generating a list of outline fonts on MacOS/OSX


From: Paul Miller
Subject: [Freetype] generating a list of outline fonts on MacOS/OSX
Date: Thu, 28 Feb 2002 15:37:48 -0600

I updated to 2.0.8 recently and it works well.

Now I'm trying to figure out why I'm getting a bunch of duplicate fonts (or fonts with garbage names) on OS/X when querying for a list of all of the available outline fonts. This is basically what I am doing. Can someone tell me what I am doing wrong?

        FMFontFamilyIterator famIter;
OSStatus status = ::FMCreateFontFamilyIterator(NULL, this, kFMUseGlobalScopeOption, &famIter);
        int id = kID_FIRST_FONT;
        while (status == 0)
        {
                FMFontFamily family = NULL;
                status = ::FMGetNextFontFamily(&famIter, &family);
                if (status == 0)
                {
                        Str255 famNameStr;
                        ::FMGetFontFamilyName(family, famNameStr);
                        
                        std::string famName;
                        p2c(famNameStr, famName);

                        // sometimes we get here with an empty family name      
                
                        if (famName.size() > 0 && famName[0] == '.')
                                continue;
                        
                        // iterate through the styles
                        FMFontFamilyInstanceIterator instIter;
                        ::FMCreateFontFamilyInstanceIterator(family, &instIter);
                        OSStatus stat2 = 0;
                        while (stat2 == 0)
                        {
                                FMFontStyle style;
                                FMFontSize size;
                                FMFont font;
                                stat2 = ::FMGetNextFontFamilyInstance(&instIter, &font, 
&style, &size);

                                // size == 0 means outline?
                                if (stat2 == 0 && size == 0)
                                {
                                        std::string fullName = famName;
                                                
                                        if (style & bold)
                                                fullName += " Bold";            
              
                                        if (style & italic)
                                                fullName += " Italic";

                                        // add the name to my list
                                }
                        }
                        ::FMDisposeFontFamilyInstanceIterator(&instIter);
                }
        }
        ::FMDisposeFontFamilyIterator(&famIter);

--
Paul T. Miller | VP of Engineering, Profound Effects, Inc. | http://www.profoundeffects.com




reply via email to

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