зеркало из https://github.com/mozilla/pjs.git
rearrange the code of FreeType2 Font Catalog under mozilla/gfx/src/x11shared
bug=166773 r=bstell@ix.netcom.com sr=jst@netscape.com patch by louie.zhao@sun.com Check in rest files of this bug.
This commit is contained in:
Родитель
68fe553866
Коммит
e2ef10fba1
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,228 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ex: set tabstop=8 softtabstop=2 shiftwidth=2 expandtab: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Stell <bstell@netscape.com>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef NS_FT2_FONT_CATALOG_H
|
||||
#define NS_FT2_FONT_CATALOG_H
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsNameValuePairDB.h"
|
||||
#include "nsICharsetConverterManager2.h"
|
||||
|
||||
#if (!defined(MOZ_ENABLE_FREETYPE2))
|
||||
class nsFT2FontCatalog {
|
||||
public:
|
||||
static void GetFontNames(const char* aPattern, nsFontNodeArray* aNodes);
|
||||
};
|
||||
#else
|
||||
|
||||
//
|
||||
// To limit the potential for namespace collision we limit the
|
||||
// number of Moz files that include FreeType's include (and hence
|
||||
// have FreeType typedefs, macros, and defines).
|
||||
//
|
||||
struct FT_LibraryRec_;
|
||||
typedef signed long FT_Long;
|
||||
typedef unsigned short FT_UShort;
|
||||
|
||||
class nsFontNodeArray;
|
||||
|
||||
#define PUBLIC_FONT_SUMMARY_NAME NS_LITERAL_CSTRING(".mozilla_font_summary.ndb")
|
||||
#define FONT_SUMMARIES_SUBDIR NS_LITERAL_CSTRING("catalog")
|
||||
#define FONT_DOWNLOAD_SUBDIR NS_LITERAL_CSTRING("fonts")
|
||||
#define FONT_SUMMARIES_EXTENSION NS_LITERAL_CSTRING(".ndb")
|
||||
#define FONT_SUMMARY_VERSION_TAG "FontSummaryVersion"
|
||||
#define FONT_SUMMARY_VERSION_MAJOR 1
|
||||
#define FONT_SUMMARY_VERSION_MINOR 0
|
||||
#define FONT_SUMMARY_VERSION_REV 0
|
||||
|
||||
|
||||
#define FC_FILE_OKAY 0
|
||||
#define FC_FILE_GARBLED 1
|
||||
#define FC_FILE_MODIFIED 2
|
||||
|
||||
#define STRMATCH(s1,s2) (strcmp((s1),(s2))==0)
|
||||
#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;
|
||||
|
||||
typedef struct {
|
||||
nsFontCatalogEntry **fonts;
|
||||
int numFonts;
|
||||
int numSlots;
|
||||
} nsFontCatalog;
|
||||
|
||||
typedef struct {
|
||||
nsDirCatalogEntry **dirs;
|
||||
int numDirs;
|
||||
int numSlots;
|
||||
} nsDirCatalog;
|
||||
|
||||
typedef struct {
|
||||
const char *vendorID;
|
||||
const char *vendorName;
|
||||
} nsFontVendorName;
|
||||
|
||||
typedef struct {
|
||||
unsigned long bit;
|
||||
const char *charsetName;
|
||||
} nsulCodePageRangeCharSetName;
|
||||
|
||||
class nsFT2FontCatalog {
|
||||
public:
|
||||
static void FreeGlobals();
|
||||
static PRBool InitGlobals(FT_LibraryRec_ *);
|
||||
static void GetFontNames(const char* aPattern,
|
||||
nsFontNodeArray* aNodes);
|
||||
static PRUint16* GetCCMap(nsFontCatalogEntry *aFce);
|
||||
static nsTTFontFamilyEncoderInfo* GetCustomEncoderInfo(const char *);
|
||||
static nsTTFontFamilyEncoderInfo* GetCustomEncoderInfo(nsFontCatalogEntry *);
|
||||
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);
|
||||
|
||||
|
||||
protected:
|
||||
void AddDir(nsDirCatalog *dc, nsDirCatalogEntry *dir);
|
||||
PRBool AddFceIfCurrent(const char*, nsHashtable*, PRInt64, nsFontCatalog*);
|
||||
void AddFont(nsFontCatalog *fc, nsFontCatalogEntry *fce);
|
||||
int CheckFontSummaryVersion(nsNameValuePairDB *aDB);
|
||||
#ifdef DEBUG
|
||||
void DumpFontCatalog(nsFontCatalog *fc);
|
||||
void DumpFontCatalogEntry(nsFontCatalogEntry *);
|
||||
#endif
|
||||
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 GetDirsPrefEnumCallback(const char* aName, void* aClosure);
|
||||
void doGetDirsPrefEnumCallback(const char* aName, void* aClosure);
|
||||
int GetFontCatalog(FT_LibraryRec_*, nsFontCatalog *, nsDirCatalog *);
|
||||
void doGetFontNames(const char* aPattern, nsFontNodeArray* aNodes);
|
||||
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);
|
||||
PRBool HandleFontDir(FT_LibraryRec_ *, nsFontCatalog *,
|
||||
const nsACString &, const nsACString &);
|
||||
void HandleFontFile(FT_LibraryRec_ *, nsFontCatalog *, const char*);
|
||||
PRBool doInitGlobals(FT_LibraryRec_ *);
|
||||
PRBool IsSpace(FT_Long);
|
||||
nsFontNode* LoadNode(nsFontCatalogEntry*, const char*,nsFontNodeArray*);
|
||||
PRBool LoadNodeTable(nsFontCatalog *);
|
||||
nsDirCatalog *NewDirCatalog();
|
||||
nsFontCatalogEntry* NewFceFromFontFile(FT_LibraryRec_*, const char*,int,int*);
|
||||
nsFontCatalogEntry* NewFceFromSummary(nsNameValuePairDB *aDB);
|
||||
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;
|
||||
nsFontCatalog *mFontCatalog;
|
||||
nsHashtable *mFreeTypeNodes;
|
||||
nsHashtable *mFontFamilies;
|
||||
PRPackedBool mIsNewCatalog;
|
||||
nsHashtable *mVendorNames;
|
||||
nsHashtable *mRange1CharSetNames;
|
||||
nsHashtable *mRange2CharSetNames;
|
||||
static nsICharsetConverterManager2* sCharSetManager;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* NS_FT2_FONT_CATALOG_H */
|
||||
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -27,14 +27,7 @@
|
|||
void nsFreeTypeFreeGlobals(void);
|
||||
nsresult nsFreeTypeInitGlobals(void);
|
||||
|
||||
#if (!defined(MOZ_ENABLE_FREETYPE2))
|
||||
// nsFreeType stubs for development systems without a FreeType dev env
|
||||
class nsFreeTypeFace;
|
||||
class nsFreeTypeFont : public nsFontGTK {
|
||||
public:
|
||||
static nsFreeTypeFont *NewFont(nsFreeTypeFace *, PRUint16, const char *);
|
||||
};
|
||||
#else
|
||||
#if (defined(MOZ_ENABLE_FREETYPE2))
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
@ -44,13 +37,10 @@ public:
|
|||
#include "nsFT2FontCatalog.h"
|
||||
|
||||
typedef struct FT_FaceRec_* FT_Face;
|
||||
typedef void (*blitGlyph) (XImage *, FT_BitmapGlyph, nscolor, int, int);
|
||||
typedef void (*blendPixel)(XImage *, int, int, nscolor, int);
|
||||
|
||||
class nsFreeTypeFace;
|
||||
|
||||
nsFreeTypeFace * nsFreeTypeGetFaceID(nsFontCatalogEntry *aFce);
|
||||
void nsFreeTypeGetFontNames(const char* aPattern, nsFontNodeArray* aNodes);
|
||||
|
||||
//
|
||||
// the FreeType2 function type declarations
|
||||
|
@ -75,10 +65,15 @@ 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 nsFreeTypeFont : public nsFontGTK
|
||||
{
|
||||
// class nsFreeType class definition
|
||||
class nsFreeType {
|
||||
public:
|
||||
inline PRBool FreeTypeAvailable() { return sAvailable; };
|
||||
inline static FTC_Manager GetFTCacheManager() { return sFTCacheManager; };
|
||||
inline static FT_Library GetLibrary() { return sFreeTypeLibrary; };
|
||||
inline static FTC_Image_Cache GetImageCache() { return sImageCache; };
|
||||
static void FreeGlobals();
|
||||
static nsresult InitGlobals();
|
||||
|
||||
// run time loaded (function pointers)
|
||||
static FT_Done_Face_t nsFT_Done_Face;
|
||||
|
@ -97,59 +92,52 @@ public:
|
|||
static FTC_Manager_Done_t nsFTC_Manager_Done;
|
||||
static FTC_Manager_New_t nsFTC_Manager_New;
|
||||
static FTC_Image_Cache_New_t nsFTC_Image_Cache_New;
|
||||
|
||||
nsFreeTypeFont();
|
||||
nsFreeTypeFont(nsFreeTypeFace *, PRUint16, const char *);
|
||||
virtual ~nsFreeTypeFont(void);
|
||||
static nsFreeTypeFont *NewFont(nsFreeTypeFace *, PRUint16, const char *);
|
||||
|
||||
void LoadFont(void);
|
||||
|
||||
virtual GdkFont* GetGDKFont(void);
|
||||
virtual PRBool GetGDKFontIs10646(void);
|
||||
virtual PRBool IsFreeTypeFont(void);
|
||||
|
||||
virtual gint GetWidth(const PRUnichar* aString, PRUint32 aLength);
|
||||
virtual gint DrawString(nsRenderingContextGTK* aContext,
|
||||
nsDrawingSurfaceGTK* aSurface, nscoord aX,
|
||||
nscoord aY, const PRUnichar* aString,
|
||||
PRUint32 aLength);
|
||||
#ifdef MOZ_MATHML
|
||||
virtual nsresult GetBoundingMetrics(const PRUnichar* aString,
|
||||
PRUint32 aLength,
|
||||
nsBoundingMetrics& aBoundingMetrics);
|
||||
#endif
|
||||
virtual nsresult doGetBoundingMetrics(const PRUnichar* aString,
|
||||
PRUint32 aLength,
|
||||
PRInt32* aLeftBearing,
|
||||
PRInt32* aRightBearing,
|
||||
PRInt32* aAscent,
|
||||
PRInt32* aDescent,
|
||||
PRInt32* aWidth);
|
||||
|
||||
virtual PRUint32 Convert(const PRUnichar* aSrc, PRUint32 aSrcLen,
|
||||
PRUnichar* aDest, PRUint32 aDestLen);
|
||||
|
||||
FT_Face getFTFace();
|
||||
int ascent();
|
||||
int descent();
|
||||
PRBool getXHeight(unsigned long &val);
|
||||
int max_ascent();
|
||||
int max_descent();
|
||||
int max_width();
|
||||
PRBool superscript_y(long &val);
|
||||
PRBool subscript_y(long &val);
|
||||
PRBool underlinePosition(long &val);
|
||||
PRBool underline_thickness(unsigned long &val);
|
||||
|
||||
FT_Error FaceRequester(FT_Face* aface);
|
||||
static void FreeGlobals();
|
||||
|
||||
static PRBool gEnableFreeType2;
|
||||
static char* gFreeType2SharedLibraryName;
|
||||
static PRBool gFreeType2Autohinted;
|
||||
static PRBool gFreeType2Unhinted;
|
||||
static PRUint8 gAATTDarkTextMinValue;
|
||||
static double gAATTDarkTextGain;
|
||||
static PRInt32 gAntiAliasMinimum;
|
||||
static PRInt32 gEmbeddedBitmapMaximumHeight;
|
||||
|
||||
protected:
|
||||
XImage *GetXImage(PRUint32 width, PRUint32 height);
|
||||
nsFreeTypeFace *mFaceID;
|
||||
PRUint16 mPixelSize;
|
||||
FTC_Image_Desc mImageDesc;
|
||||
static void ClearGlobals();
|
||||
static void ClearFunctions();
|
||||
static PRBool InitLibrary();
|
||||
static PRBool LoadSharedLib();
|
||||
static void UnloadSharedLib();
|
||||
|
||||
static PRLibrary *sSharedLib;
|
||||
static PRBool sInited;
|
||||
static PRBool sAvailable;
|
||||
static FT_Error sInitError;
|
||||
static FT_Library sFreeTypeLibrary;
|
||||
static FTC_Manager sFTCacheManager;
|
||||
static FTC_Image_Cache sImageCache;
|
||||
};
|
||||
|
||||
// class nsFreeTypeFace definition
|
||||
/* this simple record is used to model a given `installed' face */
|
||||
class nsFreeTypeFace {
|
||||
public:
|
||||
nsFreeTypeFace(nsFontCatalogEntry *aFce);
|
||||
~nsFreeTypeFace();
|
||||
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); } ;
|
||||
PRUint16 *GetCCMap();
|
||||
nsFontCatalogEntry* GetFce() { return mFce; };
|
||||
|
||||
protected:
|
||||
nsFontCatalogEntry *mFce;
|
||||
PRUint16 *mCCMap;
|
||||
|
||||
};
|
||||
|
||||
#endif /* MOZ_ENABLE_FREETYPE2 */
|
||||
|
|
|
@ -59,11 +59,13 @@ CSRCS = nsPrintdGTK.c
|
|||
# Code shared between GTK+, Xlib and Xprint gfx modules
|
||||
X11SHARED_LCPPSRCS = \
|
||||
nsAntiAliasedGlyph.cpp \
|
||||
nsFontFreeType.cpp \
|
||||
nsFreeType.cpp \
|
||||
nsFT2FontNode.cpp \
|
||||
nsFT2FontCatalog.cpp \
|
||||
nsX11AlphaBlend.cpp \
|
||||
nsXFontAAScaledBitmap.cpp \
|
||||
nsXFontNormal.cpp \
|
||||
nsX11AlphaBlend.cpp \
|
||||
nsXFontAAScaledBitmap.cpp \
|
||||
nsXFontNormal.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
|
|
|
@ -59,8 +59,9 @@
|
|||
#include "nsReadableUtils.h"
|
||||
#include "nsAString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsFT2FontCatalog.h"
|
||||
#include "nsFreeType.h"
|
||||
#include "nsFontDebug.h"
|
||||
#include "nsFT2FontNode.h"
|
||||
#include "nsFontFreeType.h"
|
||||
#include "nsXFontNormal.h"
|
||||
#include "nsX11AlphaBlend.h"
|
||||
#include "nsXFontAAScaledBitmap.h"
|
||||
|
@ -97,10 +98,6 @@ static PRLogModuleInfo * FontMetricsGTKLM = PR_NewLogModule("FontMetricsGTK");
|
|||
#undef NOISY_FONTS
|
||||
#undef REALLY_NOISY_FONTS
|
||||
|
||||
// the font catalog is so expensive to generate
|
||||
// always tell the user what is happening
|
||||
PRUint32 gFontDebug = 0 | NS_FONT_DEBUG_FONT_SCAN;
|
||||
|
||||
struct nsFontCharSetMap;
|
||||
struct nsFontFamilyName;
|
||||
struct nsFontPropertyName;
|
||||
|
@ -201,16 +198,6 @@ static PRInt32 gBitmapScaleMinimum = 10;
|
|||
static double gBitmapOversize = 1.2;
|
||||
static double gBitmapUndersize = 0.8;
|
||||
|
||||
PRInt32 gAntiAliasMinimum = 8;
|
||||
PRInt32 gEmbeddedBitmapMaximumHeight = 1000000;
|
||||
|
||||
PRBool gEnableFreeType2 = PR_TRUE;
|
||||
PRBool gFreeType2Autohinted = PR_FALSE;
|
||||
PRBool gFreeType2Unhinted = PR_TRUE;
|
||||
char* gFreeType2SharedLibraryName = nsnull;
|
||||
PRUint8 gAATTDarkTextMinValue = 64;
|
||||
double gAATTDarkTextGain = 0.8;
|
||||
|
||||
#ifdef ENABLE_X_FONT_BANNING
|
||||
static regex_t *gFontRejectRegEx = nsnull,
|
||||
*gFontAcceptRegEx = nsnull;
|
||||
|
@ -740,11 +727,7 @@ FreeGlobals(void)
|
|||
|
||||
gInitialized = 0;
|
||||
|
||||
nsFreeTypeFreeGlobals();
|
||||
if (gFreeType2SharedLibraryName) {
|
||||
free(gFreeType2SharedLibraryName);
|
||||
gFreeType2SharedLibraryName = nsnull;
|
||||
}
|
||||
nsFT2FontNode::FreeGlobals();
|
||||
|
||||
#ifdef ENABLE_X_FONT_BANNING
|
||||
if (gFontRejectRegEx) {
|
||||
|
@ -964,64 +947,7 @@ InitGlobals(nsIDeviceContext *aDevice)
|
|||
if (NS_SUCCEEDED(rv)) {
|
||||
gForceOutlineScaledFonts = force_outline_scaled_fonts;
|
||||
}
|
||||
|
||||
PRBool enable_freetype2 = PR_TRUE;
|
||||
rv = gPref->GetBoolPref("font.FreeType2.enable", &enable_freetype2);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
gEnableFreeType2 = enable_freetype2;
|
||||
FREETYPE_FONT_PRINTF(("gEnableFreeType2 = %d", gEnableFreeType2));
|
||||
}
|
||||
|
||||
rv = gPref->GetCharPref("font.freetype2.shared-library",
|
||||
&gFreeType2SharedLibraryName);
|
||||
if (NS_FAILED(rv)) {
|
||||
enable_freetype2 = PR_FALSE;
|
||||
FREETYPE_FONT_PRINTF((
|
||||
"gFreeType2SharedLibraryName missing, FreeType2 disabled"));
|
||||
gFreeType2SharedLibraryName = nsnull;
|
||||
}
|
||||
|
||||
PRBool freetype2_autohinted = PR_FALSE;
|
||||
rv = gPref->GetBoolPref("font.FreeType2.autohinted", &freetype2_autohinted);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
gFreeType2Autohinted = freetype2_autohinted;
|
||||
FREETYPE_FONT_PRINTF(("gFreeType2Autohinted = %d", gFreeType2Autohinted));
|
||||
}
|
||||
|
||||
PRBool freetype2_unhinted = PR_TRUE;
|
||||
rv = gPref->GetBoolPref("font.FreeType2.unhinted", &freetype2_unhinted);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
gFreeType2Unhinted = freetype2_unhinted;
|
||||
FREETYPE_FONT_PRINTF(("gFreeType2Unhinted = %d", gFreeType2Unhinted));
|
||||
}
|
||||
|
||||
PRInt32 antialias_minimum = 8;
|
||||
rv = gPref->GetIntPref("font.antialias.min", &antialias_minimum);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
gAntiAliasMinimum = antialias_minimum;
|
||||
FREETYPE_FONT_PRINTF(("gAntiAliasMinimum = %d", gAntiAliasMinimum));
|
||||
}
|
||||
|
||||
PRInt32 embedded_bitmaps_maximum = 1000000;
|
||||
rv = gPref->GetIntPref("font.embedded_bitmaps.max",&embedded_bitmaps_maximum);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
gEmbeddedBitmapMaximumHeight = embedded_bitmaps_maximum;
|
||||
FREETYPE_FONT_PRINTF(("gEmbeddedBitmapMaximumHeight = %d",
|
||||
gEmbeddedBitmapMaximumHeight));
|
||||
}
|
||||
int_val = 0;
|
||||
rv = gPref->GetIntPref("font.scale.tt_bitmap.dark_text.min", &int_val);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
gAATTDarkTextMinValue = int_val;
|
||||
SIZE_FONT_PRINTF(("gAATTDarkTextMinValue = %d", gAATTDarkTextMinValue));
|
||||
}
|
||||
rv = gPref->GetCharPref("font.scale.tt_bitmap.dark_text.gain",
|
||||
getter_Copies(str));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
gAATTDarkTextGain = atof(str.get());
|
||||
SIZE_FONT_PRINTF(("gAATTDarkTextGain = %g", gAATTDarkTextGain));
|
||||
}
|
||||
|
||||
|
||||
PRBool scale_bitmap_fonts_with_devscale = gScaleBitmapFontsWithDevScale;
|
||||
|
||||
rv = gPref->GetBoolPref("font.x11.scale_bitmap_fonts_with_devscale", &scale_bitmap_fonts_with_devscale);
|
||||
|
@ -1185,7 +1111,7 @@ InitGlobals(nsIDeviceContext *aDevice)
|
|||
}
|
||||
#endif /* ENABLE_X_FONT_BANNING */
|
||||
|
||||
rv = nsFreeTypeInitGlobals();
|
||||
rv = nsFT2FontNode::InitGlobals();
|
||||
if (NS_FAILED(rv)) {
|
||||
FreeGlobals();
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -3881,7 +3807,7 @@ GetFontNames(const char* aPattern, PRBool aAnyFoundry, PRBool aOnlyOutlineScaled
|
|||
#endif
|
||||
|
||||
// get FreeType fonts
|
||||
nsFT2FontCatalog::GetFontNames(aPattern, aNodes);
|
||||
nsFT2FontNode::GetFontNames(aPattern, aNodes);
|
||||
|
||||
nsCAutoString previousNodeName;
|
||||
nsHashtable* node_hash;
|
||||
|
|
|
@ -59,64 +59,6 @@
|
|||
#define FONT_HAS_GLYPH(map, char) IS_REPRESENTABLE(map, char)
|
||||
#define WEIGHT_INDEX(weight) (((weight) / 100) - 1)
|
||||
|
||||
#define NS_FONT_DEBUG_LOAD_FONT 0x01
|
||||
#define NS_FONT_DEBUG_CALL_TRACE 0x02
|
||||
#define NS_FONT_DEBUG_FIND_FONT 0x04
|
||||
#define NS_FONT_DEBUG_SIZE_FONT 0x08
|
||||
#define NS_FONT_DEBUG_SCALED_FONT 0x10
|
||||
#define NS_FONT_DEBUG_BANNED_FONT 0x20
|
||||
#define NS_FONT_DEBUG_FONT_CATALOG 0x100
|
||||
#define NS_FONT_DEBUG_FONT_SCAN 0x200
|
||||
#define NS_FONT_DEBUG_FREETYPE_FONT 0x400
|
||||
#define NS_FONT_DEBUG_FREETYPE_GRAPHICS 0x800
|
||||
|
||||
#undef NS_FONT_DEBUG
|
||||
#define NS_FONT_DEBUG 1
|
||||
#ifdef NS_FONT_DEBUG
|
||||
extern PRUint32 gFontDebug;
|
||||
|
||||
# define DEBUG_PRINTF(x) \
|
||||
DEBUG_PRINTF_MACRO(x, 0xFFFF)
|
||||
|
||||
# define DEBUG_PRINTF_MACRO(x, type) \
|
||||
PR_BEGIN_MACRO \
|
||||
if (gFontDebug & (type)) { \
|
||||
printf x ; \
|
||||
printf(", %s %d\n", __FILE__, __LINE__); \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
#else
|
||||
# define DEBUG_PRINTF_MACRO(x, type) \
|
||||
PR_BEGIN_MACRO \
|
||||
PR_END_MACRO
|
||||
#endif
|
||||
|
||||
#define FIND_FONT_PRINTF(x) \
|
||||
DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_FIND_FONT)
|
||||
|
||||
#define SIZE_FONT_PRINTF(x) \
|
||||
DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_SIZE_FONT)
|
||||
|
||||
#define SCALED_FONT_PRINTF(x) \
|
||||
DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_SCALED_FONT)
|
||||
|
||||
#define BANNED_FONT_PRINTF(x) \
|
||||
DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_BANNED_FONT)
|
||||
|
||||
#define FONT_CATALOG_PRINTF(x) \
|
||||
DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_FONT_CATALOG)
|
||||
|
||||
#define FONT_SCAN_PRINTF(x) \
|
||||
PR_BEGIN_MACRO \
|
||||
if (gFontDebug & NS_FONT_DEBUG_FONT_SCAN) { \
|
||||
printf x ; \
|
||||
fflush(stdout); \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
#define FREETYPE_FONT_PRINTF(x) \
|
||||
DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_FREETYPE_FONT)
|
||||
|
||||
typedef struct nsFontCharSetInfo nsFontCharSetInfo;
|
||||
|
||||
typedef gint (*nsFontCharSetConverter)(nsFontCharSetInfo* aSelf,
|
||||
|
|
|
@ -38,8 +38,6 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nsHashtable.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -47,10 +45,6 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <dirent.h>
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsFontMetricsGTK.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsNameValuePairDB.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsLocalFileUnix.h"
|
||||
|
@ -58,13 +52,7 @@
|
|||
#include "nsITimelineService.h"
|
||||
#include "nsFT2FontCatalog.h"
|
||||
|
||||
#if (!defined(MOZ_ENABLE_FREETYPE2))
|
||||
|
||||
// nsFreeType stubs for development systems without a FreeType dev env
|
||||
void nsFT2FontCatalog::GetFontNames(const char* aPat, nsFontNodeArray* aNodes) {};
|
||||
|
||||
#else
|
||||
|
||||
#if (defined(MOZ_ENABLE_FREETYPE2))
|
||||
//
|
||||
// Short overview:
|
||||
// This code is here primarily to solve this problem: getting the list
|
||||
|
@ -100,7 +88,7 @@ void nsFT2FontCatalog::GetFontNames(const char* aPat, nsFontNodeArray* aNodes) {
|
|||
//
|
||||
|
||||
// Solaris is missing a prototype for ctime
|
||||
extern char *ctime(const time_t *timep);
|
||||
extern "C" {char *ctime(const time_t *timep);}
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_GLYPH_H
|
||||
|
@ -108,16 +96,14 @@ extern char *ctime(const time_t *timep);
|
|||
#include FT_TRUETYPE_TABLES_H
|
||||
#include FT_TRUETYPE_IDS_H
|
||||
#include "nsFreeType.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
|
||||
extern PRUint32 gFontDebug;
|
||||
#include "nsFontDebug.h"
|
||||
|
||||
// these should be static but the compilier complains
|
||||
extern nsFontVendorName sVendorNamesList[];
|
||||
extern nsulCodePageRangeCharSetName ulCodePageRange1CharSetNames[];
|
||||
extern nsulCodePageRangeCharSetName ulCodePageRange2CharSetNames[];
|
||||
|
||||
static nsFT2FontCatalog* gFT2FontCatalog = nsnull;
|
||||
nsFT2FontCatalog* gFT2FontCatalog = nsnull;
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kCharSetManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
nsICharsetConverterManager2* nsFT2FontCatalog::sCharSetManager = nsnull;
|
||||
|
@ -240,7 +226,7 @@ void
|
|||
nsFT2FontCatalog::AddDir(nsDirCatalog *dc, nsDirCatalogEntry *dir)
|
||||
{
|
||||
if (dc->numDirs >= dc->numSlots) {
|
||||
dc->numSlots += MAX(1, MIN(dc->numDirs, 128));
|
||||
dc->numSlots += PR_MAX(1, PR_MIN(dc->numDirs, 128));
|
||||
dc->dirs = (nsDirCatalogEntry **)realloc(dc->dirs,
|
||||
dc->numSlots*sizeof(nsDirCatalogEntry *));
|
||||
}
|
||||
|
@ -309,7 +295,7 @@ void
|
|||
nsFT2FontCatalog::AddFont(nsFontCatalog *fc, nsFontCatalogEntry *fce)
|
||||
{
|
||||
if (fc->numFonts >= fc->numSlots) {
|
||||
fc->numSlots += MAX(1, MIN(fc->numFonts, 128));
|
||||
fc->numSlots += PR_MAX(1, PR_MIN(fc->numFonts, 128));
|
||||
fc->fonts = (nsFontCatalogEntry **)realloc(fc->fonts,
|
||||
fc->numSlots*sizeof(nsFontCatalogEntry *));
|
||||
}
|
||||
|
@ -623,11 +609,6 @@ nsFT2FontCatalog::doFreeGlobals()
|
|||
// mFontFamilies elements are not alloc'd so no need call Reset
|
||||
delete mFontFamilies;
|
||||
|
||||
if (mFreeTypeNodes) {
|
||||
mFreeTypeNodes->Reset(FreeNode, nsnull);
|
||||
delete mFreeTypeNodes;
|
||||
mFreeTypeNodes = nsnull;
|
||||
}
|
||||
//
|
||||
// release any encoders that were created
|
||||
//
|
||||
|
@ -793,19 +774,17 @@ cleanup_and_return:
|
|||
}
|
||||
|
||||
void
|
||||
nsFT2FontCatalog::GetFontNames(const char* aPattern, nsFontNodeArray* aNodes)
|
||||
nsFT2FontCatalog::GetFontNames(const char* aPattern, nsFontCatalog* aFC)
|
||||
{
|
||||
gFT2FontCatalog->doGetFontNames(aPattern, aNodes);
|
||||
gFT2FontCatalog->doGetFontNames(aPattern, aFC);
|
||||
}
|
||||
|
||||
void
|
||||
nsFT2FontCatalog::doGetFontNames(const char* aPattern, nsFontNodeArray* aNodes)
|
||||
nsFT2FontCatalog::doGetFontNames(const char* aPattern, nsFontCatalog* aFC)
|
||||
{
|
||||
int i, j;
|
||||
int i;
|
||||
PRBool rslt;
|
||||
char *pattern, *foundry, *family, *charset, *encoding;
|
||||
const char *charSetName;
|
||||
nsFontNode *node;
|
||||
|
||||
FONT_CATALOG_PRINTF(("looking for FreeType font matching %s", aPattern));
|
||||
nsCAutoString patt(aPattern);
|
||||
|
@ -832,45 +811,7 @@ nsFT2FontCatalog::doGetFontNames(const char* aPattern, nsFontNodeArray* aNodes)
|
|||
continue;
|
||||
if (family && !STRMATCH(family,fce->mFamilyName))
|
||||
continue;
|
||||
if (!charset) { // get all encoding
|
||||
FONT_CATALOG_PRINTF(("found FreeType %s-%s-*-*", fce->mFoundryName,
|
||||
fce->mFamilyName));
|
||||
for (j=0; j<32; j++) {
|
||||
unsigned long bit = 1 << j;
|
||||
if (bit & fce->mCodePageRange1) {
|
||||
charSetName = GetRange1CharSetName(bit);
|
||||
NS_ASSERTION(charSetName, "failed to get charset name");
|
||||
if (!charSetName)
|
||||
continue;
|
||||
node = LoadNode(fce, charSetName, aNodes);
|
||||
}
|
||||
if (bit & fce->mCodePageRange2) {
|
||||
charSetName = GetRange2CharSetName(bit);
|
||||
if (!charSetName)
|
||||
continue;
|
||||
LoadNode(fce, charSetName, aNodes);
|
||||
}
|
||||
}
|
||||
if (!foundry && family && fce->mFlags&FCE_FLAGS_SYMBOL) {
|
||||
// the "registry-encoding" is not used but LoadNode will fail without
|
||||
// some value for this
|
||||
LoadNode(fce, "symbol-fontspecific", aNodes);
|
||||
}
|
||||
}
|
||||
|
||||
if (charset && encoding) { // get this specific encoding
|
||||
PRUint32 cpr1_bits, cpr2_bits;
|
||||
nsCAutoString charsetName(charset);
|
||||
charsetName.Append('-');
|
||||
charsetName.Append(encoding);
|
||||
CharSetNameToCodeRangeBits(charsetName.get(), &cpr1_bits, &cpr2_bits);
|
||||
if (!(cpr1_bits & fce->mCodePageRange1)
|
||||
&& !(cpr2_bits & fce->mCodePageRange2))
|
||||
continue;
|
||||
FONT_CATALOG_PRINTF(("found FreeType -%s-%s-%s",
|
||||
fce->mFamilyName,charset,encoding));
|
||||
LoadNode(fce, charsetName.get(), aNodes);
|
||||
}
|
||||
AddFont(aFC, fce);
|
||||
}
|
||||
|
||||
FREE_IF(pattern);
|
||||
|
@ -1293,10 +1234,6 @@ nsFT2FontCatalog::doInitGlobals(FT_Library lib)
|
|||
if (!mFontCatalog)
|
||||
goto cleanup_and_return;
|
||||
|
||||
mFreeTypeNodes = new nsHashtable();
|
||||
if (!mFreeTypeNodes)
|
||||
goto cleanup_and_return;
|
||||
|
||||
mVendorNames = new nsHashtable();
|
||||
if (!mVendorNames)
|
||||
goto cleanup_and_return;
|
||||
|
@ -1360,7 +1297,6 @@ nsFT2FontCatalog::doInitGlobals(FT_Library lib)
|
|||
if (dump_catalog)
|
||||
DumpFontCatalog(mFontCatalog);
|
||||
#endif
|
||||
LoadNodeTable(mFontCatalog);
|
||||
|
||||
#ifdef DEBUG
|
||||
for (i=0; i<mFontCatalog->numFonts; i++) {
|
||||
|
@ -1412,124 +1348,6 @@ nsFT2FontCatalog::IsSpace(FT_Long c)
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsFontNode*
|
||||
nsFT2FontCatalog::LoadNode(nsFontCatalogEntry *aFce, const char *aCharSetName,
|
||||
nsFontNodeArray* aNodes)
|
||||
{
|
||||
nsFontCharSetMap *charSetMap = GetCharSetMap(aCharSetName);
|
||||
if (!charSetMap->mInfo) {
|
||||
return nsnull;
|
||||
}
|
||||
const char *foundry;
|
||||
foundry = GetFoundry(aFce);
|
||||
nsCAutoString nodeName(foundry);
|
||||
nodeName.Append('-');
|
||||
nodeName.Append(aFce->mFamilyName);
|
||||
nodeName.Append('-');
|
||||
nodeName.Append(aCharSetName);
|
||||
nsCStringKey key(nodeName);
|
||||
nsFontNode* node = (nsFontNode*) mFreeTypeNodes->Get(&key);
|
||||
if (!node) {
|
||||
node = new nsFontNode;
|
||||
if (!node) {
|
||||
return nsnull;
|
||||
}
|
||||
mFreeTypeNodes->Put(&key, node);
|
||||
node->mName = nodeName;
|
||||
nsFontCharSetMap *charSetMap = GetCharSetMap(aCharSetName);
|
||||
node->mCharSetInfo = charSetMap->mInfo;
|
||||
}
|
||||
|
||||
int styleIndex;
|
||||
if (aFce->mStyleFlags & FT_STYLE_FLAG_ITALIC)
|
||||
styleIndex = NS_FONT_STYLE_ITALIC;
|
||||
else
|
||||
styleIndex = NS_FONT_STYLE_NORMAL;
|
||||
nsFontStyle* style = node->mStyles[styleIndex];
|
||||
if (!style) {
|
||||
style = new nsFontStyle;
|
||||
if (!style) {
|
||||
return nsnull;
|
||||
}
|
||||
node->mStyles[styleIndex] = style;
|
||||
}
|
||||
|
||||
int weightIndex = WEIGHT_INDEX(aFce->mWeight);
|
||||
nsFontWeight* weight = style->mWeights[weightIndex];
|
||||
if (!weight) {
|
||||
weight = new nsFontWeight;
|
||||
if (!weight) {
|
||||
return nsnull;
|
||||
}
|
||||
style->mWeights[weightIndex] = weight;
|
||||
}
|
||||
|
||||
nsFontStretch* stretch = weight->mStretches[aFce->mWidth];
|
||||
if (!stretch) {
|
||||
stretch = new nsFontStretch;
|
||||
if (!stretch) {
|
||||
return nsnull;
|
||||
}
|
||||
weight->mStretches[aFce->mWidth] = stretch;
|
||||
}
|
||||
if (!stretch->mFreeTypeFaceID) {
|
||||
stretch->mFreeTypeFaceID = nsFreeTypeGetFaceID(aFce);
|
||||
}
|
||||
if (aNodes) {
|
||||
int i, n, found = 0;
|
||||
n = aNodes->Count();
|
||||
for (i=0; i<n; i++) {
|
||||
if (aNodes->GetElement(i) == node) {
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
aNodes->AppendElement(node);
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
int dump_fce = 0;
|
||||
if (dump_fce)
|
||||
DumpFontCatalogEntry(aFce);
|
||||
#endif
|
||||
return node;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsFT2FontCatalog::LoadNodeTable(nsFontCatalog *aFontCatalog)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i=0; i<aFontCatalog->numFonts; i++) {
|
||||
const char *charsetName;
|
||||
nsFontCatalogEntry *fce = aFontCatalog->fonts[i];
|
||||
if ((!fce->mFlags&FCE_FLAGS_ISVALID)
|
||||
|| (fce->mWeight < 100) || (fce->mWeight > 900) || (fce->mWidth > 8))
|
||||
continue;
|
||||
for (j=0; j<32; j++) {
|
||||
unsigned long bit = 1 << j;
|
||||
if (!(bit & fce->mCodePageRange1))
|
||||
continue;
|
||||
charsetName = GetRange1CharSetName(bit);
|
||||
NS_ASSERTION(charsetName, "failed to get charset name");
|
||||
if (!charsetName)
|
||||
continue;
|
||||
LoadNode(fce, charsetName, nsnull);
|
||||
}
|
||||
for (j=0; j<32; j++) {
|
||||
unsigned long bit = 1 << j;
|
||||
if (!(bit & fce->mCodePageRange2))
|
||||
continue;
|
||||
charsetName = GetRange2CharSetName(bit);
|
||||
if (!charsetName)
|
||||
continue;
|
||||
LoadNode(fce, charsetName, nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsDirCatalog *
|
||||
nsFT2FontCatalog::NewDirCatalog()
|
||||
{
|
||||
|
@ -1579,7 +1397,7 @@ nsFT2FontCatalog::NewFceFromFontFile(FT_Library aFreeTypeLibrary,
|
|||
fce->mFaceIndex = aFaceIndex;
|
||||
|
||||
// open the font
|
||||
fterror = (*nsFreeTypeFont::nsFT_New_Face)(aFreeTypeLibrary, aFontFileName,
|
||||
fterror = (*nsFreeType::nsFT_New_Face)(aFreeTypeLibrary, aFontFileName,
|
||||
aFaceIndex, &face);
|
||||
if (fterror) {
|
||||
FONT_SCAN_PRINTF((" FreeType failed to open, error=%d", fterror));
|
||||
|
@ -1603,7 +1421,7 @@ nsFT2FontCatalog::NewFceFromFontFile(FT_Library aFreeTypeLibrary,
|
|||
if ( (face->charmaps[i]->platform_id == TT_PLATFORM_MICROSOFT)
|
||||
&& (face->charmaps[i]->encoding_id == TT_MS_ID_UNICODE_CS)) {
|
||||
fce->mFlags = FCE_FLAGS_ISVALID | FCE_FLAGS_UNICODE;
|
||||
fterror = (*nsFreeTypeFont::nsFT_Set_Charmap)(face, face->charmaps[i]);
|
||||
fterror = (*nsFreeType::nsFT_Set_Charmap)(face, face->charmaps[i]);
|
||||
if (fterror) {
|
||||
FONT_SCAN_PRINTF(("failed to select unicode charmap"));
|
||||
goto cleanup_and_return;
|
||||
|
@ -1616,7 +1434,7 @@ nsFT2FontCatalog::NewFceFromFontFile(FT_Library aFreeTypeLibrary,
|
|||
goto cleanup_and_return;
|
||||
}
|
||||
|
||||
tt_os2 = (TT_OS2 *)(*nsFreeTypeFont::nsFT_Get_Sfnt_Table)(face, ft_sfnt_os2);
|
||||
tt_os2 = (TT_OS2 *)(*nsFreeType::nsFT_Get_Sfnt_Table)(face, ft_sfnt_os2);
|
||||
if (!tt_os2) {
|
||||
FONT_SCAN_PRINTF(("unable to get OS2 table"));
|
||||
goto cleanup_and_return;
|
||||
|
@ -1667,7 +1485,7 @@ nsFT2FontCatalog::NewFceFromFontFile(FT_Library aFreeTypeLibrary,
|
|||
slot = face->glyph;
|
||||
FONT_SCAN_PRINTF((" "));
|
||||
for (i=0; i<len; i++) {
|
||||
glyph_index = (*nsFreeTypeFont::nsFT_Get_Char_Index)(face, (FT_ULong)i);
|
||||
glyph_index = (*nsFreeType::nsFT_Get_Char_Index)(face, (FT_ULong)i);
|
||||
//FONT_CATALOG_PRINTF(("i=%d, glyph_index=%d", i, glyph_index));
|
||||
if (!glyph_index)
|
||||
continue;
|
||||
|
@ -1677,7 +1495,7 @@ nsFT2FontCatalog::NewFceFromFontFile(FT_Library aFreeTypeLibrary,
|
|||
}
|
||||
}
|
||||
num_checked++;
|
||||
fterror = (*nsFreeTypeFont::nsFT_Load_Glyph)(face, glyph_index,
|
||||
fterror = (*nsFreeType::nsFT_Load_Glyph)(face, glyph_index,
|
||||
FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING);
|
||||
//FONT_CATALOG_PRINTF(("fterror = %d", fterror));
|
||||
if (fterror) {
|
||||
|
@ -1691,10 +1509,10 @@ nsFT2FontCatalog::NewFceFromFontFile(FT_Library aFreeTypeLibrary,
|
|||
blank_chars++;
|
||||
FT_Glyph glyph;
|
||||
FT_BBox bbox;
|
||||
(*nsFreeTypeFont::nsFT_Get_Glyph)(slot, &glyph);
|
||||
(*nsFreeTypeFont::nsFT_Glyph_Get_CBox)(glyph, ft_glyph_bbox_pixels,
|
||||
(*nsFreeType::nsFT_Get_Glyph)(slot, &glyph);
|
||||
(*nsFreeType::nsFT_Glyph_Get_CBox)(glyph, ft_glyph_bbox_pixels,
|
||||
&bbox);
|
||||
(*nsFreeTypeFont::nsFT_Done_Glyph)(glyph);
|
||||
(*nsFreeType::nsFT_Done_Glyph)(glyph);
|
||||
if((bbox.xMax==0) && (bbox.xMin==0)
|
||||
&& (bbox.yMax==0) && (bbox.yMin==0)) {
|
||||
continue;
|
||||
|
@ -1750,7 +1568,7 @@ nsFT2FontCatalog::NewFceFromFontFile(FT_Library aFreeTypeLibrary,
|
|||
goto cleanup_and_return;
|
||||
}
|
||||
|
||||
(*nsFreeTypeFont::nsFT_Done_Face)(face);
|
||||
(*nsFreeType::nsFT_Done_Face)(face);
|
||||
|
||||
FONT_SCAN_PRINTF(("\n"));
|
||||
return fce;
|
||||
|
@ -1769,7 +1587,7 @@ cleanup_and_return:
|
|||
fce->mStyleName = strdup("");
|
||||
FREE_IF(fce->mEmbeddedBitmapHeights);
|
||||
if (face)
|
||||
(*nsFreeTypeFont::nsFT_Done_Face)(face);
|
||||
(*nsFreeType::nsFT_Done_Face)(face);
|
||||
FONT_SCAN_PRINTF(("\n"));
|
||||
return fce;
|
||||
|
||||
|
@ -1783,7 +1601,7 @@ no_memory_cleanup_and_return:
|
|||
FreeCCMap(fce->mCCMap);
|
||||
FREE_IF(fce);
|
||||
if (face)
|
||||
(*nsFreeTypeFont::nsFT_Done_Face)(face);
|
||||
(*nsFreeType::nsFT_Done_Face)(face);
|
||||
FONT_SCAN_PRINTF(("\n"));
|
||||
return nsnull;
|
||||
}
|
||||
|
|
|
@ -41,18 +41,18 @@
|
|||
#ifndef NS_FT2_FONT_CATALOG_H
|
||||
#define NS_FT2_FONT_CATALOG_H
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCompressedCharMap.h"
|
||||
#include "nsICharRepresentable.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsNameValuePairDB.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsICharsetConverterManager2.h"
|
||||
|
||||
#if (!defined(MOZ_ENABLE_FREETYPE2))
|
||||
class nsFT2FontCatalog {
|
||||
public:
|
||||
static void GetFontNames(const char* aPattern, nsFontNodeArray* aNodes);
|
||||
};
|
||||
#else
|
||||
|
||||
#if (defined(MOZ_ENABLE_FREETYPE2))
|
||||
//
|
||||
// To limit the potential for namespace collision we limit the
|
||||
// number of Moz files that include FreeType's include (and hence
|
||||
|
@ -62,8 +62,6 @@ struct FT_LibraryRec_;
|
|||
typedef signed long FT_Long;
|
||||
typedef unsigned short FT_UShort;
|
||||
|
||||
class nsFontNodeArray;
|
||||
|
||||
#define PUBLIC_FONT_SUMMARY_NAME NS_LITERAL_CSTRING(".mozilla_font_summary.ndb")
|
||||
#define FONT_SUMMARIES_SUBDIR NS_LITERAL_CSTRING("catalog")
|
||||
#define FONT_DOWNLOAD_SUBDIR NS_LITERAL_CSTRING("fonts")
|
||||
|
@ -152,11 +150,12 @@ typedef struct {
|
|||
} nsulCodePageRangeCharSetName;
|
||||
|
||||
class nsFT2FontCatalog {
|
||||
friend class nsFT2FontNode;
|
||||
public:
|
||||
static void FreeGlobals();
|
||||
static PRBool InitGlobals(FT_LibraryRec_ *);
|
||||
static void GetFontNames(const char* aPattern,
|
||||
nsFontNodeArray* aNodes);
|
||||
static void GetFontNames(const char* aPattern, nsFontCatalog* aFC);
|
||||
|
||||
static PRUint16* GetCCMap(nsFontCatalogEntry *aFce);
|
||||
static nsTTFontFamilyEncoderInfo* GetCustomEncoderInfo(const char *);
|
||||
static nsTTFontFamilyEncoderInfo* GetCustomEncoderInfo(nsFontCatalogEntry *);
|
||||
|
@ -185,7 +184,7 @@ protected:
|
|||
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, nsFontNodeArray* aNodes);
|
||||
void doGetFontNames(const char* aPattern, nsFontCatalog* aFC);
|
||||
PRBool GetFontSummaryName(const nsACString &, const nsACString &,
|
||||
nsACString &, nsACString &);
|
||||
const char* GetFoundry(nsFontCatalogEntry *aFce);
|
||||
|
@ -196,8 +195,6 @@ protected:
|
|||
void HandleFontFile(FT_LibraryRec_ *, nsFontCatalog *, const char*);
|
||||
PRBool doInitGlobals(FT_LibraryRec_ *);
|
||||
PRBool IsSpace(FT_Long);
|
||||
nsFontNode* LoadNode(nsFontCatalogEntry*, const char*,nsFontNodeArray*);
|
||||
PRBool LoadNodeTable(nsFontCatalog *);
|
||||
nsDirCatalog *NewDirCatalog();
|
||||
nsFontCatalogEntry* NewFceFromFontFile(FT_LibraryRec_*, const char*,int,int*);
|
||||
nsFontCatalogEntry* NewFceFromSummary(nsNameValuePairDB *aDB);
|
||||
|
@ -213,7 +210,6 @@ protected:
|
|||
|
||||
nsCOMPtr<nsIPref> mPref;
|
||||
nsFontCatalog *mFontCatalog;
|
||||
nsHashtable *mFreeTypeNodes;
|
||||
nsHashtable *mFontFamilies;
|
||||
PRPackedBool mIsNewCatalog;
|
||||
nsHashtable *mVendorNames;
|
||||
|
@ -221,8 +217,10 @@ protected:
|
|||
nsHashtable *mRange2CharSetNames;
|
||||
static nsICharsetConverterManager2* sCharSetManager;
|
||||
};
|
||||
#endif
|
||||
|
||||
extern nsFT2FontCatalog* gFT2FontCatalog;
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* NS_FT2_FONT_CATALOG_H */
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,206 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* ex: set tabstop=8 softtabstop=2 shiftwidth=2 expandtab:
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsFreeType_h__
|
||||
#define nsFreeType_h__
|
||||
|
||||
void nsFreeTypeFreeGlobals(void);
|
||||
nsresult nsFreeTypeInitGlobals(void);
|
||||
|
||||
#if (!defined(MOZ_ENABLE_FREETYPE2))
|
||||
// nsFreeType stubs for development systems without a FreeType dev env
|
||||
class nsFreeTypeFace;
|
||||
class nsFreeTypeFont : public nsFontGTK {
|
||||
public:
|
||||
static nsFreeTypeFont *NewFont(nsFreeTypeFace *, PRUint16, const char *);
|
||||
};
|
||||
#else
|
||||
|
||||
#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;
|
||||
typedef void (*blitGlyph) (XImage *, FT_BitmapGlyph, nscolor, int, int);
|
||||
typedef void (*blendPixel)(XImage *, int, int, nscolor, int);
|
||||
|
||||
class nsFreeTypeFace;
|
||||
|
||||
nsFreeTypeFace * nsFreeTypeGetFaceID(nsFontCatalogEntry *aFce);
|
||||
void nsFreeTypeGetFontNames(const char* aPattern, nsFontNodeArray* aNodes);
|
||||
|
||||
//
|
||||
// the FreeType2 function type declarations
|
||||
//
|
||||
typedef FT_Error (*FT_Done_Face_t)(FT_Face);
|
||||
typedef FT_Error (*FT_Done_FreeType_t)(FT_Library);
|
||||
typedef FT_Error (*FT_Done_Glyph_t)(FT_Glyph);
|
||||
typedef FT_Error (*FT_Get_Char_Index_t)(FT_Face, FT_ULong);
|
||||
typedef FT_Error (*FT_Get_Glyph_t)(FT_GlyphSlot, FT_Glyph*);
|
||||
typedef FT_Error (*FT_Get_Sfnt_Table_t)(FT_Face, FT_Sfnt_Tag);
|
||||
typedef FT_Error (*FT_Glyph_Get_CBox_t)(FT_Glyph, FT_UInt, FT_BBox*);
|
||||
typedef FT_Error (*FT_Init_FreeType_t)(FT_Library*);
|
||||
typedef FT_Error (*FT_Load_Glyph_t)(FT_Face, FT_UInt, FT_Int);
|
||||
typedef FT_Error (*FT_New_Face_t)(FT_Library, const char*, FT_Long, FT_Face*);
|
||||
typedef FT_Error (*FT_Set_Charmap_t)(FT_Face face, FT_CharMap charmap);
|
||||
typedef FT_Error (*FTC_Image_Cache_Lookup_t)
|
||||
(FTC_Image_Cache, FTC_Image_Desc*, FT_UInt, FT_Glyph*);
|
||||
typedef FT_Error (*FTC_Manager_Lookup_Size_t)
|
||||
(FTC_Manager, FTC_Font, FT_Face*, FT_Size*);
|
||||
typedef FT_Error (*FTC_Manager_Done_t)(FTC_Manager);
|
||||
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 nsFreeTypeFont : public nsFontGTK
|
||||
{
|
||||
public:
|
||||
|
||||
// run time loaded (function pointers)
|
||||
static FT_Done_Face_t nsFT_Done_Face;
|
||||
static FT_Done_FreeType_t nsFT_Done_FreeType;
|
||||
static FT_Done_Glyph_t nsFT_Done_Glyph;
|
||||
static FT_Get_Char_Index_t nsFT_Get_Char_Index;
|
||||
static FT_Get_Glyph_t nsFT_Get_Glyph;
|
||||
static FT_Get_Sfnt_Table_t nsFT_Get_Sfnt_Table;
|
||||
static FT_Glyph_Get_CBox_t nsFT_Glyph_Get_CBox;
|
||||
static FT_Init_FreeType_t nsFT_Init_FreeType;
|
||||
static FT_Load_Glyph_t nsFT_Load_Glyph;
|
||||
static FT_New_Face_t nsFT_New_Face;
|
||||
static FT_Set_Charmap_t nsFT_Set_Charmap;
|
||||
static FTC_Image_Cache_Lookup_t nsFTC_Image_Cache_Lookup;
|
||||
static FTC_Manager_Lookup_Size_t nsFTC_Manager_Lookup_Size;
|
||||
static FTC_Manager_Done_t nsFTC_Manager_Done;
|
||||
static FTC_Manager_New_t nsFTC_Manager_New;
|
||||
static FTC_Image_Cache_New_t nsFTC_Image_Cache_New;
|
||||
|
||||
nsFreeTypeFont();
|
||||
nsFreeTypeFont(nsFreeTypeFace *, PRUint16, const char *);
|
||||
virtual ~nsFreeTypeFont(void);
|
||||
static nsFreeTypeFont *NewFont(nsFreeTypeFace *, PRUint16, const char *);
|
||||
|
||||
void LoadFont(void);
|
||||
|
||||
virtual GdkFont* GetGDKFont(void);
|
||||
virtual PRBool GetGDKFontIs10646(void);
|
||||
virtual PRBool IsFreeTypeFont(void);
|
||||
|
||||
virtual gint GetWidth(const PRUnichar* aString, PRUint32 aLength);
|
||||
virtual gint DrawString(nsRenderingContextGTK* aContext,
|
||||
nsDrawingSurfaceGTK* aSurface, nscoord aX,
|
||||
nscoord aY, const PRUnichar* aString,
|
||||
PRUint32 aLength);
|
||||
#ifdef MOZ_MATHML
|
||||
virtual nsresult GetBoundingMetrics(const PRUnichar* aString,
|
||||
PRUint32 aLength,
|
||||
nsBoundingMetrics& aBoundingMetrics);
|
||||
#endif
|
||||
virtual nsresult doGetBoundingMetrics(const PRUnichar* aString,
|
||||
PRUint32 aLength,
|
||||
PRInt32* aLeftBearing,
|
||||
PRInt32* aRightBearing,
|
||||
PRInt32* aAscent,
|
||||
PRInt32* aDescent,
|
||||
PRInt32* aWidth);
|
||||
|
||||
virtual PRUint32 Convert(const PRUnichar* aSrc, PRUint32 aSrcLen,
|
||||
PRUnichar* aDest, PRUint32 aDestLen);
|
||||
|
||||
FT_Face getFTFace();
|
||||
int ascent();
|
||||
int descent();
|
||||
PRBool getXHeight(unsigned long &val);
|
||||
int max_ascent();
|
||||
int max_descent();
|
||||
int max_width();
|
||||
PRBool superscript_y(long &val);
|
||||
PRBool subscript_y(long &val);
|
||||
PRBool underlinePosition(long &val);
|
||||
PRBool underline_thickness(unsigned long &val);
|
||||
|
||||
FT_Error FaceRequester(FT_Face* aface);
|
||||
static void FreeGlobals();
|
||||
|
||||
protected:
|
||||
XImage *GetXImage(PRUint32 width, PRUint32 height);
|
||||
nsFreeTypeFace *mFaceID;
|
||||
PRUint16 mPixelSize;
|
||||
FTC_Image_Desc mImageDesc;
|
||||
};
|
||||
|
||||
#endif /* MOZ_ENABLE_FREETYPE2 */
|
||||
|
||||
/*
|
||||
* Defines for the TrueType codepage bits.
|
||||
* Used as a hint for the languages supported in a TrueType font.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ulCodePageRange1
|
||||
*/
|
||||
#define TT_OS2_CPR1_LATIN1 (0x00000001) /* Latin 1 */
|
||||
#define TT_OS2_CPR1_LATIN2 (0x00000002) /* Latin 2: Eastern Europe */
|
||||
#define TT_OS2_CPR1_CYRILLIC (0x00000004) /* Cyrillic */
|
||||
#define TT_OS2_CPR1_GREEK (0x00000008) /* Greek */
|
||||
#define TT_OS2_CPR1_TURKISH (0x00000010) /* Turkish */
|
||||
#define TT_OS2_CPR1_HEBREW (0x00000020) /* Hebrew */
|
||||
#define TT_OS2_CPR1_ARABIC (0x00000040) /* Arabic */
|
||||
#define TT_OS2_CPR1_BALTIC (0x00000080) /* Windows Baltic */
|
||||
#define TT_OS2_CPR1_VIETNAMESE (0x00000100) /* Vietnamese */
|
||||
/* 9-15 Reserved for Alternate ANSI */
|
||||
#define TT_OS2_CPR1_THAI (0x00010000) /* Thai */
|
||||
#define TT_OS2_CPR1_JAPANESE (0x00020000) /* JIS/Japan */
|
||||
#define TT_OS2_CPR1_CHINESE_SIMP (0x00040000) /* Chinese: Simplified */
|
||||
#define TT_OS2_CPR1_KO_WANSUNG (0x00080000) /* Korean Wansung */
|
||||
#define TT_OS2_CPR1_CHINESE_TRAD (0x00100000) /* Chinese: Traditional */
|
||||
#define TT_OS2_CPR1_KO_JOHAB (0x00200000) /* Korean Johab */
|
||||
/* 22-28 Reserved for Alternate ANSI&OEM */
|
||||
#define TT_OS2_CPR1_MAC_ROMAN (0x20000000) /* Mac (US Roman) */
|
||||
#define TT_OS2_CPR1_OEM (0x40000000) /* OEM Character Set */
|
||||
#define TT_OS2_CPR1_SYMBOL (0x80000000) /* Symbol Character Set */
|
||||
|
||||
/*
|
||||
* ulCodePageRange2
|
||||
*/ /* 32-47 Reserved for OEM */
|
||||
#define TT_OS2_CPR2_GREEK (0x00010000) /* IBM Greek */
|
||||
#define TT_OS2_CPR2_RUSSIAN (0x00020000) /* MS-DOS Russian */
|
||||
#define TT_OS2_CPR2_NORDIC (0x00040000) /* MS-DOS Nordic */
|
||||
#define TT_OS2_CPR2_ARABIC (0x00080000) /* Arabic */
|
||||
#define TT_OS2_CPR2_CA_FRENCH (0x00100000) /* MS-DOS Canadian French */
|
||||
#define TT_OS2_CPR2_HEBREW (0x00200000) /* Hebrew */
|
||||
#define TT_OS2_CPR2_ICELANDIC (0x00400000) /* MS-DOS Icelandic */
|
||||
#define TT_OS2_CPR2_PORTUGESE (0x00800000) /* MS-DOS Portuguese */
|
||||
#define TT_OS2_CPR2_TURKISH (0x01000000) /* IBM Turkish */
|
||||
#define TT_OS2_CPR2_CYRILLIC (0x02000000)/*IBM Cyrillic; primarily Russian*/
|
||||
#define TT_OS2_CPR2_LATIN2 (0x04000000) /* Latin 2 */
|
||||
#define TT_OS2_CPR2_BALTIC (0x08000000) /* MS-DOS Baltic */
|
||||
#define TT_OS2_CPR2_GREEK_437G (0x10000000) /* Greek; former 437 G */
|
||||
#define TT_OS2_CPR2_ARABIC_708 (0x20000000) /* Arabic; ASMO 708 */
|
||||
#define TT_OS2_CPR2_WE_LATIN1 (0x40000000) /* WE/Latin 1 */
|
||||
#define TT_OS2_CPR2_US (0x80000000) /* US */
|
||||
|
||||
#endif
|
Загрузка…
Ссылка в новой задаче