Commit edacde60e3974371dbab156c2d2b06b3f000e4b2

Ewald Hew 2017-09-24T22:20:38

Add new service for inter-module calls. NOTE: Does not compile! This is to allow CFF functions moved to `psaux' to call functions declared in `src/cff/cffload.h'. * include/freetype/internal/services/svcfftl.h: New file, setting up a `CFFLoad' service. * include/freetype/internal/ftserv.h (FT_DEFINE_SERVICEDESCREC10, FT_DEFINE_SERVICEDESCREC): New macros. (FT_SERVICE_CFF_TABLE_LOAD_H): New macro. * src/cff/cffdrivr.c, src/cff/cffpic.h: Register the new service. * src/cff/cfftypes.h (CFF_FontRec), src/psaux/cf2font.h (CF2_FontRec): Add service interface. * src/cff/cffobjs.c, src/psaux/cf2font.c, src/psaux/cf2ft.c, src/psaux/cf2intrp.c, src/psaux/cffdecode.c: Use the new service.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
diff --git a/ChangeLog b/ChangeLog
index 0114f48..a925810 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
 2017-09-24  Ewald Hew  <ewaldhew@gmail.com>
 
+	[psaux, cff] Add new service for inter-module calls.
+
+	NOTE: Does not compile!
+
+	This is to allow CFF functions moved to `psaux' to call functions
+	declared in `src/cff/cffload.h'.
+
+	* include/freetype/internal/services/svcfftl.h: New file, setting up
+	a `CFFLoad' service.
+
+	* include/freetype/internal/ftserv.h (FT_DEFINE_SERVICEDESCREC10,
+	FT_DEFINE_SERVICEDESCREC): New macros.
+	(FT_SERVICE_CFF_TABLE_LOAD_H): New macro.
+
+	* src/cff/cffdrivr.c, src/cff/cffpic.h: Register the new service.
+
+	* src/cff/cfftypes.h (CFF_FontRec), src/psaux/cf2font.h
+	(CF2_FontRec): Add service interface.
+
+	* src/cff/cffobjs.c, src/psaux/cf2font.c, src/psaux/cf2ft.c,
+	src/psaux/cf2intrp.c, src/psaux/cffdecode.c: Use the new service.
+
+2017-09-24  Ewald Hew  <ewaldhew@gmail.com>
+
 	[psaux, cff] Add callbacks for inter-module calls.
 
 	NOTE: Does not compile!
diff --git a/include/freetype/internal/ftserv.h b/include/freetype/internal/ftserv.h
index 71ef9ca..23f2878 100644
--- a/include/freetype/internal/ftserv.h
+++ b/include/freetype/internal/ftserv.h
@@ -330,6 +330,32 @@ FT_BEGIN_HEADER
     { NULL, NULL }                                                          \
   };
 
+#define FT_DEFINE_SERVICEDESCREC10( class_,                                 \
+                                    serv_id_1, serv_data_1,                 \
+                                    serv_id_2, serv_data_2,                 \
+                                    serv_id_3, serv_data_3,                 \
+                                    serv_id_4, serv_data_4,                 \
+                                    serv_id_5, serv_data_5,                 \
+                                    serv_id_6, serv_data_6,                 \
+                                    serv_id_7, serv_data_7,                 \
+                                    serv_id_8, serv_data_8,                 \
+                                    serv_id_9, serv_data_9,                 \
+                                    serv_id_10, serv_data_10)               \
+  static const FT_ServiceDescRec  class_[] =                                \
+  {                                                                         \
+    { serv_id_1, serv_data_1 },                                             \
+    { serv_id_2, serv_data_2 },                                             \
+    { serv_id_3, serv_data_3 },                                             \
+    { serv_id_4, serv_data_4 },                                             \
+    { serv_id_5, serv_data_5 },                                             \
+    { serv_id_6, serv_data_6 },                                             \
+    { serv_id_7, serv_data_7 },                                             \
+    { serv_id_8, serv_data_8 },                                             \
+    { serv_id_9, serv_data_9 },                                             \
+    { serv_id_10, serv_data_10 },                                           \
+    { NULL, NULL }                                                          \
+  };
+
 #else /* FT_CONFIG_OPTION_PIC */
 
 #define FT_DEFINE_SERVICEDESCREC1( class_,                                  \
@@ -755,6 +781,68 @@ FT_BEGIN_HEADER
     return FT_Err_Ok;                                                       \
   }
 
+#define FT_DEFINE_SERVICEDESCREC10( class_,                                 \
+                                    serv_id_1, serv_data_1,                 \
+                                    serv_id_2, serv_data_2,                 \
+                                    serv_id_3, serv_data_3,                 \
+                                    serv_id_4, serv_data_4,                 \
+                                    serv_id_5, serv_data_5,                 \
+                                    serv_id_6, serv_data_6,                 \
+                                    serv_id_7, serv_data_7,                 \
+                                    serv_id_8, serv_data_8,                 \
+                                    serv_id_9, serv_data_9,                 \
+                                    serv_id_10, serv_data_10 )              \
+  void                                                                      \
+  FT_Destroy_Class_ ## class_( FT_Library          library,                 \
+                               FT_ServiceDescRec*  clazz )                  \
+  {                                                                         \
+    FT_Memory  memory = library->memory;                                    \
+                                                                            \
+                                                                            \
+    if ( clazz )                                                            \
+      FT_FREE( clazz );                                                     \
+  }                                                                         \
+                                                                            \
+  FT_Error                                                                  \
+  FT_Create_Class_ ## class_( FT_Library           library,                 \
+                              FT_ServiceDescRec**  output_class)            \
+  {                                                                         \
+    FT_ServiceDescRec*  clazz  = NULL;                                      \
+    FT_Error            error;                                              \
+    FT_Memory           memory = library->memory;                           \
+                                                                            \
+                                                                            \
+    if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 11 ) )                        \
+      return error;                                                         \
+                                                                            \
+    clazz[0].serv_id   = serv_id_1;                                         \
+    clazz[0].serv_data = serv_data_1;                                       \
+    clazz[1].serv_id   = serv_id_2;                                         \
+    clazz[1].serv_data = serv_data_2;                                       \
+    clazz[2].serv_id   = serv_id_3;                                         \
+    clazz[2].serv_data = serv_data_3;                                       \
+    clazz[3].serv_id   = serv_id_4;                                         \
+    clazz[3].serv_data = serv_data_4;                                       \
+    clazz[4].serv_id   = serv_id_5;                                         \
+    clazz[4].serv_data = serv_data_5;                                       \
+    clazz[5].serv_id   = serv_id_6;                                         \
+    clazz[5].serv_data = serv_data_6;                                       \
+    clazz[6].serv_id   = serv_id_7;                                         \
+    clazz[6].serv_data = serv_data_7;                                       \
+    clazz[7].serv_id   = serv_id_8;                                         \
+    clazz[7].serv_data = serv_data_8;                                       \
+    clazz[8].serv_id   = serv_id_9;                                         \
+    clazz[8].serv_data = serv_data_9;                                       \
+    clazz[9].serv_id   = serv_id_10;                                        \
+    clazz[9].serv_data = serv_data_10;                                      \
+    clazz[10].serv_id   = NULL;                                             \
+    clazz[10].serv_data = NULL;                                             \
+                                                                            \
+    *output_class = clazz;                                                  \
+                                                                            \
+    return FT_Err_Ok;                                                       \
+  }
+
 #endif /* FT_CONFIG_OPTION_PIC */
 
 
@@ -916,7 +1004,7 @@ FT_BEGIN_HEADER
 #define FT_SERVICE_WINFNT_H             <freetype/internal/services/svwinfnt.h>
 #define FT_SERVICE_FONT_FORMAT_H        <freetype/internal/services/svfntfmt.h>
 #define FT_SERVICE_TRUETYPE_GLYF_H      <freetype/internal/services/svttglyf.h>
-
+#define FT_SERVICE_CFF_TABLE_LOAD_H     <freetype/internal/services/svcfftl.h>
  /* */
 
 FT_END_HEADER
diff --git a/include/freetype/internal/services/svcfftl.h b/include/freetype/internal/services/svcfftl.h
new file mode 100644
index 0000000..18e2276
--- /dev/null
+++ b/include/freetype/internal/services/svcfftl.h
@@ -0,0 +1,94 @@
+#ifndef SVCFFTL_H_
+#define SVCFFTL_H_
+
+#include FT_INTERNAL_SERVICE_H
+
+
+FT_BEGIN_HEADER
+
+
+#define FT_SERVICE_ID_CFF_LOAD  "cff-load"
+
+
+  typedef FT_UShort
+  (*FT_Get_Standard_Encoding_Func)( FT_UInt  charcode );
+
+  typedef FT_Error
+  (*FT_Load_Private_Dict_Func)( CFF_Font     font,
+                                CFF_SubFont  subfont,
+                                FT_UInt      lenNDV,
+                                FT_Fixed*    NDV );
+
+  typedef FT_Byte
+  (*FT_FD_Select_Get_Func)( CFF_FDSelect  fdselect,
+                            FT_UInt       glyph_index );
+
+  typedef FT_Bool
+  (*FT_Blend_Check_Vector_Func)( CFF_Blend  blend,
+                                 FT_UInt    vsindex,
+                                 FT_UInt    lenNDV,
+                                 FT_Fixed*  NDV );
+
+  typedef FT_Error
+  (*FT_Blend_Build_Vector_Func)( CFF_Blend  blend,
+                                 FT_UInt    vsindex,
+                                 FT_UInt    lenNDV,
+                                 FT_Fixed*  NDV );
+
+
+  FT_DEFINE_SERVICE( CFFLoad )
+  {
+    FT_Get_Standard_Encoding_Func  get_standard_encoding;
+    FT_Load_Private_Dict_Func      load_private_dict;
+    FT_FD_Select_Get_Func          fd_select_get;
+    FT_Blend_Check_Vector_Func     blend_check_vector;
+    FT_Blend_Build_Vector_Func     blend_build_vector;
+  };
+
+
+#ifndef FT_CONFIG_OPTION_PIC
+
+#define FT_DEFINE_SERVICE_CFFLOADREC( class_,                  \
+                                      get_standard_encoding_,  \
+                                      load_private_dict_,      \
+                                      fd_select_get_,          \
+                                      blend_check_vector_,     \
+                                      blend_build_vector_ )    \
+  static const FT_Service_CFFLoadRec  class_ =                 \
+  {                                                            \
+    get_standard_encoding_,                                    \
+    load_private_dict_,                                        \
+    fd_select_get_,                                            \
+    blend_check_vector_,                                       \
+    blend_build_vector_                                        \
+  };
+
+#else /* FT_CONFIG_OPTION_PIC */
+
+#define FT_DEFINE_SERVICE_CFFLOADREC( class_,                  \
+                                      get_standard_encoding_,  \
+                                      load_private_dict_,      \
+                                      fd_select_get_,          \
+                                      blend_check_vector_,     \
+                                      blend_build_vector_ )    \
+  void                                                         \
+  FT_Init_Class_ ## class_( FT_Service_CFFLoadRec*  clazz )    \
+  {                                                            \
+    clazz->get_standard_encoding = get_standard_encoding_;     \
+    clazz->load_private_dict     = load_private_dict_;         \
+    clazz->fd_select_get         = fd_select_get_;             \
+    clazz->blend_check_vector    = blend_check_vector_;        \
+    clazz->blend_build_vector    = blend_build_vector_;        \
+  }
+
+#endif /* FT_CONFIG_OPTION_PIC */
+
+
+
+
+FT_END_HEADER
+
+#endif
+
+
+/* END */
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 38bfc2c..689f229 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -25,6 +25,7 @@
 #include FT_SERVICE_POSTSCRIPT_INFO_H
 #include FT_SERVICE_POSTSCRIPT_NAME_H
 #include FT_SERVICE_TT_CMAP_H
+#include FT_SERVICE_CFF_TABLE_LOAD_H
 
 #include "cffdrivr.h"
 #include "cffgload.h"
@@ -1088,6 +1089,21 @@
 #endif
 
 
+  /*
+   *  CFFLOAD SERVICE
+   *
+   */
+
+  FT_DEFINE_SERVICE_CFFLOADREC(
+    cff_service_cff_load,
+
+    (FT_Get_Standard_Encoding_Func) cff_get_standard_encoding,
+    (FT_Load_Private_Dict_Func)     cff_load_private_dict,
+    (FT_FD_Select_Get_Func)         cff_fd_select_get,
+    (FT_Blend_Check_Vector_Func)    cff_blend_check_vector,
+    (FT_Blend_Build_Vector_Func)    cff_blend_build_vector
+  )
+
   /*************************************************************************/
   /*************************************************************************/
   /*************************************************************************/
@@ -1102,7 +1118,7 @@
 
 #if !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES && \
      defined TT_CONFIG_OPTION_GX_VAR_SUPPORT
-  FT_DEFINE_SERVICEDESCREC9(
+  FT_DEFINE_SERVICEDESCREC10(
     cff_services,
 
     FT_SERVICE_ID_FONT_FORMAT,          FT_FONT_FORMAT_CFF,
@@ -1113,10 +1129,11 @@
     FT_SERVICE_ID_GLYPH_DICT,           &CFF_SERVICE_GLYPH_DICT_GET,
     FT_SERVICE_ID_TT_CMAP,              &CFF_SERVICE_GET_CMAP_INFO_GET,
     FT_SERVICE_ID_CID,                  &CFF_SERVICE_CID_INFO_GET,
-    FT_SERVICE_ID_PROPERTIES,           &CFF_SERVICE_PROPERTIES_GET
+    FT_SERVICE_ID_PROPERTIES,           &CFF_SERVICE_PROPERTIES_GET,
+    FT_SERVICE_ID_CFF_LOAD,             &CFF_SERVICE_CFF_LOAD_GET
   )
 #elif !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES
-  FT_DEFINE_SERVICEDESCREC7(
+  FT_DEFINE_SERVICEDESCREC8(
     cff_services,
 
     FT_SERVICE_ID_FONT_FORMAT,          FT_FONT_FORMAT_CFF,
@@ -1125,10 +1142,11 @@
     FT_SERVICE_ID_GLYPH_DICT,           &CFF_SERVICE_GLYPH_DICT_GET,
     FT_SERVICE_ID_TT_CMAP,              &CFF_SERVICE_GET_CMAP_INFO_GET,
     FT_SERVICE_ID_CID,                  &CFF_SERVICE_CID_INFO_GET,
-    FT_SERVICE_ID_PROPERTIES,           &CFF_SERVICE_PROPERTIES_GET
+    FT_SERVICE_ID_PROPERTIES,           &CFF_SERVICE_PROPERTIES_GET,
+    FT_SERVICE_ID_CFF_LOAD,             &CFF_SERVICE_CFF_LOAD_GET
   )
 #elif defined TT_CONFIG_OPTION_GX_VAR_SUPPORT
-  FT_DEFINE_SERVICEDESCREC8(
+  FT_DEFINE_SERVICEDESCREC9(
     cff_services,
 
     FT_SERVICE_ID_FONT_FORMAT,          FT_FONT_FORMAT_CFF,
@@ -1138,10 +1156,11 @@
     FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
     FT_SERVICE_ID_TT_CMAP,              &CFF_SERVICE_GET_CMAP_INFO_GET,
     FT_SERVICE_ID_CID,                  &CFF_SERVICE_CID_INFO_GET,
-    FT_SERVICE_ID_PROPERTIES,           &CFF_SERVICE_PROPERTIES_GET
+    FT_SERVICE_ID_PROPERTIES,           &CFF_SERVICE_PROPERTIES_GET,
+    FT_SERVICE_ID_CFF_LOAD,             &CFF_SERVICE_CFF_LOAD_GET
   )
 #else
-  FT_DEFINE_SERVICEDESCREC6(
+  FT_DEFINE_SERVICEDESCREC7(
     cff_services,
 
     FT_SERVICE_ID_FONT_FORMAT,          FT_FONT_FORMAT_CFF,
@@ -1149,7 +1168,8 @@
     FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
     FT_SERVICE_ID_TT_CMAP,              &CFF_SERVICE_GET_CMAP_INFO_GET,
     FT_SERVICE_ID_CID,                  &CFF_SERVICE_CID_INFO_GET,
-    FT_SERVICE_ID_PROPERTIES,           &CFF_SERVICE_PROPERTIES_GET
+    FT_SERVICE_ID_PROPERTIES,           &CFF_SERVICE_PROPERTIES_GET,
+    FT_SERVICE_ID_CFF_LOAD,             &CFF_SERVICE_CFF_LOAD_GET
   )
 #endif
 
diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c
index b0d275c..ed15466 100644
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -496,6 +496,7 @@
     FT_Service_PsCMaps  psnames;
     PSHinter_Service    pshinter;
     PSAux_Service       psaux;
+    FT_Service_CFFLoad  cffload;
     FT_Bool             pure_cff    = 1;
     FT_Bool             cff2        = 0;
     FT_Bool             sfnt_format = 0;
@@ -526,6 +527,8 @@
     }
     face->psaux = psaux;
 
+    FT_FACE_FIND_GLOBAL_SERVICE( face, cffload, CFF_LOAD );
+
     FT_TRACE2(( "CFF driver\n" ));
 
     /* create input stream from resource */
@@ -627,6 +630,7 @@
 
       cff->pshinter = pshinter;
       cff->psnames  = psnames;
+      cff->cffload  = cffload;
 
       cffface->face_index = face_index & 0xFFFF;
 
diff --git a/src/cff/cffpic.h b/src/cff/cffpic.h
index 5db39cd..a7e0197 100644
--- a/src/cff/cffpic.h
+++ b/src/cff/cffpic.h
@@ -22,7 +22,6 @@
 
 #include FT_INTERNAL_PIC_H
 
-
 #ifndef FT_CONFIG_OPTION_PIC
 
 #define CFF_SERVICE_PS_INFO_GET          cff_service_ps_info
@@ -34,6 +33,7 @@
 #define CFF_SERVICES_GET                 cff_services
 #define CFF_SERVICE_MULTI_MASTERS_GET    cff_service_multi_masters
 #define CFF_SERVICE_METRICS_VAR_GET      cff_service_metrics_variations
+#define CFF_SERVICE_CFF_LOAD_GET         cff_service_cff_load
 #define CFF_CMAP_ENCODING_CLASS_REC_GET  cff_cmap_encoding_class_rec
 #define CFF_CMAP_UNICODE_CLASS_REC_GET   cff_cmap_unicode_class_rec
 #define CFF_FIELD_HANDLERS_GET           cff_field_handlers
@@ -65,6 +65,7 @@ FT_BEGIN_HEADER
     FT_Service_PropertiesRec         cff_service_properties;
     FT_Service_MultiMastersRec       cff_service_multi_masters;
     FT_Service_MetricsVariationsRec  cff_service_metrics_variations;
+    FT_Service_CFFLoadRec            cff_service_cff_load;
     FT_CMap_ClassRec                 cff_cmap_encoding_class_rec;
     FT_CMap_ClassRec                 cff_cmap_unicode_class_rec;
 
@@ -92,6 +93,8 @@ FT_BEGIN_HEADER
           ( GET_PIC( library )->cff_service_multi_masters )
 #define CFF_SERVICE_METRICS_VAR_GET                              \
           ( GET_PIC( library )->cff_service_metrics_variations )
+#define CFF_SERVICE_CFF_LOAD_GET                       \
+          ( GET_PIC( library )->cff_service_cff_load )
 #define CFF_CMAP_ENCODING_CLASS_REC_GET                       \
           ( GET_PIC( library )->cff_cmap_encoding_class_rec )
 #define CFF_CMAP_UNICODE_CLASS_REC_GET                       \
diff --git a/src/cff/cfftypes.h b/src/cff/cfftypes.h
index 74f569f..d6de1f3 100644
--- a/src/cff/cfftypes.h
+++ b/src/cff/cfftypes.h
@@ -381,6 +381,9 @@ FT_BEGIN_HEADER
     /* interface to Postscript Names service */
     FT_Service_PsCMaps  psnames;
 
+    /* interface to CFFLoad service */
+    const void*  cffload;
+
     /* since version 2.3.0 */
     PS_FontInfoRec*  font_info;   /* font info dictionary */
 
diff --git a/src/psaux/cf2font.c b/src/psaux/cf2font.c
index 4ac71a8..8d0dfc6 100644
--- a/src/psaux/cf2font.c
+++ b/src/psaux/cf2font.c
@@ -260,6 +260,7 @@
     CF2_UInt   lenNormalizedV = 0;
     FT_Fixed*  normalizedV    = NULL;
 
+    FT_Service_CFFLoad  cffload = (FT_Service_CFFLoad)font->cffload;
 
     /* clear previous error */
     font->error = FT_Err_Ok;
@@ -287,16 +288,16 @@
       if ( font->error )
         return;
 
-      if ( cff_blend_check_vector( &subFont->blend,
-                                   subFont->private_dict.vsindex,
-                                   lenNormalizedV,
-                                   normalizedV ) )
+      if ( cffload->blend_check_vector( &subFont->blend,
+                                        subFont->private_dict.vsindex,
+                                        lenNormalizedV,
+                                        normalizedV ) )
       {
         /* blend has changed, reparse */
-        cff_load_private_dict( decoder->cff,
-                               subFont,
-                               lenNormalizedV,
-                               normalizedV );
+        cffload->load_private_dict( decoder->cff,
+                                    subFont,
+                                    lenNormalizedV,
+                                    normalizedV );
         needExtraSetup = TRUE;
       }
 #endif
diff --git a/src/psaux/cf2font.h b/src/psaux/cf2font.h
index 17ecd17..94a31ca 100644
--- a/src/psaux/cf2font.h
+++ b/src/psaux/cf2font.h
@@ -40,9 +40,10 @@
 #define CF2FONT_H_
 
 
+#include FT_SERVICE_CFF_TABLE_LOAD_H
+
 #include "cf2ft.h"
 #include "cf2blues.h"
-#include "cffload.h"
 
 
 FT_BEGIN_HEADER
@@ -111,6 +112,8 @@ FT_BEGIN_HEADER
                                            /* counterclockwise winding */
 
     CF2_BluesRec  blues;                         /* computed zone data */
+
+    FT_Service_CFFLoad  cffload;                  /* Pointer to cff functions */
   };
 
 
diff --git a/src/psaux/cf2ft.c b/src/psaux/cf2ft.c
index 169e116..ee8133c 100644
--- a/src/psaux/cf2ft.c
+++ b/src/psaux/cf2ft.c
@@ -42,6 +42,7 @@
 #include "cf2font.h"
 #include "cf2error.h"
 
+#include FT_SERVICE_CFF_TABLE_LOAD_H
 
 #define CF2_MAX_SIZE  cf2_intToFixed( 2000 )    /* max ppem */
 
@@ -324,6 +325,7 @@
       font = (CF2_Font)decoder->cff->cf2_instance.data;
 
       font->memory = memory;
+      font->cffload = (FT_Service_CFFLoad)decoder->cff->cffload;
 
       /* initialize a client outline, to be shared by each glyph rendered */
       cf2_outline_init( &font->outline, font->memory, &font->error );
diff --git a/src/psaux/cf2intrp.c b/src/psaux/cf2intrp.c
index a816280..3e7ad57 100644
--- a/src/psaux/cf2intrp.c
+++ b/src/psaux/cf2intrp.c
@@ -38,6 +38,7 @@
 
 #include "cf2ft.h"
 #include FT_INTERNAL_DEBUG_H
+#include FT_SERVICE_CFF_TABLE_LOAD_H
 
 #include "cf2glue.h"
 #include "cf2font.h"
@@ -47,8 +48,6 @@
 
 #include "cf2error.h"
 
-#include "cffload.h"
-
 
   /*************************************************************************/
   /*                                                                       */
@@ -689,15 +688,15 @@
           }
 
           /* check cached blend vector */
-          if ( cff_blend_check_vector( &font->blend,
-                                       font->vsindex,
-                                       font->lenNDV,
-                                       font->NDV ) )
+          if ( font->cffload->blend_check_vector( &font->blend,
+                                                  font->vsindex,
+                                                  font->lenNDV,
+                                                  font->NDV ) )
           {
-            lastError = cff_blend_build_vector( &font->blend,
-                                                font->vsindex,
-                                                font->lenNDV,
-                                                font->NDV );
+            lastError = font->cffload->blend_build_vector( &font->blend,
+                                                           font->vsindex,
+                                                           font->lenNDV,
+                                                           font->NDV );
             if ( lastError )
               goto exit;
           }
diff --git a/src/psaux/cffdecode.c b/src/psaux/cffdecode.c
index baa318b..dceb916 100644
--- a/src/psaux/cffdecode.c
+++ b/src/psaux/cffdecode.c
@@ -1,6 +1,8 @@
 
 
 #include <ft2build.h>
+#include FT_INTERNAL_SERVICE_H
+#include FT_SERVICE_CFF_TABLE_LOAD_H
 
 #include "cffdecode.h"
 #include "psobjs.h"
@@ -390,7 +392,7 @@
   {
     FT_UInt    n;
     FT_UShort  glyph_sid;
-
+    FT_Service_CFFLoad  cffload;
 
     /* CID-keyed fonts don't have glyph names */
     if ( !cff->charset.sids )
@@ -400,8 +402,24 @@
     if ( charcode < 0 || charcode > 255 )
       return -1;
 
+#if 0
+    /* retrieve cffload from list of current modules */
+    FT_Service_CFFLoad  cffload;
+    {
+      FT_FACE_FIND_GLOBAL_SERVICE( face, cffload, CFF_LOAD );
+      if ( !cffload )
+      {
+        FT_ERROR(( "cff_lookup_glyph_by_stdcharcode:"
+                   " the `cffload' module is not available\n" ));
+        return FT_THROW( Unimplemented_Feature );
+      }
+    }
+#endif
+
+    cffload = (FT_Service_CFFLoad)cff->cffload;
+
     /* Get code to SID mapping from `cff_standard_encoding'. */
-    glyph_sid = cff_get_standard_encoding( (FT_UInt)charcode );
+    glyph_sid = cffload->get_standard_encoding( (FT_UInt)charcode );
 
     for ( n = 0; n < cff->num_glyphs; n++ )
     {
@@ -2271,11 +2289,12 @@
     CFF_SubFont   sub     = &cff->top_font;
     FT_Error      error   = FT_Err_Ok;
 
+    FT_Service_CFFLoad  cffload = (FT_Service_CFFLoad)cff->cffload;
 
     /* manage CID fonts */
     if ( cff->num_subfonts )
     {
-      FT_Byte  fd_index = cff_fd_select_get( &cff->fd_select, glyph_index );
+      FT_Byte  fd_index = cffload->fd_select_get( &cff->fd_select, glyph_index );
 
 
       if ( fd_index >= cff->num_subfonts )