bug=144664 r=bstell@ix.netcom.com sr=bryner@netscape.com
patch=louie.zhao@sun.com
Check in step 2(modify files)
This commit is contained in:
pete.zha%sun.com 2002-11-06 03:21:58 +00:00
Родитель 7ddd008d89
Коммит 47525b744d
14 изменённых файлов: 1101 добавлений и 612 удалений

Просмотреть файл

@ -39,6 +39,7 @@ XPIDLSRCS = \
nsIPrintOptions.idl \
nsIPrintSettings.idl \
nsIPrintSettingsService.idl \
nsIFontCatalogService.idl \
nsIPrintSession.idl \
gfxIFormats.idl \
gfxIImageFrame.idl \

Просмотреть файл

@ -111,4 +111,9 @@
{ 0x2f977d53, 0x5485, 0x11d4, \
{ 0x87, 0xe2, 0x00, 0x10, 0xa4, 0xe7, 0x5e, 0xf2 } }
#define NS_FONTCATALOGSERVICE_CID \
{ 0xa3057187, 0xc40f, 0x4ffa, \
{ 0x91, 0x60, 0x2b, 0x16, 0x48, 0x20, 0x53, 0xb1 } }
#endif

Просмотреть файл

@ -45,6 +45,8 @@ REQUIRES = xpcom \
DIRS = shared
DIRS += freetype
ifdef MOZ_ENABLE_POSTSCRIPT
DIRS += ps
endif

Просмотреть файл

