Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions
nsULE Class Reference

#include <nsULE.h>

Inheritance diagram for nsULE:
Inheritance graph
[legend]
Collaboration diagram for nsULE:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS nsULE (void)
virtual ~nsULE (void)
NS_IMETHOD NeedsCTLFix (const PRUnichar *aString, const PRInt32 aBeg, const PRInt32 aEnd, PRBool *aCTLNeeded)
NS_IMETHOD GetPresentationForm (const PRUnichar *aString, PRUint32 aLength, const char *aFontCharset, char *aGlyphs, PRSize *aOutLength, PRBool aIsWide=PR_FALSE)
NS_IMETHOD PrevCluster (const PRUnichar *aString, PRUint32 aLength, const PRInt32 aIndex, PRInt32 *aPrevOffset)
NS_IMETHOD NextCluster (const PRUnichar *aString, PRUint32 aLength, const PRInt32 aIndex, PRInt32 *aNextOffset)
NS_IMETHOD GetRangeOfCluster (const PRUnichar *aString, PRUint32 aLength, const PRInt32 aIndex, PRInt32 *aStart, PRInt32 *aEnd)

Private Member Functions

const char * GetDefaultFont (const PRUnichar)
PRInt32 GetGlyphInfo (const PRUnichar *, PRInt32, PangoliteGlyphString *, const char *=(const char *) NULL)

Detailed Description

Definition at line 53 of file nsULE.h.


Constructor & Destructor Documentation

Definition at line 56 of file nsULE.cpp.

             {
}
nsULE::~nsULE ( void  ) [virtual]

Definition at line 59 of file nsULE.cpp.

              {
}

Member Function Documentation

const char * nsULE::GetDefaultFont ( const PRUnichar  aString) [private]

Definition at line 67 of file nsULE.cpp.

{
  if ((aString >= 0x0e01) && (aString <= 0x0e5b))
    return "tis620-2";
  if ((aString >= 0x0901) && (aString <= 0x0970))
    return "sun.unicode.india-0";
  return "iso8859-1";
}

Here is the caller graph for this function:

PRInt32 nsULE::GetGlyphInfo ( const PRUnichar aSrcBuf,
PRInt32  aSrcLen,
PangoliteGlyphString *  aGlyphData,
const char *  aFontCharset = (const char*)NULL 
) [private]

Definition at line 77 of file nsULE.cpp.

{
  int                  ct=0, start=0, i, index, startgid, lastCluster=0;
  PRBool               sameCtlRun=PR_FALSE;
  PangoliteEngineShape *curShaper=NULL, *prevShaper=NULL;
  PangoliteMap         *pngMap=NULL;
  PangoliteAnalysis    pngAnalysis;
  guint                enginetypeId=0, rendertypeId=0;

  pngAnalysis.aDir = PANGO_DIRECTION_LTR;
 
  // Maybe find a better way to handle font encodings
  if (aFontCharset == NULL)
    pngAnalysis.fontCharset = strdup(GetDefaultFont(aSrcBuf[0]));
  else
    pngAnalysis.fontCharset = strdup(aFontCharset);

  enginetypeId = g_quark_from_static_string(PANGO_ENGINE_TYPE_SHAPE);
  rendertypeId = g_quark_from_static_string(PANGO_RENDER_TYPE_X);
  pngMap = pangolite_find_map("en_US", enginetypeId, rendertypeId);

  for (ct=0; ct < aSrcLen;) {
    start = ct;
    curShaper = (PangoliteEngineShape*)
      pangolite_map_get_engine(pngMap, (PRUint32)aSrcBuf[ct++]);
    sameCtlRun = (curShaper != NULL);
    prevShaper = curShaper;

    if (sameCtlRun) {
      while (sameCtlRun && ct < aSrcLen) {
        curShaper = (PangoliteEngineShape*)
          pangolite_map_get_engine(pngMap, (PRUint32)aSrcBuf[ct]);
        sameCtlRun = ((curShaper != NULL) && (curShaper == prevShaper));
        if (sameCtlRun)
          ct++;
      }
      startgid = aGlyphData->num_glyphs;
      pngAnalysis.shape_engine = curShaper;
      prevShaper->script_shape(pngAnalysis.fontCharset,
                               &aSrcBuf[start], (ct-start),
                               &pngAnalysis, aGlyphData);
      if (lastCluster > 0) {
         for (i=startgid; i < aGlyphData->num_glyphs; i++)
           aGlyphData->log_clusters[i] += lastCluster;
      }
    }
    else {
      while (!sameCtlRun && ct < aSrcLen) {
        curShaper = (PangoliteEngineShape*)
          pangolite_map_get_engine(pngMap, (PRUint32)aSrcBuf[ct]);
        sameCtlRun = (curShaper != NULL);
        if (!sameCtlRun)
          ct++;
      }
      index = aGlyphData->num_glyphs;
      for (i=0; i < (ct-start); i++) {
        pangolite_glyph_string_set_size(aGlyphData, index+1);
        aGlyphData->glyphs[index].glyph = aSrcBuf[start+i];
        aGlyphData->glyphs[index].is_cluster_start = (gint)1;
        aGlyphData->log_clusters[index] = i+lastCluster;
        index++;
      }
    }
    lastCluster = aGlyphData->log_clusters[aGlyphData->num_glyphs-1];
  }
  nsMemory::Free(pngAnalysis.fontCharset);
  return aGlyphData->num_glyphs;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsULE::GetPresentationForm ( const PRUnichar aString,
PRUint32  aLength,
const char *  aFontCharset,
char *  aGlyphs,
PRSize aOutLength,
PRBool  aIsWide = PR_FALSE 
) [virtual]

Implements nsILE.

Definition at line 186 of file nsULE.cpp.

{
  PangoliteGlyphString *tmpGlyphs=pangolite_glyph_string_new();

  GetGlyphInfo(aString, aLength, tmpGlyphs, aFontCharset);

  if (tmpGlyphs->num_glyphs > 0) {
    gint i=0, glyphCt=0;
    for (i=0; i < tmpGlyphs->num_glyphs; i++, glyphCt++) {
      if (aIsWide)
         aGlyphs[glyphCt++]=(unsigned char)
                            ((tmpGlyphs->glyphs[i].glyph & 0xFF00) >> 8);
      aGlyphs[glyphCt]=(unsigned char)(tmpGlyphs->glyphs[i].glyph & 0x00FF);
    }
    *aOutLength = (PRSize)glyphCt;
  }
  pangolite_glyph_string_free(tmpGlyphs);
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsULE::GetRangeOfCluster ( const PRUnichar aString,
PRUint32  aLength,
const PRInt32  aIndex,
PRInt32 aStart,
PRInt32 aEnd 
) [virtual]

Implements nsILE.

Definition at line 271 of file nsULE.cpp.

{
  PangoliteGlyphString *GlyphInfo=pangolite_glyph_string_new();
  int                  gCt=0;

  GetGlyphInfo(aString, aLength, GlyphInfo, NULL);

  *aStart=*aEnd=0;
  for (gCt=0; gCt < GlyphInfo->num_glyphs; gCt++) {

    if (GlyphInfo->glyphs[gCt].is_cluster_start != GLYPH_COMBINING)
       *aEnd += GlyphInfo->glyphs[gCt].is_cluster_start;

    if (*aEnd >= aIndex+1) {
      pangolite_glyph_string_free(GlyphInfo);
      return NS_OK;
    }
    *aStart = *aEnd;
  }
  *aEnd = aLength;
  pangolite_glyph_string_free(GlyphInfo);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsULE::NeedsCTLFix ( const PRUnichar aString,
const PRInt32  aBeg,
const PRInt32  aEnd,
PRBool aCTLNeeded 
) [virtual]

Implements nsILE.

Definition at line 150 of file nsULE.cpp.

{
  PangoliteEngineShape *BegShaper=NULL, *EndShaper=NULL;
  PangoliteMap         *pngMap=NULL;
  guint                enginetypeId=0, rendertypeId=0;

  enginetypeId = g_quark_from_static_string(PANGO_ENGINE_TYPE_SHAPE);
  rendertypeId = g_quark_from_static_string(PANGO_RENDER_TYPE_X);
  pngMap = pangolite_find_map("en_US", enginetypeId, rendertypeId);

  *aCTLNeeded = PR_FALSE;
  if (aBeg >= 0)
    BegShaper = (PangoliteEngineShape*)
      pangolite_map_get_engine(pngMap, (PRUint32)aString[aBeg]);

  if (!BegShaper) {

    if ((aEnd < 0) && ((aBeg+aEnd) >= 0)) {
      EndShaper = (PangoliteEngineShape*)
        pangolite_map_get_engine(pngMap, (PRUint32)aString[aBeg+aEnd]);
    }
    else {
      EndShaper = (PangoliteEngineShape*)
        pangolite_map_get_engine(pngMap, (PRUint32)aString[aEnd]);
    }
  }

  if (BegShaper || EndShaper)
    *aCTLNeeded = PR_TRUE;
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsULE::NextCluster ( const PRUnichar aString,
PRUint32  aLength,
const PRInt32  aIndex,
PRInt32 aNextOffset 
) [virtual]

Implements nsILE.

Definition at line 214 of file nsULE.cpp.

{
  int mStart, mEnd;

  if (aIndex < 0) {
    *aNextOffset = 0;
    return NS_OK;
  }

  if (PRUint32(aIndex) >= aLength) {
    *aNextOffset = aLength;
    return NS_OK;
  }
  this->GetRangeOfCluster(aString, aLength, aIndex, &mStart, &mEnd);
  *aNextOffset = mEnd;
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsULE::PrevCluster ( const PRUnichar aString,
PRUint32  aLength,
const PRInt32  aIndex,
PRInt32 aPrevOffset 
) [virtual]

Implements nsILE.

Definition at line 238 of file nsULE.cpp.

{
  int                  gCt, pCluster, cCluster;
  PangoliteGlyphString *GlyphInfo=pangolite_glyph_string_new();

  if (aIndex <= 1) {
    *aPrevOffset = 0;
    return NS_OK;
  }
  pCluster=cCluster=0;
  GetGlyphInfo(aString, aLength, GlyphInfo, NULL);
  for (gCt=0; gCt < GlyphInfo->num_glyphs; gCt++) {

    if (GlyphInfo->glyphs[gCt].is_cluster_start != GLYPH_COMBINING)
       cCluster += GlyphInfo->glyphs[gCt].is_cluster_start;

    if (cCluster >= aIndex) {
       *aPrevOffset = pCluster;
       pangolite_glyph_string_free(GlyphInfo);
       return NS_OK;
    }
    pCluster = cCluster;
  }
  *aPrevOffset = pCluster;
  pangolite_glyph_string_free(GlyphInfo);
  return NS_OK;
}

Here is the call graph for this function:


The documentation for this class was generated from the following files: