2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @(#)IndicLayoutEngine.cpp 1.3 00/03/15
|
|
|
|
*
|
2003-06-03 20:58:22 +00:00
|
|
|
* (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved
|
2000-11-14 21:22:14 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "LETypes.h"
|
|
|
|
#include "LayoutEngine.h"
|
|
|
|
#include "OpenTypeLayoutEngine.h"
|
|
|
|
#include "IndicLayoutEngine.h"
|
|
|
|
#include "ScriptAndLanguageTags.h"
|
|
|
|
|
|
|
|
#include "GlyphSubstitutionTables.h"
|
|
|
|
#include "GlyphDefinitionTables.h"
|
|
|
|
#include "GlyphPositioningTables.h"
|
|
|
|
|
|
|
|
#include "GDEFMarkFilter.h"
|
|
|
|
|
|
|
|
#include "IndicReordering.h"
|
|
|
|
|
2001-10-16 00:39:01 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2002-06-29 00:04:16 +00:00
|
|
|
const char IndicOpenTypeLayoutEngine::fgClassID=0;
|
|
|
|
|
2000-12-21 01:18:44 +00:00
|
|
|
IndicOpenTypeLayoutEngine::IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
|
2001-01-19 00:30:17 +00:00
|
|
|
const GlyphSubstitutionTableHeader *gsubTable)
|
2003-01-04 02:52:23 +00:00
|
|
|
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable), fMPreFixups(NULL)
|
2000-11-14 21:22:14 +00:00
|
|
|
{
|
2002-03-01 22:24:10 +00:00
|
|
|
fFeatureOrder = IndicReordering::getFeatureOrder();
|
2000-11-14 21:22:14 +00:00
|
|
|
}
|
|
|
|
|
2000-12-21 01:18:44 +00:00
|
|
|
IndicOpenTypeLayoutEngine::IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode)
|
2003-01-04 02:52:23 +00:00
|
|
|
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode), fMPreFixups(NULL)
|
2000-11-14 21:22:14 +00:00
|
|
|
{
|
2002-03-01 22:24:10 +00:00
|
|
|
fFeatureOrder = IndicReordering::getFeatureOrder();
|
2000-11-14 21:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
IndicOpenTypeLayoutEngine::~IndicOpenTypeLayoutEngine()
|
|
|
|
{
|
|
|
|
// nothing to do
|
|
|
|
}
|
|
|
|
|
|
|
|
// Input: characters, tags
|
|
|
|
// Output: glyphs, char indices
|
2003-09-25 15:33:02 +00:00
|
|
|
le_int32 IndicOpenTypeLayoutEngine::glyphProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
|
|
|
|
const LETag **&featureTags, LEGlyphID *&glyphs, le_int32 *&charIndices, LEErrorCode &success)
|
2000-11-14 21:22:14 +00:00
|
|
|
{
|
2002-04-02 03:33:42 +00:00
|
|
|
if (LE_FAILURE(success)) {
|
|
|
|
return 0;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2003-05-13 00:44:54 +00:00
|
|
|
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
|
2002-04-02 03:33:42 +00:00
|
|
|
success = LE_ILLEGAL_ARGUMENT_ERROR;
|
|
|
|
return 0;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
|
|
|
le_int32 retCount = OpenTypeLayoutEngine::glyphProcessing(chars, offset, count, max, rightToLeft, featureTags, glyphs, charIndices, success);
|
|
|
|
|
2002-04-02 03:33:42 +00:00
|
|
|
if (LE_FAILURE(success)) {
|
|
|
|
return 0;
|
|
|
|
}
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2003-01-04 02:52:23 +00:00
|
|
|
IndicReordering::adjustMPres(fMPreFixups, glyphs, charIndices);
|
2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
return retCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Input: characters
|
|
|
|
// Output: characters, char indices, tags
|
|
|
|
// Returns: output character count
|
2003-05-13 00:44:54 +00:00
|
|
|
le_int32 IndicOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool /*rightToLeft*/,
|
2000-12-21 01:18:44 +00:00
|
|
|
LEUnicode *&outChars, le_int32 *&charIndices, const LETag **&featureTags, LEErrorCode &success)
|
2000-11-14 21:22:14 +00:00
|
|
|
{
|
2002-04-02 03:33:42 +00:00
|
|
|
if (LE_FAILURE(success)) {
|
|
|
|
return 0;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
|
|
|
|
success = LE_ILLEGAL_ARGUMENT_ERROR;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-11-14 21:22:14 +00:00
|
|
|
le_int32 worstCase = count * IndicReordering::getWorstCaseExpansion(fScriptCode);
|
|
|
|
|
2003-01-07 22:47:19 +00:00
|
|
|
outChars = LE_NEW_ARRAY(LEUnicode, worstCase);
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2002-04-02 03:33:42 +00:00
|
|
|
if (outChars == NULL) {
|
|
|
|
success = LE_MEMORY_ALLOCATION_ERROR;
|
|
|
|
return 0;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2003-01-07 22:47:19 +00:00
|
|
|
charIndices = LE_NEW_ARRAY(le_int32, worstCase);
|
2002-04-02 03:33:42 +00:00
|
|
|
if (charIndices == NULL) {
|
2003-01-07 22:47:19 +00:00
|
|
|
LE_DELETE_ARRAY(outChars);
|
2002-04-02 03:33:42 +00:00
|
|
|
success = LE_MEMORY_ALLOCATION_ERROR;
|
|
|
|
return 0;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2003-01-07 22:47:19 +00:00
|
|
|
featureTags = LE_NEW_ARRAY(const LETag *, worstCase);
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2002-04-02 03:33:42 +00:00
|
|
|
if (featureTags == NULL) {
|
2003-01-07 22:47:19 +00:00
|
|
|
LE_DELETE_ARRAY(charIndices);
|
|
|
|
LE_DELETE_ARRAY(outChars);
|
2002-04-02 03:33:42 +00:00
|
|
|
success = LE_MEMORY_ALLOCATION_ERROR;
|
|
|
|
return 0;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2000-11-14 21:22:14 +00:00
|
|
|
// NOTE: assumes this allocates featureTags...
|
|
|
|
// (probably better than doing the worst case stuff here...)
|
2003-01-04 02:52:23 +00:00
|
|
|
return IndicReordering::reorder(&chars[offset], count, fScriptCode, outChars, charIndices, featureTags, &fMPreFixups);
|
2000-11-14 21:22:14 +00:00
|
|
|
}
|
|
|
|
|
2001-10-16 00:39:01 +00:00
|
|
|
U_NAMESPACE_END
|