* src/truetype/ttgload.c (load_truetype_glyph): Save graphics state before handling subglyphs so that it can be reinitialized each time. This fixes Savannah bug #19859.
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
diff --git a/ChangeLog b/ChangeLog
index a24e9fb..45f753e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-05-19 Werner Lemberg <wl@gnu.org>
+
+ * src/truetype/ttgload.c (load_truetype_glyph): Save graphics state
+ before handling subglyphs so that it can be reinitialized each time.
+ This fixes Savannah bug #19859.
+
2007-05-16 Werner Lemberg <wl@gnu.org>
* src/cache/ftccache.c (ftc_node_mru_link, ftc_node_mru_unlink),
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 927f8ab..1f75a2c 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -1288,9 +1288,9 @@
/* otherwise, load a composite! */
else if ( loader->n_contours == -1 )
{
- FT_UInt start_point;
- FT_UInt start_contour;
- FT_ULong ins_pos; /* position of composite instructions, if any */
+ FT_UInt start_point;
+ FT_UInt start_contour;
+ FT_ULong ins_pos; /* position of composite instructions, if any */
start_point = gloader->base.outline.n_points;
@@ -1360,7 +1360,6 @@
/* if the flag FT_LOAD_NO_RECURSE is set, we return the subglyph */
/* `as is' in the glyph slot (the client application will be */
/* responsible for interpreting these data)... */
- /* */
if ( loader->load_flags & FT_LOAD_NO_RECURSE )
{
FT_GlyphLoader_Add( gloader );
@@ -1374,14 +1373,16 @@
/*********************************************************************/
{
- FT_UInt n, num_base_points;
- FT_SubGlyph subglyph = 0;
+ FT_UInt n, num_base_points;
+ FT_SubGlyph subglyph = 0;
+
+ FT_UInt num_points = start_point;
+ FT_UInt num_subglyphs = gloader->current.num_subglyphs;
+ FT_UInt num_base_subgs = gloader->base.num_subglyphs;
- FT_UInt num_points = start_point;
- FT_UInt num_subglyphs = gloader->current.num_subglyphs;
- FT_UInt num_base_subgs = gloader->base.num_subglyphs;
+ FT_Stream old_stream = loader->stream;
- FT_Stream old_stream = loader->stream;
+ TT_GraphicsState saved_GS = loader->exec->GS;
FT_GlyphLoader_Add( gloader );
@@ -1392,6 +1393,9 @@
FT_Vector pp[4];
+ /* reinitialize graphics state */
+ loader->exec->GS = saved_GS;
+
/* Each time we call load_truetype_glyph in this loop, the */
/* value of `gloader.base.subglyphs' can change due to table */
/* reallocations. We thus need to recompute the subglyph */
@@ -1426,12 +1430,12 @@
if ( num_points == num_base_points )
continue;
- /* gloader->base.outline consists of three part: */
- /* 0 -(1)-> start_point -(2)-> num_base_points -(3)-> n_points. */
- /* */
- /* (1): exist from the beginning */
- /* (2): components that have been loaded so far */
- /* (3): the newly loaded component */
+ /* gloader->base.outline consists of three parts: */
+ /* 0 -(1)-> start_point -(2)-> num_base_points -(3)-> n_points. */
+ /* */
+ /* (1): exists from the beginning */
+ /* (2): components that have been loaded so far */
+ /* (3): the newly loaded component */
TT_Process_Composite_Component( loader, subglyph, start_point,
num_base_points );
}
@@ -1455,7 +1459,7 @@
}
else
{
- /* invalid composite count ( negative but not -1 ) */
+ /* invalid composite count (negative but not -1) */
error = TT_Err_Invalid_Outline;
goto Exit;
}
@@ -1483,8 +1487,8 @@
static FT_Error
- compute_glyph_metrics( TT_Loader loader,
- FT_UInt glyph_index )
+ compute_glyph_metrics( TT_Loader loader,
+ FT_UInt glyph_index )
{
FT_BBox bbox;
TT_Face face = (TT_Face)loader->face;
@@ -1502,8 +1506,8 @@
else
bbox = loader->bbox;
- /* get the device-independent horizontal advance. It is scaled later */
- /* by the base layer. */
+ /* get the device-independent horizontal advance; it is scaled later */
+ /* by the base layer. */
{
FT_Pos advance = loader->linear;
@@ -1763,11 +1767,11 @@
tt_size_run_prep( size );
}
- /* see if the cvt program has disabled hinting */
+ /* see whether the cvt program has disabled hinting */
if ( exec->GS.instruct_control & 1 )
load_flags |= FT_LOAD_NO_HINTING;
- /* load default graphics state - if needed */
+ /* load default graphics state -- if needed */
if ( exec->GS.instruct_control & 2 )
exec->GS = tt_default_graphics_state;
@@ -1778,7 +1782,7 @@
#endif /* TT_USE_BYTECODE_INTERPRETER */
- /* seek to the beginning of the glyph table. For Type 42 fonts */
+ /* seek to the beginning of the glyph table -- for Type 42 fonts */
/* the table might be accessed from a Postscript stream or something */
/* else... */
@@ -1894,7 +1898,7 @@
glyph->num_subglyphs = 0;
glyph->outline.flags = 0;
- /* Main loading loop */
+ /* main loading loop */
error = load_truetype_glyph( &loader, glyph_index, 0 );
if ( !error )
{