Update contrib.
3 * (C) Copyright IBM Corp. 1998-2004 - 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, set the anchor point to (0, 0)
51 void Format1AnchorTable::getAnchor(const LEFontInstance *fontInstance, LEPoint &anchor) const
53 le_int16 x = SWAPW(xCoordinate);
54 le_int16 y = SWAPW(yCoordinate);
57 fontInstance->transformFunits(x, y, pixels);
59 fontInstance->pixelsToUnits(pixels, anchor);
62 void Format2AnchorTable::getAnchor(LEGlyphID glyphID, const LEFontInstance *fontInstance, LEPoint &anchor) const
66 if (! fontInstance->getGlyphPoint(glyphID, SWAPW(anchorPoint), point)) {
67 le_int16 x = SWAPW(xCoordinate);
68 le_int16 y = SWAPW(yCoordinate);
70 fontInstance->transformFunits(x, y, point);
74 fontInstance->pixelsToUnits(point, anchor);
77 void Format3AnchorTable::getAnchor(const LEFontInstance *fontInstance, LEPoint &anchor) const
79 le_int16 x = SWAPW(xCoordinate);
80 le_int16 y = SWAPW(yCoordinate);
82 Offset dtxOffset = SWAPW(xDeviceTableOffset);
83 Offset dtyOffset = SWAPW(yDeviceTableOffset);
85 fontInstance->transformFunits(x, y, pixels);
88 const DeviceTable *dtx = (const DeviceTable *) ((char *) this + dtxOffset);
89 le_int16 adjx = dtx->getAdjustment((le_int16) fontInstance->getXPixelsPerEm());
95 const DeviceTable *dty = (const DeviceTable *) ((char *) this + dtyOffset);
96 le_int16 adjy = dty->getAdjustment((le_int16) fontInstance->getYPixelsPerEm());
101 fontInstance->pixelsToUnits(pixels, anchor);