3 * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
8 #include "LEFontInstance.h"
9 #include "DeviceTables.h"
10 #include "AnchorTables.h"
15 void AnchorTable::getAnchor(LEGlyphID glyphID, const LEFontInstance *fontInstance,
16 LEPoint &anchor) const
18 switch(SWAPW(anchorFormat)) {
21 const Format1AnchorTable *f1 = (const Format1AnchorTable *) this;
23 f1->getAnchor(fontInstance, anchor);
29 const Format2AnchorTable *f2 = (const Format2AnchorTable *) this;
31 f2->getAnchor(glyphID, fontInstance, anchor);
37 const Format3AnchorTable *f3 = (const Format3AnchorTable *) this;
39 f3->getAnchor(fontInstance, anchor);
44 // unknown format: just use x, y coordinate, like format 1...
45 const Format1AnchorTable *f1 = (const Format1AnchorTable *) this;
47 f1->getAnchor(fontInstance, anchor);
52 void Format1AnchorTable::getAnchor(const LEFontInstance *fontInstance, LEPoint &anchor) const
54 le_int16 x = SWAPW(xCoordinate);
55 le_int16 y = SWAPW(yCoordinate);
58 fontInstance->transformFunits(x, y, pixels);
60 fontInstance->pixelsToUnits(pixels, anchor);
63 void Format2AnchorTable::getAnchor(LEGlyphID glyphID, const LEFontInstance *fontInstance, LEPoint &anchor) const
67 if (! fontInstance->getGlyphPoint(glyphID, SWAPW(anchorPoint), point)) {
68 le_int16 x = SWAPW(xCoordinate);
69 le_int16 y = SWAPW(yCoordinate);
71 fontInstance->transformFunits(x, y, point);
75 fontInstance->pixelsToUnits(point, anchor);
78 void Format3AnchorTable::getAnchor(const LEFontInstance *fontInstance, LEPoint &anchor) const
80 le_int16 x = SWAPW(xCoordinate);
81 le_int16 y = SWAPW(yCoordinate);
83 Offset dtxOffset = SWAPW(xDeviceTableOffset);
84 Offset dtyOffset = SWAPW(yDeviceTableOffset);
86 fontInstance->transformFunits(x, y, pixels);
89 const DeviceTable *dtx = (const DeviceTable *) ((char *) this + dtxOffset);
90 le_int16 adjx = dtx->getAdjustment((le_int16) fontInstance->getXPixelsPerEm());
96 const DeviceTable *dty = (const DeviceTable *) ((char *) this + dtyOffset);
97 le_int16 adjy = dty->getAdjustment((le_int16) fontInstance->getYPixelsPerEm());
102 fontInstance->pixelsToUnits(pixels, anchor);