Extend CTL extension to support multiple CTL scripts (framework + hindi

support).  Bug 163962, r=gilbert.fang@sun.com, r=prabhat.hegde@sun.com,
r=cls, sr=bzbarsky, patch by prabhat.hegde@sun.com and
roland.mainz@informatik.med.uni-giessen.de
This commit is contained in:
bzbarsky%mit.edu 2002-08-30 07:45:52 +00:00
parent add1e76599
commit a3fbeac670
24 changed files with 1965 additions and 79 deletions

View File

@ -203,6 +203,7 @@ intl/ctl/public/Makefile
intl/ctl/src/Makefile
intl/ctl/src/pangoLite/Makefile
intl/ctl/src/thaiShaper/Makefile
intl/ctl/src/hindShaper/Makefile
"
fi

View File

@ -106,8 +106,9 @@ my %map = (
'mozcomps', 'xpfe/components',
'mozldap', 'directory/xpcom/base',
'mozMapi32', 'mailnews/mapi',
'mozpango', 'extensions/ctl/src/pangoLite',
'mozpango-thaix', 'extensions/ctl/src/thaiShaper',
'mozpango', 'intl/ctl/src/pangoLite',
'mozpango-thaix', 'intl/ctl/src/thaiShaper',
'mozpango-dvngx', 'intl/ctl/src/hindShaper',
'mozucth', 'xpfe/components/ucth',
'mozxfer', 'xpfe/components/xfer',
'mpfilelocprovider', 'modules/mpfilelocprovider',

View File

@ -349,6 +349,14 @@ static nsFontCharSetInfo JohabNoAscii =
{ "x-johab-noascii", DoubleByteConvert, 1,
TT_OS2_CPR1_KO_WANSUNG | TT_OS2_CPR1_KO_JOHAB, 0 };
#ifdef SUNCTL
/* Hindi range currently unsupported in FT2 range. Change TT* once we
arrive at a way to identify hindi */
static nsFontCharSetInfo SunIndic =
{ "x-sun-unicode-india-0", DoubleByteConvert, 0,
0, 0 };
#endif /* SUNCTL */
static nsFontCharSetInfo ISO106461 =
{ nsnull, ISO10646Convert, 1, 0xFFFFFFFF, 0xFFFFFFFF };
@ -523,6 +531,9 @@ static nsFontCharSetMap gCharSetMap[] =
{ "ucs2.cjk-0", &FLG_NONE, &Unknown },
{ "ucs2.cjk_japan-0", &FLG_NONE, &Unknown },
{ "ucs2.cjk_taiwan-0", &FLG_NONE, &Unknown },
#ifdef SUNCTL
{ "sun.unicode.india-0",&FLG_NONE, &SunIndic },
#endif /* SUNCTL */
{ nsnull, nsnull, nsnull }
};

View File

@ -378,6 +378,14 @@ static nsFontCharSetInfoXlib JohabNoAscii =
{ "x-johab-noascii", DoubleByteConvert, 1,
TT_OS2_CPR1_KO_WANSUNG | TT_OS2_CPR1_KO_JOHAB, 0 };
#ifdef SUNCTL
/* Hindi range currently unsupported in FT2 range. Change TT* once we
arrive at a way to identify hindi */
static nsFontCharSetInfoXlib SunIndic =
{ "x-sun-unicode-india-0", DoubleByteConvert, 0,
0, 0 };
#endif /* SUNCTL */
static nsFontCharSetInfoXlib ISO106461 =
{ nsnull, ISO10646Convert, 1, 0xFFFFFFFF, 0xFFFFFFFF };
@ -552,6 +560,9 @@ static nsFontCharSetMapXlib gCharSetMap[] =
{ "ucs2.cjk-0", &FLG_NONE, &Unknown },
{ "ucs2.cjk_japan-0", &FLG_NONE, &Unknown },
{ "ucs2.cjk_taiwan-0", &FLG_NONE, &Unknown },
#ifdef SUNCTL
{ "sun.unicode.india-0",&FLG_NONE, &SunIndic },
#endif /* SUNCTL */
{ nsnull, nsnull, nsnull }
};

View File

@ -16,7 +16,8 @@
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Contributor(s):
# Prabhat Hegde (prabhat.hegde@sun.com)
#
DEPTH = ../..
@ -26,7 +27,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src/pangoLite src/thaiShaper src
DIRS = public src/pangoLite src/thaiShaper src/hindiShaper src
include $(topsrcdir)/config/rules.mk

View File

@ -19,6 +19,8 @@
# 1999 Red Hat Software.
#
# Contributor(s):
# Prabhat Hegde (prabhat.hegde@sun.com)
#
DEPTH = ../../..
topsrcdir = @top_srcdir@

View File

@ -21,11 +21,17 @@
* 1999 Red Hat Software.
*
* Contributor(s):
* Prabhat Hegde (prabhat.hegde@sun.com)
*/
#ifndef nsCtlCIID_h___
#define nsCtlCIID_h___
// Class ID for UnicodeToSunIndia font encoding converter for *nix
#define NS_UNICODETOSUNINDIC_CID \
{ 0xc270e4e7, 0x3915, 0x43fe, \
{ 0xbc, 0xb0, 0x57, 0x4e, 0x68, 0xaf, 0x6b, 0xaf } }
// Class ID for UnicodeToTIS620 charset converter for *nix
#define NS_UNICODETOTIS620_CID \
{ 0xa2297171, 0x41ee, 0x498a, \
@ -34,7 +40,7 @@
// 1B285478-11B7-4EA3-AF47-2A7D117845AC
#define NS_ILE_IID \
{ 0x1b285478, 0x11b7, 0x4ea3, \
{ 0xaf, 0x47, 0x2a, 0x7d, 0x11, 0x78, 0x45, 0xac } }
{ 0xaf, 0x47, 0x2a, 0x7d, 0x11, 0x78, 0x45, 0xac } }
#define NS_ILE_PROGID "@mozilla.org/extensions/ctl;1"
@ -53,7 +59,7 @@
// D9E30F46-0EB5-4763-A7BD-26DECB30952F
#define NS_ISHAPEDTEXT_IID \
{ 0xd9e30f46, 0x0eb5, 0x4763, \
{ 0xa7, 0xbd, 0x26, 0xde, 0xcb, 0x30, 0x95, 0x2f } }
{ 0xa7, 0xbd, 0x26, 0xde, 0xcb, 0x30, 0x95, 0x2f } }
// {2997A657-AD7B-4036-827C-FBB3B443845B}
#define NS_SHAPEDTEXT_CID \
@ -67,4 +73,4 @@
#define NS_SHAPEDTEXT_PROGID "component://netscape/extensions/ctl/nsShapedText"
#endif
#endif /* !nsCtlCIID_h___ */

View File

@ -21,6 +21,7 @@
* 1999 Red Hat Software.
*
* Contributor(s):
* Prabhat Hegde (prabhat.hegde@sun.com)
*/
#ifndef nsILE_h__
@ -50,4 +51,5 @@ public:
NS_IMETHOD GetRangeOfCluster(const PRUnichar*, PRUint32,
const PRInt32, PRInt32*, PRInt32*) = 0;
};
#endif // nsILE_h
#endif /* !nsILE_h */

View File

@ -18,7 +18,9 @@
# by Red Hat Software. Portions created by Redhat are Copyright (C)
# 1999 Red Hat Software.
#
# Contributor(s):
# Contributor(s):
# Prabhat Hegde (prabhat.hegde@sun.com)
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
@ -43,6 +45,7 @@ EXTRA_DSO_LIBS = mozpango
CPPSRCS = \
nsULE.cpp \
nsUnicodeToTIS620.cpp \
nsUnicodeToSunIndic.cpp \
nsCtlLEModule.cpp \
$(NULL)

View File

