View | Details | Raw Unified | Return to bug 239165 | Differences between
and this patch

Collapse All | Expand All

(-)print/freetype2/distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1552633282
1
TIMESTAMP = 1562883629
2
SHA256 (freetype-2.10.0.tar.bz2) = fccc62928c65192fff6c98847233b28eb7ce05f12d2fea3f6cc90e8b4e5fbe06
2
SHA256 (freetype-2.10.1.tar.xz) = 16dbfa488a21fe827dc27eaf708f42f7aa3bb997d745d31a19781628c36ba26f
3
SIZE (freetype-2.10.0.tar.bz2) = 2743740
3
SIZE (freetype-2.10.1.tar.xz) = 2378784
(-)print/freetype2/files/patch-2.10.0.diff (-772 lines)
Removed Link Here
1
# [cff] Fix boundary checks.
2
# http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=6986ddac1ece9404c9b640a512cbd99534205fda
3
# * src/sfnt/ttcmap.c (tt_get_glyph_name): Pacify compiler (#56061).
4
# http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=885b4c2475f3272afd4115c97c150266cd815406
5
# [smooth] Fix segfault in direct mode (#56092).
6
# http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=1f271751a39e5bc9c639adc213183ed5e58a9401
7
# [pcf] Fix handling of undefined glyph (#56067).
8
# http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=c149f7397e484c97f45fb75fa1c7fdda2fc646cd
9
# Fix return value of `FT_Set_Named_Instance' (#56186).
10
# http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=af400438b7da3f07afadc3a5b3a6b982b2bdb84e
11
# * src/base/ftbitmap.c (FT_Bitmap_Blend): Check target pitch.
12
# http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=9f6ed10545b1009cce86289f793165dd7e4b7c9e
13
# [base] Fix thinko in previous commit.
14
# http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=4166c453601e856fa61e8994085f240d8771e980
15
16
--- src/base/ftbitmap.c.orig	2019-02-23 10:19:25 UTC
17
+++ src/base/ftbitmap.c
18
@@ -922,12 +922,18 @@
19
     else
20
       FT_TRACE5(( "  target bitmap: empty\n" ));
21
 
22
-    FT_TRACE5(( "  final bitmap: (%d, %d) -- (%d, %d); %d x %d\n",
23
-      final_llx / 64, final_lly / 64,
24
-      final_urx / 64, final_ury / 64,
25
-      final_width, final_rows ));
26
+    if ( final_width && final_rows )
27
+      FT_TRACE5(( "  final bitmap: (%d, %d) -- (%d, %d); %d x %d\n",
28
+        final_llx / 64, final_lly / 64,
29
+        final_urx / 64, final_ury / 64,
30
+        final_width, final_rows ));
31
+    else
32
+      FT_TRACE5(( "  final bitmap: empty\n" ));
33
 #endif /* FT_DEBUG_LEVEL_TRACE */
34
 
35
+    if ( !( final_width && final_rows ) )
36
+      return FT_Err_Ok;               /* nothing to do */
37
+
38
     /* for blending, set offset vector of final bitmap */
39
     /* temporarily to (0,0)                            */
40
     source_llx -= final_llx;
41
@@ -971,6 +977,7 @@
42
 
43
 
44
       pitch = target->pitch;
45
+
46
       if ( pitch < 0 )
47
         pitch = -pitch;
48
 
49
--- src/base/ftoutln.c.orig	2019-02-23 09:06:07 UTC
50
+++ src/base/ftoutln.c
51
@@ -621,6 +621,16 @@
52
 
53
     params->source = (void*)outline;
54
 
55
+    /* preset clip_box for direct mode */
56
+    if ( params->flags & FT_RASTER_FLAG_DIRECT    &&
57
+         !( params->flags & FT_RASTER_FLAG_CLIP ) )
58
+    {
59
+      params->clip_box.xMin = cbox.xMin >> 6;
60
+      params->clip_box.yMin = cbox.yMin >> 6;
61
+      params->clip_box.xMax = ( cbox.xMax + 63 ) >> 6;
62
+      params->clip_box.yMax = ( cbox.yMax + 63 ) >> 6;
63
+    }
64
+
65
     error = FT_ERR( Cannot_Render_Glyph );
66
     while ( renderer )
67
     {
68
--- src/cff/cffparse.c.orig	2019-03-11 07:20:07 UTC
69
+++ src/cff/cffparse.c
70
@@ -77,6 +77,23 @@
71
   }
72
 
73
 
