Make nsIFontMetrics::GetFont() non-virtual. Bug 230605, r=bryner, sr=bzbarsky.

This commit is contained in:
kjh-5727%comcast.net 2005-01-22 16:00:07 +00:00
parent 05cc0f804b
commit c9e0e90d54
37 changed files with 96 additions and 288 deletions

View File

@ -300,14 +300,8 @@ STDMETHODIMP nsTextAccessibleWrap::get_fontFamily(
return E_FAIL;
}
const nsFont *actualFont = nsnull;
fm->GetFont(actualFont);
if (!actualFont) {
return E_FAIL;
}
nsAutoString fontFamily;
deviceContext->FirstExistingFont(*actualFont, fontFamily);
deviceContext->FirstExistingFont(fm->Font(), fontFamily);
*aFontFamily = ::SysAllocString(fontFamily.get());
return S_OK;

View File

@ -40,8 +40,8 @@
#include "nsISupports.h"
#include "nsCoord.h"
#include "nsFont.h"
struct nsFont;
class nsString;
class nsIDeviceContext;
class nsIAtom;
@ -208,9 +208,10 @@ public:
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance) = 0;
/**
* Returns the font associated with these metrics
* Returns the font associated with these metrics. The return value
* is only defined after Init() has been called.
*/
NS_IMETHOD GetFont(const nsFont *&aFont) = 0;
const nsFont &Font() { return mFont; }
/**
* Returns the language group associated with these metrics
@ -231,6 +232,10 @@ public:
* Returns the often needed width of the space character
*/
NS_IMETHOD GetSpaceWidth(nscoord& aSpaceCharWidth) = 0;
protected:
nsFont mFont; // The font for this metrics object.
};
#endif /* nsIFontMetrics_h___ */

View File

