mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 549816. Adjust meaning of needsBold flag. r=bas
This commit is contained in:
parent
0347e107b7
commit
b6c4b585db
@ -318,11 +318,12 @@ public:
|
||||
void SetHasStyles(PRBool aHasStyles) { mHasStyles = aHasStyles; }
|
||||
|
||||
// choose a specific face to match a style using CSS font matching
|
||||
// rules (weight matching occurs here)
|
||||
// may return a face that doesn't precisely match (e.g. normal face when no italic face exists)
|
||||
// aNeedsBold is set to true when bolder face couldn't be found, false otherwise
|
||||
// rules (weight matching occurs here). may return a face that doesn't
|
||||
// precisely match (e.g. normal face when no italic face exists).
|
||||
// aNeedsSyntheticBold is set to true when synthetic bolding is
|
||||
// needed, false otherwise
|
||||
gfxFontEntry *FindFontForStyle(const gfxFontStyle& aFontStyle,
|
||||
PRBool& aNeedsBold);
|
||||
PRBool& aNeedsSyntheticBold);
|
||||
|
||||
// iterates over faces looking for a match with a given characters
|
||||
// used as part of the font fallback process
|
||||
|
@ -162,14 +162,15 @@ gfxFontFamily::HasOtherFamilyNames()
|
||||
}
|
||||
|
||||
gfxFontEntry*
|
||||
gfxFontFamily::FindFontForStyle(const gfxFontStyle& aFontStyle, PRBool& aNeedsBold)
|
||||
gfxFontFamily::FindFontForStyle(const gfxFontStyle& aFontStyle,
|
||||
PRBool& aNeedsSyntheticBold)
|
||||
{
|
||||
if (!mHasStyles)
|
||||
FindStyleVariations(); // collect faces for the family, if not already done
|
||||
|
||||
NS_ASSERTION(mAvailableFonts.Length() > 0, "font family with no faces!");
|
||||
|
||||
aNeedsBold = PR_FALSE;
|
||||
aNeedsSyntheticBold = PR_FALSE;
|
||||
|
||||
PRInt8 baseWeight, weightDistance;
|
||||
aFontStyle.ComputeWeightAndOffset(&baseWeight, &weightDistance);
|
||||
@ -181,7 +182,7 @@ gfxFontFamily::FindFontForStyle(const gfxFontStyle& aFontStyle, PRBool& aNeedsBo
|
||||
// If the family has only one face, we simply return it; no further checking needed
|
||||
if (mAvailableFonts.Length() == 1) {
|
||||
gfxFontEntry *fe = mAvailableFonts[0];
|
||||
aNeedsBold = wantBold && !fe->IsBold();
|
||||
aNeedsSyntheticBold = wantBold && !fe->IsBold();
|
||||
return fe;
|
||||
}
|
||||
|
||||
@ -204,7 +205,7 @@ gfxFontFamily::FindFontForStyle(const gfxFontStyle& aFontStyle, PRBool& aNeedsBo
|
||||
// if the desired style is available, return it directly
|
||||
gfxFontEntry *fe = mAvailableFonts[faceIndex];
|
||||
if (fe) {
|
||||
// no need to set aNeedsBold here as we matched the boldness request
|
||||
// no need to set aNeedsSyntheticBold here as we matched the boldness request
|
||||
return fe;
|
||||
}
|
||||
|
||||
@ -226,7 +227,7 @@ gfxFontFamily::FindFontForStyle(const gfxFontStyle& aFontStyle, PRBool& aNeedsBo
|
||||
NS_ConvertUTF16toUTF8(mName).get(),
|
||||
aFontStyle.style, aFontStyle.weight, aFontStyle.size,
|
||||
NS_ConvertUTF16toUTF8(fe->Name()).get(), trial));
|
||||
aNeedsBold = wantBold && !fe->IsBold();
|
||||
aNeedsSyntheticBold = wantBold && !fe->IsBold();
|
||||
return fe;
|
||||
}
|
||||
}
|
||||
@ -288,6 +289,13 @@ gfxFontFamily::FindFontForStyle(const gfxFontStyle& aFontStyle, PRBool& aNeedsBo
|
||||
direction = (weightDistance >= 0) ? 1 : -1;
|
||||
PRInt8 i, wghtSteps = 0;
|
||||
|
||||
// synthetic bolding occurs when font itself is not a bold-face and
|
||||
// either the absolute weight is at least 600 or the relative weight
|
||||
// (e.g. 402) implies a darker face than the ones available.
|
||||
// note: this means that (1) lighter styles *never* synthetic bold and
|
||||
// (2) synthetic bolding always occurs at the first bolder step beyond
|
||||
// available faces, no matter how light the boldest face
|
||||
|
||||
// account for synthetic bold in lighter case
|
||||
// if lighter is applied with an inherited bold weight,
|
||||
// and no actual bold faces exist, synthetic bold is used
|
||||
@ -305,10 +313,13 @@ gfxFontFamily::FindFontForStyle(const gfxFontStyle& aFontStyle, PRBool& aNeedsBo
|
||||
break;
|
||||
}
|
||||
|
||||
if ((weightDistance > 0 && wghtSteps <= absDistance) ||
|
||||
(baseWeight >= 6 && !matchFE->IsBold() &&
|
||||
(wghtSteps - 1) <= weightDistance)) {
|
||||
aNeedsBold = PR_TRUE;
|
||||
NS_ASSERTION(matchFE, "we should always be able to return something here");
|
||||
|
||||
if (!matchFE->IsBold() &&
|
||||
((weightDistance == 0 && baseWeight >= 6) ||
|
||||
(weightDistance > 0 && wghtSteps <= absDistance)))
|
||||
{
|
||||
aNeedsSyntheticBold = PR_TRUE;
|
||||
}
|
||||
|
||||
PR_LOG(gFontSelection, PR_LOG_DEBUG,
|
||||
@ -316,7 +327,6 @@ gfxFontFamily::FindFontForStyle(const gfxFontStyle& aFontStyle, PRBool& aNeedsBo
|
||||
NS_ConvertUTF16toUTF8(mName).get(),
|
||||
aFontStyle.style, aFontStyle.weight, aFontStyle.size,
|
||||
NS_ConvertUTF16toUTF8(matchFE->Name()).get()));
|
||||
NS_ASSERTION(matchFE, "we should always be able to return something here");
|
||||
return matchFE;
|
||||
}
|
||||
|
||||
|
@ -53,18 +53,7 @@ gfxMacFont::gfxMacFont(MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyl
|
||||
mScaledFont(nsnull),
|
||||
mAdjustedSize(0.0)
|
||||
{
|
||||
// determine whether synthetic bolding is needed
|
||||
PRInt8 baseWeight, weightDistance;
|
||||
mStyle.ComputeWeightAndOffset(&baseWeight, &weightDistance);
|
||||
PRUint16 targetWeight = (baseWeight * 100) + (weightDistance * 100);
|
||||
|
||||
// synthetic bolding occurs when font itself is not a bold-face and either the absolute weight
|
||||
// is at least 600 or the relative weight (e.g. 402) implies a darker face than the ones available.
|
||||
// note: this means that (1) lighter styles *never* synthetic bold and (2) synthetic bolding always occurs
|
||||
// at the first bolder step beyond available faces, no matter how light the boldest face
|
||||
if (!aFontEntry->IsBold()
|
||||
&& ((weightDistance == 0 && targetWeight >= 600) || (weightDistance > 0 && aNeedsBold)))
|
||||
{
|
||||
if (aNeedsBold) {
|
||||
mSyntheticBoldOffset = 1; // devunit offset when double-striking text to fake boldness
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user