jdk/src/share/native/sun/font/layout/ValueRecords.cpp
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 3935 afcdb712a9c5
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "LETypes.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "LEFontInstance.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "OpenTypeTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "ValueRecords.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include "DeviceTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include "GlyphIterator.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include "LESwaps.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#define Nibble(value, nibble) ((value >> (nibble * 4)) & 0xF)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#define NibbleBits(value, nibble) (bitsInNibble[Nibble(value, nibble)])
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
le_int16 ValueRecord::getFieldValue(ValueFormat valueFormat, ValueRecordField field) const
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    le_int16 valueIndex = getFieldIndex(valueFormat, field);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    le_int16 value = values[valueIndex];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    return SWAPW(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
le_int16 ValueRecord::getFieldValue(le_int16 index, ValueFormat valueFormat, ValueRecordField field) const
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    le_int16 baseIndex = getFieldCount(valueFormat) * index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    le_int16 valueIndex = getFieldIndex(valueFormat, field);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    le_int16 value = values[baseIndex + valueIndex];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    return SWAPW(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
void ValueRecord::adjustPosition(ValueFormat valueFormat, const char *base, GlyphIterator &glyphIterator,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
                                 const LEFontInstance *fontInstance) const
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    float xPlacementAdjustment = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    float yPlacementAdjustment = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    float xAdvanceAdjustment   = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    float yAdvanceAdjustment   = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    if ((valueFormat & vfbXPlacement) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        le_int16 value = getFieldValue(valueFormat, vrfXPlacement);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        LEPoint pixels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        fontInstance->transformFunits(value, 0, pixels);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        xPlacementAdjustment += fontInstance->xPixelsToUnits(pixels.fX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        yPlacementAdjustment += fontInstance->yPixelsToUnits(pixels.fY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    if ((valueFormat & vfbYPlacement) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        le_int16 value = getFieldValue(valueFormat, vrfYPlacement);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        LEPoint pixels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        fontInstance->transformFunits(0, value, pixels);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        xPlacementAdjustment += fontInstance->xPixelsToUnits(pixels.fX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        yPlacementAdjustment += fontInstance->yPixelsToUnits(pixels.fY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    if ((valueFormat & vfbXAdvance) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        le_int16 value = getFieldValue(valueFormat, vrfXAdvance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        LEPoint pixels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        fontInstance->transformFunits(value, 0, pixels);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        xAdvanceAdjustment += fontInstance->xPixelsToUnits(pixels.fX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        yAdvanceAdjustment += fontInstance->yPixelsToUnits(pixels.fY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    if ((valueFormat & vfbYAdvance) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        le_int16 value = getFieldValue(valueFormat, vrfYAdvance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        LEPoint pixels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        fontInstance->transformFunits(0, value, pixels);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        xAdvanceAdjustment += fontInstance->xPixelsToUnits(pixels.fX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        yAdvanceAdjustment += fontInstance->yPixelsToUnits(pixels.fY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    // FIXME: The device adjustments should really be transformed, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    // the only way I know how to do that is to convert them to le_int16 units,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    // transform them, and then convert them back to pixels. Sigh...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    if ((valueFormat & vfbAnyDevice) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        le_int16 xppem = (le_int16) fontInstance->getXPixelsPerEm();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        le_int16 yppem = (le_int16) fontInstance->getYPixelsPerEm();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        if ((valueFormat & vfbXPlaDevice) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            Offset dtOffset = getFieldValue(valueFormat, vrfXPlaDevice);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            if (dtOffset != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                const DeviceTable *dt = (const DeviceTable *) (base + dtOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                le_int16 xAdj = dt->getAdjustment(xppem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                xPlacementAdjustment += fontInstance->xPixelsToUnits(xAdj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        if ((valueFormat & vfbYPlaDevice) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            Offset dtOffset = getFieldValue(valueFormat, vrfYPlaDevice);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            if (dtOffset != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                const DeviceTable *dt = (const DeviceTable *) (base + dtOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                le_int16 yAdj = dt->getAdjustment(yppem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                yPlacementAdjustment += fontInstance->yPixelsToUnits(yAdj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        if ((valueFormat & vfbXAdvDevice) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            Offset dtOffset = getFieldValue(valueFormat, vrfXAdvDevice);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            if (dtOffset != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                const DeviceTable *dt = (const DeviceTable *) (base + dtOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                le_int16 xAdj = dt->getAdjustment(xppem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                xAdvanceAdjustment += fontInstance->xPixelsToUnits(xAdj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        if ((valueFormat & vfbYAdvDevice) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            Offset dtOffset = getFieldValue(valueFormat, vrfYAdvDevice);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            if (dtOffset != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                const DeviceTable *dt = (const DeviceTable *) (base + dtOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                le_int16 yAdj = dt->getAdjustment(yppem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                yAdvanceAdjustment += fontInstance->yPixelsToUnits(yAdj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    glyphIterator.adjustCurrGlyphPositionAdjustment(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        xPlacementAdjustment, yPlacementAdjustment, xAdvanceAdjustment, yAdvanceAdjustment);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
void ValueRecord::adjustPosition(le_int16 index, ValueFormat valueFormat, const char *base,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    GlyphIterator &glyphIterator, const LEFontInstance *fontInstance) const
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    float xPlacementAdjustment = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    float yPlacementAdjustment = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    float xAdvanceAdjustment   = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    float yAdvanceAdjustment   = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    if ((valueFormat & vfbXPlacement) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        le_int16 value = getFieldValue(index, valueFormat, vrfXPlacement);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        LEPoint pixels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        fontInstance->transformFunits(value, 0, pixels);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        xPlacementAdjustment += fontInstance->xPixelsToUnits(pixels.fX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        yPlacementAdjustment += fontInstance->yPixelsToUnits(pixels.fY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    if ((valueFormat & vfbYPlacement) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        le_int16 value = getFieldValue(index, valueFormat, vrfYPlacement);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        LEPoint pixels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        fontInstance->transformFunits(0, value, pixels);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        xPlacementAdjustment += fontInstance->xPixelsToUnits(pixels.fX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        yPlacementAdjustment += fontInstance->yPixelsToUnits(pixels.fY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    if ((valueFormat & vfbXAdvance) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        le_int16 value = getFieldValue(index, valueFormat, vrfXAdvance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        LEPoint pixels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        fontInstance->transformFunits(value, 0, pixels);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        xAdvanceAdjustment += fontInstance->xPixelsToUnits(pixels.fX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        yAdvanceAdjustment += fontInstance->yPixelsToUnits(pixels.fY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    if ((valueFormat & vfbYAdvance) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        le_int16 value = getFieldValue(index, valueFormat, vrfYAdvance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        LEPoint pixels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        fontInstance->transformFunits(0, value, pixels);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        xAdvanceAdjustment += fontInstance->xPixelsToUnits(pixels.fX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        yAdvanceAdjustment += fontInstance->yPixelsToUnits(pixels.fY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    // FIXME: The device adjustments should really be transformed, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    // the only way I know how to do that is to convert them to le_int16 units,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    // transform them, and then convert them back to pixels. Sigh...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    if ((valueFormat & vfbAnyDevice) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        le_int16 xppem = (le_int16) fontInstance->getXPixelsPerEm();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        le_int16 yppem = (le_int16) fontInstance->getYPixelsPerEm();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        if ((valueFormat & vfbXPlaDevice) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            Offset dtOffset = getFieldValue(index, valueFormat, vrfXPlaDevice);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            if (dtOffset != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                const DeviceTable *dt = (const DeviceTable *) (base + dtOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                le_int16 xAdj = dt->getAdjustment(xppem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                xPlacementAdjustment += fontInstance->xPixelsToUnits(xAdj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        if ((valueFormat & vfbYPlaDevice) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            Offset dtOffset = getFieldValue(index, valueFormat, vrfYPlaDevice);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            if (dtOffset != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                const DeviceTable *dt = (const DeviceTable *) (base + dtOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                le_int16 yAdj = dt->getAdjustment(yppem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                yPlacementAdjustment += fontInstance->yPixelsToUnits(yAdj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        if ((valueFormat & vfbXAdvDevice) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            Offset dtOffset = getFieldValue(index, valueFormat, vrfXAdvDevice);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            if (dtOffset != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                const DeviceTable *dt = (const DeviceTable *) (base + dtOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                le_int16 xAdj = dt->getAdjustment(xppem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                xAdvanceAdjustment += fontInstance->xPixelsToUnits(xAdj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        if ((valueFormat & vfbYAdvDevice) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            Offset dtOffset = getFieldValue(index, valueFormat, vrfYAdvDevice);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            if (dtOffset != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                const DeviceTable *dt = (const DeviceTable *) (base + dtOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                le_int16 yAdj = dt->getAdjustment(yppem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                yAdvanceAdjustment += fontInstance->yPixelsToUnits(yAdj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    glyphIterator.adjustCurrGlyphPositionAdjustment(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        xPlacementAdjustment, yPlacementAdjustment, xAdvanceAdjustment, yAdvanceAdjustment);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
le_int16 ValueRecord::getSize(ValueFormat valueFormat)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    return getFieldCount(valueFormat) * sizeof(le_int16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
le_int16 ValueRecord::getFieldCount(ValueFormat valueFormat)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    static const le_int16 bitsInNibble[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        0 + 0 + 0 + 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        0 + 0 + 0 + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        0 + 0 + 1 + 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        0 + 0 + 1 + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        0 + 1 + 0 + 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        0 + 1 + 0 + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        0 + 1 + 1 + 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        0 + 1 + 1 + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        1 + 0 + 0 + 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        1 + 0 + 0 + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        1 + 0 + 1 + 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        1 + 0 + 1 + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        1 + 1 + 0 + 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        1 + 1 + 0 + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        1 + 1 + 1 + 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        1 + 1 + 1 + 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    valueFormat &= ~vfbReserved;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    return NibbleBits(valueFormat, 0) + NibbleBits(valueFormat, 1) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
           NibbleBits(valueFormat, 2) + NibbleBits(valueFormat, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
le_int16 ValueRecord::getFieldIndex(ValueFormat valueFormat, ValueRecordField field)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    static const le_uint16 beforeMasks[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        0x0000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        0x0001,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        0x0003,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        0x0007,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        0x000F,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        0x001F,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        0x003F,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        0x007F,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        0x00FF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        0x01FF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        0x03FF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        0x07FF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        0x0FFF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        0x1FFF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        0x3FFF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        0x7FFF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        0xFFFF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    return getFieldCount(valueFormat & beforeMasks[field]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
}