@ -67,11 +67,6 @@ nsFontMetricsBeOS::nsFontMetricsBeOS()
nsFontMetricsBeOS::~nsFontMetricsBeOS()
{
if (nsnull != mFont)
{
delete mFont;
mFont = nsnull;
}
if (mDeviceContext)
{
// Notify our device context that owns us so that it can update its font cache
@ -116,16 +111,14 @@ NS_IMETHODIMP nsFontMetricsBeOS::Init(const nsFont& aFont, nsIAtom* aLangGroup,
PRInt16 face = 0;
mFont = new nsFont(aFont);
if (!mFont)
return NS_ERROR_OUT_OF_MEMORY;
mFont = aFont;
float app2dev, app2twip;
app2dev = aContext->AppUnitsToDevUnits();
app2twip = aContext->DevUnitsToTwips();
app2twip *= app2dev;
float rounded = ((float)NSIntPointsToTwips(NSTwipsToFloorIntPoints(nscoord(mFont->size * app2twip)))) / app2twip;
float rounded = ((float)NSIntPointsToTwips(NSTwipsToFloorIntPoints(nscoord(mFont.size * app2twip)))) / app2twip;
// process specified fonts from first item of the array.
// stop processing next when a real font found;
@ -401,12 +394,6 @@ NS_IMETHODIMP nsFontMetricsBeOS::GetSpaceWidth(nscoord &aSpaceWidth)
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetFont(const nsFont*& aFont)
{
aFont = mFont;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetLangGroup(nsIAtom** aLangGroup)
{
if (!aLangGroup)

View File

@ -85,7 +85,6 @@ public:
NS_IMETHOD GetMaxDescent(nscoord &aDescent);
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
NS_IMETHOD GetAveCharWidth(nscoord &aAveCharWidth);
NS_IMETHOD GetFont(const nsFont *&aFont);
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
@ -100,7 +99,6 @@ protected:
void RealizeFont(nsIDeviceContext* aContext);
nsIDeviceContext *mDeviceContext;
nsFont *mFont;
BFont mFontHandle;
nscoord mLeading;

View File

@ -59,7 +59,6 @@ static FT_Library ftlib = nsnull;
NS_IMPL_ISUPPORTS1(nsCairoFontMetrics, nsIFontMetrics)
nsCairoFontMetrics::nsCairoFontMetrics() :
mFont(nsnull),
mMaxAscent(0),
mMaxDescent(0),
mMaxAdvance(0),
@ -75,7 +74,6 @@ nsCairoFontMetrics::nsCairoFontMetrics() :
nsCairoFontMetrics::~nsCairoFontMetrics()
{
FT_Done_Face(mFace);
delete mFont;
}
static char *
@ -97,7 +95,7 @@ NS_IMETHODIMP
nsCairoFontMetrics::Init(const nsFont& aFont, nsIAtom* aLangGroup,
nsIDeviceContext *aContext)
{
mFont = new nsFont(aFont);
mFont = aFont;
mLangGroup = aLangGroup;
mDeviceContext = aContext;
@ -126,8 +124,6 @@ nsCairoFontMetrics::Init(const nsFont& aFont, nsIAtom* aLangGroup,
NS_IMETHODIMP
nsCairoFontMetrics::Destroy()
{
delete mFont;
mFont = nsnull;
return NS_OK;
}
@ -280,13 +276,6 @@ nsCairoFontMetrics::GetMaxAdvance(nscoord &aAdvance)
return NS_OK;
}
NS_IMETHODIMP
nsCairoFontMetrics::GetFont(const nsFont *&aFont)
{
aFont = mFont;
return NS_OK;
}
NS_IMETHODIMP
nsCairoFontMetrics::GetLangGroup(nsIAtom** aLangGroup)
{

View File

@ -74,7 +74,6 @@ public:
NS_IMETHOD GetMaxAscent(nscoord &aAscent);
NS_IMETHOD GetMaxDescent(nscoord &aDescent);
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
NS_IMETHOD GetFont(const nsFont *&aFont);
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
NS_IMETHOD GetAveCharWidth(nscoord& aAveCharWidth);
@ -88,7 +87,6 @@ public:
private:
FT_Face mFace;
nsFont *mFont;
nsCOMPtr<nsIDeviceContext> mDeviceContext;
nsCOMPtr<nsIAtom> mLangGroup;
float mDev2App;

View File

@ -381,14 +381,14 @@ NS_IMETHODIMP
nsFontMetricsXft::Init(const nsFont& aFont, nsIAtom* aLangGroup,
nsIDeviceContext *aContext)
{
mFont = new nsFont(aFont);
mFont = aFont;
mLangGroup = aLangGroup;
// Hang onto the device context
mDeviceContext = aContext;
float app2dev = mDeviceContext->AppUnitsToDevUnits();
mPixelSize = NSTwipsToFloatPixels(mFont->size, app2dev);
mPixelSize = NSTwipsToFloatPixels(mFont.size, app2dev);
// Make sure to clamp the pixel size to something reasonable so we
// don't make the X server blow up.
@ -396,7 +396,7 @@ nsFontMetricsXft::Init(const nsFont& aFont, nsIAtom* aLangGroup,
mPixelSize = PR_MIN(screenPixels * FONT_MAX_FONT_SCALE, mPixelSize);
// enumerate over the font names passed in
mFont->EnumerateFamilies(nsFontMetricsXft::EnumFontCallback, this);
mFont.EnumerateFamilies(nsFontMetricsXft::EnumFontCallback, this);
nsCOMPtr<nsIPref> prefService;
prefService = do_GetService(NS_PREF_CONTRACTID);
@ -484,13 +484,6 @@ nsFontMetricsXft::Destroy()
return NS_OK;
}
NS_IMETHODIMP
nsFontMetricsXft::GetFont(const nsFont *&aFont)
{
aFont = mFont;
return NS_OK;
}
NS_IMETHODIMP
nsFontMetricsXft::GetLangGroup(nsIAtom** aLangGroup)
{
@ -1026,7 +1019,7 @@ nsFontMetricsXft::SetupFCPattern(void)
// If there's a generic add a pref for the generic if there's one
// set.
if (mGenericFont && !mFont->systemFont) {
if (mGenericFont && !mFont.systemFont) {
nsCString name;
name += "font.name.";
name += mGenericFont->get();
@ -1061,21 +1054,21 @@ nsFontMetricsXft::SetupFCPattern(void)
}
// Add the generic if there is one.
if (mGenericFont && !mFont->systemFont)
if (mGenericFont && !mFont.systemFont)
AddFFRE(mPattern, mGenericFont, PR_FALSE);
if (PR_LOG_TEST(gXftFontLoad, PR_LOG_DEBUG)) {
// generic font
if (mGenericFont && !mFont->systemFont) {
if (mGenericFont && !mFont.systemFont) {
printf("\tadding generic family: %s\n", mGenericFont->get());
}
// pixel size
printf("\tpixel,twip size: %f,%d\n", mPixelSize, mFont->size);
printf("\tpixel,twip size: %f,%d\n", mPixelSize, mFont.size);
// slant type
printf("\tslant: ");
switch(mFont->style) {
switch(mFont.style) {
case NS_FONT_STYLE_ITALIC:
printf("italic\n");
break;
@ -1089,7 +1082,7 @@ nsFontMetricsXft::SetupFCPattern(void)
// weight
printf("\tweight: (orig,calc) %d,%d\n",
mFont->weight, CalculateWeight(mFont->weight));
mFont.weight, CalculateWeight(mFont.weight));
}
@ -1101,11 +1094,11 @@ nsFontMetricsXft::SetupFCPattern(void)
// Add the slant type
FcPatternAddInteger(mPattern, FC_SLANT,
CalculateSlant(mFont->style));
CalculateSlant(mFont.style));
// Add the weight
FcPatternAddInteger(mPattern, FC_WEIGHT,
CalculateWeight(mFont->weight));
CalculateWeight(mFont.weight));
// Set up the default substitutions for this font
FcConfigSubstitute(0, mPattern, FcMatchPattern);
@ -1240,7 +1233,7 @@ nsFontMetricsXft::SetupMiniFont(void)
FcPatternAddInteger(pattern, FC_PIXEL_SIZE, int(0.5 * mPixelSize));
FcPatternAddInteger(pattern, FC_WEIGHT,
CalculateWeight(mFont->weight));
CalculateWeight(mFont.weight));
FcConfigSubstitute(0, pattern, FcMatchPattern);
XftDefaultSubstitute(GDK_DISPLAY(), DefaultScreen(GDK_DISPLAY()),

View File

@ -70,7 +70,6 @@ public:
NS_IMETHOD Init (const nsFont& aFont, nsIAtom* aLangGroup,
nsIDeviceContext *aContext);
NS_IMETHOD Destroy();
NS_IMETHOD GetFont (const nsFont *&aFont);
NS_IMETHOD GetLangGroup (nsIAtom** aLangGroup);
NS_IMETHOD GetFontHandle (nsFontHandle &aHandle);
@ -265,7 +264,6 @@ private:
nsIDeviceContext *mDeviceContext;
nsCOMPtr<nsIAtom> mLangGroup;
nsCString *mGenericFont;
nsFont *mFont;
float mPixelSize;
nsCAutoString mDefaultFont;

View File

@ -1524,11 +1524,6 @@ nsFontMetricsGTK::~nsFontMetricsGTK()
{
// do not free mGeneric here
if (nsnull != mFont) {
delete mFont;
mFont = nsnull;
}
if (mLoadedFonts) {
PR_Free(mLoadedFonts);
mLoadedFonts = nsnull;
@ -1613,7 +1608,7 @@ NS_IMETHODIMP nsFontMetricsGTK::Init(const nsFont& aFont, nsIAtom* aLangGroup,
return res;
}
mFont = new nsFont(aFont);
mFont = aFont;
mLangGroup = aLangGroup;
mDeviceContext = aContext;
@ -1621,15 +1616,15 @@ NS_IMETHODIMP nsFontMetricsGTK::Init(const nsFont& aFont, nsIAtom* aLangGroup,
float app2dev;
app2dev = mDeviceContext->AppUnitsToDevUnits();
mPixelSize = NSToIntRound(app2dev * mFont->size);
mPixelSize = NSToIntRound(app2dev * mFont.size);
// Make sure to clamp the pixel size to something reasonable so we
// don't make the X server blow up.
mPixelSize = PR_MIN(gdk_screen_height() * FONT_MAX_FONT_SCALE, mPixelSize);
mStretchIndex = 4; // normal
mStyleIndex = mFont->style;
mStyleIndex = mFont.style;
mFont->EnumerateFamilies(FontEnumCallback, this);
mFont.EnumerateFamilies(FontEnumCallback, this);
nsXPIDLCString value;
if (!mGeneric) {
gPref->CopyCharPref("font.default", getter_Copies(value));
@ -2014,12 +2009,6 @@ NS_IMETHODIMP nsFontMetricsGTK::GetAveCharWidth(nscoord &aAveCharWidth)
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsGTK::GetFont(const nsFont*& aFont)
{
aFont = mFont;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsGTK::GetLangGroup(nsIAtom** aLangGroup)
{
if (!aLangGroup) {
@ -5048,7 +5037,7 @@ check_done:
nsFontStyle* style = aNode->mStyles[mStyleIndex];
nsFontWeight** weights = style->mWeights;
int weight = mFont->weight;
int weight = mFont.weight;
int steps = (weight % 100);
int weightIndex;
if (steps) {

View File

@ -255,7 +255,6 @@ public:
NS_IMETHOD GetMaxDescent(nscoord &aDescent);
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
NS_IMETHOD GetAveCharWidth(nscoord &aAveCharWidth);
NS_IMETHOD GetFont(const nsFont *&aFont);
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
@ -377,7 +376,6 @@ protected:
nsFontGTK* LocateFont(PRUint32 aChar, PRInt32 & aCount);
nsIDeviceContext *mDeviceContext;
nsFont *mFont;
nsFontGTK *mWesternFont;
nsFontGTK *mCurrentFont;

View File

@ -156,8 +156,6 @@ nsFontMetricsPango::nsFontMetricsPango()
nsFontMetricsPango::~nsFontMetricsPango()
{
delete mFont;
if (mDeviceContext)
mDeviceContext->FontMetricsDeleted(this);
@ -188,13 +186,13 @@ NS_IMETHODIMP
nsFontMetricsPango::Init(const nsFont& aFont, nsIAtom* aLangGroup,
nsIDeviceContext *aContext)
{
mFont = new nsFont(aFont);
mFont = aFont;
mLangGroup = aLangGroup;
// Hang on to the device context
mDeviceContext = aContext;
mPointSize = NSTwipsToFloatPoints(mFont->size);
mPointSize = NSTwipsToFloatPoints(mFont.size);
// Make sure to clamp the pixel size to something reasonable so we
// don't make the X server blow up.
@ -202,7 +200,7 @@ nsFontMetricsPango::Init(const nsFont& aFont, nsIAtom* aLangGroup,
mPointSize = PR_MIN(screenPixels * FONT_MAX_FONT_SCALE, mPointSize);
// enumerate over the font names passed in
mFont->EnumerateFamilies(nsFontMetricsPango::EnumFontCallback, this);
mFont.EnumerateFamilies(nsFontMetricsPango::EnumFontCallback, this);
nsCOMPtr<nsIPref> prefService;
prefService = do_GetService(NS_PREF_CONTRACTID);
@ -451,13 +449,6 @@ nsFontMetricsPango::Destroy()
return NS_OK;
}
NS_IMETHODIMP
nsFontMetricsPango::GetFont(const nsFont *&aFont)
{
aFont = mFont;
return NS_OK;
}
NS_IMETHODIMP
nsFontMetricsPango::GetLangGroup(nsIAtom** aLangGroup)
{
@ -971,7 +962,7 @@ nsFontMetricsPango::RealizeFont(void)
// If there's a generic add a pref for the generic if there's one
// set.
if (mGenericFont && !mFont->systemFont) {
if (mGenericFont && !mFont.systemFont) {
nsCString name;
name += "font.name.";
name += mGenericFont->get();
@ -1002,7 +993,7 @@ nsFontMetricsPango::RealizeFont(void)
}
// Add the generic if there is one.
if (mGenericFont && !mFont->systemFont) {
if (mGenericFont && !mFont.systemFont) {
familyList.Append(mGenericFont->get());
familyList.Append(',');
}
@ -1017,11 +1008,11 @@ nsFontMetricsPango::RealizeFont(void)
// Set the style
pango_font_description_set_style(mPangoFontDesc,
CalculateStyle(mFont->style));
CalculateStyle(mFont.style));
// Set the weight
pango_font_description_set_weight(mPangoFontDesc,
CalculateWeight(mFont->weight));
CalculateWeight(mFont.weight));
// Now that we have the font description set up, create the
// context.

View File

@ -61,7 +61,6 @@ public:
NS_IMETHOD Init (const nsFont& aFont, nsIAtom* aLangGroup,
nsIDeviceContext *aContext);
NS_IMETHOD Destroy();
NS_IMETHOD GetFont (const nsFont *&aFont);
NS_IMETHOD GetLangGroup (nsIAtom** aLangGroup);
NS_IMETHOD GetFontHandle (nsFontHandle &aHandle);
@ -211,7 +210,6 @@ private:
nsIDeviceContext *mDeviceContext;
nsCOMPtr<nsIAtom> mLangGroup;
nsCString *mGenericFont;
nsFont *mFont;
float mPointSize;
nsCAutoString mDefaultFont;

View File

@ -322,8 +322,6 @@ nsFontMetricsXft::nsFontMetricsXft(): mMiniFont(nsnull)
nsFontMetricsXft::~nsFontMetricsXft()
{
delete mFont;
if (mDeviceContext)
mDeviceContext->FontMetricsDeleted(this);
@ -355,14 +353,14 @@ NS_IMETHODIMP
nsFontMetricsXft::Init(const nsFont& aFont, nsIAtom* aLangGroup,
nsIDeviceContext *aContext)
{
mFont = new nsFont(aFont);
mFont = aFont;
mLangGroup = aLangGroup;
// Hang onto the device context
mDeviceContext = aContext;
float app2dev = mDeviceContext->AppUnitsToDevUnits();
mPixelSize = NSTwipsToFloatPixels(mFont->size, app2dev);
mPixelSize = NSTwipsToFloatPixels(mFont.size, app2dev);
// Make sure to clamp the pixel size to something reasonable so we
// don't make the X server blow up.
@ -370,7 +368,7 @@ nsFontMetricsXft::Init(const nsFont& aFont, nsIAtom* aLangGroup,
mPixelSize = PR_MIN(screenPixels * FONT_MAX_FONT_SCALE, mPixelSize);
// enumerate over the font names passed in
mFont->EnumerateFamilies(nsFontMetricsXft::EnumFontCallback, this);
mFont.EnumerateFamilies(nsFontMetricsXft::EnumFontCallback, this);
nsCOMPtr<nsIPref> prefService;
prefService = do_GetService(NS_PREF_CONTRACTID);
@ -458,13 +456,6 @@ nsFontMetricsXft::Destroy()
return NS_OK;
}
NS_IMETHODIMP
nsFontMetricsXft::GetFont(const nsFont *&aFont)
{
aFont = mFont;
return NS_OK;
}
NS_IMETHODIMP
nsFontMetricsXft::GetLangGroup(nsIAtom** aLangGroup)
{
@ -1028,27 +1019,27 @@ nsFontMetricsXft::SetupFCPattern(void)
// If there's a generic add a pref for the generic if there's one
// set.
if (mGenericFont && !mFont->systemFont) {
if (mGenericFont && !mFont.systemFont) {
NS_AddGenericFontFromPref(mGenericFont, mLangGroup, mPattern,
gXftFontLoad);
}
// Add the generic if there is one.
if (mGenericFont && !mFont->systemFont)
if (mGenericFont && !mFont.systemFont)
NS_AddFFRE(mPattern, mGenericFont, PR_FALSE);
if (PR_LOG_TEST(gXftFontLoad, PR_LOG_DEBUG)) {
// generic font
if (mGenericFont && !mFont->systemFont) {
if (mGenericFont && !mFont.systemFont) {
printf("\tadding generic family: %s\n", mGenericFont->get());
}
// pixel size
printf("\tpixel,twip size: %f,%d\n", mPixelSize, mFont->size);
printf("\tpixel,twip size: %f,%d\n", mPixelSize, mFont.size);
// slant type
printf("\tslant: ");
switch(mFont->style) {
switch(mFont.style) {
case NS_FONT_STYLE_ITALIC:
printf("italic\n");
break;
@ -1062,7 +1053,7 @@ nsFontMetricsXft::SetupFCPattern(void)
// weight
printf("\tweight: (orig,calc) %d,%d\n",
mFont->weight, NS_CalculateWeight(mFont->weight));
mFont.weight, NS_CalculateWeight(mFont.weight));
}
@ -1074,11 +1065,11 @@ nsFontMetricsXft::SetupFCPattern(void)
// Add the slant type
FcPatternAddInteger(mPattern, FC_SLANT,
NS_CalculateSlant(mFont->style));
NS_CalculateSlant(mFont.style));
// Add the weight
FcPatternAddInteger(mPattern, FC_WEIGHT,
NS_CalculateWeight(mFont->weight));
NS_CalculateWeight(mFont.weight));
// Set up the default substitutions for this font
FcConfigSubstitute(0, mPattern, FcMatchPattern);
@ -1240,7 +1231,7 @@ nsFontMetricsXft::SetupMiniFont(void)
FcPatternAddInteger(pattern, FC_PIXEL_SIZE, int(0.5 * mPixelSize));
FcPatternAddInteger(pattern, FC_WEIGHT,
NS_CalculateWeight(mFont->weight));
NS_CalculateWeight(mFont.weight));
FcConfigSubstitute(0, pattern, FcMatchPattern);
XftDefaultSubstitute(GDK_DISPLAY(), DefaultScreen(GDK_DISPLAY()),

View File

@ -70,7 +70,6 @@ public:
NS_IMETHOD Init (const nsFont& aFont, nsIAtom* aLangGroup,
nsIDeviceContext *aContext);
NS_IMETHOD Destroy();
NS_IMETHOD GetFont (const nsFont *&aFont);
NS_IMETHOD GetLangGroup (nsIAtom** aLangGroup);
NS_IMETHOD GetFontHandle (nsFontHandle &aHandle);
@ -274,7 +273,6 @@ private:
nsIDeviceContext *mDeviceContext;
nsCOMPtr<nsIAtom> mLangGroup;
nsCString *mGenericFont;
nsFont *mFont;
float mPixelSize;
nsCAutoString mDefaultFont;

View File

@ -49,18 +49,12 @@
nsFontMetricsMac :: nsFontMetricsMac()
{
mFont = nsnull;
mFontNum = BAD_FONT_NUM;
mFontMapping = nsnull;
}
nsFontMetricsMac :: ~nsFontMetricsMac()
{
if (nsnull != mFont)
{
delete mFont;
mFont = nsnull;
}
if (mContext) {
// Notify our device context that owns us so that it can update its font cache
mContext->FontMetricsDeleted(this);
@ -80,7 +74,7 @@ NS_IMETHODIMP nsFontMetricsMac::Init(const nsFont& aFont, nsIAtom* aLangGroup, n
{
NS_ASSERTION(!(nsnull == aCX), "attempt to init fontmetrics with null device context");
mFont = new nsFont(aFont);
mFont = aFont;
mLangGroup = aLangGroup;
mContext = aCX;
RealizeFont();
@ -247,7 +241,7 @@ void nsFontMetricsMac::RealizeFont()
theScriptCode = GetScriptManagerVariable (smSysScript);
FontEnumData fontData(mContext, fontName, theScriptCode);
mFont->EnumerateFamilies(FontEnumCallback, &fontData);
mFont.EnumerateFamilies(FontEnumCallback, &fontData);
nsDeviceContextMac::GetMacFontNumber(fontName, mFontNum);
}
@ -383,11 +377,6 @@ nsresult nsFontMetricsMac :: GetSpaceWidth(nscoord &aSpaceWidth)
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsMac :: GetFont(const nsFont *&aFont)
{
aFont = mFont;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsMac::GetLangGroup(nsIAtom** aLangGroup)
{
if (!aLangGroup) {

View File

@ -80,7 +80,6 @@ public:
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
NS_IMETHOD GetAveCharWidth(nscoord &aAveCharWidth);
NS_IMETHOD GetWidths(const nscoord *&aWidths);
NS_IMETHOD GetFont(const nsFont *&aFont);
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
NS_IMETHOD GetFontHandle(nsFontHandle& aHandle);
NS_IMETHOD GetSpaceWidth(nscoord& aSpaceCharWidth);
@ -104,7 +103,6 @@ protected:
nscoord mSpaceWidth;
nscoord mXHeight;
nsCOMPtr<nsIAtom> mLangGroup;
nsFont *mFont;
nsIDeviceContext *mContext;
};

View File

@ -77,10 +77,8 @@ void
nsFontUtils::GetNativeTextStyle(nsIFontMetrics& inMetrics,
const nsIDeviceContext& inDevContext, TextStyle &outStyle)
{
const nsFont *aFont;
inMetrics.GetFont(aFont);
const nsFont *aFont = &inMetrics.Font();
nsFontHandle fontNum;
inMetrics.GetFontHandle(fontNum);

View File

@ -1319,8 +1319,7 @@ nsUnicodeRenderingToolkit::GetTextSegmentDimensions(
((processLen+1) < aLength) &&
IS_LOW_SURROGATE(*(aString+1)))
{
const nsFont *font;
mGS->mFontMetrics->GetFont(font);
const nsFont *font = &mGS->mFontMetrics->Font();
fallbackDone = SurrogateGetDimensions(aString, segDim, fontNum,
font->size,
(font->weight > NS_FONT_WEIGHT_NORMAL),
@ -1350,8 +1349,7 @@ nsUnicodeRenderingToolkit::GetTextSegmentDimensions(
// Fallback by using ATSUI
if (!fallbackDone)
{
const nsFont *font;
mGS->mFontMetrics->GetFont(font);
const nsFont *font = &mGS->mFontMetrics->Font();
fallbackDone = ATSUIFallbackGetDimensions(aString, segDim, fontNum,
font->size,
(font->weight > NS_FONT_WEIGHT_NORMAL),
@ -1506,8 +1504,7 @@ nsUnicodeRenderingToolkit::GetTextSegmentBoundingMetrics(
((processLen+1) < aLength) &&
IS_LOW_SURROGATE(*(aString+1)) )
{
const nsFont *font;
mGS->mFontMetrics->GetFont(font);
const nsFont *font = &mGS->mFontMetrics->Font();
fallbackDone = SurrogateGetBoundingMetrics(aString, segBoundingMetrics, fontNum,
font->size,
(font->weight > NS_FONT_WEIGHT_NORMAL),
@ -1536,8 +1533,7 @@ nsUnicodeRenderingToolkit::GetTextSegmentBoundingMetrics(
// Fallback by using ATSUI
if (!fallbackDone)
{
const nsFont *font;
mGS->mFontMetrics->GetFont(font);
const nsFont *font = &mGS->mFontMetrics->Font();
fallbackDone = ATSUIFallbackGetBoundingMetrics(aString, segBoundingMetrics, fontNum,
font->size,
(font->weight > NS_FONT_WEIGHT_NORMAL),
@ -1648,8 +1644,7 @@ nsresult nsUnicodeRenderingToolkit :: DrawTextSegment(
((processLen+1) < aLength) &&
IS_LOW_SURROGATE(*(aString+1)) )
{
const nsFont *font;
mGS->mFontMetrics->GetFont(font);
const nsFont *font = &mGS->mFontMetrics->Font();
fallbackDone = SurrogateDrawChar(aString, x, y, thisWidth, fontNum,
font->size,
(font->weight > NS_FONT_WEIGHT_NORMAL),
@ -1677,8 +1672,7 @@ nsresult nsUnicodeRenderingToolkit :: DrawTextSegment(
#ifndef DISABLE_ATSUI_FALLBACK
// Fallback by using ATSUI
if(! fallbackDone) {
const nsFont *font;
mGS->mFontMetrics->GetFont(font);
const nsFont *font = &mGS->mFontMetrics->Font();
fallbackDone = ATSUIFallbackDrawChar(aString, x, y, thisWidth, fontNum,
font->size,
(font->weight > NS_FONT_WEIGHT_NORMAL),

View File

@ -622,9 +622,7 @@ nsFontCache::GetMetricsFor(const nsFont& aFont, nsIAtom* aLangGroup,
PRInt32 n = mFontMetrics.Count() - 1;
for (PRInt32 i = n; i >= 0; --i) {
fm = NS_STATIC_CAST(nsIFontMetrics*, mFontMetrics[i]);
const nsFont* font;
fm->GetFont(font);
if (font->Equals(aFont)) {
if (fm->Font().Equals(aFont)) {
nsCOMPtr<nsIAtom> langGroup;
fm->GetLangGroup(getter_AddRefs(langGroup));
if (aLangGroup == langGroup.get()) {

View File

@ -60,7 +60,6 @@ NS_NewRegressionTestFontMetrics(nsIFontMetrics** aMetrics)
nsRegressionTestFontMetrics:: nsRegressionTestFontMetrics()
{
mFont = nsnull;
mDeviceContext = nsnull;
mHeight = 0;
@ -83,11 +82,6 @@ NS_IMPL_ISUPPORTS1(nsRegressionTestFontMetrics, nsIFontMetrics)
nsRegressionTestFontMetrics::~nsRegressionTestFontMetrics()
{
if (nsnull != mFont)
{
delete mFont;
mFont = nsnull;
}
mDeviceContext = nsnull;
}
@ -95,7 +89,7 @@ nsRegressionTestFontMetrics::~nsRegressionTestFontMetrics()
NS_IMETHODIMP
nsRegressionTestFontMetrics::Init(const nsFont& aFont, nsIDeviceContext *aContext)
{
mFont = new nsFont(aFont);
mFont = aFont;
mDeviceContext = aContext;
RealizeFont();
return NS_OK;
@ -114,7 +108,7 @@ nsRegressionTestFontMetrics::RealizeFont()
float dev2app;
dev2app = mDeviceContext->DevUnitsToAppUnits();
nscoord onepixel = NSToCoordRound(1 * dev2app);
PRUint32 fontsize = mFont->size;
PRUint32 fontsize = mFont.size;
// Most of the numbers are just made up....
// feel free to play around.
@ -152,7 +146,7 @@ nsRegressionTestFontMetrics::RealizeFont()
NS_METHOD
nsRegressionTestFontMetrics::GetWidth(const char aChar, nscoord& aWidth)
{
float size = (float)mFont->size;
float size = (float)mFont.size;
aWidth = 0;
if(aChar == ' ')
@ -179,7 +173,7 @@ nsRegressionTestFontMetrics::GetWidth(const char aChar, nscoord& aWidth)
NS_METHOD
nsRegressionTestFontMetrics::GetWidth(const PRUnichar aChar,nscoord& aWidth)
{
float size = (float)mFont->size;
float size = (float)mFont.size;
aWidth = 0;
if(aChar == ' ')
@ -218,7 +212,7 @@ nsRegressionTestFontMetrics::GetWidth(const PRUnichar* aString, PRUint32 aLength
float totalsize = 0;
for(PRUint32 index = 0; index < aLength; index++){
size = (float)mFont->size;
size = (float)mFont.size;
if(aString[index] == ' ')
size *= MAPPING_FACTOR_FOR_SPACE;
else if(aString[index] >= 'a' && aString[index] <= 'z')
@ -255,7 +249,7 @@ nsRegressionTestFontMetrics::GetWidth(const char* aString, PRUint32 aLength, nsc
float totalsize = 0;
for(PRUint32 index=0; index < aLength; index++){
size = (float)mFont->size;
size = (float)mFont.size;
if(aString[index] == ' ')
size *= MAPPING_FACTOR_FOR_SPACE;
else if(aString[index] >= 'a' && aString[index] <= 'z')
@ -340,13 +334,6 @@ nsRegressionTestFontMetrics::GetMaxAdvance(nscoord &aAdvance)
return NS_OK;
}
NS_IMETHODIMP
nsRegressionTestFontMetrics::GetFont(const nsFont *&aFont)
{
aFont = mFont;
return NS_OK;
}
NS_IMETHODIMP
nsRegressionTestFontMetrics::GetFontHandle(nsFontHandle &aHandle)
{
//We don't have a font handler

View File

@ -67,7 +67,6 @@ public:
NS_IMETHOD GetMaxAscent(nscoord &aAscent);
NS_IMETHOD GetMaxDescent(nscoord &aDescent);
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
NS_IMETHOD GetFont(const nsFont *&aFont);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
NS_METHOD GetWidth(const char aChar, nscoord& aWidth);
@ -80,7 +79,6 @@ protected:
void RealizeFont();
nsIDeviceContext *mDeviceContext;
nsFont *mFont;
nscoord mHeight;
nscoord mAscent;
nscoord mDescent;

View File

@ -1537,12 +1537,6 @@ NS_IMETHODIMP nsFontMetricsOS2::GetMaxAdvance( nscoord &aAdvance)
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsOS2::GetFont( const nsFont *&aFont)
{
aFont = &mFont;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsOS2::GetFontHandle( nsFontHandle &aHandle)
{
aHandle = mFontHandle;

View File

@ -246,7 +246,6 @@ public:
NS_IMETHOD GetMaxAscent(nscoord &aAscent);
NS_IMETHOD GetMaxDescent(nscoord &aDescent);
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
NS_IMETHOD GetFont(const nsFont *&aFont);
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
NS_IMETHOD GetAveCharWidth(nscoord &aAveCharWidth);
@ -316,8 +315,6 @@ protected:
nsMiniMetrics* aMetrics, PRBool aDoFakeEffects);
PLHashTable* InitializeFamilyNames(void);
nsFont mFont;
nscoord mSuperscriptYOffset;
nscoord mSubscriptYOffset;
nscoord mStrikeoutPosition;

View File

@ -61,7 +61,6 @@ static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
nsFontMetricsPh::nsFontMetricsPh()
{
mDeviceContext = nsnull;
mFont = nsnull;
mHeight = 0;
mAscent = 0;
@ -118,11 +117,6 @@ static void FreeGlobals()
nsFontMetricsPh :: ~nsFontMetricsPh( )
{
if( nsnull != mFont )
{
delete mFont;
mFont = nsnull;
}
if (mFontHandle)
free (mFontHandle);
if (mDeviceContext) {
@ -148,7 +142,7 @@ NS_IMETHODIMP nsFontMetricsPh::Init ( const nsFont& aFont, nsIAtom* aLangGroup,
if( NS_FAILED(res) ) return res;
}
mFont = new nsFont(aFont);
mFont = aFont;
mLangGroup = aLangGroup;
mDeviceContext = aContext;
@ -186,9 +180,9 @@ printf( "\n\n\t\t\tIn nsFontMetricsPh::Init str=%s\n", str );
app2dev = mDeviceContext->AppUnitsToDevUnits();
PRInt32 sizePoints;
if( mFont->systemFont == PR_TRUE )
sizePoints = NSToIntRound( app2dev * mFont->size * 0.68 );
else sizePoints = NSToIntRound( app2dev * mFont->size * 0.74 );
if( mFont.systemFont == PR_TRUE )
sizePoints = NSToIntRound( app2dev * mFont.size * 0.68 );
else sizePoints = NSToIntRound( app2dev * mFont.size * 0.74 );
char NSFullFontName[MAX_FONT_TAG];

View File

@ -161,11 +161,6 @@ public:
aAveCharWidth = mAveCharWidth;
return NS_OK;
}
inline NS_IMETHODIMP GetFont(const nsFont *&aFont)
{
aFont = mFont;
return NS_OK;
}
inline NS_IMETHODIMP GetFontHandle(nsFontHandle &aHandle)
{
aHandle = (nsFontHandle) mFontHandle;
@ -181,7 +176,6 @@ protected:
void RealizeFont();
nsIDeviceContext *mDeviceContext;
nsFont *mFont;
char *mFontHandle; /* Photon Fonts are just a string */
nscoord mHeight;
nscoord mAscent;

View File

@ -92,11 +92,6 @@ nsFontMetricsPS :: nsFontMetricsPS()
*/
nsFontMetricsPS :: ~nsFontMetricsPS()
{
if (nsnull != mFont){
delete mFont;
mFont = nsnull;
}
if (mFontsPS) {
int i;
for (i=0; i<mFontsPS->Count(); i++) {
@ -145,7 +140,7 @@ nsFontMetricsPS :: Init(const nsFont& aFont, nsIAtom* aLangGroup,
{
mLangGroup = aLangGroup;
mFont = new nsFont(aFont);
mFont = aFont;
//don't addref this to avoid circular refs
mDeviceContext = (nsDeviceContextPS *)aContext;
@ -178,14 +173,14 @@ nsFontMetricsPS :: Destroy()
void
nsFontMetricsPS::RealizeFont()
{
if (mFont && mDeviceContext) {
if (mDeviceContext) {
float dev2app;
dev2app = mDeviceContext->DevUnitsToAppUnits();
fontps *font = (fontps*)mFontsPS->ElementAt(0);
#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
NS_ASSERTION(font && font->entry, "no font available");
if (font && !font->fontps && font->entry)
font->fontps = CreateFontPS(font->entry, *mFont, this);
font->fontps = CreateFontPS(font->entry, mFont, this);
#endif
NS_ASSERTION(font && font->fontps, "no font available");
if (font && font->fontps)
@ -373,17 +368,6 @@ nsFontMetricsPS :: GetSpaceWidth(nscoord &aSpaceWidth)
return NS_OK;
}
/** ---------------------------------------------------
* See documentation in nsFontMetricsPS.h
* @update 2/26/99 dwc
*/
NS_IMETHODIMP
nsFontMetricsPS :: GetFont(const nsFont *&aFont)
{
aFont = mFont;
return NS_OK;
}
NS_IMETHODIMP
nsFontMetricsPS :: GetLangGroup(nsIAtom** aLangGroup)
{
@ -418,12 +402,12 @@ nsFontMetricsPS :: GetStringWidth(const char *aString,nscoord& aWidth,nscoord aL
aWidth = 0;
if (aLength == 0)
return NS_OK;
nsFontPS* fontPS = nsFontPS::FindFont(aString[0], *mFont, this);
nsFontPS* fontPS = nsFontPS::FindFont(aString[0], mFont, this);
NS_ENSURE_TRUE(fontPS, NS_ERROR_FAILURE);
nscoord i, start = 0;
for (i=0; i<aLength; i++) {
nsFontPS* fontThisChar = nsFontPS::FindFont(aString[i], *mFont, this);
nsFontPS* fontThisChar = nsFontPS::FindFont(aString[i], mFont, this);
NS_ASSERTION(fontThisChar,"failed to find a font");
NS_ENSURE_TRUE(fontThisChar, NS_ERROR_FAILURE);
if (fontThisChar != fontPS) {
@ -451,12 +435,12 @@ nsFontMetricsPS :: GetStringWidth(const PRUnichar *aString,nscoord& aWidth,nscoo
aWidth = 0;
if (aLength == 0)
return NS_OK;
nsFontPS* fontPS = nsFontPS::FindFont(aString[0], *mFont, this);
nsFontPS* fontPS = nsFontPS::FindFont(aString[0], mFont, this);
NS_ENSURE_TRUE(fontPS, NS_ERROR_FAILURE);
nscoord i, start = 0;
for (i=0; i<aLength; i++) {
nsFontPS* fontThisChar = nsFontPS::FindFont(aString[i], *mFont, this);
nsFontPS* fontThisChar = nsFontPS::FindFont(aString[i], mFont, this);
NS_ASSERTION(fontThisChar,"failed to find a font");
NS_ENSURE_TRUE(fontThisChar, NS_ERROR_FAILURE);
if (fontThisChar != fontPS) {

View File

@ -104,7 +104,6 @@ public:
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
NS_IMETHOD GetAveCharWidth(nscoord &aAveCharWidth);
NS_IMETHOD GetSpaceWidth(nscoord& aAveCharWidth);
NS_IMETHOD GetFont(const nsFont *&aFont);
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
NS_IMETHOD GetStringWidth(const char *String,nscoord &aWidth,nscoord aLength);
@ -130,7 +129,6 @@ public:
inline void SetSpaceWidth(nscoord aSpaceWidth) { mSpaceWidth = aSpaceWidth; };
inline nsDeviceContextPS* GetDeviceContext() { return mDeviceContext; }
inline nsFont* GetFont() { return mFont; };
inline nsVoidArray* GetFontsPS() { return mFontsPS; };
inline nsHashtable *GetFontsAlreadyLoadedList() {return mFontsAlreadyLoaded;};
inline int GetFontPSState() { return mFontPSState; };
@ -154,7 +152,6 @@ protected:
void RealizeFont();
nsDeviceContextPS *mDeviceContext;
nsFont *mFont;
nscoord mHeight;
nscoord mAscent;
nscoord mDescent;

View File

@ -1080,14 +1080,14 @@ nsRenderingContextPS :: DrawString(const char *aString, PRUint32 aLength,
if (aLength == 0)
return NS_OK;
nsFontPS* fontPS = nsFontPS::FindFont(aString[0], *metrics->GetFont(), metrics);
nsFontPS* fontPS = nsFontPS::FindFont(aString[0], metrics->Font(), metrics);
NS_ENSURE_TRUE(fontPS, NS_ERROR_FAILURE);
fontPS->SetupFont(this);
PRUint32 i, start = 0;
for (i=0; i<aLength; i++) {
nsFontPS* fontThisChar;
fontThisChar = nsFontPS::FindFont(aString[i], *metrics->GetFont(), metrics);
fontThisChar = nsFontPS::FindFont(aString[i], metrics->Font(), metrics);
NS_ENSURE_TRUE(fontThisChar, NS_ERROR_FAILURE);
if (fontThisChar != fontPS) {
// draw text up to this point
@ -1132,14 +1132,14 @@ nsRenderingContextPS :: DrawString(const PRUnichar *aString, PRUint32 aLength,
if (aLength == 0)
return NS_OK;
nsFontPS* fontPS = nsFontPS::FindFont(aString[0], *metrics->GetFont(), metrics);
nsFontPS* fontPS = nsFontPS::FindFont(aString[0], metrics->Font(), metrics);
NS_ENSURE_TRUE(fontPS, NS_ERROR_FAILURE);
fontPS->SetupFont(this);
PRUint32 i, start = 0;
for (i=0; i<aLength; i++) {
nsFontPS* fontThisChar;
fontThisChar = nsFontPS::FindFont(aString[i], *metrics->GetFont(), metrics);
fontThisChar = nsFontPS::FindFont(aString[i], metrics->Font(), metrics);
NS_ENSURE_TRUE(fontThisChar, NS_ERROR_FAILURE);
if (fontThisChar != fontPS) {
// draw text up to this point

View File

@ -65,12 +65,11 @@
nsFontQt::nsFontQt(const nsFont &aFont, nsIAtom *aLangGroup, nsIDeviceContext *aContext)
{
mFont = aFont;
mLangGroup = aLangGroup;
mDeviceContext = aContext;
float a2d = aContext->AppUnitsToDevUnits();
mPixelSize = NSToIntRound(a2d * mFont.size);
mPixelSize = NSToIntRound(a2d * aFont.size);
if (mLangGroup) {
nsCAutoString name("font.min-size.variable.");
@ -93,10 +92,10 @@ nsFontQt::nsFontQt(const nsFont &aFont, nsIAtom *aLangGroup, nsIDeviceContext *a
}
}
font.setFamily(QString::fromUcs2(mFont.name.get()));
font.setFamily(QString::fromUcs2(aFont.name.get()));
font.setPixelSize(mPixelSize);
font.setWeight(mFont.weight/10);
font.setItalic(mFont.style != NS_FONT_STYLE_NORMAL);
font.setWeight(aFont.weight/10);
font.setItalic(aFont.style != NS_FONT_STYLE_NORMAL);
RealizeFont();
}
@ -152,6 +151,7 @@ NS_IMPL_ISUPPORTS1(nsFontMetricsQt,nsIFontMetrics)
{
NS_ASSERTION(!(nsnull == aContext), "attempt to init fontmetrics with null device context");
mFont = aFont;
qFont = new nsFontQt(aFont, aLangGroup, aContext);
return NS_OK;
}
@ -267,12 +267,6 @@ NS_IMETHODIMP nsFontMetricsQt::GetSpaceWidth(nscoord &aSpaceWidth)
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsQt::GetFont(const nsFont *&aFont)
{
aFont = &qFont->mFont;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsQt::GetLangGroup(nsIAtom **aLangGroup)
{
if (!aLangGroup) {

View File

@ -83,7 +83,6 @@ public:
nsIDeviceContext *mDeviceContext;
nsCOMPtr<nsIAtom> mLangGroup;
nsFont mFont;
nscoord mLeading;
nscoord mEmHeight;
@ -140,7 +139,6 @@ public:
NS_IMETHOD GetMaxDescent(nscoord &aDescent);
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
NS_IMETHOD GetAveCharWidth(nscoord &aAveCharWidth);
NS_IMETHOD GetFont(const nsFont *&aFont);
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);

View File

@ -3833,13 +3833,6 @@ nsFontMetricsWin::GetAveCharWidth(nscoord &aAveCharWidth)
return NS_OK;
}
NS_IMETHODIMP
nsFontMetricsWin::GetFont(const nsFont *&aFont)
{
aFont = &mFont;
return NS_OK;
}
NS_IMETHODIMP
nsFontMetricsWin::GetLangGroup(nsIAtom** aLangGroup)
{

View File

@ -239,7 +239,6 @@ public:
NS_IMETHOD GetMaxAscent(nscoord &aAscent);
NS_IMETHOD GetMaxDescent(nscoord &aDescent);
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
NS_IMETHOD GetFont(const nsFont *&aFont);
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
NS_IMETHOD GetAveCharWidth(nscoord &aAveCharWidth);
@ -343,7 +342,6 @@ protected:
static PLHashTable* InitializeFamilyNames(void);
nsDeviceContextWin *mDeviceContext;
nsFont mFont;
HFONT mFontHandle;

View File

@ -1882,11 +1882,6 @@ nsFontMetricsXlib::~nsFontMetricsXlib()
{
// do not free mGeneric here
if (nsnull != mFont) {
delete mFont;
mFont = nsnull;
}
if (mLoadedFonts) {
PR_Free(mLoadedFonts);
mLoadedFonts = nsnull;
@ -1964,21 +1959,21 @@ NS_IMETHODIMP nsFontMetricsXlib::Init(const nsFont& aFont, nsIAtom* aLangGroup,
NS_STATIC_CAST(nsDeviceContextX *, mDeviceContext)->GetFontMetricsContext(mFontMetricsContext);
mFont = new nsFont(aFont);
mFont = aFont;
mLangGroup = aLangGroup;
float app2dev;
app2dev = mDeviceContext->AppUnitsToDevUnits();
mPixelSize = NSToIntRound(app2dev * mFont->size);
mPixelSize = NSToIntRound(app2dev * mFont.size);
// Make sure to clamp the pixel size to something reasonable so we
// don't make the X server blow up.
mPixelSize = PR_MIN(XHeightOfScreen(xxlib_rgb_get_screen(mFontMetricsContext->mXlibRgbHandle)) * FONT_MAX_FONT_SCALE, mPixelSize);
mStretchIndex = 4; // Normal
mStyleIndex = mFont->style;
mStyleIndex = mFont.style;
mFont->EnumerateFamilies(FontEnumCallback, this);
mFont.EnumerateFamilies(FontEnumCallback, this);
nsXPIDLCString value;
if (!mGeneric) {
mFontMetricsContext->mPref->CopyCharPref("font.default", getter_Copies(value));
@ -2365,13 +2360,6 @@ NS_IMETHODIMP nsFontMetricsXlib::GetAveCharWidth(nscoord &aAveCharWidth)
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsXlib::GetFont(const nsFont*& aFont)
{
aFont = mFont;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsXlib::GetLangGroup(nsIAtom** aLangGroup)
{
if (!aLangGroup) {
@ -4311,7 +4299,7 @@ nsFontMetricsXlib::SearchNode(nsFontNodeXlib* aNode, PRUnichar aChar)
nsFontStyleXlib* style = aNode->mStyles[mStyleIndex];
nsFontWeightXlib** weights = style->mWeights;
int weight = mFont->weight;
int weight = mFont.weight;
int steps = (weight % 100);
int weightIndex;
if (steps) {

View File

@ -371,7 +371,6 @@ public:
NS_IMETHOD GetMaxDescent(nscoord &aDescent);
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
NS_IMETHOD GetAveCharWidth(nscoord &aAveCharWidth);
NS_IMETHOD GetFont(const nsFont *&aFont);
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
@ -434,7 +433,6 @@ protected:
void RealizeFont();
nsFontXlib *LocateFont(PRUint32 aChar, PRInt32 & aCount);
nsFont *mFont;
nsFontXlib *mWesternFont;
nscoord mLeading;

View File

@ -2129,9 +2129,7 @@ nsRenderingContextXlib::DrawString(const char *aString, PRUint32 aLength,
//will take it's place that will need this code again. MMP
if (mFontMetrics)
{
const nsFont *font;
mFontMetrics->GetFont(font);
PRUint8 deco = font->decorations;
PRUint8 deco = mFontMetrics->Font().decorations;
if (deco & NS_FONT_DECORATION_OVERLINE)
DrawLine(aX, aY, aX + aWidth, aY);

View File

@ -251,13 +251,10 @@ nsMathMLFrame::GetRuleThickness(nsIRenderingContext& aRenderingContext,
// get the bounding metrics of the overbar char, the rendering context
// is assumed to have been set with the font of the current style context
#ifdef NS_DEBUG
const nsFont* myFont;
aFontMetrics->GetFont(myFont);
nsCOMPtr<nsIFontMetrics> currFontMetrics;
aRenderingContext.GetFontMetrics(*getter_AddRefs(currFontMetrics));
const nsFont* currFont;
currFontMetrics->GetFont(currFont);
NS_ASSERTION(currFont->Equals(*myFont), "unexpected state");
NS_ASSERTION(currFontMetrics->Font().Equals(aFontMetrics->Font()),
"unexpected state");
#endif
nscoord xHeight;
aFontMetrics->GetXHeight(xHeight);
@ -293,13 +290,10 @@ nsMathMLFrame::GetAxisHeight(nsIRenderingContext& aRenderingContext,
// get the bounding metrics of the minus sign, the rendering context
// is assumed to have been set with the font of the current style context
#ifdef NS_DEBUG
const nsFont* myFont;
aFontMetrics->GetFont(myFont);
nsCOMPtr<nsIFontMetrics> currFontMetrics;
aRenderingContext.GetFontMetrics(*getter_AddRefs(currFontMetrics));
const nsFont* currFont;
currFontMetrics->GetFont(currFont);
NS_ASSERTION(currFont->Equals(*myFont), "unexpected state");
NS_ASSERTION(currFontMetrics->Font().Equals(aFontMetrics->Font()),
"unexpected state");
#endif
nscoord xHeight;
aFontMetrics->GetXHeight(xHeight);

View File

@ -370,9 +370,7 @@ public:
// should switch to this API in order to scale with changes of TextZoom
fm->GetEmHeight(emHeight);
#else
const nsFont* font;
fm->GetFont(font);
emHeight = NSToCoordRound(float(font->size));
emHeight = NSToCoordRound(float(fm->Font().size));
#endif
}