Fix the Font methods. This allows the pages to be rendered.. under something

so we still can't see it.. i'm looking
This commit is contained in:
pavlov%pavlov.net 1998-11-14 01:43:27 +00:00
parent fbe9c5461a
commit 5f6f52a7b2
3 changed files with 43 additions and 19 deletions

View File

@ -17,7 +17,6 @@
*/
#include <math.h>
#include <gtk/gtk.h>
#include "nspr.h"
#include "il_util.h"
@ -25,6 +24,9 @@
#include "nsDeviceContextGTK.h"
#include "../nsGfxCIID.h"
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
@ -116,7 +118,41 @@ NS_IMETHODIMP nsDeviceContextGTK::ConvertPixel(nscolor aColor,
NS_IMETHODIMP nsDeviceContextGTK::CheckFontExistence(const nsString& aFontName)
{
return NS_OK;
char **fnames = nsnull;
PRInt32 namelen = aFontName.Length() + 1;
char *wildstring = (char *)PR_Malloc(namelen + 200);
float t2d;
GetTwipsToDevUnits(t2d);
PRInt32 dpi = NSToIntRound(t2d * 1440);
int numnames = 0;
XFontStruct *fonts;
nsresult rv = NS_ERROR_FAILURE;
if (nsnull == wildstring)
return NS_ERROR_UNEXPECTED;
if (abs(dpi - 75) < abs(dpi - 100))
dpi = 75;
else
dpi = 100;
char* fontName = aFontName.ToNewCString();
PR_snprintf(wildstring, namelen + 200,
"*-%s-*-*-normal--*-*-%d-%d-*-*-*",
fontName, dpi, dpi);
delete [] fontName;
fnames = ::XListFontsWithInfo(GDK_DISPLAY(), wildstring, 1, &numnames, &fonts);
if (numnames > 0)
{
::XFreeFontInfo(fnames, fonts, numnames);
rv = NS_OK;
}
PR_Free(wildstring);
return rv;
}

View File

@ -24,6 +24,7 @@
#include <gdk/gdkx.h>
#define NOISY_FONTS 1
static NS_DEFINE_IID(kIFontMetricsIID, NS_IFONT_METRICS_IID);

View File

@ -401,18 +401,7 @@ NS_IMETHODIMP nsRenderingContextGTK::SetFont(const nsFont& aFont)
{
NS_IF_RELEASE(mFontMetrics);
mContext->GetMetricsFor(aFont, mFontMetrics);
if (mFontMetrics)
{
nsFontHandle fontHandle;
mFontMetrics->GetFontHandle(fontHandle);
mCurrentFont = (GdkFont *)fontHandle;
gdk_gc_set_font(mRenderingSurface->gc,
mCurrentFont);
return NS_OK;
}
else
return NS_ERROR_FAILURE;
return SetFont(mFontMetrics);
}
NS_IMETHODIMP nsRenderingContextGTK::SetFont(nsIFontMetrics *aFontMetrics)
@ -444,10 +433,8 @@ NS_IMETHODIMP nsRenderingContextGTK::GetLineStyle(nsLineStyle &aLineStyle)
NS_IMETHODIMP nsRenderingContextGTK::GetFontMetrics(nsIFontMetrics *&aFontMetrics)
{
if (mFontMetrics)
aFontMetrics = mFontMetrics;
else
aFontMetrics = nsnull;
NS_IF_ADDREF(mFontMetrics);
aFontMetrics = mFontMetrics;
return NS_OK;
}
@ -820,7 +807,7 @@ nsRenderingContextGTK::DrawString(const char *aString, PRUint32 aLength,
{
nscoord ascent,descent;
mFontMetrics->GetMaxAscent(ascent);
mFontMetrics->GetMaxAscent(ascent);
mFontMetrics->GetMaxDescent(descent);
DrawLine(aX, aY + ascent + (descent >> 1),