Bug 375446 - Create gfxFontGroup factory method. r=vlad

This commit is contained in:
tor%cs.brown.edu 2007-04-02 19:06:17 +00:00
Родитель 82f15f87e8
Коммит ad461522a0
12 изменённых файлов: 60 добавлений и 49 удалений

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

@ -43,21 +43,12 @@
#include <stdio.h>
#include "gfxTextRunCache.h"
#include "gfxPlatform.h"
NS_IMPL_ISUPPORTS1(nsThebesFontMetrics, nsIFontMetrics)
#include <stdlib.h>
#if defined(XP_WIN)
#include "gfxWindowsFonts.h"
#elif defined(MOZ_ENABLE_PANGO)
#include "gfxPangoFonts.h"
#elif defined(XP_MACOSX)
#include "gfxAtsuiFonts.h"
#elif defined(XP_OS2)
#include "gfxOS2Fonts.h"
#endif
nsThebesFontMetrics::nsThebesFontMetrics()
{
mFontStyle = nsnull;
@ -98,17 +89,8 @@ nsThebesFontMetrics::Init(const nsFont& aFont, nsIAtom* aLangGroup,
size, langGroup, aFont.sizeAdjust,
aFont.systemFont, aFont.familyNameQuirks);
#if defined(XP_WIN)
mFontGroup = new gfxWindowsFontGroup(aFont.name, mFontStyle);
#elif defined(MOZ_ENABLE_PANGO)
mFontGroup = new gfxPangoFontGroup(aFont.name, mFontStyle);
#elif defined(XP_MACOSX)
mFontGroup = new gfxAtsuiFontGroup(aFont.name, mFontStyle);
#elif defined(XP_OS2)
mFontGroup = new gfxOS2FontGroup(aFont.name, mFontStyle);
#else
#error implement me
#endif
mFontGroup =
gfxPlatform::GetPlatform()->CreateFontGroup(aFont.name, mFontStyle);
return NS_OK;
}

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

@ -65,6 +65,9 @@ public:
FontResolverCallback aCallback,
void *aClosure, PRBool& aAborted);
gfxFontGroup *CreateFontGroup(const nsAString &aFamilies,
const gfxFontStyle *aStyle);
private:
HDC mDC;
HPS mPS;

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

@ -46,6 +46,8 @@
#include "gfxASurface.h"
class gfxImageSurface;
class gfxFontGroup;
class gfxFontStyle;
class THEBES_API gfxPlatform {
public:
@ -119,6 +121,12 @@ public:
void *aClosure,
PRBool& aAborted) = 0;
/**
* Create the appropriate platform font group
*/
virtual gfxFontGroup *CreateFontGroup(const nsAString &aFamilies,
const gfxFontStyle *aStyle) = 0;
/* Returns PR_TRUE if the given block of ARGB32 data really has alpha, otherwise PR_FALSE */
static PRBool DoesARGBImageDataHaveAlpha(PRUint8* data,
PRUint32 width,

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

@ -72,6 +72,9 @@ public:
FontResolverCallback aCallback,
void *aClosure, PRBool& aAborted);
gfxFontGroup *CreateFontGroup(const nsAString &aFamilies,
const gfxFontStyle *aStyle);
static PRInt32 DPI() {
if (sDPI == -1) {
InitDPI();

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

@ -56,6 +56,8 @@ public:
FontResolverCallback aCallback,
void *aClosure, PRBool& aAborted);
gfxFontGroup *CreateFontGroup(const nsAString &aFamilies,
const gfxFontStyle *aStyle);
nsresult GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,

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

@ -69,6 +69,9 @@ public:
FontResolverCallback aCallback,
void *aClosure, PRBool& aAborted);
gfxFontGroup *CreateFontGroup(const nsAString &aFamilies,
const gfxFontStyle *aStyle);
/* local methods */
void FindOtherFonts(const PRUnichar *aString, PRUint32 aLength, const char *aLangGroup, const char *aGeneric, nsString& array);

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

