]> git.saurik.com Git - apple/icu.git/blame - icuSources/layout/ExtensionSubtables.cpp
ICU-551.24.tar.gz
[apple/icu.git] / icuSources / layout / ExtensionSubtables.cpp
CommitLineData
b75a7d8f
A
1/*
2 * %W% %E%
3 *
57a6839d 4 * (C) Copyright IBM Corp. 2008-2013 - All Rights Reserved
b75a7d8f
A
5 *
6 */
7
8#include "LETypes.h"
9#include "OpenTypeTables.h"
10#include "GlyphSubstitutionTables.h"
11#include "LookupProcessor.h"
12#include "ExtensionSubtables.h"
13#include "GlyphIterator.h"
14#include "LESwaps.h"
15
16U_NAMESPACE_BEGIN
17
729e4ab9 18// read a 32-bit value that might only be 16-bit-aligned in memory
4388f060
A
19static inline le_uint32 READ_LONG(le_uint32 code) {
20 le_uint16* first = ((le_uint16*)&code);
21 le_uint16* second = (((le_uint16*)&code) + 1);
22 return (le_uint32)((SWAPW(*first) << 16) + SWAPW(*second));
23}
b75a7d8f
A
24
25// FIXME: should look at the format too... maybe have a sub-class for it?
26le_uint32 ExtensionSubtable::process(const LookupProcessor *lookupProcessor, le_uint16 lookupType,
729e4ab9 27 GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode& success) const
b75a7d8f 28{
57a6839d
A
29 const LEReferenceTo<ExtensionSubtable> thisRef(lookupProcessor->getReference(), success); // create a reference to this
30
729e4ab9
A
31 if (LE_FAILURE(success)) {
32 return 0;
33 }
34
b75a7d8f
A
35 le_uint16 elt = SWAPW(extensionLookupType);
36
4388f060 37 if (elt != lookupType) {
729e4ab9 38 le_uint32 extOffset = READ_LONG(extensionOffset);
57a6839d 39 LEReferenceTo<LookupSubtable> subtable(thisRef, success, extOffset);
b75a7d8f 40
57a6839d
A
41 if(LE_SUCCESS(success)) {
42 return lookupProcessor->applySubtable(subtable, elt, glyphIterator, fontInstance, success);
43 }
b75a7d8f
A
44 }
45
46 return 0;
47}
48
49U_NAMESPACE_END