Commit 78a1e69517ca067224d6e33beffd25e2ec8361d2

Chris Liddell 2018-11-27T22:24:06

[type1,cff] Add FT_{Set,Get}_MM_WeightVector API calls. For multiple master fonts, common usage (in Postscript) is to modify the WeightVector of an existing font instance, this addition supports that use. * include/freetype/ftmm.h, src/base/ftmm.c (FT_Set_MM_WeightVector, FT_Get_MM_WeightVector): New API functions. * include/freetype/internalservices/svmm.h (FT_Set_MM_WeightVector_Func, FT_Get_MM_WeightVector_Func): New function types. (MultiMasters): Add `set_mm_weightvector' and `get_mm_weightvector' members. (FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated. * src/cffcffdrivr.c (cff_set_mm_weightvector, cff_get_mm_weightvector): New functions. (cff_service_multi_masters): Register them. * src/truetype/ttdriver.c (tt_service_gx_multi_masters): Updated. This driver doesn't use the new interface. * src/type1/t1load.c (T1_Set_MM_WeightVector, T1_Get_MM_WeightVector): New functions. * src/type1/t1driver.c (t1_service_multi_masters): Register them. * src/type1/t1load.h: Updated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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
diff --git a/ChangeLog b/ChangeLog
index ac73684..3a0162b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2018-11-27  Chris Liddell  <chris.liddell@artifex.com>
+
+	[type1,cff] Add FT_{Set,Get}_MM_WeightVector API calls.
+
+	For multiple master fonts, common usage (in Postscript) is to modify
+	the WeightVector of an existing font instance, this addition
+	supports that use.
+
+	* include/freetype/ftmm.h, src/base/ftmm.c (FT_Set_MM_WeightVector,
+	FT_Get_MM_WeightVector): New API functions.
+
+	* include/freetype/internalservices/svmm.h
+	(FT_Set_MM_WeightVector_Func, FT_Get_MM_WeightVector_Func): New
+	function types.
+	(MultiMasters): Add `set_mm_weightvector' and `get_mm_weightvector'
+	members.
+	(FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated.
+
+	* src/cffcffdrivr.c (cff_set_mm_weightvector,
+	cff_get_mm_weightvector): New functions.
+	(cff_service_multi_masters): Register them.
+
+	* src/truetype/ttdriver.c (tt_service_gx_multi_masters): Updated.
+	This driver doesn't use the new interface.
+
+	* src/type1/t1load.c (T1_Set_MM_WeightVector,
+	T1_Get_MM_WeightVector): New functions.
+	* src/type1/t1driver.c (t1_service_multi_masters): Register them.
+	* src/type1/t1load.h: Updated.
+
 2018-11-27  Ben Wagner  <bungeman@google.com>
 
 	[cff] Fix compiler warning (#55105).
diff --git a/include/freetype/ftmm.h b/include/freetype/ftmm.h
index 0584ce6..a432f5d 100644
--- a/include/freetype/ftmm.h
+++ b/include/freetype/ftmm.h
@@ -563,6 +563,98 @@ FT_BEGIN_HEADER
 
   /**************************************************************************
    *
+   * @function:
+   *   FT_Set_MM_WeightVector
+   *
+   * @description:
+   *   For Adobe MM fonts, choose an interpolated font design by directly
+   *   setting the weight vector.
+   *
+   *   This function can't be used with TrueType GX or OpenType variation
+   *   fonts.
+   *
+   * @inout:
+   *   face ::
+   *     A handle to the source face.
+   *
+   * @input:
+   *   len ::
+   *     The length of the weight vector array.  If it is larger than the
+   *     number of designs, the extra values are ignored.  If it is less than
+   *     the number of designs, the remaining values are set to zero.
+   *
+   *   weightvector ::
+   *     An array representing the weight vector.
+   *
+   * @return:
+   *   FreeType error code.  0~means success.
+   *
+   * @note:
+   *   Adobe Multiple Master fonts limit the number of designs, and thus the
+   *   length of the weight vector to~16.
+   *
+   *   If `len` is zero and `weightvector` is NULL, the weight vector array
+   *   is reset to the default values.
+   *
+   *   The Adobe documentation also states that the values in the
+   *   WeightVector array must total 1.0 +/-~0.001.  In practice this does
+   *   not seem to be enforced, so is not enforced here, either.
+   *
+   * @since:
+   *   2.10
+   */
+  FT_EXPORT( FT_Error )
+  FT_Set_MM_WeightVector( FT_Face    face,
+                          FT_UInt    len,
+                          FT_Fixed*  weightvector );
+
+
+  /**************************************************************************
+   *
+   * @function:
+   *   FT_Get_MM_WeightVector
+   *
+   * @description:
+   *   For Adobe MM fonts, retrieve the current weight vector of the font.
+   *
+   *   This function can't be used with TrueType GX or OpenType variation
+   *   fonts.
+   *
+   * @inout:
+   *   face ::
+   *     A handle to the source face.
+   *
+   *   len ::
+   *     A pointer to the size of the array to be filled.  If the size of the
+   *     array is less than the number of designs, `FT_Err_Invalid_Argument`
+   *     is returned, and `len` is set to the required size (the number of
+   *     designs).  If the size of the array is greater than the number of
+   *     designs, the remaining entries are set to~0.  On successful
+   *     completion, `len` is set to the number of designs (i.e., the number
+   *     of values written to the array).
+   *
+   * @utput:
+   *   weightvector ::
+   *     An array to be filled.
+   *
+   * @return:
+   *   FreeType error code.  0~means success.
+   *
+   * @note:
+   *   Adobe Multiple Master fonts limit the number of designs, and thus the
+   *   length of the WeightVector to~16.
+   *
+   * @since:
+   *   2.10
+   */
+  FT_EXPORT( FT_Error )
+  FT_Get_MM_WeightVector( FT_Face    face,
+                          FT_UInt*   len,
+                          FT_Fixed*  weightvector );
+
+
+  /**************************************************************************
+   *
    * @enum:
    *   FT_VAR_AXIS_FLAG_XXX
    *
diff --git a/include/freetype/internal/services/svmm.h b/include/freetype/internal/services/svmm.h
index 6aeaa45..4264259 100644
--- a/include/freetype/internal/services/svmm.h
+++ b/include/freetype/internal/services/svmm.h
@@ -86,47 +86,63 @@ FT_BEGIN_HEADER
   typedef void
   (*FT_Done_Blend_Func)( FT_Face );
 
+  typedef FT_Error
+  (*FT_Set_MM_WeightVector_Func)( FT_Face    face,
+                                  FT_UInt    len,
+                                  FT_Fixed*  weight_vector );
+
+  typedef FT_Error
+  (*FT_Get_MM_WeightVector_Func)( FT_Face    face,
+                                  FT_UInt*   len,
+                                  FT_Fixed*  weight_vector );
+
 
   FT_DEFINE_SERVICE( MultiMasters )
   {
-    FT_Get_MM_Func          get_mm;
-    FT_Set_MM_Design_Func   set_mm_design;
-    FT_Set_MM_Blend_Func    set_mm_blend;
-    FT_Get_MM_Blend_Func    get_mm_blend;
-    FT_Get_MM_Var_Func      get_mm_var;
-    FT_Set_Var_Design_Func  set_var_design;
-    FT_Get_Var_Design_Func  get_var_design;
-    FT_Set_Instance_Func    set_instance;
+    FT_Get_MM_Func               get_mm;
+    FT_Set_MM_Design_Func        set_mm_design;
+    FT_Set_MM_Blend_Func         set_mm_blend;
+    FT_Get_MM_Blend_Func         get_mm_blend;
+    FT_Get_MM_Var_Func           get_mm_var;
+    FT_Set_Var_Design_Func       set_var_design;
+    FT_Get_Var_Design_Func       get_var_design;
+    FT_Set_Instance_Func         set_instance;
+    FT_Set_MM_WeightVector_Func  set_mm_weightvector;
+    FT_Get_MM_WeightVector_Func  get_mm_weightvector;
 
     /* for internal use; only needed for code sharing between modules */
-    FT_Get_Var_Blend_Func   get_var_blend;
-    FT_Done_Blend_Func      done_blend;
+    FT_Get_Var_Blend_Func  get_var_blend;
+    FT_Done_Blend_Func     done_blend;
   };
 
 
-#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_,          \
-                                           get_mm_,         \
-                                           set_mm_design_,  \
-                                           set_mm_blend_,   \
-                                           get_mm_blend_,   \
-                                           get_mm_var_,     \
-                                           set_var_design_, \
-                                           get_var_design_, \
-                                           set_instance_,   \
-                                           get_var_blend_,  \
-                                           done_blend_ )    \
-  static const FT_Service_MultiMastersRec  class_ =         \
-  {                                                         \
-    get_mm_,                                                \
-    set_mm_design_,                                         \
-    set_mm_blend_,                                          \
-    get_mm_blend_,                                          \
-    get_mm_var_,                                            \
-    set_var_design_,                                        \
-    get_var_design_,                                        \
-    set_instance_,                                          \
-    get_var_blend_,                                         \
-    done_blend_                                             \
+#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_,            \
+                                           get_mm_,           \
+                                           set_mm_design_,    \
+                                           set_mm_blend_,     \
+                                           get_mm_blend_,     \
+                                           get_mm_var_,       \
+                                           set_var_design_,   \
+                                           get_var_design_,   \
+                                           set_instance_,     \
+                                           set_weightvector_, \
+                                           get_weightvector_, \
+                                           get_var_blend_,    \
+                                           done_blend_ )      \
+  static const FT_Service_MultiMastersRec  class_ =           \
+  {                                                           \
+    get_mm_,                                                  \
+    set_mm_design_,                                           \
+    set_mm_blend_,                                            \
+    get_mm_blend_,                                            \
+    get_mm_var_,                                              \
+    set_var_design_,                                          \
+    get_var_design_,                                          \
+    set_instance_,                                            \
+    set_weightvector_,                                        \
+    get_weightvector_,                                        \
+    get_var_blend_,                                           \
+    done_blend_                                               \
   };
 
   /* */
diff --git a/src/base/ftmm.c b/src/base/ftmm.c
index 54ab9e7..11c0e27 100644
--- a/src/base/ftmm.c
+++ b/src/base/ftmm.c
@@ -202,6 +202,67 @@
   /* documentation is in ftmm.h */
 
   FT_EXPORT_DEF( FT_Error )
+  FT_Set_MM_WeightVector( FT_Face    face,
+                          FT_UInt    len,
+                          FT_Fixed*  weightvector )
+  {
+    FT_Error                 error;
+    FT_Service_MultiMasters  service;
+
+
+    /* check of `face' delayed to `ft_face_get_mm_service' */
+
+    if ( len && !weightvector )
+      return FT_THROW( Invalid_Argument );
+
+    error = ft_face_get_mm_service( face, &service );
+    if ( !error )
+    {
+      error = FT_ERR( Invalid_Argument );
+      if ( service->set_mm_weightvector )
+        error = service->set_mm_weightvector( face, len, weightvector );
+    }
+
+    /* enforce recomputation of auto-hinting data */
+    if ( !error && face->autohint.finalizer )
+    {
+      face->autohint.finalizer( face->autohint.data );
+      face->autohint.data = NULL;
+    }
+
+    return error;
+  }
+
+
+  FT_EXPORT_DEF( FT_Error )
+  FT_Get_MM_WeightVector( FT_Face    face,
+                          FT_UInt*   len,
+                          FT_Fixed*  weightvector )
+  {
+    FT_Error                 error;
+    FT_Service_MultiMasters  service;
+
+
+    /* check of `face' delayed to `ft_face_get_mm_service' */
+
+    if ( len && !weightvector )
+      return FT_THROW( Invalid_Argument );
+
+    error = ft_face_get_mm_service( face, &service );
+    if ( !error )
+    {
+      error = FT_ERR( Invalid_Argument );
+      if ( service->get_mm_weightvector )
+        error = service->get_mm_weightvector( face, len, weightvector );
+    }
+
+    return error;
+  }
+
+
+  /* documentation is in ftmm.h */
+
+  FT_EXPORT_DEF( FT_Error )
   FT_Set_Var_Design_Coordinates( FT_Face    face,
                                  FT_UInt    num_coords,
                                  FT_Fixed*  coords )
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 3e43bed..9fe07b8 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -868,6 +868,30 @@
 
 
   static FT_Error
+  cff_set_mm_weightvector( CFF_Face   face,
+                           FT_UInt    len,
+                           FT_Fixed*  weightvector )
+  {
+    FT_Service_MultiMasters  mm = (FT_Service_MultiMasters)face->mm;
+
+
+    return mm->set_mm_weightvector( FT_FACE( face ), len, weightvector );
+  }
+
+
+  static FT_Error
+  cff_get_mm_weightvector( CFF_Face   face,
+                           FT_UInt*   len,
+                           FT_Fixed*  weightvector )
+  {
+    FT_Service_MultiMasters  mm = (FT_Service_MultiMasters)face->mm;
+
+
+    return mm->get_mm_weightvector( FT_FACE( face ), len, weightvector );
+  }
+
+
+  static FT_Error
   cff_get_mm_var( CFF_Face     face,
                   FT_MM_Var*  *master )
   {
@@ -916,17 +940,19 @@
   FT_DEFINE_SERVICE_MULTIMASTERSREC(
     cff_service_multi_masters,
 
-    (FT_Get_MM_Func)        NULL,                   /* get_mm         */
-    (FT_Set_MM_Design_Func) NULL,                   /* set_mm_design  */
-    (FT_Set_MM_Blend_Func)  cff_set_mm_blend,       /* set_mm_blend   */
-    (FT_Get_MM_Blend_Func)  cff_get_mm_blend,       /* get_mm_blend   */
-    (FT_Get_MM_Var_Func)    cff_get_mm_var,         /* get_mm_var     */
-    (FT_Set_Var_Design_Func)cff_set_var_design,     /* set_var_design */
-    (FT_Get_Var_Design_Func)cff_get_var_design,     /* get_var_design */
-    (FT_Set_Instance_Func)  cff_set_instance,       /* set_instance   */
-
-    (FT_Get_Var_Blend_Func) cff_get_var_blend,      /* get_var_blend  */
-    (FT_Done_Blend_Func)    cff_done_blend          /* done_blend     */
+    (FT_Get_MM_Func)             NULL,                    /* get_mm              */
+    (FT_Set_MM_Design_Func)      NULL,                    /* set_mm_design       */
+    (FT_Set_MM_Blend_Func)       cff_set_mm_blend,        /* set_mm_blend        */
+    (FT_Get_MM_Blend_Func)       cff_get_mm_blend,        /* get_mm_blend        */
+    (FT_Get_MM_Var_Func)         cff_get_mm_var,          /* get_mm_var          */
+    (FT_Set_Var_Design_Func)     cff_set_var_design,      /* set_var_design      */
+    (FT_Get_Var_Design_Func)     cff_get_var_design,      /* get_var_design      */
+    (FT_Set_Instance_Func)       cff_set_instance,        /* set_instance        */
+    (FT_Set_MM_WeightVector_Func)cff_set_mm_weightvector, /* set_mm_weightvector */
+    (FT_Get_MM_WeightVector_Func)cff_get_mm_weightvector, /* get_mm_weightvector */
+
+    (FT_Get_Var_Blend_Func)      cff_get_var_blend,       /* get_var_blend       */
+    (FT_Done_Blend_Func)         cff_done_blend           /* done_blend          */
   )
 
 
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index a197d6c..58d34c5 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -498,17 +498,19 @@
   FT_DEFINE_SERVICE_MULTIMASTERSREC(
     tt_service_gx_multi_masters,
 
-    (FT_Get_MM_Func)        NULL,                   /* get_mm         */
-    (FT_Set_MM_Design_Func) NULL,                   /* set_mm_design  */
-    (FT_Set_MM_Blend_Func)  TT_Set_MM_Blend,        /* set_mm_blend   */
-    (FT_Get_MM_Blend_Func)  TT_Get_MM_Blend,        /* get_mm_blend   */
-    (FT_Get_MM_Var_Func)    TT_Get_MM_Var,          /* get_mm_var     */
-    (FT_Set_Var_Design_Func)TT_Set_Var_Design,      /* set_var_design */
-    (FT_Get_Var_Design_Func)TT_Get_Var_Design,      /* get_var_design */
-    (FT_Set_Instance_Func)  TT_Set_Named_Instance,  /* set_instance   */
-
-    (FT_Get_Var_Blend_Func) tt_get_var_blend,       /* get_var_blend  */
-    (FT_Done_Blend_Func)    tt_done_blend           /* done_blend     */
+    (FT_Get_MM_Func)             NULL,                  /* get_mm              */
+    (FT_Set_MM_Design_Func)      NULL,                  /* set_mm_design       */
+    (FT_Set_MM_Blend_Func)       TT_Set_MM_Blend,       /* set_mm_blend        */
+    (FT_Get_MM_Blend_Func)       TT_Get_MM_Blend,       /* get_mm_blend        */
+    (FT_Get_MM_Var_Func)         TT_Get_MM_Var,         /* get_mm_var          */
+    (FT_Set_Var_Design_Func)     TT_Set_Var_Design,     /* set_var_design      */
+    (FT_Get_Var_Design_Func)     TT_Get_Var_Design,     /* get_var_design      */
+    (FT_Set_Instance_Func)       TT_Set_Named_Instance, /* set_instance        */
+    (FT_Set_MM_WeightVector_Func)NULL,                  /* set_mm_weightvector */
+    (FT_Get_MM_WeightVector_Func)NULL,                  /* get_mm_weightvector */
+
+    (FT_Get_Var_Blend_Func)      tt_get_var_blend,      /* get_var_blend       */
+    (FT_Done_Blend_Func)         tt_done_blend          /* done_blend          */
   )
 
   FT_DEFINE_SERVICE_METRICSVARIATIONSREC(
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index 3cde1dc..710ff14 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -122,17 +122,19 @@
 #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
   static const FT_Service_MultiMastersRec  t1_service_multi_masters =
   {
-    (FT_Get_MM_Func)        T1_Get_Multi_Master,   /* get_mm         */
-    (FT_Set_MM_Design_Func) T1_Set_MM_Design,      /* set_mm_design  */
-    (FT_Set_MM_Blend_Func)  T1_Set_MM_Blend,       /* set_mm_blend   */
-    (FT_Get_MM_Blend_Func)  T1_Get_MM_Blend,       /* get_mm_blend   */
-    (FT_Get_MM_Var_Func)    T1_Get_MM_Var,         /* get_mm_var     */
-    (FT_Set_Var_Design_Func)T1_Set_Var_Design,     /* set_var_design */
-    (FT_Get_Var_Design_Func)T1_Get_Var_Design,     /* get_var_design */
-    (FT_Set_Instance_Func)  T1_Reset_MM_Blend,     /* set_instance   */
-
-    (FT_Get_Var_Blend_Func) NULL,                  /* get_var_blend  */
-    (FT_Done_Blend_Func)    T1_Done_Blend          /* done_blend     */
+    (FT_Get_MM_Func)             T1_Get_Multi_Master,    /* get_mm              */
+    (FT_Set_MM_Design_Func)      T1_Set_MM_Design,       /* set_mm_design       */
+    (FT_Set_MM_Blend_Func)       T1_Set_MM_Blend,        /* set_mm_blend        */
+    (FT_Get_MM_Blend_Func)       T1_Get_MM_Blend,        /* get_mm_blend        */
+    (FT_Get_MM_Var_Func)         T1_Get_MM_Var,          /* get_mm_var          */
+    (FT_Set_Var_Design_Func)     T1_Set_Var_Design,      /* set_var_design      */
+    (FT_Get_Var_Design_Func)     T1_Get_Var_Design,      /* get_var_design      */
+    (FT_Set_Instance_Func)       T1_Reset_MM_Blend,      /* set_instance        */
+    (FT_Set_MM_WeightVector_Func)T1_Set_MM_WeightVector, /* set_mm_weightvector */
+    (FT_Get_MM_WeightVector_Func)T1_Get_MM_WeightVector, /* get_mm_weightvector */
+
+    (FT_Get_Var_Blend_Func)      NULL,                   /* get_var_blend       */
+    (FT_Done_Blend_Func)         T1_Done_Blend           /* done_blend          */
   };
 #endif
 
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index 01befa2..60a2c35 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -481,6 +481,75 @@
 
 
   FT_LOCAL_DEF( FT_Error )
+  T1_Set_MM_WeightVector( T1_Face    face,
+                          FT_UInt    len,
+                          FT_Fixed*  weightvector )
+  {
+    PS_Blend  blend = face->blend;
+    FT_UInt   i, n;
+
+
+    if ( !blend )
+     return FT_THROW( Invalid_Argument );
+
+    if ( !len && !weightvector )
+    {
+      for ( i = 0; i < blend->num_designs; i++ )
+        blend->weight_vector[i] = blend->default_weight_vector[i];
+    }
+    else
+    {
+      if ( !weightvector )
+        return FT_THROW( Invalid_Argument );
+
+      n = len < blend->num_designs ? len : blend->num_designs;
+
+      for ( i = 0; i < n; i++ )
+        blend->weight_vector[i] = weightvector[i];
+
+      for ( ; i < blend->num_designs; i++ )
+        blend->weight_vector[i] = (FT_Fixed)0;
+
+      if ( len )
+        face->root.face_flags |= FT_FACE_FLAG_VARIATION;
+      else
+        face->root.face_flags &= ~FT_FACE_FLAG_VARIATION;
+    }
+
+    return FT_Err_Ok;
+  }
+
+
+  FT_LOCAL_DEF( FT_Error )
+  T1_Get_MM_WeightVector( T1_Face    face,
+                          FT_UInt*   len,
+                          FT_Fixed*  weightvector )
+  {
+    PS_Blend  blend = face->blend;
+    FT_UInt   i;
+
+
+    if ( !blend )
+      return FT_THROW( Invalid_Argument );
+
+    if ( *len < blend->num_designs )
+    {
+      *len = blend->num_designs;
+      return FT_THROW( Invalid_Argument );
+    }
+
+    for ( i = 0; i < blend->num_designs; i++ )
+      weightvector[i] = blend->weight_vector[i];
+    for ( ; i < *len; i++ )
+      weightvector[i] = (FT_Fixed)0;
+
+    *len = blend->num_designs;
+
+    return FT_Err_Ok;
+  }
+
+
+  FT_LOCAL_DEF( FT_Error )
   T1_Set_MM_Design( T1_Face   face,
                     FT_UInt   num_coords,
                     FT_Long*  coords )
diff --git a/src/type1/t1load.h b/src/type1/t1load.h
index 43d5db5..0535451 100644
--- a/src/type1/t1load.h
+++ b/src/type1/t1load.h
@@ -106,6 +106,16 @@ FT_BEGIN_HEADER
   FT_LOCAL( void )
   T1_Done_Blend( T1_Face  face );
 
+  FT_LOCAL( FT_Error )
+  T1_Set_MM_WeightVector( T1_Face    face,
+                          FT_UInt    len,
+                          FT_Fixed*  weightvector );
+
+  FT_LOCAL( FT_Error )
+  T1_Get_MM_WeightVector( T1_Face    face,
+                          FT_UInt*   len,
+                          FT_Fixed*  weightvector );
+
 #endif /* !T1_CONFIG_OPTION_NO_MM_SUPPORT */