@ -0,0 +1,50 @@
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
# The Initial Developer of the Original Code is Sun Microsystems,
# Inc. Portions created by SUN are Copyright (C) 2002 SUN
# Microsystems, Inc. All Rights Reserved.
#
# Contributor(s):
# Prabhat Hegde (prabhat.hegde@sun.com)
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = mozpango-dvngx
LIBRARY_NAME = mozpango-dvngx
EXPORT_LIBRARY = 1
EXTRA_DSO_LIBS = mozpango
CSRCS = \
dvng-x.c \
$(NULL)
include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES += \
-I$(srcdir)/../pangoLite \
$(NULL)
CFLAGS += $(GLIB_CFLAGS)
EXTRA_DSO_LDOPTS += \
-L$(DIST)/lib \
$(EXTRA_DSO_LIBS) \
$(GLIB_LIBS) \
$(GLIB_GMODULE_LIBS) \
$(NULL)

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* XPCTL : nsCtlLEModule.cpp
*
* The contents of this file are subject to the Mozilla Public
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
@ -20,7 +20,8 @@
* by Red Hat Software. Portions created by Redhat are Copyright (C)
* 1999 Red Hat Software.
*
* Contributor(s):
* Contributor(s):
* Prabhat Hegde (prabhat.hegde@sun.com)
*/
#include "nsCOMPtr.h"
@ -32,6 +33,7 @@
#include "nsULE.h"
#include "nsICharsetConverterManager.h"
#include "nsUnicodeToTIS620.h"
#include "nsUnicodeToSunIndic.h"
//----------------------------------------------------------------------------
// Global functions and data [declaration]
@ -48,11 +50,13 @@ PRInt32 g_LockCount = 0;
NS_CONVERTER_REGISTRY_START
NS_UCONV_REG_UNREG_ENCODER("tis620-2", NS_UNICODETOTIS620_CID)
NS_UCONV_REG_UNREG_ENCODER("x-sun-unicode-india-0", NS_UNICODETOSUNINDIC_CID)
NS_CONVERTER_REGISTRY_END
NS_IMPL_NSUCONVERTERREGSELF
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToTIS620);
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToSunIndic);
static const nsModuleComponentInfo components[] =
{
@ -60,6 +64,10 @@ static const nsModuleComponentInfo components[] =
NS_UNICODEENCODER_CONTRACTID_BASE "tis620-2",
nsUnicodeToTIS620Constructor,
nsUConverterRegSelf, nsUConverterUnregSelf },
{ ENCODER_NAME_BASE "x-sun-unicode-india-0" , NS_UNICODETOSUNINDIC_CID,
NS_UNICODEENCODER_CONTRACTID_BASE "x-sun-unicode-india-0",
nsUnicodeToSunIndicConstructor,
nsUConverterRegSelf, nsUConverterUnregSelf },
{ "Unicode Layout Engine", NS_ULE_CID, NS_ULE_PROGID,
nsULEConstructor, NULL, NULL }
};

View File