@ -38,7 +38,10 @@
* ***** END LICENSE BLOCK ***** */
#include "math.h"
#include "nsIPref.h"
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
#include "nsCompressedCharMap.h"
#include "nsICharsetConverterManager.h"
#include "nsIRenderingContext.h"
#include "nsFontDebug.h"
@ -74,7 +77,14 @@ PRUint8 nsFreeType::gAATTDarkTextMinValue = 64;
double nsFreeType::gAATTDarkTextGain = 0.8;
PRInt32 nsFreeType::gAntiAliasMinimum = 8;
PRInt32 nsFreeType::gEmbeddedBitmapMaximumHeight = 1000000;
nsHashtable* nsFreeType::sFontFamilies = nsnull;
nsHashtable* nsFreeType::sRange1CharSetNames = nsnull;
nsHashtable* nsFreeType::sRange2CharSetNames = nsnull;
nsICharsetConverterManager2* nsFreeType::sCharSetManager = nsnull;
extern nsulCodePageRangeCharSetName ulCodePageRange1CharSetNames[];
extern nsulCodePageRangeCharSetName ulCodePageRange2CharSetNames[];
extern nsTTFontFamilyEncoderInfo gFontFamilyEncoderInfo[];
typedef int Error;
@ -141,6 +151,44 @@ static FtFuncList FtFuncs [] = {
{nsnull, (PRFuncPtr*)nsnull},
};
nsTTFontEncoderInfo FEI_Adobe_Symbol_Encoding = {
"Adobe-Symbol-Encoding", TT_PLATFORM_MICROSOFT, TT_MS_ID_SYMBOL_CS, nsnull
};
nsTTFontEncoderInfo FEI_x_ttf_cmr = {
"x-ttf-cmr", TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, nsnull
};
nsTTFontEncoderInfo FEI_x_ttf_cmmi = {
"x-ttf-cmmi", TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, nsnull
};
nsTTFontEncoderInfo FEI_x_ttf_cmsy = {
"x-ttf-cmsy", TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, nsnull
};
nsTTFontEncoderInfo FEI_x_ttf_cmex = {
"x-ttf-cmex", TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, nsnull
};
nsTTFontEncoderInfo FEI_x_mathematica1 = {
"x-mathematica1", TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, nsnull
};
nsTTFontEncoderInfo FEI_x_mathematica2 = {
"x-mathematica2", TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, nsnull
};
nsTTFontEncoderInfo FEI_x_mathematica3 = {
"x-mathematica3", TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, nsnull
};
nsTTFontEncoderInfo FEI_x_mathematica4 = {
"x-mathematica4", TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, nsnull
};
nsTTFontEncoderInfo FEI_x_mathematica5 = {
"x-mathematica5", TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, nsnull
};
nsTTFontEncoderInfo FEI_x_mtextra = {
"x-mtextra", TT_PLATFORM_MICROSOFT, TT_MS_ID_SYMBOL_CS, nsnull
};
nsTTFontEncoderInfo FEI_windows_1252 = {
"windows-1252", TT_PLATFORM_MICROSOFT, TT_MS_ID_SYMBOL_CS, nsnull
};
///////////////////////////////////////////////////////////////////////
//
// class nsFreeType data/functions
@ -225,7 +273,24 @@ nsFreeType::FreeGlobals()
(*nsFreeType::nsFT_Done_FreeType)(sFreeTypeLibrary);
sFreeTypeLibrary = nsnull;
}
nsFT2FontCatalog::FreeGlobals();
if (sRange1CharSetNames)
delete sRange1CharSetNames;
if (sRange2CharSetNames)
delete sRange2CharSetNames;
if (sFontFamilies)
delete sFontFamilies;
NS_IF_RELEASE(sCharSetManager);
// release any encoders that were created
int i;
for (i=0; gFontFamilyEncoderInfo[i].mFamilyName; i++) {
nsTTFontFamilyEncoderInfo *ffei = &gFontFamilyEncoderInfo[i];
nsTTFontEncoderInfo *fei = ffei->mEncodingInfo;
NS_IF_RELEASE(fei->mConverter);
}
UnloadSharedLib();
ClearFunctions();
ClearGlobals();
@ -237,7 +302,9 @@ nsFreeType::InitGlobals(void)
NS_ASSERTION(sInited==PR_FALSE, "InitGlobals called more than once");
// set all the globals to default values
ClearGlobals();
nsulCodePageRangeCharSetName *crn = nsnull;
nsTTFontFamilyEncoderInfo *ff = gFontFamilyEncoderInfo;
nsCOMPtr<nsIPref> mPref = do_GetService(NS_PREF_CONTRACTID);
if (!mPref) {
@ -328,10 +395,49 @@ nsFreeType::InitGlobals(void)
}
gFreeTypeFaces = new nsHashtable();
if (!gFreeTypeFaces) {
FreeGlobals();
return NS_ERROR_OUT_OF_MEMORY;
}
if (!nsFT2FontCatalog::InitGlobals(nsFreeType::GetLibrary())) {
return NS_ERROR_FAILURE;
sRange1CharSetNames = new nsHashtable();
if (!sRange1CharSetNames) {
FreeGlobals();
return NS_ERROR_OUT_OF_MEMORY;
}
crn = ulCodePageRange1CharSetNames;
while (crn->charsetName) {
char buf[32];
sprintf(buf, "0x%08lx", crn->bit);
nsCStringKey key(buf);
sRange1CharSetNames->Put(&key, (void*)crn->charsetName);
crn++;
}
sRange2CharSetNames = new nsHashtable();
if (!sRange2CharSetNames) {
FreeGlobals();
return NS_ERROR_OUT_OF_MEMORY;
}
crn = ulCodePageRange2CharSetNames;
while (crn->charsetName) {
char buf[32];
sprintf(buf, "0x%08lx", crn->bit);
nsCStringKey key(buf);
sRange2CharSetNames->Put(&key, (void*)crn->charsetName);
crn++;
}
sFontFamilies = new nsHashtable();
if (!sFontFamilies) {
FreeGlobals();
return NS_ERROR_OUT_OF_MEMORY;
}
while (ff->mFamilyName) {
nsCAutoString name(ff->mFamilyName);
ToLowerCase(name);
nsCStringKey key(name);
sFontFamilies->Put(&key, (void*)ff);
ff++;
}
return NS_OK;
@ -423,16 +529,109 @@ nsFreeType::UnloadSharedLib()
sSharedLib = nsnull;
}
const char *
nsFreeType::GetRange1CharSetName(unsigned long aBit)
{
char buf[32];
sprintf(buf, "0x%08lx", aBit);
nsCStringKey key(buf);
const char *charsetName = (const char *)sRange1CharSetNames->Get(&key);
return charsetName;
}
const char *
nsFreeType::GetRange2CharSetName(unsigned long aBit)
{
char buf[32];
sprintf(buf, "0x%08lx", aBit);
nsCStringKey key(buf);
const char *charsetName = (const char *)sRange2CharSetNames->Get(&key);
return charsetName;
}
nsTTFontFamilyEncoderInfo*
nsFreeType::GetCustomEncoderInfo(const char * aFamilyName)
{
if (!sFontFamilies)
return nsnull;
nsTTFontFamilyEncoderInfo *ffei;
nsCAutoString name(aFamilyName);
ToLowerCase(name);
nsCStringKey key(name);
ffei = (nsTTFontFamilyEncoderInfo*)sFontFamilies->Get(&key);
if (!ffei)
return nsnull;
// init the converter
if (!ffei->mEncodingInfo->mConverter) {
nsTTFontEncoderInfo *fei = ffei->mEncodingInfo;
//
// build the converter
//
nsICharsetConverterManager2* charSetManager = GetCharSetManager();
if (!charSetManager)
return nsnull;
nsCOMPtr<nsIAtom> charset(dont_AddRef(NS_NewAtom(fei->mConverterName)));
if (charset) {
nsresult res;
res = charSetManager->GetUnicodeEncoder(charset, &fei->mConverter);
if (NS_FAILED(res)) {
return nsnull;
}
}
}
return ffei;
}
nsICharsetConverterManager2*
nsFreeType::GetCharSetManager()
{
if (!sCharSetManager) {
//
// get the sCharSetManager
//
nsServiceManager::GetService(kCharSetManagerCID,
NS_GET_IID(nsICharsetConverterManager2),
(nsISupports**) &sCharSetManager);
NS_ASSERTION(sCharSetManager,"failed to create the charset manager");
}
return sCharSetManager;
}
PRUint16*
nsFreeType::GetCCMap(nsFontCatalogEntry *aFce)
{
nsCompressedCharMap ccmapObj;
ccmapObj.SetChars(aFce->mCCMap);
return ccmapObj.NewCCMap();
}
///////////////////////////////////////////////////////////////////////
//
// class nsFreeTypeFace data/functions
//
///////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS1(nsFreeTypeFace, nsITrueTypeFontCatalogEntry)
nsFreeTypeFace::nsFreeTypeFace(nsFontCatalogEntry *aFce)
nsFreeTypeFace::nsFreeTypeFace()
{
mFce = aFce;
}
nsresult nsFreeTypeFace::Init(nsFontCatalogEntry *aFce)
{
NS_ASSERTION(aFce, "init of nsFreeTypeFace needs nsFontCatalogEntry");
NS_INIT_ISUPPORTS();
if (aFce)
mFce = aFce;
else {
mFce = new nsFontCatalogEntry;
NS_ASSERTION(mFce, "memory error while creating nsFontCatalogEntry");
if (!mFce)
return NS_ERROR_OUT_OF_MEMORY;
}
mCCMap = nsnull;
return NS_OK;
}
nsFreeTypeFace::~nsFreeTypeFace()
@ -441,6 +640,156 @@ nsFreeTypeFace::~nsFreeTypeFace()
FreeCCMap(mCCMap);
}
NS_IMETHODIMP nsFreeTypeFace::GetFontCatalogType(
PRUint16 *aFontCatalogType)
{
*aFontCatalogType = FONT_CATALOG_TRUETYPE;
return NS_OK;
}
/* readonly attribute ACString fileName; */
NS_IMETHODIMP nsFreeTypeFace::GetFileName(nsACString & aFileName)
{
aFileName.Assign(mFce->mFontFileName);
return NS_OK;
}
/* readonly attribute ACString familyName; */
NS_IMETHODIMP nsFreeTypeFace::GetFamilyName(nsACString & aFamilyName)
{
aFamilyName.Assign(mFce->mFamilyName);
return NS_OK;
}
/* readonly attribute ACString styleName; */
NS_IMETHODIMP nsFreeTypeFace::GetStyleName(nsACString & aStyleName)
{
aStyleName.Assign(mFce->mStyleName);
return NS_OK;
}
/* readonly attribute ACString vendorID; */
NS_IMETHODIMP nsFreeTypeFace::GetVendorID(nsACString & aVendorID)
{
aVendorID.Assign(mFce->mVendorID);
return NS_OK;
}
/* readonly attribute short faceIndex; */
NS_IMETHODIMP nsFreeTypeFace::GetFaceIndex(PRInt16 *aFaceIndex)
{
*aFaceIndex = mFce->mFaceIndex;
return NS_OK;
}
/* readonly attribute short numFaces; */
NS_IMETHODIMP nsFreeTypeFace::GetNumFaces(PRInt16 *aNumFaces)
{
*aNumFaces = mFce->mNumFaces;
return NS_OK;
}
/* readonly attribute short numEmbeddedBitmaps; */
NS_IMETHODIMP nsFreeTypeFace::GetNumEmbeddedBitmaps(
PRInt16 *aNumEmbeddedBitmaps)
{
*aNumEmbeddedBitmaps = mFce->mNumEmbeddedBitmaps;
return NS_OK;
}
/* readonly attribute long numGlyphs; */
NS_IMETHODIMP nsFreeTypeFace::GetNumGlyphs(PRInt32 *aNumGlyphs)
{
*aNumGlyphs = mFce->mNumGlyphs;
return NS_OK;
}
/* readonly attribute long numUsableGlyphs; */
NS_IMETHODIMP nsFreeTypeFace::GetNumUsableGlyphs(
PRInt32 *aNumUsableGlyphs)
{
*aNumUsableGlyphs = mFce->mNumUsableGlyphs;
return NS_OK;
}
/* readonly attribute unsigned short weight; */
NS_IMETHODIMP nsFreeTypeFace::GetWeight(PRUint16 *aWeight)
{
*aWeight = mFce->mWeight;
return NS_OK;
}
/* readonly attribute unsigned short width; */
NS_IMETHODIMP nsFreeTypeFace::GetWidth(PRUint16 *aWidth)
{
*aWidth = mFce->mWidth;
return NS_OK;
}
/* readonly attribute unsigned long flags; */
NS_IMETHODIMP nsFreeTypeFace::GetFlags(PRUint32 *aFlags)
{
*aFlags = mFce->mFlags;
return NS_OK;
}
/* readonly attribute long long faceFlags; */
NS_IMETHODIMP nsFreeTypeFace::GetFaceFlags(PRInt64 *aFaceFlags)
{
*aFaceFlags = mFce->mFaceFlags;
return NS_OK;
}
/* readonly attribute long long styleFlags; */
NS_IMETHODIMP nsFreeTypeFace::GetStyleFlags(PRInt64 *aStyleFlags)
{
*aStyleFlags = mFce->mStyleFlags;
return NS_OK;
}
/* readonly attribute unsigned long codePageRange1; */
NS_IMETHODIMP nsFreeTypeFace::GetCodePageRange1(
PRUint32 *aCodePageRange1)
{
*aCodePageRange1 = mFce->mCodePageRange1;
return NS_OK;
}
/* readonly attribute unsigned long codePageRange2; */
NS_IMETHODIMP nsFreeTypeFace::GetCodePageRange2(
PRUint32 *aCodePageRange2)
{
*aCodePageRange2 = mFce->mCodePageRange2;
return NS_OK;
}
/* readonly attribute long long time; */
NS_IMETHODIMP nsFreeTypeFace::GetFileModTime(PRInt64 *aTime)
{
*aTime = mFce->mMTime;
return NS_OK;
}
/* void getCCMap (out unsigned long size,
* [array, size_is (size), retval] out unsigned short ccMaps); */
NS_IMETHODIMP nsFreeTypeFace::GetCCMap(
PRUint32 *size, PRUint16 **ccMaps)
{
*ccMaps = nsFreeType::GetCCMap(mFce);
*size = CCMAP_SIZE(*ccMaps);
return NS_OK;
}
/* void getEmbeddedBitmapHeights (out unsigned long size,
* [array, size_is (size), retval] out short heights); */
NS_IMETHODIMP nsFreeTypeFace::GetEmbeddedBitmapHeights(
PRUint32 *size, PRInt32 **heights)
{
*heights = mFce->mEmbeddedBitmapHeights;
*size = mFce->mNumEmbeddedBitmaps;
return NS_OK;
}
PRBool
nsFreeTypeFace::FreeFace(nsHashKey* aKey, void* aData, void* aClosure)
{
@ -454,12 +803,11 @@ PRUint16 *
nsFreeTypeFace::GetCCMap()
{
if (!mCCMap) {
mCCMap = nsFT2FontCatalog::GetCCMap(mFce);
mCCMap = nsFreeType::GetCCMap(mFce);
}
return mCCMap;
}
///////////////////////////////////////////////////////////////////////
//
// miscellaneous routines in alphabetic order
@ -478,7 +826,7 @@ nsFreeTypeFaceRequester(FTC_FaceID face_id, FT_Library lib,
// since all interesting data is in the nsFreeTypeFace object
// we do not currently need to use request_data
fterror = (*nsFreeType::nsFT_New_Face)(nsFreeType::GetLibrary(),
faceID->GetFilename(),
faceID->GetFilename(),
faceID->GetFaceIndex(), aFace);
if (fterror)
return fterror;
@ -487,7 +835,8 @@ nsFreeTypeFaceRequester(FTC_FaceID face_id, FT_Library lib,
FT_UShort platform_id = TT_PLATFORM_MICROSOFT;
FT_UShort encoding_id = TT_MS_ID_UNICODE_CS;
nsFontCatalogEntry* fce = faceID->GetFce();
nsTTFontFamilyEncoderInfo *ffei = nsFT2FontCatalog::GetCustomEncoderInfo(fce);
nsTTFontFamilyEncoderInfo *ffei =
nsFreeType::GetCustomEncoderInfo(fce->mFamilyName);
if (ffei) {
platform_id = ffei->mEncodingInfo->mCmapPlatformID;
encoding_id = ffei->mEncodingInfo->mCmapEncoding;
@ -513,19 +862,99 @@ nsFreeTypeGetFaceID(nsFontCatalogEntry *aFce)
// 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(nsFT2FontCatalog::GetFileName(aFce));
nsCAutoString key_str(aFce->mFontFileName);
key_str.Append('/');
key_str.AppendInt(nsFT2FontCatalog::GetFaceIndex(aFce));
key_str.AppendInt(aFce->mFaceIndex);
nsCStringKey key(key_str);
nsFreeTypeFace *face = (nsFreeTypeFace *)gFreeTypeFaces->Get(&key);
if (!face) {
face = new nsFreeTypeFace(aFce);
NS_ASSERTION(face, "memory error while creating nsFreeTypeFace");
if (!face)
face = new nsFreeTypeFace;
nsresult rv = face->Init(aFce);
if (NS_FAILED(rv))
return nsnull;
gFreeTypeFaces->Put(&key, face);
}
return face;
}
nsTTFontFamilyEncoderInfo gFontFamilyEncoderInfo[] = {
{ "symbol", &FEI_Adobe_Symbol_Encoding },
{ "cmr10", &FEI_x_ttf_cmr, },
{ "cmmi10", &FEI_x_ttf_cmmi, },
{ "cmsy10", &FEI_x_ttf_cmsy, },
{ "cmex10", &FEI_x_ttf_cmex, },
{ "math1", &FEI_x_mathematica1, },
{ "math1-bold", &FEI_x_mathematica1, },
{ "math1mono", &FEI_x_mathematica1, },
{ "math1mono-bold", &FEI_x_mathematica1, },
{ "math2", &FEI_x_mathematica2, },
{ "math2-bold", &FEI_x_mathematica2, },
{ "math2mono", &FEI_x_mathematica2, },
{ "math2mono-bold", &FEI_x_mathematica2, },
{ "ahMn", &FEI_x_mathematica3, }, // weird name for Math3
{ "math3", &FEI_x_mathematica3, },
{ "math3-bold", &FEI_x_mathematica3, },
{ "math3mono", &FEI_x_mathematica3, },
{ "math3mono-bold", &FEI_x_mathematica3, },
{ "math4", &FEI_x_mathematica4, },
{ "math4-bold", &FEI_x_mathematica4, },
{ "math4mono", &FEI_x_mathematica4, },
{ "math4mono-bold", &FEI_x_mathematica4, },
{ "math5", &FEI_x_mathematica5, },
{ "math5-bold", &FEI_x_mathematica5, },
{ "math5bold", &FEI_x_mathematica5, },
{ "math5mono", &FEI_x_mathematica5, },
{ "math5mono-bold", &FEI_x_mathematica5, },
{ "math5monobold", &FEI_x_mathematica5, },
{ "mtextra", &FEI_x_mtextra, },
{ "mt extra", &FEI_x_mtextra, },
{ "wingdings", &FEI_windows_1252, },
{ "webdings", &FEI_windows_1252, },
{ nsnull },
};
nsulCodePageRangeCharSetName ulCodePageRange1CharSetNames[] = {
{ 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 },
};
nsulCodePageRangeCharSetName ulCodePageRange2CharSetNames[] = {
{ 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 },
};
#endif /* (!defined(MOZ_ENABLE_FREETYPE2)) */

Просмотреть файл

@ -27,20 +27,67 @@
void nsFreeTypeFreeGlobals(void);
nsresult nsFreeTypeInitGlobals(void);
#include "nsIFontCatalogService.h"
#if (defined(MOZ_ENABLE_FREETYPE2))
#include "nspr.h"
#include "nsHashtable.h"
#include "nsICharsetConverterManager2.h"
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_CACHE_H
#include FT_CACHE_IMAGE_H
#include FT_TRUETYPE_TABLES_H
#include "nsFT2FontCatalog.h"
typedef struct FT_FaceRec_* FT_Face;
class nsFreeTypeFace;
typedef struct {
const char *mFontFileName;
time_t mMTime;
PRUint32 mFlags;
const char *mFontType;
int mFaceIndex;
int mNumFaces;
const char *mFamilyName;
const char *mStyleName;
FT_UShort mWeight;
FT_UShort mWidth;
int mNumGlyphs;
int mNumUsableGlyphs;
FT_Long mFaceFlags;
FT_Long mStyleFlags;
FT_Long mCodePageRange1;
FT_Long mCodePageRange2;
char mVendorID[5];
const char *mFoundryName;
int mNumEmbeddedBitmaps;
int *mEmbeddedBitmapHeights;
PRUint16 *mCCMap; // compressed char map
} nsFontCatalogEntry;
nsFreeTypeFace * nsFreeTypeGetFaceID(nsFontCatalogEntry *aFce);
#define FCE_FLAGS_ISVALID 0x01
#define FCE_FLAGS_UNICODE 0x02
#define FCE_FLAGS_SYMBOL 0x04
#define FREE_IF(x) if(x) free((void*)x)
typedef struct {
const char *mConverterName;
PRUint8 mCmapPlatformID;
PRUint8 mCmapEncoding;
nsIUnicodeEncoder* mConverter;
} nsTTFontEncoderInfo;
typedef struct nsTTFontFamilyEncoderInfo {
const char *mFamilyName;
nsTTFontEncoderInfo *mEncodingInfo;
} nsTTFontFamilyEncoderInfo;
typedef struct {
unsigned long bit;
const char *charsetName;
} nsulCodePageRangeCharSetName;
//
// the FreeType2 function type declarations
@ -65,6 +112,9 @@ typedef FT_Error (*FTC_Manager_New_t)(FT_Library, FT_UInt, FT_UInt, FT_ULong,
FTC_Face_Requester, FT_Pointer, FTC_Manager*);
typedef FT_Error (*FTC_Image_Cache_New_t)(FTC_Manager, FTC_Image_Cache*);
class nsFreeTypeFace;
nsFreeTypeFace * nsFreeTypeGetFaceID(nsFontCatalogEntry *aFce);
// class nsFreeType class definition
class nsFreeType {
public:
@ -75,6 +125,11 @@ public:
static void FreeGlobals();
static nsresult InitGlobals();
static PRUint16* GetCCMap(nsFontCatalogEntry *aFce);
static const char* GetRange1CharSetName(unsigned long aBit);
static const char* GetRange2CharSetName(unsigned long aBit);
static nsTTFontFamilyEncoderInfo* GetCustomEncoderInfo(const char *);
// run time loaded (function pointers)
static FT_Done_Face_t nsFT_Done_Face;
static FT_Done_FreeType_t nsFT_Done_FreeType;
@ -108,6 +163,7 @@ protected:
static PRBool InitLibrary();
static PRBool LoadSharedLib();
static void UnloadSharedLib();
static nsICharsetConverterManager2* GetCharSetManager();
static PRLibrary *sSharedLib;
static PRBool sInited;
@ -116,21 +172,35 @@ protected:
static FT_Library sFreeTypeLibrary;
static FTC_Manager sFTCacheManager;
static FTC_Image_Cache sImageCache;
static nsHashtable *sFontFamilies;
static nsHashtable *sRange1CharSetNames;
static nsHashtable *sRange2CharSetNames;
static nsICharsetConverterManager2* sCharSetManager;
};
// class nsFreeTypeFace definition
/* this simple record is used to model a given `installed' face */
class nsFreeTypeFace {
class nsFreeTypeFace : public nsITrueTypeFontCatalogEntry {
public:
nsFreeTypeFace(nsFontCatalogEntry *aFce);
~nsFreeTypeFace();
NS_DECL_ISUPPORTS
NS_DECL_NSITRUETYPEFONTCATALOGENTRY
nsFreeTypeFace();
virtual ~nsFreeTypeFace();
virtual nsresult Init(nsFontCatalogEntry *aFce);
/* additional members */
NS_IMETHODIMP GetFontCatalogType(PRUint16 *aFontCatalogType);
static PRBool FreeFace(nsHashKey* aKey, void* aData, void* aClosure);
const char *GetFilename() { return nsFT2FontCatalog::GetFileName(mFce); }
int *GetEmbeddedBitmapHeights() {
return nsFT2FontCatalog::GetEmbeddedBitmapHeights(mFce); } ;
int GetFaceIndex() { return nsFT2FontCatalog::GetFaceIndex(mFce); }
int GetNumEmbeddedBitmaps() {
return nsFT2FontCatalog::GetNumEmbeddedBitmaps(mFce); } ;
const char *GetFilename()
{ return mFce->mFontFileName; }
int *GetEmbeddedBitmapHeights()
{ return mFce->mEmbeddedBitmapHeights; } ;
int GetFaceIndex()
{ return mFce->mFaceIndex; }
int GetNumEmbeddedBitmaps()
{ return mFce->mNumEmbeddedBitmaps; } ;
PRUint16 *GetCCMap();
nsFontCatalogEntry* GetFce() { return mFce; };

Просмотреть файл

@ -60,7 +60,6 @@ CSRCS = nsPrintdGTK.c
X11SHARED_LCPPSRCS = \
nsAntiAliasedGlyph.cpp \
nsFontFreeType.cpp \
nsFreeType.cpp \
nsFT2FontNode.cpp \
nsFT2FontCatalog.cpp \
nsX11AlphaBlend.cpp \
@ -89,6 +88,7 @@ CPPSRCS += \
$(X11SHARED_LCPPSRCS) \
nsFontMetricsGTK.cpp \
nsGdkUtils.cpp
EXTRA_DSO_LDOPTS += $(LIBS_DIR) -lgfxft2
endif
ifdef MOZ_ENABLE_XFT
@ -187,6 +187,7 @@ LOCAL_INCLUDES = \
-I$(srcdir)/. \
-I$(srcdir)/.. \
-I$(srcdir)/../shared \
-I$(srcdir)/../freetype \
-I$(srcdir)/../x11shared \
$(NULL)

Просмотреть файл

@ -52,6 +52,7 @@
#include "nsICharRepresentable.h"
#include "nsCompressedCharMap.h"
#include "nsIFontMetricsGTK.h"
#include "nsIFontCatalogService.h"
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
@ -91,7 +92,7 @@ struct nsFontStretch
char* mScalable;
PRBool mOutlineScaled;
nsVoidArray mScaledFonts;
nsFreeTypeFace * mFreeTypeFaceID;
nsITrueTypeFontCatalogEntry* mFreeTypeFaceID;
};
struct nsFontStyle

Просмотреть файл

@ -70,6 +70,7 @@
#include "nsFontMetricsUtils.h"
#include "nsPrintSession.h"
#include "gfxImageFrame.h"
#include "x11shared/nsFT2FontCatalog.h"
// objects that just require generic constructors
@ -89,6 +90,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeThemeGTK)
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(gfxImageFrame)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFT2FontCatalog)
// our custom constructors
@ -284,6 +286,10 @@ static const nsModuleComponentInfo components[] =
NS_PRINTSESSION_CID,
"@mozilla.org/gfx/printsession;1",
nsPrintSessionConstructor },
{ "TrueType Font Catalog Service",
NS_FONTCATALOGSERVICE_CID,
"@mozilla.org/gfx/xfontcatalogservice;1",
nsFT2FontCatalogConstructor },
#ifdef NATIVE_THEME_SUPPORT
{ "Native Theme Renderer",
NS_THEMERENDERER_CID,

Просмотреть файл

@ -50,7 +50,14 @@
#include "nsLocalFileUnix.h"
#include "nsIEnumerator.h"
#include "nsITimelineService.h"
#include "nsFT2FontCatalog.h"
/*
* since this patch won't delete "gfx/src/freetype/nsFT2FontCatalog.h",
* using "x11shared/nsFT2FontCatalog.h" will prevent this file from
* including that "nsFT2FontCatalog.h". This can be changed to
* "#include nsFT2FontCatalog.h" safely after deleting
* unused "freetype/nsFT2FontCatalog.h"
*/
#include "x11shared/nsFT2FontCatalog.h"
#if (defined(MOZ_ENABLE_FREETYPE2))
//
@ -95,133 +102,103 @@ extern "C" {char *ctime(const time_t *timep);}
#include FT_FREETYPE_H
#include FT_TRUETYPE_TABLES_H
#include FT_TRUETYPE_IDS_H
#include "nsFreeType.h"
#include "nsFontDebug.h"
// these should be static but the compilier complains
extern nsFontVendorName sVendorNamesList[];
extern nsulCodePageRangeCharSetName ulCodePageRange1CharSetNames[];
extern nsulCodePageRangeCharSetName ulCodePageRange2CharSetNames[];
extern nsulCodePageRangeLanguage ulCodePageRange1Language[];
extern nsulCodePageRangeLanguage ulCodePageRange2Language[];
nsFT2FontCatalog* gFT2FontCatalog = nsnull;
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kCharSetManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
nsICharsetConverterManager2* nsFT2FontCatalog::sCharSetManager = nsnull;
nsTTFontEncoderInfo FEI_Adobe_Symbol_Encoding = {
"Adobe-Symbol-Encoding", TT_PLATFORM_MICROSOFT, TT_MS_ID_SYMBOL_CS, nsnull
};
nsTTFontEncoderInfo FEI_x_ttf_cmr = {
"x-ttf-cmr", TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, nsnull
};
nsTTFontEncoderInfo FEI_x_ttf_cmmi = {
"x-ttf-cmmi", TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, nsnull
};
nsTTFontEncoderInfo FEI_x_ttf_cmsy = {
"x-ttf-cmsy", TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, nsnull
};
nsTTFontEncoderInfo FEI_x_ttf_cmex = {
"x-ttf-cmex", TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, nsnull
};
nsTTFontEncoderInfo FEI_x_mathematica1 = {
"x-mathematica1", TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, nsnull
};
nsTTFontEncoderInfo FEI_x_mathematica2 = {
"x-mathematica2", TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, nsnull
};
nsTTFontEncoderInfo FEI_x_mathematica3 = {
"x-mathematica3", TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, nsnull
};
nsTTFontEncoderInfo FEI_x_mathematica4 = {
"x-mathematica4", TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, nsnull
};
nsTTFontEncoderInfo FEI_x_mathematica5 = {
"x-mathematica5", TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, nsnull
};
nsTTFontEncoderInfo FEI_x_mtextra = {
"x-mtextra", TT_PLATFORM_MICROSOFT, TT_MS_ID_SYMBOL_CS, nsnull
};
nsTTFontEncoderInfo FEI_windows_1252 = {
"windows-1252", TT_PLATFORM_MICROSOFT, TT_MS_ID_SYMBOL_CS, nsnull
};
nsHashtable* nsFT2FontCatalog::sVendorNames = nsnull;
nsIPref* nsFT2FontCatalog::sPref = nsnull;
nsTTFontFamilyEncoderInfo gFontFamilyEncoderInfo[] = {
{ "symbol", &FEI_Adobe_Symbol_Encoding },
{ "cmr10", &FEI_x_ttf_cmr, },
{ "cmmi10", &FEI_x_ttf_cmmi, },
{ "cmsy10", &FEI_x_ttf_cmsy, },
{ "cmex10", &FEI_x_ttf_cmex, },
{ "math1", &FEI_x_mathematica1, },
{ "math1-bold", &FEI_x_mathematica1, },
{ "math1mono", &FEI_x_mathematica1, },
{ "math1mono-bold", &FEI_x_mathematica1, },
{ "math2", &FEI_x_mathematica2, },
{ "math2-bold", &FEI_x_mathematica2, },
{ "math2mono", &FEI_x_mathematica2, },
{ "math2mono-bold", &FEI_x_mathematica2, },
{ "ahMn", &FEI_x_mathematica3, }, // weird name for Math3
{ "math3", &FEI_x_mathematica3, },
{ "math3-bold", &FEI_x_mathematica3, },
{ "math3mono", &FEI_x_mathematica3, },
{ "math3mono-bold", &FEI_x_mathematica3, },
{ "math4", &FEI_x_mathematica4, },
{ "math4-bold", &FEI_x_mathematica4, },
{ "math4mono", &FEI_x_mathematica4, },
{ "math4mono-bold", &FEI_x_mathematica4, },
{ "math5", &FEI_x_mathematica5, },
{ "math5-bold", &FEI_x_mathematica5, },
{ "math5bold", &FEI_x_mathematica5, },
{ "math5mono", &FEI_x_mathematica5, },
{ "math5mono-bold", &FEI_x_mathematica5, },
{ "math5monobold", &FEI_x_mathematica5, },
{ "mtextra", &FEI_x_mtextra, },
{ "mt extra", &FEI_x_mtextra, },
{ "wingdings", &FEI_windows_1252, },
{ "webdings", &FEI_windows_1252, },
{ nsnull },
};
#endif
nsTTFontFamilyEncoderInfo*
nsFT2FontCatalog::GetCustomEncoderInfo(nsFontCatalogEntry *aFce)
//
// Implementation of Interfaces nsIFontCatalogService
//
NS_IMPL_ISUPPORTS1(nsFT2FontCatalog, nsIFontCatalogService)
nsFT2FontCatalog::nsFT2FontCatalog()
{
return GetCustomEncoderInfo(GetFamilyName(aFce));
}
nsTTFontFamilyEncoderInfo*
nsFT2FontCatalog::GetCustomEncoderInfo(const char * aFamilyName)
{
if (!gFT2FontCatalog)
return nsnull;
nsTTFontFamilyEncoderInfo *ffei;
nsCAutoString name(aFamilyName);
ToLowerCase(name);
nsCStringKey key(name);
ffei = (nsTTFontFamilyEncoderInfo*)gFT2FontCatalog->mFontFamilies->Get(&key);
if (!ffei)
return nsnull;
// init the converter
if (!ffei->mEncodingInfo->mConverter) {
nsTTFontEncoderInfo *fei = ffei->mEncodingInfo;
//
// build the converter
//
nsICharsetConverterManager2* charSetManager = GetCharSetManager();
if (!charSetManager)
return nsnull;
nsCOMPtr<nsIAtom> charset(dont_AddRef(NS_NewAtom(fei->mConverterName)));
if (charset) {
nsresult res;
res = charSetManager->GetUnicodeEncoder(charset, &fei->mConverter);
if (NS_FAILED(res)) {
return nsnull;
}
}
NS_INIT_ISUPPORTS();
#if (defined(MOZ_ENABLE_FREETYPE2))
nsresult rv;
mAvailableFontCatalogService = PR_FALSE;
rv = nsFreeType::InitGlobals();
if (NS_FAILED(rv)) {
// FreeType is not available
return;
}
return ffei;
if (!InitGlobals(nsFreeType::GetLibrary())) {
// Font Catalog Service is not available
return;
}
mAvailableFontCatalogService = PR_TRUE;
#endif
}
nsFT2FontCatalog::~nsFT2FontCatalog()
{
#if (defined(MOZ_ENABLE_FREETYPE2))
/* destructor code */
FreeGlobals();
// assumption: no one else use nsFreeType
nsFreeType::FreeGlobals();
#endif
}
NS_IMETHODIMP
nsFT2FontCatalog::GetFontCatalogEntries(const nsACString & aFamilyName,
const nsACString & aLanguage,
PRUint16 aWeight,
PRUint16 aWidth,
PRUint16 aSlant,
PRUint16 aSpacing,
nsISupportsArray **_retval)
{
#if (!defined(MOZ_ENABLE_FREETYPE2))
*_retval = nsnull;
return NS_OK;
#else
if (mAvailableFontCatalogService == PR_FALSE) {
*_retval = nsnull;
return NS_OK;
}
nsFontCatalog *fc = NewFontCatalog();
if (!fc)
return NS_ERROR_OUT_OF_MEMORY;
GetFontNames(aFamilyName, aLanguage, aWeight, aWidth, aSlant, aSpacing, fc);
nsCOMPtr<nsITrueTypeFontCatalogEntry> aFce;
nsCOMPtr<nsISupports> genericFce;
nsCOMPtr<nsISupportsArray> entries;
NS_NewISupportsArray(getter_AddRefs(entries));
if (!entries)
return NS_ERROR_OUT_OF_MEMORY;
for (int i = 0; i < fc->numFonts; i++) {
aFce = nsFreeTypeGetFaceID(fc->fonts[i]);
genericFce = do_QueryInterface(aFce);
entries->InsertElementAt(genericFce, 0);
}
free(fc);
*_retval = entries;
NS_ADDREF(*_retval);
#endif
return NS_OK;
}
//--------------------------------------------------
#if (defined(MOZ_ENABLE_FREETYPE2))
void
nsFT2FontCatalog::AddDir(nsDirCatalog *dc, nsDirCatalogEntry *dir)
{
@ -520,7 +497,7 @@ nsFT2FontCatalog::FixUpFontCatalog(nsFontCatalog *fc)
ToLowerCase(vendorID);
vendorID.StripChars(" ");
nsCStringKey key(vendorID);
const char *vendorStr = (const char *)mVendorNames->Get(&key);
const char *vendorStr = (const char *)sVendorNames->Get(&key);
if (!vendorStr) {
if (fce->mVendorID[0])
vendorStr = fce->mVendorID;
@ -551,8 +528,7 @@ PRBool
nsFT2FontCatalog::FreeFceHashEntry(nsHashKey* aKey, void* aData, void* aClosure)
{
nsFontCatalogEntry *fce = (nsFontCatalogEntry *)aData;
gFT2FontCatalog->FreeFontCatalogEntry(fce);
FreeFontCatalogEntry(fce);
return PR_TRUE;
}
@ -589,69 +565,23 @@ nsFT2FontCatalog::FreeFontCatalogEntry(nsFontCatalogEntry *fce)
void
nsFT2FontCatalog::FreeGlobals()
{
if (gFT2FontCatalog) {
gFT2FontCatalog->doFreeGlobals();
gFT2FontCatalog = nsnull;
}
}
void
nsFT2FontCatalog::doFreeGlobals()
{
if (mFontCatalog) {
gFT2FontCatalog->FreeFontCatalog(mFontCatalog);
FreeFontCatalog(mFontCatalog);
mFontCatalog = nsnull;
}
// mVendorNames elements are not alloc'd so no need call Reset
delete mVendorNames;
// mFontFamilies elements are not alloc'd so no need call Reset
delete mFontFamilies;
// sVendorNames elements are not alloc'd so no need call Reset
delete sVendorNames;
delete mRange1Language;
delete mRange2Language;
//
// release any encoders that were created
//
int i;
for (i=0; gFontFamilyEncoderInfo[i].mFamilyName; i++) {
nsTTFontFamilyEncoderInfo *ffei = &gFontFamilyEncoderInfo[i];
nsTTFontEncoderInfo *fei = ffei->mEncodingInfo;
NS_IF_RELEASE(fei->mConverter);
}
NS_IF_RELEASE(sCharSetManager);
}
PRUint16*
nsFT2FontCatalog::GetCCMap(nsFontCatalogEntry *aFce)
{
nsCompressedCharMap ccmapObj;
ccmapObj.SetChars(aFce->mCCMap);
return ccmapObj.NewCCMap();
}
nsICharsetConverterManager2*
nsFT2FontCatalog::GetCharSetManager()
{
if (!sCharSetManager) {
//
// get the sCharSetManager
//
nsServiceManager::GetService(kCharSetManagerCID,
NS_GET_IID(nsICharsetConverterManager2),
(nsISupports**) &sCharSetManager);
NS_ASSERTION(sCharSetManager,"failed to create the charset manager");
}
return sCharSetManager;
NS_IF_RELEASE(sPref);
}
void
nsFT2FontCatalog::GetDirsPrefEnumCallback(const char* aName, void* aClosure)
{
gFT2FontCatalog->doGetDirsPrefEnumCallback(aName, aClosure);
}
void
nsFT2FontCatalog::doGetDirsPrefEnumCallback(const char* aName, void* aClosure)
{
nsDirCatalog *dirCatalog = (nsDirCatalog *)aClosure;
nsDirCatalogEntry *dce;
@ -659,7 +589,7 @@ nsFT2FontCatalog::doGetDirsPrefEnumCallback(const char* aName, void* aClosure)
if (!dce)
return;
// native charset?!
mPref->CopyCharPref(aName, (char **)&dce->mDirName);
sPref->CopyCharPref(aName, (char **)&dce->mDirName);
if (!dce->mDirName)
return;
AddDir(dirCatalog, dce);
@ -774,52 +704,105 @@ cleanup_and_return:
}
void
nsFT2FontCatalog::GetFontNames(const char* aPattern, nsFontCatalog* aFC)
{
gFT2FontCatalog->doGetFontNames(aPattern, aFC);
}
void
nsFT2FontCatalog::doGetFontNames(const char* aPattern, nsFontCatalog* aFC)
nsFT2FontCatalog::GetFontNames(const nsACString & aFamilyName,
const nsACString & aLanguage,
PRUint16 aWeight,
PRUint16 aWidth,
PRUint16 aSlant,
PRUint16 aSpacing,
nsFontCatalog* aFC)
{
int i;
PRBool rslt;
char *pattern, *foundry, *family, *charset, *encoding;
nsCAutoString familyName, language;
FONT_CATALOG_PRINTF(("looking for FreeType font matching"));
FONT_CATALOG_PRINTF(("looking for FreeType font matching %s", aPattern));
nsCAutoString patt(aPattern);
ToLowerCase(patt);
pattern = strdup(patt.get());
NS_ASSERTION(pattern, "failed to copy pattern");
if (!pattern)
goto cleanup_and_return;
ToLowerCase(aFamilyName, familyName);
ToLowerCase(aLanguage, language);
FONT_CATALOG_PRINTF(("familyName=%s; language=%s; "
"weight=%d; width=%d; slant=%d; spacing=%d",
familyName.get(), language.get(),
aWeight, aWidth, aSlant, aSpacing));
rslt = ParseXLFD(pattern, &foundry, &family, &charset, &encoding);
if (!rslt)
goto cleanup_and_return;
unsigned long bit1 = GetRangeLanguage(language, CPR1);
unsigned long bit2 = GetRangeLanguage(language, CPR2);
// unable to handle "name-charset-*"
if (charset && !encoding) {
goto cleanup_and_return;
PRUint16 italicBit = 0;
switch (aSlant) {
case kFCSlantRoman:
break;
case kFCSlantItalic:
case kFCSlantOblique:
case kFCSlantReverseItalic:
case kFCSlantReverseOblique:
italicBit = 1;
break;
default:
break;
}
PRUint16 monoBit = 0;
switch (aSpacing) {
case kFCSpacingMonospace:
monoBit = 0;
break;
case kFCSpacingProportional:
monoBit = 1;
break;
default:
break;
}
/* column headers for the debug output*/
FONT_CATALOG_PRINTF(("%s\t%-20s\t%-8s\t%-8s\t%-8s%-8s%-8s\t%-8s\t%-8s",
"mFlags",
"mFamilyName",
"CodePageRange1",
"mCodePageRange2",
"mWeight",
"mWidth",
"mStyleFlags",
"fce->mFaceFlags",
"Ismatched"));
for (i=0; i<mFontCatalog->numFonts; i++) {
nsFontCatalogEntry *fce = mFontCatalog->fonts[i];
if (!(fce->mFlags&FCE_FLAGS_ISVALID))
FONT_CATALOG_PRINTF(("%0x\t%-20s\t%08lx\t%08lx\t%i\t%i\t%08lx\t%08lx\t",
fce->mFlags,
fce->mFamilyName,
fce->mCodePageRange1,
fce->mCodePageRange2,
fce->mWeight,
fce->mWidth,
fce->mStyleFlags,
fce->mFaceFlags));
// not all "fce" are valid
if (!fce->mFlags&FCE_FLAGS_ISVALID)
continue;
if (foundry && !STRMATCH(foundry,fce->mFoundryName))
// family
if (!familyName.IsEmpty() && !familyName.Equals(fce->mFamilyName))
continue;
if (family && !STRMATCH(family,fce->mFamilyName))
// language
if (!language.IsEmpty() &&
!((fce->mCodePageRange1 & bit1) || (fce->mCodePageRange2 & bit2)))
continue;
// weight
if (aWeight && (aWeight != fce->mWeight))
continue;
// width
if (aWidth && (aWidth != fce->mWidth))
continue;
// slant
if (aSlant && !((fce->mStyleFlags & FT_STYLE_FLAG_ITALIC) == italicBit))
continue;
// spacing
if (aSpacing && !((fce->mFaceFlags & FT_FACE_FLAG_FIXED_WIDTH) == monoBit))
continue;
// match all patterns
FONT_CATALOG_PRINTF(("%s", "matching"));
AddFont(aFC, fce);
}
FREE_IF(pattern);
return;
cleanup_and_return:
FONT_CATALOG_PRINTF(("nsFT2FontCatalog::GetFontNames failed"));
FREE_IF(pattern);
FONT_CATALOG_PRINTF(("\n"));
return;
}
@ -950,7 +933,7 @@ nsFT2FontCatalog::GetFoundry(nsFontCatalogEntry *aFce)
ToLowerCase(foundry);
foundry.StripChars(" ");
nsCStringKey key(foundry);
const char *vendorName = (const char *)mVendorNames->Get(&key);
const char *vendorName = (const char *)sVendorNames->Get(&key);
if (!vendorName) {
if (aFce->mVendorID[0])
vendorName = aFce->mVendorID;
@ -966,25 +949,6 @@ nsFT2FontCatalog::GetNumEmbeddedBitmaps(nsFontCatalogEntry *aFce)
return aFce->mNumEmbeddedBitmaps;
}
const char *
nsFT2FontCatalog::GetRange1CharSetName(unsigned long aBit)
{
char buf[32];
sprintf(buf, "0x%08lx", aBit);
nsCStringKey key(buf);
const char *charsetName = (const char *)mRange1CharSetNames->Get(&key);
return charsetName;
}
const char *
nsFT2FontCatalog::GetRange2CharSetName(unsigned long aBit)
{
char buf[32];
sprintf(buf, "0x%08lx", aBit);
nsCStringKey key(buf);
const char *charsetName = (const char *)mRange2CharSetNames->Get(&key);
return charsetName;
}
PRBool
nsFT2FontCatalog::HandleFontDir(FT_Library aFreeTypeLibrary,
@ -1205,15 +1169,6 @@ nsFT2FontCatalog::HandleFontFile(FT_Library aFreeTypeLibrary,
PRBool
nsFT2FontCatalog::InitGlobals(FT_Library lib)
{
gFT2FontCatalog = new nsFT2FontCatalog;
if (!gFT2FontCatalog)
return PR_FALSE;
return gFT2FontCatalog->doInitGlobals(lib);
}
PRBool
nsFT2FontCatalog::doInitGlobals(FT_Library lib)
{
nsDirCatalog *dirCatalog = nsnull;
nsCAutoString prefix("font.directory.truetype.");
@ -1223,68 +1178,55 @@ nsFT2FontCatalog::doInitGlobals(FT_Library lib)
int i;
#endif
nsFontVendorName *vn = sVendorNamesList;
nsTTFontFamilyEncoderInfo *ff = gFontFamilyEncoderInfo;
nsulCodePageRangeCharSetName *crn = nsnull;
mPref = do_GetService(NS_PREF_CONTRACTID);
if (!mPref)
nsulCodePageRangeLanguage *crl = nsnull;
nsServiceManager::GetService(NS_PREF_CONTRACTID,
NS_GET_IID(nsIPref),
(nsISupports**) &sPref);
if (!sPref)
goto cleanup_and_return;
mFontCatalog = NewFontCatalog();
if (!mFontCatalog)
goto cleanup_and_return;
mVendorNames = new nsHashtable();
if (!mVendorNames)
sVendorNames = new nsHashtable();
if (!sVendorNames)
goto cleanup_and_return;
while (vn->vendorID) {
nsCAutoString name(vn->vendorID);
ToLowerCase(name);
nsCStringKey key(name);
mVendorNames->Put(&key, (void*)vn->vendorName);
sVendorNames->Put(&key, (void*)vn->vendorName);
vn++;
}
mFontFamilies = new nsHashtable();
if (!mFontFamilies)
mRange1Language = new nsHashtable();
if (!mRange1Language)
goto cleanup_and_return;
while (ff->mFamilyName) {
nsCAutoString name(ff->mFamilyName);
ToLowerCase(name);
nsCStringKey key(name);
mFontFamilies->Put(&key, (void*)ff);
ff++;
crl = ulCodePageRange1Language;
while (crl->language) {
nsCStringKey key(crl->language);
mRange1Language->Put(&key, &(crl->bit));
crl++;
}
mRange1CharSetNames = new nsHashtable();
if (!mRange1CharSetNames)
mRange2Language = new nsHashtable();
if (!mRange2Language)
goto cleanup_and_return;
crn = ulCodePageRange1CharSetNames;
while (crn->charsetName) {
char buf[32];
sprintf(buf, "0x%08lx", crn->bit);
nsCStringKey key(buf);
mRange1CharSetNames->Put(&key, (void*)crn->charsetName);
crn++;
}
mRange2CharSetNames = new nsHashtable();
if (!mRange2CharSetNames)
goto cleanup_and_return;
crn = ulCodePageRange2CharSetNames;
while (crn->charsetName) {
char buf[32];
sprintf(buf, "0x%08lx", crn->bit);
nsCStringKey key(buf);
mRange2CharSetNames->Put(&key, (void*)crn->charsetName);
crn++;
crl = ulCodePageRange2Language;
while (crl->language) {
nsCStringKey key(crl->language);
mRange2Language->Put(&key, &(crl->bit));
crl++;
}
// get dirs list from prefs
dirCatalog = NewDirCatalog();
if (!dirCatalog)
goto cleanup_and_return;
mPref->EnumerateChildren(prefix.get(), GetDirsPrefEnumCallback,
sPref->EnumerateChildren(prefix.get(), GetDirsPrefEnumCallback,
dirCatalog);
NS_TIMELINE_START_TIMER("nsFT2FontCatalog::GetFontCatalog");
@ -1412,7 +1354,7 @@ nsFT2FontCatalog::NewFceFromFontFile(FT_Library aFreeTypeLibrary,
if (!face->family_name)
goto cleanup_and_return;
nsTTFontFamilyEncoderInfo *ffei;
ffei = nsFT2FontCatalog::GetCustomEncoderInfo(face->family_name);
ffei = nsFreeType::GetCustomEncoderInfo(face->family_name);
if (ffei) {
fce->mFlags = FCE_FLAGS_ISVALID | FCE_FLAGS_SYMBOL;
}
@ -1994,105 +1936,6 @@ nsFT2FontCatalog::ParseCCMapLine(nsCompressedCharMap *aCCMapObj, long base,
return PR_TRUE;
}
//
// Parse XLFD
// The input is a typical XLFD string.
//
// the XLFD entries look like this:
// -adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1
// -adobe-courier-medium-r-*-*-12-*-*-*-*-*-*-*
//
// the fields are:
// -foundry-family-weight-slant-width-style-pixelsize-pointsize-
// resolution_x-resolution_y-spacing-avg_width-registry-encoding
//
// see ftp://ftp.x.org/pub/R6.4/xc/doc/hardcopy/XLFD
//
PRBool
nsFT2FontCatalog::ParseXLFD(char *aPattern, char** aFoundry, char** aFamily,
char** aCharset, char** aEncoding)
{
char *p;
int i;
*aFoundry = nsnull;
*aFamily = nsnull;
*aCharset = nsnull;
*aEncoding = nsnull;
// start of pattern
p = aPattern;
NS_ASSERTION(*p == '-',"garbled pattern: does not start with a '-'");
if (*p++ != '-')
return PR_FALSE;
// foundry
NS_ASSERTION(*p,"garbled pattern: unexpected end of pattern");
if (!*p)
return PR_FALSE;
if (*p == '*')
*aFoundry = nsnull;
else
*aFoundry = p;
while (*p && (*p!='-'))
p++;
if (!*p)
return PR_TRUE; // short XLFD
NS_ASSERTION(*p == '-',"garbled pattern: cannot find end of foundry");
*p++ = '\0';
// family
if (!*p)
return PR_TRUE; // short XLFD
if (*p == '*')
*aFamily = nsnull;
else
*aFamily = p;
while (*p && (*p!='-'))
p++;
if (!*p)
return PR_TRUE; // short XLFD
NS_ASSERTION(*p == '-',"garbled pattern: cannot find end of family");
*p++ = '\0';
// skip forward to charset
for (i=0; i<10; i++) {
while (*p && (*p!='-'))
p++;
if (!*p)
return PR_TRUE; // short XLFD
*p++ = '\0';
}
// charset
NS_ASSERTION(*p,"garbled pattern: unexpected end of pattern");
if (!*p)
return PR_FALSE;
if (*p == '*')
*aCharset = nsnull;
else
*aCharset = p;
while (*p && (*p!='-'))
p++;
if (!*p)
return PR_TRUE; // short XLFD
NS_ASSERTION(*p == '-',"garbled pattern: cannot find end of charset");
*p++ = '\0';
// encoding
NS_ASSERTION(*p,"garbled pattern: unexpected end of pattern");
if (!*p)
return PR_FALSE;
if (*p == '*')
*aEncoding = nsnull;
else
*aEncoding = p;
while (*p && (*p!='-'))
p++;
if (*p)
return PR_TRUE; // short XLFD
return PR_TRUE;
}
void
nsFT2FontCatalog::PrintCCMap(nsNameValuePairDB *aDB, PRUint16 *aCCMap)
@ -2299,6 +2142,23 @@ cleanup_and_return:
return 0;
}
unsigned long
nsFT2FontCatalog::GetRangeLanguage(const nsACString & aLanguage,
PRInt16 aRange)
{
unsigned long *bit;
if (aLanguage.IsEmpty())
return 0;
nsCStringKey key(aLanguage);
if (aRange == CPR1)
bit = (unsigned long *)(mRange1Language->Get(&key));
if (aRange == CPR2)
bit = (unsigned long *)(mRange2Language->Get(&key));
if (bit)
return *bit;
return 0;
}
nsFontVendorName sVendorNamesList[] = {
{ "2REB", "2Rebels" },
{ "39BC", "Finley's Barcode Fonts" },
@ -2488,46 +2348,42 @@ nsFontVendorName sVendorNamesList[] = {
{ nsnull, nsnull },
};
nsulCodePageRangeCharSetName ulCodePageRange1CharSetNames[] = {
{ 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 },
// TODO: what TT_OS2_CPR1_OEM standard for. use "oem" temporarily.
nsulCodePageRangeLanguage ulCodePageRange1Language[] = {
{ TT_OS2_CPR1_LATIN1 | TT_OS2_CPR1_MAC_ROMAN, "latin1" },
{ TT_OS2_CPR1_LATIN2, "latin2" },
{ TT_OS2_CPR1_CYRILLIC, "cyrillic" },
{ TT_OS2_CPR1_GREEK, "greek" },
{ TT_OS2_CPR1_TURKISH, "turkish" },
{ TT_OS2_CPR1_HEBREW, "hebrew" },
{ TT_OS2_CPR1_ARABIC, "arabic" },
{ TT_OS2_CPR1_BALTIC, "baltic" },
{ TT_OS2_CPR1_VIETNAMESE, "vietnamese" },
{ TT_OS2_CPR1_THAI, "thai" },
{ TT_OS2_CPR1_JAPANESE, "apanese" },
{ TT_OS2_CPR1_CHINESE_SIMP, "simplified chinese" },
{ TT_OS2_CPR1_KO_WANSUNG | TT_OS2_CPR1_KO_JOHAB, "korean" },
{ TT_OS2_CPR1_CHINESE_TRAD, "traditional chinese" },
{ TT_OS2_CPR1_OEM, "oem" },
{ TT_OS2_CPR1_SYMBOL, "symbol" },
{ 0, nsnull },
};
nsulCodePageRangeCharSetName ulCodePageRange2CharSetNames[] = {
{ 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 },
nsulCodePageRangeLanguage ulCodePageRange2Language[] = {
{ TT_OS2_CPR2_GREEK | TT_OS2_CPR2_GREEK_437G, "greek" },
{ TT_OS2_CPR2_RUSSIAN, "russian" },
{ TT_OS2_CPR2_NORDIC, "nordic" },
{ TT_OS2_CPR2_ARABIC | TT_OS2_CPR2_ARABIC_708, "arabic" },
{ TT_OS2_CPR2_CA_FRENCH, "canadian french" },
{ TT_OS2_CPR2_HEBREW, "hebrew" },
{ TT_OS2_CPR2_ICELANDIC, "icelandic" },
{ TT_OS2_CPR2_PORTUGESE, "portugese" },
{ TT_OS2_CPR2_TURKISH, "turkish" },
{ TT_OS2_CPR2_CYRILLIC, "cyrillic" },
{ TT_OS2_CPR2_LATIN2, "latin2" },
{ TT_OS2_CPR2_BALTIC, "baltic" },
{ TT_OS2_CPR2_WE_LATIN1 || TT_OS2_CPR2_US, "latin1" },
{ 0, nsnull },
};
#endif /* #if (!defined(MOZ_ENABLE_FREETYPE2)) */

Просмотреть файл

@ -40,10 +40,14 @@
#ifndef NS_FT2_FONT_CATALOG_H
#define NS_FT2_FONT_CATALOG_H
#include "nspr.h"
#include "nsHashtable.h"
#include "nsIServiceManager.h"
/*
* since this patch won't delete "gfx/src/x11shared/nsFreeType.h",
* using "freetype/nsFreeType.h" will prevent this file from
* including the one under "x11shared". This can be changed to
* "#include nsFreeType.h" safely after deleting
* unused "x11shared/nsFreeType.h".
*/
#include "freetype/nsFreeType.h"
#include "nsCompressedCharMap.h"
#include "nsICharRepresentable.h"
@ -51,7 +55,6 @@
#include "nsIPref.h"
#include "nsNameValuePairDB.h"
#include "nsICharsetConverterManager.h"
#include "nsICharsetConverterManager2.h"
#if (defined(MOZ_ENABLE_FREETYPE2))
//
// To limit the potential for namespace collision we limit the
@ -80,52 +83,12 @@ typedef unsigned short FT_UShort;
#define STRNMATCH(s1,s2,l) (strncmp((s1),(s2),(l))==0)
#define STRCASEMATCH(s1,s2) (strcasecmp((s1),(s2))==0)
#define FREE_IF(x) if(x) free((void*)x)
typedef struct {
const char *mConverterName;
PRUint8 mCmapPlatformID;
PRUint8 mCmapEncoding;
nsIUnicodeEncoder* mConverter;
} nsTTFontEncoderInfo;
typedef struct nsTTFontFamilyEncoderInfo {
const char *mFamilyName;
nsTTFontEncoderInfo *mEncodingInfo;
} nsTTFontFamilyEncoderInfo;
typedef struct {
const char *mDirName; // encoded in the native charset
} nsDirCatalogEntry;
#define FCE_FLAGS_ISVALID 0x01
#define FCE_FLAGS_UNICODE 0x02
#define FCE_FLAGS_SYMBOL 0x04
typedef struct {
const char *mFontFileName;
time_t mMTime;
PRUint32 mFlags;
const char *mFontType;
int mFaceIndex;
int mNumFaces;
const char *mFamilyName;
const char *mStyleName;
FT_UShort mWeight;
FT_UShort mWidth;
int mNumGlyphs;
int mNumUsableGlyphs;
FT_Long mFaceFlags;
FT_Long mStyleFlags;
FT_Long mCodePageRange1;
FT_Long mCodePageRange2;
char mVendorID[5];
const char *mFoundryName;
int mNumEmbeddedBitmaps;
int *mEmbeddedBitmapHeights;
PRUint16 *mCCMap; // compressed char map
} nsFontCatalogEntry;
#define CPR1 1 // designate CodePageRange1 to use for "GetRangeLanguage"
#define CPR2 2 // designate CodePageRange2 to use for "GetRangeLanguage"
typedef struct {
nsFontCatalogEntry **fonts;
@ -146,28 +109,39 @@ typedef struct {
typedef struct {
unsigned long bit;
const char *charsetName;
} nsulCodePageRangeCharSetName;
const char *language;
} nsulCodePageRangeLanguage;
class nsFT2FontCatalog {
friend class nsFT2FontNode;
#endif
class nsFT2FontCatalog : public nsIFontCatalogService {
public:
static void FreeGlobals();
static PRBool InitGlobals(FT_LibraryRec_ *);
static void GetFontNames(const char* aPattern, nsFontCatalog* aFC);
NS_DECL_ISUPPORTS
NS_DECL_NSIFONTCATALOGSERVICE
static PRUint16* GetCCMap(nsFontCatalogEntry *aFce);
static nsTTFontFamilyEncoderInfo* GetCustomEncoderInfo(const char *);
static nsTTFontFamilyEncoderInfo* GetCustomEncoderInfo(nsFontCatalogEntry *);
nsFT2FontCatalog();
virtual ~nsFT2FontCatalog();
#if (defined(MOZ_ENABLE_FREETYPE2))
void FreeGlobals();
PRBool InitGlobals(FT_LibraryRec_ *);
void GetFontNames(const nsACString & aFamilyName,
const nsACString & aLanguage,
PRUint16 aWeight,
PRUint16 aWidth,
PRUint16 aSlant,
PRUint16 aSpacing,
nsFontCatalog* aFC);
static const char* GetFileName(nsFontCatalogEntry *aFce);
static const char* GetFamilyName(nsFontCatalogEntry *aFce);
static PRInt32* GetEmbeddedBitmapHeights(nsFontCatalogEntry *aFce);
static PRInt32 GetFaceIndex(nsFontCatalogEntry *aFce);
static PRInt32 GetNumEmbeddedBitmaps(nsFontCatalogEntry *aFce);
static const char* GetFoundry(nsFontCatalogEntry *aFce);
protected:
void AddDir(nsDirCatalog *dc, nsDirCatalogEntry *dir);
static void AddDir(nsDirCatalog *dc, nsDirCatalogEntry *dir);
PRBool AddFceIfCurrent(const char*, nsHashtable*, PRInt64, nsFontCatalog*);
void AddFont(nsFontCatalog *fc, nsFontCatalogEntry *fce);
int CheckFontSummaryVersion(nsNameValuePairDB *aDB);
@ -178,22 +152,15 @@ protected:
void FixUpFontCatalog(nsFontCatalog *fc);
static PRBool FreeFceHashEntry(nsHashKey* aKey, void* aData, void* aClosure);
void FreeFontCatalog(nsFontCatalog *fc);
void FreeFontCatalogEntry(nsFontCatalogEntry *);
void doFreeGlobals();
static nsICharsetConverterManager2* GetCharSetManager();
static void FreeFontCatalogEntry(nsFontCatalogEntry *);
static void GetDirsPrefEnumCallback(const char* aName, void* aClosure);
void doGetDirsPrefEnumCallback(const char* aName, void* aClosure);
int GetFontCatalog(FT_LibraryRec_*, nsFontCatalog *, nsDirCatalog *);
void doGetFontNames(const char* aPattern, nsFontCatalog* aFC);
PRBool GetFontSummaryName(const nsACString &, const nsACString &,
nsACString &, nsACString &);
const char* GetFoundry(nsFontCatalogEntry *aFce);
const char* GetRange1CharSetName(unsigned long aBit);
const char* GetRange2CharSetName(unsigned long aBit);
unsigned long GetRangeLanguage(const nsACString &, PRInt16 aRange);
PRBool HandleFontDir(FT_LibraryRec_ *, nsFontCatalog *,
const nsACString &, const nsACString &);
void HandleFontFile(FT_LibraryRec_ *, nsFontCatalog *, const char*);
PRBool doInitGlobals(FT_LibraryRec_ *);
PRBool IsSpace(FT_Long);
nsDirCatalog *NewDirCatalog();
nsFontCatalogEntry* NewFceFromFontFile(FT_LibraryRec_*, const char*,int,int*);
@ -201,26 +168,22 @@ protected:
nsFontCatalog *NewFontCatalog();
PRBool ReadFontDirSummary(const nsACString&, nsHashtable*);
PRBool ParseCCMapLine(nsCompressedCharMap*,long,const char*);
PRBool ParseXLFD(char *, char**, char**, char**, char**);
void PrintCCMap(nsNameValuePairDB *aDB, PRUint16 *aCCMap);
void PrintFontSummaries(nsNameValuePairDB *, nsFontCatalog *);
void PrintFontSummaryVersion(nsNameValuePairDB *aDB);
void PrintPageBits(nsNameValuePairDB*,PRUint16*,PRUint32);
int ReadFontSummaries(nsHashtable*, nsNameValuePairDB *);
nsCOMPtr<nsIPref> mPref;
static nsIPref* sPref;
nsFontCatalog *mFontCatalog;
nsHashtable *mFontFamilies;
PRPackedBool mIsNewCatalog;
nsHashtable *mVendorNames;
nsHashtable *mRange1CharSetNames;
nsHashtable *mRange2CharSetNames;
static nsICharsetConverterManager2* sCharSetManager;
};
extern nsFT2FontCatalog* gFT2FontCatalog;
static nsHashtable *sVendorNames;
nsHashtable *mRange1Language;
nsHashtable *mRange2Language;
PRBool mAvailableFontCatalogService;
#endif
};
#endif /* NS_FT2_FONT_CATALOG_H */

Просмотреть файл

@ -39,9 +39,17 @@
* ***** END LICENSE BLOCK ***** */
#include "nsFT2FontNode.h"
#include "nsFreeType.h"
/*
* since this patch won't delete "gfx/src/x11shared/nsFreeType.h",
* using "freetype/nsFreeType.h" will prevent this file from
* including the one under "x11shared". This can be changed to
* "#include nsFreeType.h" safely after deleting
* unused "x11shared/nsFreeType.h".
*/
#include "freetype/nsFreeType.h"
#include "nsFontDebug.h"
#include "nsFontFreeType.h"
#include "nsIServiceManager.h"
#if (!defined(MOZ_ENABLE_FREETYPE2))
@ -61,6 +69,7 @@ void nsFT2FontNode::GetFontNames(const char* aPattern,
nsHashtable* nsFT2FontNode::mFreeTypeNodes = nsnull;
PRBool nsFT2FontNode::sInited = PR_FALSE;
nsIFontCatalogService* nsFT2FontNode::sFcs = nsnull;
void
nsFT2FontNode::FreeGlobals()
@ -70,7 +79,6 @@ nsFT2FontNode::FreeGlobals()
delete mFreeTypeNodes;
mFreeTypeNodes = nsnull;
}
nsFreeTypeFreeGlobals();
sInited = PR_FALSE;
}
@ -82,22 +90,19 @@ nsFT2FontNode::InitGlobals()
sInited = PR_TRUE;
nsresult rv;
rv = nsFreeTypeInitGlobals();
if (NS_FAILED(rv))
return rv;
if (!gFT2FontCatalog)
nsServiceManager::GetService("@mozilla.org/gfx/xfontcatalogservice;1",
NS_GET_IID(nsIFontCatalogService),
(nsISupports**) &sFcs);
if (!sFcs) {
NS_ERROR("Font Catalog Service init failed\n");
return NS_ERROR_FAILURE;
}
mFreeTypeNodes = new nsHashtable();
if (!mFreeTypeNodes)
return NS_ERROR_FAILURE;
if (gFT2FontCatalog->mFontCatalog) {
LoadNodeTable(gFT2FontCatalog->mFontCatalog);
}
//setup the weighting table
LoadNodeTable();
WeightTableInitCorrection(nsFreeTypeFont::sLinearWeightTable,
nsFreeType::gAATTDarkTextMinValue,
nsFreeType::gAATTDarkTextGain);
@ -108,14 +113,13 @@ nsFT2FontNode::InitGlobals()
void
nsFT2FontNode::GetFontNames(const char* aPattern, nsFontNodeArray* aNodes)
{
int i, j;
int j;
PRBool rslt;
char *pattern, *foundry, *family, *charset, *encoding;
const char *charSetName;
nsFontNode *node;
nsFontCatalog * aFC;
if (!gFT2FontCatalog) return;
nsISupportsArray* arrayFC;
nsCAutoString familyTmp, languageTmp;
FONT_CATALOG_PRINTF(("looking for FreeType font matching %s", aPattern));
nsCAutoString patt(aPattern);
@ -125,8 +129,7 @@ nsFT2FontNode::GetFontNames(const char* aPattern, nsFontNodeArray* aNodes)
if (!pattern)
goto cleanup_and_return;
rslt = gFT2FontCatalog->ParseXLFD(pattern, &foundry, &family,
&charset, &encoding);
rslt = ParseXLFD(pattern, &foundry, &family, &charset, &encoding);
if (!rslt)
goto cleanup_and_return;
@ -134,32 +137,47 @@ nsFT2FontNode::GetFontNames(const char* aPattern, nsFontNodeArray* aNodes)
if (charset && !encoding) {
goto cleanup_and_return;
}
aFC = gFT2FontCatalog->NewFontCatalog();
nsFT2FontCatalog::GetFontNames(aPattern, aFC);
for (i=0; i<aFC->numFonts; i++) {
nsFontCatalogEntry *fce = aFC->fonts[i];
if (family)
familyTmp.Assign(family);
sFcs->GetFontCatalogEntries(familyTmp, languageTmp, 0, 0, 0, 0, &arrayFC);
PRUint32 count;
arrayFC->Count(&count);
for (PRUint32 i = 0; i < count; i++) {
nsISupports* item = (nsISupports*)arrayFC->ElementAt(i);
nsCOMPtr<nsITrueTypeFontCatalogEntry> fce = do_QueryInterface(item);
if (!fce)
continue;
nsCAutoString foundryName, familyName;
PRUint32 flags, codePageRange1, codePageRange2;
PRUint16 weight, width;
fce->GetFamilyName(familyName);
fce->GetFlags(&flags);
fce->GetWidth(&width);
fce->GetWeight(&weight);
fce->GetCodePageRange1(&codePageRange1);
fce->GetCodePageRange2(&codePageRange2);
if (!charset) { // get all encoding
FONT_CATALOG_PRINTF(("found FreeType %s-%s-*-*", fce->mFoundryName,
fce->mFamilyName));
FONT_CATALOG_PRINTF(("found FreeType %s-%s-*-*", foundryName.get(),
familyName.get()));
for (j=0; j<32; j++) {
unsigned long bit = 1 << j;
if (bit & fce->mCodePageRange1) {
charSetName = gFT2FontCatalog->GetRange1CharSetName(bit);
if (bit & codePageRange1) {
charSetName = nsFreeType::GetRange1CharSetName(bit);
NS_ASSERTION(charSetName, "failed to get charset name");
if (!charSetName)
continue;
node = LoadNode(fce, charSetName, aNodes);
}
if (bit & fce->mCodePageRange2) {
charSetName = gFT2FontCatalog->GetRange2CharSetName(bit);
if (bit & codePageRange2) {
charSetName = nsFreeType::GetRange2CharSetName(bit);
if (!charSetName)
continue;
LoadNode(fce, charSetName, aNodes);
}
}
if (!foundry && family && fce->mFlags&FCE_FLAGS_SYMBOL) {
if (!(foundryName.get()) && familyName.get() && flags&FCE_FLAGS_SYMBOL) {
// the "registry-encoding" is not used but LoadNode will fail without
// some value for this
LoadNode(fce, "symbol-fontspecific", aNodes);
@ -172,11 +190,11 @@ nsFT2FontNode::GetFontNames(const char* aPattern, nsFontNodeArray* aNodes)
charsetName.Append('-');
charsetName.Append(encoding);
CharSetNameToCodeRangeBits(charsetName.get(), &cpr1_bits, &cpr2_bits);
if (!(cpr1_bits & fce->mCodePageRange1)
&& !(cpr2_bits & fce->mCodePageRange2))
if (!(cpr1_bits & codePageRange1)
&& !(cpr2_bits & codePageRange2))
continue;
FONT_CATALOG_PRINTF(("found FreeType -%s-%s-%s",
fce->mFamilyName,charset,encoding));
familyName.get(),charset,encoding));
LoadNode(fce, charsetName.get(), aNodes);
}
}
@ -191,21 +209,20 @@ cleanup_and_return:
}
nsFontNode*
nsFT2FontNode::LoadNode(nsFontCatalogEntry *aFce, const char *aCharSetName,
nsFT2FontNode::LoadNode(nsITrueTypeFontCatalogEntry *aFce,
const char *aCharSetName,
nsFontNodeArray* aNodes)
{
if (!gFT2FontCatalog)
return nsnull;
nsFontCharSetMap *charSetMap = GetCharSetMap(aCharSetName);
if (!charSetMap->mInfo) {
return nsnull;
}
const char *foundry;
foundry = gFT2FontCatalog->GetFoundry(aFce);
nsCAutoString nodeName(foundry);
nsCAutoString nodeName, familyName;
aFce->GetVendorID(nodeName);
aFce->GetFamilyName(familyName);
nodeName.Append('-');
nodeName.Append(aFce->mFamilyName);
nodeName.Append(familyName);
nodeName.Append('-');
nodeName.Append(aCharSetName);
nsCStringKey key(nodeName);
@ -221,8 +238,14 @@ nsFT2FontNode::LoadNode(nsFontCatalogEntry *aFce, const char *aCharSetName,
node->mCharSetInfo = charSetMap->mInfo;
}
PRInt64 styleFlags;
PRUint16 fceWeight, fceWidth;
aFce->GetStyleFlags(&styleFlags);
aFce->GetWidth(&fceWidth);
aFce->GetWeight(&fceWeight);
int styleIndex;
if (aFce->mStyleFlags & FT_STYLE_FLAG_ITALIC)
if (styleFlags & FT_STYLE_FLAG_ITALIC)
styleIndex = NS_FONT_STYLE_ITALIC;
else
styleIndex = NS_FONT_STYLE_NORMAL;
@ -235,7 +258,7 @@ nsFT2FontNode::LoadNode(nsFontCatalogEntry *aFce, const char *aCharSetName,
node->mStyles[styleIndex] = style;
}
int weightIndex = WEIGHT_INDEX(aFce->mWeight);
int weightIndex = WEIGHT_INDEX(fceWeight);
nsFontWeight* weight = style->mWeights[weightIndex];
if (!weight) {
weight = new nsFontWeight;
@ -245,16 +268,16 @@ nsFT2FontNode::LoadNode(nsFontCatalogEntry *aFce, const char *aCharSetName,
style->mWeights[weightIndex] = weight;
}
nsFontStretch* stretch = weight->mStretches[aFce->mWidth];
nsFontStretch* stretch = weight->mStretches[fceWidth];
if (!stretch) {
stretch = new nsFontStretch;
if (!stretch) {
return nsnull;
}
weight->mStretches[aFce->mWidth] = stretch;
weight->mStretches[fceWidth] = stretch;
}
if (!stretch->mFreeTypeFaceID) {
stretch->mFreeTypeFaceID = nsFreeTypeGetFaceID(aFce);
stretch->mFreeTypeFaceID = aFce;
}
if (aNodes) {
int i, n, found = 0;
@ -272,24 +295,35 @@ nsFT2FontNode::LoadNode(nsFontCatalogEntry *aFce, const char *aCharSetName,
}
PRBool
nsFT2FontNode::LoadNodeTable(nsFontCatalog *aFontCatalog)
nsFT2FontNode::LoadNodeTable()
{
if (!gFT2FontCatalog)
return PR_FALSE;
int i, j;
for (i=0; i<aFontCatalog->numFonts; i++) {
int j;
nsISupportsArray* arrayFC;
nsCAutoString family, language;
sFcs->GetFontCatalogEntries(family, language, 0, 0, 0, 0, &arrayFC);
PRUint32 count;
arrayFC->Count(&count);
for (PRUint32 i = 0; i < count; i++) {
nsISupports* item = (nsISupports*)arrayFC->ElementAt(i);
const char *charsetName;
nsFontCatalogEntry *fce = aFontCatalog->fonts[i];
if ((!fce->mFlags&FCE_FLAGS_ISVALID)
|| (fce->mWeight < 100) || (fce->mWeight > 900) || (fce->mWidth > 8))
nsCOMPtr<nsITrueTypeFontCatalogEntry> fce = do_QueryInterface(item);
if (!fce)
continue;
PRUint32 flags, codePageRange1, codePageRange2;
PRUint16 weight, width;
fce->GetFlags(&flags);
fce->GetWidth(&width);
fce->GetWeight(&weight);
fce->GetCodePageRange1(&codePageRange1);
fce->GetCodePageRange2(&codePageRange2);
if ((!flags&FCE_FLAGS_ISVALID)
|| (weight < 100) || (weight > 900) || (width > 8))
continue;
for (j=0; j<32; j++) {
unsigned long bit = 1 << j;
if (!(bit & fce->mCodePageRange1))
if (!(bit & codePageRange1))
continue;
charsetName = gFT2FontCatalog->GetRange1CharSetName(bit);
charsetName = nsFreeType::GetRange1CharSetName(bit);
NS_ASSERTION(charsetName, "failed to get charset name");
if (!charsetName)
continue;
@ -297,17 +331,116 @@ nsFT2FontNode::LoadNodeTable(nsFontCatalog *aFontCatalog)
}
for (j=0; j<32; j++) {
unsigned long bit = 1 << j;
if (!(bit & fce->mCodePageRange2))
if (!(bit & codePageRange2))
continue;
charsetName = gFT2FontCatalog->GetRange2CharSetName(bit);
charsetName = nsFreeType::GetRange2CharSetName(bit);
if (!charsetName)
continue;
LoadNode(fce, charsetName, nsnull);
}
}
return 0;
}
//
// Parse XLFD
// The input is a typical XLFD string.
//
// the XLFD entries look like this:
// -adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1
// -adobe-courier-medium-r-*-*-12-*-*-*-*-*-*-*
//
// the fields are:
// -foundry-family-weight-slant-width-style-pixelsize-pointsize-
// resolution_x-resolution_y-spacing-avg_width-registry-encoding
//
// see ftp://ftp.x.org/pub/R6.4/xc/doc/hardcopy/XLFD
//
PRBool
nsFT2FontNode::ParseXLFD(char *aPattern, char** aFoundry, char** aFamily,
char** aCharset, char** aEncoding)
{
char *p;
int i;
*aFoundry = nsnull;
*aFamily = nsnull;
*aCharset = nsnull;
*aEncoding = nsnull;
// start of pattern
p = aPattern;
NS_ASSERTION(*p == '-',"garbled pattern: does not start with a '-'");
if (*p++ != '-')
return PR_FALSE;
// foundry
NS_ASSERTION(*p,"garbled pattern: unexpected end of pattern");
if (!*p)
return PR_FALSE;
if (*p == '*')
*aFoundry = nsnull;
else
*aFoundry = p;
while (*p && (*p!='-'))
p++;
if (!*p)
return PR_TRUE; // short XLFD
NS_ASSERTION(*p == '-',"garbled pattern: cannot find end of foundry");
*p++ = '\0';
// family
if (!*p)
return PR_TRUE; // short XLFD
if (*p == '*')
*aFamily = nsnull;
else
*aFamily = p;
while (*p && (*p!='-'))
p++;
if (!*p)
return PR_TRUE; // short XLFD
NS_ASSERTION(*p == '-',"garbled pattern: cannot find end of family");
*p++ = '\0';
// skip forward to charset
for (i=0; i<10; i++) {
while (*p && (*p!='-'))
p++;
if (!*p)
return PR_TRUE; // short XLFD
*p++ = '\0';
}
// charset
NS_ASSERTION(*p,"garbled pattern: unexpected end of pattern");
if (!*p)
return PR_FALSE;
if (*p == '*')
*aCharset = nsnull;
else
*aCharset = p;
while (*p && (*p!='-'))
p++;
if (!*p)
return PR_TRUE; // short XLFD
NS_ASSERTION(*p == '-',"garbled pattern: cannot find end of charset");
*p++ = '\0';
// encoding
NS_ASSERTION(*p,"garbled pattern: unexpected end of pattern");
if (!*p)
return PR_FALSE;
if (*p == '*')
*aEncoding = nsnull;
else
*aEncoding = p;
while (*p && (*p!='-'))
p++;
if (*p)
return PR_TRUE; // short XLFD
return PR_TRUE;
}
#endif

Просмотреть файл

@ -41,7 +41,6 @@
#define NS_FT2_FONT_NODE_H
#include "nsFontMetricsGTK.h"
#include "nsFT2FontCatalog.h"
class nsFT2FontNode {
public:
@ -51,10 +50,14 @@ public:
#if (defined(MOZ_ENABLE_FREETYPE2))
protected:
static nsFontNode* LoadNode(nsFontCatalogEntry*,const char*,nsFontNodeArray*);
static PRBool LoadNodeTable(nsFontCatalog *);
static PRBool ParseXLFD(char *, char**, char**, char**, char**);
static nsFontNode* LoadNode(nsITrueTypeFontCatalogEntry*,
const char*,
nsFontNodeArray*);
static PRBool LoadNodeTable();
static nsHashtable *mFreeTypeNodes;
static PRBool sInited;
static nsIFontCatalogService* sFcs;
#endif //MOZ_ENABLE_FREETYPE2
};

Просмотреть файл

@ -51,7 +51,7 @@
#if (!defined(MOZ_ENABLE_FREETYPE2))
nsFreeTypeFont *
nsFreeTypeFont::NewFont(nsFreeTypeFace *, PRUint16, const char *)
nsFreeTypeFont::NewFont(nsITrueTypeFontCatalogEntry *, PRUint16, const char *)
{
return nsnull;
}
@ -78,7 +78,7 @@ PRUint8 nsFreeTypeFont::sLinearWeightTable[256];
//
class nsFreeTypeXImage : public nsFreeTypeFont {
public:
nsFreeTypeXImage(nsFreeTypeFace *aFaceID, PRUint16 aPixelSize,
nsFreeTypeXImage(nsITrueTypeFontCatalogEntry *aFaceID, PRUint16 aPixelSize,
const char *aName);
gint DrawString(nsRenderingContextGTK* aContext,
nsDrawingSurfaceGTK* aSurface, nscoord aX,
@ -93,8 +93,8 @@ protected:
//
class nsFreeTypeXImageSBC : public nsFreeTypeXImage {
public:
nsFreeTypeXImageSBC(nsFreeTypeFace *aFaceID, PRUint16 aPixelSize,
const char *aName);
nsFreeTypeXImageSBC(nsITrueTypeFontCatalogEntry *aFaceID,
PRUint16 aPixelSize, const char *aName);
#ifdef MOZ_MATHML
virtual nsresult GetBoundingMetrics(const PRUnichar* aString,
PRUint32 aLength,
@ -133,8 +133,8 @@ nsFreeTypeFont::nsFreeTypeFont()
}
nsFreeTypeFont *
nsFreeTypeFont::NewFont(nsFreeTypeFace *aFaceID, PRUint16 aPixelSize,
const char *aName)
nsFreeTypeFont::NewFont(nsITrueTypeFontCatalogEntry *aFaceID,
PRUint16 aPixelSize, const char *aName)
{
// for now we only support ximage (XGetImage/alpha-blend/XPutImage) display
// when we support XRender then we will need to test if it is
@ -142,8 +142,10 @@ nsFreeTypeFont::NewFont(nsFreeTypeFace *aFaceID, PRUint16 aPixelSize,
PRBool ximage = PR_TRUE;
PRBool render = PR_FALSE;
nsFreeTypeFont *ftfont;
nsFontCatalogEntry* fce = aFaceID->GetFce();
nsTTFontFamilyEncoderInfo *ffei = nsFT2FontCatalog::GetCustomEncoderInfo(fce);
nsCAutoString familyName;
aFaceID->GetFamilyName(familyName);
nsTTFontFamilyEncoderInfo *ffei =
nsFreeType::GetCustomEncoderInfo(familyName.get());
if (ximage) {
if (ffei) {
ftfont = new nsFreeTypeXImageSBC(aFaceID, aPixelSize, aName);
@ -174,7 +176,7 @@ nsFreeTypeFont::getFTFace()
return face;
}
nsFreeTypeFont::nsFreeTypeFont(nsFreeTypeFace *aFaceID,
nsFreeTypeFont::nsFreeTypeFont(nsITrueTypeFontCatalogEntry *aFaceID,
PRUint16 aPixelSize, const char *aName)
{
PRBool anti_alias = PR_TRUE;
@ -197,12 +199,14 @@ nsFreeTypeFont::nsFreeTypeFont(nsFreeTypeFace *aFaceID,
if (nsFreeType::gFreeType2Unhinted)
mImageDesc.image_type |= ftc_image_flag_unhinted;
PRUint32 num_embedded_bitmaps;
PRInt32* embedded_bitmapheights;
mFaceID->GetEmbeddedBitmapHeights(&num_embedded_bitmaps,
&embedded_bitmapheights);
// check if we have an embedded bitmap
if (aPixelSize <= nsFreeType::gEmbeddedBitmapMaximumHeight) {
int num_embedded_bitmaps = mFaceID->GetNumEmbeddedBitmaps();
if (num_embedded_bitmaps) {
int *embedded_bitmapheights = mFaceID->GetEmbeddedBitmapHeights();
for (int i=0; i<num_embedded_bitmaps; i++) {
for (PRUint32 i=0; i<num_embedded_bitmaps; i++) {
if (embedded_bitmapheights[i] == aPixelSize) {
embedded_bimap = PR_TRUE;
// unhinted must be set for embedded bitmaps to be used
@ -230,11 +234,14 @@ nsFreeTypeFont::LoadFont()
}
mAlreadyCalledLoadFont = PR_TRUE;
mCCMap = mFaceID->GetCCMap();
PRUint32 size;
mFaceID->GetCCMap(&size, &mCCMap);
#ifdef NS_FONT_DEBUG_LOAD_FONT
nsCAutoString fileName;
mFaceID->GetFileName(fileName);
if (gFontDebug & NS_FONT_DEBUG_LOAD_FONT) {
printf("loaded \"%s\", size=%d, filename=%s\n",
mName, mSize, mFaceID->GetFilename());
mName, mSize, fileName.get());
}
#endif
}
@ -568,8 +575,8 @@ nsFreeTypeXImage::nsFreeTypeXImage()
NS_ERROR("should never call nsFreeTypeXImage::nsFreeTypeXImage");
}
nsFreeTypeXImage::nsFreeTypeXImage(nsFreeTypeFace *aFaceID, PRUint16 aPixelSize,
const char *aName)
nsFreeTypeXImage::nsFreeTypeXImage(nsITrueTypeFontCatalogEntry *aFaceID,
PRUint16 aPixelSize, const char *aName)
: nsFreeTypeFont(aFaceID, aPixelSize, aName)
{
//NS_ERROR("should never call nsFreeTypeXImage::nsFreeTypeXImage");
@ -779,7 +786,7 @@ nsFreeTypeXImageSBC::nsFreeTypeXImageSBC()
NS_ERROR("should never call nsFreeTypeXImageSBC::nsFreeTypeXImageSBC");
}
nsFreeTypeXImageSBC::nsFreeTypeXImageSBC(nsFreeTypeFace *aFaceID,
nsFreeTypeXImageSBC::nsFreeTypeXImageSBC(nsITrueTypeFontCatalogEntry *aFaceID,
PRUint16 aPixelSize,
const char *aName)
: nsFreeTypeXImage(aFaceID, aPixelSize, aName)
@ -796,8 +803,10 @@ nsFreeTypeXImageSBC::GetBoundingMetrics(const PRUnichar* aString,
char buf[512];
PRInt32 bufLen = sizeof(buf);
PRInt32 stringLen = aLength;
nsFontCatalogEntry* fce = mFaceID->GetFce();
nsTTFontFamilyEncoderInfo *ffei = nsFT2FontCatalog::GetCustomEncoderInfo(fce);
nsCAutoString familyName;
mFaceID->GetFamilyName(familyName);
nsTTFontFamilyEncoderInfo *ffei =
nsFreeType::GetCustomEncoderInfo(familyName.get());
NS_ASSERTION(ffei,"failed to find font encoder info");
if (!ffei)
return NS_ERROR_FAILURE;
@ -826,8 +835,10 @@ nsFreeTypeXImageSBC::GetWidth(const PRUnichar* aString, PRUint32 aLength)
char buf[512];
PRInt32 bufLen = sizeof(buf);
PRInt32 stringLen = aLength;
nsFontCatalogEntry* fce = mFaceID->GetFce();
nsTTFontFamilyEncoderInfo *ffei = nsFT2FontCatalog::GetCustomEncoderInfo(fce);
nsCAutoString familyName;
mFaceID->GetFamilyName(familyName);
nsTTFontFamilyEncoderInfo *ffei =
nsFreeType::GetCustomEncoderInfo(familyName.get());
NS_ASSERTION(ffei,"failed to find font encoder info");
if (!ffei)
return NS_ERROR_FAILURE;
@ -859,8 +870,10 @@ nsFreeTypeXImageSBC::DrawString(nsRenderingContextGTK* aContext,
char buf[512];
PRInt32 bufLen = sizeof(buf);
PRInt32 stringLen = aLength;
nsFontCatalogEntry* fce = mFaceID->GetFce();
nsTTFontFamilyEncoderInfo *ffei = nsFT2FontCatalog::GetCustomEncoderInfo(fce);
nsCAutoString familyName;
mFaceID->GetFamilyName(familyName);
nsTTFontFamilyEncoderInfo *ffei =
nsFreeType::GetCustomEncoderInfo(familyName.get());
NS_ASSERTION(ffei,"failed to find font encoder info");
if (!ffei)
return NS_ERROR_FAILURE;

Просмотреть файл

@ -41,13 +41,20 @@
#define nsFontFreeType_h__
#include "nsFontMetricsGTK.h"
#include "nsFreeType.h"
/*
* since this patch won't delete "gfx/src/x11shared/nsFreeType.h",
* using "freetype/nsFreeType.h" will prevent this file from
* including the one under "x11shared". This can be changed to
* "#include nsFreeType.h" safely after deleting
* unused "x11shared/nsFreeType.h".
*/
#include "freetype/nsFreeType.h"
#if (!defined(MOZ_ENABLE_FREETYPE2))
class nsFreeTypeFace;
class nsFreeTypeFont : public nsFontGTK {
public:
static nsFreeTypeFont *NewFont(nsFreeTypeFace *, PRUint16, const char *);
static nsFreeTypeFont *NewFont(nsITrueTypeFontCatalogEntry*,
PRUint16, const char *);
};
#else
@ -57,16 +64,15 @@ public:
#include FT_CACHE_IMAGE_H
#include FT_TRUETYPE_TABLES_H
class nsFreeTypeFace;
class nsFreeTypeFont : public nsFontGTK
{
public:
nsFreeTypeFont();
nsFreeTypeFont(nsFreeTypeFace *, PRUint16, const char *);
nsFreeTypeFont(nsITrueTypeFontCatalogEntry *, PRUint16, const char *);
virtual ~nsFreeTypeFont(void);
static nsFreeTypeFont *NewFont(nsFreeTypeFace *, PRUint16, const char *);
static nsFreeTypeFont *NewFont(nsITrueTypeFontCatalogEntry*,
PRUint16, const char *);
void LoadFont(void);
@ -114,7 +120,7 @@ public:
protected:
XImage *GetXImage(PRUint32 width, PRUint32 height);
nsFreeTypeFace *mFaceID;
nsITrueTypeFontCatalogEntry *mFaceID;
PRUint16 mPixelSize;
FTC_Image_Desc mImageDesc;
};