mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-05 05:30:29 +00:00
Bug 549816. Fix synthetic bolding with dwrite. r=jkew,jdaggett
This commit is contained in:
parent
9468c2a7e4
commit
56f398990f
@ -51,14 +51,10 @@ class gfxDWriteFont : public gfxFont
|
||||
{
|
||||
public:
|
||||
gfxDWriteFont(gfxFontEntry *aFontEntry,
|
||||
const gfxFontStyle *aFontStyle);
|
||||
const gfxFontStyle *aFontStyle,
|
||||
PRBool aNeedsBold = PR_FALSE);
|
||||
~gfxDWriteFont();
|
||||
|
||||
static already_AddRefed<gfxDWriteFont>
|
||||
GetOrMakeFont(gfxFontEntry *aFontEntry,
|
||||
const gfxFontStyle *aStyle,
|
||||
PRBool aNeedsBold = PR_FALSE);
|
||||
|
||||
virtual nsString GetUniqueName();
|
||||
|
||||
virtual const gfxFont::Metrics& GetMetrics();
|
||||
|
@ -301,9 +301,9 @@ gfxDWriteFontEntry::ReadCMAP()
|
||||
|
||||
gfxFont *
|
||||
gfxDWriteFontEntry::CreateFontInstance(const gfxFontStyle* aFontStyle,
|
||||
PRBool /*aNeedsBold*/)
|
||||
PRBool aNeedsBold)
|
||||
{
|
||||
return new gfxDWriteFont(this, aFontStyle);
|
||||
return new gfxDWriteFont(this, aFontStyle, aNeedsBold);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -48,7 +48,8 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// gfxDWriteFont
|
||||
gfxDWriteFont::gfxDWriteFont(gfxFontEntry *aFontEntry,
|
||||
const gfxFontStyle *aFontStyle)
|
||||
const gfxFontStyle *aFontStyle,
|
||||
PRBool aNeedsBold)
|
||||
: gfxFont(aFontEntry, aFontStyle)
|
||||
, mMetrics(nsnull)
|
||||
, mCairoFontFace(nsnull)
|
||||
@ -67,8 +68,7 @@ gfxDWriteFont::gfxDWriteFont(gfxFontEntry *aFontEntry,
|
||||
}
|
||||
PRInt8 baseWeight, weightDistance;
|
||||
GetStyle()->ComputeWeightAndOffset(&baseWeight, &weightDistance);
|
||||
if (((weightDistance == 0 && baseWeight >= 6)
|
||||
|| (weightDistance > 0)) && !fe->IsBold()) {
|
||||
if (aNeedsBold) {
|
||||
sims |= DWRITE_FONT_SIMULATIONS_BOLD;
|
||||
}
|
||||
|
||||
@ -90,37 +90,6 @@ gfxDWriteFont::~gfxDWriteFont()
|
||||
delete mMetrics;
|
||||
}
|
||||
|
||||
already_AddRefed<gfxDWriteFont>
|
||||
gfxDWriteFont::GetOrMakeFont(gfxFontEntry *aFontEntry,
|
||||
const gfxFontStyle *aStyle,
|
||||
PRBool aNeedsBold)
|
||||
{
|
||||
// because we know the FontEntry has the weight we really want, use it for
|
||||
// matching things in the cache so we don't end up with things like 402 in
|
||||
// there.
|
||||
gfxFontStyle style(*aStyle);
|
||||
|
||||
if (aFontEntry->mIsUserFont && !aFontEntry->IsBold()) {
|
||||
// determine whether synthetic bolding is needed
|
||||
PRInt8 baseWeight, weightDistance;
|
||||
aStyle->ComputeWeightAndOffset(&baseWeight, &weightDistance);
|
||||
|
||||
if ((weightDistance == 0 && baseWeight >= 6) ||
|
||||
(weightDistance > 0 && aNeedsBold)) {
|
||||
style.weight = 700;
|
||||
} else {
|
||||
style.weight = aFontEntry->mWeight;
|
||||
}
|
||||
} else {
|
||||
style.weight = aFontEntry->mWeight;
|
||||
}
|
||||
|
||||
nsRefPtr<gfxFont> font = aFontEntry->FindOrMakeFont(aStyle, aNeedsBold);
|
||||
|
||||
font->AddRef();
|
||||
return static_cast<gfxDWriteFont*>(font.get());
|
||||
}
|
||||
|
||||
nsString
|
||||
gfxDWriteFont::GetUniqueName()
|
||||
{
|
||||
|
@ -305,7 +305,9 @@ gfxFontFamily::FindFontForStyle(const gfxFontStyle& aFontStyle, PRBool& aNeedsBo
|
||||
break;
|
||||
}
|
||||
|
||||
if (weightDistance > 0 && wghtSteps <= absDistance) {
|
||||
if ((weightDistance > 0 && wghtSteps <= absDistance) ||
|
||||
(baseWeight >= 6 && !matchFE->IsBold() &&
|
||||
(wghtSteps - 1) <= weightDistance)) {
|
||||
aNeedsBold = PR_TRUE;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user