Commit cb8ede4dca7e9cd1b43d2955f9199a79634c7f79

Werner Lemberg 2003-12-27T21:44:18

* include/freetype/internal/sfnt.h (TT_Set_SBit_Strike_Func): Use FT_UInt for ppem values. * src/sfnt/ttsbit.c (tt_face_set_sbit_strike): Use FT_UInt for ppem values. * src/sfnt/ttsbit.h: Updated. * src/base/ftobjs.c (FT_Set_Pixel_Sizes): Don't allow ppem values larger than -0FFFF.

diff --git a/ChangeLog b/ChangeLog
index 8cf5a1b..7d37368 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2003-12-26  Werner Lemberg  <wl@gnu.org>
+
+	* include/freetype/internal/sfnt.h (TT_Set_SBit_Strike_Func):
+	Use FT_UInt for ppem values.
+	* src/sfnt/ttsbit.c (tt_face_set_sbit_strike): Use FT_UInt for
+	ppem values.
+	* src/sfnt/ttsbit.h: Updated.
+
+	* src/base/ftobjs.c (FT_Set_Pixel_Sizes): Don't allow ppem values
+	larger than -0FFFF.
+
 2003-12-25  Werner Lemberg  <wl@gnu.org>
 
 	* src/base/fttrigon.c, src/base/ftgloadr.c: Inlude
diff --git a/include/freetype/internal/sfnt.h b/include/freetype/internal/sfnt.h
index 8c4d93b..2a9a645 100644
--- a/include/freetype/internal/sfnt.h
+++ b/include/freetype/internal/sfnt.h
@@ -250,20 +250,27 @@ FT_BEGIN_HEADER
   /*    returns its metrics.                                               */
   /*                                                                       */
   /* <Input>                                                               */
-  /*    face        :: The target face object.                             */
+  /*    face ::                                                            */
+  /*      The target face object.                                          */
   /*                                                                       */
-  /*    x_ppem      :: The horizontal resolution in points per EM.         */
+  /*    strike_index ::                                                    */
+  /*      The strike index.                                                */
   /*                                                                       */
-  /*    y_ppem      :: The vertical resolution in points per EM.           */
+  /*    glyph_index ::                                                     */
+  /*      The current glyph index.                                         */
   /*                                                                       */
-  /*    glyph_index :: The current glyph index.                            */
+  /*    load_flags ::                                                      */
+  /*      The current load flags.                                          */
   /*                                                                       */
-  /*    stream      :: The input stream.                                   */
+  /*    stream ::                                                          */
+  /*      The input stream.                                                */
   /*                                                                       */
   /* <Output>                                                              */
-  /*    amap        :: The target pixmap.                                  */
+  /*    amap ::                                                            */
+  /*      The target pixmap.                                               */
   /*                                                                       */
-  /*    ametrics    :: A big sbit metrics structure for the glyph image.   */
+  /*    ametrics ::                                                        */
+  /*      A big sbit metrics structure for the glyph image.                */
   /*                                                                       */
   /* <Return>                                                              */
   /*    FreeType error code.  0 means success.  Returns an error if no     */
@@ -307,8 +314,8 @@ FT_BEGIN_HEADER
   /*                                                                       */
   typedef FT_Error
   (*TT_Set_SBit_Strike_Func)( TT_Face    face,
-                              FT_Int     x_ppem,
-                              FT_Int     y_ppem,
+                              FT_UInt    x_ppem,
+                              FT_UInt    y_ppem,
                               FT_ULong  *astrike_index );
 
 
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index a7eda7a..8e02377 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -2080,7 +2080,6 @@
     metrics = &face->size->metrics;
     clazz   = driver->clazz;
 
-    /* default processing -- this can be overridden by the driver */
     if ( pixel_width == 0 )
       pixel_width = pixel_height;
 
@@ -2092,6 +2091,12 @@
     if ( pixel_height < 1 )
       pixel_height = 1;
 
+    /* use `>=' to avoid potention compiler warning on 16bit platforms */
+    if ( pixel_width  >= 0xFFFFU )
+      pixel_width  = 0xFFFFU;
+    if ( pixel_height >= 0xFFFFU )
+      pixel_height = 0xFFFFU;
+
     metrics->x_ppem = (FT_UShort)pixel_width;
     metrics->y_ppem = (FT_UShort)pixel_height;
 
diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c
index d4c16b1..4b4fd90 100644
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -622,14 +622,14 @@
 
   FT_LOCAL_DEF( FT_Error )
   tt_face_set_sbit_strike( TT_Face    face,
-                           FT_Int     x_ppem,
-                           FT_Int     y_ppem,
+                           FT_UInt    x_ppem,
+                           FT_UInt    y_ppem,
                            FT_ULong  *astrike_index )
   {
     FT_ULong  i;
 
 
-    if ( x_ppem < 0 || x_ppem > 255 ||
+    if ( x_ppem > 255 ||
          y_ppem < 1 || y_ppem > 255 )
       return SFNT_Err_Invalid_PPem;
 
diff --git a/src/sfnt/ttsbit.h b/src/sfnt/ttsbit.h
index edc858a..89499bb 100644
--- a/src/sfnt/ttsbit.h
+++ b/src/sfnt/ttsbit.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    TrueType and OpenType embedded bitmap support (specification).       */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002 by                                           */
+/*  Copyright 1996-2001, 2002, 2003 by                                     */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -37,8 +37,8 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( FT_Error )
   tt_face_set_sbit_strike( TT_Face    face,
-                           FT_Int     x_ppem,
-                           FT_Int     y_ppem,
+                           FT_UInt    x_ppem,
+                           FT_UInt    y_ppem,
                            FT_ULong  *astrike_index );
 
   FT_LOCAL( FT_Error )