Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Enumerations | Functions | Variables
nsFontMetricsWin.cpp File Reference
#include "nsIPref.h"
#include "nsIServiceManager.h"
#include "nsILanguageAtomService.h"
#include "nsICharsetConverterManager.h"
#include "nsICharRepresentable.h"
#include "nsISaveAsCharset.h"
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "nsFontMetricsWin.h"
#include "nsQuickSort.h"
#include "nsTextFormatter.h"
#include "nsIFontPackageProxy.h"
#include "nsIPersistentProperties2.h"
#include "nsNetUtil.h"
#include "prmem.h"
#include "plhash.h"
#include "prprf.h"
#include "nsReadableUtils.h"
#include "nsUnicodeRange.h"
#include "nsAutoBuffer.h"
#include "ignorable.x-ccmap"
#include "blank_glyph.ccmap"

Go to the source code of this file.

Classes

struct  nsCharsetInfo
class  nsFontCleanupObserver
class  nsFontSubset
class  nsFontSubsetSubstitute
class  nsFontInfo
class  nsGlyphAgent
class  nsFontWinUnicode
class  nsFontWinNonUnicode
class  nsFontWeightEntry
struct  nsFontWeightInfo
struct  GenericFontEnumContext

Defines

#define DEFAULT_TTF_SYMBOL_ENCODING   "windows-1252"
#define IS_RTL_PRESENTATION_FORM(c)   ((0xfb1d <= (c)) && ((c)<= 0xfefc))
#define NOT_SETUP   0x33
#define USER_DEFINED   "x-user-def"
#define NS_REPLACEMENT_CHAR   PRUnichar(0x003F)
#define NS_MAX_FONT_WEIGHT   900
#define NS_MIN_FONT_WEIGHT   100
#define CHAR_BUFFER_SIZE   1024
#define CLIP_TURNOFF_FONTASSOCIATION   0x40
#define CFF   (('C') | ('F' << 8) | ('F' << 16) | (' ' << 24))
#define CMAP   (('c') | ('m' << 8) | ('a' << 16) | ('p' << 24))
#define HEAD   (('h') | ('e' << 8) | ('a' << 16) | ('d' << 24))
#define LOCA   (('l') | ('o' << 8) | ('c' << 16) | ('a' << 24))
#define NAME   (('n') | ('a' << 8) | ('m' << 16) | ('e' << 24))
#define AUTO_FONTDATA_BUFFER_SIZE   16384 /* 16K */
#define SHOULD_BE_SPACE_CHAR(ch)   (CCMAP_HAS_CHAR(gCharsWithBlankGlyphCCMap,ch))
#define MAKE_FONT_PREF_KEY(_pref, _s0, _s1)
#define IsCJKLangGroupAtom(a)
#define DEBUG_VERIFY_FONT_HASGLYPH(font, string, length)

Typedefs

typedef nsAutoBuffer< char,
CHAR_BUFFER_SIZE
nsAutoCharBuffer
typedef nsAutoBuffer
< PRUnichar, CHAR_BUFFER_SIZE
nsAutoChar16Buffer
typedef nsAutoBuffer< PRUint8,
AUTO_FONTDATA_BUFFER_SIZE
nsAutoFontDataBuffer

Enumerations

enum  eCharset {
  eCharset_DEFAULT = 0, eCharset_ANSI, eCharset_EASTEUROPE, eCharset_RUSSIAN,
  eCharset_GREEK, eCharset_TURKISH, eCharset_HEBREW, eCharset_ARABIC,
  eCharset_BALTIC, eCharset_THAI, eCharset_SHIFTJIS, eCharset_GB2312,
  eCharset_HANGEUL, eCharset_CHINESEBIG5, eCharset_JOHAB, eCharset_COUNT
}
enum  eGetNameError { eGetName_OK = 0, eGetName_GDIError, eGetName_OtherError }
enum  { eTTPlatformIDUnicode = 0, eTTPlatformIDMacintosh = 1, eTTPlatformIDMicrosoft = 3 }
enum  { eTTMicrosoftEncodingSymbol = 0, eTTMicrosoftEncodingUnicode = 1, eTTMicrosoftEncodingUCS4 = 10 }
enum  {
  eTTFormatUninitialize = -1, eTTFormat0ByteEncodingTable = 0, eTTFormat2HighbyteMappingThroughTable = 2, eTTFormat4SegmentMappingToDeltaValues = 4,
  eTTFormat6TrimmedTableMapping = 6, eTTFormat8Mixed16bitAnd32bitCoverage = 8, eTTFormat10TrimmedArray = 10, eTTFormat12SegmentedCoverage = 12
}
enum  eGlyphAgent { eGlyphAgent_UNKNOWN = -1, eGlyphAgent_UNICODE, eGlyphAgent_ANSI }

Functions

PRBool IsWin95OrWin98 ()
PRBool UseAFunctions ()
static PRUint16GenerateDefault (nsCharsetInfo *aSelf)
static PRUint16GenerateSingleByte (nsCharsetInfo *aSelf)
static PRUint16GenerateMultiByte (nsCharsetInfo *aSelf)
static PRBool LookupWinFontName (const nsAFlatString &aName, nsAString &aWinName)
static NS_DEFINE_CID (kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID)
static NS_DEFINE_CID (kPrefCID, NS_PREF_CID)
 DEFINE_X_CCMAP (gIgnorableCCMapExt,)
static void FreeGlobals (void)
static nsresult InitGlobals (void)
static void CheckFontLangGroup (nsIAtom *lang1, nsIAtom *lang2, const char *lang3)
static PRUint16 GetGlyphIndex (PRUint16 segCount, PRUint16 *endCode, PRUint16 *startCode, PRUint16 *idRangeOffset, PRUint16 *idDelta, PRUint8 *end, PRUint16 aChar)
static eGetNameError GetNAME (HDC aDC, nsString *aName, PRBool *aIsSymbolEncoding=nsnull)
static PLHashNumber HashKey (const void *aString)
static PRIntn CompareKeys (const void *aStr1, const void *aStr2)
static int GetIndexToLocFormat (HDC aDC)
static nsresult GetSpaces (HDC aDC, PRBool *aIsCFFOutline, PRUint32 *aMaxGlyph, nsAutoFontDataBuffer &aIsSpace)
static nsresult GetCustomEncoding (const char *aFontName, nsCString &aValue, PRBool *aIsWide)
static nsresult GetConverterCommon (const char *aEncoding, nsIUnicodeEncoder **aConverter)
static nsresult GetDefaultConverterForTTFSymbolEncoding (nsIUnicodeEncoder **aConverter)
static nsresult GetConverter (const char *aFontName, PRBool aNameQuirks, nsIUnicodeEncoder **aConverter, PRBool *aIsWide=nsnull)
static PRUint16GetCCMapThroughConverter (const char *aFontName, PRBool aNameQuirks)
static nsresult ConvertUnicodeToGlyph (const PRUnichar *aSrc, PRInt32 aSrcLength, PRInt32 &aDestLength, nsIUnicodeEncoder *aConverter, PRBool aIsWide, nsAutoCharBuffer &aResult)
 PR_STATIC_CALLBACK (void *) fontmap_AllocTable(void *pool
 DEFINE_CCMAP (gCharsWithBlankGlyphCCMap, const)
static void ReadCMAPTableFormat12 (PRUint8 *aBuf, PRInt32 len, PRUint32 **aExtMap)
static void ReadCMAPTableFormat4 (PRUint8 *aBuf, PRInt32 aLength, PRUint32 *aMap, PRBool aIsCFFOutline, PRUint8 *aIsSpace, PRUint32 aMaxGlyph)
static nsresult GetGlyphIndices (HDC aDC, nsCharacterMap **aCMAP, const PRUnichar *aString, PRUint32 aLength, nsAutoChar16Buffer &aResult)
static int CALLBACK enumProc (const LOGFONT *logFont, const TEXTMETRIC *metrics, DWORD fontType, LPARAM hasFontSig)
static int PR_CALLBACK CompareGlobalFonts (const void *aArg1, const void *aArg2, void *aClosure)
static void BitFromUnicodeRange (PRUint32 range, DWORD *usb)
static PLHashNumber HashKeyFontWeight (const void *aFontWeightEntry)
static PRIntn CompareKeysFontWeight (const void *aFontWeightEntry1, const void *aFontWeightEntry2)
static int CALLBACK nsFontWeightCallback (const LOGFONT *logFont, const TEXTMETRIC *metrics, DWORD fontType, LPARAM closure)
static void SearchSimulatedFontWeight (HDC aDC, nsFontWeightInfo *aWeightInfo)
static PRBool PR_CALLBACK GenericFontEnumCallback (const nsString &aFamily, PRBool aGeneric, void *aData)
static void AppendGenericFontFromPref (nsString &aFontname, const char *aLangGroup, const char *aGeneric)
static PRBool FontEnumCallback (const nsString &aFamily, PRBool aGeneric, void *aData)
static PRBool NS_ExtTextOutA (HDC aDC, nsFontWin *aFont, PRInt32 aX, PRInt32 aY, UINT uOptions, LPCRECT lprc, LPCSTR aString, UINT aLength, INT *lpDx)
static PRBool NS_ExtTextOutW (HDC aDC, nsFontWin *aFont, PRInt32 aX, PRInt32 aY, UINT uOptions, LPCRECT lprc, LPCWSTR aString, UINT aLength, INT *lpDx)
static nsresult SubstituteChars (PRBool aDisplayUnicode, const PRUnichar *aString, PRUint32 aLength, nsAutoChar16Buffer &aResult, PRUint32 *aCount)
static int HaveConverterFor (PRUint8 aCharset)
static int SystemSupportsChar (PRUnichar aChar)
static int InitializeFontEnumerator (void)
static int CompareFontNames (const void *aArg1, const void *aArg2, void *aClosure)
static int SignatureMatchesLangGroup (FONTSIGNATURE *aSignature, const char *aLangGroup)
static int FontMatchesGenericType (nsGlobalFont *aFont, const char *aGeneric)
static nsresult EnumerateMatchingFonts (const char *aLangGroup, const char *aGeneric, PRUint32 *aCount, PRUnichar ***aResult)

Variables

static PRBool gIsWIN95OR98 = NOT_SETUP
static nsIPersistentPropertiesgFontEncodingProperties = nsnull
static nsIPersistentPropertiesgFontNameMapProperties = nsnull
static nsICharsetConverterManagergCharsetManager = nsnull
static nsIUnicodeEncodergUserDefinedConverter = nsnull
static nsISaveAsCharsetgFontSubstituteConverter = nsnull
static nsIPrefgPref = nsnull
static nsIFontPackageProxygFontPackageProxy = nsnull
static nsIAtomgUsersLocale = nsnull
static nsIAtomgSystemLocale = nsnull
static nsIAtomgUserDefined = nsnull
static nsIAtomgJA = nsnull
static nsIAtomgKO = nsnull
static nsIAtomgZHTW = nsnull
static nsIAtomgZHCN = nsnull
static nsIAtomgZHHK = nsnull
static nsStringgCodepageStr = nsnull
static int gInitialized = 0
static PRBool gDoingLineheightFixup = PR_FALSE
static PRUint16gUserDefinedCCMap = nsnull
static nsFontWingFontForIgnorable = nsnull
static nsCharsetInfo gCharsetInfo [eCharset_COUNT]
static nsFontCleanupObservergFontCleanupObserver
static PRUint8 gBitToCharset [64]
static eCharset gCharsetToIndex [256]
static PRUint8 gCharsetToBit [eCharset_COUNT]
static PRUint8 gBitToUnicodeRange []
nsGlyphAgent gGlyphAgent
static int gInitializedFontEnumerator = 0

Class Documentation

struct nsFontWeightInfo

Definition at line 3069 of file nsFontMetricsWin.cpp.

Collaboration diagram for nsFontWeightInfo:
Class Members
int mFontCount
LOGFONT mLogFont
PRUint16 mWeights
struct GenericFontEnumContext

Definition at line 1079 of file nsFontMetricsOS2.cpp.

Collaboration diagram for GenericFontEnumContext:
Class Members
PRUint32 mChar
HDC mDC
nsFontOS2 * mFont
nsFontWin * mFont
nsFontMetricsOS2 * mMetrics
nsFontMetricsWin * mMetrics
HPS mPS

Define Documentation

#define AUTO_FONTDATA_BUFFER_SIZE   16384 /* 16K */

Definition at line 680 of file nsFontMetricsWin.cpp.

#define CFF   (('C') | ('F' << 8) | ('F' << 16) | (' ' << 24))

Definition at line 655 of file nsFontMetricsWin.cpp.

Definition at line 289 of file nsFontMetricsWin.cpp.

Definition at line 606 of file nsFontMetricsWin.cpp.

#define CMAP   (('c') | ('m' << 8) | ('a' << 16) | ('p' << 24))

Definition at line 657 of file nsFontMetricsWin.cpp.

Definition at line 4340 of file nsFontMetricsWin.cpp.

#define DEFAULT_TTF_SYMBOL_ENCODING   "windows-1252"

Definition at line 64 of file nsFontMetricsWin.cpp.

#define HEAD   (('h') | ('e' << 8) | ('a' << 16) | ('d' << 24))

Definition at line 659 of file nsFontMetricsWin.cpp.

#define IS_RTL_PRESENTATION_FORM (   c)    ((0xfb1d <= (c)) && ((c)<= 0xfefc))

Definition at line 65 of file nsFontMetricsWin.cpp.

Value:
((a)==gJA || (a)==gKO || (a)==gZHCN || \
                                (a)==gZHTW || (a) == gZHHK)

Definition at line 3519 of file nsFontMetricsWin.cpp.

#define LOCA   (('l') | ('o' << 8) | ('c' << 16) | ('a' << 24))

Definition at line 661 of file nsFontMetricsWin.cpp.

#define MAKE_FONT_PREF_KEY (   _pref,
  _s0,
  _s1 
)
Value:
_pref.Assign(_s0); \
 _pref.Append(_s1);

Definition at line 3429 of file nsFontMetricsWin.cpp.

#define NAME   (('n') | ('a' << 8) | ('m' << 16) | ('e' << 24))

Definition at line 663 of file nsFontMetricsWin.cpp.

#define NOT_SETUP   0x33

Definition at line 67 of file nsFontMetricsWin.cpp.

Definition at line 146 of file nsFontMetricsWin.cpp.

Definition at line 147 of file nsFontMetricsWin.cpp.

Definition at line 97 of file nsFontMetricsWin.cpp.

#define SHOULD_BE_SPACE_CHAR (   ch)    (CCMAP_HAS_CHAR(gCharsWithBlankGlyphCCMap,ch))

Definition at line 1564 of file nsFontMetricsWin.cpp.

#define USER_DEFINED   "x-user-def"

Definition at line 94 of file nsFontMetricsWin.cpp.


Typedef Documentation

Definition at line 292 of file nsFontMetricsWin.cpp.

Definition at line 291 of file nsFontMetricsWin.cpp.

Definition at line 682 of file nsFontMetricsWin.cpp.


Enumeration Type Documentation

anonymous enum
Enumerator:
eTTPlatformIDUnicode 
eTTPlatformIDMacintosh 
eTTPlatformIDMicrosoft 

Definition at line 1566 of file nsFontMetricsWin.cpp.

anonymous enum
Enumerator:
eTTMicrosoftEncodingSymbol 
eTTMicrosoftEncodingUnicode 
eTTMicrosoftEncodingUCS4 

Definition at line 1571 of file nsFontMetricsWin.cpp.

anonymous enum
Enumerator:
eTTFormatUninitialize 
eTTFormat0ByteEncodingTable 
eTTFormat2HighbyteMappingThroughTable 
eTTFormat4SegmentMappingToDeltaValues 
eTTFormat6TrimmedTableMapping 
eTTFormat8Mixed16bitAnd32bitCoverage 
eTTFormat10TrimmedArray 
eTTFormat12SegmentedCoverage 

Definition at line 1578 of file nsFontMetricsWin.cpp.

enum eCharset
Enumerator:
eCharset_DEFAULT 
eCharset_ANSI 
eCharset_EASTEUROPE 
eCharset_RUSSIAN 
eCharset_GREEK 
eCharset_TURKISH 
eCharset_HEBREW 
eCharset_ARABIC 
eCharset_BALTIC 
eCharset_THAI 
eCharset_SHIFTJIS 
eCharset_GB2312 
eCharset_HANGEUL 
eCharset_CHINESEBIG5 
eCharset_JOHAB 
eCharset_COUNT 

Definition at line 103 of file nsFontMetricsWin.cpp.

Enumerator:
eGetName_OK 
eGetName_GDIError 
eGetName_OtherError 

Definition at line 714 of file nsFontMetricsWin.cpp.

{
  eGetName_OK = 0,    // exit code for a TrueType font
  eGetName_GDIError,  // we use this internally to flag a raster (bitmap) font
  eGetName_OtherError // unknown error, the font can't be used
};
Enumerator:
eGlyphAgent_UNKNOWN 
eGlyphAgent_UNICODE 
eGlyphAgent_ANSI 

Definition at line 2095 of file nsFontMetricsWin.cpp.


Function Documentation

static void AppendGenericFontFromPref ( nsString aFontname,
const char *  aLangGroup,
const char *  aGeneric 
) [static]

Definition at line 3434 of file nsFontMetricsWin.cpp.

{
  nsresult res;
  nsCAutoString pref;
  nsXPIDLString value;
  nsCAutoString generic_dot_langGroup;

  generic_dot_langGroup.Assign(aGeneric);
  generic_dot_langGroup.Append('.');
  generic_dot_langGroup.Append(aLangGroup);

  // font.name.[generic].[langGroup]
  // the current user' selected font, it gives the first preferred font
  MAKE_FONT_PREF_KEY(pref, "font.name.", generic_dot_langGroup);
  res = gPref->CopyUnicharPref(pref.get(), getter_Copies(value));      
  if (NS_SUCCEEDED(res)) {
    if(!aFontname.IsEmpty())
      aFontname.Append((PRUnichar)',');
    aFontname.Append(value);
  }

  // font.name-list.[generic].[langGroup]
  // the pre-built list of default fonts, it gives alternative fonts
  MAKE_FONT_PREF_KEY(pref, "font.name-list.", generic_dot_langGroup);
  res = gPref->CopyUnicharPref(pref.get(), getter_Copies(value));      
  if (NS_SUCCEEDED(res)) {
    if(!aFontname.IsEmpty())
      aFontname.Append((PRUnichar)',');
    aFontname.Append(value);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void BitFromUnicodeRange ( PRUint32  range,
DWORD usb 
) [static]

Definition at line 2753 of file nsFontMetricsWin.cpp.

{
  for (int i = 0, dword = 0; dword < 3; ++dword) {
    for (int bit = 0; bit < sizeof(DWORD) * 8; ++bit, ++i) {
      if (range == gBitToUnicodeRange[i]) {
        usb[dword] |= 1 << bit;
      }
    }
  }
}

Here is the caller graph for this function:

static void CheckFontLangGroup ( nsIAtom lang1,
nsIAtom lang2,
const char *  lang3 
) [static]

Definition at line 494 of file nsFontMetricsWin.cpp.

{
  if (lang1 == lang2) {
    nsresult res = NS_OK;
    if (!gFontPackageProxy) {
      res = CallGetService("@mozilla.org/intl/fontpackageservice;1",
                           &gFontPackageProxy);
      if (NS_FAILED(res)) {
        NS_ERROR("Cannot get the font package proxy");
        return;
      }
    }

    char fontpackageid[256];
    PR_snprintf(fontpackageid, sizeof(fontpackageid), "lang:%s", lang3);
    res = gFontPackageProxy->NeedFontPackage(fontpackageid);
    NS_ASSERTION(NS_SUCCEEDED(res), "cannot notify missing font package ");
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 5641 of file nsFontMetricsWin.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 int PR_CALLBACK CompareGlobalFonts ( const void aArg1,
const void aArg2,
void aClosure 
) [static]

Definition at line 2672 of file nsFontMetricsWin.cpp.

{
  const nsGlobalFont* font1 = (const nsGlobalFont*)aArg1;
  const nsGlobalFont* font2 = (const nsGlobalFont*)aArg2;

  // Sorting criteria is like a tree:
  // + TrueType fonts
  //    + non-Symbol fonts
  //    + Symbol fonts
  // + non-TrueType fonts
  //    + non-Symbol fonts
  //    + Symbol fonts
  PRInt32 weight1 = 0, weight2 = 0; // computed as node mask 
  if (!(font1->flags & NS_GLOBALFONT_TRUETYPE))
    weight1 |= 0x2;
  if (!(font2->flags & NS_GLOBALFONT_TRUETYPE))
    weight2 |= 0x2; 
  if (font1->flags & NS_GLOBALFONT_SYMBOL)
    weight1 |= 0x1;
  if (font2->flags & NS_GLOBALFONT_SYMBOL)
    weight2 |= 0x1;

  return weight1 - weight2;
}

Here is the caller graph for this function:

static PRIntn CompareKeys ( const void aStr1,
const void aStr2 
) [static]

Definition at line 806 of file nsFontMetricsWin.cpp.

{
  return nsCRT::strcmp(((const nsString*) aStr1)->get(),
    ((const nsString*) aStr2)->get()) == 0;
}

Here is the caller graph for this function:

static PRIntn CompareKeysFontWeight ( const void aFontWeightEntry1,
const void aFontWeightEntry2 
) [static]

Definition at line 3016 of file nsFontMetricsWin.cpp.

{
  const nsString* str1 = &((const nsFontWeightEntry*) aFontWeightEntry1)->mFontName;
  const nsString* str2 = &((const nsFontWeightEntry*) aFontWeightEntry2)->mFontName;
  return nsCRT::strcmp(str1->get(), str2->get()) == 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult ConvertUnicodeToGlyph ( const PRUnichar aSrc,
PRInt32  aSrcLength,
PRInt32 aDestLength,
nsIUnicodeEncoder aConverter,
PRBool  aIsWide,
nsAutoCharBuffer aResult 
) [static]

Definition at line 1459 of file nsFontMetricsWin.cpp.

{
  if (aIsWide && 
      NS_FAILED(aConverter->GetMaxLength(aSrc, aSrcLength, &aDestLength))) {
    return NS_ERROR_UNEXPECTED;
  }

  if (!aResult.EnsureElemCapacity(aDestLength)) return NS_ERROR_OUT_OF_MEMORY;
  char* str = aResult.get();

  aConverter->Convert(aSrc, &aSrcLength, str, &aDestLength);

#ifdef IS_LITTLE_ENDIAN
  // Convert BE UCS2 to LE UCS2 for 'wide' fonts
  if (aIsWide) {
    char* pstr = str;
    while (pstr < str + aDestLength) {
      PRUint8 tmp = pstr[0];
      pstr[0] = pstr[1];
      pstr[1] = tmp;
      pstr += 2;  // swap every two bytes
    }
  }
#endif
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

DEFINE_CCMAP ( gCharsWithBlankGlyphCCMap  ,
const   
)
DEFINE_X_CCMAP ( gIgnorableCCMapExt  )
static nsresult EnumerateMatchingFonts ( const char *  aLangGroup,
const char *  aGeneric,
PRUint32 aCount,
PRUnichar ***  aResult 
) [static]

Definition at line 5742 of file nsFontMetricsWin.cpp.

{
  // aLangGroup=null or ""  means any (i.e., don't care)
  // aGeneric=null or ""  means any (i.e, don't care)

  NS_ENSURE_ARG_POINTER(aCount);
  NS_ENSURE_ARG_POINTER(aResult);

  *aCount = 0;
  *aResult = nsnull;

  if (aLangGroup && *aLangGroup && 
     (!strcmp(aLangGroup, "x-unicode") ||
      !strcmp(aLangGroup, "x-user-def"))) {
    return EnumerateMatchingFonts(nsnull, nsnull, aCount, aResult);
  }

  if (!gInitializedFontEnumerator) {
    if (!InitializeFontEnumerator()) {
      return NS_ERROR_FAILURE;
    }
  }

  int count = nsFontMetricsWin::gGlobalFonts->Count();
  PRUnichar** array = (PRUnichar**)nsMemory::Alloc(count * sizeof(PRUnichar*));
  if (!array) {
    return NS_ERROR_OUT_OF_MEMORY;
  }
  int j = 0;
  for (int i = 0; i < count; ++i) {
    nsGlobalFont* font = (nsGlobalFont*)nsFontMetricsWin::gGlobalFonts->ElementAt(i);
    PRBool accept = PR_TRUE;
    if (aLangGroup && *aLangGroup) {
      accept = SignatureMatchesLangGroup(&font->signature, aLangGroup);
    }
    if (accept && aGeneric && *aGeneric) {
      accept = FontMatchesGenericType(font, aGeneric);
    }
    if (accept) {
      PRUnichar* str = ToNewUnicode(font->name);
      if (!str) {
        for (j = j - 1; j >= 0; --j) {
          nsMemory::Free(array[j]);
        }
        nsMemory::Free(array);
        return NS_ERROR_OUT_OF_MEMORY;
      }
      array[j] = str;
      ++j;
    }
  }

  NS_QuickSort(array, j, sizeof(PRUnichar*), CompareFontNames, nsnull);

  *aCount = j;
  *aResult = array;

  return NS_OK;
}

Here is the call graph for this function:

static int CALLBACK enumProc ( const LOGFONT *  logFont,
const TEXTMETRIC *  metrics,
DWORD  fontType,
LPARAM  hasFontSig 
) [static]

Definition at line 2597 of file nsFontMetricsWin.cpp.

{
  // XXX ignore vertical fonts
  if (logFont->lfFaceName[0] == '@') {
    return 1;
  }

  for (int i = nsFontMetricsWin::gGlobalFonts->Count()-1; i >= 0; --i) {
    nsGlobalFont* font = (nsGlobalFont*)nsFontMetricsWin::gGlobalFonts->ElementAt(i);
    if (!strcmp(font->logFont.lfFaceName, logFont->lfFaceName)) {
      // work-around for Win95/98 problem 
      int charsetSigBit = gCharsetToBit[gCharsetToIndex[logFont->lfCharSet]];
      if (charsetSigBit >= 0) {
        DWORD charsetSigAdd = 1 << charsetSigBit;
        font->signature.fsCsb[0] |= charsetSigAdd;
      }

      // copy Unicode subrange bitfield (128bit) if it's a truetype font. 
      if (fontType & hasFontSig) {
#ifndef WINCE
        memcpy(font->signature.fsUsb, ((NEWTEXTMETRICEX*)metrics)->ntmFontSig.fsUsb, 16);
#else
        memset(font->signature.fsUsb, '\0', 16);
#endif
      }
      return 1;
    }
  }

  // XXX make this smarter: don't add font to list if we already have a font
  // with the same font signature -- erik

  PRUnichar name[LF_FACESIZE];
  name[0] = 0;
  MultiByteToWideChar(CP_ACP, 0, logFont->lfFaceName,
    strlen(logFont->lfFaceName) + 1, name, sizeof(name)/sizeof(name[0]));

  nsGlobalFont* font = new nsGlobalFont;
  if (!font) {
    return 0;
  }
  font->name.Assign(name);
  font->ccmap = nsnull;
  font->logFont = *logFont;
  font->signature.fsCsb[0] = 0;
  font->signature.fsCsb[1] = 0;
  font->fonttype = eFontType_UNKNOWN;
  font->flags = 0;

  if (fontType & hasFontSig) {
    font->flags |= NS_GLOBALFONT_TRUETYPE;
#ifndef WINCE
    // copy Unicode subrange bitfield (128 bits = 16 bytes)
    memcpy(font->signature.fsUsb, ((NEWTEXTMETRICEX*)metrics)->ntmFontSig.fsUsb, 16);
#else
    memset(font->signature.fsUsb, '\0', 16);
#endif
  }

  if (logFont->lfCharSet == SYMBOL_CHARSET) {
    font->flags |= NS_GLOBALFONT_SYMBOL;
  }

  int charsetSigBit = gCharsetToBit[gCharsetToIndex[logFont->lfCharSet]];
  if (charsetSigBit >= 0) {
    DWORD charsetSigAdd = 1 << charsetSigBit;
    font->signature.fsCsb[0] |= charsetSigAdd;
  }

  nsFontMetricsWin::gGlobalFonts->AppendElement(font);
  return 1;
}

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 3660 of file nsFontMetricsWin.cpp.

{
  nsFontMetricsWin* metrics = (nsFontMetricsWin*) aData;
  metrics->mFonts.AppendString(aFamily);
  if (aGeneric) {
    metrics->mGeneric.Assign(aFamily);
    ToLowerCase(metrics->mGeneric);
    return PR_FALSE; // stop
  }
  ++metrics->mGenericIndex;

  return PR_TRUE; // don't stop
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int FontMatchesGenericType ( nsGlobalFont aFont,
const char *  aGeneric 
) [static]

Definition at line 5711 of file nsFontMetricsWin.cpp.

{
  PRUint8 family = aFont->logFont.lfPitchAndFamily & 0xF0;
  PRUint8 pitch = aFont->logFont.lfPitchAndFamily & 0x0F;

  // Japanese 'Mincho' fonts do not belong to FF_MODERN even if
  // they are fixed pitch because they have variable stroke width.
  if (family == FF_ROMAN && pitch & FIXED_PITCH) {
    return !strcmp(aGeneric, "monospace");
  }

  // Japanese 'Gothic' fonts do not belong to FF_SWISS even if
  // they are variable pitch because they have constant stroke width.
  if (family == FF_MODERN && pitch & VARIABLE_PITCH) {
    return !strcmp(aGeneric, "sans-serif");
  }

  // All other fonts will be grouped correctly using family...
  switch (family) {
    case FF_DONTCARE:   return 1;
    case FF_ROMAN:      return !strcmp(aGeneric, "serif");
    case FF_SWISS:      return !strcmp(aGeneric, "sans-serif");
    case FF_MODERN:     return !strcmp(aGeneric, "monospace");
    case FF_SCRIPT:     return !strcmp(aGeneric, "cursive");
    case FF_DECORATIVE: return !strcmp(aGeneric, "fantasy");
  }

  return 0;
}

Here is the caller graph for this function:

static void FreeGlobals ( void  ) [static]

Definition at line 202 of file nsFontMetricsWin.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static PRUint16 * GenerateDefault ( nsCharsetInfo aSelf) [static]

Definition at line 4716 of file nsFontMetricsWin.cpp.

{ 
  PRUint32 map[UCS2_MAP_LEN];

  memset(map, 0xff, sizeof(map));
  return MapToCCMap(map);
}

Here is the call graph for this function:

static PRUint16 * GenerateMultiByte ( nsCharsetInfo aSelf) [static]

Definition at line 4782 of file nsFontMetricsWin.cpp.

{ 
  PRUint32 map[UCS2_MAP_LEN];
  memset(map, 0, sizeof(map));
  for (WCHAR c = 0; c < 0xFFFF; ++c) {
    BOOL defaulted = FALSE;
    WideCharToMultiByte(aSelf->mCodePage, 0, &c, 1, nsnull, 0, nsnull,
      &defaulted);
    if (!defaulted) {
      ADD_GLYPH(map, c);
    }
  }
  return MapToCCMap(map);
}

Here is the call graph for this function:

static PRUint16 * GenerateSingleByte ( nsCharsetInfo aSelf) [static]

Definition at line 4725 of file nsFontMetricsWin.cpp.

{ 
  PRUint32 map[UCS2_MAP_LEN];
  PRUint8 mb[256];
  WCHAR wc[256];
  int i;

  memset(map, 0, sizeof(map));
  if (UseAFunctions()) {
    // A-functions use this function for TrueType
    for (i = 0; i <= 255; ++i) {
      mb[i] = i;
    }
  } else {
    memset(mb + 128, 0, 160 - 128);
    for (i = 0; i <= 127; ++i) {
      mb[i] = i;
    }
    mb[145] = 145;
    mb[146] = 146;

    if (aSelf->mCodePage == 1250) {
      mb[138] = 138;
      mb[140] = 140;
      mb[141] = 141;
      mb[142] = 142;
      mb[143] = 143;
      mb[154] = 154;
      mb[156] = 156;
      mb[158] = 158;
      mb[159] = 159;
    }

    for (i = 160; i <= 255; ++i) {
      mb[i] = i;
    }

    //win95/98 have problem in some raster fonts (MS Sans Serif and MS Serif) in
    //rendering 0xb7. So let's skip this in charmap, that will let system resort 
    //to other fonts.  
    if (IsWin95OrWin98())
      mb[0xb7] = 0;
  }

  int len = MultiByteToWideChar(aSelf->mCodePage, 0, (char*) mb, 256, wc, 256);
#ifdef NS_DEBUG
  if (len != 256) {
    printf("%s: MultiByteToWideChar returned %d\n", aSelf->mName, len);
  }
#endif
  for (i = 0; i <= 255; ++i) {
    ADD_GLYPH(map, wc[i]);
  }
  return MapToCCMap(map);
}

Here is the call graph for this function:

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

Definition at line 3416 of file nsFontMetricsWin.cpp.

{
  GenericFontEnumContext* context = (GenericFontEnumContext*)aData;
  HDC dc = context->mDC;
  PRUint32 ch = context->mChar;
  nsFontMetricsWin* metrics = context->mMetrics;
  context->mFont = metrics->LoadGenericFont(dc, ch, aFamily);
  if (context->mFont) {
    return PR_FALSE; // stop enumerating the list
  }
  return PR_TRUE; // don't stop
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRUint16* GetCCMapThroughConverter ( const char *  aFontName,
PRBool  aNameQuirks 
) [static]

Definition at line 1446 of file nsFontMetricsWin.cpp.

{
  // see if we know something about the converter of this font 
  nsCOMPtr<nsIUnicodeEncoder> converter;
  if (NS_SUCCEEDED(GetConverter(aFontName, aNameQuirks, getter_AddRefs(converter)))) {
    nsCOMPtr<nsICharRepresentable> mapper(do_QueryInterface(converter));
    if (mapper)
      return MapperToCCMap(mapper);
  } 
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult GetConverter ( const char *  aFontName,
PRBool  aNameQuirks,
nsIUnicodeEncoder **  aConverter,
PRBool aIsWide = nsnull 
) [static]

Definition at line 1416 of file nsFontMetricsWin.cpp.

{
  *aConverter = nsnull;

  if (aNameQuirks) {
#ifdef NS_DEBUG
    // we don't apply the quirky behavior to wide Non-Unicode fonts
    nsCAutoString value;
    PRBool isWide = PR_FALSE;
    NS_ASSERTION(NS_FAILED(GetCustomEncoding(aFontName, value, &isWide)) || !isWide,
                 "internal error -- shouldn't get here");
#endif
    return GetDefaultConverterForTTFSymbolEncoding(aConverter);
  }

  nsCAutoString value;
  PRBool isWide = PR_FALSE;
  nsresult rv = GetCustomEncoding(aFontName, value, &isWide);
  if (NS_FAILED(rv)) return rv;
  if (aIsWide) {
    *aIsWide = isWide;
  }

  return GetConverterCommon(value.get(), aConverter);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult GetConverterCommon ( const char *  aEncoding,
nsIUnicodeEncoder **  aConverter 
) [static]

Definition at line 1400 of file nsFontMetricsWin.cpp.

{
  *aConverter = nsnull;
  nsresult rv;
  rv = gCharsetManager->GetUnicodeEncoderRaw(aEncoding, aConverter);
  if (NS_FAILED(rv)) return rv;
  return (*aConverter)->SetOutputErrorBehavior((*aConverter)->kOnError_Replace, nsnull, '?');
}

Here is the caller graph for this function:

static nsresult GetCustomEncoding ( const char *  aFontName,
nsCString aValue,
PRBool aIsWide 
) [static]

Definition at line 1342 of file nsFontMetricsWin.cpp.

{
  // this is "MS P Gothic" in Japanese
  static const char* mspgothic=  
    "\x82\x6c\x82\x72 \x82\x6f\x83\x53\x83\x56\x83\x62\x83\x4e";
  // below is a list of common used name for startup
  if ( (!strcmp(aFontName, "Tahoma" )) ||
       (!strcmp(aFontName, "Arial" )) ||
       (!strcmp(aFontName, "Times New Roman" )) ||
       (!strcmp(aFontName, "Courier New" )) ||
       (!strcmp(aFontName, mspgothic )) )
    return NS_ERROR_NOT_AVAILABLE; // error means do not get a special encoding

  // XXX We need this kludge to deal with aFontName in CP949 when the locale 
  // is Korean until we figure out a way to get facename in US-ASCII
  // regardless of the current locale. We have no control over what 
  // EnumFontFamiliesEx() does.
  nsCAutoString name;
  if ( ::GetACP() != 949) 
    name.Assign(NS_LITERAL_CSTRING("encoding.") + nsDependentCString(aFontName) + NS_LITERAL_CSTRING(".ttf"));
  else {
    PRUnichar fname[LF_FACESIZE];
    fname[0] = 0;
    MultiByteToWideChar(CP_ACP, 0, aFontName,
    strlen(aFontName) + 1, fname, sizeof(fname)/sizeof(fname[0]));
    name.Assign(NS_LITERAL_CSTRING("encoding.") + NS_ConvertUCS2toUTF8(fname) + NS_LITERAL_CSTRING(".ttf"));
  }

  name.StripWhitespace();
  ToLowerCase(name);

  // if we have not init the property yet, init it right now.
  if (!gFontEncodingProperties)
    NS_LoadPersistentPropertiesFromURISpec(&gFontEncodingProperties,
      NS_LITERAL_CSTRING("resource://gre/res/fonts/fontEncoding.properties"));

  if (gFontEncodingProperties) {
    nsAutoString prop;
    nsresult rv = gFontEncodingProperties->GetStringProperty(name, prop);
    if (NS_SUCCEEDED(rv)) {
      aValue.AssignWithConversion(prop);

      // The encoding name of a wide NonUnicode font in fontEncoding.properties
      // has '.wide' suffix which has to be removed to get the actual encoding.
      *aIsWide = StringEndsWith(aValue, NS_LITERAL_CSTRING(".wide"));
      if (*aIsWide) {
        aValue.Truncate(aValue.Length()-5);
      }
    }
    return rv;
  }
  return NS_ERROR_NOT_AVAILABLE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1410 of file nsFontMetricsWin.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static PRUint16 GetGlyphIndex ( PRUint16  segCount,
PRUint16 endCode,
PRUint16 startCode,
PRUint16 idRangeOffset,
PRUint16 idDelta,
PRUint8 end,
PRUint16  aChar 
) [static]

Definition at line 685 of file nsFontMetricsWin.cpp.

{
  PRUint16 glyphIndex = 0;
  PRUint16 i;
  for (i = 0; i < segCount; ++i) {
    if (endCode[i] >= aChar) {
      break;
    }
  }
  PRUint16 startC = startCode[i];
  if (startC <= aChar) {
    if (idRangeOffset[i]) {
      PRUint16* p =
        (idRangeOffset[i]/2 + (aChar - startC) + &idRangeOffset[i]);
      if ((PRUint8*) p < end) {
        if (*p) {
          glyphIndex = (idDelta[i] + *p) % 65536;
        }
      }
    }
    else {
      glyphIndex = (idDelta[i] + aChar) % 65536;
    }
  }

  return glyphIndex;
}

Here is the caller graph for this function:

static nsresult GetGlyphIndices ( HDC  aDC,
nsCharacterMap **  aCMAP,
const PRUnichar aString,
PRUint32  aLength,
nsAutoChar16Buffer aResult 
) [static]

Definition at line 1949 of file nsFontMetricsWin.cpp.

{  
  NS_ASSERTION(aString, "null arg");
  if (!aString)
    return NS_ERROR_NULL_POINTER;

  nsAutoFontDataBuffer buffer;
  PRUint8* buf = nsnull;
  DWORD len = -1;
  
  // --------------
  // Dig for the Unicode subtable if this is the first call.

  if (!aCMAP || // the caller doesn't cache the CMAP, or
      !*aCMAP || (*aCMAP)->mLength < 0  // the CMAP is not yet initialized
     ) 
  {
    // Initialize as a 0-length CMAP, so that if there is an
    // error with this CMAP, it will never be tried again.
    if (aCMAP && *aCMAP) (*aCMAP)->mLength = 0; 

    len = GetFontData(aDC, CMAP, 0, nsnull, 0);
    if ((len == GDI_ERROR) || (!len)) {
      return NS_ERROR_UNEXPECTED;
    }
    if (!buffer.EnsureElemCapacity(len)) {
      return NS_ERROR_OUT_OF_MEMORY;
    }
    buf = buffer.get();
    DWORD newLen = GetFontData(aDC, CMAP, 0, buf, len);
    if (newLen != len) {
      return NS_ERROR_UNEXPECTED;
    }
    PRUint8* p = buf + sizeof(PRUint16); // skip version, move to numberOfSubtables
    PRUint16 n = GET_SHORT(p);
    p += sizeof(PRUint16); // skip numberSubtables, move to the encoding subtables
    PRUint16 i;
    PRUint32 offset;
    for (i = 0; i < n; ++i) {
      PRUint16 platformID = GET_SHORT(p); // get platformID
      p += sizeof(PRUint16); // move to platformSpecificID
      PRUint16 encodingID = GET_SHORT(p); // get platformSpecificID
      p += sizeof(PRUint16); // move to offset
      offset = GET_LONG(p);  // get offset
      p += sizeof(PRUint32); // move to next entry
      if (platformID == eTTPlatformIDMicrosoft && 
          encodingID == eTTMicrosoftEncodingUnicode) // Unicode
        break;
    }
    if (i == n) {
      NS_WARNING("nsFontMetricsWin::GetGlyphIndices() called for a non-unicode font!");
      return NS_ERROR_UNEXPECTED;
    }
    p = buf + offset;
    PRUint16 format = GET_SHORT(p);
    if (format != eTTFormat4SegmentMappingToDeltaValues) {
      return NS_ERROR_UNEXPECTED;
    }
    PRUint8* end = buf + len;

    // XXX byte swapping only required for little endian (ifdef?)
    while (p < end) {
      PRUint8 tmp = p[0];
      p[0] = p[1];
      p[1] = tmp;
      p += 2; // swap every two bytes
    }
#ifdef MOZ_MATHML
    // cache these for later re-use
    if (aCMAP) {
      nsAutoString name;
      nsFontInfo* info;
      if (GetNAME(aDC, &name) == eGetName_OK) {
        info = (nsFontInfo*)PL_HashTableLookup(nsFontMetricsWin::gFontMaps, &name);
        if (info) {
          info->mCMAP.mData = (PRUint8*)nsMemory::Alloc(len);
          if (info->mCMAP.mData) {
            memcpy(info->mCMAP.mData, buf, len);
            info->mCMAP.mLength = len;
            *aCMAP = &(info->mCMAP);
          }          
        }
      }
    }
#endif
  }

  // --------------
  // get glyph indices

  if (aCMAP && *aCMAP) { // recover cached CMAP if we have skipped the previous step
    buf = (*aCMAP)->mData;
    len = (*aCMAP)->mLength;
  }
  if (buf && len > 0) {
    // get the offset   
    PRUint8* p = buf + sizeof(PRUint16); // skip version, move to numberOfSubtables
    PRUint16 n = GET_SHORT(p);
    p += sizeof(PRUint16); // skip numberSubtables, move to the encoding subtables
    PRUint16 i;
    PRUint32 offset;
    for (i = 0; i < n; ++i) {
      PRUint16 platformID = GET_SHORT(p); // get platformID
      p += sizeof(PRUint16); // move to platformSpecificID
      PRUint16 encodingID = GET_SHORT(p); // get platformSpecificID
      p += sizeof(PRUint16); // move to offset
      offset = GET_LONG(p);  // get offset
      p += sizeof(PRUint32); // move to next entry
      if (platformID == eTTPlatformIDMicrosoft && 
          encodingID == eTTMicrosoftEncodingUnicode) // Unicode
        break;
    }
    PRUint8* end = buf + len;

    PRUint16* s = (PRUint16*) (buf + offset);
    PRUint16 segCount = s[3] / 2;
    PRUint16* endCode = &s[7];
    PRUint16* startCode = endCode + segCount + 1;
    PRUint16* idDelta = startCode + segCount;
    PRUint16* idRangeOffset = idDelta + segCount;

    if (!aResult.EnsureElemCapacity(aLength)) {
      return NS_ERROR_OUT_OF_MEMORY;
    }
    PRUnichar* result = aResult.get();
    for (i = 0; i < aLength; ++i) {
      result[i] = GetGlyphIndex(segCount, endCode, startCode,
                                idRangeOffset, idDelta, end, 
                                aString[i]);
    }

    return NS_OK;
  }
  return NS_ERROR_UNEXPECTED;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int GetIndexToLocFormat ( HDC  aDC) [static]

Definition at line 813 of file nsFontMetricsWin.cpp.

{
  PRUint16 indexToLocFormat;
  if (GetFontData(aDC, HEAD, 50, &indexToLocFormat, 2) != 2) {
    return -1;
  }
  if (!indexToLocFormat) {
    return 0;
  }
  return 1;
}

Here is the caller graph for this function:

static eGetNameError GetNAME ( HDC  aDC,
nsString aName,
PRBool aIsSymbolEncoding = nsnull 
) [static]

Definition at line 722 of file nsFontMetricsWin.cpp.

{
#ifdef WINCE
  return eGetName_GDIError;
#else

  DWORD len = GetFontData(aDC, NAME, 0, nsnull, 0);
  if (len == GDI_ERROR) {
    TEXTMETRIC metrics;
    if (::GetTextMetrics(aDC, &metrics) == 0) // can fail here -- see bug 113779#c81
      return eGetName_OtherError;
    return (metrics.tmPitchAndFamily & TMPF_TRUETYPE) ?
      eGetName_OtherError : eGetName_GDIError;
  }
  if (!len) {
    return eGetName_OtherError;
  }
  nsAutoFontDataBuffer buffer;
  if (!buffer.EnsureElemCapacity(len)) {
    return eGetName_OtherError;
  }
  PRUint8* buf = buffer.get();

  DWORD newLen = GetFontData(aDC, NAME, 0, buf, len);
  if (newLen != len) {
    return eGetName_OtherError;
  }
  PRUint8* p = buf + 2;
  PRUint16 n = GET_SHORT(p);
  p += 2;
  PRUint16 offset = GET_SHORT(p);
  p += 2;
  PRUint16 i;
  PRUint16 idLength;
  PRUint16 idOffset;
  for (i = 0; i < n; ++i) {
    PRUint16 platform = GET_SHORT(p);
    p += 2;
    PRUint16 encoding = GET_SHORT(p);
    p += 4;
    PRUint16 name = GET_SHORT(p);
    p += 2;
    idLength = GET_SHORT(p);
    p += 2;
    idOffset = GET_SHORT(p);
    p += 2;
    // encoding: 1 == Unicode; 0 == symbol
    if ((platform == 3) && ((encoding == 1) || (!encoding)) && (name == 3)) {
      if (aIsSymbolEncoding) {
        *aIsSymbolEncoding = encoding == 0;
      }
      break;
    }
  }
  if (i == n) {
    return eGetName_OtherError;
  }
  p = buf + offset + idOffset;
  idLength /= 2;
  // Prefix with a little flag to distinguish quirky fonts. Assume
  // '0' (i.e., non quirks) to begin with. On return, the caller can
  // decide to treat this font in quirks fashion and override with
  // aName[0] = '1'. More info in bug 195038.
  PRUnichar c = '0';
  aName->Append(c);
  for (i = 0; i < idLength; ++i) {
    c = GET_SHORT(p);
    p += 2;
    aName->Append(c);
  }

  return eGetName_OK;
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult GetSpaces ( HDC  aDC,
PRBool aIsCFFOutline,
PRUint32 aMaxGlyph,
nsAutoFontDataBuffer aIsSpace 
) [static]

Definition at line 826 of file nsFontMetricsWin.cpp.

{
  // OpenType fonts with CFF outline do not have the 'loca' table
  DWORD len = GetFontData(aDC, CFF, 0, nsnull, 0);
  if ((len != GDI_ERROR) && len) {
    *aIsCFFOutline = PR_TRUE;
    return NS_OK;
  }
  *aIsCFFOutline = PR_FALSE;
  int isLong = GetIndexToLocFormat(aDC);
  if (isLong < 0) {
    return NS_ERROR_FAILURE;
  }
  len = GetFontData(aDC, LOCA, 0, nsnull, 0);
  if ((len == GDI_ERROR) || (!len)) {
    return NS_ERROR_FAILURE;
  }
  if (!aIsSpace.EnsureElemCapacity(len)) {
    return NS_ERROR_OUT_OF_MEMORY;
  }
  PRUint8* buf = aIsSpace.get();
  DWORD newLen = GetFontData(aDC, LOCA, 0, buf, len);
  if (newLen != len) {
    return NS_ERROR_FAILURE;
  }
  if (isLong) {
    DWORD longLen = ((len / 4) - 1);
    *aMaxGlyph = longLen;
    PRUint32* longBuf = (PRUint32*) buf;
    for (PRUint32 i = 0; i < longLen; ++i) {
      if (longBuf[i] == longBuf[i+1]) {
        buf[i] = 1;
      }
      else {
        buf[i] = 0;
      }
    }
  }
  else {
    DWORD shortLen = ((len / 2) - 1);
    *aMaxGlyph = shortLen;
    PRUint16* shortBuf = (PRUint16*) buf;
    for (PRUint16 i = 0; i < shortLen; ++i) {
      if (shortBuf[i] == shortBuf[i+1]) {
        buf[i] = 1;
      }
      else {
        buf[i] = 0;
      }
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PLHashNumber HashKey ( const void aString) [static]

Definition at line 798 of file nsFontMetricsWin.cpp.

{
  const nsString* str = (const nsString*)aString;
  return (PLHashNumber)
    nsCRT::HashCode(str->get());
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PLHashNumber HashKeyFontWeight ( const void aFontWeightEntry) [static]

Definition at line 3009 of file nsFontMetricsWin.cpp.

{
  const nsString* string = &((const nsFontWeightEntry*) aFontWeightEntry)->mFontName;
  return (PLHashNumber)nsCRT::HashCode(string->get());
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int HaveConverterFor ( PRUint8  aCharset) [static]

Definition at line 4798 of file nsFontMetricsWin.cpp.

{
  WCHAR wc = 'a';
  char mb[8];
  if (WideCharToMultiByte(gCharsetInfo[gCharsetToIndex[aCharset]].mCodePage, 0,
                          &wc, 1, mb, sizeof(mb), nsnull, nsnull)) {
    return 1;
  }
  // remove from table, since we can't support it anyway
  for (int i = sizeof(gBitToCharset)-1; i >= 0; --i) {
    if (gBitToCharset[i] == aCharset) {
      gBitToCharset[i] = DEFAULT_CHARSET;
    }
  }

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult InitGlobals ( void  ) [static]

Definition at line 357 of file nsFontMetricsWin.cpp.

{
  CallGetService(kCharsetConverterManagerCID, &gCharsetManager);
  if (!gCharsetManager) {
    FreeGlobals();
    return NS_ERROR_FAILURE;
  }
  CallGetService(kPrefCID, &gPref);
  if (!gPref) {
    FreeGlobals();
    return NS_ERROR_FAILURE;
  }

  // if we do not include/compensate external leading in calculating normal 
  // line height, we don't set gDoingLineheightFixup either to keep old behavior.
  // These code should be eliminated in future when we choose to stay with 
  // one normal lineheight calculation method.
  PRInt32 intPref;
  if (NS_SUCCEEDED(gPref->GetIntPref(
      "browser.display.normal_lineheight_calc_control", &intPref)))
    gDoingLineheightFixup = (intPref != 0);

  nsCOMPtr<nsILanguageAtomService> langService;
  langService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
  if (langService) {
    NS_IF_ADDREF(gUsersLocale = langService->GetLocaleLanguageGroup());
  }
  if (!gUsersLocale) {
    gUsersLocale = NS_NewAtom("x-western");
  }
  if (!gUsersLocale) {
    FreeGlobals();
    return NS_ERROR_OUT_OF_MEMORY;
  }

  // used in LookupWinFontName()
  if (!gCodepageStr) {
    gCodepageStr = new nsString(NS_LITERAL_STRING(".cp"));
  }
  if (!gCodepageStr) {
    FreeGlobals();
    return NS_ERROR_OUT_OF_MEMORY;
  }

  UINT cp = ::GetACP();
  gCodepageStr->AppendInt(cp); 
  
  if (!gSystemLocale) {
    for (int i = 1; i < eCharset_COUNT; ++i) {
      if (gCharsetInfo[i].mCodePage == cp) {
        gSystemLocale = NS_NewAtom(gCharsetInfo[i].mLangGroup);
        break;
      }
    }
  }
  if (!gSystemLocale) {
    gSystemLocale = gUsersLocale;
    NS_ADDREF(gSystemLocale);
  }

  gUserDefined = NS_NewAtom(USER_DEFINED);
  if (!gUserDefined) {
    FreeGlobals();
    return NS_ERROR_OUT_OF_MEMORY;
  }
  gJA = NS_NewAtom("ja");
  if (!gJA) {
    FreeGlobals();
    return NS_ERROR_OUT_OF_MEMORY;
  }
  gKO = NS_NewAtom("ko");
  if (!gKO) {
    FreeGlobals();
    return NS_ERROR_OUT_OF_MEMORY;
  }
  gZHCN = NS_NewAtom("zh-CN");
  if (!gZHCN) {
    FreeGlobals();
    return NS_ERROR_OUT_OF_MEMORY;
  }
  gZHTW = NS_NewAtom("zh-TW");
  if (!gZHTW) {
    FreeGlobals();
    return NS_ERROR_OUT_OF_MEMORY;
  }
  gZHHK = NS_NewAtom("zh-HK");
  if (!gZHHK) {
    FreeGlobals();
    return NS_ERROR_OUT_OF_MEMORY;
  }

  if (!UseAFunctions()) {
    gFontForIgnorable = new nsFontWinSubstitute(gIgnorableCCMapExt); 
    if (!gFontForIgnorable) {
      FreeGlobals();
      return NS_ERROR_OUT_OF_MEMORY;
    }
  } else {
    nsFontWinSubstituteA* font = new nsFontWinSubstituteA(gIgnorableCCMapExt);
    gFontForIgnorable = font;
    if (!gFontForIgnorable) {
      FreeGlobals();
      return NS_ERROR_OUT_OF_MEMORY;
    }
    font->mSubsets = (nsFontSubset**)nsMemory::Alloc(sizeof(nsFontSubset*));
    if (!font->mSubsets) {
      FreeGlobals();
      return NS_ERROR_OUT_OF_MEMORY;
    }
    font->mSubsets[0] = nsnull;
    nsFontSubsetSubstitute* subset = new nsFontSubsetSubstitute(TRUE);
    if (!subset) {
      FreeGlobals();
      return NS_ERROR_OUT_OF_MEMORY;
    }
    font->mSubsetsCount = 1;
    font->mSubsets[0] = subset;
  }

  //register an observer to take care of cleanup
  gFontCleanupObserver = new nsFontCleanupObserver();
  if (!gFontCleanupObserver) {
    FreeGlobals();
    return NS_ERROR_OUT_OF_MEMORY;
  }

  // register for shutdown
  nsresult rv;
  nsCOMPtr<nsIObserverService> observerService(do_GetService("@mozilla.org/observer-service;1", &rv));
  if (NS_SUCCEEDED(rv)) {
    rv = observerService->AddObserver(gFontCleanupObserver, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
  }
  gInitialized = 1;

  return NS_OK;
}

Here is the call graph for this function:

static int InitializeFontEnumerator ( void  ) [static]

Definition at line 5625 of file nsFontMetricsWin.cpp.

{
  gInitializedFontEnumerator = 1;
  if (!nsFontMetricsWin::gGlobalFonts) {
    HDC dc = ::GetDC(nsnull);
    if (!nsFontMetricsWin::InitializeGlobalFonts(dc)) {
      ::ReleaseDC(nsnull, dc);
      return 0;
    }
    ::ReleaseDC(nsnull, dc);
  }

  return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 70 of file nsFontMetricsWin.cpp.

{
#ifndef WINCE
  if (NOT_SETUP == gIsWIN95OR98) {
    OSVERSIONINFO os;
    os.dwOSVersionInfoSize = sizeof(os);
    ::GetVersionEx(&os);
    // XXX This may need tweaking for win98
    if (VER_PLATFORM_WIN32_WINDOWS == os.dwPlatformId) {
      gIsWIN95OR98 = PR_TRUE;
    }
    else {
      gIsWIN95OR98 = PR_FALSE;
    }
  }
  return gIsWIN95OR98;
#else
  return PR_TRUE;
#endif
}

Here is the caller graph for this function:

PRBool LookupWinFontName ( const nsAFlatString aName,
nsAString &  aWinName 
) [static]

Definition at line 5913 of file nsFontMetricsWin.cpp.

{
  // to speed up start-up, bypass the property look-up for these fonts
  if (aName.LowerCaseEqualsLiteral("tahoma") ||
      aName.LowerCaseEqualsLiteral("arial") ||
      aName.LowerCaseEqualsLiteral("times new roman") ||
      aName.LowerCaseEqualsLiteral("courier new"))
    return PR_FALSE;

  if (!gFontNameMapProperties)
    NS_LoadPersistentPropertiesFromURISpec(&gFontNameMapProperties,
      NS_LITERAL_CSTRING("resource://gre/res/fonts/fontNameMap.properties"));

  if (!gFontNameMapProperties) {
    NS_WARNING("fontNameMap.properties is not available"); 
    return PR_FALSE;
  }

  nsAutoString name(aName); 
  ToLowerCase(name); 

  NS_ConvertUTF16toUTF8 propKey(name);
  propKey.StripWhitespace(); 

  if (IsASCII(propKey)) {
    // see if there's the native name in the current codepage
    // <ascii name>.cp<codepage>=<native name>
    LossyAppendUTF16toASCII(*gCodepageStr, propKey); 
    return NS_SUCCEEDED(gFontNameMapProperties->
                        GetStringProperty(propKey, aWinName));
  }

  // <native name>=<ascii name>.cp<codepage>
  if (NS_SUCCEEDED(gFontNameMapProperties->
                   GetStringProperty(propKey, aWinName))) {
    if (StringEndsWith(aWinName, *gCodepageStr)) {
      // if font codepage == current codepage, use the native name
      return PR_FALSE;
    }
    // if font codepage != current codepage, map to the ASCII name by
    // truncating '.cpXXX' (6 characters) at the end. 
    // aWinName ends with '.cpXXX' where 'XXX' is 932,936,949 or 950.
    aWinName.Truncate(aWinName.Length() - 6);
    return PR_TRUE;
  }
  return PR_FALSE;  // native name not listed in the properties file.
}

Here is the call graph for this function:

Here is the caller graph for this function:

static NS_DEFINE_CID ( kCharsetConverterManagerCID  ,
NS_ICHARSETCONVERTERMANAGER_CID   
) [static]
static NS_DEFINE_CID ( kPrefCID  ,
NS_PREF_CID   
) [static]
static PRBool NS_ExtTextOutA ( HDC  aDC,
nsFontWin aFont,
PRInt32  aX,
PRInt32  aY,
UINT  uOptions,
LPCRECT  lprc,
LPCSTR  aString,
UINT  aLength,
INT lpDx 
) [static]

Definition at line 4276 of file nsFontMetricsWin.cpp.

{
  RECT clipRect;
  if (!lpDx && !lprc && aFont->FillClipRect(aX, aY, aLength, uOptions, clipRect)) {
    lprc = &clipRect;
    uOptions |= ETO_CLIPPED;
  }
  return ::ExtTextOutA(aDC, aX, aY, uOptions, lprc, aString, aLength, lpDx);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool NS_ExtTextOutW ( HDC  aDC,
nsFontWin aFont,
PRInt32  aX,
PRInt32  aY,
UINT  uOptions,
LPCRECT  lprc,
LPCWSTR  aString,
UINT  aLength,
INT lpDx 
) [static]

Definition at line 4288 of file nsFontMetricsWin.cpp.

{
  RECT clipRect;
  if (!lpDx && !lprc && aFont->FillClipRect(aX, aY, aLength, uOptions, clipRect)) {
    lprc = &clipRect;
    uOptions |= ETO_CLIPPED;
  }
  return ::ExtTextOutW(aDC, aX, aY, uOptions, lprc, aString, aLength, lpDx);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int CALLBACK nsFontWeightCallback ( const LOGFONT *  logFont,
const TEXTMETRIC *  metrics,
DWORD  fontType,
LPARAM  closure 
) [static]

Definition at line 3076 of file nsFontMetricsWin.cpp.

{
// printf("Name %s Log font sizes %d\n",logFont->lfFaceName,logFont->lfWeight);
  nsFontWeightInfo* weightInfo = (nsFontWeightInfo*)closure;
  if (metrics) {
      // Set a bit to indicate the font weight is available
    if (weightInfo->mFontCount == 0)
      weightInfo->mLogFont = *logFont;
    nsFontMetricsWin::SetFontWeight(metrics->tmWeight / 100,
      &weightInfo->mWeights);
    ++weightInfo->mFontCount;
  }
  return TRUE; // Keep looking for more weights.
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void ReadCMAPTableFormat12 ( PRUint8 aBuf,
PRInt32  len,
PRUint32 **  aExtMap 
) [static]

Definition at line 1590 of file nsFontMetricsWin.cpp.

{
  PRUint8* p = aBuf;
  PRUint32 i;

  p += sizeof(PRUint16); // skip format
  p += sizeof(PRUint16); // skip reserve field
  p += sizeof(PRUint32); // skip tableLen
  p += sizeof(PRUint32); // skip language
  PRUint32 nGroup = GET_LONG(p);
  p += sizeof(PRUint32); 

  PRUint32 plane;
  PRUint32 startCode;
  PRUint32 endCode;
  PRUint32 c;
  for (i = 0; i < nGroup; i++) {
    startCode = GET_LONG(p);
    p += sizeof(PRUint32); 
    endCode = GET_LONG(p);
    p += sizeof(PRUint32); 
    for ( c = startCode; c <= endCode; ++c) {
      plane = c >> 16;
      if (!aExtMap[plane]) {
        aExtMap[plane] = new PRUint32[UCS2_MAP_LEN];
        if (!aExtMap[plane])
          return; // i.e., we will only retain the BMP and what we were able to allocate so far
        memset(aExtMap[plane], 0, sizeof(PRUint32) * UCS2_MAP_LEN);
      }
      ADD_GLYPH(aExtMap[plane], c & 0xffff);
    }
    p += sizeof(PRUint32); // skip startGlyphID  field
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void ReadCMAPTableFormat4 ( PRUint8 aBuf,
PRInt32  aLength,
PRUint32 aMap,
PRBool  aIsCFFOutline,
PRUint8 aIsSpace,
PRUint32  aMaxGlyph 
) [static]

Definition at line 1627 of file nsFontMetricsWin.cpp.

{
  PRUint8* p = aBuf;
  PRUint8* end = aBuf + aLength;
  PRUint32 i;

  // XXX byte swapping only required for little endian (ifdef?)
  while (p < end) {
    PRUint8 tmp = p[0];
    p[0] = p[1];
    p[1] = tmp;
    p += 2; // every two bytes
  }

  PRUint16* s = (PRUint16*) aBuf;
  PRUint16 segCount = s[3] / 2;
  PRUint16* endCode = &s[7];
  PRUint16* startCode = endCode + segCount + 1;
  PRUint16* idDelta = startCode + segCount;
  PRUint16* idRangeOffset = idDelta + segCount;

  for (i = 0; i < segCount; ++i) {
    if (idRangeOffset[i]) {
      PRUint16 startC = startCode[i];
      PRUint16 endC = endCode[i];
      for (PRUint32 c = startC; c <= endC; ++c) {
        PRUint16* g =
          (idRangeOffset[i]/2 + (c - startC) + &idRangeOffset[i]);
        if ((PRUint8*) g < end) {
          if (*g) {
            PRUint16 glyph = idDelta[i] + *g;
            if (aIsCFFOutline) {
              ADD_GLYPH(aMap, c);
            }
            else if (glyph < aMaxGlyph) {
              if (aIsSpace[glyph]) {
                if (SHOULD_BE_SPACE_CHAR(c)) {
                  ADD_GLYPH(aMap, c);
                } 
              }
              else {
                ADD_GLYPH(aMap, c);
              }
            }
          }
          else {
            // index 0 also applies to space character
            if (SHOULD_BE_SPACE_CHAR(c))
              ADD_GLYPH(aMap, c);
          }
        }
        else {
          // XXX should we trust this font at all if it does this?
        }
      }
      //printf("0x%04X-0x%04X ", startC, endC);
    }
    else {
      PRUint16 endC = endCode[i];
      for (PRUint32 c = startCode[i]; c <= endC; ++c) {
        PRUint16 glyph = idDelta[i] + c;
        if (aIsCFFOutline) {
          ADD_GLYPH(aMap, c);
        }
        else if (glyph < aMaxGlyph) {
          if (aIsSpace[glyph]) {
            if (SHOULD_BE_SPACE_CHAR(c)) {
              ADD_GLYPH(aMap, c);
            }
          }
          else {
            ADD_GLYPH(aMap, c);
          }
        }
      }
      //printf("0x%04X-0x%04X ", startCode[i], endC);
    }
  }
  //printf("\n");
}

Here is the caller graph for this function:

static void SearchSimulatedFontWeight ( HDC  aDC,
nsFontWeightInfo aWeightInfo 
) [static]

Definition at line 3093 of file nsFontMetricsWin.cpp.

{
  int weight, weightCount;

  // if the font does not exist return immediately 
  if (aWeightInfo->mFontCount == 0) {
    return;
  }

  // If two or more nonsimulated variants exist, just use them.
  weightCount = 0;
  for (weight = 100; weight <= 900; weight += 100) {
    if (nsFontMetricsWin::IsFontWeightAvailable(weight, aWeightInfo->mWeights))
      ++weightCount;
  }

  // If the font does not exist (weightCount == 0) or
  // there are 2 or more weights already, don't look for
  // simulated font weights.
  if ((weightCount == 0) || (weightCount > 1)) {
    return;
  }

  // Searching simulated variants.
  // The tmWeight member holds simulated font weight.
  LOGFONT logFont = aWeightInfo->mLogFont;
  for (weight = 100; weight <= 900; weight += 100) {
    logFont.lfWeight = weight;
    HFONT hfont = ::CreateFontIndirect(&logFont);
    HFONT oldfont = (HFONT)::SelectObject(aDC, (HGDIOBJ)hfont);

    TEXTMETRIC metrics;
    GetTextMetrics(aDC, &metrics);
    if (metrics.tmWeight == weight) {
//      printf("font weight for %s found: %d%s\n", logFont.lfFaceName, weight,
//        nsFontMetricsWin::IsFontWeightAvailable(weight, aWeightInfo->mWeights) ?
//        "" : " (simulated)");
      nsFontMetricsWin::SetFontWeight(weight / 100, &aWeightInfo->mWeights);
    }

    ::SelectObject(aDC, (HGDIOBJ)oldfont);
    ::DeleteObject((HGDIOBJ)hfont);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int SignatureMatchesLangGroup ( FONTSIGNATURE *  aSignature,
const char *  aLangGroup 
) [static]

Definition at line 5652 of file nsFontMetricsWin.cpp.

{
  int dword;

  // hack : FONTSIGNATURE in Win32 doesn't have a separate signature field
  // for zh-HK.  We have to treat it as zh-TW.
  const char *langGroup = strcmp(aLangGroup, "zh-HK") ? aLangGroup : "zh-TW";

  // For scripts that have been supported by 'ANSI' codepage in Win9x/ME,
  // we can rely on fsCsb. 
  DWORD* array = aSignature->fsCsb;
  int i = 0;
  for (dword = 0; dword < 2; ++dword) {
    for (int bit = 0; bit < sizeof(DWORD) * 8; ++bit) {
      if ((array[dword] >> bit) & 1) {
        if (!strcmp(gCharsetInfo[gCharsetToIndex[gBitToCharset[i]]].mLangGroup,
                    langGroup)) {
          return 1;
        }
      }
      ++i;
    }
  }

  // For aLangGroup corresponding to one of 'ANSI' codepages, the negative
  // result from fsCsb should be considered final. Otherwise, we risk getting
  // a false positive from fsUsb, which could lead unncessarily to 
  // a mix of glyphs from different fonts.

  // x-western .. zh-TW. (exclude JOHAB)
  for (i = eCharset_ANSI; i <= eCharset_CHINESEBIG5; ++i) 
  {
    if (!strcmp(gCharsetInfo[i].mLangGroup, langGroup))
      return 0;
  }

  // For other scripts, we need fsUsb (Unicode coverage bitfield : 128bit).
  // Here we're just examining the first 3 dwords because at the moment
  // only the first 84 bits are assigned according to the MSDN.

  array = aSignature->fsUsb;
  for (i = 0, dword = 0; dword < 3; ++dword) {
    for (int bit = 0; bit < sizeof(DWORD) * 8; ++bit) {
      if ((array[dword] >> bit) & 1) {
        PRUint8 range = gBitToUnicodeRange[i];
        if (kRangeSpecificItemNum > range &&
            !strcmp(gUnicodeRangeToLangGroupTable[range], langGroup)) {
          return 1;
        }
      }
      ++i;
    }
  }

  return 0;
}

Here is the caller graph for this function:

static nsresult SubstituteChars ( PRBool  aDisplayUnicode,
const PRUnichar aString,
PRUint32  aLength,
nsAutoChar16Buffer aResult,
PRUint32 aCount 
) [static]

Definition at line 4568 of file nsFontMetricsWin.cpp.

{

#ifdef WINCE
// Unicode backend on WINCE... Substitute nothing.

  if (!aResult.EnsureElemCapacity(aLength))
    return NS_ERROR_OUT_OF_MEMORY;

  *aCount = aLength;
  memcpy(aResult.get(), aString, aLength * sizeof(PRUnichar));
  return NS_OK;

#else


  nsresult res;
  if (!gFontSubstituteConverter) {
    CallCreateInstance(NS_SAVEASCHARSET_CONTRACTID, &gFontSubstituteConverter);
    if (gFontSubstituteConverter) {
      // if aDisplayUnicode is set: transliterate, and then fallback
      //   to literal Unicode points &#xNNNN; for unknown characters
      // otherwise: transliterate, and then fallback to entities for
      //   recorded characters and question marks for unknown characters
      res = gFontSubstituteConverter->Init("ISO-8859-1",
              aDisplayUnicode
              ? nsISaveAsCharset::attr_FallbackHexNCR
              : nsISaveAsCharset::attr_EntityAfterCharsetConv + nsISaveAsCharset::attr_FallbackQuestionMark + nsISaveAsCharset::attr_IgnoreIgnorables,
              nsIEntityConverter::transliterate);
      if (NS_FAILED(res)) {
        NS_RELEASE(gFontSubstituteConverter);
      }
    }
  }

  // do the transliteration if we have a converter
  PRUnichar* result; 
  if (gFontSubstituteConverter) {
    nsXPIDLCString conv;
    nsAutoString tmp(aString, aLength); // we need to pass a null-terminated string
    res = gFontSubstituteConverter->Convert(tmp.get(), getter_Copies(conv));
    if (NS_SUCCEEDED(res)) {
      *aCount = conv.Length();
      if (*aCount > 0) {
        if (!aResult.EnsureElemCapacity(*aCount)) {
          return NS_ERROR_OUT_OF_MEMORY;
        }
        result = aResult.get();
        PRUnichar* u = result;
        const char* c = conv.get();
        for (; *c; ++c, ++u) {
          *u = *c;
        }
      }
      return NS_OK;
    }
  }

  // we reach here if we couldn't transliterate, so fallback to question marks 
  if (!aResult.EnsureElemCapacity(aLength)) return NS_ERROR_OUT_OF_MEMORY;
  result = aResult.get();
  for (PRUint32 i = 0; i < aLength; i++) {
    result[i] = NS_REPLACEMENT_CHAR;
  }
  *aCount = aLength;
  return NS_OK;
#endif // WINCE
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int SystemSupportsChar ( PRUnichar  aChar) [static]

Definition at line 5260 of file nsFontMetricsWin.cpp.

{
  for (int i = 0; i < sizeof(gBitToCharset); ++i) {
    PRUint8 charset = gBitToCharset[i];
    if (charset == DEFAULT_CHARSET) 
      continue;
    if (!HaveConverterFor(charset)) 
      continue;
    int j = gCharsetToIndex[charset];
    if (!gCharsetInfo[j].mCCMap) {
      gCharsetInfo[j].mCCMap = gCharsetInfo[j].GenerateMap(&gCharsetInfo[j]);
      if (!gCharsetInfo[j].mCCMap) 
          return 0;
    }
    if (CCMAP_HAS_CHAR(gCharsetInfo[j].mCCMap, aChar)) 
      return 1;
  }

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 83 of file nsGfxFactoryWin.cpp.

{
#ifndef WINCE
  static PRBool useAFunctions = PR_FALSE;
  static PRBool init = PR_FALSE;
  if (!init) {
    init = 1;
    OSVERSIONINFO os;
    os.dwOSVersionInfoSize = sizeof(os);
    ::GetVersionEx(&os);
    if ((os.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) &&
        (os.dwMajorVersion == 4) &&
        (os.dwMinorVersion == 0) &&    // Windows 95 (not 98)
        (::GetACP() == 932)) {         // Shift-JIS (Japanese)
      useAFunctions = 1;
    }
  }

  return useAFunctions;
#else
  return PR_FALSE;
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

PRUint8 gBitToCharset[64] [static]

Definition at line 884 of file nsFontMetricsWin.cpp.

Definition at line 1236 of file nsFontMetricsWin.cpp.

Initial value:
{
  { "DEFAULT",     0,    "",               GenerateDefault,    nsnull},
  { "ANSI",        1252, "x-western",      GenerateSingleByte, nsnull},
  { "EASTEUROPE",  1250, "x-central-euro", GenerateSingleByte, nsnull},
  { "RUSSIAN",     1251, "x-cyrillic",     GenerateSingleByte, nsnull},
  { "GREEK",       1253, "el",             GenerateSingleByte, nsnull},
  { "TURKISH",     1254, "tr",             GenerateSingleByte, nsnull},
  { "HEBREW",      1255, "he",             GenerateSingleByte, nsnull},
  { "ARABIC",      1256, "ar",             GenerateSingleByte, nsnull},
  { "BALTIC",      1257, "x-baltic",       GenerateSingleByte, nsnull},
  { "THAI",        874,  "th",             GenerateSingleByte, nsnull},
  { "SHIFTJIS",    932,  "ja",             GenerateMultiByte,  nsnull},
  { "GB2312",      936,  "zh-CN",          GenerateMultiByte,  nsnull},
  { "HANGEUL",     949,  "ko",             GenerateMultiByte,  nsnull},
  { "CHINESEBIG5", 950,  "zh-TW",          GenerateMultiByte,  nsnull},
  { "JOHAB",       1361, "ko-XXX",         GenerateMultiByte,  nsnull}
}

Definition at line 182 of file nsFontMetricsWin.cpp.

Definition at line 152 of file nsFontMetricsWin.cpp.

Initial value:
{
       -1,  
        0,  
        1,  
        2,  
        3,  
        4,  
        5,  
        6,  
        7,  
       16,  
       17,  
       18,  
       19,  
       20,  
       21   
}

Definition at line 1212 of file nsFontMetricsWin.cpp.

eCharset gCharsetToIndex[256] [static]

Definition at line 952 of file nsFontMetricsWin.cpp.

Definition at line 167 of file nsFontMetricsWin.cpp.

Definition at line 170 of file nsFontMetricsWin.cpp.

Definition at line 286 of file nsFontMetricsWin.cpp.

Definition at line 150 of file nsFontMetricsWin.cpp.

Definition at line 177 of file nsFontMetricsWin.cpp.

Definition at line 151 of file nsFontMetricsWin.cpp.

Definition at line 156 of file nsFontMetricsWin.cpp.

Definition at line 154 of file nsFontMetricsWin.cpp.

Definition at line 2198 of file nsFontMetricsWin.cpp.

int gInitialized = 0 [static]

Definition at line 169 of file nsFontMetricsWin.cpp.

Definition at line 5622 of file nsFontMetricsWin.cpp.

Definition at line 68 of file nsFontMetricsWin.cpp.

nsIAtom* gJA = nsnull [static]

Definition at line 161 of file nsFontMetricsWin.cpp.

nsIAtom* gKO = nsnull [static]

Definition at line 162 of file nsFontMetricsWin.cpp.

nsIPref* gPref = nsnull [static]

Definition at line 155 of file nsFontMetricsWin.cpp.

Definition at line 159 of file nsFontMetricsWin.cpp.

Definition at line 160 of file nsFontMetricsWin.cpp.

Definition at line 171 of file nsFontMetricsWin.cpp.

Definition at line 153 of file nsFontMetricsWin.cpp.

Definition at line 158 of file nsFontMetricsWin.cpp.

nsIAtom* gZHCN = nsnull [static]

Definition at line 164 of file nsFontMetricsWin.cpp.

nsIAtom* gZHHK = nsnull [static]

Definition at line 165 of file nsFontMetricsWin.cpp.

nsIAtom* gZHTW = nsnull [static]

Definition at line 163 of file nsFontMetricsWin.cpp.