Back to index

lightning-sunbird  0.9+nobinonly
Defines | Typedefs | Functions | Variables
nsFreeType.cpp File Reference
#include "math.h"
#include "nsIPref.h"
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
#include "nsICharRepresentable.h"
#include "nsCompressedCharMap.h"
#include "nsICharsetConverterManager.h"
#include "nsIRenderingContext.h"
#include "nsFreeType.h"
#include <ft2build.h>

Go to the source code of this file.

Defines

#define FREETYPE_PRINTF(x)
#define NS_FT2_OFFSET(f)   (long)&((nsFreeType2*)0)->f

Typedefs

typedef int Error

Functions

FT_Error nsFreeTypeFaceRequester (FTC_FaceID, FT_Library, FT_Pointer, FT_Face *)
static FT_Error nsFreeType2__DummyFunc ()
static NS_DEFINE_CID (kCharSetManagerCID, NS_ICHARSETCONVERTERMANAGER_CID)
nsFreeTypeFace * nsFreeTypeGetFaceID (nsFontCatalogEntry *aFce)

Variables

PRUint32 gFreeTypeDebug = 0
nsulCodePageRangeCharSetName ulCodePageRange1CharSetNames []
nsulCodePageRangeCharSetName ulCodePageRange2CharSetNames []
nsTTFontFamilyEncoderInfo gFontFamilyEncoderInfo []
static nsHashtable * gFreeTypeFaces = nsnull
nsTTFontEncoderInfo FEI_Adobe_Symbol_Encoding
nsTTFontEncoderInfo FEI_x_ttf_cmr
nsTTFontEncoderInfo FEI_x_ttf_cmmi
nsTTFontEncoderInfo FEI_x_ttf_cmsy
nsTTFontEncoderInfo FEI_x_ttf_cmex
nsTTFontEncoderInfo FEI_x_mathematica1
nsTTFontEncoderInfo FEI_x_mathematica2
nsTTFontEncoderInfo FEI_x_mathematica3
nsTTFontEncoderInfo FEI_x_mathematica4
nsTTFontEncoderInfo FEI_x_mathematica5
nsTTFontEncoderInfo FEI_x_mtextra
nsTTFontEncoderInfo FEI_windows_1252

Define Documentation

Value:
PR_BEGIN_MACRO \
              if (gFreeTypeDebug) { \
                printf x ; \
                printf(", %s %d\n", __FILE__, __LINE__); \
              } \
            PR_END_MACRO

Definition at line 56 of file nsFreeType.cpp.

#define NS_FT2_OFFSET (   f)    (long)&((nsFreeType2*)0)->f

Definition at line 99 of file nsFreeType.cpp.


Typedef Documentation

typedef int Error

Definition at line 85 of file nsFreeType.cpp.


Function Documentation

static NS_DEFINE_CID ( kCharSetManagerCID  ,
NS_ICHARSETCONVERTERMANAGER_CID   
) [static]
static FT_Error nsFreeType2__DummyFunc ( ) [static]

Definition at line 442 of file nsFreeType.cpp.

{
  NS_ERROR("nsFreeType2__DummyFunc should never be called");
  return 1;
}
FT_Error nsFreeTypeFaceRequester ( FTC_FaceID  face_id,
FT_Library  lib,
FT_Pointer  request_data,
FT_Face aFace 
)

Definition at line 1014 of file nsFreeType.cpp.

