Applied a patch from Hidetoshi for embedded bitmap metrics support.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c
index 96e3d15..5f0928c 100644
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -575,14 +575,56 @@
}
/* Compute root ascender, descender, test height, and max_advance */
- metrics->ascender = ( FT_MulFix( face->root.ascender,
+
+#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
+
+ if ( ( !( face->root.face_flags & FT_FACE_FLAG_SCALABLE ) &&
+ ( face->root.face_flags & FT_FACE_FLAG_FIXED_SIZES ) ) )
+ {
+ FT_Int i;
+
+
+ for ( i = 0; i < face->root.num_fixed_sizes; i++ )
+ {
+ if ( ( face->sbit_strikes[i].x_ppem == metrics->x_ppem ) &&
+ ( face->sbit_strikes[i].y_ppem == metrics->y_ppem ) )
+ {
+ /*
+ * XXX: We now set horizontal metrics,
+ * but this is not valid if we use vertical layout style
+ */
+ metrics->ascender =
+ face->sbit_strikes[i].hori.ascender * 64;
+ metrics->descender =
+ face->sbit_strikes[i].hori.descender * 64;
+ metrics->height =
+ ( face->sbit_strikes[i].hori.ascender -
+ face->sbit_strikes[i].hori.descender ) * 64;
+ /* XXX: Is this correct? */
+ metrics->max_advance =
+ ( face->sbit_strikes[i].hori.min_origin_SB +
+ face->sbit_strikes[i].hori.max_width +
+ face->sbit_strikes[i].hori.min_advance_SB ) * 64;
+ break;
+ }
+ }
+ if ( i == face->root.num_fixed_sizes )
+ return TT_Err_Invalid_PPem;
+ }
+ else
+
+#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
+
+ {
+ metrics->ascender = ( FT_MulFix( face->root.ascender,
metrics->y_scale ) + 32 ) & -64;
- metrics->descender = ( FT_MulFix( face->root.descender,
+ metrics->descender = ( FT_MulFix( face->root.descender,
metrics->y_scale ) + 32 ) & -64;
- metrics->height = ( FT_MulFix( face->root.height,
+ metrics->height = ( FT_MulFix( face->root.height,
metrics->y_scale ) + 32 ) & -64;
- metrics->max_advance = ( FT_MulFix( face->root.max_advance_width,
+ metrics->max_advance = ( FT_MulFix( face->root.max_advance_width,
metrics->x_scale ) + 32 ) & -64;
+ }
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER