mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Android: Fixed an issue where getting the metrics of a string on android could crash if the string can't be represented as a UTF-16 string
This commit is contained in:
parent
16935088e1
commit
a7b5c1f77f
1 changed files with 3 additions and 5 deletions
|
|
@ -199,7 +199,7 @@ public:
|
|||
float getStringWidth (const String& text) override
|
||||
{
|
||||
JNIEnv* env = getEnv();
|
||||
const int numChars = text.length();
|
||||
const int numChars = CharPointer_UTF16::getBytesRequiredFor (text.getCharPointer());
|
||||
jfloatArray widths = env->NewFloatArray (numChars);
|
||||
|
||||
const int numDone = paint.callIntMethod (AndroidPaint.getTextWidths, javaString (text).get(), widths);
|
||||
|
|
@ -218,12 +218,10 @@ public:
|
|||
void getGlyphPositions (const String& text, Array<int>& glyphs, Array<float>& xOffsets) override
|
||||
{
|
||||
JNIEnv* env = getEnv();
|
||||
auto jtext = javaString (text);
|
||||
|
||||
const int numChars = env->GetStringLength (jtext.get());
|
||||
const int numChars = CharPointer_UTF16::getBytesRequiredFor (text.getCharPointer());
|
||||
jfloatArray widths = env->NewFloatArray (numChars);
|
||||
|
||||
const int numDone = paint.callIntMethod (AndroidPaint.getTextWidths, jtext.get(), widths);
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue