CoreText CopyFontsForRequest received mig IPC error
Asked Answered
M

3

9

I've been working on a BIG project (there's no point of showing any actual code anyway) and I've notice that the following message appears in the logs:

CoreText CopyFontsForRequest received mig IPC error (FFFFFFFFFFFFFECC) from font server

The error pops up as soon as a WebView has finished loading. And I kinda believe it's the culprit behind a tiny lag.

Why is that happening? What can I do to fix this?


P.S. Tried the suggested solution here to check whether it was something system-specific, but it didn't work.


More details:

  • The error appears when using the AMEditorAppearance.car NSAppearance file, from the Appearance Maker project. Disabling it (= not loading it all) makes the error go away.

  • I don't really care about the error message, other than that it creates some weird issues with fonts. E.g. NSAlert panels, with input fiels, show a noticeable flicker and the font/text seems rather messed up, in a way I'm not sure I can accurately describe. (I could post a video with that if that'd help)

Merca answered 27/9, 2014 at 8:18 Comment(0)
G
3

This is probably related to system font conflicts and can easily be fixed:

  1. Open Font book
  2. Select all fonts
  3. Go to the file menu and select "Validate fonts"
  4. Resolve all font conflicts (by removing duplets).

Source: Andreas Wacker

Gasworks answered 5/11, 2014 at 10:14 Comment(1)
Hmm.. I had tried this one but it didn't work. Btw, the issue still remains... :SMerca
L
2

This is caused by calling NSFont fontWithFamily: with a family name argument which is not available on the system from within Chromium's renderer process. When Chromium's sandbox is active this call triggers the CoreText error that you're observing.

It happens during matching CSS font family names against locally installed system fonts.

Probably you were working on a Chromium-derived project. More info can be found in Chromium Bug 452849.

Larocca answered 28/1, 2015 at 13:53 Comment(0)
C
2

Answer by @Abrax5 is excellent. I just wanted to add my experience with this problem and could not fit it into a comment:

As far as I can tell, this error is raised only on the first failed attempt to initialise an NSFont with a font name that is not available. NSFont initialisers are failable and will return nil in such a case at which time you have an opportunity to do something about it.

You can check whether a font by a given name is available using:

NSFontDescriptor(fontAttributes: [NSFontNameAttribute: "<font name>"]).matchingFontDescriptorWithMandatoryKeys([NSFontNameAttribute]) != nil

Unfortunately, this also raises the error! The following method does not, but is deprecated:

let fontDescr = NSFontDescriptor(fontAttributes: [NSFontNameAttribute: "<font name>"])
let isAvailable = NSFontManager.sharedFontManager().availableFontNamesMatchingFontDescriptor(fontDescr)?.count ?? 0 > 0

So the only way I found of checking the availability of a font of a given name without raising that error is as follows:

public extension NSFont {

    private static let availableFonts = (NSFontManager.sharedFontManager().availableFonts as? [String]).map { Set($0) }

    public class func available(fontName: String) -> Bool {
        return NSFont.availableFonts?.contains(fontName) ?? false
    }
}

For example:

NSFont.available("Georgia")  //--> true
NSFont.available("WTF?")     //--> false

(I'm probably overly cautious with that optional constant there and if you are so inclined you can convert the returned [AnyObject] using as! [String]...)

Note that for the sake of efficiency this will not update until the app is started again, i.e. any fonts installed during the app's run will not be matched. If this is an important issue for your particular app, just turn the constant into a computed property:

public extension NSFont {

    private static var allAvailable: Set<String>? {
        return (NSFontManager.sharedFontManager().availableFonts as? [String]).map { Set($0) }
    }

    private static let allAvailableAtStart = allAvailable

    public class func available(fontName: String) -> Bool {
        return NSFont.allAvailable?.contains(fontName) ?? false
    }

    public class func availableAtStart(fontName: String) -> Bool {
        return NSFont.allAvailableAtStart?.contains(fontName) ?? false
    }
}

On my machine available(:) takes 0.006s. Of course, availableAtStart(:) takes virtually no time on all but the first call...

Crossbred answered 24/5, 2015 at 18:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.