Commit 28534d616be45a45767e5cfa65164a863d068eea

David Turner 2008-09-01T21:35:21

* include/freetype/ftadvanc.h, src/base/ftadvanc.c, include/freetype/config/ftheader.h, include/freetype/freetype.h, src/base/Jamfile, src/base/rules.mk, src/cff/cffdrivr.c, src/cff/cffgload.c, src/cff/cffgload.h, src/truetype/ttdriver.c, src/truetype/ttgload.h, src/truetype/ttgload.c, src/type1/t1driver.c, src/type1/t1gload.h, src/type1/t1gload.c: Add a new header named FT_ADVANCES_H declaring some new APIs to extract the advances of one or more glyphs without necessarily loading their outlines. Also provide 'fast loaders' for the TrueType, Type1 and CFF font drivers (more to come later) * autogen.sh: add checks for minimum version of the 'autotools' stuff.

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
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
diff --git a/ChangeLog b/ChangeLog
index 5a6c7a5..5210b35 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2008-09-01  david turner <david@freetype.org>
+
+	* include/freetype/ftadvanc.h, src/base/ftadvanc.c,
+	include/freetype/config/ftheader.h, include/freetype/freetype.h,
+	src/base/Jamfile, src/base/rules.mk, src/cff/cffdrivr.c,
+	src/cff/cffgload.c, src/cff/cffgload.h, src/truetype/ttdriver.c,
+	src/truetype/ttgload.h, src/truetype/ttgload.c, src/type1/t1driver.c,
+	src/type1/t1gload.h, src/type1/t1gload.c:
+	Add a new header named FT_ADVANCES_H declaring some new APIs
+	to extract the advances of one or more glyphs without necessarily
+	loading their outlines. Also provide 'fast loaders' for the
+	TrueType, Type1 and CFF font drivers (more to come later) 
+
+	* autogen.sh: add checks for minimum version of the 'autotools'
+	stuff.
+
 2008-08-29  suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
 
 	* src/sfnt/sfobjs.c (sfnt_open_font): Use TTAG_OTTO defined in
diff --git a/README.CVS b/README.CVS
index 2764ae9..676578f 100644
--- a/README.CVS
+++ b/README.CVS
@@ -13,17 +13,13 @@ The versions given  in parentheses are known to  work.  Newer versions
 should work too, of course.   Note that autogen.sh also sets up proper
 file permissions for the `configure' and auxiliary scripts.
 
-A very common problem is that this script complains that the `aclocal'
-program doesn't accept a `--force' option:
+The autogen.sh script now checks the version of your installed auto tools
+to see if they match the numbers above. If not, it will complain and suggest
+either upgrading or using an environment variable to point to a more recent
+version of the required tool(s).
 
-  generating `configure.ac'
-  running `aclocal -I . --force'
-  aclocal: unrecognized option -- `--force'
-  Try `aclocal --help' for more information.
-  error while running `aclocal -I . --force'
-
-This  means that  your version  of the  automake package  is  too old.
-Please update it before trying to build FreeType.
+Note that 'aclocal' is provided by the 'automake' package on Linux, and
+that 'libtoolize' is called 'glibtoolize' on Darwin (OS X)
 
 
 For static builds which  don't use platform specific optimizations, no
diff --git a/autogen.sh b/autogen.sh
index 87f30a1..c167abb 100644
--- a/autogen.sh
+++ b/autogen.sh
@@ -20,12 +20,119 @@ run ()
   fi
 }
 
+# extract major version
+get_major_version ()
+{
+    echo $1 | sed -e 's/\([0-9]\+\)\..*/\1/g'
+}
+
+get_minor_version ()
+{
+    echo $1 | sed -e 's/[0-9]\+\.\([0-9]\+\).*/\1/g'
+}
+
+get_patch_version ()
+{
+    # tricky, some version numbers don't include a patch
+    # separated with a point, but something like 1.4-p6
+    #
+    patch=`echo $1 | sed -e 's/[0-9]\+\.[0-9]\+\.\([0-9]\+\).*/\1/g'`
+    if test "$patch" = "$1"; then
+      patch=`echo $1 | sed -e 's/[0-9]\+\.[0-9]\+\-p\([0-9]\+\).*/\1/g'`
+      # if there isn't any patch number, default to 0
+      if test "$patch" = "$1"; then
+        patch=0
+      fi
+    fi
+    echo $patch
+}
+
+# $1: version to check
+# $2: minimum version
+compare_to_minimum_version ()
+{
+    MAJOR1=`get_major_version $1`
+    MAJOR2=`get_major_version $2`
+    if test $MAJOR1 -lt $MAJOR2; then
+      echo 0
+      return
+    else 
+      if test $MAJOR1 -gt $MAJOR2; then
+        echo 1
+        return
+      fi
+    fi
+
+    MINOR1=`get_minor_version $1`
+    MINOR2=`get_minor_version $2`
+    if test $MINOR1 -lt $MINOR2; then
+      echo 0
+      return
+    else 
+      if test $MINOR1 -gt $MINOR2; then
+        echo 1
+        return
+      fi
+    fi
+
+    PATCH1=`get_patch_version $1`
+    PATCH2=`get_patch_version $2`
+    if test $PATCH1 -lt $PATCH2; then
+        echo 0
+    else
+        echo 1
+    fi
+}
+
+
+# check that version of a given tool against a minimum version number
+# $1: tool path
+# $2: tool usual name (e.g. 'aclocal')
+# $3: tool variable  (e.g. 'ACLOCAL')
+# $4: minimum version to check against
+# $5: option field index used to extract the tool version from the output of --version
+#
+check_tool_version ()
+{
+  field=$5
+  if test "$field"x = x; then
+    field=4  # default to 4 for all GNU autotools
+  fi
+  version=`$1 --version | head -1 | cut -d ' ' -f $field`
+  version_check=`compare_to_minimum_version $version $4`
+  if test "$version_check"x = 0x; then
+      echo "ERROR: You $2 version is too old. minimum version $4 is required (yours is $version)"
+      echo "please upgrade or use the $3 variable to point to a more recent one"
+      echo ""
+      exit 1
+  fi
+}
+
 if test ! -f ./builds/unix/configure.raw; then
-  echo "You must be in the same directory as \`autogen.sh'."
-  echo "Bootstrapping doesn't work if srcdir != builddir."
-  exit 1
+ echo "You must be in the same directory as \`autogen.sh'."
+ echo "Bootstrapping doesn't work if srcdir != builddir."
+ exit 1
+fi
+
+# On MacOS X, the GNU libtool is named `glibtool'.
+HOSTOS=`uname`
+LIBTOOLIZE=libtoolize
+if test "$HOSTOS"x = Darwinx; then
+  LIBTOOLIZE=glibtoolize
+fi
+
+if test "$ACLOCAL"x = x; then
+  ACLOCAL=aclocal
 fi
 
+if test "$AUTOCONF"x = x; then
+  AUTOCONF=autoconf
+fi
+
+check_tool_version $ACLOCAL    aclocal ACLOCAL  1.10.1
+check_tool_version $LIBTOOLIZE libtoolize LIBTOOLIZE 2.2.4
+check_tool_version $AUTOCONF autoconf AUTOCONF 2.62
+
 # This sets freetype_major, freetype_minor, and freetype_patch.
 eval `sed -nf version.sed include/freetype/freetype.h`
 
@@ -40,13 +147,6 @@ echo "generating \`configure.ac'"
 sed -e "s;@VERSION@;$freetype_major$freetype_minor$freetype_patch;" \
     < configure.raw > configure.ac
 
