[BeOS]re-enable EMULATE_BOLD, Bug 342966, p=sergei_d, r=thesuckiestemail, BeOS-only

This commit is contained in:
sergei_d%fi.tartu.ee 2006-06-28 16:17:37 +00:00
Родитель 59aed63f0a
Коммит 49262a639d
3 изменённых файлов: 28 добавлений и 8 удалений

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

@ -188,7 +188,12 @@ NS_IMETHODIMP nsFontMetricsBeOS::Init(const nsFont& aFont, nsIAtom* aLangGroup,
face |= B_ITALIC_FACE;
if ( aFont.weight > NS_FONT_WEIGHT_NORMAL )
{
mIsBold = PR_TRUE;
face |= B_BOLD_FACE;
}
else
mIsBold = PR_FALSE;
// I don't think B_UNDERSCORE_FACE and B_STRIKEOUT_FACE really works...
// instead, nsTextFrame do them for us. ( my guess... Makoto Hamanaka )
@ -197,7 +202,7 @@ NS_IMETHODIMP nsFontMetricsBeOS::Init(const nsFont& aFont, nsIAtom* aLangGroup,
if ( aFont.decorations & NS_FONT_DECORATION_LINE_THROUGH )
face |= B_STRIKEOUT_FACE;
mFontHandle.SetFace( face );
// emulate italic the selected family has no such style
if (aFont.style == NS_FONT_STYLE_ITALIC
@ -206,6 +211,7 @@ NS_IMETHODIMP nsFontMetricsBeOS::Init(const nsFont& aFont, nsIAtom* aLangGroup,
mFontHandle.SetSize(mFont.size/app2twip);
mFontHandle.SetSpacing(B_FIXED_SPACING);
#ifdef NOISY_FONTS
#ifdef DEBUG
fprintf(stderr, "looking for font %s (%d)", wildstring, aFont.size / app2twip);
@ -454,6 +460,8 @@ float nsFontMetricsBeOS::GetStringWidth(char *utf8str, uint32 bytelen)
retwidth += width;
utf8str += charlen;
}
if (mIsBold && !(mFontHandle.Face() & B_BOLD_FACE))
retwidth += 1.0;
return retwidth;
}

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

@ -91,7 +91,8 @@ public:
NS_IMETHOD GetSpaceWidth(nscoord &aSpaceWidth);
static nsresult FamilyExists(const nsString& aFontName);
static nsresult FamilyExists(const nsString& aFontName);
inline PRBool IsBold() { return mIsBold; }
static int FontMatchesGenericType(font_family family, uint32 flags, const char* aGeneric, const char* aLangGroup);
nsCOMPtr<nsIAtom> mLangGroup;
static int MatchesLangGroup(font_family family, const char* aLangGroup);
@ -124,6 +125,7 @@ protected:
PRUint16 mPixelSize;
PRUint8 mStretchIndex;
PRUint8 mStyleIndex;
PRBool mIsBold;
nsDataHashtable<nsUint32HashKey, float> mFontWidthCache;
};

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

@ -1341,17 +1341,25 @@ NS_IMETHODIMP nsRenderingContextBeOS::DrawString(const char *aString, PRUint32 a
nscoord xx = aX, yy = aY, y=aY;
// Subtract xFontStruct ascent since drawing specifies baseline
if (LockAndUpdateView())
{
// XXX: the following maybe isn't most efficient for text rendering,
// but it's the easy way to render antialiased text correctly
mView->SetDrawingMode(B_OP_OVER);
PRBool doEmulateBold = PR_FALSE;
if (mFontMetrics)
{
doEmulateBold = ((nsFontMetricsBeOS *)mFontMetrics)->IsBold() && !(mCurrentBFont->Face() & B_BOLD_FACE);
}
// XXX: B_OP_OVER isn't most efficient for text rendering,
// but it's the only way to render antialiased text correctly on arbitrary background
PRBool offscreen;
mSurface->IsOffscreen(&offscreen);
mView->SetDrawingMode( offscreen ? B_OP_OVER : B_OP_COPY);
if (nsnull == aSpacing || utf8_char_len((uchar)aString[0])==aLength)
{
mTranMatrix->TransformCoord(&xx, &yy);
mView->DrawString(aString, aLength, BPoint(xx, yy));
if (doEmulateBold)
mView->DrawString(aString, aLength, BPoint(xx + 1.0, yy));
}
else
{
@ -1365,7 +1373,9 @@ NS_IMETHODIMP nsRenderingContextBeOS::DrawString(const char *aString, PRUint32 a
yy = y;
mTranMatrix->TransformCoord(&xx, &yy);
// yy++; DrawString quirk!
mView->DrawString((char *)(wpoint), ch_len, BPoint(xx, yy));
mView->DrawString((char *)(wpoint), ch_len, BPoint(xx, yy));
if (doEmulateBold)
mView->DrawString((char *)(wpoint), ch_len, BPoint(xx + 1.0, yy));
position += aSpacing[unichnum++];
}
}