74
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
75
+  static void
76
+  finalize_t2_strings( FT_Memory  memory,
77
+                       void*      data,
78
+                       void*      user )
79
+  {
80
+    CFF_T2_String  t2 = (CFF_T2_String)data;
81
+
82
+
83
+    FT_UNUSED( user );
84
+
85
+    memory->free( memory, t2->start );
86
+    memory->free( memory, data );
87
+  }
88
+#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
89
+
90
+
91
   FT_LOCAL_DEF( void )
92
   cff_parser_done( CFF_Parser  parser )
93
   {
94
@@ -84,13 +101,65 @@
95
 
96
 
97
     FT_FREE( parser->stack );
98
+
99
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
100
+    FT_List_Finalize( &parser->t2_strings,
101
+                      finalize_t2_strings,
102
+                      memory,
103
+                      NULL );
104
+#endif
105
+  }
106
+
107
+
108
+  /* Assuming `first >= last'. */
109
+
110
+  static FT_Error
111
+  cff_parser_within_limits( CFF_Parser  parser,
112
+                            FT_Byte*    first,
113
+                            FT_Byte*    last )
114
+  {
115
+#ifndef CFF_CONFIG_OPTION_OLD_ENGINE
116
+
117
+    /* Fast path for regular FreeType builds with the "new" engine; */
118
+    /*   `first >= parser->start' can be assumed.                   */
119
+
120
+    FT_UNUSED( first );
121
+
122
+    return last < parser->limit ? FT_Err_Ok : FT_THROW( Invalid_Argument );
123
+
124
+#else /* CFF_CONFIG_OPTION_OLD_ENGINE */
125
+
126
+    FT_ListNode  node;
127
+
128
+
129
+    if ( first >= parser->start &&
130
+         last  <  parser->limit )
131
+      return FT_Err_Ok;
132
+
133
+    node = parser->t2_strings.head;
134
+
135
+    while ( node )
136
+    {
137
+      CFF_T2_String  t2 = (CFF_T2_String)node->data;
138
+
139
+
140
+      if ( first >= t2->start &&
141
+           last  <  t2->limit )
142
+        return FT_Err_Ok;
143
+
144
+      node = node->next;
145
+    }
146
+
147
+    return FT_THROW( Invalid_Argument );
148
+
149
+#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
150
   }
151
 
152
 
153
   /* read an integer */
154
   static FT_Long
155
-  cff_parse_integer( FT_Byte*  start,
156
-                     FT_Byte*  limit )
157
+  cff_parse_integer( CFF_Parser  parser,
158
+                     FT_Byte*    start )
159
   {
160
     FT_Byte*  p   = start;
161
     FT_Int    v   = *p++;
162
@@ -99,14 +168,14 @@
163
 
164
     if ( v == 28 )
165
     {
166
-      if ( p + 2 > limit )
167
+      if ( cff_parser_within_limits( parser, p, p + 1 ) )
168
         goto Bad;
169
 
170
       val = (FT_Short)( ( (FT_UShort)p[0] << 8 ) | p[1] );
171
     }
172
     else if ( v == 29 )
173
     {
174
-      if ( p + 4 > limit )
175
+      if ( cff_parser_within_limits( parser, p, p + 3 ) )
176
         goto Bad;
177
 
178
       val = (FT_Long)( ( (FT_ULong)p[0] << 24 ) |
179
@@ -120,14 +189,14 @@
180
     }
181
     else if ( v < 251 )
182
     {
183
-      if ( p + 1 > limit )
184
+      if ( cff_parser_within_limits( parser, p, p ) )
185
         goto Bad;
186
 
187
       val = ( v - 247 ) * 256 + p[0] + 108;
188
     }
189
     else
190
     {
191
-      if ( p + 1 > limit )
192
+      if ( cff_parser_within_limits( parser, p, p ) )
193
         goto Bad;
194
 
195
       val = -( v - 251 ) * 256 - p[0] - 108;
196
@@ -176,10 +245,10 @@
197
 
198
   /* read a real */
199
   static FT_Fixed
200
-  cff_parse_real( FT_Byte*  start,
201
-                  FT_Byte*  limit,
202
-                  FT_Long   power_ten,
203
-                  FT_Long*  scaling )
204
+  cff_parse_real( CFF_Parser  parser,
205
+                  FT_Byte*    start,
206
+                  FT_Long     power_ten,
207
+                  FT_Long*    scaling )
208
   {
209
     FT_Byte*  p = start;
210
     FT_Int    nib;
211
@@ -214,7 +283,7 @@
212
         p++;
213
 
214
         /* Make sure we don't read past the end. */
215
-        if ( p >= limit )
216
+        if ( cff_parser_within_limits( parser, p, p ) )
217
           goto Bad;
218
       }
219
 
220
@@ -251,7 +320,7 @@
221
           p++;
222
 
223
           /* Make sure we don't read past the end. */
224
-          if ( p >= limit )
225
+          if ( cff_parser_within_limits( parser, p, p ) )
226
             goto Bad;
227
         }
228
 
229
@@ -290,7 +359,7 @@
230
           p++;
231
 
232
           /* Make sure we don't read past the end. */
233
-          if ( p >= limit )
234
+          if ( cff_parser_within_limits( parser, p, p ) )
235
             goto Bad;
236
         }
237
 
238
@@ -457,7 +526,7 @@
239
     if ( **d == 30 )
240
     {
241
       /* binary-coded decimal is truncated to integer */
242
-      return cff_parse_real( *d, parser->limit, 0, NULL ) >> 16;
243
+      return cff_parse_real( parser, *d, 0, NULL ) >> 16;
244
     }
245
 
246
     else if ( **d == 255 )
247
@@ -483,7 +552,7 @@
248
     }
249
 
250
     else
251
-      return cff_parse_integer( *d, parser->limit );
252
+      return cff_parse_integer( parser, *d );
253
   }
254
 
255
 
256
@@ -494,10 +563,10 @@
257
             FT_Long     scaling )
258
   {
259
     if ( **d == 30 )
260
-      return cff_parse_real( *d, parser->limit, scaling, NULL );
261
+      return cff_parse_real( parser, *d, scaling, NULL );
262
     else
263
     {
264
-      FT_Long  val = cff_parse_integer( *d, parser->limit );
265
+      FT_Long  val = cff_parse_integer( parser, *d );
266
 
267
 
268
       if ( scaling )
269
@@ -562,14 +631,14 @@
270
     FT_ASSERT( scaling );
271
 
272
     if ( **d == 30 )
273
-      return cff_parse_real( *d, parser->limit, 0, scaling );
274
+      return cff_parse_real( parser, *d, 0, scaling );
275
     else
276
     {
277
       FT_Long  number;
278
       FT_Int   integer_length;
279
 
280
 
281
-      number = cff_parse_integer( d[0], d[1] );
282
+      number = cff_parse_integer( parser, d[0] );
283
 
284
       if ( number > 0x7FFFL )
285
       {
286
@@ -1122,18 +1191,6 @@
287
 #endif /* FT_DEBUG_LEVEL_TRACE */
288
 
289
 
290
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
291
-  static void
292
-  destruct_t2s_item( FT_Memory  memory,
293
-                     void*      data,
294
-                     void*      user )
295
-  {
296
-    FT_UNUSED( user );
297
-    memory->free( memory, data );
298
-  }
299
-#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
300
-
301
-
302
   FT_LOCAL_DEF( FT_Error )
303
   cff_parser_run( CFF_Parser  parser,
304
                   FT_Byte*    start,
305
@@ -1147,11 +1204,6 @@
306
 
307
     FT_Library  library = parser->library;
308
     FT_Memory   memory  = library->memory;
309
-
310
-    FT_ListRec  t2s;
311
-
312
-
313
-    FT_ZERO( &t2s );
314
 #endif
315
 
316
     parser->top    = parser->stack;
317
@@ -1212,9 +1264,11 @@
318
         FT_Byte*     charstring_base;
319
         FT_ULong     charstring_len;
320
 
321
-        FT_Fixed*    stack;
322
-        FT_ListNode  node;
323
-        FT_Byte*     q;
324
+        FT_Fixed*     stack;
325
+        FT_ListNode   node;
326
+        CFF_T2_String t2;
327
+        size_t        t2_size;
328
+        FT_Byte*      q;
329
 
330
 
331
         charstring_base = ++p;
332
@@ -1261,16 +1315,26 @@
333
         if ( !node )
334
           goto Out_Of_Memory_Error;
335
 
336
+        FT_List_Add( &parser->t2_strings, node );
337
+
338
+        t2 = (CFF_T2_String)memory->alloc( memory,
339
+                                           sizeof ( CFF_T2_StringRec ) );
340
+        if ( !t2 )
341
+          goto Out_Of_Memory_Error;
342
+
343
+        node->data = t2;
344
+
345
         /* `5' is the conservative upper bound of required bytes per stack */
346
         /* element.                                                        */
347
-        q = (FT_Byte*)memory->alloc( memory,
348
-                                     5 * ( decoder.top - decoder.stack ) );
349
+
350
+        t2_size = 5 * ( decoder.top - decoder.stack );
351
+
352
+        q = (FT_Byte*)memory->alloc( memory, t2_size );
353
         if ( !q )
354
           goto Out_Of_Memory_Error;
355
 
356
-        node->data = q;
357
-
358
-        FT_List_Add( &t2s, node );
359
+        t2->start = q;
360
+        t2->limit = q + t2_size;
361
 
362
         stack = decoder.stack;
363
 
364
@@ -1531,9 +1595,6 @@
365
     } /* while ( p < limit ) */
366
 
367
   Exit:
368
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
369
-    FT_List_Finalize( &t2s, destruct_t2s_item, memory, NULL );
370
-#endif
371
     return error;
372
 
373
 #ifdef CFF_CONFIG_OPTION_OLD_ENGINE
374
--- src/cff/cffparse.h.orig	2019-02-23 09:06:07 UTC
375
+++ src/cff/cffparse.h
376
@@ -60,6 +60,10 @@ FT_BEGIN_HEADER
377
     FT_Byte**   top;
378
     FT_UInt     stackSize;  /* allocated size */
379
 
380
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
381
+    FT_ListRec  t2_strings;
382
+#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
383
+
384
     FT_UInt     object_code;
385
     void*       object;
386
 
387
@@ -130,6 +134,15 @@ FT_BEGIN_HEADER
388
 FT_END_HEADER
389
 
390
 
391
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
392
+  typedef struct  CFF_T2_String_
393
+  {
394
+    FT_Byte*  start;
395
+    FT_Byte*  limit;
396
+
397
+  } CFF_T2_StringRec, *CFF_T2_String;
398
+#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
399
+
400
 #endif /* CFFPARSE_H_ */
401
 
402
 
403
--- src/pcf/pcf.h.orig	2019-02-23 08:39:04 UTC
404
+++ src/pcf/pcf.h
405
@@ -99,7 +99,8 @@ FT_BEGIN_HEADER
406
     FT_Short  ascent;
407
     FT_Short  descent;
408
     FT_Short  attributes;
409
-    FT_ULong  bits;
410
+
411
+    FT_ULong  bits;  /* offset into the PCF_BITMAPS table */
412
 
413
   } PCF_MetricRec, *PCF_Metric;
414
 
415
--- src/pcf/pcfdrivr.c.orig	2019-02-23 08:39:04 UTC
416
+++ src/pcf/pcfdrivr.c
417
@@ -122,9 +122,9 @@ THE SOFTWARE.
418
          charcodeCol > enc->lastCol  )
419
       return 0;
420
 
421
-    return (FT_UInt)enc->offset[ ( charcodeRow - enc->firstRow ) *
422
-                                 ( enc->lastCol - enc->firstCol + 1 ) +
423
-                                   charcodeCol - enc->firstCol          ];
424
+    return (FT_UInt)enc->offset[( charcodeRow - enc->firstRow ) *
425
+                                  ( enc->lastCol - enc->firstCol + 1 ) +
426
+                                charcodeCol - enc->firstCol];
427
   }
428
 
429
 
430
@@ -160,9 +160,9 @@ THE SOFTWARE.
431
 
432
       charcode = (FT_UInt32)( charcodeRow * 256 + charcodeCol );
433
 
434
-      result = (FT_UInt)enc->offset[ ( charcodeRow - enc->firstRow ) *
435
-                                     ( enc->lastCol - enc->firstCol + 1 ) +
436
-                                       charcodeCol - enc->firstCol          ];
437
+      result = (FT_UInt)enc->offset[( charcodeRow - enc->firstRow ) *
438
+                                      ( enc->lastCol - enc->firstCol + 1 ) +
439
+                                    charcodeCol - enc->firstCol];
440
       if ( result != 0xFFFFU )
441
         break;
442
     }
443
--- src/pcf/pcfread.c.orig	2019-02-23 08:39:04 UTC
444
+++ src/pcf/pcfread.c
445
@@ -743,33 +743,39 @@ THE SOFTWARE.
446
     if ( !orig_nmetrics )
447
       return FT_THROW( Invalid_Table );
448
 
449
-    /* PCF is a format from ancient times; Unicode was in its       */
450
-    /* infancy, and widely used two-byte character sets for CJK     */
451
-    /* scripts (Big 5, GB 2312, JIS X 0208, etc.) did have at most  */
452
-    /* 15000 characters.  Even the more exotic CNS 11643 and CCCII  */
453
-    /* standards, which were essentially three-byte character sets, */
454
-    /* provided less then 65536 assigned characters.                */
455
-    /*                                                              */
456
-    /* While technically possible to have a larger number of glyphs */
457
-    /* in PCF files, we thus limit the number to 65536.             */
458
-    if ( orig_nmetrics > 65536 )
459
+    /*
460
+     * PCF is a format from ancient times; Unicode was in its infancy, and
461
+     * widely used two-byte character sets for CJK scripts (Big 5, GB 2312,
462
+     * JIS X 0208, etc.) did have at most 15000 characters.  Even the more
463
+     * exotic CNS 11643 and CCCII standards, which were essentially
464
+     * three-byte character sets, provided less then 65536 assigned
465
+     * characters.
466
+     *
467
+     * While technically possible to have a larger number of glyphs in PCF
468
+     * files, we thus limit the number to 65535, taking into account that we
469
+     * synthesize the metrics of glyph 0 to be a copy of the `default
470
+     * character', and that 0xFFFF in the encodings array indicates a
471
+     * missing glyph.
472
+     */
473
+    if ( orig_nmetrics > 65534 )
474
     {
475
       FT_TRACE0(( "pcf_get_metrics:"
476
-                  " only loading first 65536 metrics\n" ));
477
-      nmetrics = 65536;
478
+                  " only loading first 65534 metrics\n" ));
479
+      nmetrics = 65534;
480
     }