-# On MacOS X, the GNU libtool is named `glibtool'.
-HOSTOS=`uname`
-LIBTOOLIZE=libtoolize
-if test "$HOSTOS"x = Darwinx; then
-  LIBTOOLIZE=glibtoolize
-fi
-
 run aclocal -I . --force
 run $LIBTOOLIZE --force --copy --install
 run autoconf --force
diff --git a/include/freetype/config/ftheader.h b/include/freetype/config/ftheader.h
index dc5ad3f..4c3ce0a 100644
--- a/include/freetype/config/ftheader.h
+++ b/include/freetype/config/ftheader.h
@@ -728,6 +728,16 @@
    */
 #define FT_GASP_H  <freetype/ftgasp.h>
 
+  /*************************************************************************
+   *
+   * @macro:
+   *   FT_ADVANCES_H
+   *
+   * @description:
+   *   A macro used in #include statements to name the file containing the
+   *   FreeType~2 API which returns individual and ranged glyph advances
+   */
+#define FT_ADVANCES_H             <freetype/ftadvanc.h>
 
   /* */
 
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index 238eca6..b0193c7 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -2431,8 +2431,11 @@ FT_BEGIN_HEADER
 #define FT_LOAD_IGNORE_TRANSFORM             0x800
 #define FT_LOAD_MONOCHROME                   0x1000
 #define FT_LOAD_LINEAR_DESIGN                0x2000
-#define FT_LOAD_SBITS_ONLY                   0x4000   /* temporary hack! */
 #define FT_LOAD_NO_AUTOHINT                  0x8000U
+#define FT_LOAD_ADVANCE_ONLY                 0x10000U
+
+  /* used internally only by certain font drivers ! */
+#define FT_LOAD_SBITS_ONLY                   0x4000
 
   /* */
 
diff --git a/include/freetype/internal/ftdriver.h b/include/freetype/internal/ftdriver.h
index e433e78..6119630 100644
--- a/include/freetype/internal/ftdriver.h
+++ b/include/freetype/internal/ftdriver.h
@@ -97,18 +97,17 @@ FT_BEGIN_HEADER
                              FT_UInt     right_glyph,
                              FT_Vector*  kerning );
 
-
   typedef FT_Error
   (*FT_Face_AttachFunc)( FT_Face    face,
                          FT_Stream  stream );
 
 
   typedef FT_Error
-  (*FT_Face_GetAdvancesFunc)( FT_Face     face,
-                              FT_UInt     first,
-                              FT_UInt     count,
-                              FT_Bool     vertical,
-                              FT_UShort*  advances );
+  (*FT_Face_GetAdvancesFunc)( FT_Face    face,
+                              FT_UInt    first,
+                              FT_UInt    count,
+                              FT_UInt    flags,
+                              FT_Fixed*  advances );
 
 
   /*************************************************************************/
diff --git a/src/base/Jamfile b/src/base/Jamfile
index aeffe38..d13d9bf 100644
--- a/src/base/Jamfile
+++ b/src/base/Jamfile
@@ -34,7 +34,7 @@ SubDir  FT2_TOP $(FT2_SRC_DIR) base ;
   local  _sources =  system  init    glyph  mm      bdf
                      bbox    debug   xf86   type1   pfr
                      stroke  winfnt  otval  bitmap  synth
-                     gxval   lcdfil  gasp   patent
+                     gxval   lcdfil  gasp   patent  advanc
                      ;
 
   Library  $(FT2_LIB) : ft$(_sources).c ;
diff --git a/src/base/rules.mk b/src/base/rules.mk
index d6e4412..738264c 100644
--- a/src/base/rules.mk
+++ b/src/base/rules.mk
@@ -44,7 +44,9 @@ BASE_SRC := $(BASE_DIR)/ftcalc.c   \
             $(BASE_DIR)/ftrfork.c  \
             $(BASE_DIR)/ftstream.c \
             $(BASE_DIR)/fttrigon.c \
-            $(BASE_DIR)/ftutil.c
+            $(BASE_DIR)/ftutil.c   \
+            $(BASE_DIR)/ftadvanc.c
+
 
 # Base layer `extensions' sources
 #
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 6c3ff98..4e96d68 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -187,6 +187,32 @@
   }
 
 
+  FT_CALLBACK_DEF(FT_Error)
+  cff_get_advances( FT_Face    ftface,
+                    FT_UInt    start,
+                    FT_UInt    count,
+                    FT_UInt    flags,
+                    FT_Fixed*  advances )
+  {
+    CFF_Face      face = (CFF_Face) ftface;
+    FT_UInt       nn;
+    FT_Error      error = 0;
+    FT_GlyphSlot  slot = face->root.glyph;
+
+    flags |= FT_LOAD_ADVANCE_ONLY;
+
+    for (nn = 0; nn < count; nn++)
+    {
+      error = Load_Glyph( slot, face->root.size, start+nn, flags );
+      if (error) break;
+
+      advances[nn] = (flags & FT_LOAD_VERTICAL_LAYOUT)
+                   ? slot->advance.y
+                   : slot->advance.x;
+    }
+    return error;
+  }
+
   /*
    *  GLYPH DICT SERVICE
    *
@@ -570,7 +596,7 @@
 
     cff_get_kerning,
     0,                      /* FT_Face_AttachFunc      */
-    0,                      /* FT_Face_GetAdvancesFunc */
+    cff_get_advances,       /* FT_Face_GetAdvancesFunc */
 
     cff_size_request,
 
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index 935239d..1914983 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -384,6 +384,11 @@
     decoder->hint_mode    = hint_mode;
   }
 
+  FT_LOCAL_DEF( void )
+  cff_decoder_set_width_only( CFF_Decoder*  decoder )
+  {
+    decoder->width_only = 1;
+  }
 
   /* this function is used to select the subfont */
   /* and the locals subrs array                  */
@@ -1200,6 +1205,12 @@
               decoder->glyph_width = decoder->nominal_width +
                                        ( stack[0] >> 16 );
 
+              if (decoder->width_only)
+              {
+                /* we only want the advance width, stop here */
+                break;
+              }
+
               /* Consumed an argument. */
               num_args--;
             }
@@ -2559,6 +2570,9 @@
       cff_decoder_init( &decoder, face, size, glyph, hinting,
                         FT_LOAD_TARGET_MODE( load_flags ) );
 
+      if ((load_flags & FT_LOAD_ADVANCE_ONLY) != 0)
+        cff_decoder_set_width_only( &decoder );
+
       decoder.builder.no_recurse =
         (FT_Bool)( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 );
 
diff --git a/src/cff/cffgload.h b/src/cff/cffgload.h
index d661f9e..bf21654 100644
--- a/src/cff/cffgload.h
+++ b/src/cff/cffgload.h
@@ -139,6 +139,7 @@ FT_BEGIN_HEADER
     FT_Pos             nominal_width;
 
     FT_Bool            read_width;
+    FT_Bool            width_only;
     FT_Int             num_hints;
     FT_Fixed*          buildchar;
     FT_Int             len_buildchar;
@@ -168,6 +169,9 @@ FT_BEGIN_HEADER
                     FT_Bool         hinting,
                     FT_Render_Mode  hint_mode );
 
+  FT_LOCAL( void )
+  cff_decoder_set_width_only( CFF_Decoder*  decoder );
+
   FT_LOCAL( FT_Error )
   cff_decoder_prepare( CFF_Decoder*  decoder,
                        CFF_Size      size,
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index c2cf452..2647cf5 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -125,6 +125,44 @@
 #undef PAIR_TAG
 
 
+  static FT_Error
+  tt_get_advances( FT_Face    ttface,
+                   FT_UInt    start,
+                   FT_UInt    count,
+                   FT_UInt    flags,
+                   FT_Fixed  *advances )
+  {
+    FT_UInt  nn;
+    TT_Face  face  = (TT_Face) ttface;
+    FT_Bool  check = FT_BOOL(!(flags & FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH));
+
+    /* XXX: TODO: check for sbits */
+
+    if (flags & FT_LOAD_VERTICAL_LAYOUT)
+    {
+      for (nn = 0; nn < count; nn++)
+      {
+        FT_Short   tsb;
+        FT_UShort  ah;
+
+        TT_Get_VMetrics( face, start + nn, check, &tsb, &ah );
+        advances[nn] = ah;
+      }
+    }
+    else
+    {
+      for (nn = 0; nn < count; nn++)
+      {
+        FT_Short   lsb;
+        FT_UShort  aw;
+
+        TT_Get_HMetrics( face, start + nn, check, &lsb, &aw );
+        advances[nn] = aw;
+      }
+    }
+    return 0;
+  }
+
   /*************************************************************************/
   /*************************************************************************/
   /*************************************************************************/
@@ -404,7 +442,7 @@
 
     tt_get_kerning,
     0,                      /* FT_Face_AttachFunc      */
-    0,                      /* FT_Face_GetAdvancesFunc */
+    tt_get_advances,
 
     tt_size_request,
 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index ed79b93..56857a3 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -69,12 +69,12 @@
   /* `check' is true, take care of monospaced fonts by returning the       */
   /* advance width maximum.                                                */
   /*                                                                       */
-  static void
-  Get_HMetrics( TT_Face     face,
-                FT_UInt     idx,
-                FT_Bool     check,
-                FT_Short*   lsb,
-                FT_UShort*  aw )
+  FT_LOCAL_DEF(void)
+  TT_Get_HMetrics( TT_Face     face,
+                   FT_UInt     idx,
+                   FT_Bool     check,
+                   FT_Short*   lsb,
+                   FT_UShort*  aw )
   {
     ( (SFNT_Service)face->sfnt )->get_metrics( face, 0, idx, lsb, aw );
 
@@ -96,12 +96,12 @@
   /* The monospace `check' is probably not meaningful here, but we leave   */
   /* it in for a consistent interface.                                     */
   /*                                                                       */
-  static void
-  Get_VMetrics( TT_Face     face,
-                FT_UInt     idx,
-                FT_Bool     check,
-                FT_Short*   tsb,
-                FT_UShort*  ah )
+  FT_LOCAL_DEF(void)
+  TT_Get_VMetrics( TT_Face     face,
+                   FT_UInt     idx,
+                   FT_Bool     check,
+                   FT_Short*   tsb,
+                   FT_UShort*  ah )
   {
     FT_UNUSED( check );
 
@@ -1143,16 +1143,16 @@
       FT_UShort  advance_width = 0, advance_height = 0;
 
 
-      Get_HMetrics( face, glyph_index,
-                    (FT_Bool)!( loader->load_flags &
-                                FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ),
-                    &left_bearing,
-                    &advance_width );
-      Get_VMetrics( face, glyph_index,
-                    (FT_Bool)!( loader->load_flags &
-                                FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ),
-                    &top_bearing,
-                    &advance_height );
+      TT_Get_HMetrics( face, glyph_index,
+                       (FT_Bool)!( loader->load_flags &
+                                   FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ),
+                       &left_bearing,
+                       &advance_width );
+      TT_Get_VMetrics( face, glyph_index,
+                       (FT_Bool)!( loader->load_flags &
+                                   FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ),
+                       &top_bearing,
+                       &advance_height );
 
 #ifdef FT_CONFIG_OPTION_INCREMENTAL
 
diff --git a/src/truetype/ttgload.h b/src/truetype/ttgload.h
index b261e97..313bb14 100644
--- a/src/truetype/ttgload.h
+++ b/src/truetype/ttgload.h
@@ -34,6 +34,20 @@ FT_BEGIN_HEADER
   FT_LOCAL( void )
   TT_Init_Glyph_Loading( TT_Face  face );
 
+  FT_LOCAL(void)
+  TT_Get_HMetrics( TT_Face     face,
+                   FT_UInt     idx,
+                   FT_Bool     check,
+                   FT_Short*   lsb,
+                   FT_UShort*  aw );
+
+  FT_LOCAL(void)
+  TT_Get_VMetrics( TT_Face     face,
+                   FT_UInt     idx,
+                   FT_Bool     check,
+                   FT_Short*   tsb,
+                   FT_UShort*  ah );
+
   FT_LOCAL( FT_Error )
   TT_Load_Glyph( TT_Size       size,
                  TT_GlyphSlot  glyph,
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index 3ca21dc..42302e5 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -304,7 +304,7 @@
     (FT_Face_GetKerningFunc)  Get_Kerning,
     (FT_Face_AttachFunc)      T1_Read_Metrics,
 #endif
-    (FT_Face_GetAdvancesFunc) 0,
+    (FT_Face_GetAdvancesFunc) T1_Get_Advances,
     (FT_Size_RequestFunc)     T1_Size_Request,
     (FT_Size_SelectFunc)      0
   };
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index e08a428..6d7420c 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -203,6 +203,63 @@
 
 
   FT_LOCAL_DEF( FT_Error )
+  T1_Get_Advances( T1_Face    face,
+                   FT_UInt    first,
+                   FT_UInt    count,
+                   FT_ULong   load_flags,
+                   FT_Fixed*  advances )
+  {
+    T1_DecoderRec  decoder;
+    T1_Font        type1 = &face->type1;
+    PSAux_Service  psaux = (PSAux_Service)face->psaux;
+    FT_UInt        nn;
+    FT_Error       error;
+
+    if (load_flags & FT_LOAD_VERTICAL_LAYOUT)
+    {
+        for (nn = 0; nn < count; nn++)
+            advances[nn] = 0;
+
+        return T1_Err_Ok;
+    }
+
+    error = psaux->t1_decoder_funcs->init( &decoder,
+                                           (FT_Face)face,
+                                           0, /* size       */
+                                           0, /* glyph slot */
+                                           (FT_Byte**)type1->glyph_names,
+                                           face->blend,
+                                           0,
+                                           FT_RENDER_MODE_NORMAL,
+                                           T1_Parse_Glyph );
+    if ( error )
+      return error;
+
+    FT_UNUSED(load_flags);
+
+    decoder.builder.metrics_only = 1;
+    decoder.builder.load_points  = 0;
+
+    decoder.num_subrs     = type1->num_subrs;
+    decoder.subrs         = type1->subrs;
+    decoder.subrs_len     = type1->subrs_len;
+
+    decoder.buildchar     = face->buildchar;
+    decoder.len_buildchar = face->len_buildchar;
+
+    for ( nn = 0; nn < count; nn++ )
+    {
+      error = T1_Parse_Glyph( &decoder, first + nn );
+      if (!error)
+        advances[nn] = decoder.builder.advance.x;
+      else
+        advances[nn] = 0;
+    }
+    return T1_Err_Ok;
+  }
+
+
+  FT_LOCAL_DEF( FT_Error )
   T1_Load_Glyph( T1_GlyphSlot  glyph,
                  T1_Size       size,
                  FT_UInt       glyph_index,
diff --git a/src/type1/t1gload.h b/src/type1/t1gload.h
index de87896..1638db8 100644
--- a/src/type1/t1gload.h
+++ b/src/type1/t1gload.h
@@ -32,6 +32,13 @@ FT_BEGIN_HEADER
                           FT_Pos*  max_advance );
 
   FT_LOCAL( FT_Error )
+  T1_Get_Advances( T1_Face    face,
+                   FT_UInt    first,
+                   FT_UInt    count,
+                   FT_ULong   load_flags,
+                   FT_Fixed*  advances );
+
+  FT_LOCAL( FT_Error )
   T1_Load_Glyph( T1_GlyphSlot  glyph,
                  T1_Size       size,
                  FT_UInt       glyph_index,