@ -1,7 +1,7 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* XPCTL : nsULE.cpp
*
* The contents of this file are subject to the Mozilla Public
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
@ -20,7 +20,8 @@
* by Red Hat Software. Portions created by Redhat are Copyright (C)
* 1999 Red Hat Software.
*
* Contributor(s):
* Contributor(s):
* Prabhat Hegde (prabhat.hegde@sun.com)
*/
#include "nsULE.h"
@ -31,6 +32,14 @@
#include "pango-modules.h"
#include "pango-utils.h"
/*
* To Do: (Last Updated by prabhat - 08/24/02)
* A> Extend shapers to support ASCII + Script
* B> Eliminate Separate Script
* C> Look at improving the speed of cursor handling logic
*
*/
#define CLEAN_RUN \
aPtr = aRun.head; \
for (int ct=0; (ct < aRun.numRuns); ct++) { \
@ -81,14 +90,14 @@ nsULE::GetShaper(const PRUnichar *inBuf,
}
PRInt32
nsULE::SeparateScript(const PRUnichar* aSrcBuf,
PRInt32 aSrcLen,
textRunList *aRunList)
nsULE::ScriptsByRun(const PRUnichar *aSrcBuf,
PRInt32 aSrcLen,
textRunList *aRunList)
{
int ct = 0, start = 0;
PRBool isCtl = PR_FALSE;
PRBool sameCtlRun = PR_FALSE;
struct textRun *tmpChunk;
PangoEngineShape *aEngine = NULL;
PangoEngineShape *curEngine = NULL, *prevEngine = NULL;
PangoMap *aMap = NULL;
guint engine_type_id = 0, render_type_id = 0;
@ -108,26 +117,27 @@ nsULE::SeparateScript(const PRUnichar* aSrcBuf,
tmpChunk->start = &aSrcBuf[ct];
start = ct;
aEngine = (PangoEngineShape*)
curEngine = (PangoEngineShape*)
pango_map_get_engine(aMap, (PRUint32)aSrcBuf[ct]);
isCtl = (aEngine != NULL);
sameCtlRun = (curEngine != NULL);
prevEngine = curEngine;
if (isCtl) {
while (isCtl && ct < aSrcLen) {
aEngine = (PangoEngineShape*)
if (sameCtlRun) {
while (sameCtlRun && ct < aSrcLen) {
curEngine = (PangoEngineShape*)
pango_map_get_engine(aMap, (PRUint32)aSrcBuf[ct]);
isCtl = (aEngine != NULL);
if (isCtl)
sameCtlRun = ((curEngine != NULL) && (curEngine == prevEngine));
if (sameCtlRun)
ct++;
}
tmpChunk->isOther = PR_FALSE;
}
else {
while (!isCtl && ct < aSrcLen) {
aEngine = (PangoEngineShape*)
while (!sameCtlRun && ct < aSrcLen) {
curEngine = (PangoEngineShape*)
pango_map_get_engine(aMap, (PRUint32)aSrcBuf[ct]);
isCtl = (aEngine != NULL);
if (!isCtl)
sameCtlRun = (curEngine != NULL);
if (!sameCtlRun)
ct++;
}
tmpChunk->isOther = PR_TRUE;
@ -138,23 +148,42 @@ nsULE::SeparateScript(const PRUnichar* aSrcBuf,
return (PRInt32)aRunList->numRuns;
}
// Analysis needs to have valid direction and font charset
// Default font encoding by code-range
// At the moment pangoLite only supports 2 shapers/scripts
const char*
nsULE::GetDefaultFont(const PRUnichar aString)
{
if ((aString >= 0x0e01) && (aString <= 0x0e5b))
return "tis620-2";
else if ((aString >= 0x0901) && (aString <= 0x0970))
return "sun.unicode.india-0";
else
return "iso8859-1";
}
// Analysis needs to have valid direction
PRInt32
nsULE::GetRawCtlData(const PRUnichar *aString,
PRUint32 aLength,
PangoGlyphString *aGlyphs)
nsULE::GetCtlData(const PRUnichar *aString,
PRUint32 aLength,
PangoGlyphString *aGlyphs,
const char *fontCharset)
{
PangoEngineShape *aShaper = GetShaper(aString, aLength, (const char*)NULL);
PangoAnalysis aAnalysis;
aAnalysis.shape_engine = aShaper;
aAnalysis.aDir = PANGO_DIRECTION_LTR;
// In future fontCharset hard-coding should be removed
aAnalysis.fontCharset = strdup("tis620-2");
// Maybe find a better way to handle font encodings
if (fontCharset == NULL)
aAnalysis.fontCharset = strdup(GetDefaultFont(aString[0]));
else
aAnalysis.fontCharset = strdup(fontCharset);
if (aShaper != NULL) {
if (aShaper != NULL) {
aShaper->script_shape(aAnalysis.fontCharset, aString, aLength,
&aAnalysis, aGlyphs);
&aAnalysis, aGlyphs);
nsMemory::Free(aAnalysis.fontCharset);
}
else {
@ -171,27 +200,21 @@ nsULE::GetPresentationForm(const PRUnichar *aString,
char *aGlyphs,
PRSize *aOutLength)
{
PangoEngineShape *aShaper = GetShaper(aString, aLength, (const char*)NULL);
PangoAnalysis aAnalysis;
PangoGlyphString *tmpGlyphs = pango_glyph_string_new();
int aSize = 0;
aAnalysis.shape_engine = aShaper;
aAnalysis.aDir = PANGO_DIRECTION_LTR;
aAnalysis.fontCharset = (char*)fontCharset;
if (aShaper != NULL) {
aShaper->script_shape(fontCharset, aString, aLength,
&aAnalysis, tmpGlyphs);
if (tmpGlyphs->num_glyphs > 0) {
// Note : Does NOT handle 2 byte fonts
aSize = tmpGlyphs->num_glyphs;
// if (*aOutLength < aSize)
// trouble
for (int i = 0; i < aSize; i++)
aGlyphs[i] = tmpGlyphs->glyphs[i].glyph & 0xFF;
GetCtlData(aString, aLength, tmpGlyphs, fontCharset);
if (tmpGlyphs->num_glyphs > 0) {
guint i = 0, glyphCt = 0;
for (i = 0; i < tmpGlyphs->num_glyphs; i++, glyphCt++) {
if (tmpGlyphs->glyphs[i].glyph > 0xFF) {
aGlyphs[glyphCt]=(unsigned char)((tmpGlyphs->glyphs[i].glyph & 0xFF00) >> 8);
glyphCt++;
}
aGlyphs[glyphCt]=(unsigned char)(tmpGlyphs->glyphs[i].glyph & 0x00FF);
}
*aOutLength = (PRSize)aSize;
*aOutLength = (PRSize)glyphCt;
}
else {
/* No Shaper - Copy Input to output */
@ -221,7 +244,7 @@ nsULE::NextCluster(const PRUnichar *aString,
}
aRun.numRuns = 0;
SeparateScript(aString, aLength, &aRun);
ScriptsByRun(aString, aLength, &aRun);
aPtr = aRun.head;
for (int i=0; (i < aRun.numRuns); i++) {
@ -247,7 +270,7 @@ nsULE::NextCluster(const PRUnichar *aString,
PRInt32 j, startCt, beg, end, numCur;
startCt=aStrCt;
GetRawCtlData(aPtr->start, runLen, aGlyphData);
GetCtlData(aPtr->start, runLen, aGlyphData);
numCur=beg=0;
for (j=0; j<aGlyphData->num_glyphs; j++) {
@ -296,7 +319,7 @@ nsULE::PrevCluster(const PRUnichar *aString,
}
aRun.numRuns=0;
SeparateScript(aString, aLength, &aRun);
ScriptsByRun(aString, aLength, &aRun);
// Get the index of current cluster
aPtr=aRun.head;
@ -314,7 +337,7 @@ nsULE::PrevCluster(const PRUnichar *aString,
}
else { /* Move back a cluster */
startCt=aStrCt;
GetRawCtlData(aPtr->start, runLen, aGlyphData);
GetCtlData(aPtr->start, runLen, aGlyphData);
glyphct=aGlyphData->num_glyphs-1;
while (glyphct > 0) {
@ -340,7 +363,7 @@ nsULE::PrevCluster(const PRUnichar *aString,
PRInt32 j,beg,end,numPrev,numCur;
startCt=aStrCt;
GetRawCtlData(aPtr->start, runLen, aGlyphData);
GetCtlData(aPtr->start, runLen, aGlyphData);
numPrev=numCur=beg=0;
for (j=1; j<aGlyphData->num_glyphs; j++) {
@ -386,7 +409,7 @@ nsULE::GetRangeOfCluster(const PRUnichar *aString,
*aStart = *aEnd = 0;
aRun.numRuns=0;
SeparateScript(aString, aLength, &aRun);
ScriptsByRun(aString, aLength, &aRun);
// Get the index of current cluster
aPtr=aRun.head;
@ -405,7 +428,7 @@ nsULE::GetRangeOfCluster(const PRUnichar *aString,
PRInt32 beg,end,numCur;
startCt=aStrCt;
GetRawCtlData(aPtr->start, runLen, aGlyphData);
GetCtlData(aPtr->start, runLen, aGlyphData);
numCur=beg=0;
for (j=1; j<aGlyphData->num_glyphs; j++) {

View File

@ -1,7 +1,7 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* XPCTL : nsULE.h
*
* The contents of this file are subject to the Mozilla Public
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
@ -20,7 +20,8 @@
* by Red Hat Software. Portions created by Redhat are Copyright (C)
* 1999 Red Hat Software.
*
* Contributor(s):
* Contributor(s):
* Prabhat Hegde (prabhat.hegde@sun.com)
*/
#ifndef nsULE_H
@ -88,15 +89,13 @@ public:
PRInt32 *aEnd);
private:
// Housekeeping Members
void Init(void);
void CleanUp(void);
PangoEngineShape* GetShaper(const PRUnichar *, PRUint32, const char *);
PRInt32 GetRawCtlData(const PRUnichar*, PRUint32, PangoGlyphString*);
PRInt32 SeparateScript(const PRUnichar*, PRInt32, textRunList*);
const char* GetDefaultFont(const PRUnichar);
PangoEngineShape* GetShaper(const PRUnichar *, PRUint32, const char *);
PRInt32 GetCtlData(const PRUnichar*, PRUint32, PangoGlyphString*, const char* = (const char*)NULL);
PRInt32 ScriptsByRun(const PRUnichar*, PRInt32, textRunList*);
};
#endif /* nsULE_H */
#endif /* !nsULE_H */

View File

@ -0,0 +1,264 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* ucvhi : nsUnicodeToSunIndic.h
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
* The Initial Developer of the Original Code is Sun Microsystems,
* Inc. Portions created by SUN are Copyright (C) 2000 SUN
* Microsystems, Inc. All Rights Reserved.
*
* Contributor(s):
* Prabhat Hegde (prabhat.hegde@sun.com)
*/
#include "nsCOMPtr.h"
#include "nsCtlCIID.h"
#include "nsILE.h"
#include "nsULE.h"
#include "nsUnicodeToSunIndic.h"
NS_IMPL_ADDREF(nsUnicodeToSunIndic);
NS_IMPL_RELEASE(nsUnicodeToSunIndic);
PRInt32
nsUnicodeToSunIndic::Itemize(const PRUnichar* aSrcBuf, PRInt32 aSrcLen, textRunList *aRunList)
{
int ct = 0, start = 0;
PRBool isHindi = PR_FALSE;
struct textRun *tmpChunk;
// Handle Simple Case Now : Multiple Ranges later
PRUnichar hindiBeg = 2305; // U+0x0901;
PRUnichar hindiEnd = 2416; // U+0x097f;
for (ct = 0; ct < aSrcLen;) {
tmpChunk = new textRun;
if (aRunList->numRuns == 0)
aRunList->head = tmpChunk;
else
aRunList->cur->next = tmpChunk;
aRunList->cur = tmpChunk;
aRunList->numRuns++;
tmpChunk->start = &aSrcBuf[ct];
start = ct;
isHindi = (aSrcBuf[ct] >= hindiBeg && aSrcBuf[ct] <= hindiEnd);
if (isHindi) {
while (isHindi && ct < aSrcLen) {
isHindi = (aSrcBuf[ct] >= hindiBeg && aSrcBuf[ct] <= hindiEnd);
if (isHindi)
ct++;
}
tmpChunk->isOther = PR_FALSE;
}
else {
while (!isHindi && ct < aSrcLen) {
isHindi = (aSrcBuf[ct] >= hindiBeg && aSrcBuf[ct] <= hindiEnd);
if (!isHindi)
ct++;
}
tmpChunk->isOther = PR_TRUE;
}
tmpChunk->length = ct - start;
}
return (PRInt32)aRunList->numRuns;
}
nsresult nsUnicodeToSunIndic::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr)
return NS_ERROR_NULL_POINTER;
*aInstancePtr = NULL;
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(NS_GET_IID(nsIUnicodeEncoder))) {
*aInstancePtr = (void*) ((nsIUnicodeEncoder*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsICharRepresentable))) {
*aInstancePtr = (void*) ((nsICharRepresentable*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*) ((nsISupports*)((nsIUnicodeEncoder*)this));
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMETHODIMP nsUnicodeToSunIndic::SetOutputErrorBehavior(PRInt32 aBehavior,
nsIUnicharEncoder * aEncoder,
PRUnichar aChar)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
// constructor and destructor
nsUnicodeToSunIndic::nsUnicodeToSunIndic()
{
static NS_DEFINE_CID(kLECID, NS_ULE_CID);
nsresult rv;
NS_INIT_REFCNT();
mCtlObj = do_CreateInstance(kLECID, &rv);
if (NS_FAILED(rv)) {
#ifdef DEBUG_prabhat
// No other error handling needed here since we
// handle absence of mCtlObj in Convert
printf("ERROR: Cannot create instance of component " NS_ULE_PROGID " [%x].\n",
rv);
#endif
NS_WARNING("Indian Text Shaping Will Not Be Supported\n");
mCtlObj = nsnull;
}
}
nsUnicodeToSunIndic::~nsUnicodeToSunIndic()
{
// Maybe convert nsILE to a service
// No NS_IF_RELEASE(mCtlObj) of nsCOMPtr;
}
/*
* This method converts the unicode to this font index.
* Note: ConversionBufferFullException is not handled
* since this class is only used for character display.
*/
NS_IMETHODIMP nsUnicodeToSunIndic::Convert(const PRUnichar* input,
PRInt32* aSrcLength,
char* output,
PRInt32* aDestLength)
{
textRunList txtRuns;
textRun *aPtr, *aTmpPtr;
int i;
if (mCtlObj == nsnull) {
nsresult res;
#ifdef DEBUG_prabhath
printf("Debug/Test Case of No Hindi pango shaper Object\n");
// Comment out mCtlObj == nsnull for test purposes
printf("ERROR: No Hindi Text Layout Implementation");
#endif
NS_WARNING("cannot get default converter for Hindi");
return NS_ERROR_FAILURE;
}
mCharOff = mByteOff = 0;
txtRuns.numRuns = 0;
Itemize(input, *aSrcLength, &txtRuns);
aPtr = txtRuns.head;
for (i = 0; i < txtRuns.numRuns; i++) {
PRInt32 tmpSrcLen = aPtr->length;
if (aPtr->isOther) {
// PangoHindiShaper does not handle ASCII + Hindi in same shaper
for (int j = 0; j < tmpSrcLen; j++)
output[j + mByteOff] = (char)(*(aPtr->start + j));
mByteOff += tmpSrcLen;
}
else {
PRSize outLen = *aDestLength - mByteOff;
// At the moment only generate presentation forms for
// sun.unicode.india are supported.
mCtlObj->GetPresentationForm(aPtr->start, tmpSrcLen, "sun.unicode.india-0",
&output[mByteOff], &outLen);
mByteOff += outLen;
}
aPtr = aPtr->next;
}
// Cleanup Run Info;
aPtr = txtRuns.head;
for (i = 0; i < txtRuns.numRuns; i++) {
aTmpPtr = aPtr;
aPtr = aPtr->next;
delete aTmpPtr;
}
*aDestLength = mByteOff;
return NS_OK;
}
NS_IMETHODIMP nsUnicodeToSunIndic::Finish(char *output, PRInt32 *aDestLength)
{
// Finish does'nt have to do much as Convert already flushes
// to output buffer
mByteOff = mCharOff = 0;
return NS_OK;
}
//================================================================
NS_IMETHODIMP nsUnicodeToSunIndic::Reset()
{
mByteOff = mCharOff = 0;
return NS_OK;
}
//================================================================
NS_IMETHODIMP nsUnicodeToSunIndic::GetMaxLength(const PRUnichar * aSrc,
PRInt32 aSrcLength,
PRInt32 * aDestLength)
{
*aDestLength = (aSrcLength + 1) * 2; // Each Hindi character can generate
// atmost two presentation forms
return NS_OK;
}
//================================================================
NS_IMETHODIMP nsUnicodeToSunIndic::FillInfo(PRUint32* aInfo)
{
PRUint16 i;
// 00-0x7f
for (i = 0;i <= 0x7f; i++)
SET_REPRESENTABLE(aInfo, i);
// \u904, \u90a, \u93b, \u94e, \u94f are Undefined
for (i = 0x0901; i <= 0x0903; i++)
SET_REPRESENTABLE(aInfo, i);
for (i = 0x0905; i <= 0x0939; i++)
SET_REPRESENTABLE(aInfo, i);
for (i = 0x093c; i <= 0x094d; i++)
SET_REPRESENTABLE(aInfo, i);
for (i = 0x0950; i <= 0x0954; i++)
SET_REPRESENTABLE(aInfo, i);
for (i = 0x0958; i <= 0x0970; i++)
SET_REPRESENTABLE(aInfo, i);
// ZWJ and ZWNJ support & coverage need to be added.
return NS_OK;
}

View File

@ -0,0 +1,83 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* ucvth : nsUnicodeToSunIndic.h
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
* The Initial Developer of the Original Code is Sun Microsystems,
* Inc. Portions created by SUN are Copyright (C) 2000 SUN
* Microsystems, Inc. All Rights Reserved.
*
* Contributor(s):
* Prabhat Hegde (prabhat.hegde@sun.com)
*/
#ifndef nsUnicodeToSunIndic_h___
#define nsUnicodeToSunIndic_h___
#include "nspr.h"
#include "nsIFactory.h"
#include "nsIRegistry.h"
#include "nsIGenericFactory.h"
#include "nsIServiceManager.h"
#include "nsICharsetConverterManager.h"
#include "nsIModule.h"
#include "nsIUnicodeEncoder.h"
#include "nsICharRepresentable.h"
#include "nsILE.h"
struct textRunList;
//----------------------------------------------------------------------
// Class nsUnicodeToSunIndic [declaration]
class nsUnicodeToSunIndic : public nsIUnicodeEncoder, public nsICharRepresentable
{
NS_DECL_ISUPPORTS
public:
/**
* Class constructor.
*/
nsUnicodeToSunIndic();
virtual ~nsUnicodeToSunIndic();
NS_IMETHOD Convert(const PRUnichar * aSrc, PRInt32 * aSrcLength,
char * aDest, PRInt32 * aDestLength);
NS_IMETHOD Finish(char * aDest, PRInt32 * aDestLength);
NS_IMETHOD GetMaxLength(const PRUnichar * aSrc, PRInt32 aSrcLength,
PRInt32 * aDestLength);
NS_IMETHOD Reset();
NS_IMETHOD SetOutputErrorBehavior(PRInt32 aBehavior,
nsIUnicharEncoder * aEncoder,
PRUnichar aChar);
NS_IMETHOD FillInfo(PRUint32* aInfo);
private:
PRUint8 mState;
PRInt32 mByteOff;
PRInt32 mCharOff;
nsCOMPtr<nsILE> mCtlObj;
// beg and end denote ranges and may need to be expanded in the future to
// handle discontinous ranges
PRInt32 Itemize(const PRUnichar* aSrcBuf, PRInt32 aSrcLen, textRunList *aRunList);
};
#endif /* !nsUnicodeToSunIndic_h___ */

View File

@ -1,7 +1,7 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* ucvth : nsUnicodeToTIS620.h
*
* The contents of this file are subject to the Mozilla Public
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
@ -20,7 +20,8 @@
* Red Hat Software. Portions created by Redhat are Copyright (C)
* 1999 Red Hat Software.
*
* Contributor(s):
* Contributor(s):
* Prabhat Hegde (prabhat.hegde@sun.com)
*/
#include "nsCOMPtr.h"

View File

@ -1,7 +1,7 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* ucvth : nsUnicodeToTIS620.h
*
* The contents of this file are subject to the Mozilla Public
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
@ -20,7 +20,8 @@
* Red Hat Software. Portions created by Redhat are Copyright (C)
* 1999 Red Hat Software.
*
* Contributor(s):
* Contributor(s):
* Prabhat Hegde (prabhat.hegde@sun.com)
*/
#ifndef nsUnicodeToTIS620_h___
#define nsUnicodeToTIS620_h___
@ -81,4 +82,4 @@ private:
// handle discontinous ranges
PRInt32 Itemize(const PRUnichar* aSrcBuf, PRInt32 aSrcLen, textRunList *aRunList);
};
#endif /* nsUnicodeToTIS620_h___ */
#endif /* !nsUnicodeToTIS620_h___ */

View File

@ -1,5 +1,5 @@
# Pango Modules file
# Automatically generated file, do not edit
#
libmozpango-thaix.so ThaiScriptEngineX PangoEngineShape PangoRenderX 3585-3675:*
libmozpango-dvngx.so DvngScriptEngineX PangoEngineShape PangoRenderX 2305-2416:*

View File

@ -1,4 +1,4 @@
# The contents of this file are subject to the Mozilla Public
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
@ -13,7 +13,8 @@
# The Initial Developer of the Original Code is Red Hat Software
# Portions created by Red Hat are Copyright (C) 1999 Red Hat Software.
#
# Contributor(s):
# Contributor(s):
# Prabhat Hegde (prabhat.hegde@sun.com)
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU Lessor General Public License Version 2 (the

View File

@ -128,6 +128,7 @@ x-johab-noascii.LangGroup = ko
x-windows-949.LangGroup = ko
x-mac-hebrew.LangGroup = he
x-mac-arabic.LangGroup = ar
x-sun-unicode-india-0.LangGroup = hi-IN
utf-8.MIMEHeaderEncodingMethod = B
utf-8.MIMEMailCharset = utf-8

View File

@ -104,6 +104,8 @@ x-mac-hebrew.title = Hebrew (MacHebrew)
x-mac-devanagari.title = Hindi (MacDevanagari)
x-mac-gujarati.title = Gujarati (MacGujarati)
x-mac-gurmukhi.title = Gurmukhi (MacGurmukhi)
x-sun-unicode-india-0.title = Hindi (SunDevanagari)
chardet.off.title = (Off)
chardet.alis_charset_detector.title = All

View File

@ -63,6 +63,7 @@
<menuitem value="th" label="&font.langGroup.thai;"/>
<menuitem value="he" label="&font.langGroup.hebrew;"/>
<menuitem value="ar" label="&font.langGroup.arabic;"/>
<menuitem value="hi-IN" label="&font.langGroup.hi-IN;"/>
</menupopup>
</menulist>
</caption>

View File

@ -41,6 +41,7 @@
<!ENTITY font.langGroup.thai "Thai">
<!ENTITY font.langGroup.hebrew "Hebrew">
<!ENTITY font.langGroup.arabic "Arabic">
<!ENTITY font.langGroup.hi-IN "Hindi">
<!-- Minimum font size -->
<!ENTITY minSize.label "Minimum font size:">
<!ENTITY minSize.accesskey "z">