mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Fixed bugs 2522 and 4875. Switched from FONTSIGNATURE to cmap to figure
out which glyphs are available. Removed FONT_SWITCHING ifdef.
This commit is contained in:
parent
094e319485
commit
1a70e1f12d
File diff suppressed because it is too large
Load Diff
@ -29,9 +29,6 @@
|
||||
#include "nsCRT.h"
|
||||
#include "nsDeviceContextWin.h"
|
||||
|
||||
#define FONT_SWITCHING
|
||||
#ifdef FONT_SWITCHING
|
||||
|
||||
#ifdef FONT_HAS_GLYPH
|
||||
#undef FONT_HAS_GLYPH
|
||||
#endif
|
||||
@ -44,12 +41,10 @@
|
||||
|
||||
typedef struct nsFontWin
|
||||
{
|
||||
HFONT font;
|
||||
PRUint8 map[8192]; // XXX save memory by sharing these among fonts -- erik
|
||||
HFONT font;
|
||||
PRUint8* map;
|
||||
} nsFontWin;
|
||||
|
||||
#endif /* FONT_SWITCHING */
|
||||
|
||||
class nsFontMetricsWin : public nsIFontMetrics
|
||||
{
|
||||
public:
|
||||
@ -77,10 +72,9 @@ public:
|
||||
NS_IMETHOD GetFont(const nsFont *&aFont);
|
||||
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
|
||||
|
||||
#ifdef FONT_SWITCHING
|
||||
|
||||
nsFontWin* FindGlobalFont(HDC aDC, PRUnichar aChar);
|
||||
nsFontWin* FindLocalFont(HDC aDC, PRUnichar aChar);
|
||||
nsFontWin* FindFont(HDC aDC, PRUnichar aChar);
|
||||
nsFontWin* LoadFont(HDC aDC, nsString* aName);
|
||||
|
||||
nsFontWin *mLoadedFonts;
|
||||
@ -92,8 +86,6 @@ public:
|
||||
PRUint16 mFontsCount;
|
||||
PRUint16 mFontsIndex;
|
||||
|
||||
#endif /* FONT_SWITCHING */
|
||||
|
||||
protected:
|
||||
void FillLogFont(LOGFONT* aLogFont);
|
||||
void RealizeFont();
|
||||
|
@ -1446,32 +1446,6 @@ NS_IMETHODIMP nsRenderingContextWin :: GetWidth(const nsString& aString, nscoord
|
||||
return GetWidth(aString.GetUnicode(), aString.Length(), aWidth, aFontID);
|
||||
}
|
||||
|
||||
#ifndef FONT_SWITCHING
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextWin :: GetWidth(const PRUnichar *aString,
|
||||
PRUint32 aLength,
|
||||
nscoord &aWidth,
|
||||
PRInt32 *aFontID)
|
||||
{
|
||||
if (nsnull != mFontMetrics)
|
||||
{
|
||||
SIZE size;
|
||||
|
||||
SetupFontAndColor();
|
||||
::GetTextExtentPoint32W(mDC, aString, aLength, &size);
|
||||
aWidth = NSToCoordRound(float(size.cx) * mP2T);
|
||||
|
||||
if (nsnull != aFontID)
|
||||
*aFontID = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#else /* FONT_SWITCHING */
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextWin :: GetWidth(const PRUnichar *aString,
|
||||
PRUint32 aLength,
|
||||
nscoord &aWidth,
|
||||
@ -1546,8 +1520,6 @@ FoundFont:
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#endif /* FONT_SWITCHING */
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextWin :: DrawString(const char *aString, PRUint32 aLength,
|
||||
nscoord aX, nscoord aY,
|
||||
const nscoord* aSpacing)
|
||||
@ -1577,66 +1549,6 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawString(const char *aString, PRUint32
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifndef FONT_SWITCHING
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextWin :: DrawString(const PRUnichar *aString, PRUint32 aLength,
|
||||
nscoord aX, nscoord aY,
|
||||
PRInt32 aFontID,
|
||||
const nscoord* aSpacing)
|
||||
{
|
||||
PRInt32 x = aX;
|
||||
PRInt32 y = aY;
|
||||
|
||||
SetupFontAndColor();
|
||||
|
||||
if (nsnull != aSpacing)
|
||||
{
|
||||
// XXX Fix path to use a twips transform in the DC and use the
|
||||
// spacing values directly and let windows deal with the sub-pixel
|
||||
// positioning.
|
||||
|
||||
// Slow, but accurate rendering
|
||||
const PRUnichar* end = aString + aLength;
|
||||
while (aString < end)
|
||||
{
|
||||
// XXX can shave some cycles by inlining a version of transform
|
||||
// coord where y is constant and transformed once
|
||||
x = aX;
|
||||
y = aY;
|
||||
mTMatrix->TransformCoord(&x, &y);
|
||||
::ExtTextOutW(mDC, x, y, 0, NULL, aString, 1, NULL);
|
||||
aX += *aSpacing++;
|
||||
aString++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mTMatrix->TransformCoord(&x, &y);
|
||||
::ExtTextOutW(mDC, x, y, 0, NULL, aString, aLength, NULL);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (nsnull != mFontMetrics)
|
||||
{
|
||||
nsFont *font;
|
||||
mFontMetrics->GetFont(font);
|
||||
PRUint8 decorations = font->decorations;
|
||||
|
||||
if (decorations & NS_FONT_DECORATION_OVERLINE)
|
||||
{
|
||||
nscoord offset;
|
||||
nscoord size;
|
||||
mFontMetrics->GetUnderline(offset, size);
|
||||
FillRect(aX, aY, aWidth, size);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#else /* FONT_SWITCHING */
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextWin :: DrawString(const PRUnichar *aString, PRUint32 aLength,
|
||||
nscoord aX, nscoord aY,
|
||||
PRInt32 aFontID,
|
||||
@ -1749,8 +1661,6 @@ FoundFont:
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#endif /* FONT_SWITCHING */
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextWin :: DrawString(const nsString& aString,
|
||||
nscoord aX, nscoord aY,
|
||||
PRInt32 aFontID,
|
||||
|
Loading…
Reference in New Issue
Block a user