added code to correctly scale global metrics
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 66
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index 2892774..d52fb09 100644
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -121,10 +121,29 @@
LOCAL_FUNC
T1_Error T1_Reset_Size( T1_Size size )
{
+ /* recompute ascender, descender, etc.. */
+ T1_Face face = (T1_Face)size->root.face;
+ FT_Size_Metrics* metrics = &size->root.metrics;
+
+ if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 )
+ return FT_Err_Invalid_Argument;
+
+ /* Compute root ascender, descender, test height, and max_advance */
+ metrics->ascender = ( FT_MulFix( face->root.ascender,
+ metrics->y_scale ) + 32 ) & -64;
+
+ metrics->descender = ( FT_MulFix( face->root.descender,
+ metrics->y_scale ) + 32 ) & -64;
+
+ metrics->height = ( FT_MulFix( face->root.height,
+ metrics->y_scale ) + 32 ) & -64;
+
+ metrics->max_advance = ( FT_MulFix( face->root.max_advance_width,
+ metrics->x_scale ) + 32 ) & -64;
+
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
return T1_Reset_Size_Hinter( size );
#else
- (void)size;
return 0;
#endif
}
diff --git a/src/type1z/t1objs.c b/src/type1z/t1objs.c
index 48ac8cf..84dd55b 100644
--- a/src/type1z/t1objs.c
+++ b/src/type1z/t1objs.c
@@ -101,7 +101,25 @@
LOCAL_FUNC
T1_Error T1_Reset_Size( T1_Size size )
{
- UNUSED(size);
+ /* recompute ascender, descender, etc.. */
+ T1_Face face = (T1_Face)size->root.face;
+ FT_Size_Metrics* metrics = &size->root.metrics;
+
+ if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 )
+ return FT_Err_Invalid_Argument;
+
+ /* Compute root ascender, descender, test height, and max_advance */
+ metrics->ascender = ( FT_MulFix( face->root.ascender,
+ metrics->y_scale ) + 32 ) & -64;
+
+ metrics->descender = ( FT_MulFix( face->root.descender,
+ metrics->y_scale ) + 32 ) & -64;
+
+ metrics->height = ( FT_MulFix( face->root.height,
+ metrics->y_scale ) + 32 ) & -64;
+
+ metrics->max_advance = ( FT_MulFix( face->root.max_advance_width,
+ metrics->x_scale ) + 32 ) & -64;
return 0;
}