Finally, the TrueType driver was completely audited. The code should now be 100% compatible with the implementation in FreeType 1.x. It's now time to make a new tag for the repository :-) - David
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 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 0a78315..5f0fb36 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -371,7 +371,6 @@
if ( c & 8 )
{
cnt = GET_Byte();
-
while( cnt > 0 )
{
flag[j++] = c;
@@ -648,10 +647,10 @@
element->element_flag = 0;
element->preserve_pps = FALSE;
- element->transform.xx = 1 << 16;
+ element->transform.xx = 0x10000;
element->transform.xy = 0;
element->transform.yx = 0;
- element->transform.yy = 1 << 16;
+ element->transform.yy = 0x10000;
element->transform.ox = 0;
element->transform.oy = 0;
@@ -728,6 +727,7 @@
TT_UShort index;
TT_UShort u;
TT_Long count;
+ TT_Long Top;
TT_Long glyph_offset, offset;
@@ -744,6 +744,7 @@
TPhases phase;
TT_Byte* widths;
+ TT_Int num_elem_points;
SFNT_Interface* sfnt;
@@ -905,7 +906,6 @@
}
phase = Load_Header;
- break;
/************************************************************/
/* */
@@ -923,8 +923,8 @@
count = 0;
if (index < face->num_locations-1)
count = face->glyph_locations[index+1] - offset;
-
- if ( index < ( face->num_locations - 1 ) && count == 0 )
+
+ if (count == 0)
{
/* as described by Frederic Loyer, these are spaces, and */
/* not the unknown glyph. */
@@ -993,13 +993,14 @@
}
/* is it a simple glyph ? */
- if ( num_contours > 0 )
- phase = Load_Simple;
- else
+ if ( num_contours < 0 )
+ {
phase = Load_Composite;
+ break;
+ }
- break;
-
+ phase = Load_Simple;
+
/************************************************************/
/* */
/* Load_Simple state */
@@ -1035,7 +1036,6 @@
num_points = exec->pts.n_points - 2;
phase = Load_End;
-
break;
/************************************************************/
@@ -1111,10 +1111,10 @@
subglyph->transform.oy = l;
}
- xx = 1 << 16;
+ xx = 0x10000;
xy = 0;
yx = 0;
- yy = 1 << 16;
+ yy = 0x10000;
if ( new_flags & WE_HAVE_A_SCALE )
{
@@ -1147,13 +1147,12 @@
k = FT_MulFix( xx, yy ) - FT_MulFix( xy, yx );
/* disable hinting in case of scaling/slanting */
- if ( ABS( k ) != (1 << 16) )
+ if ( ABS( k ) != 0x10000 )
subglyph2->is_hinted = FALSE;
subglyph->file_offset = FILE_Pos();
phase = Load_Glyph;
-
break;
/************************************************************/
@@ -1223,8 +1222,10 @@
/* adjust counts */
+ num_elem_points = subglyph->zone.n_points;
+
for ( k = 0; k < num_contours; k++ )
- subglyph2->zone.contours[k] += subglyph->zone.n_points;
+ subglyph2->zone.contours[k] += num_elem_points;
subglyph->zone.n_points += num_points;
subglyph->zone.n_contours += num_contours;
@@ -1239,14 +1240,14 @@
k = subglyph->arg1;
l = subglyph->arg2;
- if ( k >= subglyph->zone.n_points ||
+ if ( k >= num_elem_points ||
l >= num_points )
{
error = TT_Err_Invalid_Composite;
goto Fail;
}
- l += subglyph->zone.n_points;
+ l += num_elem_points;
x = subglyph->zone.cur[k].x - subglyph->zone.cur[l].x;
y = subglyph->zone.cur[k].y - subglyph->zone.cur[l].y;
@@ -1260,15 +1261,15 @@
{
x = SCALE_X( x );
y = SCALE_Y( y );
+
+ if ( subglyph->element_flag & ROUND_XY_TO_GRID )
+ {
+ x = (x + 32) & -64;
+ y = (y + 32) & -64;
+ }
}
}
- if ( subglyph->element_flag & ROUND_XY_TO_GRID )
- {
- x = (x + 32) & -64;
- y = (y + 32) & -64;
- }
-
translate_array( num_points, subglyph2->zone.cur, x, y );
cur_to_org( num_points, &subglyph2->zone );
@@ -1313,7 +1314,7 @@
exec->pts = base_pts;
- for ( u = 0; u < num_points; u++ )
+ for ( u = 0; u < num_points + 2; u++ )
{
glyph->outline.points[u] = exec->pts.cur[u];
glyph->outline.flags [u] = exec->pts.touch[u];
@@ -1327,7 +1328,7 @@
glyph->outline.second_pass = TRUE;
/* translate array so that (0,0) is the glyph's origin */
- translate_array( num_points, glyph->outline.points,
+ translate_array( num_points + 2, glyph->outline.points,
-subglyph->pp1.x, 0 );
FT_Get_Outline_CBox( &glyph->outline, &bbox );
@@ -1423,19 +1424,25 @@
}
}
+ /* We must adjust the top_bearing value from the bounding box given
+ in the glyph header to te bounding box calculated with
+ TT_Get_Outline_BBox() */
+
/* scale the metrics */
if ( !(load_flags & FT_LOAD_NO_SCALE) )
{
- top = SCALE_Y( top_bearing );
+ Top = SCALE_Y( top_bearing );
+ top = SCALE_Y( top_bearing + subglyph->bbox.yMax ) - bbox.yMax;
advance = SCALE_X( advance_height );
}
else
{
- top = top_bearing;
+ Top = top_bearing;
+ top = top_bearing + subglyph->bbox.yMax - bbox.yMax;
advance = advance_height;
}
- glyph->metrics2.vertBearingY = top;
+ glyph->metrics2.vertBearingY = Top;
glyph->metrics2.vertAdvance = advance;
/* XXX: for now, we have no better algorithm for the lsb, but it */
diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c
index caa14ab..24adfd8 100644
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -135,7 +135,6 @@
TT_Bool wide_chars = 1;
/* first pass, look for a given name record */
-
rec = face->name_table.names;
for ( n = 0; n < face->name_table.numNameRecords; n++, rec++ )
{
@@ -144,7 +143,6 @@
/* found the name - now create an ASCII string from it */
TT_Bool found = 0;
-
/* Test for Microsoft English language */
if ( rec->platformID == TT_PLATFORM_MICROSOFT &&
rec->encodingID < TT_MS_ID_UNICODE_CS &&