slight speed-up of the TrueType glyph loader
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
diff --git a/ChangeLog b/ChangeLog
index 6f8aa54..ee6ba16 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2007-06-10 David Turner <david@freetype.org>
+ * src/truetype/ttgload.c: slight speed-up to the TrueType glyph loader
+
* include/freetype/config/ftoption.h: clarify documentation regarding
unpatented hinting
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 55e43bc..3ff639d 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -251,6 +251,7 @@
FT_Vector *vec, *vec_limit;
FT_Pos x;
FT_Short *cont, *cont_limit;
+ FT_Int xy_size = 0;
/* check that we can add the contours to the glyph */
@@ -362,23 +363,27 @@
flag = (FT_Byte*)outline->tags;
x = 0;
+ if ( p + xy_size > limit )
+ goto Invalid_Outline;
+
for ( ; vec < vec_limit; vec++, flag++ )
{
FT_Pos y = 0;
+ FT_Byte f = *flag;
- if ( *flag & 2 )
+ if ( f & 2 )
{
- if ( p + 1 > limit )
+ if (p + 1 > limit)
goto Invalid_Outline;
y = (FT_Pos)FT_NEXT_BYTE( p );
- if ( ( *flag & 16 ) == 0 )
+ if ( ( f & 16 ) == 0 )
y = -y;
}
- else if ( ( *flag & 16 ) == 0 )
+ else if ( ( f & 16 ) == 0 )
{
- if ( p + 2 > limit )
+ if (p + 2 > limit)
goto Invalid_Outline;
y = (FT_Pos)FT_NEXT_SHORT( p );
@@ -386,6 +391,7 @@
x += y;
vec->x = x;
+ *flag = f & ~(2|16);
}
/* reading the Y coordinates */
@@ -398,20 +404,21 @@
for ( ; vec < vec_limit; vec++, flag++ )
{
FT_Pos y = 0;
+ FT_Byte f = *flag;
- if ( *flag & 4 )
+ if ( f & 4 )
{
- if ( p +1 > limit )
+ if (p + 1 > limit)
goto Invalid_Outline;
y = (FT_Pos)FT_NEXT_BYTE( p );
- if ( ( *flag & 32 ) == 0 )
+ if ( ( f & 32 ) == 0 )
y = -y;
}
- else if ( ( *flag & 32 ) == 0 )
+ else if ( ( f & 32 ) == 0 )
{
- if ( p + 2 > limit )
+ if (p + 2 > limit)
goto Invalid_Outline;
y = (FT_Pos)FT_NEXT_SHORT( p );
@@ -419,12 +426,9 @@
x += y;
vec->y = x;
+ *flag = f & ~(4|32);
}
- /* clear the touch tags */
- for ( n = 0; n < n_points; n++ )
- outline->tags[n] &= FT_CURVE_TAG_ON;
-
outline->n_points = (FT_UShort)n_points;
outline->n_contours = (FT_Short) n_contours;