481
     else
482
       nmetrics = orig_nmetrics;
483
 
484
-    face->nmetrics = nmetrics;
485
+    face->nmetrics = nmetrics + 1;
486
 
487
-    if ( FT_NEW_ARRAY( face->metrics, nmetrics ) )
488
+    if ( FT_NEW_ARRAY( face->metrics, face->nmetrics ) )
489
       return error;
490
 
491
-    metrics = face->metrics;
492
+    /* we handle glyph index 0 later on */
493
+    metrics = face->metrics + 1;
494
 
495
     FT_TRACE4(( "\n" ));
496
-    for ( i = 0; i < nmetrics; i++, metrics++ )
497
+    for ( i = 1; i < face->nmetrics; i++, metrics++ )
498
     {
499
       FT_TRACE5(( "  idx %ld:", i ));
500
       error = pcf_get_metric( stream, format, metrics );
501
@@ -808,12 +814,10 @@ THE SOFTWARE.
502
   pcf_get_bitmaps( FT_Stream  stream,
503
                    PCF_Face   face )
504
   {
505
-    FT_Error   error;
506
-    FT_Memory  memory  = FT_FACE( face )->memory;
507
-    FT_ULong*  offsets = NULL;
508
-    FT_ULong   bitmapSizes[GLYPHPADOPTIONS];
509
-    FT_ULong   format, size;
510
-    FT_ULong   nbitmaps, orig_nbitmaps, i, sizebitmaps = 0;
511
+    FT_Error  error;
512
+    FT_ULong  bitmapSizes[GLYPHPADOPTIONS];
513
+    FT_ULong  format, size, pos;
514
+    FT_ULong  nbitmaps, orig_nbitmaps, i, sizebitmaps = 0;
515
 
516
 
517
     error = pcf_seek_to_table_type( stream,
518
@@ -859,31 +863,46 @@ THE SOFTWARE.
519
     FT_TRACE4(( "  number of bitmaps: %ld\n", orig_nbitmaps ));
520
 
521
     /* see comment in `pcf_get_metrics' */
522
-    if ( orig_nbitmaps > 65536 )
523
+    if ( orig_nbitmaps > 65534 )
524
     {
525
       FT_TRACE0(( "pcf_get_bitmaps:"
526
-                  " only loading first 65536 bitmaps\n" ));
527
-      nbitmaps = 65536;
528
+                  " only loading first 65534 bitmaps\n" ));
529
+      nbitmaps = 65534;
530
     }
531
     else
532
       nbitmaps = orig_nbitmaps;
533
 
534
-    if ( nbitmaps != face->nmetrics )
535
+    /* no extra bitmap for glyph 0 */
536
+    if ( nbitmaps != face->nmetrics - 1 )
537
       return FT_THROW( Invalid_File_Format );
538
 
539
-    if ( FT_NEW_ARRAY( offsets, nbitmaps ) )
540
-      return error;
541
+    /* start position of bitmap data */
542
+    pos = stream->pos + nbitmaps * 4 + 4 * 4;
543
 
544
     FT_TRACE5(( "\n" ));
545
-    for ( i = 0; i < nbitmaps; i++ )
546
+    for ( i = 1; i <= nbitmaps; i++ )
547
     {
548
+      FT_ULong  offset;
549
+
550
+
551
       if ( PCF_BYTE_ORDER( format ) == MSBFirst )
552
-        (void)FT_READ_ULONG( offsets[i] );
553
+        (void)FT_READ_ULONG( offset );
554
       else
555
-        (void)FT_READ_ULONG_LE( offsets[i] );
556
+        (void)FT_READ_ULONG_LE( offset );
557
 
558
       FT_TRACE5(( "  bitmap %lu: offset %lu (0x%lX)\n",
559
-                  i, offsets[i], offsets[i] ));
560
+                  i, offset, offset ));
561
+
562
+      /* right now, we only check the offset with a rough estimate; */
563
+      /* actual bitmaps are only loaded on demand                   */
564
+      if ( offset > size )
565
+      {
566
+        FT_TRACE0(( "pcf_get_bitmaps:"
567
+                    " invalid offset to bitmap data of glyph %lu\n", i ));
568
+        face->metrics[i].bits = pos;
569
+      }
570
+      else
571
+        face->metrics[i].bits = pos + offset;
572
     }
573
     if ( error )
574
       goto Bail;
575
@@ -910,24 +929,9 @@ THE SOFTWARE.
576
 
577
     FT_UNUSED( sizebitmaps );       /* only used for debugging */
578
 
579
-    /* right now, we only check the bitmap offsets; */
580
-    /* actual bitmaps are only loaded on demand     */
581
-    for ( i = 0; i < nbitmaps; i++ )
582
-    {
583
-      /* rough estimate */
584
-      if ( offsets[i] > size )
585
-      {
586
-        FT_TRACE0(( "pcf_get_bitmaps:"
587
-                    " invalid offset to bitmap data of glyph %lu\n", i ));
588
-      }
589
-      else
590
-        face->metrics[i].bits = stream->pos + offsets[i];
591
-    }
592
-
593
     face->bitmapsFormat = format;
594
 
595
   Bail:
596
-    FT_FREE( offsets );
597
     return error;
598
   }
599
 
600
@@ -1062,41 +1066,52 @@ THE SOFTWARE.
601
       defaultCharCol = enc->firstCol;
602
     }
603
 
604
-    /* FreeType mandates that glyph index 0 is the `undefined glyph',  */
605
-    /* which PCF calls the `default character'.  For this reason, we   */
606
-    /* swap the positions of glyph index 0 and the index corresponding */
607
-    /* to `defaultChar' in case they are different.                    */
608
-
609
-    /* `stream->cursor' still points at the beginning of the frame; */
610
-    /* we can thus easily get the offset to the default character   */
611
+    /*
612
+     * FreeType mandates that glyph index 0 is the `undefined glyph', which
613
+     * PCF calls the `default character'.  However, FreeType needs glyph
614
+     * index 0 to be used for the undefined glyph only, which is is not the
615
+     * case for PCF.  For this reason, we add one slot for glyph index 0 and
616
+     * simply copy the default character to it.
617
+     *
618
+     * `stream->cursor' still points to the beginning of the frame; we can
619
+     * thus easily get the offset to the default character.
620
+     */
621
     pos = stream->cursor +
622
             2 * ( ( defaultCharRow - enc->firstRow ) *
623
-                  ( enc->lastCol - enc->firstCol + 1 ) +
624
-                    defaultCharCol - enc->firstCol       );
625
+                    ( enc->lastCol - enc->firstCol + 1 ) +
626
+                  defaultCharCol - enc->firstCol );
627
 
628
     if ( PCF_BYTE_ORDER( format ) == MSBFirst )
629
       defaultCharEncodingOffset = FT_PEEK_USHORT( pos );
630
     else
631
       defaultCharEncodingOffset = FT_PEEK_USHORT_LE( pos );
632
 
633
-    if ( defaultCharEncodingOffset >= face->nmetrics )
634
+    if ( defaultCharEncodingOffset == 0xFFFF )
635
     {
636
       FT_TRACE0(( "pcf_get_encodings:"
637
-                  " Invalid glyph index for default character,"
638
-                  " setting to zero\n" ));
639
-      defaultCharEncodingOffset = 0;
640
+                  " No glyph for default character,\n"
641
+                  "                  "
642
+                  " setting it to the first glyph of the font\n" ));
643
+      defaultCharEncodingOffset = 1;
644
     }
645
-
646
-    if ( defaultCharEncodingOffset )
647
+    else
648
     {
649
-      /* do the swapping */
650
-      PCF_MetricRec  tmp = face->metrics[defaultCharEncodingOffset];
651
-
652
+      defaultCharEncodingOffset++;
653
 
654
-      face->metrics[defaultCharEncodingOffset] = face->metrics[0];
655
-      face->metrics[0]                         = tmp;
656
+      if ( defaultCharEncodingOffset >= face->nmetrics )
657
+      {
658
+        FT_TRACE0(( "pcf_get_encodings:"
659
+                    " Invalid glyph index for default character,\n"
660
+                    "                  "
661
+                    " setting it to the first glyph of the font\n" ));
662
+        defaultCharEncodingOffset = 1;
663
+      }
664
     }
665
 
666
+    /* copy metrics of default character to index 0 */
667
+    face->metrics[0] = face->metrics[defaultCharEncodingOffset];
668
+
669
+    /* now loop over all values */
670
     offset = enc->offset;
671
     for ( i = enc->firstRow; i <= enc->lastRow; i++ )
672
     {
673
@@ -1111,15 +1126,9 @@ THE SOFTWARE.
674
         else
675
           encodingOffset = FT_GET_USHORT_LE();
676
 
677
-        if ( encodingOffset != 0xFFFFU )
678
-        {
679
-          if ( encodingOffset == defaultCharEncodingOffset )
680
-            encodingOffset = 0;
681
-          else if ( encodingOffset == 0 )
682
-            encodingOffset = defaultCharEncodingOffset;
683
-        }
684
-
685
-        *offset++ = encodingOffset;
686
+        /* everything is off by 1 due to the artificial glyph 0 */
687
+        *offset++ = encodingOffset == 0xFFFF ? 0xFFFF
688
+                                             : encodingOffset + 1;
689
       }
690
     }
691
     FT_Stream_ExitFrame( stream );
692
--- src/sfnt/ttcmap.c.orig	2019-03-07 08:32:56 UTC
693
+++ src/sfnt/ttcmap.c
694
@@ -3661,7 +3661,7 @@
695
   tt_get_glyph_name( TT_Face  face,
696
                      FT_UInt  idx )
697
   {
698
-    FT_String*  PSname;
699
+    FT_String*  PSname = NULL;
700
 
701
 
702
     tt_face_get_ps_name( face, idx, &PSname );
703
--- src/smooth/ftgrays.c.orig	2019-02-23 09:06:07 UTC
704
+++ src/smooth/ftgrays.c
705
@@ -1755,7 +1755,6 @@ typedef ptrdiff_t  FT_PtrDist;
706
   {
707
     const FT_Outline*  outline    = (const FT_Outline*)params->source;
708
     const FT_Bitmap*   target_map = params->target;
709
-    FT_BBox            clip;
710
 
711
 #ifndef FT_STATIC_RASTER
712
     gray_TWorker  worker[1];
713
@@ -1792,6 +1791,11 @@ typedef ptrdiff_t  FT_PtrDist;
714
 
715
       ras.render_span      = (FT_Raster_Span_Func)params->gray_spans;
716
       ras.render_span_data = params->user;
717
+
718
+      ras.min_ex = params->clip_box.xMin;
719
+      ras.min_ey = params->clip_box.yMin;
720
+      ras.max_ex = params->clip_box.xMax;
721
+      ras.max_ey = params->clip_box.yMax;
722
     }
723
     else
724
     {
725
@@ -1816,27 +1820,14 @@ typedef ptrdiff_t  FT_PtrDist;
726
 
727
       ras.render_span      = (FT_Raster_Span_Func)NULL;
728
       ras.render_span_data = NULL;
729
-    }
730
 
731
-    /* compute clipping box */
732
-    if ( params->flags & FT_RASTER_FLAG_DIRECT &&
733
-         params->flags & FT_RASTER_FLAG_CLIP   )
734
-      clip = params->clip_box;
735
-    else
736
-    {
737
-      /* compute clip box from target pixmap */
738
-      clip.xMin = 0;
739
-      clip.yMin = 0;
740
-      clip.xMax = (FT_Pos)target_map->width;
741
-      clip.yMax = (FT_Pos)target_map->rows;
742
+      ras.min_ex = 0;
743
+      ras.min_ey = 0;
744
+      ras.max_ex = (FT_Pos)target_map->width;
745
+      ras.max_ey = (FT_Pos)target_map->rows;
746
     }
747
 
748
-    /* clip to target bitmap, exit if nothing to do */
749
-    ras.min_ex = clip.xMin;
750
-    ras.min_ey = clip.yMin;
751
-    ras.max_ex = clip.xMax;
752
-    ras.max_ey = clip.yMax;
753
-
754
+    /* exit if nothing to do */
755
     if ( ras.max_ex <= ras.min_ex || ras.max_ey <= ras.min_ey )
756
       return 0;
757
 
758
--- src/truetype/ttgxvar.c.orig	2019-02-23 09:06:07 UTC
759
+++ src/truetype/ttgxvar.c
760
@@ -3080,7 +3080,12 @@
761
                                  mmvar->num_axis,
762
                                  named_style->coords );
763
       if ( error )
764
+      {
765
+        /* internal error code -1 means `no change' */
766
+        if ( error == -1 )
767
+          error = FT_Err_Ok;
768
         goto Exit;
769
+      }
770
     }
771
     else
772
       error = TT_Set_Var_Design( face, 0, NULL );
(-)print/freetype2/files/patch-builds_unix_detect.mk (-2 / +2 lines)
Lines 1-4 Link Here
1
--- builds/unix/detect.mk.orig	2016-02-03 18:13:58 UTC
1
--- builds/unix/detect.mk.orig	2019-02-23 09:06:06 UTC
2
+++ builds/unix/detect.mk
2
+++ builds/unix/detect.mk
3
@@ -22,6 +22,9 @@ ifeq ($(PLATFORM),ansi)
3
@@ -22,6 +22,9 @@ ifeq ($(PLATFORM),ansi)
4
                      $(wildcard /usr/sbin/init) \
4
                      $(wildcard /usr/sbin/init) \
Lines 10-16 Link Here
10
   ifneq ($(is_unix),)
10
   ifneq ($(is_unix),)
11
 
11
 
12
     PLATFORM := unix
12
     PLATFORM := unix
13
@@ -80,10 +83,10 @@ ifeq ($(PLATFORM),unix)
13
@@ -86,10 +89,10 @@ ifeq ($(PLATFORM),unix)
14
   ifdef must_configure
14
   ifdef must_configure
15
     ifneq ($(have_Makefile),)
15
     ifneq ($(have_Makefile),)
16
       # we are building FT2 not in the src tree
16
       # we are building FT2 not in the src tree
(-)print/freetype2/Makefile (-3 / +3 lines)
Lines 2-8 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	freetype2
4
PORTNAME=	freetype2
5
PORTVERSION=	2.10.0
5
PORTVERSION=	2.10.1
6
CATEGORIES=	print
6
CATEGORIES=	print
7
MASTER_SITES=	http://savannah.nongnu.org/download/freetype/ \
7
MASTER_SITES=	http://savannah.nongnu.org/download/freetype/ \
8
		SF/freetype/${PORTNAME}/${PORTVERSION:C/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/}/ \
8
		SF/freetype/${PORTNAME}/${PORTVERSION:C/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/}/ \
Lines 22-28 LICENSE_FILE_FTL= ${WRKSRC}/docs/FTL.TXT Link Here
22
LICENSE_FILE_GPLv2+ =	${WRKSRC}/docs/GPLv2.TXT
22
LICENSE_FILE_GPLv2+ =	${WRKSRC}/docs/GPLv2.TXT
23
LICENSE_PERMS_FTL=	dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
23
LICENSE_PERMS_FTL=	dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
24
24
25
USES=		cpe gmake libtool tar:bzip2
25
USES=		cpe gmake libtool tar:xz
26
MAKE_ENV=	TOP=""
26
MAKE_ENV=	TOP=""
27
USE_LDCONFIG=	yes
27
USE_LDCONFIG=	yes
28
GNU_CONFIGURE=	yes
28
GNU_CONFIGURE=	yes
Lines 44-50 OPTIONS_SINGLE= RENDERING Link Here
44
OPTIONS_SINGLE_RENDERING=	LCD_FILTERING LCD_RENDERING
44
OPTIONS_SINGLE_RENDERING=	LCD_FILTERING LCD_RENDERING
45
OPTIONS_RADIO=		SIZE_METRICS_CHOICE
45
OPTIONS_RADIO=		SIZE_METRICS_CHOICE
46
OPTIONS_RADIO_SIZE_METRICS_CHOICE=	FIX_SIZE_METRICS TT_SIZE_METRICS
46
OPTIONS_RADIO_SIZE_METRICS_CHOICE=	FIX_SIZE_METRICS TT_SIZE_METRICS
47
OPTIONS_DEFAULT=	CONFIG LCD_RENDERING V40
47
OPTIONS_DEFAULT=	CONFIG LCD_RENDERING LONG_PCF_NAMES V40
48
OPTIONS_SUB=	yes
48
OPTIONS_SUB=	yes
49
49
50
CONFIG_DESC=	Install freetype-config
50
CONFIG_DESC=	Install freetype-config
(-)print/freetype2/pkg-plist (-1 / +1 lines)
Lines 52-58 include/freetype2/ft2build.h Link Here
52
lib/libfreetype.a
52
lib/libfreetype.a
53
lib/libfreetype.so
53
lib/libfreetype.so
54
lib/libfreetype.so.6
54
lib/libfreetype.so.6
55
lib/libfreetype.so.6.17.0
55
lib/libfreetype.so.6.17.1
56
libdata/pkgconfig/freetype2.pc
56
libdata/pkgconfig/freetype2.pc
57
%%CONFIG%%man/man1/freetype-config.1.gz
57
%%CONFIG%%man/man1/freetype-config.1.gz
58
share/aclocal/freetype2.m4
58
share/aclocal/freetype2.m4

Return to bug 239165