]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/layout/ValueRecords.cpp
ICU-8.11.tar.gz
[apple/icu.git] / icuSources / layout / ValueRecords.cpp
index 4a42c91a4cc2bcd5d39b975e6880823811a679e5..6731ea4b2dcf213d876e6e4e6036a3ff568d97f7 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *
- * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
  *
  */
 
@@ -10,7 +10,6 @@
 #include "ValueRecords.h"
 #include "DeviceTables.h"
 #include "GlyphIterator.h"
-#include "GlyphPositionAdjustments.h"
 #include "LESwaps.h"
 
 U_NAMESPACE_BEGIN
@@ -35,17 +34,22 @@ le_int16 ValueRecord::getFieldValue(le_int16 index, ValueFormat valueFormat, Val
     return SWAPW(value);
 }
 
-void ValueRecord::adjustPosition(ValueFormat valueFormat, const char *base, GlyphPositionAdjustment &positionAdjustment,
+void ValueRecord::adjustPosition(ValueFormat valueFormat, const char *base, GlyphIterator &glyphIterator,
                                  const LEFontInstance *fontInstance) const
 {
+    float xPlacementAdjustment = 0;
+    float yPlacementAdjustment = 0;
+    float xAdvanceAdjustment   = 0;
+    float yAdvanceAdjustment   = 0;
+
     if ((valueFormat & vfbXPlacement) != 0) {
         le_int16 value = getFieldValue(valueFormat, vrfXPlacement);
         LEPoint pixels;
 
         fontInstance->transformFunits(value, 0, pixels);
 
-        positionAdjustment.adjustXPlacement(fontInstance->xPixelsToUnits(pixels.fX));
-        positionAdjustment.adjustYPlacement(fontInstance->yPixelsToUnits(pixels.fY));
+        xPlacementAdjustment += fontInstance->xPixelsToUnits(pixels.fX);
+        yPlacementAdjustment += fontInstance->yPixelsToUnits(pixels.fY);
     }
 
     if ((valueFormat & vfbYPlacement) != 0) {
@@ -54,8 +58,8 @@ void ValueRecord::adjustPosition(ValueFormat valueFormat, const char *base, Glyp
 
         fontInstance->transformFunits(0, value, pixels);
 
-        positionAdjustment.adjustXPlacement(fontInstance->xPixelsToUnits(pixels.fX));
-        positionAdjustment.adjustYPlacement(fontInstance->yPixelsToUnits(pixels.fY));
+        xPlacementAdjustment += fontInstance->xPixelsToUnits(pixels.fX);
+        yPlacementAdjustment += fontInstance->yPixelsToUnits(pixels.fY);
     }
 
     if ((valueFormat & vfbXAdvance) != 0) {
@@ -64,8 +68,8 @@ void ValueRecord::adjustPosition(ValueFormat valueFormat, const char *base, Glyp
 
         fontInstance->transformFunits(value, 0, pixels);
 
-        positionAdjustment.adjustXAdvance(fontInstance->xPixelsToUnits(pixels.fX));
-        positionAdjustment.adjustYAdvance(fontInstance->yPixelsToUnits(pixels.fY));
+        xAdvanceAdjustment += fontInstance->xPixelsToUnits(pixels.fX);
+        yAdvanceAdjustment += fontInstance->yPixelsToUnits(pixels.fY);
     }
 
     if ((valueFormat & vfbYAdvance) != 0) {
@@ -74,8 +78,8 @@ void ValueRecord::adjustPosition(ValueFormat valueFormat, const char *base, Glyp
 
         fontInstance->transformFunits(0, value, pixels);
 
-        positionAdjustment.adjustXAdvance(fontInstance->xPixelsToUnits(pixels.fX));
-        positionAdjustment.adjustYAdvance(fontInstance->yPixelsToUnits(pixels.fY));
+        xAdvanceAdjustment += fontInstance->xPixelsToUnits(pixels.fX);
+        yAdvanceAdjustment += fontInstance->yPixelsToUnits(pixels.fY);
     }
 
     // FIXME: The device adjustments should really be transformed, but
@@ -92,7 +96,7 @@ void ValueRecord::adjustPosition(ValueFormat valueFormat, const char *base, Glyp
                 const DeviceTable *dt = (const DeviceTable *) (base + dtOffset);
                 le_int16 xAdj = dt->getAdjustment(xppem);
 
-                positionAdjustment.adjustXPlacement(fontInstance->xPixelsToUnits(xAdj));
+                xPlacementAdjustment += fontInstance->xPixelsToUnits(xAdj);
             }
         }
 
@@ -103,7 +107,7 @@ void ValueRecord::adjustPosition(ValueFormat valueFormat, const char *base, Glyp
                 const DeviceTable *dt = (const DeviceTable *) (base + dtOffset);
                 le_int16 yAdj = dt->getAdjustment(yppem);
 
-                positionAdjustment.adjustYPlacement(fontInstance->yPixelsToUnits(yAdj));
+                yPlacementAdjustment += fontInstance->yPixelsToUnits(yAdj);
             }
         }
 
@@ -114,7 +118,7 @@ void ValueRecord::adjustPosition(ValueFormat valueFormat, const char *base, Glyp
                 const DeviceTable *dt = (const DeviceTable *) (base + dtOffset);
                 le_int16 xAdj = dt->getAdjustment(xppem);
 
-                positionAdjustment.adjustXAdvance(fontInstance->xPixelsToUnits(xAdj));
+                xAdvanceAdjustment += fontInstance->xPixelsToUnits(xAdj);
             }
         }
 
@@ -125,23 +129,31 @@ void ValueRecord::adjustPosition(ValueFormat valueFormat, const char *base, Glyp
                 const DeviceTable *dt = (const DeviceTable *) (base + dtOffset);
                 le_int16 yAdj = dt->getAdjustment(yppem);
 
-                positionAdjustment.adjustYAdvance(fontInstance->yPixelsToUnits(yAdj));
+                yAdvanceAdjustment += fontInstance->yPixelsToUnits(yAdj);
             }
         }
     }
+
+    glyphIterator.adjustCurrGlyphPositionAdjustment(
+        xPlacementAdjustment, yPlacementAdjustment, xAdvanceAdjustment, yAdvanceAdjustment);
 }
 
-void ValueRecord::adjustPosition(le_int16 index, ValueFormat valueFormat, const char *base, GlyphPositionAdjustment &positionAdjustment,
+void ValueRecord::adjustPosition(le_int16 index, ValueFormat valueFormat, const char *base, GlyphIterator &glyphIterator,
                                  const LEFontInstance *fontInstance) const
 {
+    float xPlacementAdjustment = 0;
+    float yPlacementAdjustment = 0;
+    float xAdvanceAdjustment   = 0;
+    float yAdvanceAdjustment   = 0;
+
     if ((valueFormat & vfbXPlacement) != 0) {
         le_int16 value = getFieldValue(index, valueFormat, vrfXPlacement);
         LEPoint pixels;
 
         fontInstance->transformFunits(value, 0, pixels);
 
-        positionAdjustment.adjustXPlacement(fontInstance->xPixelsToUnits(pixels.fX));
-        positionAdjustment.adjustYPlacement(fontInstance->yPixelsToUnits(pixels.fY));
+        xPlacementAdjustment += fontInstance->xPixelsToUnits(pixels.fX);
+        yPlacementAdjustment += fontInstance->yPixelsToUnits(pixels.fY);
     }
 
     if ((valueFormat & vfbYPlacement) != 0) {
@@ -150,8 +162,8 @@ void ValueRecord::adjustPosition(le_int16 index, ValueFormat valueFormat, const
 
         fontInstance->transformFunits(0, value, pixels);
 
-        positionAdjustment.adjustXPlacement(fontInstance->xPixelsToUnits(pixels.fX));
-        positionAdjustment.adjustYPlacement(fontInstance->yPixelsToUnits(pixels.fY));
+        xPlacementAdjustment += fontInstance->xPixelsToUnits(pixels.fX);
+        yPlacementAdjustment += fontInstance->yPixelsToUnits(pixels.fY);
     }
 
     if ((valueFormat & vfbXAdvance) != 0) {
@@ -160,8 +172,8 @@ void ValueRecord::adjustPosition(le_int16 index, ValueFormat valueFormat, const
 
         fontInstance->transformFunits(value, 0, pixels);
 
-        positionAdjustment.adjustXAdvance(fontInstance->xPixelsToUnits(pixels.fX));
-        positionAdjustment.adjustYAdvance(fontInstance->yPixelsToUnits(pixels.fY));
+        xAdvanceAdjustment += fontInstance->xPixelsToUnits(pixels.fX);
+        yAdvanceAdjustment += fontInstance->yPixelsToUnits(pixels.fY);
     }
 
     if ((valueFormat & vfbYAdvance) != 0) {
@@ -170,8 +182,8 @@ void ValueRecord::adjustPosition(le_int16 index, ValueFormat valueFormat, const
 
         fontInstance->transformFunits(0, value, pixels);
 
-        positionAdjustment.adjustXAdvance(fontInstance->xPixelsToUnits(pixels.fX));
-        positionAdjustment.adjustYAdvance(fontInstance->yPixelsToUnits(pixels.fY));
+        xAdvanceAdjustment += fontInstance->xPixelsToUnits(pixels.fX);
+        yAdvanceAdjustment += fontInstance->yPixelsToUnits(pixels.fY);
     }
 
     // FIXME: The device adjustments should really be transformed, but
@@ -188,7 +200,7 @@ void ValueRecord::adjustPosition(le_int16 index, ValueFormat valueFormat, const
                 const DeviceTable *dt = (const DeviceTable *) (base + dtOffset);
                 le_int16 xAdj = dt->getAdjustment(xppem);
 
-                positionAdjustment.adjustXAdvance(fontInstance->xPixelsToUnits(xAdj));
+                xPlacementAdjustment += fontInstance->xPixelsToUnits(xAdj);
             }
         }
 
@@ -199,7 +211,7 @@ void ValueRecord::adjustPosition(le_int16 index, ValueFormat valueFormat, const
                 const DeviceTable *dt = (const DeviceTable *) (base + dtOffset);
                 le_int16 yAdj = dt->getAdjustment(yppem);
 
-                positionAdjustment.adjustYAdvance(fontInstance->yPixelsToUnits(yAdj));
+                yPlacementAdjustment += fontInstance->yPixelsToUnits(yAdj);
             }
         }
 
@@ -210,7 +222,7 @@ void ValueRecord::adjustPosition(le_int16 index, ValueFormat valueFormat, const
                 const DeviceTable *dt = (const DeviceTable *) (base + dtOffset);
                 le_int16 xAdj = dt->getAdjustment(xppem);
 
-                positionAdjustment.adjustXAdvance(fontInstance->xPixelsToUnits(xAdj));
+                xAdvanceAdjustment += fontInstance->xPixelsToUnits(xAdj);
             }
         }
 
@@ -221,10 +233,13 @@ void ValueRecord::adjustPosition(le_int16 index, ValueFormat valueFormat, const
                 const DeviceTable *dt = (const DeviceTable *) (base + dtOffset);
                 le_int16 yAdj = dt->getAdjustment(yppem);
 
-                positionAdjustment.adjustYAdvance(fontInstance->yPixelsToUnits(yAdj));
+                yAdvanceAdjustment += fontInstance->yPixelsToUnits(yAdj);
             }
         }
     }
+
+    glyphIterator.adjustCurrGlyphPositionAdjustment(
+        xPlacementAdjustment, yPlacementAdjustment, xAdvanceAdjustment, yAdvanceAdjustment);
 }
 
 le_int16 ValueRecord::getSize(ValueFormat valueFormat)