场景:
1.假如你向做自己的字体管理界面时,这样就需要获取支持的所有字体名字。
2.objc的强大之处是它可以和C++混合编程,这是其他语言所不具备的。这里使用了ATS Service接口.ATS(AppleType Service)
文件1:test_fontdata.mm
#include <stdlib.h>
#include <stdio.h>
#include <ATSFont.h>
#import <Foundation/Foundation.h>
#include <vector>
#include <string>
inline void StoreFontDatabaseFromATS(std::vector<std::string>& name_list)
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
ATSFontFamilyIterator theFontFamilyIterator = NULL;
ATSFontFamilyRef theATSFontFamilyRef = 0;
OSStatus status = noErr;
// Create the iterator
status = ATSFontFamilyIteratorCreate(kATSFontContextLocal, nil,nil,