Crash in Font Class on Snow Leopard

Hi Jules,
My application uses juce_1.39, It handles fonts and the application crashes on snow leopard. This is the crash report.

crash report :

bool getPathAndKerning (const juce_wchar char1,
                            const juce_wchar char2,
                            Path* path,
                            float& kerning,
                            float* ascent,
                            float* descent)
    {
        bool ok = false;

        UniChar buffer[4];
        buffer[0] = T(' ');
        buffer[1] = char1;
        buffer[2] = char2;
        buffer[3] = 0;

        UniCharCount count = kATSUToTextEnd;
        ATSUTextLayout layout;
        OSStatus err = ATSUCreateTextLayoutWithTextPtr (buffer,
                                                        0,
                                                        2,
                                                        2,
                                                        1,
                                                        &count,
                                                        &style,
                                                        &layout);
        if (err == noErr)
        {
            ATSUSetTransientFontMatching (layout, true);

            ATSLayoutRecord* layoutRecords;
            ItemCount numRecords;
            Fixed* deltaYs;
            ItemCount numDeltaYs;

            ATSUDirectGetLayoutDataArrayPtrFromTextLayout (layout,
                                                           0,
                                                           kATSUDirectDataLayoutRecordATSLayoutRecordCurrent,
                                                           (void**) &layoutRecords,
                                                           &numRecords);

            ATSUDirectGetLayoutDataArrayPtrFromTextLayout (layout,
                                                           0,
                                                           kATSUDirectDataBaselineDeltaFixedArray,
                                                           (void**) &deltaYs,
                                                           &numDeltaYs);

            if (numRecords > 2 )
            {
                //crashes here since layoutRecords has garbage values because 
                // this call has failed 'kATSUDirectDataLayoutRecordATSLayoutRecordCurrent'
                kerning = (float) (Fix2X (layoutRecords[2].realPos)
                                   - Fix2X (layoutRecords[1].realPos));

                if (ascent != 0)
                {
                    ATSUTextMeasurement asc;
                    ByteCount actualSize;

                    ATSUGetLineControl (layout,
                                        0,
                                        kATSULineAscentTag,
                                        sizeof (ATSUTextMeasurement),
                                        &asc,
                                        &actualSize);

                    *ascent = (float) Fix2X (asc);
                }

                if (descent != 0)
                {
                    ATSUTextMeasurement desc;
                    ByteCount actualSize;

                    ATSUGetLineControl (layout,
                                        0,
                                        kATSULineDescentTag,
                                        sizeof (ATSUTextMeasurement),
                                        &desc,
                                        &actualSize);

                    *descent = (float) Fix2X (desc);
                }

                if (path != 0)
                {
                    OSStatus callbackResult;

                    ok = (ATSUGlyphGetCubicPaths (style,
                                                  layoutRecords[1].glyphID,
                                                  moveToProc,
                                                  lineToProc,
                                                  curveToProc,
                                                  closePathProc,
                                                  (void*) path,
                                                  &callbackResult) == noErr);

                    if (numDeltaYs > 0 && ok)
                    {
                        const float dy = (float) Fix2X (deltaYs[1]);

                        path->applyTransform (AffineTransform::translation (0.0f, dy));
                    }
                }
                else
                {
                    ok = true;
                }
            }

            if (deltaYs != 0)
                ATSUDirectReleaseLayoutDataArrayPtr (0, kATSUDirectDataBaselineDeltaFixedArray,
                                                     (void**) &deltaYs);

            if (layoutRecords != 0)
                ATSUDirectReleaseLayoutDataArrayPtr (0, kATSUDirectDataLayoutRecordATSLayoutRecordCurrent,
                                                     (void**) &layoutRecords);

            ATSUDisposeTextLayout (layout);
        }

        return kerning;
    }

These calls are deprecated on snow leopard and also on leopard. I do understand that I would have to change my application to use juce_1.50 but my application is very huge and it may takes months to change it to juce_1.50, is there any patch fix I can try till am able to move to juce_1.50 .

I have no idea, but I suspect the answer is “no”…

Update on the issue.

  1. The problem is partially with Snow leopard, which has a bug, in using open type fonts.

    http://discussions.apple.com/thread.jspa?threadID=2154431&start=0&tstart=0
    http://discussions.apple.com/thread.jspa?threadID=2136944&tstart=0

  2. The calls were deprecated, since my application was using a old version of juce. It was easy to fix, I moved juce_mac_Fonts.mm to my old version of juce. Had to thinker a bit. :slight_smile:

Thanks jules for maintaining the code structure over the years, you made by task so much easier. :smiley: