Fix Savannah bug #25669.

* src/base/ftadvanc.h (FT_Get_Advances): Fix serious typo.

* src/base/ftobjs.c (FT_Select_Metrics, FT_Request_Metrics): Fix
scaling factor for non-scalable fonts.

* src/cff/cffdrivr.c (cff_get_advances): Use correct advance width
value to prevent incorrect scaling.

* docs/CHANGES: Document it.
diff --git a/ChangeLog b/ChangeLog
index 8a2ac39..70741603 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2009-02-23  Werner Lemberg  <wl@gnu.org>
+
+	Fix Savannah bug #25669.
+
+	* src/base/ftadvanc.h (FT_Get_Advances): Fix serious typo.
+
+	* src/base/ftobjs.c (FT_Select_Metrics, FT_Request_Metrics): Fix
+	scaling factor for non-scalable fonts.
+
+	* src/cff/cffdrivr.c (cff_get_advances): Use correct advance width
+	value to prevent incorrect scaling.
+
+	* docs/CHANGES: Document it.
+
 2009-02-15  Matt Godbolt  <matt@godbolt.org>
 
 	Fix Savannah bug #25588.
diff --git a/docs/CHANGES b/docs/CHANGES
index 4641bac..15ba669 100644
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -7,6 +7,9 @@
       FreeType2 is built without Carbon framework, these fonts are not
       handled correctly.  Version 2.3.7 didn't have this bug.
 
+    - `FT_Get_Advance' (and `FT_Get_Advances') returned bad values for
+      almost all font formats except TrueType fonts.
+
 
   II. IMPORTANT CHANGES
 
diff --git a/src/base/ftadvanc.c b/src/base/ftadvanc.c
index 2a30829..504f9d2 100644
--- a/src/base/ftadvanc.c
+++ b/src/base/ftadvanc.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Quick computation of advance widths (body).                          */
 /*                                                                         */
-/*  Copyright 2008 by                                                      */
+/*  Copyright 2008, 2009 by                                                */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -42,8 +42,8 @@
     else
       scale = face->size->metrics.x_scale;
 
-    /* this must be the same computation as to get linearHori/VertAdvance */
-    /* (see `FT_Load_Glyph' implementation in src/base/ftobjs.c           */
+    /* this must be the same scaling as to get linear{Hori,Vert}Advance */
+    /* (see `FT_Load_Glyph' implementation in src/base/ftobjs.c)        */
 
     for ( nn = 0; nn < count; nn++ )
       advances[nn] = FT_MulDiv( advances[nn], scale, 64 );
@@ -148,8 +148,8 @@
         break;
 
       padvances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT )
-                      ? face->glyph->advance.x
-                      : face->glyph->advance.y;
+                      ? face->glyph->advance.y
+                      : face->glyph->advance.x;
     }
 
     if ( error )
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 4b0aed8..89892df 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -2454,8 +2454,8 @@
     }
     else
     {
-      metrics->x_scale     = 1L << 22;
-      metrics->y_scale     = 1L << 22;
+      metrics->x_scale     = 1L << 16;
+      metrics->y_scale     = 1L << 16;
       metrics->ascender    = bsize->y_ppem;
       metrics->descender   = 0;
       metrics->height      = bsize->height << 6;
@@ -2566,8 +2566,8 @@
     else
     {
       FT_ZERO( metrics );
-      metrics->x_scale = 1L << 22;
-      metrics->y_scale = 1L << 22;
+      metrics->x_scale = 1L << 16;
+      metrics->y_scale = 1L << 16;
     }
   }
 
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 68b866a..a7f433a 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    OpenType font driver implementation (body).                          */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by       */
+/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -188,29 +188,28 @@
 
 
   FT_CALLBACK_DEF( FT_Error )
-  cff_get_advances( FT_Face    ftface,
+  cff_get_advances( FT_Face    face,
                     FT_UInt    start,
                     FT_UInt    count,
                     FT_Int32   flags,
                     FT_Fixed*  advances )
   {
-    CFF_Face      face = (CFF_Face)ftface;
     FT_UInt       nn;
     FT_Error      error = CFF_Err_Ok;
-    FT_GlyphSlot  slot  = face->root.glyph;
+    FT_GlyphSlot  slot  = face->glyph;
 
 
     flags |= FT_LOAD_ADVANCE_ONLY;
 
     for ( nn = 0; nn < count; nn++ )
     {
-      error = Load_Glyph( slot, face->root.size, start+nn, flags );
+      error = Load_Glyph( slot, face->size, start + nn, flags );
       if ( error )
         break;
 
       advances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT )
-                     ? slot->advance.y
-                     : slot->advance.x;
+                     ? slot->linearVertAdvance
+                     : slot->linearHoriAdvance;
     }
 
     return error;