< prev index next >

src/java.desktop/share/native/libfontmanager/HBShaper.c

Print this page




 186     }
 187 
 188     /* Do an initial approximation, in root */
 189     root = a > b ? a + (b / 2) : b + (a / 2);
 190 
 191     /* An unrolled Newton-Raphson iteration sequence */
 192     root = (root + (a * (a / root)) + (b * (b / root)) + 1) / 2;
 193     root = (root + (a * (a / root)) + (b * (b / root)) + 1) / 2;
 194     root = (root + (a * (a / root)) + (b * (b / root)) + 1) / 2;
 195 
 196     return root;
 197 }
 198 
 199 JDKFontInfo*
 200      createJDKFontInfo(JNIEnv *env,
 201                        jobject font2D,
 202                        jobject fontStrike,
 203                        jfloat ptSize,
 204                        jlong pScaler,
 205                        jlong pNativeFont,
 206                        jlong layoutTables,
 207                        jfloatArray matrix,
 208                        jboolean aat) {
 209 
 210 
 211     JDKFontInfo *fi = (JDKFontInfo*)malloc(sizeof(JDKFontInfo));
 212     if (!fi) {
 213        return NULL;
 214     }
 215     fi->env = env; // this is valid only for the life of this JNI call.
 216     fi->font2D = font2D;
 217     fi->fontStrike = fontStrike;
 218     fi->nativeFont = pNativeFont;
 219     fi->layoutTables = (TTLayoutTableCache*)layoutTables;
 220     fi->aat = aat;
 221     (*env)->GetFloatArrayRegion(env, matrix, 0, 4, fi->matrix);
 222     fi->ptSize = ptSize;
 223     fi->xPtSize = euclidianDistance(fi->matrix[0], fi->matrix[1]);
 224     fi->yPtSize = euclidianDistance(fi->matrix[2], fi->matrix[3]);
 225     if (!aat && (getenv("HB_NODEVTX") != NULL)) {
 226         fi->devScale = fi->xPtSize / fi->ptSize;
 227     } else {
 228         fi->devScale = 1.0f;
 229     }
 230     return fi;
 231 }
 232 
 233 
 234 #define TYPO_KERN 0x00000001
 235 #define TYPO_LIGA 0x00000002
 236 #define TYPO_RTL  0x80000000
 237 
 238 JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape
 239     (JNIEnv *env, jclass cls,
 240      jobject font2D,
 241      jobject fontStrike,
 242      jfloat ptSize,
 243      jfloatArray matrix,
 244      jlong pScaler,
 245      jlong pNativeFont,
 246      jlong layoutTables,
 247      jboolean aat,
 248      jcharArray text,
 249      jobject gvdata,
 250      jint script,
 251      jint offset,
 252      jint limit,
 253      jint baseIndex,
 254      jobject startPt,
 255      jint flags,
 256      jint slot) {
 257 
 258      hb_buffer_t *buffer;

 259      hb_font_t* hbfont;
 260      jchar  *chars;
 261      jsize len;
 262      int glyphCount;
 263      hb_glyph_info_t *glyphInfo;
 264      hb_glyph_position_t *glyphPos;
 265      hb_direction_t direction = HB_DIRECTION_LTR;
 266      hb_feature_t *features = NULL;
 267      int featureCount = 0;
 268      char* kern = (flags & TYPO_KERN) ? "kern" : "-kern";
 269      char* liga = (flags & TYPO_LIGA) ? "liga" : "-liga";
 270      jboolean ret;
 271      unsigned int buflen;
 272 
 273      JDKFontInfo *jdkFontInfo =
 274          createJDKFontInfo(env, font2D, fontStrike, ptSize,
 275                            pScaler, pNativeFont, layoutTables, matrix, aat);
 276      if (!jdkFontInfo) {
 277         return JNI_FALSE;
 278      }
 279      jdkFontInfo->env = env; // this is valid only for the life of this JNI call.
 280      jdkFontInfo->font2D = font2D;
 281      jdkFontInfo->fontStrike = fontStrike;
 282 
 283      hbfont = hb_jdk_font_create(jdkFontInfo, NULL);

 284 
 285      buffer = hb_buffer_create();
 286      hb_buffer_set_script(buffer, getHBScriptCode(script));
 287      hb_buffer_set_language(buffer,
 288                             hb_ot_tag_to_language(HB_OT_TAG_DEFAULT_LANGUAGE));
 289      if ((flags & TYPO_RTL) != 0) {
 290          direction = HB_DIRECTION_RTL;
 291      }
 292      hb_buffer_set_direction(buffer, direction);
 293      hb_buffer_set_cluster_level(buffer,
 294                                  HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
 295 
 296      chars = (*env)->GetCharArrayElements(env, text, NULL);
 297      if ((*env)->ExceptionCheck(env)) {
 298          hb_buffer_destroy(buffer);
 299          hb_font_destroy(hbfont);
 300          free((void*)jdkFontInfo);
 301          return JNI_FALSE;
 302      }
 303      len = (*env)->GetArrayLength(env, text);




 186     }
 187 
 188     /* Do an initial approximation, in root */
 189     root = a > b ? a + (b / 2) : b + (a / 2);
 190 
 191     /* An unrolled Newton-Raphson iteration sequence */
 192     root = (root + (a * (a / root)) + (b * (b / root)) + 1) / 2;
 193     root = (root + (a * (a / root)) + (b * (b / root)) + 1) / 2;
 194     root = (root + (a * (a / root)) + (b * (b / root)) + 1) / 2;
 195 
 196     return root;
 197 }
 198 
 199 JDKFontInfo*
 200      createJDKFontInfo(JNIEnv *env,
 201                        jobject font2D,
 202                        jobject fontStrike,
 203                        jfloat ptSize,
 204                        jlong pScaler,
 205                        jlong pNativeFont,

 206                        jfloatArray matrix,
 207                        jboolean aat) {
 208 
 209 
 210     JDKFontInfo *fi = (JDKFontInfo*)malloc(sizeof(JDKFontInfo));
 211     if (!fi) {
 212        return NULL;
 213     }
 214     fi->env = env; // this is valid only for the life of this JNI call.
 215     fi->font2D = font2D;
 216     fi->fontStrike = fontStrike;
 217     fi->nativeFont = pNativeFont;

 218     fi->aat = aat;
 219     (*env)->GetFloatArrayRegion(env, matrix, 0, 4, fi->matrix);
 220     fi->ptSize = ptSize;
 221     fi->xPtSize = euclidianDistance(fi->matrix[0], fi->matrix[1]);
 222     fi->yPtSize = euclidianDistance(fi->matrix[2], fi->matrix[3]);
 223     if (!aat && (getenv("HB_NODEVTX") != NULL)) {
 224         fi->devScale = fi->xPtSize / fi->ptSize;
 225     } else {
 226         fi->devScale = 1.0f;
 227     }
 228     return fi;
 229 }
 230 
 231 
 232 #define TYPO_KERN 0x00000001
 233 #define TYPO_LIGA 0x00000002
 234 #define TYPO_RTL  0x80000000
 235 
 236 JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape
 237     (JNIEnv *env, jclass cls,
 238      jobject font2D,
 239      jobject fontStrike,
 240      jfloat ptSize,
 241      jfloatArray matrix,
 242      jlong pScaler,
 243      jlong pNativeFont,
 244      jlong pFace,
 245      jboolean aat,
 246      jcharArray text,
 247      jobject gvdata,
 248      jint script,
 249      jint offset,
 250      jint limit,
 251      jint baseIndex,
 252      jobject startPt,
 253      jint flags,
 254      jint slot) {
 255 
 256      hb_buffer_t *buffer;
 257      hb_face_t* hbface;
 258      hb_font_t* hbfont;
 259      jchar  *chars;
 260      jsize len;
 261      int glyphCount;
 262      hb_glyph_info_t *glyphInfo;
 263      hb_glyph_position_t *glyphPos;
 264      hb_direction_t direction = HB_DIRECTION_LTR;
 265      hb_feature_t *features = NULL;
 266      int featureCount = 0;
 267      char* kern = (flags & TYPO_KERN) ? "kern" : "-kern";
 268      char* liga = (flags & TYPO_LIGA) ? "liga" : "-liga";
 269      jboolean ret;
 270      unsigned int buflen;
 271 
 272      JDKFontInfo *jdkFontInfo =
 273          createJDKFontInfo(env, font2D, fontStrike, ptSize,
 274                            pScaler, pNativeFont, matrix, aat);
 275      if (!jdkFontInfo) {
 276         return JNI_FALSE;
 277      }
 278      jdkFontInfo->env = env; // this is valid only for the life of this JNI call.
 279      jdkFontInfo->font2D = font2D;
 280      jdkFontInfo->fontStrike = fontStrike;
 281 
 282      hbface = (hb_face_t*) jlong_to_ptr(pFace);
 283      hbfont = hb_jdk_font_create(hbface, jdkFontInfo, NULL);
 284 
 285      buffer = hb_buffer_create();
 286      hb_buffer_set_script(buffer, getHBScriptCode(script));
 287      hb_buffer_set_language(buffer,
 288                             hb_ot_tag_to_language(HB_OT_TAG_DEFAULT_LANGUAGE));
 289      if ((flags & TYPO_RTL) != 0) {
 290          direction = HB_DIRECTION_RTL;
 291      }
 292      hb_buffer_set_direction(buffer, direction);
 293      hb_buffer_set_cluster_level(buffer,
 294                                  HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
 295 
 296      chars = (*env)->GetCharArrayElements(env, text, NULL);
 297      if ((*env)->ExceptionCheck(env)) {
 298          hb_buffer_destroy(buffer);
 299          hb_font_destroy(hbfont);
 300          free((void*)jdkFontInfo);
 301          return JNI_FALSE;
 302      }
 303      len = (*env)->GetArrayLength(env, text);


< prev index next >