Группа :: Сети/WWW
Пакет: firefox
Главная Изменения Спек Патчи Загрузить Bugs and FR
Патч: firefox-234035-4xftonly.patch
? gfx/src/ps/.nsType8.cpp.swp
? gfx/src/ps/UnBatang.raw
? gfx/src/ps/nsType8.cpp.new
? gfx/src/ps/output.ps
Index: gfx/src/ps/nsFontMetricsPS.cpp
===================================================================
RCS file: /cvsroot/mozilla/gfx/src/ps/nsFontMetricsPS.cpp,v
retrieving revision 1.45
diff -u -7 -p -r1.45 nsFontMetricsPS.cpp
--- gfx/src/ps/nsFontMetricsPS.cpp 20 Aug 2004 09:11:25 -0000 1.45
+++ gfx/src/ps/nsFontMetricsPS.cpp 15 Oct 2004 22:55:11 -0000
@@ -1024,28 +1024,14 @@ nsFontPSXft::FindFont(PRUnichar aChar, c
FcPatternDestroy(pattern);
}
return nsnull;
}
-/*FT_CALLBACK_DEF*/
-FT_Error
-nsXftFaceRequester(FTC_FaceID face_id, FT_Library lib,
- FT_Pointer request_data, FT_Face* aFace)
-{
- nsXftEntry *faceID = (nsXftEntry *)face_id;
-
- FT_Error fterror = FT_New_Face(lib, faceID->mFontFileName.get(),
- faceID->mFaceIndex, aFace);
- if (fterror)
- *aFace = nsnull;
- return 0;
-}
-
nsFontPSXft::nsFontPSXft(const nsFont& aFont,
nsFontMetricsPS* aFontMetrics)
:nsFontPS(aFont, aFontMetrics)
{
}
nsresult
@@ -1059,63 +1045,46 @@ nsFontPSXft::Init(nsXftEntry* aEntry,
float app2dev;
nsIDeviceContext* dc = mFontMetrics->GetDeviceContext();
NS_ENSURE_TRUE(dc, NS_ERROR_NULL_POINTER);
app2dev = dc->AppUnitsToDevUnits();
mPixelSize = NSToIntRound(app2dev * mFont->size);
- mImageDesc.font.face_id = (void*)mEntry;
- mImageDesc.font.pix_width = mPixelSize;
- mImageDesc.font.pix_height = mPixelSize;
- mImageDesc.image_type = 0;
-
FT_Error fterror;
fterror = FT_Init_FreeType(&mFreeTypeLibrary);
if (fterror) {
- NS_ASSERTION(!fterror, "failed to initialize FreeType library");
+ NS_ERROR("failed to initialize FreeType library");
mFreeTypeLibrary = nsnull;
return NS_ERROR_FAILURE;
}
- fterror = FTC_Manager_New(mFreeTypeLibrary, 0, 0, 0, nsXftFaceRequester,
- NULL, &mFTCacheManager);
- NS_ASSERTION(!fterror, "failed to create FreeType Cache manager");
- if (fterror)
- return NS_ERROR_FAILURE;
-
- fterror = FTC_Image_Cache_New(mFTCacheManager, &mImageCache);
- NS_ASSERTION(!fterror, "failed to create FreeType image cache");
- if (fterror)
- return NS_ERROR_FAILURE;
-
return NS_OK;
}
nsFontPSXft::~nsFontPSXft()
{
- FTC_Manager_Done(mFTCacheManager);
+ if (mEntry->mFace)
+ FT_Done_Face(mEntry->mFace);
if (FT_Done_FreeType(mFreeTypeLibrary))
return;
mEntry = nsnull;
}
FT_Face
nsFontPSXft::getFTFace()
{
- FT_Error error;
FT_Face face = mEntry->mFace;
if (face)
return (face);
- error = FTC_Manager_Lookup_Size(mFTCacheManager, &mImageDesc.font,
- &face, nsnull);
- NS_ASSERTION(error == 0, "failed to get face/size");
- if (error)
+ if (FT_New_Face(mFreeTypeLibrary, mEntry->mFontFileName.get(),
+ mEntry->mFaceIndex, &face) ||
+ FT_Set_Pixel_Sizes(face, mPixelSize, 0))
return nsnull;
mEntry->mFace = face;
return face;
}
nscoord
@@ -1145,23 +1114,24 @@ nsFontPSXft::GetWidth(const PRUnichar* a
// get the face/size from the FreeType cache
FT_Face face = getFTFace();
NS_ASSERTION(face, "failed to get face/size");
if (!face)
return 0;
+ // XXX : we might need some caching here
for (PRUint32 i=0; i<aLength; i++) {
glyph_index = FT_Get_Char_Index((FT_Face)face, aString[i]);
- FT_Error error = FTC_Image_Cache_Lookup(mImageCache, &mImageDesc,
- glyph_index, &glyph);
- if (error) {
+ if (FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT) ||
+ FT_Get_Glyph(face->glyph, &glyph)) {
origin_x += FT_REG_TO_16_16(face->size->metrics.x_ppem/2 + 2);
continue;
}
origin_x += glyph->advance.x;
+ FT_Done_Glyph(glyph);
}
NS_ENSURE_TRUE(mFontMetrics, 0);
nsDeviceContextPS* dc = mFontMetrics->GetDeviceContext();
NS_ENSURE_TRUE(dc, 0);
@@ -2407,52 +2377,40 @@ nsXftType8Generator::Init(nsXftEntry* aE
FT_Error error = FT_Init_FreeType(&mFreeTypeLibrary);
NS_ASSERTION(!error, "failed to initialize FreeType library");
if (error) {
mFreeTypeLibrary = nsnull;
return NS_ERROR_FAILURE;
}
- error = FTC_Manager_New(mFreeTypeLibrary, 0, 0, 0, nsXftFaceRequester,
- NULL, &mFTCacheManager);
- NS_ASSERTION(!error, "failed to create FreeType Cache manager");
- if (error)
- return NS_ERROR_FAILURE;
return NS_OK;
}
nsXftType8Generator::~nsXftType8Generator()
{
- FTC_Manager_Done(mFTCacheManager);
+ if (mEntry->mFace)
+ FT_Done_Face(mEntry->mFace);
if (FT_Done_FreeType(mFreeTypeLibrary))
return;
mEntry = nsnull;
}
void nsXftType8Generator::GeneratePSFont(FILE* aFile)
{
- FT_Error error;
FT_Face face = mEntry->mFace;
if (face == nsnull) {
- mImageDesc.font.face_id = (void*)mEntry;
- mImageDesc.font.pix_width = 16;
- mImageDesc.font.pix_height = 16;
- mImageDesc.image_type = 0;
- error = FTC_Manager_Lookup_Size(mFTCacheManager, &mImageDesc.font,
- &face, nsnull);
- if (error)
- return;
+ if (FT_New_Face(mFreeTypeLibrary, mEntry->mFontFileName.get(), mEntry->mFaceIndex, &face) ||
+ face == nsnull /* || FT_Set_Pixel_Sizes(face, 16, 0) */)
+ return;
+ mEntry->mFace = face;
}
- if (face == nsnull)
- return;
-
int wmode = 0;
if (!mSubset.IsEmpty())
FT2SubsetToType8(face, mSubset.get(), mSubset.Length(), wmode, aFile);
}
#else
#ifdef MOZ_ENABLE_FREETYPE2
Index: gfx/src/ps/nsFontMetricsPS.h
===================================================================
RCS file: /cvsroot/mozilla/gfx/src/ps/nsFontMetricsPS.h,v
retrieving revision 1.26
diff -u -7 -p -r1.26 nsFontMetricsPS.h
--- gfx/src/ps/nsFontMetricsPS.h 20 Aug 2004 09:11:25 -0000 1.26
+++ gfx/src/ps/nsFontMetricsPS.h 15 Oct 2004 22:55:12 -0000
@@ -337,18 +337,15 @@ public:
#endif
nsXftEntry *mEntry;
FT_Face getFTFace();
protected:
PRUint16 mPixelSize;
- FTC_Image_Desc mImageDesc;
FT_Library mFreeTypeLibrary;
- FTC_Manager mFTCacheManager;
- FTC_Image_Cache mImageCache;
int ascent();
int descent();
PRBool getXHeight(unsigned long &aVal);
int max_ascent();
int max_descent();
int max_width();
@@ -474,17 +471,15 @@ public:
nsXftType8Generator();
~nsXftType8Generator();
nsresult Init(nsXftEntry* aFce);
void GeneratePSFont(FILE* aFile);
protected:
nsXftEntry *mEntry;
- FTC_Image_Desc mImageDesc;
FT_Library mFreeTypeLibrary;
- FTC_Manager mFTCacheManager;
};
#else
#ifdef MOZ_ENABLE_FREETYPE2
class nsFT2Type8Generator : public nsPSFontGenerator {
public:
nsFT2Type8Generator();
~nsFT2Type8Generator();