Aravindhan
Aravindhan

Reputation: 15628

Parameter Error while Activating a Font

I have to activate a Font in Mac OSX 10.5. For that I referred the ATS. And I coded like this.

    NSString *filePath =  @"/Users/userName/Desktop/Fonts/Impasto.otf";
    CFURLRef url = (CFURLRef)[NSURL fileURLWithPath:filePath];
    OSStatus status = ATSFontSetAutoActivationSettingForApplication(kATSFontAutoActivationEnabled,url);
    if(status == paramErr)
    {
        NSLog(@"parameter error");
    }

But I am getting parameter Error for this code. I can't able to understand what I am doing wrong here.

Upvotes: 2

Views: 107

Answers (1)

DarkDust
DarkDust

Reputation: 92336

Disclaimer: I'm merely interpreting the docs, I haven't got actual experience with ATS.

From the documentation for ATSFontSetAutoActivationSettingForApplication:

Sets the auto-activation setting for the specified application bundle.

And then for the second parameter:

A valid file URL for an application. Pass NULL to specify the current process.

I read it as: the method activates all the fonts in a given app bundle. You would either pass (CFURLRef)[[NSBundle mainBundle] bundleURL] or simply NULL. To activate a font outside your bundle you might need ATSFontActivateFromFileReference.

Upvotes: 1

Related Questions