os/textandloc/fontservices/textshaperplugin/IcuSource/layout/GlyphPosnLookupProc.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/layout/GlyphPosnLookupProc.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,151 @@
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 "OpenTypeTables.h"
1.13 +#include "Features.h"
1.14 +#include "Lookups.h"
1.15 +#include "ScriptAndLanguage.h"
1.16 +#include "GlyphDefinitionTables.h"
1.17 +#include "GlyphPositioningTables.h"
1.18 +#include "SinglePositioningSubtables.h"
1.19 +#include "PairPositioningSubtables.h"
1.20 +#include "CursiveAttachmentSubtables.h"
1.21 +#include "MarkToBasePosnSubtables.h"
1.22 +#include "MarkToLigaturePosnSubtables.h"
1.23 +#include "MarkToMarkPosnSubtables.h"
1.24 +//#include "ContextualPositioningSubtables.h"
1.25 +#include "ContextualSubstSubtables.h"
1.26 +#include "ExtensionSubtables.h"
1.27 +#include "LookupProcessor.h"
1.28 +#include "GlyphPosnLookupProc.h"
1.29 +#include "LESwaps.h"
1.30 +
1.31 +U_NAMESPACE_BEGIN
1.32 +
1.33 +// Aside from the names, the contextual positioning subtables are
1.34 +// the same as the contextual substitution subtables.
1.35 +typedef ContextualSubstitutionSubtable ContextualPositioningSubtable;
1.36 +typedef ChainingContextualSubstitutionSubtable ChainingContextualPositioningSubtable;
1.37 +
1.38 +GlyphPositioningLookupProcessor::GlyphPositioningLookupProcessor(
1.39 + const GlyphPositioningTableHeader *glyphPositioningTableHeader,
1.40 + LETag scriptTag, LETag languageTag, const LETag *featureOrder)
1.41 + : LookupProcessor(
1.42 + (char *) glyphPositioningTableHeader,
1.43 + SWAPW(glyphPositioningTableHeader->scriptListOffset),
1.44 + SWAPW(glyphPositioningTableHeader->featureListOffset),
1.45 + SWAPW(glyphPositioningTableHeader->lookupListOffset),
1.46 + scriptTag, languageTag, featureOrder)
1.47 +{
1.48 + // anything?
1.49 +}
1.50 +
1.51 +GlyphPositioningLookupProcessor::GlyphPositioningLookupProcessor()
1.52 +{
1.53 +}
1.54 +
1.55 +le_uint32 GlyphPositioningLookupProcessor::applySubtable(
1.56 + const LookupSubtable *lookupSubtable, le_uint16 lookupType,
1.57 + GlyphIterator *glyphIterator, const LEFontInstance *fontInstance,
1.58 + LEErrorCode& success) const
1.59 +{
1.60 + if (LE_FAILURE(success)) {
1.61 + return 0;
1.62 + }
1.63 +
1.64 + le_uint32 delta = 0;
1.65 +
1.66 + switch(lookupType)
1.67 + {
1.68 + case 0:
1.69 + break;
1.70 +
1.71 + case gpstSingle:
1.72 + {
1.73 + const SinglePositioningSubtable *subtable = (const SinglePositioningSubtable *) lookupSubtable;
1.74 +
1.75 + delta = subtable->process(glyphIterator, fontInstance);
1.76 + break;
1.77 + }
1.78 +
1.79 + case gpstPair:
1.80 + {
1.81 + const PairPositioningSubtable *subtable = (const PairPositioningSubtable *) lookupSubtable;
1.82 +
1.83 + delta = subtable->process(glyphIterator, fontInstance);
1.84 + break;
1.85 + }
1.86 +
1.87 + case gpstCursive:
1.88 + {
1.89 + const CursiveAttachmentSubtable *subtable = (const CursiveAttachmentSubtable *) lookupSubtable;
1.90 +
1.91 + delta = subtable->process(glyphIterator, fontInstance);
1.92 + break;
1.93 + }
1.94 +
1.95 + case gpstMarkToBase:
1.96 + {
1.97 + const MarkToBasePositioningSubtable *subtable = (const MarkToBasePositioningSubtable *) lookupSubtable;
1.98 +
1.99 + delta = subtable->process(glyphIterator, fontInstance);
1.100 + break;
1.101 + }
1.102 +
1.103 + case gpstMarkToLigature:
1.104 + {
1.105 + const MarkToLigaturePositioningSubtable *subtable = (const MarkToLigaturePositioningSubtable *) lookupSubtable;
1.106 +
1.107 + delta = subtable->process(glyphIterator, fontInstance);
1.108 + break;
1.109 + }
1.110 +
1.111 + case gpstMarkToMark:
1.112 + {
1.113 + const MarkToMarkPositioningSubtable *subtable = (const MarkToMarkPositioningSubtable *) lookupSubtable;
1.114 +
1.115 + delta = subtable->process(glyphIterator, fontInstance);
1.116 + break;
1.117 + }
1.118 +
1.119 + case gpstContext:
1.120 + {
1.121 + const ContextualPositioningSubtable *subtable = (const ContextualPositioningSubtable *) lookupSubtable;
1.122 +
1.123 + delta = subtable->process(this, glyphIterator, fontInstance, success);
1.124 + break;
1.125 + }
1.126 +
1.127 + case gpstChainedContext:
1.128 + {
1.129 + const ChainingContextualPositioningSubtable *subtable = (const ChainingContextualPositioningSubtable *) lookupSubtable;
1.130 +
1.131 + delta = subtable->process(this, glyphIterator, fontInstance, success);
1.132 + break;
1.133 + }
1.134 +
1.135 + case gpstExtension:
1.136 + {
1.137 + const ExtensionSubtable *subtable = (const ExtensionSubtable *) lookupSubtable;
1.138 +
1.139 + delta = subtable->process(this, lookupType, glyphIterator, fontInstance, success);
1.140 + break;
1.141 + }
1.142 +
1.143 + default:
1.144 + break;
1.145 + }
1.146 +
1.147 + return delta;
1.148 +}
1.149 +
1.150 +GlyphPositioningLookupProcessor::~GlyphPositioningLookupProcessor()
1.151 +{
1.152 +}
1.153 +
1.154 +U_NAMESPACE_END