[truetype] Fix last `truetype' commit. * src/truetype/ttgload.c (tt_get_metrics): Preserve stream position. Return error value. (load_truetype_glyph): Updated.
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
diff --git a/ChangeLog b/ChangeLog
index 8c95b96..9614fca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2013-11-12 Werner Lemberg <wl@gnu.org>
+
+ [truetype] Fix last `truetype' commit.
+
+ * src/truetype/ttgload.c (tt_get_metrics): Preserve stream position.
+ Return error value.
+ (load_truetype_glyph): Updated.
+
2013-11-10 Werner Lemberg <wl@gnu.org>
* docs/CMAKE: New dummy file.
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 5497562..aaeae34 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -114,7 +114,7 @@
}
- static void
+ static FT_Error
tt_get_metrics( TT_Loader loader,
FT_UInt glyph_index )
{
@@ -123,9 +123,16 @@
TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
#endif
+ FT_Error error;
+ FT_Stream stream = loader->stream;
+
FT_Short left_bearing = 0, top_bearing = 0;
FT_UShort advance_width = 0, advance_height = 0;
+ /* we must preserve the stream position */
+ /* (which gets altered by the metrics functions) */
+ FT_ULong pos = FT_STREAM_POS();
+
TT_Get_HMetrics( face, glyph_index,
&left_bearing,
@@ -135,6 +142,9 @@
&top_bearing,
&advance_height );
+ if ( FT_STREAM_SEEK( pos ) )
+ return error;
+
loader->left_bearing = left_bearing;
loader->advance = advance_width;
loader->top_bearing = top_bearing;
@@ -157,6 +167,8 @@
loader->linear_def = 1;
loader->linear = advance_width;
}
+
+ return FT_Err_Ok;
}
@@ -1452,7 +1464,9 @@
/* the metrics must be computed after loading the glyph header */
/* since we need the glyph's `yMax' value in case the vertical */
/* metrics must be emulated */
- tt_get_metrics( loader, glyph_index );
+ error = tt_get_metrics( loader, glyph_index );
+ if ( error )
+ goto Exit;
if ( header_only )
goto Exit;
@@ -1465,7 +1479,9 @@
loader->bbox.yMin = 0;
loader->bbox.yMax = 0;
- tt_get_metrics( loader, glyph_index );
+ error = tt_get_metrics( loader, glyph_index );
+ if ( error )
+ goto Exit;
if ( header_only )
goto Exit;