Android - crashing when using certain characters


#1

The following function will crash on Android, if passed a string that contains certain characters (example: :butterfly:). Doesn’t crash iOS/macOS or Windows.

   void getGlyphPositions (const String& text, Array<int>& glyphs, Array<float>& xOffsets) override

As a work-around, for now I’m having to filter-out characters in certain ranges before attempting to display them; not really optimal :slight_smile:

Thanks,

Pete


#2

OK the crash is fixed now on develop with 6c08f04. However, JUCE currently does not support any emoticons at the moment. :frowning:


#3

No worries, Fabian. Understood - but at least great to fix the crash however :slight_smile: Pete


#4

Hi Fabian,

Just found another very similar crash, in here, on the call to GetFloatArrayRegion …:

    float getStringWidth (const String& text) override
    {
        JNIEnv* env = getEnv();
        const int numChars = text.length();
        jfloatArray widths = env->NewFloatArray (numChars);

        const int numDone = paint.callIntMethod (AndroidPaint.getTextWidths, javaString (text).get(), widths);

        HeapBlock<jfloat> localWidths (static_cast<size_t> (numDone));
        env->GetFloatArrayRegion (widths, 0, numDone, localWidths);
        env->DeleteLocalRef (widths);

        float x = 0;
        for (int i = 0; i < numDone; ++i)
            x += localWidths[i];

        return x * referenceFontToUnits;
    }

It happens when you call juce::Font::getStringWidthFloat

I’d guess the fix would be very similar?

Hoping you can advise!

Pete


#5

OK I’ll fix this.


#6

This is now fixed on develop with commit a7b5c1f.


#7

Thanks!