< prev index next >

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

Print this page




 444                                  sunFontIDs.strikeMetricsClass,
 445                                  sunFontIDs.strikeMetricsCtr,
 446                                  f0, f0, f0, f0, f0, f0, f0, f0, f0, f0);
 447         invalidateJavaScaler(env, scaler, scalerInfo);
 448         return metrics;
 449     }
 450 
 451     /* This is ugly and has to be reworked.
 452        Freetype provide means to add style to glyph but
 453        it seems there is no way to adjust metrics accordingly.
 454 
 455        So, we have to do adust them explicitly and stay consistent with what
 456        freetype does to outlines. */
 457 
 458 
 459     /**** Note: only some metrics are affected by styling ***/
 460 
 461     /* See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=657854 */
 462 #define FT_MulFixFloatShift6(a, b) (((float) (a)) * ((float) (b)) / 65536.0 / 64.0)
 463 


 464     /*
 465      * See FreeType source code: src/base/ftobjs.c ft_recompute_scaled_metrics()
 466      * http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=1659
 467      */
 468     /* ascent */
 469     ax = 0;
 470     ay = -(jfloat) (FT_MulFixFloatShift6(
 471                        ((jlong) scalerInfo->face->ascender),
 472                        (jlong) scalerInfo->face->size->metrics.y_scale));
 473     /* descent */
 474     dx = 0;
 475     dy = -(jfloat) (FT_MulFixFloatShift6(
 476                        ((jlong) scalerInfo->face->descender),
 477                        (jlong) scalerInfo->face->size->metrics.y_scale));
 478     /* baseline */
 479     bx = by = 0;
 480 
 481     /* leading */
 482     lx = 0;
 483     ly = (jfloat) (FT_MulFixFloatShift6(
 484                       (jlong) scalerInfo->face->height,
 485                       (jlong) scalerInfo->face->size->metrics.y_scale))
 486                   + ay - dy;
 487     /* max advance */
 488     mx = (jfloat) FT26Dot6ToFloat(
 489                      scalerInfo->face->size->metrics.max_advance +
 490                      OBLIQUE_MODIFIER(scalerInfo->face->size->metrics.height));
 491     my = 0;
 492 
 493     metrics = (*env)->NewObject(env,
 494                                 sunFontIDs.strikeMetricsClass,
 495                                 sunFontIDs.strikeMetricsCtr,
 496                                 ax, ay, dx, dy, bx, by, lx, ly, mx, my);




 497 
 498     return metrics;
 499 }
 500 
 501 /*
 502  * Class:     sun_font_FreetypeFontScaler
 503  * Method:    getGlyphAdvanceNative
 504  * Signature: (Lsun/font/Font2D;JI)F
 505  */
 506 JNIEXPORT jfloat JNICALL
 507 Java_sun_font_FreetypeFontScaler_getGlyphAdvanceNative(
 508         JNIEnv *env, jobject scaler, jobject font2D,
 509         jlong pScalerContext, jlong pScaler, jint glyphCode) {
 510 
 511    /* This method is rarely used because requests for metrics are usually
 512       coupled with request for bitmap and to large extend work can be reused
 513       (to find out metrics we need to hint glyph).
 514       So, we typically go through getGlyphImage code path.
 515 
 516       For initial freetype implementation we delegate




 444                                  sunFontIDs.strikeMetricsClass,
 445                                  sunFontIDs.strikeMetricsCtr,
 446                                  f0, f0, f0, f0, f0, f0, f0, f0, f0, f0);
 447         invalidateJavaScaler(env, scaler, scalerInfo);
 448         return metrics;
 449     }
 450 
 451     /* This is ugly and has to be reworked.
 452        Freetype provide means to add style to glyph but
 453        it seems there is no way to adjust metrics accordingly.
 454 
 455        So, we have to do adust them explicitly and stay consistent with what
 456        freetype does to outlines. */
 457 
 458 
 459     /**** Note: only some metrics are affected by styling ***/
 460 
 461     /* See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=657854 */
 462 #define FT_MulFixFloatShift6(a, b) (((float) (a)) * ((float) (b)) / 65536.0 / 64.0)
 463 
 464 #define contextAwareMetricsX(vx, vy) (FTFixedToFloat(context->transform.xx) * (vx) - FTFixedToFloat(context->transform.xy) * (vy))
 465 #define contextAwareMetricsY(vx, vy) (-FTFixedToFloat(context->transform.yx) * (vx) + FTFixedToFloat(context->transform.yy) * (vy))
 466     /*
 467      * See FreeType source code: src/base/ftobjs.c ft_recompute_scaled_metrics()
 468      * http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=1659
 469      */
 470     /* ascent */
 471     ax = 0;
 472     ay = -(jfloat) (FT_MulFixFloatShift6(
 473                        ((jlong) scalerInfo->face->ascender),
 474                        (jlong) scalerInfo->face->size->metrics.y_scale));
 475     /* descent */
 476     dx = 0;
 477     dy = -(jfloat) (FT_MulFixFloatShift6(
 478                        ((jlong) scalerInfo->face->descender),
 479                        (jlong) scalerInfo->face->size->metrics.y_scale));
 480     /* baseline */
 481     bx = by = 0;
 482 
 483     /* leading */
 484     lx = 0;
 485     ly = (jfloat) (FT_MulFixFloatShift6(
 486                       (jlong) scalerInfo->face->height,
 487                       (jlong) scalerInfo->face->size->metrics.y_scale))
 488                   + ay - dy;
 489     /* max advance */
 490     mx = (jfloat) FT26Dot6ToFloat(
 491                      scalerInfo->face->size->metrics.max_advance +
 492                      OBLIQUE_MODIFIER(scalerInfo->face->size->metrics.height));
 493     my = 0;
 494 
 495     metrics = (*env)->NewObject(env,
 496         sunFontIDs.strikeMetricsClass,
 497         sunFontIDs.strikeMetricsCtr,
 498         contextAwareMetricsX(ax, ay), contextAwareMetricsY(ax, ay),
 499         contextAwareMetricsX(dx, dy), contextAwareMetricsY(dx, dy),
 500         bx, by,
 501         contextAwareMetricsX(lx, ly), contextAwareMetricsY(lx, ly),
 502         contextAwareMetricsX(mx, my), contextAwareMetricsY(mx, my));
 503 
 504     return metrics;
 505 }
 506 
 507 /*
 508  * Class:     sun_font_FreetypeFontScaler
 509  * Method:    getGlyphAdvanceNative
 510  * Signature: (Lsun/font/Font2D;JI)F
 511  */
 512 JNIEXPORT jfloat JNICALL
 513 Java_sun_font_FreetypeFontScaler_getGlyphAdvanceNative(
 514         JNIEnv *env, jobject scaler, jobject font2D,
 515         jlong pScalerContext, jlong pScaler, jint glyphCode) {
 516 
 517    /* This method is rarely used because requests for metrics are usually
 518       coupled with request for bitmap and to large extend work can be reused
 519       (to find out metrics we need to hint glyph).
 520       So, we typically go through getGlyphImage code path.
 521 
 522       For initial freetype implementation we delegate


< prev index next >