]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/layout/DeviceTables.cpp
ICU-59180.0.1.tar.gz
[apple/icu.git] / icuSources / layout / DeviceTables.cpp
index 34a08688da03e7f89449905b52d308628a72277d..0bbbf18149645e9ada955f6864eeed240701a685 100644 (file)
@@ -1,15 +1,13 @@
 /*
  * @(#)DeviceTables.cpp 1.5 00/03/15
  *
 /*
  * @(#)DeviceTables.cpp 1.5 00/03/15
  *
- * (C) Copyright IBM Corp. 1998, 1999, 2000, 2001 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1998 - 2006 - All Rights Reserved
  *
  */
 
 #include "LETypes.h"
 #include "OpenTypeTables.h"
 #include "DeviceTables.h"
  *
  */
 
 #include "LETypes.h"
 #include "OpenTypeTables.h"
 #include "DeviceTables.h"
-#include "GlyphIterator.h"
-#include "GlyphPositionAdjustments.h"
 #include "LESwaps.h"
 
 U_NAMESPACE_BEGIN
 #include "LESwaps.h"
 
 U_NAMESPACE_BEGIN
@@ -18,13 +16,15 @@ const le_uint16 DeviceTable::fieldMasks[]    = {0x0003, 0x000F, 0x00FF};
 const le_uint16 DeviceTable::fieldSignBits[] = {0x0002, 0x0008, 0x0080};
 const le_uint16 DeviceTable::fieldBits[]     = {     2,      4,      8};
 
 const le_uint16 DeviceTable::fieldSignBits[] = {0x0002, 0x0008, 0x0080};
 const le_uint16 DeviceTable::fieldBits[]     = {     2,      4,      8};
 
+#define FORMAT_COUNT LE_ARRAY_SIZE(fieldBits)
+
 le_int16 DeviceTable::getAdjustment(le_uint16 ppem) const
 {
     le_uint16 start = SWAPW(startSize);
     le_uint16 format = SWAPW(deltaFormat) - 1;
     le_int16 result = 0;
     
 le_int16 DeviceTable::getAdjustment(le_uint16 ppem) const
 {
     le_uint16 start = SWAPW(startSize);
     le_uint16 format = SWAPW(deltaFormat) - 1;
     le_int16 result = 0;
     
-    if (ppem >= start && ppem <= SWAPW(endSize)) {
+    if (ppem >= start && ppem <= SWAPW(endSize) && format < FORMAT_COUNT) {
         le_uint16 sizeIndex = ppem - start;
         le_uint16 bits = fieldBits[format];
         le_uint16 count = 16 / bits;
         le_uint16 sizeIndex = ppem - start;
         le_uint16 bits = fieldBits[format];
         le_uint16 count = 16 / bits;
@@ -36,7 +36,7 @@ le_int16 DeviceTable::getAdjustment(le_uint16 ppem) const
         result = field;
 
         if ((field & fieldSignBits[format]) != 0) {
         result = field;
 
         if ((field & fieldSignBits[format]) != 0) {
-            result |= ! fieldMasks[format];
+            result |= ~ fieldMasks[format];
         }
     }
 
         }
     }