jdk/src/share/native/sun/font/layout/AnchorTables.cpp
changeset 22330 cafb826672bd
parent 5506 202f599c92aa
equal deleted inserted replaced
22329:4cd45450d07c 22330:cafb826672bd
    35 #include "AnchorTables.h"
    35 #include "AnchorTables.h"
    36 #include "LESwaps.h"
    36 #include "LESwaps.h"
    37 
    37 
    38 U_NAMESPACE_BEGIN
    38 U_NAMESPACE_BEGIN
    39 
    39 
    40 void AnchorTable::getAnchor(LEGlyphID glyphID, const LEFontInstance *fontInstance,
    40 void AnchorTable::getAnchor(const LETableReference &base, LEGlyphID glyphID, const LEFontInstance *fontInstance,
    41                             LEPoint &anchor) const
    41                             LEPoint &anchor, LEErrorCode &success) const
    42 {
    42 {
    43     switch(SWAPW(anchorFormat)) {
    43   switch(SWAPW(anchorFormat)) {
    44     case 1:
    44     case 1:
    45     {
    45     {
    46         const Format1AnchorTable *f1 = (const Format1AnchorTable *) this;
    46         LEReferenceTo<Format1AnchorTable> f1(base, success);
    47 
    47         f1->getAnchor(f1, fontInstance, anchor, success);
    48         f1->getAnchor(fontInstance, anchor);
       
    49         break;
    48         break;
    50     }
    49     }
    51 
    50 
    52     case 2:
    51     case 2:
    53     {
    52     {
    54         const Format2AnchorTable *f2 = (const Format2AnchorTable *) this;
    53         LEReferenceTo<Format2AnchorTable> f2(base, success);
    55 
    54         f2->getAnchor(f2, glyphID, fontInstance, anchor, success);
    56         f2->getAnchor(glyphID, fontInstance, anchor);
       
    57         break;
    55         break;
    58     }
    56     }
    59 
    57 
    60     case 3:
    58     case 3:
    61     {
    59     {
    62         const Format3AnchorTable *f3 = (const Format3AnchorTable *) this;
    60         LEReferenceTo<Format3AnchorTable> f3(base, success);
    63 
    61         f3->getAnchor(f3, fontInstance, anchor, success);
    64         f3->getAnchor(fontInstance, anchor);
       
    65         break;
    62         break;
    66     }
    63     }
    67 
    64 
    68     default:
    65     default:
       
    66     {
    69         // unknown format: just use x, y coordinate, like format 1...
    67         // unknown format: just use x, y coordinate, like format 1...
    70         const Format1AnchorTable *f1 = (const Format1AnchorTable *) this;
    68         LEReferenceTo<Format1AnchorTable> f1(base, success);
    71 
    69         f1->getAnchor(f1, fontInstance, anchor, success);
    72         f1->getAnchor(fontInstance, anchor);
       
    73         break;
    70         break;
    74     }
    71     }
       
    72   }
    75 }
    73 }
    76 
    74 
    77 void Format1AnchorTable::getAnchor(const LEFontInstance *fontInstance, LEPoint &anchor) const
    75 void Format1AnchorTable::getAnchor(const LEReferenceTo<Format1AnchorTable>& base, const LEFontInstance *fontInstance, LEPoint &anchor, LEErrorCode &success) const
    78 {
    76 {
    79     le_int16 x = SWAPW(xCoordinate);
    77     le_int16 x = SWAPW(xCoordinate);
    80     le_int16 y = SWAPW(yCoordinate);
    78     le_int16 y = SWAPW(yCoordinate);
    81     LEPoint pixels;
    79     LEPoint pixels;
    82 
    80 
    83     fontInstance->transformFunits(x, y, pixels);
    81     fontInstance->transformFunits(x, y, pixels);
    84 
       
    85     fontInstance->pixelsToUnits(pixels, anchor);
    82     fontInstance->pixelsToUnits(pixels, anchor);
    86 }
    83 }
    87 
    84 
    88 void Format2AnchorTable::getAnchor(LEGlyphID glyphID, const LEFontInstance *fontInstance, LEPoint &anchor) const
    85 void Format2AnchorTable::getAnchor(const LEReferenceTo<Format2AnchorTable>& base,
       
    86                                    LEGlyphID glyphID, const LEFontInstance *fontInstance, LEPoint &anchor
       
    87                                    , LEErrorCode &success) const
    89 {
    88 {
    90     LEPoint point;
    89     LEPoint point;
    91 
    90 
    92     if (! fontInstance->getGlyphPoint(glyphID, SWAPW(anchorPoint), point)) {
    91     if (! fontInstance->getGlyphPoint(glyphID, SWAPW(anchorPoint), point)) {
    93         le_int16 x = SWAPW(xCoordinate);
    92         le_int16 x = SWAPW(xCoordinate);
    98 
    97 
    99 
    98 
   100     fontInstance->pixelsToUnits(point, anchor);
    99     fontInstance->pixelsToUnits(point, anchor);
   101 }
   100 }
   102 
   101 
   103 void Format3AnchorTable::getAnchor(const LEFontInstance *fontInstance, LEPoint &anchor) const
   102 void Format3AnchorTable::getAnchor(const LEReferenceTo<Format3AnchorTable> &base, const LEFontInstance *fontInstance,
       
   103                                    LEPoint &anchor, LEErrorCode &success) const
   104 {
   104 {
   105     le_int16 x = SWAPW(xCoordinate);
   105     le_int16 x = SWAPW(xCoordinate);
   106     le_int16 y = SWAPW(yCoordinate);
   106     le_int16 y = SWAPW(yCoordinate);
   107     LEPoint pixels;
   107     LEPoint pixels;
   108     Offset dtxOffset = SWAPW(xDeviceTableOffset);
   108     Offset dtxOffset = SWAPW(xDeviceTableOffset);
   109     Offset dtyOffset = SWAPW(yDeviceTableOffset);
   109     Offset dtyOffset = SWAPW(yDeviceTableOffset);
   110 
   110 
   111     fontInstance->transformFunits(x, y, pixels);
   111     fontInstance->transformFunits(x, y, pixels);
   112 
   112 
   113     if (dtxOffset != 0) {
   113     if (dtxOffset != 0) {
   114         const DeviceTable *dtx = (const DeviceTable *) ((char *) this + dtxOffset);
   114         LEReferenceTo<DeviceTable> dt(base, success, dtxOffset);
   115         le_int16 adjx = dtx->getAdjustment((le_int16) fontInstance->getXPixelsPerEm());
   115         le_int16 adjx = dt->getAdjustment(dt, (le_int16) fontInstance->getXPixelsPerEm(), success);
   116 
   116 
   117         pixels.fX += adjx;
   117         pixels.fX += adjx;
   118     }
   118     }
   119 
   119 
   120     if (dtyOffset != 0) {
   120     if (dtyOffset != 0) {
   121         const DeviceTable *dty = (const DeviceTable *) ((char *) this + dtyOffset);
   121         LEReferenceTo<DeviceTable> dt(base, success, dtyOffset);
   122         le_int16 adjy = dty->getAdjustment((le_int16) fontInstance->getYPixelsPerEm());
   122         le_int16 adjy = dt->getAdjustment(dt, (le_int16) fontInstance->getYPixelsPerEm(), success);
   123 
   123 
   124         pixels.fY += adjy;
   124         pixels.fY += adjy;
   125     }
   125     }
   126 
   126 
   127     fontInstance->pixelsToUnits(pixels, anchor);
   127     fontInstance->pixelsToUnits(pixels, anchor);