Как можно загрузить шрифт (TTF) из файла с помощью Базового текста?

До OSX 10.6 ATSFontActivateFromFileSpecification/ATSFontActivateFromFileReference были доступны и могли использоваться для загрузки шрифта из файла. Я ничто не могу найти подобным в Базовом тексте.

13
задан miekelly 24 April 2010 в 03:20
поделиться

2 ответа

Вы можете получить CTFontRef из файла шрифта, перейдя через CGFontRef :

CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, CFSTR("/path/to/font"), kCFURLPOSIXPathStyle, false);
CGDataProviderRef dataProvider = CGDataProviderCreateWithURL(url);
CGFontRef theCGFont = CGFontCreateWithDataProvider(dataProvider);
CTFontRef theCTFont = CTFontCreateWithGraphicsFont(theCGFont);
CFRelease(theCGFont);
CFRelease(dataProvider);
CFRelease(url);

// do something with the CTFontRef here

CFRelease(theCTFont);   
18
ответ дан 1 December 2019 в 20:00
поделиться

Похоже, CTFontManagerCreateFontDescriptorsFromURL - это замена Core Text.

10
ответ дан 1 December 2019 в 20:00
поделиться
Другие вопросы по тегам:

Похожие вопросы: