Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions | Variables
nsFontMetricsXlib.cpp File Reference
#include <sys/types.h>
#include "gfx-config.h"
#include "nscore.h"
#include "nsQuickSort.h"
#include "nsFontMetricsXlib.h"
#include "nsIServiceManager.h"
#include "nsICharsetConverterManager.h"
#include "nsILanguageAtomService.h"
#include "nsISaveAsCharset.h"
#include "nsIPref.h"
#include "nsCOMPtr.h"
#include "nsPrintfCString.h"
#include "nspr.h"
#include "nsHashtable.h"
#include "nsReadableUtils.h"
#include "nsAString.h"
#include "nsXPIDLString.h"
#include "xlibrgb.h"
#include "nsUnicharUtils.h"
#include <regex.h>
#include <X11/Xatom.h>
#include "dbyte_special_chars.ccmap"

Go to the source code of this file.

Classes

class  nsFontMetricsXlibContext
struct  nsFontCharSetInfoXlib
struct  nsFontFamilyXlib
struct  nsFontFamilyNameXlib
struct  nsFontPropertyNameXlib
class  nsFontXlibNormal
class  nsFontXlibSubstitute
class  nsFontXlibUserDefined
struct  EnumerateNodeInfo

Defines

#define ENABLE_X_FONT_BANNING   1
#define UCS2_NOMAPPING   0XFFFD
#define REG_OK   (0)
#define USER_DEFINED   "x-user-def"
#define FONT_MAX_FONT_SCALE   2
#define MAX_ALIGN_BYTES   (sizeof(void *) * 2)
#define ALIGN_PTR(ptr)   ((void *)(((PRUptrdiff)(ptr) & ~(MAX_ALIGN_BYTES-1L)) + MAX_ALIGN_BYTES))
#define NOT_FOUND_FONT_SIZE   1000*1000*1000
#define GET_WEIGHT_INDEX(index, weight)
#define FIND_FIELD(var)
#define SKIP_FIELD(var)
#define BOOL2STR(b)   ((b)?("true"):("false"))

Typedefs

typedef struct EnumerateNodeInfo EnumerateNodeInfo

Functions

static PRBool FreeNode (nsHashKey *aKey, void *aData, void *aClosure)
static const nsFontCharSetMapXlibGetCharSetMap (nsFontMetricsXlibContext *aFmctx, const char *aCharSetName)
static void SetCharsetLangGroup (nsFontMetricsXlibContext *aFmctx, nsFontCharSetInfoXlib *aCharSetInfo)
static int SingleByteConvert (nsFontCharSetInfoXlib *aSelf, XFontStruct *aFont, const PRUnichar *aSrcBuf, PRInt32 aSrcLen, char *aDestBuf, PRInt32 aDestLen)
static int DoubleByteConvert (nsFontCharSetInfoXlib *aSelf, XFontStruct *aFont, const PRUnichar *aSrcBuf, PRInt32 aSrcLen, char *aDestBuf, PRInt32 aDestLen)
static int ISO10646Convert (nsFontCharSetInfoXlib *aSelf, XFontStruct *aFont, const PRUnichar *aSrcBuf, PRInt32 aSrcLen, char *aDestBuf, PRInt32 aDestLen)
static PRBool CopyFontCharSetMapXlib (nsFontMetricsXlibContext *aFmctx)
static char * atomToName (nsIAtom *aAtom)
 DEFINE_CCMAP (gDoubleByteSpecialCharsCCMap, const)
static PRBool FreeCharSetMap (nsHashKey *aKey, void *aData, void *aClosure)
static PRBool FreeFamily (nsHashKey *aKey, void *aData, void *aClosure)
static void FreeStretch (nsFontStretchXlib *aStretch)
static void FreeWeight (nsFontWeightXlib *aWeight)
static void FreeStyle (nsFontStyleXlib *aStyle)
static PRBool FreeNodeArray (nsHashKey *aKey, void *aData, void *aClosure)
nsresult CreateFontMetricsXlibContext (nsIDeviceContext *aDevice, PRBool aPrintermode, nsFontMetricsXlibContext **aFontMetricsXlibContext)
void DeleteFontMetricsXlibContext (nsFontMetricsXlibContext *aFontMetricsXlibContext)
static PRBool IsASCIIFontName (const nsString &aName)
static PRBool FontEnumCallback (const nsString &aFamily, PRBool aGeneric, void *aData)
static PRBool SetUpFontCharSetInfo (nsFontMetricsXlibContext *aFmctx, nsFontCharSetInfoXlib *aSelf)
static PRUint16GetMapFor10646Font (XFontStruct *aFont)
static PRBool SetFontCharsetInfo (nsFontXlib *aFont, nsFontCharSetInfoXlib *aCharSet, PRUnichar aChar)
static nsFontXlibSetupUserDefinedFont (nsFontMetricsXlibContext *aFmctx, nsFontXlib *aFont)
static PR_BEGIN_EXTERN_C int CompareSizes (const void *aArg1, const void *aArg2, void *data)
static void SetFontLangGroupInfo (nsFontMetricsXlibContext *aFmctx, const nsFontCharSetMapXlib *aCharSetMap)
static nsFontStyleXlibNodeGetStyle (nsFontNodeXlib *aNode, int aStyleIndex)
static nsFontWeightXlibNodeGetWeight (nsFontStyleXlib *aStyle, int aWeightIndex)
static nsFontStretchXlibNodeGetStretch (nsFontWeightXlib *aWeight, int aStretchIndex)
static PRBool NodeAddScalable (nsFontStretchXlib *aStretch, PRBool aOutlineScaled, const char *aDashFoundry, const char *aFamily, const char *aWeight, const char *aSlant, const char *aWidth, const char *aStyle, const char *aSpacing, const char *aCharSet)
static PRBool NodeAddSize (nsFontMetricsXlibContext *aFmctx, nsFontStretchXlib *aStretch, int aPixelSize, int aPointSize, float scaler, int aResX, int aResY, const char *aDashFoundry, const char *aFamily, const char *aWeight, const char *aSlant, const char *aWidth, const char *aStyle, const char *aSpacing, const char *aCharSet, nsFontCharSetInfoXlib *aCharSetInfo)
static void GetFontNames (nsFontMetricsXlibContext *aFmctx, const char *aPattern, PRBool aAnyFoundry, PRBool aOnlyOutlineScaledFonts, nsFontNodeArrayXlib *aNodes)
static nsresult GetAllFontNames (nsFontMetricsXlibContext *aFmctx)
static nsFontFamilyXlibFindFamily (nsFontMetricsXlibContext *aFmctx, nsCString *aName)
static void FFREToXLFDPattern (nsACString &aFFREName, nsACString &oPattern)
static void FFRESubstituteCharset (nsACString &aFFREName, const char *aReplacementCharset)
static void FFRESubstituteEncoding (nsACString &aFFREName, const char *aReplacementEncoding)
static void PrefEnumCallback (const char *aName, void *aClosure)
static PRIntn EnumerateNode (void *aElement, void *aData)
static PR_BEGIN_EXTERN_C int CompareFontNames (const void *aArg1, const void *aArg2, void *aClosure)
static PR_END_EXTERN_C nsresult EnumFonts (nsFontMetricsXlibContext *aFmctx, nsIAtom *aLangGroup, const char *aGeneric, PRUint32 *aCount, PRUnichar ***aResult)

Variables

static PRUint32 gFontDebug = 0 | NS_FONT_DEBUG_FONT_SCAN
static nsFontCharSetInfoXlib Unknown = { nsnull }
static nsFontCharSetInfoXlib Special = { nsnull }
static nsFontCharSetInfoXlib USASCII
static nsFontCharSetInfoXlib ISO88591
static nsFontCharSetInfoXlib ISO88592
static nsFontCharSetInfoXlib ISO88593
static nsFontCharSetInfoXlib ISO88594
static nsFontCharSetInfoXlib ISO88595
static nsFontCharSetInfoXlib ISO88596
static nsFontCharSetInfoXlib ISO885968x
static nsFontCharSetInfoXlib ISO8859616
static nsFontCharSetInfoXlib IBM1046
static nsFontCharSetInfoXlib ISO88597
static nsFontCharSetInfoXlib ISO88598
static nsFontCharSetInfoXlib ISO88599
static nsFontCharSetInfoXlib ISO885913
static nsFontCharSetInfoXlib ISO885915
static nsFontCharSetInfoXlib JISX0201
static nsFontCharSetInfoXlib KOI8R
static nsFontCharSetInfoXlib KOI8U
static nsFontCharSetInfoXlib TIS6202
static nsFontCharSetInfoXlib TIS620
static nsFontCharSetInfoXlib ISO885911
static nsFontCharSetInfoXlib Big5
static nsFontCharSetInfoXlib Big5TWHK
static nsFontCharSetInfoXlib CNS116431
static nsFontCharSetInfoXlib CNS116432
static nsFontCharSetInfoXlib CNS116433
static nsFontCharSetInfoXlib CNS116434
static nsFontCharSetInfoXlib CNS116435
static nsFontCharSetInfoXlib CNS116436
static nsFontCharSetInfoXlib CNS116437
static nsFontCharSetInfoXlib GB2312
static nsFontCharSetInfoXlib GB18030_0
static nsFontCharSetInfoXlib GB18030_1
static nsFontCharSetInfoXlib GBK
static nsFontCharSetInfoXlib HKSCS
static nsFontCharSetInfoXlib JISX0208
static nsFontCharSetInfoXlib JISX0212
static nsFontCharSetInfoXlib KSC5601
static nsFontCharSetInfoXlib X11Johab
static nsFontCharSetInfoXlib JohabNoAscii
static nsFontCharSetInfoXlib JamoTTF
static nsFontCharSetInfoXlib TamilTTF
static nsFontCharSetInfoXlib CP1250
static nsFontCharSetInfoXlib CP1251
static nsFontCharSetInfoXlib CP1252
static nsFontCharSetInfoXlib CP1253
static nsFontCharSetInfoXlib CP1257
static nsFontCharSetInfoXlib ISO106461
static nsFontCharSetInfoXlib AdobeSymbol
static nsFontCharSetInfoXlib AdobeEuro
static nsFontLangGroupXlib FLG_WESTERN = { "x-western", nsnull }
static nsFontLangGroupXlib FLG_BALTIC = { "x-baltic", nsnull }
static nsFontLangGroupXlib FLG_CE = { "x-central-euro",nsnull }
static nsFontLangGroupXlib FLG_RUSSIAN = { "x-cyrillic", nsnull }
static nsFontLangGroupXlib FLG_GREEK = { "el", nsnull }
static nsFontLangGroupXlib FLG_TURKISH = { "tr", nsnull }
static nsFontLangGroupXlib FLG_HEBREW = { "he", nsnull }
static nsFontLangGroupXlib FLG_ARABIC = { "ar", nsnull }
static nsFontLangGroupXlib FLG_THAI = { "th", nsnull }
static nsFontLangGroupXlib FLG_ZHCN = { "zh-CN", nsnull }
static nsFontLangGroupXlib FLG_ZHTW = { "zh-TW", nsnull }
static nsFontLangGroupXlib FLG_ZHHK = { "zh-HK", nsnull }
static nsFontLangGroupXlib FLG_ZHTWHK = { "x-zh-TWHK", nsnull }
static nsFontLangGroupXlib FLG_JA = { "ja", nsnull }
static nsFontLangGroupXlib FLG_KO = { "ko", nsnull }
static nsFontLangGroupXlib FLG_TAMIL = { "x-tamil", nsnull }
static nsFontLangGroupXlib FLG_NONE = { nsnull, nsnull }
static const nsFontCharSetMapXlib gConstCharSetMap []
static const nsFontFamilyNameXlib gFamilyNameTable []
static const nsFontCharSetMapXlib gConstNoneCharSetMap [] = { { nsnull }, }
static const nsFontCharSetMapXlib gConstSpecialCharSetMap []
static const nsFontPropertyNameXlib gStretchNames []
static const nsFontPropertyNameXlib gWeightNames []
static nsFontMetricsXlibContextglobal_fmctx = nsnull

Class Documentation

struct nsFontCharSetInfoXlib

Definition at line 233 of file nsFontMetricsXlib.cpp.

Collaboration diagram for nsFontCharSetInfoXlib:
Class Members
nsFontCharSetConverterXlib Convert
double mBitmapOversize
PRInt32 mBitmapScaleMin
double mBitmapUndersize
PRUint16 * mCCMap
const char * mCharSet
nsIUnicodeEncoder * mConverter
PRBool mInitedSizeInfo
nsIAtom * mLangGroup
PRInt32 mOutlineScaleMin
PRUint8 mSpecialUnderline
struct nsFontFamilyXlib

Definition at line 258 of file nsFontMetricsXlib.cpp.

Collaboration diagram for nsFontFamilyXlib:
Class Members
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
nsFontNodeArrayXlib
mNodes
struct nsFontFamilyNameXlib

Definition at line 265 of file nsFontMetricsXlib.cpp.

Class Members
const char * mName
const char * mXName
struct nsFontPropertyNameXlib

Definition at line 271 of file nsFontMetricsXlib.cpp.

Collaboration diagram for nsFontPropertyNameXlib:
Class Members
const char * mName
int mValue
struct nsFontSearch

Definition at line 2575 of file nsFontMetricsGTK.cpp.

Collaboration diagram for nsFontSearch:
Class Members
PRUint32 mChar
PRUnichar mChar
nsFontGTK * mFont
nsFontXlib * mFont
nsFontMetricsGTK * mMetrics
nsFontMetricsXlib * mMetrics
struct EnumerateNodeInfo

Definition at line 6609 of file nsFontMetricsGTK.cpp.

Collaboration diagram for EnumerateNodeInfo:
Class Members
PRUnichar ** mArray
nsFontMetricsXlibContext * mFontMetricsContext
int mIndex
nsIAtom * mLangGroup

Define Documentation

#define ALIGN_PTR (   ptr)    ((void *)(((PRUptrdiff)(ptr) & ~(MAX_ALIGN_BYTES-1L)) + MAX_ALIGN_BYTES))
#define BOOL2STR (   b)    ((b)?("true"):("false"))

Definition at line 47 of file nsFontMetricsXlib.cpp.

#define FIND_FIELD (   var)
Value:
char* var = p;                  \
  while ((*p) && ((*p) != '-')) { \
    p++;                          \
  }                               \
  if (*p) {                       \
    *p++ = 0;                     \
  }                               \
  else {                          \
    continue;                     \
  }

Definition at line 108 of file nsFontMetricsXlib.cpp.

#define GET_WEIGHT_INDEX (   index,
  weight 
)
Value:
do {                                  \
    (index) = WEIGHT_INDEX(weight);     \
    if ((index) < 0) {                  \
      (index) = 0;                      \
    }                                   \
    else if ((index) > 8) {             \
      (index) = 8;                      \
    }                                   \
  } while (0)

Definition at line 4253 of file nsFontMetricsXlib.cpp.

#define MAX_ALIGN_BYTES   (sizeof(void *) * 2)
#define NOT_FOUND_FONT_SIZE   1000*1000*1000

Definition at line 3704 of file nsFontMetricsXlib.cpp.

#define REG_OK   (0)

Definition at line 97 of file nsFontMetricsXlib.cpp.

#define SKIP_FIELD (   var)
Value:
while ((*p) && ((*p) != '-')) { \
    p++;                          \
  }                               \
  if (*p) {                       \
    p++;                          \
  }                               \
  else {                          \
    continue;                     \
  }
#define UCS2_NOMAPPING   0XFFFD

Definition at line 88 of file nsFontMetricsXlib.cpp.

#define USER_DEFINED   "x-user-def"

Definition at line 102 of file nsFontMetricsXlib.cpp.


Typedef Documentation


Function Documentation

static char* atomToName ( nsIAtom aAtom) [static]

Definition at line 1085 of file nsFontMetricsXlib.cpp.

{
  const char *namePRU;
  aAtom->GetUTF8String(&namePRU);
  return ToNewCString(nsDependentCString(namePRU));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PR_BEGIN_EXTERN_C int CompareFontNames ( const void aArg1,
const void aArg2,
void aClosure 
) [static]

Definition at line 5925 of file nsFontMetricsXlib.cpp.

{
  const PRUnichar* str1 = *((const PRUnichar**) aArg1);
  const PRUnichar* str2 = *((const PRUnichar**) aArg2);

  // XXX add nsICollation stuff

  return nsCRT::strcmp(str1, str2);
}

Here is the caller graph for this function:

static PR_BEGIN_EXTERN_C int CompareSizes ( const void aArg1,
const void aArg2,
void data 
) [static]

Definition at line 4037 of file nsFontMetricsXlib.cpp.

{
  return (*((nsFontXlib**) aArg1))->mSize - (*((nsFontXlib**) aArg2))->mSize;
}

Here is the caller graph for this function:

Definition at line 950 of file nsFontMetricsXlib.cpp.

{
  long                        size1[3],
                              size2[3],
                              size3[3];
  int                         i,
                              j,
                              k,
                              l,
                              count[3];
  char                       *s;
  const nsFontCharSetMapXlib *fcsm[3];
  nsFontCharSetMapXlib       *copy[3];
  nsFontLangGroupXlib        *langgroup;
  nsFontCharSetInfoXlib      *charsetinfo;

  fcsm[0] = gConstCharSetMap;
  fcsm[1] = gConstNoneCharSetMap;
  fcsm[2] = gConstSpecialCharSetMap; 
  
  size1[0] = size2[0] = size3[0] = 0;
  size1[1] = size2[1] = size3[1] = 0;
  size1[2] = size2[2] = size3[2] = 0;

/* Alignment macros to force memory alignment required by most RISC platforms
 * MAX_ALIGN_BYTES = sizeof(pointer) incl. the doubleword alignment required
 * by some platforms, ALIGN_PTR() aligns the given pointer to match
 * MAX_ALIGN_BYTES alignment
 * XXX: NSPR should define that...
 */
#define MAX_ALIGN_BYTES (sizeof(void *) * 2)
#define ALIGN_PTR(ptr) ((void *)(((PRUptrdiff)(ptr) & ~(MAX_ALIGN_BYTES-1L)) + MAX_ALIGN_BYTES))

  for( l = 0 ; l < 3 ; l++ )
  {  
    /* Count entries in fcsm */
    for( count[l]=0 ; fcsm[l][count[l]].mName ; count[l]++ ) ;

    count[l]++;
    size1[l] = sizeof(nsFontCharSetMapXlib)   * count[l] + MAX_ALIGN_BYTES;
    size2[l] = sizeof(nsFontLangGroupXlib)    * count[l] + MAX_ALIGN_BYTES;
    size3[l] = sizeof(nsFontCharSetInfoXlib)  * count[l] + MAX_ALIGN_BYTES;
    count[l]--;
  }
  
  s = (char *)calloc(1, size1[0]+size2[0]+size3[0]+
                        size1[1]+size2[1]+size3[1]+
                        size1[2]+size2[2]+size3[2]);
  if (!s)
    return PR_FALSE;

  /* Note that the pointer in |copy[0]| is stored in |mCharSetMap| later which
   * is finally passed to |free()| when the nsFontMetricsXlibContext destructor
   * is called. */
  copy[0]     = (nsFontCharSetMapXlib *)s;             s += size1[0];
  copy[1]     = (nsFontCharSetMapXlib *)ALIGN_PTR(s);  s += size1[1];
  copy[2]     = (nsFontCharSetMapXlib *)ALIGN_PTR(s);  s += size1[2];
  langgroup   = (nsFontLangGroupXlib  *)ALIGN_PTR(s);  s += size2[0] + size2[1] + size2[2];
  charsetinfo = (nsFontCharSetInfoXlib *)ALIGN_PTR(s);

  for( l = 0 ; l < 3 ; l++ )
  { 
    for( i = 0 ; i < count[l] ; i++ )
    {
      copy[l][i].mName = fcsm[l][i].mName;

      if (!copy[l][i].mFontLangGroup)
      {
        nsFontLangGroupXlib *slot = langgroup++;
        *slot = *fcsm[l][i].mFontLangGroup;
        copy[l][i].mFontLangGroup = slot;

        for( k = 0 ; k < 3 ; k++ )
        {
          for( j = 0 ; j < count[k] ; j++ )
          {
            if ((!copy[k][j].mFontLangGroup) && 
                (fcsm[k][j].mFontLangGroup == fcsm[l][i].mFontLangGroup))
            {
              copy[k][j].mFontLangGroup = slot;
            }
          }
        }
      }

      if (!copy[l][i].mInfo)
      {
        nsFontCharSetInfoXlib *slot = charsetinfo++;

        if (fcsm[l][i].mInfo == &Unknown)
        {
          aFmctx->mUnknown = slot;
        }
        else if (fcsm[l][i].mInfo == &Special)
        {
          aFmctx->mSpecial = slot;
        }
        else if (fcsm[l][i].mInfo == &ISO106461)
        {
          aFmctx->mISO106461 = slot;
        }

        *slot = *fcsm[l][i].mInfo;

        copy[l][i].mInfo = slot;

        for( k = 0 ; k < 3 ; k++ )
        {
          for( j = 0 ; j < count[k] ; j++ )
          {
            if ((!copy[k][j].mInfo) && 
                (fcsm[k][j].mInfo == fcsm[l][i].mInfo))
            {
              copy[k][j].mInfo = slot;
            }
          }
        }
      }
    }
  }
  
  aFmctx->mCharSetMap        = copy[0];
  aFmctx->mNoneCharSetMap    = copy[1];
  aFmctx->mSpecialCharSetMap = copy[2];

#ifdef DEBUG_copyfontcharsetmap
  DumpFontCharSetMap(aFmctx->mCharSetMap);
  DumpFontCharSetMap(aFmctx->mNoneCharSetMap);
  DumpFontCharSetMap(aFmctx->mSpecialCharSetMap);
#endif /* DEBUG_copyfontcharsetmap */
  
  return PR_TRUE; 
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult CreateFontMetricsXlibContext ( nsIDeviceContext aDevice,
PRBool  aPrintermode,
nsFontMetricsXlibContext **  aFontMetricsXlibContext 
)

Definition at line 1252 of file nsFontMetricsXlib.cpp.

{
  nsresult                  rv;
  nsFontMetricsXlibContext *fmctx;
  
  *aFontMetricsXlibContext = nsnull;
  
  fmctx = new nsFontMetricsXlibContext();
  if (!fmctx)
    return NS_ERROR_OUT_OF_MEMORY;
  
  rv = fmctx->Init(aDevice, aPrintermode);
  if ((NS_FAILED(rv))) {
    delete fmctx;
    return rv;
  }
  
  *aFontMetricsXlibContext = fmctx;
  
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

DEFINE_CCMAP ( gDoubleByteSpecialCharsCCMap  ,
const   
)

Definition at line 1274 of file nsFontMetricsXlib.cpp.

{
  if (aFontMetricsXlibContext) {
    delete aFontMetricsXlibContext;
  }
}

Here is the caller graph for this function:

static int DoubleByteConvert ( nsFontCharSetInfoXlib aSelf,
XFontStruct *  aFont,
const PRUnichar aSrcBuf,
PRInt32  aSrcLen,
char *  aDestBuf,
PRInt32  aDestLen 
) [static]

Definition at line 2689 of file nsFontMetricsXlib.cpp.

{
  int count;
  if (aSelf->mConverter) {
    aSelf->mConverter->Convert(aSrcBuf, &aSrcLen, aDestBuf, &aDestLen);
    count = aDestLen;
    if (count > 0) {
      if ((aDestBuf[0] & 0x80) && (!(aFont->max_byte1 & 0x80))) {
        for (PRInt32 i = 0; i < aDestLen; i++)
          aDestBuf[i] &= 0x7F;
      }
      // We're using a GL encoder (KSC5601 or GB2312) for a GR font
      // (ksc5601.1987-1 or gb2312.1980-1)
      else if ((!(aDestBuf[0] & 0x80)) && (aFont->min_byte1 & 0x80)) {
        for (PRInt32 i = 0; i < aDestLen; i++)
          aDestBuf[i] |= 0x80;
      }
    }
  }
  else {
    count = 0;
  }

  return count;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRIntn EnumerateNode ( void aElement,
void aData 
) [static]

Definition at line 5871 of file nsFontMetricsXlib.cpp.

{
  nsFontNodeXlib* node = (nsFontNodeXlib*) aElement;
  EnumerateNodeInfo* info = (EnumerateNodeInfo*) aData;
  nsFontMetricsXlibContext *aFmctx = info->mFontMetricsContext;
  if (info->mLangGroup != aFmctx->mUserDefined) {
    if (node->mCharSetInfo == aFmctx->mUnknown) {
      return PR_TRUE; // continue
    }
    else if (info->mLangGroup != aFmctx->mUnicode) {
      // if font's langGroup is different from requested langGroup, continue.
      // An exception is that font's langGroup ZHTWHK(big5-1, big5-0) matches 
      // both ZHTW and ZHHK (Freetype2 and Solaris).
      if (node->mCharSetInfo->mLangGroup != info->mLangGroup &&
         (node->mCharSetInfo->mLangGroup != aFmctx->mZHTWHK ||
         (info->mLangGroup != aFmctx->mZHHK && 
          info->mLangGroup != aFmctx->mZHTW))) {
        return PR_TRUE; // continue
      }
    }
    // else {
    //   if (lang == add-style-field) {
    //     consider it part of the lang group
    //   }
    //   else if (a Unicode font reports its lang group) {
    //     consider it part of the lang group
    //   }
    //   else if (lang's ranges in list of ranges) {
    //     consider it part of the lang group
    //     // Note: at present we have no way to do this test but we 
    //     // could in the future and this would be the place to enable
    //     // to make the font show up in the preferences dialog
    //   }
    // }

  }
  PRUnichar** array = info->mArray;
  int j = info->mIndex;
  PRUnichar* str = ToNewUnicode(node->mName);
  if (!str) {
    for (j = j - 1; j >= 0; j--) {
      nsMemory::Free(array[j]);
    }
    info->mIndex = 0;
    return PR_FALSE; // stop
  }
  array[j] = str;
  info->mIndex++;

  return PR_TRUE; // continue
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PR_END_EXTERN_C nsresult EnumFonts ( nsFontMetricsXlibContext aFmctx,
nsIAtom aLangGroup,
const char *  aGeneric,
PRUint32 aCount,
PRUnichar ***  aResult 
) [static]

Definition at line 5937 of file nsFontMetricsXlib.cpp.

{
  nsresult res = GetAllFontNames(aFmctx);
  if (NS_FAILED(res))
    return res;

  PRUnichar** array =
    (PRUnichar**) nsMemory::Alloc(aFmctx->mGlobalList.Count() * sizeof(PRUnichar*));
  if (!array)
    return NS_ERROR_OUT_OF_MEMORY;

  EnumerateNodeInfo info = { array, 0, aLangGroup, aFmctx };
  if (!aFmctx->mGlobalList.EnumerateForwards(EnumerateNode, &info)) {
    nsMemory::Free(array);
    return NS_ERROR_OUT_OF_MEMORY;
  }

  NS_QuickSort(array, info.mIndex, sizeof(PRUnichar*), CompareFontNames,
               nsnull);

  *aCount = info.mIndex;
  if (*aCount) {
    *aResult = array;
  }
  else {
    nsMemory::Free(array);
  }

  return NS_OK;
}

Here is the call graph for this function:

static void FFRESubstituteCharset ( nsACString &  aFFREName,
const char *  aReplacementCharset 
) [static]

Definition at line 5156 of file nsFontMetricsXlib.cpp.

{
  PRInt32 charsetHyphen = aFFREName.FindChar('-');
  charsetHyphen = aFFREName.FindChar('-', charsetHyphen + 1);
  aFFREName.Truncate(charsetHyphen+1);
  aFFREName.Append(aReplacementCharset);
}

Here is the caller graph for this function:

static void FFRESubstituteEncoding ( nsACString &  aFFREName,
const char *  aReplacementEncoding 
) [static]

Definition at line 5169 of file nsFontMetricsXlib.cpp.

{
  PRInt32 encodingHyphen;
  /* Search for the 3rd apperance of '-' */
  encodingHyphen = aFFREName.FindChar('-');
  encodingHyphen = aFFREName.FindChar('-', encodingHyphen + 1);
  encodingHyphen = aFFREName.FindChar('-', encodingHyphen + 1);
  aFFREName.Truncate(encodingHyphen+1);
  aFFREName.Append(aReplacementEncoding);
}

Here is the caller graph for this function:

static void FFREToXLFDPattern ( nsACString &  aFFREName,
nsACString &  oPattern 
) [static]

Definition at line 5139 of file nsFontMetricsXlib.cpp.

{
  PRInt32 charsetHyphen;

  oPattern.Append("-");
  oPattern.Append(aFFREName);
  /* Search for the 3rd appearance of '-' */
  charsetHyphen = oPattern.FindChar('-');
  charsetHyphen = oPattern.FindChar('-', charsetHyphen + 1);
  charsetHyphen = oPattern.FindChar('-', charsetHyphen + 1);
  oPattern.Insert("-*-*-*-*-*-*-*-*-*-*", charsetHyphen);
}

Here is the caller graph for this function:

static nsFontFamilyXlib* FindFamily ( nsFontMetricsXlibContext aFmctx,
nsCString aName 
) [static]

Definition at line 5095 of file nsFontMetricsXlib.cpp.

{
  nsCStringKey key(*aName);
  nsFontFamilyXlib* family = (nsFontFamilyXlib*) aFmctx->mFamilies.Get(&key);
  if (!family) {
    family = new nsFontFamilyXlib();
    if (family) {
      char pattern[256];
      PR_snprintf(pattern, sizeof(pattern), "-*-%s-*-*-*-*-*-*-*-*-*-*-*-*",
        aName->get());
      GetFontNames(aFmctx, pattern, PR_TRUE, aFmctx->mForceOutlineScaledFonts, &family->mNodes);
      aFmctx->mFamilies.Put(&key, family);
    }
  }

  return family;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool FontEnumCallback ( const nsString aFamily,
PRBool  aGeneric,
void aData 
) [static]

Definition at line 1924 of file nsFontMetricsXlib.cpp.

{
#ifdef REALLY_NOISY_FONTS
  printf("font = '");
  fputs(NS_LossyConvertUCS2toASCII(aFamily).get(), stdout);
  printf("'\n");
#endif

  if (!IsASCIIFontName(aFamily)) {
    return PR_TRUE; // skip and continue
  }

  nsCAutoString name;
  name.AssignWithConversion(aFamily.get());
  ToLowerCase(name);
  nsFontMetricsXlib* metrics = (nsFontMetricsXlib*) aData;
  metrics->mFonts.AppendCString(name);
  metrics->mFontIsGeneric.AppendElement((void*) aGeneric);
  if (aGeneric) {
    metrics->mGeneric = metrics->mFonts.CStringAt(metrics->mFonts.Count() - 1);
    return PR_FALSE; // stop
  }

  return PR_TRUE; // continue
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool FreeCharSetMap ( nsHashKey *  aKey,
void aData,
void aClosure 
) [static]

Definition at line 1101 of file nsFontMetricsXlib.cpp.

{
  nsFontCharSetMapXlib* charsetMap = (nsFontCharSetMapXlib*) aData;
  NS_IF_RELEASE(charsetMap->mInfo->mConverter);
  NS_IF_RELEASE(charsetMap->mInfo->mLangGroup);
  FreeCCMap(charsetMap->mInfo->mCCMap);

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool FreeFamily ( nsHashKey *  aKey,
void aData,
void aClosure 
) [static]

Definition at line 1112 of file nsFontMetricsXlib.cpp.

{
  delete (nsFontFamilyXlib*) aData;

  return PR_TRUE;
}

Here is the caller graph for this function:

static PRBool FreeNode ( nsHashKey *  aKey,
void aData,
void aClosure 
) [static]
static PRBool FreeNodeArray ( nsHashKey *  aKey,
void aData,
void aClosure 
) [static]

Definition at line 1191 of file nsFontMetricsXlib.cpp.

{
  nsFontNodeArrayXlib* nodes = (nsFontNodeArrayXlib*) aData;
  delete nodes;

  return PR_TRUE;
}

Here is the caller graph for this function:

static void FreeStretch ( nsFontStretchXlib aStretch) [static]

Definition at line 1120 of file nsFontMetricsXlib.cpp.

{
  PR_smprintf_free(aStretch->mScalable);

  for (PRInt32 count = aStretch->mScaledFonts.Count()-1; count >= 0; --count) {
    nsFontXlib *font = (nsFontXlib*)aStretch->mScaledFonts.ElementAt(count);
    if (font) delete font;
  }
  // aStretch->mScaledFonts.Clear(); handled by delete of aStretch

  for (int i = 0; i < aStretch->mSizesCount; i++) {
    delete aStretch->mSizes[i];
  }
  delete [] aStretch->mSizes;
  delete aStretch;
}

Here is the caller graph for this function:

static void FreeStyle ( nsFontStyleXlib aStyle) [static]

Definition at line 1154 of file nsFontMetricsXlib.cpp.

{
  for (int i = 0; i < 9; i++) {
    if (aStyle->mWeights[i]) {
      for (int j = i + 1; j < 9; j++) {
        if (aStyle->mWeights[j] == aStyle->mWeights[i]) {
          aStyle->mWeights[j] = nsnull;
        }
      }
      FreeWeight(aStyle->mWeights[i]);
    }
  }
  delete aStyle;
}

Here is the call graph for this function:

static void FreeWeight ( nsFontWeightXlib aWeight) [static]

Definition at line 1138 of file nsFontMetricsXlib.cpp.

{
  for (int i = 0; i < 9; i++) {
    if (aWeight->mStretches[i]) {
      for (int j = i + 1; j < 9; j++) {
        if (aWeight->mStretches[j] == aWeight->mStretches[i]) {
          aWeight->mStretches[j] = nsnull;
        }
      }
      FreeStretch(aWeight->mStretches[i]);
    }
  }
  delete aWeight;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult GetAllFontNames ( nsFontMetricsXlibContext aFmctx) [static]

Definition at line 5079 of file nsFontMetricsXlib.cpp.

{
  if (!aFmctx->mGlobalListInitalised) {
    aFmctx->mGlobalListInitalised = PR_TRUE;
    // This may well expand further (families * sizes * styles?), but it's
    // only created once.

    /* Using "-*" instead of the full-qualified "-*-*-*-*-*-*-*-*-*-*-*-*-*-*"
     * because it's faster and "smarter" - see bug 34242 for details. */
    GetFontNames(aFmctx, "-*", PR_FALSE, PR_FALSE, &aFmctx->mGlobalList);
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static const nsFontCharSetMapXlib * GetCharSetMap ( nsFontMetricsXlibContext aFmctx,
const char *  aCharSetName 
) [static]

Definition at line 6035 of file nsFontMetricsXlib.cpp.

{
  nsCStringKey charSetKey(aCharSetName);
  const nsFontCharSetMapXlib* charSetMap = (const nsFontCharSetMapXlib *) aFmctx->mCharSetMaps.Get(&charSetKey);
  if (!charSetMap)
    charSetMap = aFmctx->mNoneCharSetMap;
  return charSetMap;
}
static void GetFontNames ( nsFontMetricsXlibContext aFmctx,
const char *  aPattern,
PRBool  aAnyFoundry,
PRBool  aOnlyOutlineScaledFonts,
nsFontNodeArrayXlib aNodes 
) [static]

Definition at line 4633 of file nsFontMetricsXlib.cpp.

{
  Display *dpy = xxlib_rgb_get_display(aFmctx->mXlibRgbHandle);
  Screen  *scr = xxlib_rgb_get_screen (aFmctx->mXlibRgbHandle);

#ifdef NS_FONT_DEBUG_CALL_TRACE
  if (gFontDebug & NS_FONT_DEBUG_CALL_TRACE) {
    printf("GetFontNames %s\n", aPattern);
  }
#endif

#ifdef MOZ_ENABLE_FREETYPE2
  // get FreeType fonts
  nsFT2FontCatalog::GetFontNames(aFmctx, aPattern, aNodes);
#endif /* MOZ_ENABLE_FREETYPE2 */

  nsCAutoString previousNodeName;
  nsHashtable* node_hash;
  if (aAnyFoundry) {
    NS_ASSERTION(aPattern[1] == '*', "invalid 'anyFoundry' pattern");
    node_hash = &aFmctx->mAFRENodes;
  }
  else {
    node_hash = &aFmctx->mFFRENodes;
  }

#ifdef USE_XPRINT
#ifdef DEBUG
  if (aFmctx->mPrinterMode)
  {
    if (!dpy)
    {
      NS_ERROR("Obtaining font information without having a |Display *|");
      abort(); /* DIE!! */
    }
  
    if (XpGetContext(dpy) == None)
    {
      /* applications must not make any assumptions about fonts _before_ XpSetContext() !!! */
      NS_ERROR("Obtaining font information without valid print context (XListFonts()) _before_ XpSetContext()");
      abort(); /* DIE!! */
    }    
  }               
#endif /* DEBUG */
#endif /* USE_XPRINT */
  
#ifdef ENABLE_X_FONT_BANNING
  int  screen_xres,
       screen_yres;
  /* Get Xserver DPI. 
   * We cannot use Mozilla's API here because it may "override" the DPI
   * got from the Xserver via prefs. But we want to filter ("ban") fonts
   * we get from the Xserver which _it_(=Xserver) has "choosen" for us
   * using its DPI value ...
   */
#ifdef USE_XPRINT
  if (aFmctx->mPrinterMode) {
    Bool success;
    long x_dpi = 0,
         y_dpi = 0;
    success = XpuGetResolution(dpy, XpGetContext(dpy), &x_dpi, &y_dpi);
    NS_ASSERTION(success, "XpuGetResolution(dpy, XpGetContext(dpy), &x_dpi, &y_dpi)!");
    screen_xres = x_dpi;
    screen_yres = y_dpi;
  }
  else
#endif /* USE_XPRINT */
  {  
    screen_xres = int(((( double(::XWidthOfScreen(scr)))  * 25.4 / double(::XWidthMMOfScreen(scr)) ))  + 0.5);
    screen_yres = int(((( double(::XHeightOfScreen(scr))) * 25.4 / double(::XHeightMMOfScreen(scr)) )) + 0.5);
  }
#endif /* ENABLE_X_FONT_BANNING */
      
  BANNED_FONT_PRINTF(("Loading font '%s'", aPattern));
  /*
   * We do not use XListFontsWithInfo here, because it is very expensive.
   * Instead, we get that info at the time when we actually load the font.
   */
  int    count;
  char **list = ::XListFonts(dpy, aPattern, INT_MAX, &count);
  if ((!list) || (count < 1)) {
    return;
  }
  for (int i = 0; i < count; i++) {
    char name[256]; /* X11 font names are never larger than 255 chars */

    /* Check if we can handle the font name ('*' and '?' are only valid in
     * input patterns passed as argument to |XListFont()|&co. but _not_ in
     * font names returned by these functions (see bug 136743 ("xlib complains
     * a lot about fonts with '*' in the XLFD string"))) */
    if ((!list[i]) || (list[i][0] != '-') || (PL_strpbrk(list[i], "*?") != nsnull)) {
      continue;
    }

    strcpy(name, list[i]);
    
    char *p = name + 1;
    PRBool scalable       = PR_FALSE,
           outline_scaled = PR_FALSE;
#ifdef USE_XPRINT
    PRBool builtin_printer_font = PR_FALSE;
#endif /* USE_XPRINT */
    int    resX = -1,
           resY = -1;

#ifdef FIND_FIELD
#undef FIND_FIELD
#endif
#define FIND_FIELD(var)           \
  char* var = p;                  \
  while ((*p) && ((*p) != '-')) { \
    p++;                          \
  }                               \
  if (*p) {                       \
    *p++ = 0;                     \
  }                               \
  else {                          \
    continue;                     \
  }

#ifdef SKIP_FIELD
#undef SKIP_FIELD
#endif
#define SKIP_FIELD(var)           \
  while ((*p) && ((*p) != '-')) { \
    p++;                          \
  }                               \
  if (*p) {                       \
    p++;                          \
  }                               \
  else {                          \
    continue;                     \
  }

    FIND_FIELD(foundry);
    // XXX What to do about the many Applix fonts that start with "ax"?
    FIND_FIELD(familyName);
    FIND_FIELD(weightName);
    FIND_FIELD(slant);
    FIND_FIELD(setWidth);
    FIND_FIELD(addStyle);
    FIND_FIELD(pixelSize);
    if (pixelSize[0] == '0') {
      scalable = PR_TRUE;
    }
    FIND_FIELD(pointSize);
    if (pointSize[0] == '0') {
      scalable = PR_TRUE;
    }
    FIND_FIELD(resolutionX);
    resX = atoi(resolutionX);
    NS_ASSERTION(!(resolutionX[0] != '0' && resX == 0), "atoi(resolutionX) failure.");
    if (resolutionX[0] == '0') {
      scalable = PR_TRUE;
    }
    FIND_FIELD(resolutionY);
    resY = atoi(resolutionY);
    NS_ASSERTION(!(resolutionY[0] != '0' && resY == 0), "atoi(resolutionY) failure.");
    if (resolutionY[0] == '0') {
      scalable = PR_TRUE;
    }
    /* check if bitmap non-scaled font */
    if ((pixelSize[0] != '0') || (pointSize[0] != '0')) {
      SCALED_FONT_PRINTF(("bitmap (non-scaled) font: %s", list[i]));
    }
    /* check if bitmap scaled font */
    else if ((pixelSize[0] == '0') && (pointSize[0] == '0')
          && (resolutionX[0] != '0') && (resolutionY[0] != '0')) {
      SCALED_FONT_PRINTF(("bitmap scaled font: %s", list[i]));
    }
    /* check if outline scaled font */
    else if ((pixelSize[0] == '0') && (pointSize[0] == '0')
          && (resolutionX[0] == '0') && (resolutionY[0] == '0')) {
      outline_scaled = PR_TRUE;
      SCALED_FONT_PRINTF(("outline scaled font: %s", list[i]));
    }
    else {
      SCALED_FONT_PRINTF(("unexpected font values: %s", list[i]));
      SCALED_FONT_PRINTF(("      pixelSize[0] = %c", pixelSize[0]));
      SCALED_FONT_PRINTF(("      pointSize[0] = %c", pointSize[0]));
      SCALED_FONT_PRINTF(("    resolutionX[0] = %c", resolutionX[0]));
      SCALED_FONT_PRINTF(("    resolutionY[0] = %c", resolutionY[0]));
      static PRBool already_complained = PR_FALSE;
      // only complaing once 
      if (!already_complained) {
        already_complained = PR_TRUE;
        NS_ASSERTION(pixelSize[0] == '0', "font scaler type test failed");
        NS_ASSERTION(pointSize[0] == '0', "font scaler type test failed");
        NS_ASSERTION(resolutionX[0] == '0', "font scaler type test failed");
        NS_ASSERTION(resolutionY[0] == '0', "font scaler type test failed");
      }
    }
    FIND_FIELD(spacing);
    FIND_FIELD(averageWidth);

#ifdef USE_XPRINT
    /* I am not sure what Xprint built-in printer fonts exactly look like
     * (usually '-adobe-helvetica-medium-r-normal--0-0-1200-1200-p-0-iso8859-1'
     * for a 300DPI printer ("fonts.dir" entry in 
     * $XPCONFIGDIR/C/print/models/SPSPARC2/fonts/ for "Helvetica.pmf" 
     * (PMF=printer font metrics) looks like this: 
     * '-adobe-helvetica-medium-r-normal--199-120-1200-1200-p-1085-iso8859-1'))
     * but this test is good enough (except when someone installs 1200DPI
     * bitmap (!!) fonts on a system... =:-)
     */
    if (aFmctx->mPrinterMode &&
        averageWidth[0] == '0' && 
        resX > screen_xres && 
        resY > screen_yres) {
      builtin_printer_font = PR_TRUE;
      /* Treat built-in printer fonts like outline-scaled ones... */
      outline_scaled = PR_TRUE;

      PR_LOG(FontMetricsXlibLM, PR_LOG_DEBUG, ("This may be a built-in printer font '%s'\n", list[i]));
    }
#endif /* USE_XPRINT */

    if (averageWidth[0] == '0') {
      scalable = PR_TRUE;
/* Workaround for bug 103159 ("sorting fonts by foundry names cause font
 * size of css ignored in some cases").
 * Hardcoded font ban until bug 104075 ("need X font banning") has been
 * implemented. See http://bugzilla.mozilla.org/show_bug.cgi?id=94327#c34
 * for additional comments...
 */      
#ifndef DISABLE_WORKAROUND_FOR_BUG_103159
      /* Skip 'mysterious' and 'spurious' cases like
       * -adobe-times-medium-r-normal--17-120-100-100-p-0-iso8859-9
       * The only "legal" use for this type of XLFD are Xprint
       * build-in printer fonts.like
       * -adobe-times-medium-r-normal--50-120-300-300-p-0-iso8859-1
       * (300DPI printer)
       */
      if ((pixelSize[0] != '0' || pointSize[0] != 0) && 
          (outline_scaled == PR_FALSE)
#ifdef USE_XPRINT
           && (builtin_printer_font == PR_FALSE)
#endif /* USE_XPRINT */          
          ) {
        PR_LOG(FontMetricsXlibLM, PR_LOG_DEBUG, ("rejecting font '%s' (via hardcoded workaround for bug 103159)\n", list[i]));
        BANNED_FONT_PRINTF(("rejecting font '%s' (via hardcoded workaround for bug 103159)", list[i]));          
        continue;
      }  
#endif /* DISABLE_WORKAROUND_FOR_BUG_103159 */
    }
    char* charSetName = p; // CHARSET_REGISTRY & CHARSET_ENCODING
    if (!*charSetName) {
      continue;
    }
    
    if (aOnlyOutlineScaledFonts && (outline_scaled == PR_FALSE)) {
      continue;
    }

#ifdef ENABLE_X_FONT_BANNING
#define BOOL2STR(b) ((b)?("true"):("false"))    
    if (aFmctx->mFontRejectRegEx || aFmctx->mFontAcceptRegEx) {
      char fmatchbuf[512]; /* See sprintf() below. */
           
      sprintf(fmatchbuf, "fname=%s;scalable=%s;outline_scaled=%s;xdisplay=%s;xdpy=%d;ydpy=%d;xdevice=%s",
              list[i], /* full font name */
              BOOL2STR(scalable), 
              BOOL2STR(outline_scaled),
              XDisplayString(dpy),
              screen_xres,
              screen_yres,
#ifdef USE_XPRINT
              aFmctx->mPrinterMode?("printer"):
#endif /* USE_XPRINT */
              ("display")
              );
#undef BOOL2STR
                  
      if (aFmctx->mFontRejectRegEx) {
        /* reject font if reject pattern matches it... */        
        if (regexec(aFmctx->mFontRejectRegEx, fmatchbuf, 0, nsnull, 0) == REG_OK) {
          PR_LOG(FontMetricsXlibLM, PR_LOG_DEBUG, ("rejecting font '%s' (via reject pattern)\n", fmatchbuf));
          BANNED_FONT_PRINTF(("rejecting font '%s' (via reject pattern)", fmatchbuf));
          continue;
        }  
      }

      if (aFmctx->mFontAcceptRegEx) {
        if (regexec(aFmctx->mFontAcceptRegEx, fmatchbuf, 0, nsnull, 0) == REG_NOMATCH) {
          PR_LOG(FontMetricsXlibLM, PR_LOG_DEBUG, ("rejecting font '%s' (via accept pattern)\n", fmatchbuf));
          BANNED_FONT_PRINTF(("rejecting font '%s' (via accept pattern)", fmatchbuf));
          continue;
        }
      }       
    }    
#endif /* ENABLE_X_FONT_BANNING */    

    const nsFontCharSetMapXlib *charSetMap = GetCharSetMap(aFmctx, charSetName);
    nsFontCharSetInfoXlib* charSetInfo = charSetMap->mInfo;
    // indirection for font specific charset encoding 
    if (charSetInfo == aFmctx->mSpecial) {
      nsCAutoString familyCharSetName(familyName);
      familyCharSetName.Append('-');
      familyCharSetName.Append(charSetName);
      nsCStringKey familyCharSetKey(familyCharSetName);
      charSetMap = NS_STATIC_CAST(nsFontCharSetMapXlib*, aFmctx->mSpecialCharSets.Get(&familyCharSetKey));
      if (!charSetMap)
        charSetMap = aFmctx->mNoneCharSetMap;
      charSetInfo = charSetMap->mInfo;
    }
    if (!charSetInfo) {
#ifdef NOISY_FONTS
      printf("cannot find charset %s\n", charSetName);
#endif
      charSetInfo = aFmctx->mUnknown;
    }
    SetCharsetLangGroup(aFmctx, charSetInfo);
    SetFontLangGroupInfo(aFmctx, charSetMap);

    nsCAutoString nodeName;
    if (aAnyFoundry)
      nodeName.Assign('*');
    else
      nodeName.Assign(foundry);
    nodeName.Append('-');
    nodeName.Append(familyName);
    nodeName.Append('-');
    nodeName.Append(charSetName);
    nsCStringKey key(nodeName);
    nsFontNodeXlib* node = (nsFontNodeXlib*) node_hash->Get(&key);
    if (!node) {
      node = new nsFontNodeXlib;
      if (!node) {
        continue;
      }
      node_hash->Put(&key, node);
      node->mName = nodeName;
      node->mCharSetInfo = charSetInfo;
    }

    int found = 0;
    if (nodeName == previousNodeName) {
      found = 1;
    }
    else {
      found = (aNodes->IndexOf(node) >= 0);
    }
    previousNodeName = nodeName;
    if (!found) {
      aNodes->AppendElement(node);
    }

    int styleIndex;
    // XXX This does not cover the full XLFD spec for SLANT.
    switch (slant[0]) {
    case 'i':
      styleIndex = NS_FONT_STYLE_ITALIC;
      break;
    case 'o':
      styleIndex = NS_FONT_STYLE_OBLIQUE;
      break;
    case 'r':
    default:
      styleIndex = NS_FONT_STYLE_NORMAL;
      break;
    }
    nsFontStyleXlib* style = NodeGetStyle(node, styleIndex);
    if (!style)
      continue;

    nsCStringKey weightKey(weightName);
    int weightNumber = NS_PTR_TO_INT32(aFmctx->mWeights.Get(&weightKey));
    if (!weightNumber) {
#ifdef NOISY_FONTS
      printf("cannot find weight %s\n", weightName);
#endif
      weightNumber = NS_FONT_WEIGHT_NORMAL;
    }
    int weightIndex = WEIGHT_INDEX(weightNumber);
    nsFontWeightXlib* weight = NodeGetWeight(style, weightIndex);
    if (!weight)
      continue;
  
    nsCStringKey setWidthKey(setWidth);
    int stretchIndex = NS_PTR_TO_INT32(aFmctx->mStretches.Get(&setWidthKey));
    if (!stretchIndex) {
#ifdef NOISY_FONTS
      printf("cannot find stretch %s\n", setWidth);
#endif
      stretchIndex = 5;
    }
    stretchIndex--;
    nsFontStretchXlib* stretch = NodeGetStretch(weight, stretchIndex);
    if (!stretch)
      continue;

    if (scalable) {
      if (!NodeAddScalable(stretch, outline_scaled,
#ifdef USE_XPRINT
                           builtin_printer_font, resX, resY, 
#endif /* USE_XPRINT */
                           name, familyName, weightName, slant, setWidth, addStyle, spacing, charSetName))
        continue;
    }
  
    // get pixel size before the string is changed
    int pixels,
        points;

    pixels = atoi(pixelSize);
    points = atoi(pointSize);

    if (pixels) {
      if (aFmctx->mScaleBitmapFontsWithDevScale && (aFmctx->mDevScale > 1.0f)) {
        /* Add a font size which is exactly scaled as the scaling factor ... */
        if (!NodeAddSize(aFmctx, stretch, pixels, points, aFmctx->mDevScale, resX, resY, name, familyName, weightName, 
                         slant, setWidth, addStyle, spacing, charSetName, charSetInfo))
          continue;

        /* ... and offer a range of scaled fonts with integer scaling factors
         * (we're taking half steps between integers, too - to avoid too big
         * steps between font sizes) */
        float minScaler = PR_MAX(aFmctx->mDevScale / 2.0f, 1.5f),
              maxScaler = aFmctx->mDevScale * 2.f,
              scaler;
        for( scaler = minScaler ; scaler <= maxScaler ; scaler += 0.5f )
        {
          if (!NodeAddSize(aFmctx, stretch, pixels, points, scaler, resX, resY, name, familyName, weightName, 
                           slant, setWidth, addStyle, spacing, charSetName, charSetInfo))
            break;
        }
        if (scaler <= maxScaler) {
          continue; /* |NodeAddSize| returned an error in the loop above... */
        }
      }
      else
      {
        if (!NodeAddSize(aFmctx, stretch, pixels, points, 1.0f, resX, resY, name, familyName, weightName, 
                         slant, setWidth, addStyle, spacing, charSetName, charSetInfo))
          continue;     
      }
    }
  }
  XFreeFontNames(list);

#ifdef DEBUG_DUMP_TREE
  DumpTree();
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRUint16* GetMapFor10646Font ( XFontStruct *  aFont) [static]

Definition at line 2945 of file nsFontMetricsXlib.cpp.

{
  if (!aFont->per_char)
    return nsnull;

  nsCompressedCharMap ccmapObj;
  PRInt32 minByte1 = aFont->min_byte1;
  PRInt32 maxByte1 = aFont->max_byte1;
  PRInt32 minByte2 = aFont->min_char_or_byte2;
  PRInt32 maxByte2 = aFont->max_char_or_byte2;
  PRInt32 charsPerRow = maxByte2 - minByte2 + 1;
  for (PRInt32 row = minByte1; row <= maxByte1; row++) {
    PRInt32 offset = (((row - minByte1) * charsPerRow) - minByte2);
    for (PRInt32 cell = minByte2; cell <= maxByte2; cell++) {
      XCharStruct* bounds = &aFont->per_char[offset + cell];
      // From Section 8.5 Font Metrics in the Xlib programming manual:
      // A nonexistent character is represented with all members of its XCharStruct set to zero. 
      if (bounds->ascent ||
          bounds->descent ||
          bounds->lbearing ||
          bounds->rbearing ||
          bounds->width ||
          bounds->attributes) {
        ccmapObj.SetChar((row << 8) | cell);
      }
    }
  }
  PRUint16 *ccmap = ccmapObj.NewCCMap();
  return ccmap;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool IsASCIIFontName ( const nsString aName) [static]

Definition at line 1907 of file nsFontMetricsXlib.cpp.

{
  PRUint32 len = aName.Length();
  const PRUnichar* str = aName.get();
  for (PRUint32 i = 0; i < len; i++) {
    /*
     * X font names are printable ASCII, ignore others (for now)
     */
    if ((str[i] < 0x20) || (str[i] > 0x7E)) {
      return PR_FALSE;
    }
  }

  return PR_TRUE;
}

Here is the caller graph for this function:

static int ISO10646Convert ( nsFontCharSetInfoXlib aSelf,
XFontStruct *  aFont,
const PRUnichar aSrcBuf,
PRInt32  aSrcLen,
char *  aDestBuf,
PRInt32  aDestLen 
) [static]

Definition at line 2717 of file nsFontMetricsXlib.cpp.

{
  aDestLen /= 2;
  if (aSrcLen > aDestLen) {
    aSrcLen = aDestLen;
  }
  if (aSrcLen < 0) {
    aSrcLen = 0;
  }
  XChar2b* dest = (XChar2b*) aDestBuf;
  for (PRInt32 i = 0; i < aSrcLen; i++) {
    dest[i].byte1 = (aSrcBuf[i] >> 8);
    dest[i].byte2 = (aSrcBuf[i] & 0xFF);
  }

  return (int) aSrcLen * 2;
}
static PRBool NodeAddScalable ( nsFontStretchXlib aStretch,
PRBool  aOutlineScaled,
const char *  aDashFoundry,
const char *  aFamily,
const char *  aWeight,
const char *  aSlant,
const char *  aWidth,
const char *  aStyle,
const char *  aSpacing,
const char *  aCharSet 
) [static]

Definition at line 4513 of file nsFontMetricsXlib.cpp.

{
  // if we have both an outline scaled font and a bitmap 
  // scaled font pick the outline scaled font
  if ((aStretch->mScalable) && (!aStretch->mOutlineScaled) 
      && (aOutlineScaled)) {
    PR_smprintf_free(aStretch->mScalable);
    aStretch->mScalable = nsnull;
  }
  if (!aStretch->mScalable) {
    aStretch->mOutlineScaled = aOutlineScaled;
#ifdef USE_XPRINT
    /* Xprint built-in printer fonts are outline-scaled fonts (except
     * that we ask explicitly for X/Y resolution instead of using 0/0)
     */
    if (aPrinterBuiltinFont) {
      aStretch->mScalable = 
          PR_smprintf("%s-%s-%s-%s-%s-%s-%%d-*-%d-%d-%s-*-%s", 
          aDashFoundry, aFamily, aWeight, aSlant, aWidth, aStyle, 
          aResX, aResY, aSpacing, aCharSet);      
      if (!aStretch->mScalable)
        return PR_FALSE;
    }
    else 
#endif /* USE_XPRINT */                
    if (aOutlineScaled) {
      aStretch->mScalable = 
          PR_smprintf("%s-%s-%s-%s-%s-%s-%%d-*-0-0-%s-*-%s", 
          aDashFoundry, aFamily, aWeight, aSlant, aWidth, aStyle, 
          aSpacing, aCharSet);
      if (!aStretch->mScalable)
        return PR_FALSE;
    }
    else {
      aStretch->mScalable = 
          PR_smprintf("%s-%s-%s-%s-%s-%s-%%d-*-*-*-%s-*-%s", 
          aDashFoundry, aFamily, aWeight, aSlant, aWidth, aStyle, 
          aSpacing, aCharSet);
      if (!aStretch->mScalable)
        return PR_FALSE;
    }
  }
  return PR_TRUE;
}

Here is the caller graph for this function:

static PRBool NodeAddSize ( nsFontMetricsXlibContext aFmctx,
nsFontStretchXlib aStretch,
int  aPixelSize,
int  aPointSize,
float  scaler,
int  aResX,
int  aResY,
const char *  aDashFoundry,
const char *  aFamily,
const char *  aWeight,
const char *  aSlant,
const char *  aWidth,
const char *  aStyle,
const char *  aSpacing,
const char *  aCharSet,
nsFontCharSetInfoXlib aCharSetInfo 
) [static]

Definition at line 4567 of file nsFontMetricsXlib.cpp.

{
  if (scaler!=1.0f)
  {
    aPixelSize = int(float(aPixelSize) * scaler);
    aPointSize = int(float(aPointSize) * scaler);
    aResX = 0;
    aResY = 0;
  }

  PRBool haveSize = PR_FALSE;
  if (aStretch->mSizesCount) {
    nsFontXlib** end = &aStretch->mSizes[aStretch->mSizesCount];
    nsFontXlib** s;
    for (s = aStretch->mSizes; s < end; s++) {
      if ((*s)->mSize == aPixelSize) {
        haveSize = PR_TRUE;
        break;
      }
    }
  }
  if (!haveSize) {
    if (aStretch->mSizesCount == aStretch->mSizesAlloc) {
      int newSize = 2 * (aStretch->mSizesAlloc ? aStretch->mSizesAlloc : 1);
      nsFontXlib** newSizes = new nsFontXlib*[newSize];
      if (!newSizes)
        return PR_FALSE;
      for (int j = aStretch->mSizesAlloc - 1; j >= 0; j--) {
        newSizes[j] = aStretch->mSizes[j];
      }
      aStretch->mSizesAlloc = newSize;
      delete [] aStretch->mSizes;
      aStretch->mSizes = newSizes;
    }
    char *name = PR_smprintf("%s-%s-%s-%s-%s-%s-%d-%d-%d-%d-%s-*-%s", 
                             aDashFoundry, aFamily, aWeight, aSlant, aWidth, aStyle, 
                             aPixelSize, aPointSize, aResX, aResY, aSpacing, aCharSet);  

    if (!name) {
      return PR_FALSE;
    }
    nsFontXlib* size = new nsFontXlibNormal(aFmctx);
    if (!size) {
      return PR_FALSE;
    }
    aStretch->mSizes[aStretch->mSizesCount++] = size;
    size->mName           = name;
    // size->mFont is initialized in the constructor
    size->mSize           = aPixelSize;
    size->mBaselineAdjust = 0;
    size->mCCMap          = nsnull;
    size->mCharSetInfo    = aCharSetInfo;
  }
  return PR_TRUE;
}

Here is the caller graph for this function:

static nsFontStretchXlib* NodeGetStretch ( nsFontWeightXlib aWeight,
int  aStretchIndex 
) [static]

Definition at line 4499 of file nsFontMetricsXlib.cpp.

{
  nsFontStretchXlib* stretch = aWeight->mStretches[aStretchIndex];
  if (!stretch) {
    stretch = new nsFontStretchXlib;
    if (!stretch) {
      return nsnull;
    }
    aWeight->mStretches[aStretchIndex] = stretch;
  }
  return stretch;
}

Here is the caller graph for this function:

static nsFontStyleXlib* NodeGetStyle ( nsFontNodeXlib aNode,
int  aStyleIndex 
) [static]

Definition at line 4471 of file nsFontMetricsXlib.cpp.

{
  nsFontStyleXlib* style = aNode->mStyles[aStyleIndex];
  if (!style) {
    style = new nsFontStyleXlib;
    if (!style) {
      return nsnull;
    }
    aNode->mStyles[aStyleIndex] = style;
  }
  return style;
}

Here is the caller graph for this function:

static nsFontWeightXlib* NodeGetWeight ( nsFontStyleXlib aStyle,
int  aWeightIndex 
) [static]

Definition at line 4485 of file nsFontMetricsXlib.cpp.

{
  nsFontWeightXlib* weight = aStyle->mWeights[aWeightIndex];
  if (!weight) {
    weight = new nsFontWeightXlib;
    if (!weight) {
      return nsnull;
    }
    aStyle->mWeights[aWeightIndex] = weight;
  }
  return weight;
}

Here is the caller graph for this function:

static void PrefEnumCallback ( const char *  aName,
void aClosure 
) [static]

Definition at line 5415 of file nsFontMetricsXlib.cpp.

{
  nsFontSearch* s = (nsFontSearch*) aClosure;
  nsFontMetricsXlibContext *aFmctx = s->mMetrics->mFontMetricsContext;

  if (s->mFont) {
    NS_ASSERTION(s->mFont->SupportsChar(s->mChar), "font supposed to support this char");
    return;
  }
  nsXPIDLCString value;
  aFmctx->mPref->CopyCharPref(aName, getter_Copies(value));
  nsCAutoString name;
  if (value.get()) {
    name = value;
    FIND_FONT_PRINTF(("       PrefEnumCallback"));
    s->mFont = s->mMetrics->TryNode(&name, s->mChar);
    if (s->mFont) {
      NS_ASSERTION(s->mFont->SupportsChar(s->mChar), "font supposed to support this char");
      return;
    }
    s->mFont = s->mMetrics->TryLangGroup(s->mMetrics->mLangGroup, &name, s->mChar);
    if (s->mFont) {
      NS_ASSERTION(s->mFont->SupportsChar(s->mChar), "font supposed to support this char");
      return;
    }
  }
  aFmctx->mPref->CopyDefaultCharPref(aName, getter_Copies(value));
  if (value.get() && (!name.Equals(value))) {
    name = value;
    FIND_FONT_PRINTF(("       PrefEnumCallback:default"));
    s->mFont = s->mMetrics->TryNode(&name, s->mChar);
    if (s->mFont) {
      NS_ASSERTION(s->mFont->SupportsChar(s->mChar), "font supposed to support this char");
      return;
    }
    s->mFont = s->mMetrics->TryLangGroup(s->mMetrics->mLangGroup, &name, s->mChar);
    NS_ASSERTION(s->mFont ? s->mFont->SupportsChar(s->mChar) : 1, "font supposed to support this char");
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void SetCharsetLangGroup ( nsFontMetricsXlibContext aFmctx,
nsFontCharSetInfoXlib aCharSetInfo 
) [static]

Definition at line 4236 of file nsFontMetricsXlib.cpp.

{
  if (!aCharSetInfo->mCharSet || aCharSetInfo->mLangGroup)
    return;

  nsresult res;
  
  res = aFmctx->mCharSetManager->GetCharsetLangGroupRaw(aCharSetInfo->mCharSet,
                                                        &aCharSetInfo->mLangGroup);
  if (NS_FAILED(res)) {
    aCharSetInfo->mLangGroup = NS_NewAtom("");
#ifdef NOISY_FONTS
    printf("=== cannot get lang group for %s\n", aCharSetInfo->mCharSet);
#endif
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool SetFontCharsetInfo ( nsFontXlib aFont,
nsFontCharSetInfoXlib aCharSet,
PRUnichar  aChar 
) [static]

Definition at line 3738 of file nsFontMetricsXlib.cpp.

{
  if (aCharSet->mCharSet) {
    aFont->mCCMap = aCharSet->mCCMap;
    // check that the font is not empty
    if (CCMAP_HAS_CHAR(aFont->mCCMap, aChar)) {
      aFont->LoadFont();
      if (!aFont->GetXFont()) {
        return PR_FALSE;
      }
    }
  }
  else {
    if (aCharSet == aFont->mFontMetricsContext->mISO106461) {
      aFont->LoadFont();
      if (!aFont->GetXFont()) {
        return PR_FALSE;
      }
    }
  }
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void SetFontLangGroupInfo ( nsFontMetricsXlibContext aFmctx,
const nsFontCharSetMapXlib aCharSetMap 
) [static]

Definition at line 4353 of file nsFontMetricsXlib.cpp.

{
  nsFontLangGroupXlib *fontLangGroup = aCharSetMap->mFontLangGroup;
  if (!fontLangGroup)
    return;

  // get the atom for mFontLangGroup->mFontLangGroupName so we can
  // apply fontLangGroup operations to it
  // eg: search for related groups, check for scaling prefs
  const char *langGroup = fontLangGroup->mFontLangGroupName;

  // the font.scale prefs don't make sense without a langGroup
  // XXX FIX!!!  if langGroup is "", we need to bypass the font.scale stuff
  if (!langGroup)
    langGroup = "";
  if (!fontLangGroup->mFontLangGroupAtom) {
      fontLangGroup->mFontLangGroupAtom = NS_NewAtom(langGroup);
  }

  // hack : map 'x-zh-TWHK' to 'zh-TW'. See nsFontMetricsGTK.cpp for details.
  if (fontLangGroup->mFontLangGroupAtom == aFmctx->mZHTWHK) {
    langGroup = "zh-TW";
  }

  // get the font scaling controls
  nsFontCharSetInfoXlib *charSetInfo = aCharSetMap->mInfo;
  if (!charSetInfo->mInitedSizeInfo) {
    charSetInfo->mInitedSizeInfo = PR_TRUE;

    nsCAutoString name;
    nsresult rv;
    name.Assign("font.scale.outline.min.");
    name.Append(langGroup);
    rv = aFmctx->mPref->GetIntPref(name.get(), &charSetInfo->mOutlineScaleMin);
    if (NS_SUCCEEDED(rv))
      SIZE_FONT_PRINTF(("%s = %d", name.get(), charSetInfo->mOutlineScaleMin));
    else
      charSetInfo->mOutlineScaleMin = aFmctx->mOutlineScaleMinimum;

#ifdef USE_AASB
    name.Assign("font.scale.aa_bitmap.min.");
    name.Append(langGroup);
    rv = aFmctx->mPref->GetIntPref(name.get(), &charSetInfo->mAABitmapScaleMin);
    if (NS_SUCCEEDED(rv))
      SIZE_FONT_PRINTF(("%s = %d", name.get(), charSetInfo->mAABitmapScaleMin));
    else
      charSetInfo->mAABitmapScaleMin = aFmctx->mAABitmapScaleMinimum;
#endif /* USE_AASB */

    name.Assign("font.scale.bitmap.min.");
    name.Append(langGroup);
    rv = aFmctx->mPref->GetIntPref(name.get(), &charSetInfo->mBitmapScaleMin);
    if (NS_SUCCEEDED(rv))
      SIZE_FONT_PRINTF(("%s = %d", name.get(), charSetInfo->mBitmapScaleMin));
    else
      charSetInfo->mBitmapScaleMin = aFmctx->mBitmapScaleMinimum;

    PRInt32 percent = 0;
#ifdef USE_AASB
    name.Assign("font.scale.aa_bitmap.oversize.");
    name.Append(langGroup);
    percent = 0;
    rv = mFontMetricsContext->mPref->GetIntPref(name.get(), &percent);
    if (NS_SUCCEEDED(rv)) {
      charSetInfo->mAABitmapOversize = percent/100.0;
      SIZE_FONT_PRINTF(("%s = %g", name.get(), charSetInfo->mAABitmapOversize));
    }
    else
      charSetInfo->mAABitmapOversize = aFmctx->mAABitmapOversize;

    percent = 0;
    name.Assign("font.scale.aa_bitmap.undersize.");
    name.Append(langGroup);
    rv = mFontMetricsContext->mPref->GetIntPref(name.get(), &percent);
    if (NS_SUCCEEDED(rv)) {
      charSetInfo->mAABitmapUndersize = percent/100.0;
      SIZE_FONT_PRINTF(("%s = %g", name.get(),charSetInfo->mAABitmapUndersize));
    }
    else
      charSetInfo->mAABitmapUndersize = aFmctx->mAABitmapUndersize;

    PRBool val = PR_TRUE;
    name.Assign("font.scale.aa_bitmap.always.");
    name.Append(langGroup);
    rv = mFontMetricsContext->mPref->GetBoolPref(name.get(), &val);
    if (NS_SUCCEEDED(rv)) {
      charSetInfo->mAABitmapScaleAlways = val;
      SIZE_FONT_PRINTF(("%s = %d", name.get(),charSetInfo->mAABitmapScaleAlways));
    }
    else
      charSetInfo->mAABitmapScaleAlways = aFmctx->mAABitmapScaleAlways;
#endif /* USE_AASB */

    percent = 0;
    name.Assign("font.scale.bitmap.oversize.");
    name.Append(langGroup);
    rv = aFmctx->mPref->GetIntPref(name.get(), &percent);
    if (NS_SUCCEEDED(rv)) {
      charSetInfo->mBitmapOversize = percent/100.0;
      SIZE_FONT_PRINTF(("%s = %g", name.get(), charSetInfo->mBitmapOversize));
    }
    else
      charSetInfo->mBitmapOversize = aFmctx->mBitmapOversize;

    percent = 0;
    name.Assign("font.scale.bitmap.undersize.");
    name.Append(langGroup);
    rv = aFmctx->mPref->GetIntPref(name.get(), &percent);
    if (NS_SUCCEEDED(rv)) {
      charSetInfo->mBitmapUndersize = percent/100.0;
      SIZE_FONT_PRINTF(("%s = %g", name.get(), charSetInfo->mBitmapUndersize));
    }
    else
      charSetInfo->mBitmapUndersize = aFmctx->mBitmapUndersize;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool SetUpFontCharSetInfo ( nsFontMetricsXlibContext aFmctx,
nsFontCharSetInfoXlib aSelf 
) [static]

Definition at line 2771 of file nsFontMetricsXlib.cpp.

{
#ifdef DEBUG
  static PRBool checkedSelf = PR_FALSE;
  if (!checkedSelf) {
    CheckSelf(aFmctx);
    checkedSelf = PR_TRUE;
  }
#endif /* DEBUG */

  nsresult res;
  
  nsIUnicodeEncoder* converter = nsnull;
  res = aFmctx->mCharSetManager->GetUnicodeEncoderRaw(aSelf->mCharSet, &converter);
  if (NS_SUCCEEDED(res)) {
    aSelf->mConverter = converter;
    res = converter->SetOutputErrorBehavior(converter->kOnError_Replace,
                                            nsnull, '?');
    nsCOMPtr<nsICharRepresentable> mapper = do_QueryInterface(converter);
    if (mapper) {
      aSelf->mCCMap = MapperToCCMap(mapper);
      if (aSelf->mCCMap) {
#ifdef DEBUG
        NS_WARNING(nsPrintfCString(256, "SetUpFontCharSetInfo: charset = '%s'", aSelf->mCharSet).get());
#endif /* DEBUG */

        /*
         * We used to disable special characters like smart quotes
         * in CJK fonts because if they are quite a bit larger than
         * western glyphs and we did not want glyph fill-in to use them
         * in single byte documents.
         *
         * Now, single byte documents find these special chars before
         * the CJK fonts are searched so this is no longer needed
         * but is useful when trying to determine which font(s) the
         * special chars are found in.
         */
        if ((aSelf->Convert == DoubleByteConvert) 
            && (!aFmctx->mAllowDoubleByteSpecialChars)) {
          PRUint16* ccmap = aSelf->mCCMap;
          PRUint32 page = CCMAP_BEGIN_AT_START_OF_MAP;
          const PRUint16* specialmap = aFmctx->mDoubleByteSpecialCharsCCMap;
          while (NextNonEmptyCCMapPage(specialmap, &page)) {
            PRUint32 pagechar = page;
            for (int i=0; i < CCMAP_BITS_PER_PAGE; i++) {
              if (CCMAP_HAS_CHAR(specialmap, pagechar)) 
                CCMAP_UNSET_CHAR(ccmap, pagechar);
              pagechar++;
            }
          }
        }
        return PR_TRUE;
      }
    }
    else {
      NS_WARNING("cannot get nsICharRepresentable");
    }
  }
  else {
    NS_WARNING("cannot get Unicode converter");
  }

  //
  // always try to return a map even if it is empty
  //
  nsCompressedCharMap empty_ccmapObj;
  aSelf->mCCMap = empty_ccmapObj.NewCCMap();

  // return false if unable to alloc a map
  if (aSelf->mCCMap == nsnull)
    return PR_FALSE;

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsFontXlib* SetupUserDefinedFont ( nsFontMetricsXlibContext aFmctx,
nsFontXlib aFont 
) [static]

Definition at line 3763 of file nsFontMetricsXlib.cpp.

{
  if (!aFont->mUserDefinedFont) {
    aFont->mUserDefinedFont = new nsFontXlibUserDefined(aFmctx);
    if (!aFont->mUserDefinedFont) {
      return nsnull;
    }
    if (!aFont->mUserDefinedFont->Init(aFont)) {
      return nsnull;
    }
  }
  return aFont->mUserDefinedFont;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int SingleByteConvert ( nsFontCharSetInfoXlib aSelf,
XFontStruct *  aFont,
const PRUnichar aSrcBuf,
PRInt32  aSrcLen,
char *  aDestBuf,
PRInt32  aDestLen 
) [static]

Definition at line 2641 of file nsFontMetricsXlib.cpp.

{
  int count = 0;
  if (aSelf->mConverter) {
    aSelf->mConverter->Convert(aSrcBuf, &aSrcLen, aDestBuf, &aDestLen);
    count = aDestLen;
  }

  return count;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Initial value:
  { "x-adobe-euro", SingleByteConvert, 0 }

Definition at line 625 of file nsFontMetricsXlib.cpp.

Initial value:
   { "Adobe-Symbol-Encoding", SingleByteConvert, 0 }

Definition at line 623 of file nsFontMetricsXlib.cpp.

Initial value:
  { "x-x-big5", DoubleByteConvert, 1 }

Definition at line 558 of file nsFontMetricsXlib.cpp.

Initial value:
  { "x-x-big5", DoubleByteConvert, 1 }

Definition at line 562 of file nsFontMetricsXlib.cpp.

Initial value:
  { "x-cns-11643-1", DoubleByteConvert, 1 }

Definition at line 564 of file nsFontMetricsXlib.cpp.

Initial value:
  { "x-cns-11643-2", DoubleByteConvert, 1 }

Definition at line 566 of file nsFontMetricsXlib.cpp.

Initial value:
  { "x-cns-11643-3", DoubleByteConvert, 1 }

Definition at line 568 of file nsFontMetricsXlib.cpp.

Initial value:
  { "x-cns-11643-4", DoubleByteConvert, 1 }

Definition at line 570 of file nsFontMetricsXlib.cpp.

Initial value:
  { "x-cns-11643-5", DoubleByteConvert, 1 }

Definition at line 572 of file nsFontMetricsXlib.cpp.

Initial value:
  { "x-cns-11643-6", DoubleByteConvert, 1 }

Definition at line 574 of file nsFontMetricsXlib.cpp.

Initial value:
  { "x-cns-11643-7", DoubleByteConvert, 1 }

Definition at line 576 of file nsFontMetricsXlib.cpp.

Initial value:
  { "windows-1250", SingleByteConvert, 0 }

Definition at line 602 of file nsFontMetricsXlib.cpp.

Initial value:
  { "windows-1251", SingleByteConvert, 0 }

Definition at line 604 of file nsFontMetricsXlib.cpp.

Initial value:
  { "windows-1252", SingleByteConvert, 0 }

Definition at line 606 of file nsFontMetricsXlib.cpp.

Initial value:
  { "windows-1253", SingleByteConvert, 0 }

Definition at line 608 of file nsFontMetricsXlib.cpp.

Initial value:
  { "windows-1257", SingleByteConvert, 0 }

Definition at line 610 of file nsFontMetricsXlib.cpp.

nsFontLangGroupXlib FLG_ARABIC = { "ar", nsnull } [static]

Definition at line 657 of file nsFontMetricsXlib.cpp.

nsFontLangGroupXlib FLG_BALTIC = { "x-baltic", nsnull } [static]

Definition at line 651 of file nsFontMetricsXlib.cpp.

nsFontLangGroupXlib FLG_CE = { "x-central-euro",nsnull } [static]

Definition at line 652 of file nsFontMetricsXlib.cpp.

nsFontLangGroupXlib FLG_GREEK = { "el", nsnull } [static]

Definition at line 654 of file nsFontMetricsXlib.cpp.

nsFontLangGroupXlib FLG_HEBREW = { "he", nsnull } [static]

Definition at line 656 of file nsFontMetricsXlib.cpp.

nsFontLangGroupXlib FLG_JA = { "ja", nsnull } [static]

Definition at line 663 of file nsFontMetricsXlib.cpp.

nsFontLangGroupXlib FLG_KO = { "ko", nsnull } [static]

Definition at line 664 of file nsFontMetricsXlib.cpp.

Definition at line 669 of file nsFontMetricsXlib.cpp.

nsFontLangGroupXlib FLG_RUSSIAN = { "x-cyrillic", nsnull } [static]

Definition at line 653 of file nsFontMetricsXlib.cpp.

nsFontLangGroupXlib FLG_TAMIL = { "x-tamil", nsnull } [static]

Definition at line 668 of file nsFontMetricsXlib.cpp.

nsFontLangGroupXlib FLG_THAI = { "th", nsnull } [static]

Definition at line 658 of file nsFontMetricsXlib.cpp.

nsFontLangGroupXlib FLG_TURKISH = { "tr", nsnull } [static]

Definition at line 655 of file nsFontMetricsXlib.cpp.

nsFontLangGroupXlib FLG_WESTERN = { "x-western", nsnull } [static]

Definition at line 650 of file nsFontMetricsXlib.cpp.

nsFontLangGroupXlib FLG_ZHCN = { "zh-CN", nsnull } [static]

Definition at line 659 of file nsFontMetricsXlib.cpp.

nsFontLangGroupXlib FLG_ZHHK = { "zh-HK", nsnull } [static]

Definition at line 661 of file nsFontMetricsXlib.cpp.

nsFontLangGroupXlib FLG_ZHTW = { "zh-TW", nsnull } [static]

Definition at line 660 of file nsFontMetricsXlib.cpp.

nsFontLangGroupXlib FLG_ZHTWHK = { "x-zh-TWHK", nsnull } [static]

Definition at line 662 of file nsFontMetricsXlib.cpp.

Initial value:
  { "gb18030.2000-0", DoubleByteConvert, 1 }

Definition at line 580 of file nsFontMetricsXlib.cpp.

Initial value:
  { "gb18030.2000-1", DoubleByteConvert, 1 }

Definition at line 582 of file nsFontMetricsXlib.cpp.

Initial value:
  { "gb_2312-80", DoubleByteConvert, 1 }

Definition at line 578 of file nsFontMetricsXlib.cpp.

Initial value:
  { "x-gbk-noascii", DoubleByteConvert, 1 }

Definition at line 584 of file nsFontMetricsXlib.cpp.

Definition at line 697 of file nsFontMetricsXlib.cpp.

Definition at line 860 of file nsFontMetricsXlib.cpp.

Initial value:
{
  { "symbol-adobe-fontspecific", &FLG_NONE, &AdobeSymbol  },
  { "euromono-adobe-fontspecific",  &FLG_NONE, &AdobeEuro },
  { "eurosans-adobe-fontspecific",  &FLG_NONE, &AdobeEuro },
  { "euroserif-adobe-fontspecific", &FLG_NONE, &AdobeEuro },


















 

  { nsnull,                      nsnull        }
}

Definition at line 862 of file nsFontMetricsXlib.cpp.

Initial value:
{
  { "arial",           "helvetica" },
  { "courier new",     "courier" },
  { "times new roman", "times" },






 

  { nsnull, nsnull }
}

Definition at line 844 of file nsFontMetricsXlib.cpp.

Definition at line 122 of file nsFontMetricsXlib.cpp.

Definition at line 1200 of file nsFontMetricsXlib.cpp.

Initial value:
{
  { "block",         5 }, 
  { "bold",          7 }, 
  { "double wide",   9 },
  { "medium",        5 },
  { "narrow",        3 },
  { "normal",        5 },
  { "semicondensed", 4 },
  { "wide",          7 },

  { nsnull,          0 }
}

Definition at line 891 of file nsFontMetricsXlib.cpp.

Initial value:
{
  { "black",    900 },
  { "bold",     700 },
  { "book",     400 },
  { "demi",     600 },
  { "demibold", 600 },
  { "light",    300 },
  { "medium",   400 },
  { "regular",  400 },
  
  { nsnull,     0 }
}

Definition at line 905 of file nsFontMetricsXlib.cpp.

Initial value:
  { "hkscs-1", DoubleByteConvert, 1 }

Definition at line 586 of file nsFontMetricsXlib.cpp.

Initial value:
  { "x-IBM1046", SingleByteConvert, 0 }

Definition at line 517 of file nsFontMetricsXlib.cpp.

Initial value:

Definition at line 620 of file nsFontMetricsXlib.cpp.

Initial value:
  { "ISO-8859-1", SingleByteConvert, 0 }

Definition at line 501 of file nsFontMetricsXlib.cpp.

Initial value:
  { "ISO-8859-11", SingleByteConvert, 0 }

Definition at line 556 of file nsFontMetricsXlib.cpp.

Initial value:
  { "ISO-8859-13", SingleByteConvert, 0 }

Definition at line 536 of file nsFontMetricsXlib.cpp.

Initial value:
  { "ISO-8859-15", SingleByteConvert, 0 }

Definition at line 538 of file nsFontMetricsXlib.cpp.

Initial value:
  { "ISO-8859-2", SingleByteConvert, 0 }

Definition at line 503 of file nsFontMetricsXlib.cpp.

Initial value:
  { "ISO-8859-3", SingleByteConvert, 0 }

Definition at line 505 of file nsFontMetricsXlib.cpp.

Initial value:
  { "ISO-8859-4", SingleByteConvert, 0 }

Definition at line 507 of file nsFontMetricsXlib.cpp.

Initial value:
  { "ISO-8859-5", SingleByteConvert, 0 }

Definition at line 509 of file nsFontMetricsXlib.cpp.

Initial value:
  { "ISO-8859-6", SingleByteConvert, 0 }

Definition at line 511 of file nsFontMetricsXlib.cpp.

Initial value:
  { "x-iso-8859-6-16", SingleByteConvert, 0 }

Definition at line 515 of file nsFontMetricsXlib.cpp.

Initial value:
  { "x-iso-8859-6-8-x", SingleByteConvert, 0 }

Definition at line 513 of file nsFontMetricsXlib.cpp.

Initial value:
  { "ISO-8859-7", SingleByteConvert, 0 }

Definition at line 519 of file nsFontMetricsXlib.cpp.

Initial value:
  { "ISO-8859-8", SingleByteConvert, 0 }

Definition at line 521 of file nsFontMetricsXlib.cpp.

Initial value:
  { "ISO-8859-9", SingleByteConvert, 0 }

Definition at line 526 of file nsFontMetricsXlib.cpp.

Initial value:
  { "x-koreanjamo-0", DoubleByteConvert, 1 }

Definition at line 598 of file nsFontMetricsXlib.cpp.

Initial value:
  { "jis_0201", SingleByteConvert, 1 }

Definition at line 540 of file nsFontMetricsXlib.cpp.

Initial value:
  { "jis_0208-1983", DoubleByteConvert, 1 }

Definition at line 588 of file nsFontMetricsXlib.cpp.

Initial value:
  { "jis_0212-1990", DoubleByteConvert, 1 }

Definition at line 590 of file nsFontMetricsXlib.cpp.

Initial value:
  { "x-johab-noascii", DoubleByteConvert, 1 }

Definition at line 596 of file nsFontMetricsXlib.cpp.

Initial value:
  { "KOI8-R", SingleByteConvert, 0 }

Definition at line 542 of file nsFontMetricsXlib.cpp.

Initial value:
  { "KOI8-U", SingleByteConvert, 0 }

Definition at line 544 of file nsFontMetricsXlib.cpp.

Initial value:
  { "ks_c_5601-1987", DoubleByteConvert, 1 }

Definition at line 592 of file nsFontMetricsXlib.cpp.

Definition at line 287 of file nsFontMetricsXlib.cpp.

Initial value:
  { "x-tamilttf-0", DoubleByteConvert, 0 }

Definition at line 600 of file nsFontMetricsXlib.cpp.

Initial value:
  { "TIS-620", SingleByteConvert, 0 }

Definition at line 554 of file nsFontMetricsXlib.cpp.

Initial value:




  { "windows-874", SingleByteConvert, 0 }

Definition at line 546 of file nsFontMetricsXlib.cpp.

Definition at line 286 of file nsFontMetricsXlib.cpp.

Initial value:
  { "us-ascii", SingleByteConvert, 0 }

Definition at line 499 of file nsFontMetricsXlib.cpp.

Initial value:
  { "x-x11johab", DoubleByteConvert, 1 }

Definition at line 594 of file nsFontMetricsXlib.cpp.