ICU-5309 Move fFilterZeroWidth from OpenTypeLayoutEngine to LayoutEngine, add fFilterZeroWidth to DefaultCharMapper, remove filterZeroWidth parameters from MapCharsToGlyphs, MapCharToGlyph.

X-SVN-Rev: 20918
This commit is contained in:
Eric Mader 2007-01-24 22:45:49 +00:00
parent 31a9f8c37b
commit 69b172a199
15 changed files with 54 additions and 92 deletions

View File

@ -1,7 +1,7 @@
/*
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
* (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved
*
*/
@ -164,14 +164,14 @@ le_int32 UnicodeArabicOpenTypeLayoutEngine::glyphPostProcessing(LEGlyphStorage &
glyphStorage.adoptCharIndicesArray(tempGlyphStorage);
ArabicOpenTypeLayoutEngine::mapCharsToGlyphs(tempChars, 0, tempGlyphCount, FALSE, TRUE, TRUE, glyphStorage, success);
ArabicOpenTypeLayoutEngine::mapCharsToGlyphs(tempChars, 0, tempGlyphCount, FALSE, TRUE, glyphStorage, success);
LE_DELETE_ARRAY(tempChars);
return tempGlyphCount;
}
void UnicodeArabicOpenTypeLayoutEngine::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool /*mirror*/, le_bool /*filterZeroWidth*/, LEGlyphStorage &glyphStorage, LEErrorCode &success)
void UnicodeArabicOpenTypeLayoutEngine::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool /*mirror*/, LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return;

View File

@ -1,7 +1,7 @@
/*
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
* (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved
*
*/
@ -207,14 +207,13 @@ protected:
* @param count - the number of characters to be mapped
* @param reverse - if <code>TRUE</code>, the output will be in reverse order
* @param mirror - if <code>TRUE</code>, do character mirroring
* @param filterZeroWidth - if <code>TRUE</code> replace ZWJ / ZWNJ with a glyph with no contours.
* @param glyphStorage - the glyph storage object. Glyph and char index arrays will be updated.
*
* @param success - set to an error code if the operation fails
*
* @internal
*/
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror, le_bool filterZeroWidth,
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror,
LEGlyphStorage &glyphStorage, LEErrorCode &success);
/**

View File

@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
* (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved
*
*/
@ -28,6 +28,7 @@ class DefaultCharMapper : public UMemory, public LECharMapper
private:
le_bool fFilterControls;
le_bool fMirror;
le_bool fFilterZeroWidth;
static const LEUnicode32 controlChars[];
@ -39,8 +40,8 @@ private:
static const le_int32 mirroredCharsCount;
public:
DefaultCharMapper(le_bool filterControls, le_bool mirror)
: fFilterControls(filterControls), fMirror(mirror)
DefaultCharMapper(le_bool filterControls, le_bool mirror, le_bool filterZeroWidth)
: fFilterControls(filterControls), fMirror(mirror), fFilterZeroWidth(filterZeroWidth)
{
// nothing
};

View File

@ -1,7 +1,7 @@
/*
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
* (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved
*
*/
@ -39,7 +39,7 @@ le_int32 GXLayoutEngine::computeGlyphs(const LEUnicode chars[], le_int32 offset,
return 0;
}
mapCharsToGlyphs(chars, offset, count, FALSE, rightToLeft, TRUE, glyphStorage, success);
mapCharsToGlyphs(chars, offset, count, FALSE, rightToLeft, glyphStorage, success);
if (LE_FAILURE(success)) {
return 0;

View File

@ -1,7 +1,7 @@
/*
*******************************************************************************
*
* Copyright (C) 1999-2006, International Business Machines
* Copyright (C) 1999-2007, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@ -47,7 +47,7 @@ const LEFontInstance *LEFontInstance::getSubFont(const LEUnicode chars[], le_int
}
void LEFontInstance::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count,
le_bool reverse, const LECharMapper *mapper, le_bool filterZeroWidth, LEGlyphStorage &glyphStorage) const
le_bool reverse, const LECharMapper *mapper, LEGlyphStorage &glyphStorage) const
{
le_int32 i, out = 0, dir = 1;
@ -68,7 +68,7 @@ void LEFontInstance::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset,
}
}
glyphStorage[out] = mapCharToGlyph(code, mapper, filterZeroWidth);
glyphStorage[out] = mapCharToGlyph(code, mapper);
if (code >= 0x10000) {
i += 1;
@ -78,21 +78,21 @@ void LEFontInstance::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset,
}
LEGlyphID LEFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const
{
return mapCharToGlyph(ch, mapper, TRUE);
}
LEGlyphID LEFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const
{
LEUnicode32 mappedChar = mapper->mapChar(ch);
if (mappedChar == 0xFFFE || mappedChar == 0xFFFF) {
if (mappedChar == 0xFFFE || mappedChar == 0xFFFF ||
mappedChar == 0x200C || mappedChar == 0x200D) {
return 0xFFFF;
}
#if 0
// TODO: figure out if we still need to do this now that DefaultCharMapper
// does the filtering... (and why did we call canDisplay at all?)
if (filterZeroWidth && (mappedChar == 0x200C || mappedChar == 0x200D)) {
return canDisplay(mappedChar)? 0x0001 : 0xFFFF;
}
#endif
return mapCharToGlyph(mappedChar);
}

View File

@ -1,7 +1,7 @@
/*
*
* (C) Copyright IBM Corp. 1998-2006 - All Rights Reserved
* (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved
*
*/
@ -209,32 +209,13 @@ public:
* @param count - the number of characters
* @param reverse - if <code>TRUE</code>, store the glyph indices in reverse order.
* @param mapper - the character mapper.
* @param filterZeroWidth - <code>TRUE</code> if ZWJ / ZWNJ characters should map to a glyph w/ no contours.
* @param glyphStorage - the object which contains the output glyph array
*
* @see LECharMapper
*
* @draft ICU 3.6
*/
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, const LECharMapper *mapper, le_bool filterZeroWidth, LEGlyphStorage &glyphStorage) const;
/**
* This method maps a single character to a glyph index, using the
* font's character to glyph map. The default implementation of this
* method calls the mapper, and then calls <code>mapCharToGlyph(mappedCh)</code>.
*
* @param ch - the character
* @param mapper - the character mapper
* @param filterZeroWidth - <code>TRUE</code> if ZWJ / ZWNJ characters should map to a glyph w/ no contours.
*
* @return the glyph index
*
* @see LECharMapper
*
* @draft ICU 3.6
*/
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const;
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, const LECharMapper *mapper, LEGlyphStorage &glyphStorage) const;
/**
* This method maps a single character to a glyph index, using the

View File

@ -1,7 +1,7 @@
/*
*
* (C) Copyright IBM Corp. 1998-2006 - All Rights Reserved
* (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved
*
*/
@ -61,6 +61,10 @@ LEUnicode32 DefaultCharMapper::mapChar(LEUnicode32 ch) const
}
}
if (fFilterZeroWidth && (ch == 0x200C || ch == 0x200D)) {
return 0xFFFF;
}
return ch;
}
@ -101,7 +105,7 @@ static const le_int32 canonFeatureMapCount = LE_ARRAY_SIZE(canonFeatureMap);
LayoutEngine::LayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags)
: fGlyphStorage(NULL), fFontInstance(fontInstance), fScriptCode(scriptCode), fLanguageCode(languageCode),
fTypoFlags(typoFlags)
fTypoFlags(typoFlags), fFilterZeroWidth(FALSE)
{
fGlyphStorage = new LEGlyphStorage();
}
@ -238,10 +242,10 @@ le_int32 LayoutEngine::computeGlyphs(const LEUnicode chars[], le_int32 offset, l
le_int32 outCharCount = characterProcessing(chars, offset, count, max, rightToLeft, outChars, glyphStorage, success);
if (outChars != NULL) {
mapCharsToGlyphs(outChars, 0, outCharCount, rightToLeft, rightToLeft, TRUE, glyphStorage, success);
mapCharsToGlyphs(outChars, 0, outCharCount, rightToLeft, rightToLeft, glyphStorage, success);
LE_DELETE_ARRAY(outChars); // FIXME: a subclass may have allocated this, in which case this delete might not work...
} else {
mapCharsToGlyphs(chars, offset, count, rightToLeft, rightToLeft, TRUE, glyphStorage, success);
mapCharsToGlyphs(chars, offset, count, rightToLeft, rightToLeft, glyphStorage, success);
}
return glyphStorage.getGlyphCount();
@ -382,7 +386,7 @@ const void *LayoutEngine::getFontTable(LETag tableTag) const
return fFontInstance->getFontTable(tableTag);
}
void LayoutEngine::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror, le_bool filterZeroWidth,
void LayoutEngine::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror,
LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
@ -391,9 +395,9 @@ void LayoutEngine::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le
glyphStorage.allocateGlyphArray(count, reverse, success);
DefaultCharMapper charMapper(TRUE, mirror);
DefaultCharMapper charMapper(TRUE, mirror, fFilterZeroWidth);
fFontInstance->mapCharsToGlyphs(chars, offset, count, reverse, &charMapper, filterZeroWidth, glyphStorage);
fFontInstance->mapCharsToGlyphs(chars, offset, count, reverse, &charMapper, glyphStorage);
}
// Input: characters, font?

View File

@ -1,7 +1,7 @@
/*
*
* (C) Copyright IBM Corp. 1998-2006 - All Rights Reserved
* (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved
*
*/
@ -107,6 +107,14 @@ protected:
*/
le_int32 fTypoFlags;
/**
* <code>TRUE</code> if <code>mapCharsToGlyphs</code> should replace ZWJ / ZWNJ with a glyph
* with no contours.
*
* @internal
*/
le_bool fFilterZeroWidth;
/**
* This constructs an instance for a given font, script and language. Subclass constructors
* must call this constructor.
@ -254,7 +262,6 @@ protected:
* @param count - the number of characters to be mapped
* @param reverse - if <code>TRUE</code>, the output will be in reverse order
* @param mirror - if <code>TRUE</code>, do character mirroring
* @param filterZeroWidth - if <code>TRUE</code> replace ZWJ / ZWNJ with a glyph with no contours.
* @param glyphStorage - the object which holds the per-glyph storage. The glyph and char
* indices arrays will be filled in.
* @param success - set to an error code if the operation fails
@ -263,7 +270,7 @@ protected:
*
* @internal
*/
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror, le_bool filterZeroWidth, LEGlyphStorage &glyphStorage, LEErrorCode &success);
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror, LEGlyphStorage &glyphStorage, LEErrorCode &success);
/**
* This is a convenience method that forces the advance width of mark

View File

@ -1,7 +1,7 @@
/*
*
* (C) Copyright IBM Corp. 1998-2006 - All Rights Reserved
* (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved
*
*/
@ -70,7 +70,7 @@ OpenTypeLayoutEngine::OpenTypeLayoutEngine(const LEFontInstance *fontInstance, l
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable)
: LayoutEngine(fontInstance, scriptCode, languageCode, typoFlags), fFeatureMask(minimalFeatures),
fFeatureMap(featureMap), fFeatureMapCount(featureMapCount), fFeatureOrder(FALSE),
fGSUBTable(gsubTable), fGDEFTable(NULL), fGPOSTable(NULL), fSubstitutionFilter(NULL), fFilterZeroWidth(TRUE)
fGSUBTable(gsubTable), fGDEFTable(NULL), fGPOSTable(NULL), fSubstitutionFilter(NULL)
{
static const le_uint32 gdefTableTag = LE_GDEF_TABLE_TAG;
static const le_uint32 gposTableTag = LE_GPOS_TABLE_TAG;
@ -110,7 +110,7 @@ void OpenTypeLayoutEngine::reset()
OpenTypeLayoutEngine::OpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags)
: LayoutEngine(fontInstance, scriptCode, languageCode, typoFlags), fFeatureOrder(FALSE),
fGSUBTable(NULL), fGDEFTable(NULL), fGPOSTable(NULL), fSubstitutionFilter(NULL), fFilterZeroWidth(TRUE)
fGSUBTable(NULL), fGDEFTable(NULL), fGPOSTable(NULL), fSubstitutionFilter(NULL)
{
setScriptAndLanguageTags();
}
@ -190,7 +190,7 @@ le_int32 OpenTypeLayoutEngine::glyphProcessing(const LEUnicode chars[], le_int32
return 0;
}
mapCharsToGlyphs(chars, offset, count, rightToLeft, rightToLeft, fFilterZeroWidth, glyphStorage, success);
mapCharsToGlyphs(chars, offset, count, rightToLeft, rightToLeft, glyphStorage, success);
if (LE_FAILURE(success)) {
return 0;

View File

@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 1998-2006 - All Rights Reserved
* (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved
*
*/
@ -221,14 +221,6 @@ protected:
*/
LETag fLangSysTag;
/**
* <code>TRUE</code> if <code>mapCharsToGlyphs</code> should replace ZWJ / ZWNJ with a glyph
* with no contours.
*
* @internal
*/
le_bool fFilterZeroWidth;
/**
* This method does the OpenType character processing. It assigns the OpenType feature
* tags to the characters, and may generate output characters that differ from the input

View File

@ -1,7 +1,7 @@
/*
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
* (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved
*
*/
@ -83,7 +83,7 @@ le_int32 ThaiLayoutEngine::computeGlyphs(const LEUnicode chars[], le_int32 offse
}
glyphCount = ThaiShaping::compose(chars, offset, count, fGlyphSet, fErrorChar, outChars, glyphStorage);
mapCharsToGlyphs(outChars, 0, glyphCount, FALSE, FALSE, TRUE, glyphStorage, success);
mapCharsToGlyphs(outChars, 0, glyphCount, FALSE, FALSE, glyphStorage, success);
LE_DELETE_ARRAY(outChars);

View File

@ -1,7 +1,7 @@
/*
*******************************************************************************
*
* Copyright (C) 1999-2006, International Business Machines
* Copyright (C) 1999-2007, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@ -360,13 +360,6 @@ le_int32 PortableFontInstance::getLeading() const
return fLeading;
}
// We really want to inherit this method from the superclass, but some compilers
// issue a warning if we don't implement it...
LEGlyphID PortableFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const
{
return LEFontInstance::mapCharToGlyph(ch, mapper, filterZeroWidth);
}
// We really want to inherit this method from the superclass, but some compilers
// issue a warning if we don't implement it...
LEGlyphID PortableFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const

View File

@ -2,7 +2,7 @@
/*
*******************************************************************************
*
* Copyright (C) 1999-2006, International Business Machines
* Copyright (C) 1999-2007, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@ -87,10 +87,6 @@ public:
virtual le_int32 getLeading() const;
// We really want to inherit this method from the superclass, but some compilers
// issue a warning if we don't implement it...
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const;
// We really want to inherit this method from the superclass, but some compilers
// issue a warning if we don't implement it...
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;

View File

@ -1,7 +1,7 @@
/*
*******************************************************************************
*
* Copyright (C) 1999-2006, International Business Machines
* Copyright (C) 1999-2007, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@ -86,13 +86,6 @@ le_int32 SimpleFontInstance::getLeading() const
return 0;
}
// We really want to inherit this method from the superclass, but some compilers
// issue a warning if we don't implement it...
LEGlyphID SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const
{
return LEFontInstance::mapCharToGlyph(ch, mapper, filterZeroWidth);
}
// We really want to inherit this method from the superclass, but some compilers
// issue a warning if we don't implement it...
LEGlyphID SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const

View File

@ -2,7 +2,7 @@
/*
*******************************************************************************
*
* Copyright (C) 1999-2006, International Business Machines
* Copyright (C) 1999-2007, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@ -45,10 +45,6 @@ public:
virtual le_int32 getLeading() const;
// We really want to inherit this method from the superclass, but some compilers
// issue a warning if we don't implement it...
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const;
// We really want to inherit this method from the superclass, but some compilers
// issue a warning if we don't implement it...
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;