{
  nsFreeTypeFace *faceID = (nsFreeTypeFace *)face_id;
  FT_Error fterror = 0;
  nsFreeType2 *ft2 = (nsFreeType2 *)request_data;
  nsresult rv;

  rv = ft2->NewFace(lib, faceID->GetFilename(), faceID->GetFaceIndex(), aFace);
  if (NS_FAILED(rv))
    return fterror;

  FT_Face face = *aFace;
  FT_UShort platform_id = TT_PLATFORM_MICROSOFT;
  FT_UShort encoding_id = TT_MS_ID_UNICODE_CS;
  nsFontCatalogEntry* fce = faceID->GetFce();
  nsTTFontFamilyEncoderInfo *ffei =
                     nsFreeType2::GetCustomEncoderInfo(fce->mFamilyName);
  if (ffei) {
    platform_id = ffei->mEncodingInfo->mCmapPlatformID;
    encoding_id = ffei->mEncodingInfo->mCmapEncoding;
  }

  for (int i=0; i < face->num_charmaps; i++) {
    if (face->charmaps[i]->platform_id == platform_id) {
#if defined(TT_MS_ID_UCS_4)
      if (face->charmaps[i]->encoding_id == TT_MS_ID_UCS_4) {
        rv = ft2->SetCharmap(face, face->charmaps[i]);
        if (NS_FAILED(rv)) {
          FREETYPE_PRINTF(("failed to set cmap"));
          ft2->DoneFace(face);
          *aFace = nsnull;
          fterror = 1;
        }
        // UCS_4 is the most prefered cmap since it supports surrogates
        // so stop here to avoid the possibly of getting UNICODE_CS which
        // is the 2nd prefered choice.
        break;
      } else
#endif /* defined(TT_MS_ID_UCS_4) */
      if (face->charmaps[i]->encoding_id == encoding_id) {
        rv = ft2->SetCharmap(face, face->charmaps[i]);
        if (NS_FAILED(rv)) {
          FREETYPE_PRINTF(("failed to set cmap"));
          ft2->DoneFace(face);
          *aFace = nsnull;
          fterror = 1;
        }
      }
    }
  }

  return fterror;
}

Here is the call graph for this function:

nsFreeTypeFace* nsFreeTypeGetFaceID ( nsFontCatalogEntry *  aFce)

Definition at line 1070 of file nsFreeType.cpp.

{
  // We need to have separate keys for the different faces in a ttc file.
  // We append a slash and the face index to the file name to give us a 
  // unique key for each ttc face.
  nsCAutoString key_str(aFce->mFontFileName);
  key_str.Append('/');
  key_str.AppendInt(aFce->mFaceIndex);
  nsCStringKey key(key_str);
  nsFreeTypeFace *face = (nsFreeTypeFace *)gFreeTypeFaces->Get(&key);
  if (!face) {
    face = new nsFreeTypeFace;
    NS_ASSERTION(face, "memory error while creating nsFreeTypeFace");
    if (!face)
      return nsnull;
    NS_ADDREF(face);
    nsresult rv = face->Init(aFce);
    if (NS_FAILED(rv)) {
      NS_RELEASE(face);
      return nsnull;
    }
    gFreeTypeFaces->Put(&key, face);
  }
  return face;
}

Here is the call graph for this function:


Variable Documentation

nsTTFontEncoderInfo FEI_Adobe_Symbol_Encoding
Initial value:
 {
  "Adobe-Symbol-Encoding", TT_PLATFORM_MICROSOFT, TT_MS_ID_SYMBOL_CS, nsnull
}

Definition at line 129 of file nsFreeType.cpp.

nsTTFontEncoderInfo FEI_windows_1252
Initial value:
 {
  "windows-1252", TT_PLATFORM_MICROSOFT, TT_MS_ID_SYMBOL_CS, nsnull
}

Definition at line 162 of file nsFreeType.cpp.

nsTTFontEncoderInfo FEI_x_mathematica1
Initial value:
 {
  "x-mathematica1", TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, nsnull
}

Definition at line 144 of file nsFreeType.cpp.

nsTTFontEncoderInfo FEI_x_mathematica2
Initial value:
 {
  "x-mathematica2", TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, nsnull
}

Definition at line 147 of file nsFreeType.cpp.

nsTTFontEncoderInfo FEI_x_mathematica3
Initial value:
 {
  "x-mathematica3", TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, nsnull
}

Definition at line 150 of file nsFreeType.cpp.

nsTTFontEncoderInfo FEI_x_mathematica4
Initial value:
 {
  "x-mathematica4", TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, nsnull
}

Definition at line 153 of file nsFreeType.cpp.

nsTTFontEncoderInfo FEI_x_mathematica5
Initial value:
 {
  "x-mathematica5", TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, nsnull
}

Definition at line 156 of file nsFreeType.cpp.

nsTTFontEncoderInfo FEI_x_mtextra
Initial value:
 {
  "x-mtextra", TT_PLATFORM_MICROSOFT, TT_MS_ID_SYMBOL_CS, nsnull
}

Definition at line 159 of file nsFreeType.cpp.

nsTTFontEncoderInfo FEI_x_ttf_cmex
Initial value:
 {
  "x-ttf-cmex", TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, nsnull
}

Definition at line 141 of file nsFreeType.cpp.

nsTTFontEncoderInfo FEI_x_ttf_cmmi
Initial value:
 {
  "x-ttf-cmmi", TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, nsnull
}

Definition at line 135 of file nsFreeType.cpp.

nsTTFontEncoderInfo FEI_x_ttf_cmr
Initial value:
 {
  "x-ttf-cmr", TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, nsnull
}

Definition at line 132 of file nsFreeType.cpp.

nsTTFontEncoderInfo FEI_x_ttf_cmsy
Initial value:
 {
  "x-ttf-cmsy", TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, nsnull
}

Definition at line 138 of file nsFreeType.cpp.

nsTTFontFamilyEncoderInfo gFontFamilyEncoderInfo

Definition at line 1096 of file nsFreeType.cpp.

Definition at line 64 of file nsFreeType.cpp.

nsHashtable* gFreeTypeFaces = nsnull [static]

Definition at line 91 of file nsFreeType.cpp.

nsulCodePageRangeCharSetName ulCodePageRange1CharSetNames
Initial value:
 {
{ TT_OS2_CPR1_LATIN1,       "iso8859-1"         },
{ TT_OS2_CPR1_LATIN2,       "iso8859-2"         },
{ TT_OS2_CPR1_CYRILLIC,     "iso8859-5"         },
{ TT_OS2_CPR1_GREEK,        "iso8859-7"         },
{ TT_OS2_CPR1_TURKISH,      "iso8859-9"         },
{ TT_OS2_CPR1_HEBREW,       "iso8859-8"         },
{ TT_OS2_CPR1_ARABIC,       "iso8859-6"         },
{ TT_OS2_CPR1_BALTIC,       "iso8859-13"        },
{ TT_OS2_CPR1_VIETNAMESE,   "viscii1.1-1"       },
{ TT_OS2_CPR1_THAI,         "tis620.2533-1"     },
{ TT_OS2_CPR1_JAPANESE,     "jisx0208.1990-0"   },
{ TT_OS2_CPR1_CHINESE_SIMP, "gb2312.1980-1"     },
{ TT_OS2_CPR1_KO_WANSUNG,   "ksc5601.1992-3"    },
{ TT_OS2_CPR1_CHINESE_TRAD, "big5-0"            },
{ TT_OS2_CPR1_KO_JOHAB,     "ksc5601.1992-3"    },
{ TT_OS2_CPR1_MAC_ROMAN,    "iso8859-1"         },
{ TT_OS2_CPR1_OEM,          "fontspecific-0"    },
{ TT_OS2_CPR1_SYMBOL,       "fontspecific-0"    },
{ 0,                         nsnull             },
}

Definition at line 1132 of file nsFreeType.cpp.

nsulCodePageRangeCharSetName ulCodePageRange2CharSetNames
Initial value:
 {
{ TT_OS2_CPR2_GREEK,        "iso8859-7"         },
{ TT_OS2_CPR2_RUSSIAN,      "koi8-r"            },
{ TT_OS2_CPR2_NORDIC,       "iso8859-10"        },
{ TT_OS2_CPR2_ARABIC,       "iso8859-6"         },
{ TT_OS2_CPR2_CA_FRENCH,    "iso8859-1"         },
{ TT_OS2_CPR2_HEBREW,       "iso8859-8"         },
{ TT_OS2_CPR2_ICELANDIC,    "iso8859-1"         },
{ TT_OS2_CPR2_PORTUGESE,    "iso8859-1"         },
{ TT_OS2_CPR2_TURKISH,      "iso8859-9"         },
{ TT_OS2_CPR2_CYRILLIC,     "iso8859-5"         },
{ TT_OS2_CPR2_LATIN2,       "iso8859-2"         },
{ TT_OS2_CPR2_BALTIC,       "iso8859-4"         },
{ TT_OS2_CPR2_GREEK_437G,   "iso8859-7"         },
{ TT_OS2_CPR2_ARABIC_708,   "iso8859-6"         },
{ TT_OS2_CPR2_WE_LATIN1,    "iso8859-1"         },
{ TT_OS2_CPR2_US,           "iso8859-1"         },
{ 0,                         nsnull             },
}

Definition at line 1154 of file nsFreeType.cpp.