0N/A/*
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A *
0N/A */
0N/A
0N/A/*
0N/A *
1693N/A *
0N/A * (C) Copyright IBM Corp. 1998 - 2005 - All Rights Reserved
0N/A *
0N/A */
0N/A
0N/A#include "LETypes.h"
0N/A#include "OpenTypeTables.h"
0N/A#include "DeviceTables.h"
0N/A#include "LESwaps.h"
0N/A
1693N/AU_NAMESPACE_BEGIN
1693N/A
0N/Aconst le_uint16 DeviceTable::fieldMasks[] = {0x0003, 0x000F, 0x00FF};
0N/Aconst le_uint16 DeviceTable::fieldSignBits[] = {0x0002, 0x0008, 0x0080};
0N/Aconst le_uint16 DeviceTable::fieldBits[] = { 2, 4, 8};
0N/A
3171N/A#define FORMAT_COUNT LE_ARRAY_SIZE(fieldBits)
3171N/A
0N/Ale_int16 DeviceTable::getAdjustment(le_uint16 ppem) const
0N/A{
0N/A le_uint16 start = SWAPW(startSize);
0N/A le_uint16 format = SWAPW(deltaFormat) - 1;
0N/A le_int16 result = 0;
0N/A
3171N/A if (ppem >= start && ppem <= SWAPW(endSize) && format < FORMAT_COUNT) {
0N/A le_uint16 sizeIndex = ppem - start;
0N/A le_uint16 bits = fieldBits[format];
0N/A le_uint16 count = 16 / bits;
0N/A le_uint16 word = SWAPW(deltaValues[sizeIndex / count]);
0N/A le_uint16 fieldIndex = sizeIndex % count;
0N/A le_uint16 shift = 16 - (bits * (fieldIndex + 1));
0N/A le_uint16 field = (word >> shift) & fieldMasks[format];
0N/A
0N/A result = field;
0N/A
0N/A if ((field & fieldSignBits[format]) != 0) {
0N/A result |= ~ fieldMasks[format];
0N/A }
0N/A }
0N/A
0N/A return result;
0N/A}
1693N/A
1693N/AU_NAMESPACE_END