1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/layout/AnchorTables.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,105 @@
1.4 +/*
1.5 + *
1.6 + * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
1.7 + *
1.8 + */
1.9 +
1.10 +#include "LETypes.h"
1.11 +#include "LEFontInstance.h"
1.12 +#include "DeviceTables.h"
1.13 +#include "AnchorTables.h"
1.14 +#include "LESwaps.h"
1.15 +
1.16 +U_NAMESPACE_BEGIN
1.17 +
1.18 +void AnchorTable::getAnchor(LEGlyphID glyphID, const LEFontInstance *fontInstance,
1.19 + LEPoint &anchor) const
1.20 +{
1.21 + switch(SWAPW(anchorFormat)) {
1.22 + case 1:
1.23 + {
1.24 + const Format1AnchorTable *f1 = (const Format1AnchorTable *) this;
1.25 +
1.26 + f1->getAnchor(fontInstance, anchor);
1.27 + break;
1.28 + }
1.29 +
1.30 + case 2:
1.31 + {
1.32 + const Format2AnchorTable *f2 = (const Format2AnchorTable *) this;
1.33 +
1.34 + f2->getAnchor(glyphID, fontInstance, anchor);
1.35 + break;
1.36 + }
1.37 +
1.38 + case 3:
1.39 + {
1.40 + const Format3AnchorTable *f3 = (const Format3AnchorTable *) this;
1.41 +
1.42 + f3->getAnchor(fontInstance, anchor);
1.43 + break;
1.44 + }
1.45 +
1.46 + default:
1.47 + // Unknown format, set the anchor point to (0, 0)
1.48 + anchor.fX = 0;
1.49 + anchor.fY = 0;
1.50 + break;
1.51 + }
1.52 +}
1.53 +
1.54 +void Format1AnchorTable::getAnchor(const LEFontInstance *fontInstance, LEPoint &anchor) const
1.55 +{
1.56 + le_int16 x = SWAPW(xCoordinate);
1.57 + le_int16 y = SWAPW(yCoordinate);
1.58 + LEPoint pixels;
1.59 +
1.60 + fontInstance->transformFunits(x, y, pixels);
1.61 +
1.62 + fontInstance->pixelsToUnits(pixels, anchor);
1.63 +}
1.64 +
1.65 +void Format2AnchorTable::getAnchor(LEGlyphID glyphID, const LEFontInstance *fontInstance, LEPoint &anchor) const
1.66 +{
1.67 + LEPoint point;
1.68 +
1.69 + if (! fontInstance->getGlyphPoint(glyphID, SWAPW(anchorPoint), point)) {
1.70 + le_int16 x = SWAPW(xCoordinate);
1.71 + le_int16 y = SWAPW(yCoordinate);
1.72 +
1.73 + fontInstance->transformFunits(x, y, point);
1.74 + }
1.75 +
1.76 +
1.77 + fontInstance->pixelsToUnits(point, anchor);
1.78 +}
1.79 +
1.80 +void Format3AnchorTable::getAnchor(const LEFontInstance *fontInstance, LEPoint &anchor) const
1.81 +{
1.82 + le_int16 x = SWAPW(xCoordinate);
1.83 + le_int16 y = SWAPW(yCoordinate);
1.84 + LEPoint pixels;
1.85 + Offset dtxOffset = SWAPW(xDeviceTableOffset);
1.86 + Offset dtyOffset = SWAPW(yDeviceTableOffset);
1.87 +
1.88 + fontInstance->transformFunits(x, y, pixels);
1.89 +
1.90 + if (dtxOffset != 0) {
1.91 + const DeviceTable *dtx = (const DeviceTable *) ((char *) this + dtxOffset);
1.92 + le_int16 adjx = dtx->getAdjustment((le_int16) fontInstance->getXPixelsPerEm());
1.93 +
1.94 + pixels.fX += adjx;
1.95 + }
1.96 +
1.97 + if (dtyOffset != 0) {
1.98 + const DeviceTable *dty = (const DeviceTable *) ((char *) this + dtyOffset);
1.99 + le_int16 adjy = dty->getAdjustment((le_int16) fontInstance->getYPixelsPerEm());
1.100 +
1.101 + pixels.fY += adjy;
1.102 + }
1.103 +
1.104 + fontInstance->pixelsToUnits(pixels, anchor);
1.105 +}
1.106 +
1.107 +U_NAMESPACE_END
1.108 +