1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-15 00:24:19 +00:00

Android: Fixed a crash when painting a string that can't be represented as a UTF-16 string

This commit is contained in:
hogliux 2018-04-09 16:28:38 +01:00
parent 0055d3f8f8
commit 6c08f04a8e

View file

@ -218,10 +218,12 @@ public:
void getGlyphPositions (const String& text, Array<int>& glyphs, Array<float>& xOffsets) override
{
JNIEnv* env = getEnv();
const int numChars = text.length();
auto jtext = javaString (text);
const int numChars = env->GetStringLength (jtext.get());
jfloatArray widths = env->NewFloatArray (numChars);
const int numDone = paint.callIntMethod (AndroidPaint.getTextWidths, javaString (text).get(), widths);
const int numDone = paint.callIntMethod (AndroidPaint.getTextWidths, jtext.get(), widths);
HeapBlock<jfloat> localWidths (static_cast<size_t> (numDone));
env->GetFloatArrayRegion (widths, 0, numDone, localWidths);