env->ReleaseStringUTFChars (chars, str);
jobject Java_vdr_mhp_awt_MHPFontPeer_getGlyphVector(JNIEnv* env, jobject obj, jlong nativeData, jstring chars, jobject java_font, jobject fontRenderContext){   IDirectFBFont *font = (IDirectFBFont *)nativeData;   int len, j, clen, cj;   double *native_extents;   int *native_codes;   jintArray java_codes = NULL;   jdoubleArray java_extents = NULL;   const char *str;   if (!font) {      JNI::Exception::Throw(JNI::JavaLangNullPointerException, "IDirectFBFont is NULL");      return 0;   }      len = env->GetStringUTFLength (chars);   clen = env->GetStringLength (chars);   str = env->GetStringUTFChars (chars, NULL);      if (len > 0 && str[len-1] == '\0')      len--;     int x = 0;   //double scale = ((double) PANGO_SCALE);   java_extents = env->NewDoubleArray (clen * NUM_GLYPH_METRICS);   java_codes = env->NewIntArray (clen);   native_extents = env->GetDoubleArrayElements (java_extents, NULL);   native_codes = env->GetIntArrayElements (java_codes, NULL);   // len is the length in bytes, clen in characters - in UTF8, a character can have 1..3 bytes.   // j and cj are the respective counters.   for (j = 0, cj = 0; j < len; cj++ )   {      DFBRectangle ink;      DFBRectangle logical;      int byteLen = utf8GetCharWidth(str+j);            font->GetStringExtents(str+j, byteLen, &logical, &ink);      //PangoGlyphGeometry *geom = &glyphs->glyphs[j].geometry;      //don't what code is wanted here, using unicode index      native_codes[cj] = utf8GetUnicodeIndex(str+j);      //native_codes[j] = glyphs->glyphs[j].glyph;      native_extents[ GLYPH_LOG_X(cj)      ] = (logical.x);      native_extents[ GLYPH_LOG_Y(cj)      ] = (- logical.y);      native_extents[ GLYPH_LOG_WIDTH(cj)  ] = (logical.w);      native_extents[ GLYPH_LOG_HEIGHT(cj) ] = (logical.h);      native_extents[ GLYPH_INK_X(cj)      ] = (ink.x);      native_extents[ GLYPH_INK_Y(cj)      ] = (- ink.y);      native_extents[ GLYPH_INK_WIDTH(cj)  ] = (ink.w) ;      native_extents[ GLYPH_INK_HEIGHT(cj) ] = (ink.h);      //here I am very unsure as well. See the Pango implementation below,      //I don't have these values in DirectFB.      native_extents[ GLYPH_POS_X(cj)      ] = (x + logical.x);      native_extents[ GLYPH_POS_Y(cj)      ] = (  - logical.y);      x += logical.x;      //native_extents[ GLYPH_POS_X(j)      ] = (x + geom->x_offset);      //native_extents[ GLYPH_POS_Y(j)      ] = (  - geom->y_offset);      //x += geom->width;            //increment for loop!      j += byteLen;   }   env->ReleaseDoubleArrayElements (java_extents, native_extents, 0);   env->ReleaseIntArrayElements (java_codes, native_codes, 0);   env->ReleaseStringUTFChars (chars, str);   jobject newObj;   mhpGlyphVectorConstructor.NewObject(newObj, java_extents, java_codes, java_font, fontRenderContext);   return newObj;}