trying to fix TrueType rendering glitches
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
diff --git a/ChangeLog b/ChangeLog
index 409e3bd..73319f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-03-14 David Turner <david@freetype.org>
+
+ * src/truetype/ttdriver.c: fixing the small TrueType native rendering
+ glitches, they came from a small rounding error.
+
2003-03-13 David Turner <david@freetype.org>
* src/base/ftdbgmem.c, docs/DEBUG.TXT: added new environment variables
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index cc58b06..174cd85 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -193,6 +193,7 @@
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;
*metrics2 = *metrics;
@@ -203,19 +204,25 @@
/* */
if ( ( face->header.Flags & 8 ) != 0 )
{
- FT_Long dim_x, dim_y;
-
/* 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 ) / 72;
- dim_y = ( char_height * vert_resolution + 36 ) / 72;
-
- 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 ) / 72 ) + 32 ) & -64;
+ dim_y = ( ( ( char_height * vert_resolution ) / 72 ) + 32 ) & -64;
}
+ else
+ {
+ dim_x = ( ( char_width * horz_resolution + 36 ) / 72 );
+ dim_y = ( ( char_height * vert_resolution + 36 ) / 72 );
+ }
+
+ /* 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 );
size->ttmetrics.valid = FALSE;
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS