os/textandloc/fontservices/textshaperplugin/IcuSource/layout/SingleSubstitutionSubtables.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/layout/SingleSubstitutionSubtables.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,79 @@
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 "OpenTypeTables.h"
1.13 +#include "GlyphSubstitutionTables.h"
1.14 +#include "SingleSubstitutionSubtables.h"
1.15 +#include "GlyphIterator.h"
1.16 +#include "LESwaps.h"
1.17 +
1.18 +U_NAMESPACE_BEGIN
1.19 +
1.20 +le_uint32 SingleSubstitutionSubtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const
1.21 +{
1.22 + switch(SWAPW(subtableFormat))
1.23 + {
1.24 + case 0:
1.25 + return 0;
1.26 +
1.27 + case 1:
1.28 + {
1.29 + const SingleSubstitutionFormat1Subtable *subtable = (const SingleSubstitutionFormat1Subtable *) this;
1.30 +
1.31 + return subtable->process(glyphIterator, filter);
1.32 + }
1.33 +
1.34 + case 2:
1.35 + {
1.36 + const SingleSubstitutionFormat2Subtable *subtable = (const SingleSubstitutionFormat2Subtable *) this;
1.37 +
1.38 + return subtable->process(glyphIterator, filter);
1.39 + }
1.40 +
1.41 + default:
1.42 + return 0;
1.43 + }
1.44 +}
1.45 +
1.46 +le_uint32 SingleSubstitutionFormat1Subtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const
1.47 +{
1.48 + LEGlyphID glyph = glyphIterator->getCurrGlyphID();
1.49 + le_int32 coverageIndex = getGlyphCoverage(glyph);
1.50 +
1.51 + if (coverageIndex >= 0) {
1.52 + TTGlyphID substitute = ((TTGlyphID) LE_GET_GLYPH(glyph)) + SWAPW(deltaGlyphID);
1.53 +
1.54 + if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, substitute))) {
1.55 + glyphIterator->setCurrGlyphID(substitute);
1.56 + }
1.57 +
1.58 + return 1;
1.59 + }
1.60 +
1.61 + return 0;
1.62 +}
1.63 +
1.64 +le_uint32 SingleSubstitutionFormat2Subtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const
1.65 +{
1.66 + LEGlyphID glyph = glyphIterator->getCurrGlyphID();
1.67 + le_int32 coverageIndex = getGlyphCoverage(glyph);
1.68 +
1.69 + if (coverageIndex >= 0) {
1.70 + TTGlyphID substitute = SWAPW(substituteArray[coverageIndex]);
1.71 +
1.72 + if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, substitute))) {
1.73 + glyphIterator->setCurrGlyphID(substitute);
1.74 + }
1.75 +
1.76 + return 1;
1.77 + }
1.78 +
1.79 + return 0;
1.80 +}
1.81 +
1.82 +U_NAMESPACE_END