* src/truetype/ttdriver.c, src/truetype/ttobjs.h, src/truetype/ttobjs.c, src/truetype/ttinterp.c, src/base/ftobjs.c: fixing the slight distortion problem that occured due to the latest auto-hinter changes
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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
diff --git a/ChangeLog b/ChangeLog
index 39cb00d..6b8f149 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,20 @@
+2003-02-18 David Turner <david@freetype.org>
+
+ * src/truetype/ttdriver.c, src/truetype/ttobjs.h, src/truetype/ttobjs.c,
+ src/truetype/ttinterp.c, src/base/ftobjs.c: fixing the slight distortion
+ problem that occured due to the latest auto-hinter changes
+
+
+
2003-02-13 Graham Asher <graham.asher@btinternet.com>
- * include/freetype/ftincrem.h, src/cff/cffgload.c, src/cid/cidgload.c,
- src/truetype/ttgload.c, src/type1/t1gload.c
- [FT_CONFIG_OPTION_INCREMENTAL]: I have changed the incremental loading
- interface in a way that makes it simpler and allows glyph metrics to
- be changed (e.g., by adding a constant, as required by CFF fonts)
- rather than just overridden. This was required to make the GhsotScript-
- to-FreeType bridge work.
+ * include/freetype/ftincrem.h, src/cff/cffgload.c, src/cid/cidgload.c,
+ src/truetype/ttgload.c, src/type1/t1gload.c
+ [FT_CONFIG_OPTION_INCREMENTAL]: I have changed the incremental loading
+ interface in a way that makes it simpler and allows glyph metrics to
+ be changed (e.g., by adding a constant, as required by CFF fonts)
+ rather than just overridden. This was required to make the GhsotScript-
+ to-FreeType bridge work.
2003-01-31 David Turner <david@freetype.org>
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 2852d46..3254738 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -1330,10 +1330,10 @@
/* Compute root ascender, descender, test height, and max_advance */
metrics->ascender = ( FT_MulFix( face->ascender,
- metrics->y_scale ) + 32 ) & -64;
+ metrics->y_scale ) + 63 ) & -64;
metrics->descender = ( FT_MulFix( face->descender,
- metrics->y_scale ) + 32 ) & -64;
+ metrics->y_scale ) + 0 ) & -64;
metrics->height = ( FT_MulFix( face->height,
metrics->y_scale ) + 32 ) & -64;
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index 1f54488..c4d1de4 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -190,43 +190,32 @@
FT_UInt horz_resolution,
FT_UInt vert_resolution )
{
- FT_Size_Metrics* metrics = &size->root.metrics;
- TT_Face face = (TT_Face)size->root.face;
+ FT_Size_Metrics* metrics = &size->root.metrics;
+ FT_Size_Metrics* metrics2 = &size->metrics;
+ TT_Face face = (TT_Face)size->root.face;
+ *metrics2 = *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. */
/* */
- /* However, for those rare fonts who do not set it, we override */
- /* the default computations performed by the base layer. I */
- /* really don't know whether this is useful, but hey, that's the */
- /* spec :-) */
- /* */
-#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
- if ( ( face->header.Flags & 8 ) == 0 )
+ if ( ( face->header.Flags & 8 ) != 0 )
{
- /* Compute pixel sizes in 26.6 units */
FT_Long dim_x, dim_y;
- dim_x = ( char_width * horz_resolution + 36 ) / 72;
- dim_y = ( char_height * vert_resolution + 36 ) / 72;
-
- metrics->x_scale = FT_DivFix( dim_x, face->root.units_per_EM );
- metrics->y_scale = FT_DivFix( dim_y, face->root.units_per_EM );
+ /* 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 ) / 72 ) + 32 ) & -64;
+ dim_y = ( ( ( char_height * vert_resolution ) / 72 ) + 32 ) & -64;
- metrics->x_ppem = (FT_UShort)( dim_x >> 6 );
- metrics->y_ppem = (FT_UShort)( dim_y >> 6 );
+ 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 );
}
-#else
- FT_UNUSED( vert_resolution );
- FT_UNUSED( horz_resolution );
- FT_UNUSED( char_height );
- FT_UNUSED( char_width );
-
- FT_UNUSED( face );
- FT_UNUSED( metrics );
-#endif
size->ttmetrics.valid = FALSE;
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
@@ -267,6 +256,7 @@
/* many things have been pre-computed by the base layer */
+ size->metrics = size->root.metrics;
size->ttmetrics.valid = FALSE;
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
size->strike_index = 0xFFFF;
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index cee0f78..74726a1 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -568,7 +568,7 @@
exec->FDefs = size->function_defs;
exec->IDefs = size->instruction_defs;
exec->tt_metrics = size->ttmetrics;
- exec->metrics = size->root.metrics;
+ exec->metrics = size->metrics;
exec->maxFunc = size->max_func;
exec->maxIns = size->max_ins;
diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c
index 41afa35..6835648 100644
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -541,7 +541,7 @@
face = (TT_Face)size->root.face;
- metrics = &size->root.metrics;
+ metrics = &size->metrics;
if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 )
return TT_Err_Invalid_PPem;
@@ -566,21 +566,11 @@
size->ttmetrics.y_ratio = 0x10000L;
}
-#ifdef FT_CONFIG_CHESTER_ASCENDER
-
- /* Compute root ascender, descender, test height, and max_advance */
- metrics->ascender = ( FT_MulFix( face->root.ascender,
- metrics->y_scale ) + 63 ) & -64;
- metrics->descender = ( FT_MulFix( face->root.descender,
- metrics->y_scale ) + 0 ) & -64;
-#else /* !CHESTER_ASCENDER */
/* 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;
-#endif /* !CHESTER_ASCENDER */
-
metrics->height = ( FT_MulFix( face->root.height,
metrics->y_scale ) + 32 ) & -64;
metrics->max_advance = ( FT_MulFix( face->root.max_advance_width,
@@ -701,7 +691,7 @@
SFNT_Service sfnt;
- metrics = &size->root.metrics;
+ metrics = &size->metrics;
if ( size->strike_index != 0xFFFFU )
return TT_Err_Ok;
@@ -739,8 +729,8 @@
sbit_metrics->descender;
/* XXX: Is this correct? */
- sbit_metrics->max_advance = ( strike->hori.min_origin_SB +
- strike->hori.max_width +
+ sbit_metrics->max_advance = ( strike->hori.min_origin_SB +
+ strike->hori.max_width +
strike->hori.min_advance_SB ) << 6;
size->strike_index = strike_index;
diff --git a/src/truetype/ttobjs.h b/src/truetype/ttobjs.h
index 28bcdc4..e462d64 100644
--- a/src/truetype/ttobjs.h
+++ b/src/truetype/ttobjs.h
@@ -311,6 +311,7 @@ FT_BEGIN_HEADER
{
FT_SizeRec root;
+ FT_Size_Metrics metrics; /* slightly different from the root metrics */
TT_Size_Metrics ttmetrics;
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS