OSX 10.9.4 : CoreText CopyFontsForRequest .... IPC error ??

On OSX 10.9.4 I receive an error when I startup my app, and then I cannot use the fonts which I try distribute with my app.
It works on Yosemite, but not on a Mavericks install (on VMWare Fusion).
(opensource otf Adobe fonts which I have from Github: https://github.com/adobe-fonts/source-sans-pro)

I register those fonts and this seems to work. However there is some error message which shows up in the console, even before I am in the app.open event. As a result I cannot use the fonts.

So my question: Does anyone know what is happening here? Why does it work on Yosemite but not on Mavericks?

Code for registering fonts used in the app, called in Window.Open:

[code]Sub imRegisterFont(FontName As String)
// Original code by Sam Rowlands, Ohanaware

#If TargetCocoa
If FontName.Trim = “” Then Return

Dim f As folderitem = App.ExecutableFile.Parent.Parent.Child("Resources").Child("AppFonts").Child(FontName)

If f <> Nil Then
  // - We have a True Type Font file, first step to make a CFURL.
  // CFURLRef CFURLCreateFromFSRef (
  // CFAllocatorRef     allocator,
  // const struct FSRef *fsRef
  // );
  
  Declare Function CFURLCreateFromFSRef Lib "Cocoa" ( allocator As Ptr, fsRef As Ptr ) As Ptr
  Dim CFURLRef As Ptr = CFUrlCreateFromFSRef( Nil, f.MacFSRef )
  
  If CFUrlRef = Nil Then
    im.logEvent("[" + CurrentMethodName + "] Failed to get the CFURLRef of folder " + f.nativePath )
  Else
    
    // - Now that we have a CFURLRef, we can register it.
    
    // bool CTFontManagerRegisterFontsForURL(
    // CFURLRef fontURL,
    // CTFontManagerScope scope,
    // CFErrorRef * error
    // );
    
    // - Here is our declare.
    Declare Function CTFontManagerRegisterFontsForURL Lib "Cocoa" ( fontURL As Ptr, scope As UInt32, error As Ptr ) As Boolean
    Dim CFErrorRef As Ptr
    
    If CTFontManagerRegisterFontsForURL( CFURLRef, 1, CFErrorRef ) Then
      // Font is registered
      im.logEvent("[" + CurrentMethodName + "] Font is registered : " + FontName)
    Else
      im.logEvent("[" + CurrentMethodName + "] Font registration failed : " + FontName)
    End If
    
    
    // - As we had a valid CFURLRef from a 'Create' or 'Copy' API, we must release it.
    Declare Sub CFRelease Lib "Cocoa" ( ref As ptr )
    CFRelease CFUrlRef
  End If
End If

#EndIf
End Sub
[/code]

Hi Oliver, I see this IPC error a lot. More commonly when the font name is not 100% correct and the system has to go find a similar font.

This is strange. I have used that method ever since you helped me with it back in 2013, and whatever the system it works as clockwork. I even applied it to iOS.

The error does not seem to be triggered by Sam’s function. As one can see on the above screenshot, the function reports the fonts as being registered (green frame).

There is font server error which is reported before App.Open fires (red frame). I have no clue how I could trace this one down.

What the happens is, that PDF files which make use of those “Source” fonts, are not showing any text at all.

(On a clean install OSX Macericks, in a Vmware Fusion vm)

… it fails in a similar way on a clean Yosemite install.

I try to register some Adobe opensource fonts at startup.
Some are TrueType (.ttf) other are OpenType .otf)

In the log files I’m getting them all listed as registered (by Sam’s function).

Now I try to generate a pdf file (using DynaPdfMBS) from a Xojoscript.
There I have a SetFont method which reports “Source Sans Pro not found”

Sorry, I didn’t mean it with the code we use, I see it when trying to specify a font when using NSFont declares and the font name is not exactly as the OS expects.

I suppose you have verified after using RegisterFontsForURL that they are indeed accessible to the system, seen in the Font Menu of applications and display correctly ?

[quote=171548:@Oliver Osswald]Now I try to generate a pdf file (using DynaPdfMBS) from a Xojoscript.
There I have a SetFont method which reports “Source Sans Pro not found”[/quote]

There may be the problem. It is possible that the fonts do not permit PDF embedding.

If you be so kind to tell exactly which fonts you downloaded from https://github.com/adobe-fonts/source-sans-pro you encounter the issue with, I can look at them with my tools and tell you if that is the issue.

Thanks Michel, very kind!

I cloned the whole github for source-sans-pro and built the fonts with the Adobe Font Development Kit for OpenType, according to the instructions on the same page (https://github.com/adobe-fonts/source-sans-pro)

With a copy-file-step I copy those fonts to a AppFonts folder inside of Resources of the app.

From there I try to register these fonts using the function posted above. The app is sandboxed, so that may also be the cause for not actually working (even though the functions reports the fonts as registered).

The fonts I built are available for download here:
http://osswald.com/issues/sourcesanspro.zip

[quote=171574:@Oliver Osswald]Thanks Michel, very kind!

I cloned the whole github for source-sans-pro and built the fonts with the Adobe Font Development Kit for OpenType, according to the instructions on the same page (https://github.com/adobe-fonts/source-sans-pro)

With a copy-file-step I copy those fonts to a AppFonts folder inside of Resources of the app.

From there I try to register these fonts using the function posted above. The app is sandboxed, so that may also be the cause for not actually working (even though the functions reports the fonts as registered).

The fonts I built are available for download here:
http://osswald.com/issues/sourcesanspro.zip[/quote]

Most of my fonts apps in the MAS use the same code, and I never got any report of an issue. So the sandboxing must not be the problem.

I looked at the fonts. They are valid, and allow embedding. So that cannot explain the problem with DynaPDF.

But I did spot something : when I install one of them in Font Book, I get this warning in Console :

3/1/15 2:43:48.364 PM CoreServicesUIAgent[471]: Error -60005 creating authorization

Have you checked the font is actually available in your app after RegisterFontsforURL ? The messages you mention may just be warnings.

[quote=171577:@Michel Bujardet]<…>

But I did spot something : when I install one of them in Font Book, I get this warning in Console :

3/1/15 2:43:48.364 PM CoreServicesUIAgent[471]: Error -60005 creating authorization

Maybe this is somehow related to the fact that I built these fonts myself? I see if I can get them ready built and see if this makes a difference…

[quote=171577:@Michel Bujardet]Have you checked the font is actually available in your app after RegisterFontsforURL ? The messages you mention may just be warnings.[/quote] DynaPDFMBS reports them as not being available.

As a workaround I’m using DynaPDF.enumhostfonts to check if a font to be set is actually available. If I do not find the font, then I fallback to Arial.

But I still will keep on trying to get those sourcesanspro fonts actually installed.

BTW: I just noticed, that on a clean Yosemite install, the ttf fonts (Source Code Pro) are not available as well, and I have not built them by myself.

So at the moment I have no strategy how to find out why the install fails.

[quote=171579:@Oliver Osswald]Maybe this is somehow related to the fact that I built these fonts myself? I see if I can get them ready built and see if this makes a difference…

DynaPDFMBS reports them as not being available.

As a workaround I’m using DynaPDF.enumhostfonts to check if a font to be set is actually available. If I do not find the font, then I fallback to Arial.

But I still will keep on trying to get those sourcesanspro fonts actually installed.

BTW: I just noticed, that on a clean Yosemite install, the ttf fonts (Source Code Pro) are not available as well, and I have not built them by myself.

So at the moment I have no strategy how to find out why the install fails.[/quote]

I verified the fonts you built do install oin Font Book. Apart from the warning in Console, they are functional.

Unless you want them installed and removed dynamically, why don’t you try them using ATSApplicationFontPath ? This method is supposed to be deprecated, but since that is the preferred way in iOS, I have reasons to think it will work for a long time :
https://forum.xojo.com/5179-mac-os-custom-fonts?search=ATSApplicationFontsPath

I is in a couple of my afont apps as well, and works perfectly to this day.

I’ll give it a try.

And thanks again, appreciate very much your constant support for everybody!