@ -38,6 +38,7 @@
#include "gfxOS2Platform.h"
#include "gfxOS2Surface.h"
#include "gfxImageSurface.h"
#include "gfxOS2Fonts.h"
/**********************************************************************
* class gfxOS2Platform
@ -161,3 +162,10 @@ gfxOS2Platform::ResolveFontName(const nsAString& aFontName,
aAborted = !(*aCallback)(aFontName, aClosure);
return NS_OK;
}
gfxFontGroup *
gfxOS2Platform::CreateFontGroup(const nsAString &aFamilies,
const gfxFontStyle *aStyle)
{
return new gfxOS2FontGroup(aFamilies, aStyle);
}

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

@ -50,6 +50,8 @@
#include "gfxImageSurface.h"
#include "gfxXlibSurface.h"
#include "gfxPangoFonts.h"
#ifdef MOZ_ENABLE_GLITZ
#include "gfxGlitzSurface.h"
#include "glitz-glx.h"
@ -263,6 +265,13 @@ gfxPlatformGtk::ResolveFontName(const nsAString& aFontName,
aClosure, aAborted);
}
gfxFontGroup *
gfxPlatformGtk::CreateFontGroup(const nsAString &aFamilies,
const gfxFontStyle *aStyle)
{
return new gfxPangoFontGroup(aFamilies, aStyle);
}
static PRInt32
GetXftDPI()
{

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

@ -42,6 +42,7 @@
#include "gfxQuartzSurface.h"
#include "gfxQuartzFontCache.h"
#include "gfxAtsuiFonts.h"
#ifdef MOZ_ENABLE_GLITZ
#include "gfxGlitzSurface.h"
@ -150,6 +151,13 @@ gfxPlatformMac::ResolveFontName(const nsAString& aFontName,
return NS_OK;
}
gfxFontGroup *
gfxPlatformMac::CreateFontGroup(const nsAString &aFamilies,
const gfxFontStyle *aStyle)
{
return new gfxAtsuiFontGroup(aFamilies, aStyle);
}
nsresult
gfxPlatformMac::GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,

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

@ -50,6 +50,8 @@
#include "nsIWindowsRegKey.h"
#include "gfxWindowsFonts.h"
#include <string>
gfxWindowsPlatform::gfxWindowsPlatform()
@ -499,3 +501,10 @@ gfxWindowsPlatform::PutFontWeightTable(const nsAString& aName, WeightTable *aWei
{
mFontWeights.Put(aName, aWeightTable);
}
gfxFontGroup *
gfxWindowsPlatform::CreateFontGroup(const nsAString &aFamilies,
const gfxFontStyle *aStyle)
{
return new gfxWindowsFontGroup(aFamilies, aStyle);
}

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

@ -50,12 +50,7 @@
#include "gfxFontTest.h"
#if defined(XP_WIN)
#include "gfxWindowsFonts.h"
#elif defined(MOZ_ENABLE_PANGO)
#include "gfxPangoFonts.h"
#elif defined(XP_MACOSX)
#include "gfxAtsuiFonts.h"
#if defined(XP_MACOSX)
#include "gfxTestCocoaHelper.h"
#endif
@ -288,15 +283,7 @@ PRBool
RunTest (TestEntry *test, gfxContext *ctx) {
nsRefPtr<gfxFontGroup> fontGroup;
#if defined(XP_WIN)
fontGroup = new gfxWindowsFontGroup(NS_ConvertUTF8toUTF16(test->utf8FamilyString), &test->fontStyle);
#elif defined(MOZ_ENABLE_PANGO)
fontGroup = new gfxPangoFontGroup(NS_ConvertUTF8toUTF16(test->utf8FamilyString), &test->fontStyle);
#elif defined(XP_MACOSX)
fontGroup = new gfxAtsuiFontGroup(NS_ConvertUTF8toUTF16(test->utf8FamilyString), &test->fontStyle);
#else
return PR_FALSE;
#endif
fontGroup = gfxPlatform::GetPlatform()->CreateFontGroup(NS_ConvertUTF8toUTF16(test->utf8FamilyString), &test->fontStyle);
nsAutoPtr<gfxTextRun> textRun;
gfxTextRunFactory::Parameters params = {

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

@ -52,12 +52,7 @@
#include "gfxFontTest.h"
#if defined(XP_WIN)
#include "gfxWindowsFonts.h"
#elif defined(MOZ_ENABLE_PANGO)
#include "gfxPangoFonts.h"
#elif defined(XP_MACOSX)
#include "gfxAtsuiFonts.h"
#if defined(XP_MACOSX)
#include "gfxTestCocoaHelper.h"
#endif
@ -103,13 +98,7 @@ RunTest (TestEntry *test, gfxContext *ctx) {
0.0,
PR_FALSE, PR_FALSE);
#if defined(XP_WIN)
fontGroup = new gfxWindowsFontGroup(NS_ConvertUTF8toUTF16(test->mFamilies), &style_western_normal_16);
#elif defined(MOZ_ENABLE_PANGO)
fontGroup = new gfxPangoFontGroup(NS_ConvertUTF8toUTF16(test->mFamilies), &style_western_normal_16);
#elif defined(XP_MACOSX)
fontGroup = new gfxAtsuiFontGroup(NS_ConvertUTF8toUTF16(test->mFamilies), &style_western_normal_16);
#endif
fontGroup = gfxPlatform::GetPlatform()->CreateFontGroup(NS_ConvertUTF8toUTF16(test->mFamilies), &style_western_normal_16);
}
nsAutoPtr<gfxTextRun> textRun;