* src/truetype/ttdriver.c (Set_Char_Sizes): Avoid unnecessary computations and clean up. * src/truetype/ttobjs.h (struct TT_SizeRec_): Comment on the internal copy of 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
diff --git a/ChangeLog b/ChangeLog
index bd45e87..8685464 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2005-07-26 Chia I Wu <b90201047@ntu.edu.tw>
+
+ * src/truetype/ttdriver.c (Set_Char_Sizes): Avoid unnecessary
+ computations and clean up.
+
+ * src/truetype/ttobjs.h (struct TT_SizeRec_): Comment on the
+ internal copy of metrics.
+
2005-07-12 Werner Lemberg <wl@gnu.org>
* include/freetype/ftoutln.h (FT_Outline_Embolden): Fix prototype.
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index c981dfd..100e0db 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -167,40 +167,33 @@
FT_UInt horz_resolution,
FT_UInt vert_resolution )
{
- TT_Size size = (TT_Size)ttsize;
- FT_Size_Metrics* metrics = &size->root.metrics;
- FT_Size_Metrics* metrics2 = &size->metrics;
- TT_Face face = (TT_Face)size->root.face;
- FT_Long dim_x, dim_y;
+ TT_Size size = (TT_Size)ttsize;
+ FT_Size_Metrics* metrics = &size->metrics;
+ TT_Face face = (TT_Face)size->root.face;
- *metrics2 = *metrics;
+ /* copy the result from base layer */
+ *metrics = size->root.metrics;
/* This bit flag, when set, indicates that the pixel size must be */
- /* truncated to an integer. Nearly all TrueType fonts have this */
- /* bit set, as hinting won't work really well otherwise. */
+ /* rounded to integer. Nearly all TrueType fonts have this bit */
+ /* set, as hinting won't work really well otherwise. */
/* */
if ( ( face->header.Flags & 8 ) != 0 )
{
- /* we need to use rounding in the following computations. Otherwise,
- * the resulting hinted outlines will be very slightly distorted
- */
- dim_x = ( ( char_width * horz_resolution + (36+32*72) ) / 72 ) & ~63;
- dim_y = ( ( char_height * vert_resolution + (36+32*72) ) / 72 ) & ~63;
- }
- else
- {
- dim_x = ( ( char_width * horz_resolution + 36 ) / 72 );
- dim_y = ( ( char_height * vert_resolution + 36 ) / 72 );
- }
+ FT_Long dim_x, dim_y;
- /* we only modify "metrics2", not "metrics", so these changes have */
- /* no effect on the result of the auto-hinter when it is used */
- /* */
- metrics2->x_ppem = (FT_UShort)( dim_x >> 6 );
- metrics2->y_ppem = (FT_UShort)( dim_y >> 6 );
- metrics2->x_scale = FT_DivFix( dim_x, face->root.units_per_EM );
- metrics2->y_scale = FT_DivFix( dim_y, face->root.units_per_EM );
+ dim_x = ( char_width * horz_resolution + 36 ) / 72;
+ dim_y = ( char_height * vert_resolution + 36 ) / 72;
+
+ dim_x = FT_PIX_ROUND(dim_x);
+ dim_y = FT_PIX_ROUND(dim_y);
+
+ metrics->x_ppem = (FT_UShort)( dim_x >> 6 );
+ metrics->y_ppem = (FT_UShort)( dim_y >> 6 );
+ metrics->x_scale = FT_DivFix( dim_x, face->root.units_per_EM );
+ metrics->y_scale = FT_DivFix( dim_y, face->root.units_per_EM );
+ }
size->ttmetrics.valid = FALSE;
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
diff --git a/src/truetype/ttobjs.h b/src/truetype/ttobjs.h
index 423d3f0..d193b2d 100644
--- a/src/truetype/ttobjs.h
+++ b/src/truetype/ttobjs.h
@@ -316,7 +316,10 @@ FT_BEGIN_HEADER
{
FT_SizeRec root;
- FT_Size_Metrics metrics; /* slightly different from the root metrics */
+ /* we have our own copy of metrics so that we can modify */
+ /* it without affecting auto-hinting (when used) */
+ FT_Size_Metrics metrics;
+
TT_Size_Metrics ttmetrics;
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS