Merge lp:~3v1n0/ubuntu/trusty/freetype/multithread-safe into lp:ubuntu/trusty-updates/freetype

Proposed by Marco Trevisan (Treviño)
Status: Approved
Approved by: Brian Murray
Approved revision: 62
Proposed branch: lp:~3v1n0/ubuntu/trusty/freetype/multithread-safe
Merge into: lp:ubuntu/trusty-updates/freetype
Diff against target: 2133 lines (+2113/-0)
3 files modified
debian/changelog (+7/-0)
debian/patches-freetype/multi-thread-violations.patch (+2105/-0)
debian/patches-freetype/series (+1/-0)
To merge this branch: bzr merge lp:~3v1n0/ubuntu/trusty/freetype/multithread-safe
Reviewer Review Type Date Requested Status
Brian Murray Approve
Review via email: mp+247375@code.launchpad.net

Description of the change

Proposing fixes included in lp:~3v1n0/ubuntu/vivid/freetype/multithread-safe to trusty.

---
Backported patches coming from this patchset [1] that has been just merged upstream [2] and that fixes huge multithread violations that are causing crashes in a lot of places in the upper stack.

Here [3] you can read more details about this patch.

[1] https://github.com/behdad/freetype/tree/ftthread
[2] http://<email address hidden>/msg06780.html
[3] http://<email address hidden>/msg06758.html

For being precise, this patch includes the changes merged in commits:
  http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=89bc8d4d
  http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=531d463a
  http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=747ae2c8
  http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=8dc86358
  http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=a773c304
  http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=6dfdaf4d
  http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=51634253
  http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=603292d7
  http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=b2ba6866
  http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=c242fe41
  http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=ae6699f8
  http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=a4117fbd
  http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=c2733656
  http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=6f16b100
  http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=56ddafa0
  http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=48c86628
  http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=4eff854c

To post a comment you must log in.
61. By Marco Trevisan (Treviño)

debian/patches-freetype/multi-thread-violations.patch: include commit 264b5e46

Fixes chrome rendering issues

62. By Marco Trevisan (Treviño)

Add back ft_raster5_renderer_class symbol

Revision history for this message
Brian Murray (brian-murray) wrote :

I've uploaded this but the bug report is missing SRU information, see my comment there.

review: Approve

Unmerged revisions

62. By Marco Trevisan (Treviño)

Add back ft_raster5_renderer_class symbol

61. By Marco Trevisan (Treviño)

debian/patches-freetype/multi-thread-violations.patch: include commit 264b5e46

Fixes chrome rendering issues

60. By Marco Trevisan (Treviño)

Merging with lp:ubuntu/trusty-updates/freetype

59. By Marco Trevisan (Treviño)

Added patchset to fix multithread violations, LP: #1199571
    - debian/patches-freetype/multi-thread-violations.patch

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2014-04-27 22:05:39 +0000
+++ debian/changelog 2015-01-26 16:10:26 +0000
@@ -1,3 +1,10 @@
1freetype (2.5.2-1ubuntu2.3) trusty; urgency=medium
2
3 * Added patchset to fix multithread violations, LP: #1199571
4 - debian/patches-freetype/multi-thread-violations.patch
5
6 -- Marco Trevisan (Treviño) <marco@ubuntu.com> Fri, 23 Jan 2015 03:38:04 +0100
7
1freetype (2.5.2-1ubuntu2.2) trusty; urgency=medium8freetype (2.5.2-1ubuntu2.2) trusty; urgency=medium
29
3 * Fix incorrect Korean Fonts rendering. (LP: #1310017)10 * Fix incorrect Korean Fonts rendering. (LP: #1310017)
411
=== added file 'debian/patches-freetype/multi-thread-violations.patch'
--- debian/patches-freetype/multi-thread-violations.patch 1970-01-01 00:00:00 +0000
+++ debian/patches-freetype/multi-thread-violations.patch 2015-01-26 16:10:26 +0000
@@ -0,0 +1,2105 @@
1Author: Behdad Esfahbod <behdad@behdad.org>
2Description: Multithread-safe FreeType
3Forwarded: http://www.mail-archive.com/freetype-devel@nongnu.org/msg06758.html
4Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69034
5Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/freetype/+bug/1199571
6Origin: upstream, https://github.com/behdad/freetype/commits/ftthread
7Applied-Upstream: 2.5.6, git commits 89bc8d4d, 531d463a, 747ae2c8, 8dc86358,
8 a773c304, 6dfdaf4d, 51634253, 603292d7, b2ba6866, c242fe41, ae6699f8, a4117fbd,
9 c2733656, 6f16b100, 56ddafa0, 48c86628, 4eff854c, 264b5e46
10
11
12Index: freetype-2.5.2/devel/ftoption.h
13===================================================================
14--- freetype-2.5.2.orig/devel/ftoption.h 2015-01-26 16:49:42.692849510 +0100
15+++ freetype-2.5.2/devel/ftoption.h 2015-01-26 16:49:42.668849502 +0100
16@@ -365,10 +365,6 @@
17 /* The size in bytes of the render pool used by the scan-line converter */
18 /* to do all of its work. */
19 /* */
20- /* This must be greater than 4KByte if you use FreeType to rasterize */
21- /* glyphs; otherwise, you may set it to zero to avoid unnecessary */
22- /* allocation of the render pool. */
23- /* */
24 #define FT_RENDER_POOL_SIZE 16384L
25
26
27Index: freetype-2.5.2/include/config/ftoption.h
28===================================================================
29--- freetype-2.5.2.orig/include/config/ftoption.h 2015-01-26 16:49:42.692849510 +0100
30+++ freetype-2.5.2/include/config/ftoption.h 2015-01-26 16:49:42.668849502 +0100
31@@ -365,10 +365,6 @@
32 /* The size in bytes of the render pool used by the scan-line converter */
33 /* to do all of its work. */
34 /* */
35- /* This must be greater than 4KByte if you use FreeType to rasterize */
36- /* glyphs; otherwise, you may set it to zero to avoid unnecessary */
37- /* allocation of the render pool. */
38- /* */
39 #define FT_RENDER_POOL_SIZE 16384L
40
41
42Index: freetype-2.5.2/include/freetype.h
43===================================================================
44--- freetype-2.5.2.orig/include/freetype.h 2015-01-26 16:49:42.692849510 +0100
45+++ freetype-2.5.2/include/freetype.h 2015-01-26 16:49:42.672849504 +0100
46@@ -332,8 +332,11 @@
47 /* It also embeds a memory manager (see @FT_Memory), as well as a */
48 /* scan-line converter object (see @FT_Raster). */
49 /* */
50- /* In multi-threaded applications, make sure that the same FT_Library */
51- /* object or any of its children doesn't get accessed in parallel. */
52+ /* In multi-threaded applications it is easiest to use one */
53+ /* `FT_Library' object per thread. In case this is too cumbersome, */
54+ /* a single `FT_Library' object across threads is possible also */
55+ /* (since FreeType version 2.5.6), as long as a mutex lock is used */
56+ /* around @FT_New_Face and @FT_Done_Face. */
57 /* */
58 /* <Note> */
59 /* Library objects are normally created by @FT_Init_FreeType, and */
60@@ -401,6 +404,14 @@
61 /* */
62 /* Use @FT_Done_Face to destroy it (along with its slot and sizes). */
63 /* */
64+ /* An `FT_Face' object can only be safely used from one thread at a */
65+ /* time. Similarly, creation and destruction of `FT_Face' with the */
66+ /* same @FT_Library object can only be done from one thread at a */
67+ /* time. On the other hand, functions like @FT_Load_Glyph and its */
68+ /* siblings are thread-safe and do not need the lock to be held as */
69+ /* long as the same `FT_Face' object is not used from multiple */
70+ /* threads at the same time. */
71+ /* */
72 /* <Also> */
73 /* See @FT_FaceRec for the publicly accessible fields of a given face */
74 /* object. */
75@@ -1701,8 +1712,8 @@
76 /* use @FT_New_Library instead, followed by a call to */
77 /* @FT_Add_Default_Modules (or a series of calls to @FT_Add_Module). */
78 /* */
79- /* For multi-threading applications each thread should have its own */
80- /* FT_Library object. */
81+ /* See the documentation of @FT_Library and @FT_Face for */
82+ /* multi-threading issues. */
83 /* */
84 /* If you need reference-counting (cf. @FT_Reference_Library), use */
85 /* @FT_New_Library and @FT_Done_Library. */
86Index: freetype-2.5.2/include/ftimage.h
87===================================================================
88--- freetype-2.5.2.orig/include/ftimage.h 2015-01-26 16:49:42.692849510 +0100
89+++ freetype-2.5.2/include/ftimage.h 2015-01-26 16:49:42.672849504 +0100
90@@ -1179,10 +1179,10 @@
91 /* FT_Raster_ResetFunc */
92 /* */
93 /* <Description> */
94- /* FreeType provides an area of memory called the `render pool', */
95- /* available to all registered rasters. This pool can be freely used */
96- /* during a given scan-conversion but is shared by all rasters. Its */
97- /* content is thus transient. */
98+ /* FreeType used to provide an area of memory called the `render */
99+ /* pool' available to all registered rasters. This was not thread */
100+ /* safe however and now FreeType never allocates this pool. NULL */
101+ /* is always passed in as pool_base. */
102 /* */
103 /* This function is called each time the render pool changes, or just */
104 /* after a new raster object is created. */
105@@ -1195,10 +1195,9 @@
106 /* pool_size :: The size in bytes of the render pool. */
107 /* */
108 /* <Note> */
109- /* Rasters can ignore the render pool and rely on dynamic memory */
110+ /* Rasters should ignore the render pool and rely on dynamic or stack */
111 /* allocation if they want to (a handle to the memory allocator is */
112- /* passed to the raster constructor). However, this is not */
113- /* recommended for efficiency purposes. */
114+ /* passed to the raster constructor). */
115 /* */
116 typedef void
117 (*FT_Raster_ResetFunc)( FT_Raster raster,
118Index: freetype-2.5.2/include/ftrender.h
119===================================================================
120--- freetype-2.5.2.orig/include/ftrender.h 2015-01-26 16:49:42.692849510 +0100
121+++ freetype-2.5.2/include/ftrender.h 2015-01-26 16:49:42.672849504 +0100
122@@ -212,13 +212,8 @@
123 /* */
124 /* This doesn't change the current renderer for other formats. */
125 /* */
126- /* Currently, only the B/W renderer, if compiled with */
127- /* FT_RASTER_OPTION_ANTI_ALIASING (providing a 5-levels */
128- /* anti-aliasing mode; this option must be set directly in */
129- /* `ftraster.c' and is undefined by default) accepts a single tag */
130- /* `pal5' to set its gray palette as a character string with */
131- /* 5~elements. Consequently, the third and fourth argument are zero */
132- /* normally. */
133+ /* Currently, no FreeType renderer module uses `parameters'; you */
134+ /* should thus always pass NULL as the value. */
135 /* */
136 FT_EXPORT( FT_Error )
137 FT_Set_Renderer( FT_Library library,
138Index: freetype-2.5.2/include/internal/ftobjs.h
139===================================================================
140--- freetype-2.5.2.orig/include/internal/ftobjs.h 2015-01-26 16:49:42.692849510 +0100
141+++ freetype-2.5.2/include/internal/ftobjs.h 2015-01-26 16:49:42.672849504 +0100
142@@ -738,9 +738,8 @@
143 /* faces_list :: The list of faces currently opened by this */
144 /* driver. */
145 /* */
146- /* glyph_loader :: The glyph loader for all faces managed by this */
147- /* driver. This object isn't defined for unscalable */
148- /* formats. */
149+ /* glyph_loader :: Unused. Used to be glyph loader for all faces */
150+ /* managed by this driver. */
151 /* */
152 typedef struct FT_DriverRec_
153 {
154Index: freetype-2.5.2/src/autofit/afhints.c
155===================================================================
156--- freetype-2.5.2.orig/src/autofit/afhints.c 2015-01-26 16:49:42.692849510 +0100
157+++ freetype-2.5.2/src/autofit/afhints.c 2015-01-26 16:49:42.672849504 +0100
158@@ -43,7 +43,15 @@
159 AF_Segment segment = NULL;
160
161
162- if ( axis->num_segments >= axis->max_segments )
163+ if ( axis->num_segments < AF_SEGMENTS_EMBEDDED )
164+ {
165+ if ( axis->segments == NULL )
166+ {
167+ axis->segments = axis->embedded.segments;
168+ axis->max_segments = AF_SEGMENTS_EMBEDDED;
169+ }
170+ }
171+ else if ( axis->num_segments >= axis->max_segments )
172 {
173 FT_Int old_max = axis->max_segments;
174 FT_Int new_max = old_max;
175@@ -60,8 +68,18 @@
176 if ( new_max < old_max || new_max > big_max )
177 new_max = big_max;
178
179- if ( FT_RENEW_ARRAY( axis->segments, old_max, new_max ) )
180- goto Exit;
181+ if ( axis->segments == axis->embedded.segments )
182+ {
183+ if ( FT_NEW_ARRAY( axis->segments, new_max ) )
184+ goto Exit;
185+ ft_memcpy( axis->segments, axis->embedded.segments,
186+ sizeof ( axis->embedded.segments ) );
187+ }
188+ else
189+ {
190+ if ( FT_RENEW_ARRAY( axis->segments, old_max, new_max ) )
191+ goto Exit;
192+ }
193
194 axis->max_segments = new_max;
195 }
196@@ -88,7 +106,15 @@
197 AF_Edge edges;
198
199
200- if ( axis->num_edges >= axis->max_edges )
201+ if ( axis->num_edges < AF_EDGES_EMBEDDED )
202+ {
203+ if ( axis->edges == NULL )
204+ {
205+ axis->edges = axis->embedded.edges;
206+ axis->max_edges = AF_EDGES_EMBEDDED;
207+ }
208+ }
209+ else if ( axis->num_edges >= axis->max_edges )
210 {
211 FT_Int old_max = axis->max_edges;
212 FT_Int new_max = old_max;
213@@ -105,8 +131,18 @@
214 if ( new_max < old_max || new_max > big_max )
215 new_max = big_max;
216
217- if ( FT_RENEW_ARRAY( axis->edges, old_max, new_max ) )
218- goto Exit;
219+ if ( axis->edges == axis->embedded.edges )
220+ {
221+ if ( FT_NEW_ARRAY( axis->edges, new_max ) )
222+ goto Exit;
223+ ft_memcpy( axis->edges, axis->embedded.edges,
224+ sizeof ( axis->embedded.edges ) );
225+ }
226+ else
227+ {
228+ if ( FT_RENEW_ARRAY( axis->edges, old_max, new_max ) )
229+ goto Exit;
230+ }
231
232 axis->max_edges = new_max;
233 }
234@@ -485,7 +521,8 @@
235 af_glyph_hints_init( AF_GlyphHints hints,
236 FT_Memory memory )
237 {
238- FT_ZERO( hints );
239+ /* no need to initialize the embedded items */
240+ FT_MEM_ZERO( hints, sizeof ( *hints ) - sizeof ( hints->embedded ) );
241 hints->memory = memory;
242 }
243
244@@ -511,20 +548,24 @@
245
246 axis->num_segments = 0;
247 axis->max_segments = 0;
248- FT_FREE( axis->segments );
249+ if ( axis->segments != axis->embedded.segments )
250+ FT_FREE( axis->segments );
251
252 axis->num_edges = 0;
253 axis->max_edges = 0;
254- FT_FREE( axis->edges );
255+ if ( axis->edges != axis->embedded.edges )
256+ FT_FREE( axis->edges );
257 }
258
259- FT_FREE( hints->contours );
260+ if ( hints->contours != hints->embedded.contours )
261+ FT_FREE( hints->contours );
262 hints->max_contours = 0;
263 hints->num_contours = 0;
264
265- FT_FREE( hints->points );
266- hints->num_points = 0;
267+ if ( hints->points != hints->embedded.points )
268+ FT_FREE( hints->points );
269 hints->max_points = 0;
270+ hints->num_points = 0;
271
272 hints->memory = NULL;
273 }
274@@ -569,8 +610,14 @@
275 /* first of all, reallocate the contours array if necessary */
276 new_max = (FT_UInt)outline->n_contours;
277 old_max = hints->max_contours;
278- if ( new_max > old_max )
279+
280+ if ( new_max <= AF_CONTOURS_EMBEDDED )
281+ hints->contours = hints->embedded.contours;
282+ else if ( new_max > old_max )
283 {
284+ if ( hints->contours == hints->embedded.contours )
285+ hints->contours = NULL;
286+
287 new_max = ( new_max + 3 ) & ~3; /* round up to a multiple of 4 */
288
289 if ( FT_RENEW_ARRAY( hints->contours, old_max, new_max ) )
290@@ -586,8 +633,14 @@
291 */
292 new_max = (FT_UInt)( outline->n_points + 2 );
293 old_max = hints->max_points;
294- if ( new_max > old_max )
295+
296+ if ( new_max <= AF_POINTS_EMBEDDED )
297+ hints->points = hints->embedded.points;
298+ else if ( new_max > old_max )
299 {
300+ if ( hints->points == hints->embedded.points )
301+ hints->points = NULL;
302+
303 new_max = ( new_max + 2 + 7 ) & ~7; /* round up to a multiple of 8 */
304
305 if ( FT_RENEW_ARRAY( hints->points, old_max, new_max ) )
306Index: freetype-2.5.2/src/autofit/afhints.h
307===================================================================
308--- freetype-2.5.2.orig/src/autofit/afhints.h 2015-01-26 16:49:42.692849510 +0100
309+++ freetype-2.5.2/src/autofit/afhints.h 2015-01-26 16:49:42.672849504 +0100
310@@ -322,6 +322,8 @@
311
312 } AF_EdgeRec;
313
314+#define AF_SEGMENTS_EMBEDDED 18 /* number of embedded segments */
315+#define AF_EDGES_EMBEDDED 12 /* number of embedded edges */
316
317 typedef struct AF_AxisHintsRec_
318 {
319@@ -338,9 +340,20 @@
320
321 AF_Direction major_dir; /* either vertical or horizontal */
322
323+ /* two arrays to avoid allocation penalty */
324+ struct
325+ {
326+ AF_SegmentRec segments[AF_SEGMENTS_EMBEDDED];
327+ AF_EdgeRec edges[AF_EDGES_EMBEDDED];
328+ } embedded;
329+
330+
331 } AF_AxisHintsRec, *AF_AxisHints;
332
333
334+#define AF_POINTS_EMBEDDED 96 /* number of embedded points */
335+#define AF_CONTOURS_EMBEDDED 8 /* number of embedded contours */
336+
337 typedef struct AF_GlyphHintsRec_
338 {
339 FT_Memory memory;
340@@ -369,6 +382,14 @@
341 FT_Pos xmin_delta; /* used for warping */
342 FT_Pos xmax_delta;
343
344+ /* Two arrays to avoid allocation penalty. */
345+ /* The `embedded' structure must be the last element! */
346+ struct
347+ {
348+ AF_Point contours[AF_CONTOURS_EMBEDDED];
349+ AF_PointRec points[AF_POINTS_EMBEDDED];
350+ } embedded;
351+
352 } AF_GlyphHintsRec;
353
354
355Index: freetype-2.5.2/src/autofit/afloader.c
356===================================================================
357--- freetype-2.5.2.orig/src/autofit/afloader.c 2015-01-26 16:49:42.692849510 +0100
358+++ freetype-2.5.2/src/autofit/afloader.c 2015-01-26 16:49:42.676849505 +0100
359@@ -26,38 +26,32 @@
360
361 /* Initialize glyph loader. */
362
363- FT_LOCAL_DEF( FT_Error )
364- af_loader_init( AF_Module module )
365+ FT_LOCAL_DEF( void )
366+ af_loader_init( AF_Loader loader,
367+ AF_GlyphHints hints )
368 {
369- AF_Loader loader = module->loader;
370- FT_Memory memory = module->root.library->memory;
371-
372-
373 FT_ZERO( loader );
374
375- af_glyph_hints_init( &loader->hints, memory );
376+ loader->hints = hints;
377 #ifdef FT_DEBUG_AUTOFIT
378- _af_debug_hints = &loader->hints;
379+ _af_debug_hints = loader->hints;
380 #endif
381- return FT_GlyphLoader_New( memory, &loader->gloader );
382 }
383
384
385 /* Reset glyph loader and compute globals if necessary. */
386
387 FT_LOCAL_DEF( FT_Error )
388- af_loader_reset( AF_Module module,
389+ af_loader_reset( AF_Loader loader,
390+ AF_Module module,
391 FT_Face face )
392 {
393- FT_Error error = FT_Err_Ok;
394- AF_Loader loader = module->loader;
395+ FT_Error error = FT_Err_Ok;
396
397
398 loader->face = face;
399 loader->globals = (AF_FaceGlobals)face->autohint.data;
400
401- FT_GlyphLoader_Rewind( loader->gloader );
402-
403 if ( loader->globals == NULL )
404 {
405 error = af_face_globals_new( face, &loader->globals, module );
406@@ -77,42 +71,37 @@
407 /* Finalize glyph loader. */
408
409 FT_LOCAL_DEF( void )
410- af_loader_done( AF_Module module )
411+ af_loader_done( AF_Loader loader )
412 {
413- AF_Loader loader = module->loader;
414-
415-
416- af_glyph_hints_done( &loader->hints );
417-
418 loader->face = NULL;
419 loader->globals = NULL;
420+ loader->hints = NULL;
421
422 #ifdef FT_DEBUG_AUTOFIT
423 _af_debug_hints = NULL;
424 #endif
425- FT_GlyphLoader_Done( loader->gloader );
426- loader->gloader = NULL;
427 }
428
429
430- /* Load a single glyph component. This routine calls itself */
431- /* recursively, if necessary, and does the main work of */
432- /* `af_loader_load_glyph.' */
433+ /* Do the main work of `af_loader_load_glyph'. Note that we never */
434+ /* have to deal with composite glyphs as those get loaded into */
435+ /* FT_GLYPH_FORMAT_OUTLINE by the recursed `FT_Load_Glyph' function. */
436+ /* In the rare cases where FT_LOAD_NO_RECURSE is set, it implies */
437+ /* FT_LOAD_NO_SCALE and as such the auto-hinter is never called. */
438
439 static FT_Error
440 af_loader_load_g( AF_Loader loader,
441 AF_Scaler scaler,
442 FT_UInt glyph_index,
443- FT_Int32 load_flags,
444- FT_UInt depth )
445+ FT_Int32 load_flags )
446 {
447 FT_Error error;
448 FT_Face face = loader->face;
449- FT_GlyphLoader gloader = loader->gloader;
450 AF_ScriptMetrics metrics = loader->metrics;
451- AF_GlyphHints hints = &loader->hints;
452+ AF_GlyphHints hints = loader->hints;
453 FT_GlyphSlot slot = face->glyph;
454 FT_Slot_Internal internal = slot->internal;
455+ FT_GlyphLoader gloader = internal->loader;
456 FT_Int32 flags;
457
458
459@@ -144,29 +133,6 @@
460 loader->trans_delta.x,
461 loader->trans_delta.y );
462
463- /* copy the outline points in the loader's current */
464- /* extra points which are used to keep original glyph coordinates */
465- error = FT_GLYPHLOADER_CHECK_POINTS( gloader,
466- slot->outline.n_points + 4,
467- slot->outline.n_contours );
468- if ( error )
469- goto Exit;
470-
471- FT_ARRAY_COPY( gloader->current.outline.points,
472- slot->outline.points,
473- slot->outline.n_points );
474-
475- FT_ARRAY_COPY( gloader->current.outline.contours,
476- slot->outline.contours,
477- slot->outline.n_contours );
478-
479- FT_ARRAY_COPY( gloader->current.outline.tags,
480- slot->outline.tags,
481- slot->outline.n_points );
482-
483- gloader->current.outline.n_points = slot->outline.n_points;
484- gloader->current.outline.n_contours = slot->outline.n_contours;
485-
486 /* compute original horizontal phantom points (and ignore */
487 /* vertical ones) */
488 loader->pp1.x = hints->x_delta;
489@@ -192,7 +158,7 @@
490
491 if ( writing_system_class->script_hints_apply )
492 writing_system_class->script_hints_apply( hints,
493- &gloader->current.outline,
494+ &gloader->base.outline,
495 metrics );
496 }
497
498@@ -267,133 +233,6 @@
499 slot->rsb_delta = loader->pp2.x - pp2x;
500 }
501
502- /* good, we simply add the glyph to our loader's base */
503- FT_GlyphLoader_Add( gloader );
504- break;
505-
506- case FT_GLYPH_FORMAT_COMPOSITE:
507- {
508- FT_UInt nn, num_subglyphs = slot->num_subglyphs;
509- FT_UInt num_base_subgs, start_point;
510- FT_SubGlyph subglyph;
511-
512-
513- start_point = gloader->base.outline.n_points;
514-
515- /* first of all, copy the subglyph descriptors in the glyph loader */
516- error = FT_GlyphLoader_CheckSubGlyphs( gloader, num_subglyphs );
517- if ( error )
518- goto Exit;
519-
520- FT_ARRAY_COPY( gloader->current.subglyphs,
521- slot->subglyphs,
522- num_subglyphs );
523-
524- gloader->current.num_subglyphs = num_subglyphs;
525- num_base_subgs = gloader->base.num_subglyphs;
526-
527- /* now read each subglyph independently */
528- for ( nn = 0; nn < num_subglyphs; nn++ )
529- {
530- FT_Vector pp1, pp2;
531- FT_Pos x, y;
532- FT_UInt num_points, num_new_points, num_base_points;
533-
534-
535- /* gloader.current.subglyphs can change during glyph loading due */
536- /* to re-allocation -- we must recompute the current subglyph on */
537- /* each iteration */
538- subglyph = gloader->base.subglyphs + num_base_subgs + nn;
539-
540- pp1 = loader->pp1;
541- pp2 = loader->pp2;
542-
543- num_base_points = gloader->base.outline.n_points;
544-
545- error = af_loader_load_g( loader, scaler, subglyph->index,
546- load_flags, depth + 1 );
547- if ( error )
548- goto Exit;
549-
550- /* recompute subglyph pointer */
551- subglyph = gloader->base.subglyphs + num_base_subgs + nn;
552-
553- if ( subglyph->flags & FT_SUBGLYPH_FLAG_USE_MY_METRICS )
554- {
555- pp1 = loader->pp1;
556- pp2 = loader->pp2;
557- }
558- else
559- {
560- loader->pp1 = pp1;
561- loader->pp2 = pp2;
562- }
563-
564- num_points = gloader->base.outline.n_points;
565- num_new_points = num_points - num_base_points;
566-
567- /* now perform the transformation required for this subglyph */
568-
569- if ( subglyph->flags & ( FT_SUBGLYPH_FLAG_SCALE |
570- FT_SUBGLYPH_FLAG_XY_SCALE |
571- FT_SUBGLYPH_FLAG_2X2 ) )
572- {
573- FT_Vector* cur = gloader->base.outline.points +
574- num_base_points;
575- FT_Vector* limit = cur + num_new_points;
576-
577-
578- for ( ; cur < limit; cur++ )
579- FT_Vector_Transform( cur, &subglyph->transform );
580- }
581-
582- /* apply offset */
583-
584- if ( !( subglyph->flags & FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES ) )
585- {
586- FT_Int k = subglyph->arg1;
587- FT_UInt l = subglyph->arg2;
588- FT_Vector* p1;
589- FT_Vector* p2;
590-
591-
592- if ( start_point + k >= num_base_points ||
593- l >= (FT_UInt)num_new_points )
594- {
595- error = FT_THROW( Invalid_Composite );
596- goto Exit;
597- }
598-
599- l += num_base_points;
600-
601- /* for now, only use the current point coordinates; */
602- /* we eventually may consider another approach */
603- p1 = gloader->base.outline.points + start_point + k;
604- p2 = gloader->base.outline.points + start_point + l;
605-
606- x = p1->x - p2->x;
607- y = p1->y - p2->y;
608- }
609- else
610- {
611- x = FT_MulFix( subglyph->arg1, hints->x_scale ) + hints->x_delta;
612- y = FT_MulFix( subglyph->arg2, hints->y_scale ) + hints->y_delta;
613-
614- x = FT_PIX_ROUND( x );
615- y = FT_PIX_ROUND( y );
616- }
617-
618- {
619- FT_Outline dummy = gloader->base.outline;
620-
621-
622- dummy.points += num_base_points;
623- dummy.n_points = (short)num_new_points;
624-
625- FT_Outline_Translate( &dummy, x, y );
626- }
627- }
628- }
629 break;
630
631 default:
632@@ -402,7 +241,6 @@
633 }
634
635 Hint_Metrics:
636- if ( depth == 0 )
637 {
638 FT_BBox bbox;
639 FT_Vector vvector;
640@@ -477,18 +315,14 @@
641 slot->metrics.horiAdvance = FT_PIX_ROUND( slot->metrics.horiAdvance );
642 slot->metrics.vertAdvance = FT_PIX_ROUND( slot->metrics.vertAdvance );
643
644- /* now copy outline into glyph slot */
645- FT_GlyphLoader_Rewind( internal->loader );
646- error = FT_GlyphLoader_CopyPoints( internal->loader, gloader );
647- if ( error )
648- goto Exit;
649-
650+#if 0
651 /* reassign all outline fields except flags to protect them */
652 slot->outline.n_contours = internal->loader->base.outline.n_contours;
653 slot->outline.n_points = internal->loader->base.outline.n_points;
654 slot->outline.points = internal->loader->base.outline.points;
655 slot->outline.tags = internal->loader->base.outline.tags;
656 slot->outline.contours = internal->loader->base.outline.contours;
657+#endif
658
659 slot->format = FT_GLYPH_FORMAT_OUTLINE;
660 }
661@@ -501,14 +335,14 @@
662 /* Load a glyph. */
663
664 FT_LOCAL_DEF( FT_Error )
665- af_loader_load_glyph( AF_Module module,
666+ af_loader_load_glyph( AF_Loader loader,
667+ AF_Module module,
668 FT_Face face,
669 FT_UInt gindex,
670 FT_Int32 load_flags )
671 {
672 FT_Error error;
673 FT_Size size = face->size;
674- AF_Loader loader = module->loader;
675 AF_ScalerRec scaler;
676
677
678@@ -526,7 +360,7 @@
679 scaler.render_mode = FT_LOAD_TARGET_MODE( load_flags );
680 scaler.flags = 0; /* XXX: fix this */
681
682- error = af_loader_reset( module, face );
683+ error = af_loader_reset( loader, module, face );
684 if ( !error )
685 {
686 AF_ScriptMetrics metrics;
687@@ -563,13 +397,13 @@
688
689 if ( writing_system_class->script_hints_init )
690 {
691- error = writing_system_class->script_hints_init( &loader->hints,
692+ error = writing_system_class->script_hints_init( loader->hints,
693 metrics );
694 if ( error )
695 goto Exit;
696 }
697
698- error = af_loader_load_g( loader, &scaler, gindex, load_flags, 0 );
699+ error = af_loader_load_g( loader, &scaler, gindex, load_flags );
700 }
701 }
702 Exit:
703Index: freetype-2.5.2/src/autofit/afloader.h
704===================================================================
705--- freetype-2.5.2.orig/src/autofit/afloader.h 2015-01-26 16:49:42.692849510 +0100
706+++ freetype-2.5.2/src/autofit/afloader.h 2015-01-26 16:49:42.676849505 +0100
707@@ -20,13 +20,12 @@
708 #define __AFLOADER_H__
709
710 #include "afhints.h"
711+#include "afmodule.h"
712 #include "afglobal.h"
713
714
715 FT_BEGIN_HEADER
716
717- typedef struct AF_ModuleRec_* AF_Module;
718-
719 /*
720 * The autofitter module's (global) data structure to communicate with
721 * actual fonts. If necessary, `local' data like the current face, the
722@@ -42,8 +41,7 @@
723 AF_FaceGlobals globals;
724
725 /* current glyph data */
726- FT_GlyphLoader gloader;
727- AF_GlyphHintsRec hints;
728+ AF_GlyphHints hints;
729 AF_ScriptMetrics metrics;
730 FT_Bool transformed;
731 FT_Matrix trans_matrix;
732@@ -55,21 +53,24 @@
733 } AF_LoaderRec, *AF_Loader;
734
735
736- FT_LOCAL( FT_Error )
737- af_loader_init( AF_Module module );
738+ FT_LOCAL( void )
739+ af_loader_init( AF_Loader loader,
740+ AF_GlyphHints hints );
741
742
743 FT_LOCAL( FT_Error )
744- af_loader_reset( AF_Module module,
745+ af_loader_reset( AF_Loader loader,
746+ AF_Module module,
747 FT_Face face );
748
749
750 FT_LOCAL( void )
751- af_loader_done( AF_Module module );
752+ af_loader_done( AF_Loader loader );
753
754
755 FT_LOCAL( FT_Error )
756- af_loader_load_glyph( AF_Module module,
757+ af_loader_load_glyph( AF_Loader loader,
758+ AF_Module module,
759 FT_Face face,
760 FT_UInt gindex,
761 FT_Int32 load_flags );
762Index: freetype-2.5.2/src/autofit/afmodule.c
763===================================================================
764--- freetype-2.5.2.orig/src/autofit/afmodule.c 2015-01-26 16:49:42.692849510 +0100
765+++ freetype-2.5.2/src/autofit/afmodule.c 2015-01-26 16:49:42.676849505 +0100
766@@ -208,17 +208,14 @@
767
768 module->fallback_script = AF_SCRIPT_FALLBACK;
769
770- return af_loader_init( module );
771+ return FT_Err_Ok;
772 }
773
774
775 FT_CALLBACK_DEF( void )
776 af_autofitter_done( FT_Module ft_module ) /* AF_Module */
777 {
778- AF_Module module = (AF_Module)ft_module;
779-
780-
781- af_loader_done( module );
782+ FT_UNUSED( ft_module );
783 }
784
785
786@@ -229,10 +226,25 @@
787 FT_UInt glyph_index,
788 FT_Int32 load_flags )
789 {
790+ FT_Error error = FT_Err_Ok;
791+ FT_Memory memory = module->root.library->memory;
792+
793+ AF_GlyphHintsRec hints[1];
794+ AF_LoaderRec loader[1];
795+
796 FT_UNUSED( size );
797
798- return af_loader_load_glyph( module, slot->face,
799- glyph_index, load_flags );
800+
801+ af_glyph_hints_init( hints, memory );
802+ af_loader_init( loader, hints );
803+
804+ error = af_loader_load_glyph( loader, module, slot->face,
805+ glyph_index, load_flags );
806+
807+ af_loader_done( loader );
808+ af_glyph_hints_done( hints );
809+
810+ return error;
811 }
812
813
814Index: freetype-2.5.2/src/autofit/afmodule.h
815===================================================================
816--- freetype-2.5.2.orig/src/autofit/afmodule.h 2015-01-26 16:49:42.692849510 +0100
817+++ freetype-2.5.2/src/autofit/afmodule.h 2015-01-26 16:49:42.676849505 +0100
818@@ -23,17 +23,13 @@
819 #include FT_INTERNAL_OBJECTS_H
820 #include FT_MODULE_H
821
822-#include "afloader.h"
823-
824
825 FT_BEGIN_HEADER
826
827
828 /*
829 * This is the `extended' FT_Module structure which holds the
830- * autofitter's global data. Right before hinting a glyph, the data
831- * specific to the glyph's face (blue zones, stem widths, etc.) are
832- * loaded into `loader' (see function `af_loader_reset').
833+ * autofitter's global data.
834 */
835
836 typedef struct AF_ModuleRec_
837@@ -42,9 +38,7 @@
838
839 FT_UInt fallback_script;
840
841- AF_LoaderRec loader[1];
842-
843- } AF_ModuleRec;
844+ } AF_ModuleRec, *AF_Module;
845
846
847 FT_DECLARE_MODULE(autofit_module_class)
848Index: freetype-2.5.2/src/base/ftobjs.c
849===================================================================
850--- freetype-2.5.2.orig/src/base/ftobjs.c 2015-01-26 16:49:42.692849510 +0100
851+++ freetype-2.5.2/src/base/ftobjs.c 2015-01-26 16:49:42.676849505 +0100
852@@ -963,10 +963,6 @@
853 (FT_List_Destructor)destroy_face,
854 driver->root.memory,
855 driver );
856-
857- /* check whether we need to drop the driver's glyph loader */
858- if ( FT_DRIVER_USES_OUTLINES( driver ) )
859- FT_GlyphLoader_Done( driver->glyph_loader );
860 }
861
862
863@@ -4046,8 +4042,7 @@
864
865 default:
866 {
867- FT_ListNode node = 0;
868- FT_Bool update = 0;
869+ FT_ListNode node = 0;
870
871
872 /* small shortcut for the very common case */
873@@ -4074,13 +4069,7 @@
874 /* now, look for another renderer that supports the same */
875 /* format. */
876 renderer = FT_Lookup_Renderer( library, slot->format, &node );
877- update = 1;
878 }
879-
880- /* if we changed the current renderer for the glyph image format */
881- /* we need to select it as the next current one */
882- if ( !error && update && renderer )
883- FT_Set_Renderer( library, renderer, 0, 0 );
884 }
885 }
886
887@@ -4280,17 +4269,10 @@
888 /* if the module is a font driver */
889 if ( FT_MODULE_IS_DRIVER( module ) )
890 {
891- /* allocate glyph loader if needed */
892 FT_Driver driver = FT_DRIVER( module );
893
894
895 driver->clazz = (FT_Driver_Class)module->clazz;
896- if ( FT_DRIVER_USES_OUTLINES( driver ) )
897- {
898- error = FT_GlyphLoader_New( memory, &driver->glyph_loader );
899- if ( error )
900- goto Fail;
901- }
902 }
903
904 if ( clazz->module_init )
905@@ -4307,15 +4289,6 @@
906 return error;
907
908 Fail:
909- if ( FT_MODULE_IS_DRIVER( module ) )
910- {
911- FT_Driver driver = FT_DRIVER( module );
912-
913-
914- if ( FT_DRIVER_USES_OUTLINES( driver ) )
915- FT_GlyphLoader_Done( driver->glyph_loader );
916- }
917-
918 if ( FT_MODULE_IS_RENDERER( module ) )
919 {
920 FT_Renderer renderer = FT_RENDERER( module );
921@@ -4630,12 +4603,9 @@
922 goto Fail;
923 #endif
924
925- /* allocate the render pool */
926- library->raster_pool_size = FT_RENDER_POOL_SIZE;
927-#if FT_RENDER_POOL_SIZE > 0
928- if ( FT_ALLOC( library->raster_pool, FT_RENDER_POOL_SIZE ) )
929- goto Fail;
930-#endif
931+ /* we don't use raster_pool anymore. */
932+ library->raster_pool_size = 0;
933+ library->raster_pool = NULL;
934
935 library->version_major = FREETYPE_MAJOR;
936 library->version_minor = FREETYPE_MINOR;
937@@ -4648,6 +4618,8 @@
938
939 return FT_Err_Ok;
940
941+ /* Fix compilation warning */
942+ goto Fail;
943 Fail:
944 #ifdef FT_CONFIG_OPTION_PIC
945 ft_pic_container_destroy( library );
946@@ -4784,10 +4756,6 @@
947 }
948 #endif
949
950- /* Destroy raster objects */
951- FT_FREE( library->raster_pool );
952- library->raster_pool_size = 0;
953-
954 #ifdef FT_CONFIG_OPTION_PIC
955 /* Destroy pic container contents */
956 ft_pic_container_destroy( library );
957Index: freetype-2.5.2/src/base/ftoutln.c
958===================================================================
959--- freetype-2.5.2.orig/src/base/ftoutln.c 2015-01-26 16:49:42.692849510 +0100
960+++ freetype-2.5.2/src/base/ftoutln.c 2015-01-26 16:49:42.676849505 +0100
961@@ -606,7 +606,6 @@
962 FT_Raster_Params* params )
963 {
964 FT_Error error;
965- FT_Bool update = FALSE;
966 FT_Renderer renderer;
967 FT_ListNode node;
968
969@@ -637,14 +636,8 @@
970 /* format */
971 renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE,
972 &node );
973- update = TRUE;
974 }
975
976- /* if we changed the current renderer for the glyph image format */
977- /* we need to select it as the next current one */
978- if ( !error && update && renderer )
979- FT_Set_Renderer( library, renderer, 0, 0 );
980-
981 return error;
982 }
983
984Index: freetype-2.5.2/src/raster/ftraster.c
985===================================================================
986--- freetype-2.5.2.orig/src/raster/ftraster.c 2015-01-26 16:49:42.692849510 +0100
987+++ freetype-2.5.2/src/raster/ftraster.c 2015-01-26 16:49:42.680849506 +0100
988@@ -150,14 +150,6 @@
989 /* define DEBUG_RASTER if you want to compile a debugging version */
990 /* #define DEBUG_RASTER */
991
992- /* define FT_RASTER_OPTION_ANTI_ALIASING if you want to support */
993- /* 5-levels anti-aliasing */
994-/* #define FT_RASTER_OPTION_ANTI_ALIASING */
995-
996- /* The size of the two-lines intermediate bitmap used */
997- /* for anti-aliasing, in bytes. */
998-#define RASTER_GRAY_LINES 2048
999-
1000
1001 /*************************************************************************/
1002 /*************************************************************************/
1003@@ -514,9 +506,6 @@
1004
1005 Short traceIncr; /* sweep's increment in target bitmap */
1006
1007- Short gray_min_x; /* current min x during gray rendering */
1008- Short gray_max_x; /* current max x during gray rendering */
1009-
1010 /* dispatch variables */
1011
1012 Function_Sweep_Init* Proc_Sweep_Init;
1013@@ -529,45 +518,19 @@
1014 Bool second_pass; /* indicates whether a horizontal pass */
1015 /* should be performed to control */
1016 /* drop-out accurately when calling */
1017- /* Render_Glyph. Note that there is */
1018- /* no horizontal pass during gray */
1019- /* rendering. */
1020+ /* Render_Glyph. */
1021
1022 TPoint arcs[3 * MaxBezier + 1]; /* The Bezier stack */
1023
1024 black_TBand band_stack[16]; /* band stack used for sub-banding */
1025 Int band_top; /* band stack top */
1026
1027-#ifdef FT_RASTER_OPTION_ANTI_ALIASING
1028-
1029- Byte* grays;
1030-
1031- Byte gray_lines[RASTER_GRAY_LINES];
1032- /* Intermediate table used to render the */
1033- /* graylevels pixmaps. */
1034- /* gray_lines is a buffer holding two */
1035- /* monochrome scanlines */
1036-
1037- Short gray_width; /* width in bytes of one monochrome */
1038- /* intermediate scanline of gray_lines. */
1039- /* Each gray pixel takes 2 bits long there */
1040-
1041- /* The gray_lines must hold 2 lines, thus with size */
1042- /* in bytes of at least `gray_width*2'. */
1043-
1044-#endif /* FT_RASTER_ANTI_ALIASING */
1045-
1046 };
1047
1048
1049 typedef struct black_TRaster_
1050 {
1051- char* buffer;
1052- long buffer_size;
1053 void* memory;
1054- black_PWorker worker;
1055- Byte grays[5];
1056- Short gray_width;
1057
1058 } black_TRaster, *black_PRaster;
1059
1060@@ -583,70 +546,6 @@
1061 #endif /* !FT_STATIC_RASTER */
1062
1063
1064-#ifdef FT_RASTER_OPTION_ANTI_ALIASING
1065-
1066- /* A lookup table used to quickly count set bits in four gray 2x2 */
1067- /* cells. The values of the table have been produced with the */
1068- /* following code: */
1069- /* */
1070- /* for ( i = 0; i < 256; i++ ) */
1071- /* { */
1072- /* l = 0; */
1073- /* j = i; */
1074- /* */
1075- /* for ( c = 0; c < 4; c++ ) */
1076- /* { */
1077- /* l <<= 4; */
1078- /* */
1079- /* if ( j & 0x80 ) l++; */
1080- /* if ( j & 0x40 ) l++; */
1081- /* */
1082- /* j = ( j << 2 ) & 0xFF; */
1083- /* } */
1084- /* printf( "0x%04X", l ); */
1085- /* } */
1086- /* */
1087-
1088- static const short count_table[256] =
1089- {
1090- 0x0000, 0x0001, 0x0001, 0x0002, 0x0010, 0x0011, 0x0011, 0x0012,
1091- 0x0010, 0x0011, 0x0011, 0x0012, 0x0020, 0x0021, 0x0021, 0x0022,
1092- 0x0100, 0x0101, 0x0101, 0x0102, 0x0110, 0x0111, 0x0111, 0x0112,
1093- 0x0110, 0x0111, 0x0111, 0x0112, 0x0120, 0x0121, 0x0121, 0x0122,
1094- 0x0100, 0x0101, 0x0101, 0x0102, 0x0110, 0x0111, 0x0111, 0x0112,
1095- 0x0110, 0x0111, 0x0111, 0x0112, 0x0120, 0x0121, 0x0121, 0x0122,
1096- 0x0200, 0x0201, 0x0201, 0x0202, 0x0210, 0x0211, 0x0211, 0x0212,
1097- 0x0210, 0x0211, 0x0211, 0x0212, 0x0220, 0x0221, 0x0221, 0x0222,
1098- 0x1000, 0x1001, 0x1001, 0x1002, 0x1010, 0x1011, 0x1011, 0x1012,
1099- 0x1010, 0x1011, 0x1011, 0x1012, 0x1020, 0x1021, 0x1021, 0x1022,
1100- 0x1100, 0x1101, 0x1101, 0x1102, 0x1110, 0x1111, 0x1111, 0x1112,
1101- 0x1110, 0x1111, 0x1111, 0x1112, 0x1120, 0x1121, 0x1121, 0x1122,
1102- 0x1100, 0x1101, 0x1101, 0x1102, 0x1110, 0x1111, 0x1111, 0x1112,
1103- 0x1110, 0x1111, 0x1111, 0x1112, 0x1120, 0x1121, 0x1121, 0x1122,
1104- 0x1200, 0x1201, 0x1201, 0x1202, 0x1210, 0x1211, 0x1211, 0x1212,
1105- 0x1210, 0x1211, 0x1211, 0x1212, 0x1220, 0x1221, 0x1221, 0x1222,
1106- 0x1000, 0x1001, 0x1001, 0x1002, 0x1010, 0x1011, 0x1011, 0x1012,
1107- 0x1010, 0x1011, 0x1011, 0x1012, 0x1020, 0x1021, 0x1021, 0x1022,
1108- 0x1100, 0x1101, 0x1101, 0x1102, 0x1110, 0x1111, 0x1111, 0x1112,
1109- 0x1110, 0x1111, 0x1111, 0x1112, 0x1120, 0x1121, 0x1121, 0x1122,
1110- 0x1100, 0x1101, 0x1101, 0x1102, 0x1110, 0x1111, 0x1111, 0x1112,
1111- 0x1110, 0x1111, 0x1111, 0x1112, 0x1120, 0x1121, 0x1121, 0x1122,
1112- 0x1200, 0x1201, 0x1201, 0x1202, 0x1210, 0x1211, 0x1211, 0x1212,
1113- 0x1210, 0x1211, 0x1211, 0x1212, 0x1220, 0x1221, 0x1221, 0x1222,
1114- 0x2000, 0x2001, 0x2001, 0x2002, 0x2010, 0x2011, 0x2011, 0x2012,
1115- 0x2010, 0x2011, 0x2011, 0x2012, 0x2020, 0x2021, 0x2021, 0x2022,
1116- 0x2100, 0x2101, 0x2101, 0x2102, 0x2110, 0x2111, 0x2111, 0x2112,
1117- 0x2110, 0x2111, 0x2111, 0x2112, 0x2120, 0x2121, 0x2121, 0x2122,
1118- 0x2100, 0x2101, 0x2101, 0x2102, 0x2110, 0x2111, 0x2111, 0x2112,
1119- 0x2110, 0x2111, 0x2111, 0x2112, 0x2120, 0x2121, 0x2121, 0x2122,
1120- 0x2200, 0x2201, 0x2201, 0x2202, 0x2210, 0x2211, 0x2211, 0x2212,
1121- 0x2210, 0x2211, 0x2211, 0x2212, 0x2220, 0x2221, 0x2221, 0x2222
1122- };
1123-
1124-#endif /* FT_RASTER_OPTION_ANTI_ALIASING */
1125-
1126-
1127-
1128 /*************************************************************************/
1129 /*************************************************************************/
1130 /** **/
1131@@ -2083,7 +1982,8 @@
1132 /* to be drawn. */
1133
1134 lastProfile = ras.cProfile;
1135- if ( ras.cProfile->flags & Flow_Up )
1136+ if ( ras.top != ras.cProfile->offset &&
1137+ ( ras.cProfile->flags & Flow_Up ) )
1138 o = IS_TOP_OVERSHOOT( ras.lastY );
1139 else
1140 o = IS_BOTTOM_OVERSHOOT( ras.lastY );
1141@@ -2268,9 +2168,6 @@
1142 ras.traceOfs = -*min * pitch;
1143 if ( pitch > 0 )
1144 ras.traceOfs += ( ras.target.rows - 1 ) * pitch;
1145-
1146- ras.gray_min_x = 0;
1147- ras.gray_max_x = 0;
1148 }
1149
1150
1151@@ -2315,11 +2212,6 @@
1152 f1 = (Byte) ( 0xFF >> ( e1 & 7 ) );
1153 f2 = (Byte) ~( 0x7F >> ( e2 & 7 ) );
1154
1155- if ( ras.gray_min_x > c1 )
1156- ras.gray_min_x = (short)c1;
1157- if ( ras.gray_max_x < c2 )
1158- ras.gray_max_x = (short)c2;
1159-
1160 target = ras.bTarget + ras.traceOfs + c1;
1161 c2 -= c1;
1162
1163@@ -2483,11 +2375,6 @@
1164 c1 = (Short)( e1 >> 3 );
1165 f1 = (Short)( e1 & 7 );
1166
1167- if ( ras.gray_min_x > c1 )
1168- ras.gray_min_x = c1;
1169- if ( ras.gray_max_x < c1 )
1170- ras.gray_max_x = c1;
1171-
1172 ras.bTarget[ras.traceOfs + c1] |= (char)( 0x80 >> f1 );
1173 }
1174 }
1175@@ -2692,249 +2579,6 @@
1176 }
1177
1178
1179-#ifdef FT_RASTER_OPTION_ANTI_ALIASING
1180-
1181-
1182- /*************************************************************************/
1183- /* */
1184- /* Vertical Gray Sweep Procedure Set */
1185- /* */
1186- /* These two routines are used during the vertical gray-levels sweep */
1187- /* phase by the generic Draw_Sweep() function. */
1188- /* */
1189- /* NOTES */
1190- /* */
1191- /* - The target pixmap's width *must* be a multiple of 4. */
1192- /* */
1193- /* - You have to use the function Vertical_Sweep_Span() for the gray */
1194- /* span call. */
1195- /* */
1196- /*************************************************************************/
1197-
1198- static void
1199- Vertical_Gray_Sweep_Init( RAS_ARGS Short* min,
1200- Short* max )
1201- {
1202- Long pitch, byte_len;
1203-
1204-
1205- *min = *min & -2;
1206- *max = ( *max + 3 ) & -2;
1207-
1208- ras.traceOfs = 0;
1209- pitch = ras.target.pitch;
1210- byte_len = -pitch;
1211- ras.traceIncr = (Short)byte_len;
1212- ras.traceG = ( *min / 2 ) * byte_len;
1213-
1214- if ( pitch > 0 )
1215- {
1216- ras.traceG += ( ras.target.rows - 1 ) * pitch;
1217- byte_len = -byte_len;
1218- }
1219-
1220- ras.gray_min_x = (Short)byte_len;
1221- ras.gray_max_x = -(Short)byte_len;
1222- }
1223-
1224-
1225- static void
1226- Vertical_Gray_Sweep_Step( RAS_ARG )
1227- {
1228- short* count = (short*)count_table;
1229- Byte* grays;
1230-
1231-
1232- ras.traceOfs += ras.gray_width;
1233-
1234- if ( ras.traceOfs > ras.gray_width )
1235- {
1236- PByte pix;
1237-
1238-
1239- pix = ras.gTarget + ras.traceG + ras.gray_min_x * 4;
1240- grays = ras.grays;
1241-
1242- if ( ras.gray_max_x >= 0 )
1243- {
1244- Long last_pixel = ras.target.width - 1;
1245- Int last_cell = last_pixel >> 2;
1246- Int last_bit = last_pixel & 3;
1247- Bool over = 0;
1248-
1249- Int c1, c2;
1250- PByte bit, bit2;
1251-
1252-
1253- if ( ras.gray_max_x >= last_cell && last_bit != 3 )
1254- {
1255- ras.gray_max_x = last_cell - 1;
1256- over = 1;
1257- }
1258-
1259- if ( ras.gray_min_x < 0 )
1260- ras.gray_min_x = 0;
1261-
1262- bit = ras.bTarget + ras.gray_min_x;
1263- bit2 = bit + ras.gray_width;
1264-
1265- c1 = ras.gray_max_x - ras.gray_min_x;
1266-
1267- while ( c1 >= 0 )
1268- {
1269- c2 = count[*bit] + count[*bit2];
1270-
1271- if ( c2 )
1272- {
1273- pix[0] = grays[(c2 >> 12) & 0x000F];
1274- pix[1] = grays[(c2 >> 8 ) & 0x000F];
1275- pix[2] = grays[(c2 >> 4 ) & 0x000F];
1276- pix[3] = grays[ c2 & 0x000F];
1277-
1278- *bit = 0;
1279- *bit2 = 0;
1280- }
1281-
1282- bit++;
1283- bit2++;
1284- pix += 4;
1285- c1--;
1286- }
1287-
1288- if ( over )
1289- {
1290- c2 = count[*bit] + count[*bit2];
1291- if ( c2 )
1292- {
1293- switch ( last_bit )
1294- {
1295- case 2:
1296- pix[2] = grays[(c2 >> 4 ) & 0x000F];
1297- case 1:
1298- pix[1] = grays[(c2 >> 8 ) & 0x000F];
1299- default:
1300- pix[0] = grays[(c2 >> 12) & 0x000F];
1301- }
1302-
1303- *bit = 0;
1304- *bit2 = 0;
1305- }
1306- }
1307- }
1308-
1309- ras.traceOfs = 0;
1310- ras.traceG += ras.traceIncr;
1311-
1312- ras.gray_min_x = 32000;
1313- ras.gray_max_x = -32000;
1314- }
1315- }
1316-
1317-
1318- static void
1319- Horizontal_Gray_Sweep_Span( RAS_ARGS Short y,
1320- FT_F26Dot6 x1,
1321- FT_F26Dot6 x2,
1322- PProfile left,
1323- PProfile right )
1324- {
1325- /* nothing, really */
1326- FT_UNUSED_RASTER;
1327- FT_UNUSED( y );
1328- FT_UNUSED( x1 );
1329- FT_UNUSED( x2 );
1330- FT_UNUSED( left );
1331- FT_UNUSED( right );
1332- }
1333-
1334-
1335- static void
1336- Horizontal_Gray_Sweep_Drop( RAS_ARGS Short y,
1337- FT_F26Dot6 x1,
1338- FT_F26Dot6 x2,
1339- PProfile left,
1340- PProfile right )
1341- {
1342- Long e1, e2;
1343- PByte pixel;
1344-
1345-
1346- /* During the horizontal sweep, we only take care of drop-outs */
1347-
1348- e1 = CEILING( x1 );
1349- e2 = FLOOR ( x2 );
1350-
1351- if ( e1 > e2 )
1352- {
1353- Int dropOutControl = left->flags & 7;
1354-
1355-
1356- if ( e1 == e2 + ras.precision )
1357- {
1358- switch ( dropOutControl )
1359- {
1360- case 0: /* simple drop-outs including stubs */
1361- e1 = e2;
1362- break;
1363-
1364- case 4: /* smart drop-outs including stubs */
1365- e1 = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half );
1366- break;
1367-
1368- case 1: /* simple drop-outs excluding stubs */
1369- case 5: /* smart drop-outs excluding stubs */
1370- /* see Vertical_Sweep_Drop for details */
1371-
1372- /* rightmost stub test */
1373- if ( left->next == right && left->height <= 0 )
1374- return;
1375-
1376- /* leftmost stub test */
1377- if ( right->next == left && left->start == y )
1378- return;
1379-
1380- if ( dropOutControl == 1 )
1381- e1 = e2;
1382- else
1383- e1 = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half );
1384-
1385- break;
1386-
1387- default: /* modes 2, 3, 6, 7 */
1388- return; /* no drop-out control */
1389- }
1390- }
1391- else
1392- return;
1393- }
1394-
1395- if ( e1 >= 0 )
1396- {
1397- Byte color;
1398-
1399-
1400- if ( x2 - x1 >= ras.precision_half )
1401- color = ras.grays[2];
1402- else
1403- color = ras.grays[1];
1404-
1405- e1 = TRUNC( e1 ) / 2;
1406- if ( e1 < ras.target.rows )
1407- {
1408- pixel = ras.gTarget - e1 * ras.target.pitch + y / 2;
1409- if ( ras.target.pitch > 0 )
1410- pixel += ( ras.target.rows - 1 ) * ras.target.pitch;
1411-
1412- if ( pixel[0] == ras.grays[0] )
1413- pixel[0] = color;
1414- }
1415- }
1416- }
1417-
1418-
1419-#endif /* FT_RASTER_OPTION_ANTI_ALIASING */
1420-
1421-
1422 /*************************************************************************/
1423 /* */
1424 /* Generic Sweep Drawing routine */
1425@@ -3329,118 +2973,10 @@
1426 }
1427
1428
1429-#ifdef FT_RASTER_OPTION_ANTI_ALIASING
1430-
1431- /*************************************************************************/
1432- /* */
1433- /* <Function> */
1434- /* Render_Gray_Glyph */
1435- /* */
1436- /* <Description> */
1437- /* Render a glyph with grayscaling. Sub-banding if needed. */
1438- /* */
1439- /* <Return> */
1440- /* FreeType error code. 0 means success. */
1441- /* */
1442- FT_LOCAL_DEF( FT_Error )
1443- Render_Gray_Glyph( RAS_ARG )
1444- {
1445- Long pixel_width;
1446- FT_Error error;
1447-
1448-
1449- Set_High_Precision( RAS_VARS ras.outline.flags &
1450- FT_OUTLINE_HIGH_PRECISION );
1451- ras.scale_shift = ras.precision_shift + 1;
1452-
1453- if ( ras.outline.flags & FT_OUTLINE_IGNORE_DROPOUTS )
1454- ras.dropOutControl = 2;
1455- else
1456- {
1457- if ( ras.outline.flags & FT_OUTLINE_SMART_DROPOUTS )
1458- ras.dropOutControl = 4;
1459- else
1460- ras.dropOutControl = 0;
1461-
1462- if ( !( ras.outline.flags & FT_OUTLINE_INCLUDE_STUBS ) )
1463- ras.dropOutControl += 1;
1464- }
1465-
1466- ras.second_pass = !( ras.outline.flags & FT_OUTLINE_SINGLE_PASS );
1467-
1468- /* Vertical Sweep */
1469-
1470- ras.band_top = 0;
1471- ras.band_stack[0].y_min = 0;
1472- ras.band_stack[0].y_max = 2 * ras.target.rows - 1;
1473-
1474- ras.bWidth = ras.gray_width;
1475- pixel_width = 2 * ( ( ras.target.width + 3 ) >> 2 );
1476-
1477- if ( ras.bWidth > pixel_width )
1478- ras.bWidth = pixel_width;
1479-
1480- ras.bWidth = ras.bWidth * 8;
1481- ras.bTarget = (Byte*)ras.gray_lines;
1482- ras.gTarget = (Byte*)ras.target.buffer;
1483-
1484- ras.Proc_Sweep_Init = Vertical_Gray_Sweep_Init;
1485- ras.Proc_Sweep_Span = Vertical_Sweep_Span;
1486- ras.Proc_Sweep_Drop = Vertical_Sweep_Drop;
1487- ras.Proc_Sweep_Step = Vertical_Gray_Sweep_Step;
1488-
1489- error = Render_Single_Pass( RAS_VARS 0 );
1490- if ( error )
1491- return error;
1492-
1493- /* Horizontal Sweep */
1494- if ( ras.second_pass && ras.dropOutControl != 2 )
1495- {
1496- ras.Proc_Sweep_Init = Horizontal_Sweep_Init;
1497- ras.Proc_Sweep_Span = Horizontal_Gray_Sweep_Span;
1498- ras.Proc_Sweep_Drop = Horizontal_Gray_Sweep_Drop;
1499- ras.Proc_Sweep_Step = Horizontal_Sweep_Step;
1500-
1501- ras.band_top = 0;
1502- ras.band_stack[0].y_min = 0;
1503- ras.band_stack[0].y_max = ras.target.width * 2 - 1;
1504-
1505- error = Render_Single_Pass( RAS_VARS 1 );
1506- if ( error )
1507- return error;
1508- }
1509-
1510- return Raster_Err_None;
1511- }
1512-
1513-#else /* !FT_RASTER_OPTION_ANTI_ALIASING */
1514-
1515- FT_LOCAL_DEF( FT_Error )
1516- Render_Gray_Glyph( RAS_ARG )
1517- {
1518- FT_UNUSED_RASTER;
1519-
1520- return FT_THROW( Unsupported );
1521- }
1522-
1523-#endif /* !FT_RASTER_OPTION_ANTI_ALIASING */
1524-
1525-
1526 static void
1527 ft_black_init( black_PRaster raster )
1528 {
1529-#ifdef FT_RASTER_OPTION_ANTI_ALIASING
1530- FT_UInt n;
1531-
1532-
1533- /* set default 5-levels gray palette */
1534- for ( n = 0; n < 5; n++ )
1535- raster->grays[n] = n * 255 / 4;
1536-
1537- raster->gray_width = RASTER_GRAY_LINES / 2;
1538-#else
1539 FT_UNUSED( raster );
1540-#endif
1541 }
1542
1543
1544@@ -3517,25 +3053,9 @@
1545 char* pool_base,
1546 long pool_size )
1547 {
1548- if ( raster )
1549- {
1550- if ( pool_base && pool_size >= (long)sizeof ( black_TWorker ) + 2048 )
1551- {
1552- black_PWorker worker = (black_PWorker)pool_base;
1553-
1554-
1555- raster->buffer = pool_base + ( ( sizeof ( *worker ) + 7 ) & ~7 );
1556- raster->buffer_size = (long)( pool_base + pool_size -
1557- (char*)raster->buffer );
1558- raster->worker = worker;
1559- }
1560- else
1561- {
1562- raster->buffer = NULL;
1563- raster->buffer_size = 0;
1564- raster->worker = NULL;
1565- }
1566- }
1567+ FT_UNUSED( raster );
1568+ FT_UNUSED( pool_base );
1569+ FT_UNUSED( pool_size );
1570 }
1571
1572
1573@@ -3544,25 +3064,9 @@
1574 unsigned long mode,
1575 const char* palette )
1576 {
1577-#ifdef FT_RASTER_OPTION_ANTI_ALIASING
1578-
1579- if ( mode == FT_MAKE_TAG( 'p', 'a', 'l', '5' ) )
1580- {
1581- /* set 5-levels gray palette */
1582- raster->grays[0] = palette[0];
1583- raster->grays[1] = palette[1];
1584- raster->grays[2] = palette[2];
1585- raster->grays[3] = palette[3];
1586- raster->grays[4] = palette[4];
1587- }
1588-
1589-#else
1590-
1591 FT_UNUSED( raster );
1592 FT_UNUSED( mode );
1593 FT_UNUSED( palette );
1594-
1595-#endif
1596 }
1597
1598
1599@@ -3572,10 +3076,13 @@
1600 {
1601 const FT_Outline* outline = (const FT_Outline*)params->source;
1602 const FT_Bitmap* target_map = params->target;
1603- black_PWorker worker;
1604
1605+ black_TWorker worker[1];
1606
1607- if ( !raster || !raster->buffer || !raster->buffer_size )
1608+ Long buffer[FT_MAX( FT_RENDER_POOL_SIZE, 2048 ) / sizeof ( Long )];
1609+
1610+
1611+ if ( !raster )
1612 return FT_THROW( Not_Ini );
1613
1614 if ( !outline )
1615@@ -3592,12 +3099,13 @@
1616 outline->contours[outline->n_contours - 1] + 1 )
1617 return FT_THROW( Invalid );
1618
1619- worker = raster->worker;
1620-
1621 /* this version of the raster does not support direct rendering, sorry */
1622 if ( params->flags & FT_RASTER_FLAG_DIRECT )
1623 return FT_THROW( Unsupported );
1624
1625+ if ( params->flags & FT_RASTER_FLAG_AA )
1626+ return FT_THROW( Unsupported );
1627+
1628 if ( !target_map )
1629 return FT_THROW( Invalid );
1630
1631@@ -3611,19 +3119,10 @@
1632 ras.outline = *outline;
1633 ras.target = *target_map;
1634
1635- worker->buff = (PLong) raster->buffer;
1636- worker->sizeBuff = worker->buff +
1637- raster->buffer_size / sizeof ( Long );
1638-#ifdef FT_RASTER_OPTION_ANTI_ALIASING
1639- worker->grays = raster->grays;
1640- worker->gray_width = raster->gray_width;
1641-
1642- FT_MEM_ZERO( worker->gray_lines, worker->gray_width * 2 );
1643-#endif
1644+ worker->buff = buffer;
1645+ worker->sizeBuff = (&buffer)[1]; /* Points to right after buffer. */
1646
1647- return ( params->flags & FT_RASTER_FLAG_AA )
1648- ? Render_Gray_Glyph( RAS_VAR )
1649- : Render_Glyph( RAS_VAR );
1650+ return Render_Glyph( RAS_VAR );
1651 }
1652
1653
1654Index: freetype-2.5.2/src/raster/ftrend1.c
1655===================================================================
1656--- freetype-2.5.2.orig/src/raster/ftrend1.c 2015-01-26 16:49:42.692849510 +0100
1657+++ freetype-2.5.2/src/raster/ftrend1.c 2015-01-26 16:56:56.633016853 +0100
1658@@ -120,38 +120,11 @@
1659 }
1660
1661 /* check rendering mode */
1662-#ifndef FT_CONFIG_OPTION_PIC
1663 if ( mode != FT_RENDER_MODE_MONO )
1664 {
1665 /* raster1 is only capable of producing monochrome bitmaps */
1666- if ( render->clazz == &ft_raster1_renderer_class )
1667- return FT_THROW( Cannot_Render_Glyph );
1668+ return FT_THROW( Cannot_Render_Glyph );
1669 }
1670- else
1671- {
1672- /* raster5 is only capable of producing 5-gray-levels bitmaps */
1673- if ( render->clazz == &ft_raster5_renderer_class )
1674- return FT_THROW( Cannot_Render_Glyph );
1675- }
1676-#else /* FT_CONFIG_OPTION_PIC */
1677- /* When PIC is enabled, we cannot get to the class object */
1678- /* so instead we check the final character in the class name */
1679- /* ("raster5" or "raster1"). Yes this is a hack. */
1680- /* The "correct" thing to do is have different render function */
1681- /* for each of the classes. */
1682- if ( mode != FT_RENDER_MODE_MONO )
1683- {
1684- /* raster1 is only capable of producing monochrome bitmaps */
1685- if ( render->clazz->root.module_name[6] == '1' )
1686- return FT_THROW( Cannot_Render_Glyph );
1687- }
1688- else
1689- {
1690- /* raster5 is only capable of producing 5-gray-levels bitmaps */
1691- if ( render->clazz->root.module_name[6] == '5' )
1692- return FT_THROW( Cannot_Render_Glyph );
1693- }
1694-#endif /* FT_CONFIG_OPTION_PIC */
1695
1696 outline = &slot->outline;
1697
1698@@ -194,19 +167,8 @@
1699 slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
1700 }
1701
1702- /* allocate new one, depends on pixel format */
1703- if ( !( mode & FT_RENDER_MODE_MONO ) )
1704- {
1705- /* we pad to 32 bits, only for backwards compatibility with FT 1.x */
1706- pitch = FT_PAD_CEIL( width, 4 );
1707- bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
1708- bitmap->num_grays = 256;
1709- }
1710- else
1711- {
1712- pitch = ( ( width + 15 ) >> 4 ) << 1;
1713- bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
1714- }
1715+ pitch = ( ( width + 15 ) >> 4 ) << 1;
1716+ bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
1717
1718 bitmap->width = width;
1719 bitmap->rows = height;
1720@@ -225,9 +187,6 @@
1721 params.source = outline;
1722 params.flags = 0;
1723
1724- if ( bitmap->pixel_mode == FT_PIXEL_MODE_GRAY )
1725- params.flags |= FT_RASTER_FLAG_AA;
1726-
1727 /* render outline into the bitmap */
1728 error = render->raster_render( render->raster, &params );
1729
1730Index: freetype-2.5.2/src/smooth/ftgrays.c
1731===================================================================
1732--- freetype-2.5.2.orig/src/smooth/ftgrays.c 2015-01-26 16:49:42.692849510 +0100
1733+++ freetype-2.5.2/src/smooth/ftgrays.c 2015-01-26 16:49:42.680849506 +0100
1734@@ -461,11 +461,7 @@
1735
1736 typedef struct gray_TRaster_
1737 {
1738- void* buffer;
1739- long buffer_size;
1740- int band_size;
1741 void* memory;
1742- gray_PWorker worker;
1743
1744 } gray_TRaster, *gray_PRaster;
1745
1746@@ -1940,12 +1936,17 @@
1747 gray_raster_render( gray_PRaster raster,
1748 const FT_Raster_Params* params )
1749 {
1750- const FT_Outline* outline = (const FT_Outline*)params->source;
1751- const FT_Bitmap* target_map = params->target;
1752- gray_PWorker worker;
1753+ const FT_Outline* outline = (const FT_Outline*)params->source;
1754+ const FT_Bitmap* target_map = params->target;
1755
1756+ gray_TWorker worker[1];
1757
1758- if ( !raster || !raster->buffer || !raster->buffer_size )
1759+ TCell buffer[FT_MAX( FT_RENDER_POOL_SIZE, 2048 ) / sizeof ( TCell )];
1760+ long buffer_size = sizeof ( buffer );
1761+ int band_size = (int)( buffer_size / ( sizeof ( TCell ) * 8 ) );
1762+
1763+
1764+ if ( !raster )
1765 return FT_THROW( Invalid_Argument );
1766
1767 if ( !outline )
1768@@ -1962,8 +1963,6 @@
1769 outline->contours[outline->n_contours - 1] + 1 )
1770 return FT_THROW( Invalid_Outline );
1771
1772- worker = raster->worker;
1773-
1774 /* if direct mode is not set, we must have a target bitmap */
1775 if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) )
1776 {
1777@@ -2001,13 +2000,14 @@
1778 ras.clip_box.yMax = 32767L;
1779 }
1780
1781- gray_init_cells( RAS_VAR_ raster->buffer, raster->buffer_size );
1782+ gray_init_cells( RAS_VAR_ buffer, buffer_size );
1783
1784 ras.outline = *outline;
1785 ras.num_cells = 0;
1786 ras.invalid = 1;
1787- ras.band_size = raster->band_size;
1788+ ras.band_size = band_size;
1789 ras.num_gray_spans = 0;
1790+ ras.span_y = 0;
1791
1792 if ( params->flags & FT_RASTER_FLAG_DIRECT )
1793 {
1794@@ -2091,34 +2091,9 @@
1795 char* pool_base,
1796 long pool_size )
1797 {
1798- gray_PRaster rast = (gray_PRaster)raster;
1799-
1800-
1801- if ( raster )
1802- {
1803- if ( pool_base && pool_size >= (long)sizeof ( gray_TWorker ) + 2048 )
1804- {
1805- gray_PWorker worker = (gray_PWorker)pool_base;
1806-
1807-
1808- rast->worker = worker;
1809- rast->buffer = pool_base +
1810- ( ( sizeof ( gray_TWorker ) +
1811- sizeof ( TCell ) - 1 ) &
1812- ~( sizeof ( TCell ) - 1 ) );
1813- rast->buffer_size = (long)( ( pool_base + pool_size ) -
1814- (char*)rast->buffer ) &
1815- ~( sizeof ( TCell ) - 1 );
1816- rast->band_size = (int)( rast->buffer_size /
1817- ( sizeof ( TCell ) * 8 ) );
1818- }
1819- else
1820- {
1821- rast->buffer = NULL;
1822- rast->buffer_size = 0;
1823- rast->worker = NULL;
1824- }
1825- }
1826+ FT_UNUSED( raster );
1827+ FT_UNUSED( pool_base );
1828+ FT_UNUSED( pool_size );
1829 }
1830
1831
1832Index: freetype-2.5.2/src/truetype/ttgload.c
1833===================================================================
1834--- freetype-2.5.2.orig/src/truetype/ttgload.c 2015-01-26 16:49:42.692849510 +0100
1835+++ freetype-2.5.2/src/truetype/ttgload.c 2015-01-26 16:49:42.684849507 +0100
1836@@ -802,7 +802,6 @@
1837
1838 if ( n_ins > 0 )
1839 {
1840- FT_Bool debug;
1841 FT_Error error;
1842
1843 FT_GlyphLoader gloader = loader->gloader;
1844@@ -817,10 +816,7 @@
1845 loader->exec->is_composite = is_composite;
1846 loader->exec->pts = *zone;
1847
1848- debug = FT_BOOL( !( loader->load_flags & FT_LOAD_NO_SCALE ) &&
1849- ((TT_Size)loader->size)->debug );
1850-
1851- error = TT_Run_Context( loader->exec, debug );
1852+ error = TT_Run_Context( loader->exec );
1853 if ( error && loader->exec->pedantic_hinting )
1854 return error;
1855
1856@@ -2116,8 +2112,7 @@
1857 }
1858
1859 /* query new execution context */
1860- exec = size->debug ? size->context
1861- : ( (TT_Driver)FT_FACE_DRIVER( face ) )->context;
1862+ exec = size->context;
1863 if ( !exec )
1864 return FT_THROW( Could_Not_Find_Context );
1865
1866Index: freetype-2.5.2/src/truetype/ttinterp.c
1867===================================================================
1868--- freetype-2.5.2.orig/src/truetype/ttinterp.c 2015-01-26 16:49:42.692849510 +0100
1869+++ freetype-2.5.2/src/truetype/ttinterp.c 2015-01-26 16:49:42.684849507 +0100
1870@@ -714,12 +714,8 @@
1871 /* <Return> */
1872 /* TrueType error code. 0 means success. */
1873 /* */
1874- /* <Note> */
1875- /* Only the glyph loader and debugger should call this function. */
1876- /* */
1877 FT_LOCAL_DEF( FT_Error )
1878- TT_Run_Context( TT_ExecContext exec,
1879- FT_Bool debug )
1880+ TT_Run_Context( TT_ExecContext exec )
1881 {
1882 FT_Error error;
1883
1884@@ -754,16 +750,7 @@
1885 exec->top = 0;
1886 exec->callTop = 0;
1887
1888-#if 1
1889- FT_UNUSED( debug );
1890-
1891 return exec->face->interpreter( exec );
1892-#else
1893- if ( !debug )
1894- return TT_RunIns( exec );
1895- else
1896- return FT_Err_Ok;
1897-#endif
1898 }
1899
1900
1901@@ -796,32 +783,26 @@
1902 FT_EXPORT_DEF( TT_ExecContext )
1903 TT_New_Context( TT_Driver driver )
1904 {
1905- TT_ExecContext exec;
1906 FT_Memory memory;
1907+ FT_Error error;
1908
1909+ TT_ExecContext exec;
1910
1911- memory = driver->root.root.memory;
1912- exec = driver->context;
1913-
1914- if ( !driver->context )
1915- {
1916- FT_Error error;
1917-
1918-
1919- /* allocate object */
1920- if ( FT_NEW( exec ) )
1921- goto Fail;
1922+ if ( !driver )
1923+ goto Fail;
1924
1925- /* initialize it; in case of error this deallocates `exec' too */
1926- error = Init_Context( exec, memory );
1927- if ( error )
1928- goto Fail;
1929+ memory = driver->root.root.memory;
1930
1931- /* store it into the driver */
1932- driver->context = exec;
1933- }
1934+ /* allocate object */
1935+ if ( FT_NEW( exec ) )
1936+ goto Fail;
1937+
1938+ /* initialize it; in case of error this deallocates `exec' too */
1939+ error = Init_Context( exec, memory );
1940+ if ( error )
1941+ goto Fail;
1942
1943- return driver->context;
1944+ return exec;
1945
1946 Fail:
1947 return NULL;
1948Index: freetype-2.5.2/src/truetype/ttinterp.h
1949===================================================================
1950--- freetype-2.5.2.orig/src/truetype/ttinterp.h 2015-01-26 16:49:42.692849510 +0100
1951+++ freetype-2.5.2/src/truetype/ttinterp.h 2015-01-26 16:49:42.684849507 +0100
1952@@ -340,6 +340,7 @@
1953 /* */
1954 /* <Note> */
1955 /* Only the glyph loader and debugger should call this function. */
1956+ /* (And right now only the glyph loader uses it.) */
1957 /* */
1958 FT_EXPORT( TT_ExecContext )
1959 TT_New_Context( TT_Driver driver );
1960@@ -359,8 +360,7 @@
1961 TT_Size ins );
1962
1963 FT_LOCAL( FT_Error )
1964- TT_Run_Context( TT_ExecContext exec,
1965- FT_Bool debug );
1966+ TT_Run_Context( TT_ExecContext exec );
1967 #endif /* TT_USE_BYTECODE_INTERPRETER */
1968
1969
1970Index: freetype-2.5.2/src/truetype/ttobjs.c
1971===================================================================
1972--- freetype-2.5.2.orig/src/truetype/ttobjs.c 2015-01-26 16:49:42.692849510 +0100
1973+++ freetype-2.5.2/src/truetype/ttobjs.c 2015-01-26 16:49:42.688849509 +0100
1974@@ -751,14 +751,7 @@
1975 FT_Error error;
1976
1977
1978- /* debugging instances have their own context */
1979- if ( size->debug )
1980- exec = size->context;
1981- else
1982- exec = ( (TT_Driver)FT_FACE_DRIVER( face ) )->context;
1983-
1984- if ( !exec )
1985- return FT_THROW( Could_Not_Find_Context );
1986+ exec = size->context;
1987
1988 TT_Load_Context( exec, face, size );
1989
1990@@ -845,14 +838,7 @@
1991 FT_Error error;
1992
1993
1994- /* debugging instances have their own context */
1995- if ( size->debug )
1996- exec = size->context;
1997- else
1998- exec = ( (TT_Driver)FT_FACE_DRIVER( face ) )->context;
1999-
2000- if ( !exec )
2001- return FT_THROW( Could_Not_Find_Context );
2002+ exec = size->context;
2003
2004 TT_Load_Context( exec, face, size );
2005
2006@@ -872,14 +858,11 @@
2007
2008 if ( face->cvt_program_size > 0 )
2009 {
2010- error = TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 );
2011+ TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 );
2012
2013- if ( !error && !size->debug )
2014- {
2015- FT_TRACE4(( "Executing `prep' table.\n" ));
2016+ FT_TRACE4(( "Executing `prep' table.\n" ));
2017
2018- error = face->interpreter( exec );
2019- }
2020+ error = face->interpreter( exec );
2021 }
2022 else
2023 error = FT_Err_Ok;
2024@@ -924,12 +907,10 @@
2025 TT_Face face = (TT_Face)ftsize->face;
2026 FT_Memory memory = face->root.memory;
2027
2028-
2029- if ( size->debug )
2030+ if ( size->context )
2031 {
2032- /* the debug context must be deleted by the debugger itself */
2033+ TT_Done_Context( size->context );
2034 size->context = NULL;
2035- size->debug = FALSE;
2036 }
2037
2038 FT_FREE( size->cvt );
2039@@ -977,6 +958,8 @@
2040 size->bytecode_ready = 1;
2041 size->cvt_ready = 0;
2042
2043+ size->context = TT_New_Context( (TT_Driver)face->root.driver );
2044+
2045 size->max_function_defs = maxp->maxFunctionDefs;
2046 size->max_instruction_defs = maxp->maxInstructionDefs;
2047
2048@@ -1261,10 +1244,6 @@
2049
2050 TT_Driver driver = (TT_Driver)ttdriver;
2051
2052-
2053- if ( !TT_New_Context( driver ) )
2054- return FT_THROW( Could_Not_Find_Context );
2055-
2056 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
2057 driver->interpreter_version = TT_INTERPRETER_VERSION_38;
2058 #else
2059@@ -1295,20 +1274,7 @@
2060 FT_LOCAL_DEF( void )
2061 tt_driver_done( FT_Module ttdriver ) /* TT_Driver */
2062 {
2063-#ifdef TT_USE_BYTECODE_INTERPRETER
2064- TT_Driver driver = (TT_Driver)ttdriver;
2065-
2066-
2067- /* destroy the execution context */
2068- if ( driver->context )
2069- {
2070- TT_Done_Context( driver->context );
2071- driver->context = NULL;
2072- }
2073-#else
2074 FT_UNUSED( ttdriver );
2075-#endif
2076-
2077 }
2078
2079
2080Index: freetype-2.5.2/src/truetype/ttobjs.h
2081===================================================================
2082--- freetype-2.5.2.orig/src/truetype/ttobjs.h 2015-01-26 16:49:42.692849510 +0100
2083+++ freetype-2.5.2/src/truetype/ttobjs.h 2015-01-26 16:49:42.688849509 +0100
2084@@ -324,13 +324,6 @@
2085
2086 TT_GlyphZoneRec twilight; /* The instance's twilight zone */
2087
2088- /* debugging variables */
2089-
2090- /* When using the debugger, we must keep the */
2091- /* execution context tied to the instance */
2092- /* object rather than asking it on demand. */
2093-
2094- FT_Bool debug;
2095 TT_ExecContext context;
2096
2097 FT_Bool bytecode_ready;
2098@@ -349,7 +342,6 @@
2099 {
2100 FT_DriverRec root;
2101
2102- TT_ExecContext context; /* execution context */
2103 TT_GlyphZoneRec zone; /* glyph loader points zone */
2104
2105 FT_UInt interpreter_version;
02106
=== modified file 'debian/patches-freetype/series'
--- debian/patches-freetype/series 2014-04-27 22:05:39 +0000
+++ debian/patches-freetype/series 2015-01-26 16:10:26 +0000
@@ -6,3 +6,4 @@
6CVE-2014-2241.patch6CVE-2014-2241.patch
70001-Fix-Savannah-bug-40997.patch70001-Fix-Savannah-bug-40997.patch
8fix-incorrect-korean-fonts-rendering.patch8fix-incorrect-korean-fonts-rendering.patch
9multi-thread-violations.patch

Subscribers

People subscribed via source and target branches