port of gtk's font code to xlib
git-svn-id: svn://10.0.0.236/trunk@30901 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -25,14 +25,64 @@
|
||||
#include "nsUnitConversion.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsDeviceContextXlib.h"
|
||||
#include "nsDrawingSurfaceXlib.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xos.h>
|
||||
|
||||
#define FONT_SWITCHING
|
||||
#ifdef FONT_SWITCHING
|
||||
|
||||
#ifdef ADD_GLYPH
|
||||
#undef ADD_GLYPH
|
||||
#endif
|
||||
#define ADD_GLYPH(map, g) (map)[(g) >> 3] |= (1 << ((g) & 7))
|
||||
|
||||
#ifdef FONT_HAS_GLYPH
|
||||
#undef FONT_HAS_GLYPH
|
||||
#endif
|
||||
#define FONT_HAS_GLYPH(map, g) (((map)[(g) >> 3] >> ((g) & 7)) & 1)
|
||||
|
||||
typedef struct nsFontCharSetInfo nsFontCharSetInfo;
|
||||
|
||||
typedef int (*nsFontCharSetConverter)(nsFontCharSetInfo* aSelf,
|
||||
const PRUnichar* aSrcBuf, PRUint32 aSrcLen, PRUint8* aDestBuf,
|
||||
PRUint32 aDestLen);
|
||||
|
||||
struct nsFontCharSet;
|
||||
class nsFontMetricsXlib;
|
||||
|
||||
struct nsFontXlib
|
||||
{
|
||||
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
||||
|
||||
void LoadFont(nsFontCharSet* aCharSet, nsFontMetricsXlib* aMetrics);
|
||||
|
||||
Font mFont;
|
||||
PRUint8* mMap;
|
||||
nsFontCharSetInfo* mCharSetInfo;
|
||||
char* mName;
|
||||
PRUint16 mSize;
|
||||
PRUint16 mActualSize;
|
||||
PRInt16 mBaselineAdjust;
|
||||
};
|
||||
|
||||
struct nsFontStretch;
|
||||
struct nsFontFamily;
|
||||
typedef struct nsFontSearch nsFontSearch;
|
||||
|
||||
#endif /* FONT_SWITCHING */
|
||||
|
||||
class nsFontMetricsXlib : public nsIFontMetrics
|
||||
{
|
||||
public:
|
||||
public:
|
||||
nsFontMetricsXlib();
|
||||
virtual ~nsFontMetricsXlib();
|
||||
|
||||
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(const nsFont& aFont, nsIDeviceContext* aContext);
|
||||
@@ -52,9 +102,63 @@ class nsFontMetricsXlib : public nsIFontMetrics
|
||||
NS_IMETHOD GetFont(const nsFont *&aFont);
|
||||
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
|
||||
|
||||
protected:
|
||||
#ifdef FONT_SWITCHING
|
||||
|
||||
nsFontXlib* FindFont(PRUnichar aChar);
|
||||
static int GetWidth(nsFontXlib* aFont, const PRUnichar* aString,
|
||||
PRUint32 aLength);
|
||||
static void DrawString(nsDrawingSurfaceXlib* aSurface, nsFontXlib* aFont,
|
||||
nscoord aX, nscoord aY, const PRUnichar* aString,
|
||||
PRUint32 aLength);
|
||||
static void InitFonts(void);
|
||||
|
||||
friend void PickASizeAndLoad(nsFontSearch* aSearch, nsFontStretch* aStretch,
|
||||
nsFontCharSet* aCharSet);
|
||||
friend void TryCharSet(nsFontSearch* aSearch, nsFontCharSet* aCharSet);
|
||||
friend void TryFamily(nsFontSearch* aSearch, nsFontFamily* aFamily);
|
||||
friend struct nsFontXlib;
|
||||
|
||||
nsFontXlib **mLoadedFonts;
|
||||
PRUint16 mLoadedFontsAlloc;
|
||||
PRUint16 mLoadedFontsCount;
|
||||
|
||||
nsString *mFonts;
|
||||
PRUint16 mFontsAlloc;
|
||||
PRUint16 mFontsCount;
|
||||
PRUint16 mFontsIndex;
|
||||
|
||||
#endif /* FONT_SWITCHING */
|
||||
|
||||
protected:
|
||||
char *PickAppropriateSize(char **names, XFontStruct *fonts, int cnt, nscoord desired);
|
||||
void RealizeFont();
|
||||
|
||||
nsIDeviceContext *mDeviceContext;
|
||||
nsFont *mFont;
|
||||
Font mFontHandle;
|
||||
|
||||
nscoord mHeight;
|
||||
nscoord mAscent;
|
||||
nscoord mDescent;
|
||||
nscoord mLeading;
|
||||
nscoord mMaxAscent;
|
||||
nscoord mMaxDescent;
|
||||
nscoord mMaxAdvance;
|
||||
nscoord mXHeight;
|
||||
nscoord mSuperscriptOffset;
|
||||
nscoord mSubscriptOffset;
|
||||
nscoord mStrikeoutSize;
|
||||
nscoord mStrikeoutOffset;
|
||||
nscoord mUnderlineSize;
|
||||
nscoord mUnderlineOffset;
|
||||
|
||||
#ifdef FONT_SWITCHING
|
||||
|
||||
PRUint16 mPixelSize;
|
||||
PRUint8 mStretchIndex;
|
||||
PRUint8 mStyleIndex;
|
||||
|
||||
#endif /* FONT_SWITCHING */
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -32,6 +32,7 @@ nsRenderingContextXlib::nsRenderingContextXlib()
|
||||
mFontMetrics = nsnull;
|
||||
mContext = nsnull;
|
||||
mScriptObject = nsnull;
|
||||
mCurrentFont = 0;
|
||||
}
|
||||
|
||||
nsRenderingContextXlib::~nsRenderingContextXlib()
|
||||
@@ -268,13 +269,26 @@ NS_IMETHODIMP
|
||||
nsRenderingContextXlib::SetFont(const nsFont& aFont)
|
||||
{
|
||||
printf("nsRenderingContextXlib::SetFont()\n");
|
||||
return NS_OK;
|
||||
NS_IF_RELEASE(mFontMetrics);
|
||||
mContext->GetMetricsFor(aFont, mFontMetrics);
|
||||
return SetFont(mFontMetrics);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::SetFont(nsIFontMetrics *aFontMetrics)
|
||||
{
|
||||
printf("nsRenderingContextXlib::SetFont()\n");
|
||||
NS_IF_RELEASE(mFontMetrics);
|
||||
mFontMetrics = aFontMetrics;
|
||||
NS_IF_ADDREF(mFontMetrics);
|
||||
|
||||
if (mFontMetrics)
|
||||
{
|
||||
nsFontHandle fontHandle;
|
||||
mFontMetrics->GetFontHandle(fontHandle);
|
||||
mCurrentFont = (Font)fontHandle;
|
||||
XSetFont(gDisplay, mRenderingSurface->GetGC(), mCurrentFont);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -282,6 +296,8 @@ NS_IMETHODIMP
|
||||
nsRenderingContextXlib::GetFontMetrics(nsIFontMetrics *&aFontMetrics)
|
||||
{
|
||||
printf("nsRenderingContextXlib::GetFontMetrics()\n");
|
||||
NS_IF_ADDREF(mFontMetrics);
|
||||
aFontMetrics = mFontMetrics;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,6 +165,7 @@ private:
|
||||
nsIFontMetrics *mFontMetrics;
|
||||
nsIDeviceContext *mContext;
|
||||
void *mScriptObject;
|
||||
Font mCurrentFont;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
8196
mozilla/gfx/src/xlib/u2j208.h
Normal file
8196
mozilla/gfx/src/xlib/u2j208.h
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user