sl@0: /* sl@0: * sl@0: * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved sl@0: * sl@0: */ sl@0: sl@0: #include "LETypes.h" sl@0: #include "LEFontInstance.h" sl@0: #include "DeviceTables.h" sl@0: #include "AnchorTables.h" sl@0: #include "LESwaps.h" sl@0: sl@0: U_NAMESPACE_BEGIN sl@0: sl@0: void AnchorTable::getAnchor(LEGlyphID glyphID, const LEFontInstance *fontInstance, sl@0: LEPoint &anchor) const sl@0: { sl@0: switch(SWAPW(anchorFormat)) { sl@0: case 1: sl@0: { sl@0: const Format1AnchorTable *f1 = (const Format1AnchorTable *) this; sl@0: sl@0: f1->getAnchor(fontInstance, anchor); sl@0: break; sl@0: } sl@0: sl@0: case 2: sl@0: { sl@0: const Format2AnchorTable *f2 = (const Format2AnchorTable *) this; sl@0: sl@0: f2->getAnchor(glyphID, fontInstance, anchor); sl@0: break; sl@0: } sl@0: sl@0: case 3: sl@0: { sl@0: const Format3AnchorTable *f3 = (const Format3AnchorTable *) this; sl@0: sl@0: f3->getAnchor(fontInstance, anchor); sl@0: break; sl@0: } sl@0: sl@0: default: sl@0: // Unknown format, set the anchor point to (0, 0) sl@0: anchor.fX = 0; sl@0: anchor.fY = 0; sl@0: break; sl@0: } sl@0: } sl@0: sl@0: void Format1AnchorTable::getAnchor(const LEFontInstance *fontInstance, LEPoint &anchor) const sl@0: { sl@0: le_int16 x = SWAPW(xCoordinate); sl@0: le_int16 y = SWAPW(yCoordinate); sl@0: LEPoint pixels; sl@0: sl@0: fontInstance->transformFunits(x, y, pixels); sl@0: sl@0: fontInstance->pixelsToUnits(pixels, anchor); sl@0: } sl@0: sl@0: void Format2AnchorTable::getAnchor(LEGlyphID glyphID, const LEFontInstance *fontInstance, LEPoint &anchor) const sl@0: { sl@0: LEPoint point; sl@0: sl@0: if (! fontInstance->getGlyphPoint(glyphID, SWAPW(anchorPoint), point)) { sl@0: le_int16 x = SWAPW(xCoordinate); sl@0: le_int16 y = SWAPW(yCoordinate); sl@0: sl@0: fontInstance->transformFunits(x, y, point); sl@0: } sl@0: sl@0: sl@0: fontInstance->pixelsToUnits(point, anchor); sl@0: } sl@0: sl@0: void Format3AnchorTable::getAnchor(const LEFontInstance *fontInstance, LEPoint &anchor) const sl@0: { sl@0: le_int16 x = SWAPW(xCoordinate); sl@0: le_int16 y = SWAPW(yCoordinate); sl@0: LEPoint pixels; sl@0: Offset dtxOffset = SWAPW(xDeviceTableOffset); sl@0: Offset dtyOffset = SWAPW(yDeviceTableOffset); sl@0: sl@0: fontInstance->transformFunits(x, y, pixels); sl@0: sl@0: if (dtxOffset != 0) { sl@0: const DeviceTable *dtx = (const DeviceTable *) ((char *) this + dtxOffset); sl@0: le_int16 adjx = dtx->getAdjustment((le_int16) fontInstance->getXPixelsPerEm()); sl@0: sl@0: pixels.fX += adjx; sl@0: } sl@0: sl@0: if (dtyOffset != 0) { sl@0: const DeviceTable *dty = (const DeviceTable *) ((char *) this + dtyOffset); sl@0: le_int16 adjy = dty->getAdjustment((le_int16) fontInstance->getYPixelsPerEm()); sl@0: sl@0: pixels.fY += adjy; sl@0: } sl@0: sl@0: fontInstance->pixelsToUnits(pixels, anchor); sl@0: } sl@0: sl@0: U_NAMESPACE_END sl@0: