< prev index next >

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

Print this page




 184     if (b == 0) {
 185         return a;
 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      jboolean aat,
 245      jcharArray text,
 246      jobject gvdata,
 247      jint script,
 248      jint offset,
 249      jint limit,
 250      jint baseIndex,
 251      jobject startPt,
 252      jint flags,
 253      jint slot) {
 254 
 255      hb_buffer_t *buffer;

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

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




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


< prev index next >