2000-11-28 20:56:52 +00:00
|
|
|
/*
|
|
|
|
* @(#)SingleSubstitutionSubtables.cpp 1.6 00/03/15
|
|
|
|
*
|
2001-03-21 19:46:26 +00:00
|
|
|
* (C) Copyright IBM Corp. 1998, 1999, 2000, 2001 - All Rights Reserved
|
2000-11-28 20:56:52 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "LETypes.h"
|
|
|
|
#include "LEGlyphFilter.h"
|
|
|
|
#include "OpenTypeTables.h"
|
|
|
|
#include "GlyphSubstitutionTables.h"
|
|
|
|
#include "SingleSubstitutionSubtables.h"
|
|
|
|
#include "GlyphIterator.h"
|
|
|
|
#include "LESwaps.h"
|
|
|
|
|
2001-01-19 00:30:17 +00:00
|
|
|
le_uint32 SingleSubstitutionSubtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
|
|
|
switch(SWAPW(subtableFormat))
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
2001-01-19 00:30:17 +00:00
|
|
|
const SingleSubstitutionFormat1Subtable *subtable = (const SingleSubstitutionFormat1Subtable *) this;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
return subtable->process(glyphIterator, filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
2001-01-19 00:30:17 +00:00
|
|
|
const SingleSubstitutionFormat2Subtable *subtable = (const SingleSubstitutionFormat2Subtable *) this;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
return subtable->process(glyphIterator, filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-19 00:30:17 +00:00
|
|
|
le_uint32 SingleSubstitutionFormat1Subtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
|
|
|
LEGlyphID glyph = (LEGlyphID) glyphIterator->getCurrGlyphID();
|
|
|
|
le_int32 coverageIndex = getGlyphCoverage(glyph);
|
|
|
|
|
|
|
|
if (coverageIndex >= 0)
|
|
|
|
{
|
|
|
|
LEGlyphID substitute = glyph + SWAPW(deltaGlyphID);
|
|
|
|
|
|
|
|
if (filter == NULL || filter->accept(substitute)) {
|
|
|
|
glyphIterator->setCurrGlyphID(substitute);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-01-19 00:30:17 +00:00
|
|
|
le_uint32 SingleSubstitutionFormat2Subtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
|
|
|
LEGlyphID glyph = (LEGlyphID) glyphIterator->getCurrGlyphID();
|
|
|
|
le_int32 coverageIndex = getGlyphCoverage(glyph);
|
|
|
|
|
|
|
|
if (coverageIndex >= 0)
|
|
|
|
{
|
|
|
|
LEGlyphID substitute = SWAPW(substituteArray[coverageIndex]);
|
|
|
|
|
|
|
|
if (filter == NULL || filter->accept(substitute)) {
|
|
|
|
glyphIterator->setCurrGlyphID(substitute);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|