os/textandloc/fontservices/textshaperplugin/IcuSource/layout/GlyphSubstLookupProc.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/layout/GlyphSubstLookupProc.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,127 @@
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 "LEGlyphFilter.h"
1.12 +#include "LEFontInstance.h"
1.13 +#include "OpenTypeTables.h"
1.14 +#include "Features.h"
1.15 +#include "Lookups.h"
1.16 +#include "ScriptAndLanguage.h"
1.17 +#include "GlyphDefinitionTables.h"
1.18 +#include "GlyphSubstitutionTables.h"
1.19 +#include "SingleSubstitutionSubtables.h"
1.20 +#include "MultipleSubstSubtables.h"
1.21 +#include "AlternateSubstSubtables.h"
1.22 +#include "LigatureSubstSubtables.h"
1.23 +#include "ContextualSubstSubtables.h"
1.24 +#include "ExtensionSubtables.h"
1.25 +#include "LookupProcessor.h"
1.26 +#include "GlyphSubstLookupProc.h"
1.27 +#include "LESwaps.h"
1.28 +
1.29 +U_NAMESPACE_BEGIN
1.30 +
1.31 +GlyphSubstitutionLookupProcessor::GlyphSubstitutionLookupProcessor(
1.32 + const GlyphSubstitutionTableHeader *glyphSubstitutionTableHeader,
1.33 + LETag scriptTag, LETag languageTag, const LEGlyphFilter *filter, const LETag *featureOrder)
1.34 + : LookupProcessor(
1.35 + (char *) glyphSubstitutionTableHeader,
1.36 + SWAPW(glyphSubstitutionTableHeader->scriptListOffset),
1.37 + SWAPW(glyphSubstitutionTableHeader->featureListOffset),
1.38 + SWAPW(glyphSubstitutionTableHeader->lookupListOffset),
1.39 + scriptTag, languageTag, featureOrder), fFilter(filter)
1.40 +{
1.41 + // anything?
1.42 +}
1.43 +
1.44 +GlyphSubstitutionLookupProcessor::GlyphSubstitutionLookupProcessor()
1.45 +{
1.46 +}
1.47 +
1.48 +le_uint32 GlyphSubstitutionLookupProcessor::applySubtable(
1.49 + const LookupSubtable *lookupSubtable, le_uint16 lookupType,
1.50 + GlyphIterator *glyphIterator, const LEFontInstance *fontInstance,
1.51 + LEErrorCode& success) const
1.52 +{
1.53 + if (LE_FAILURE(success)) {
1.54 + return 0;
1.55 + }
1.56 + le_uint32 delta = 0;
1.57 +
1.58 + switch(lookupType)
1.59 + {
1.60 + case 0:
1.61 + break;
1.62 +
1.63 + case gsstSingle:
1.64 + {
1.65 + const SingleSubstitutionSubtable *subtable = (const SingleSubstitutionSubtable *) lookupSubtable;
1.66 +
1.67 + delta = subtable->process(glyphIterator, fFilter);
1.68 + break;
1.69 + }
1.70 +
1.71 + case gsstMultiple:
1.72 + {
1.73 + const MultipleSubstitutionSubtable *subtable = (const MultipleSubstitutionSubtable *) lookupSubtable;
1.74 +
1.75 + delta = subtable->process(glyphIterator, success, fFilter);
1.76 + break;
1.77 + }
1.78 +
1.79 + case gsstAlternate:
1.80 + {
1.81 + const AlternateSubstitutionSubtable *subtable = (const AlternateSubstitutionSubtable *) lookupSubtable;
1.82 +
1.83 + delta = subtable->process(glyphIterator, fFilter);
1.84 + break;
1.85 + }
1.86 +
1.87 + case gsstLigature:
1.88 + {
1.89 + const LigatureSubstitutionSubtable *subtable = (const LigatureSubstitutionSubtable *) lookupSubtable;
1.90 +
1.91 + delta = subtable->process(glyphIterator, fFilter);
1.92 + break;
1.93 + }
1.94 +
1.95 + case gsstContext:
1.96 + {
1.97 + const ContextualSubstitutionSubtable *subtable = (const ContextualSubstitutionSubtable *) lookupSubtable;
1.98 +
1.99 + delta = subtable->process(this, glyphIterator, fontInstance, success);
1.100 + break;
1.101 + }
1.102 +
1.103 + case gsstChainingContext:
1.104 + {
1.105 + const ChainingContextualSubstitutionSubtable *subtable = (const ChainingContextualSubstitutionSubtable *) lookupSubtable;
1.106 +
1.107 + delta = subtable->process(this, glyphIterator, fontInstance, success);
1.108 + break;
1.109 + }
1.110 +
1.111 + case gsstExtension:
1.112 + {
1.113 + const ExtensionSubtable *subtable = (const ExtensionSubtable *) lookupSubtable;
1.114 +
1.115 + delta = subtable->process(this, lookupType, glyphIterator, fontInstance, success);
1.116 + break;
1.117 + }
1.118 +
1.119 + default:
1.120 + break;
1.121 + }
1.122 +
1.123 + return delta;
1.124 +}
1.125 +
1.126 +GlyphSubstitutionLookupProcessor::~GlyphSubstitutionLookupProcessor()
1.127 +{
1.128 +}
1.129 +
1.130 +U_NAMESPACE_END