bug 728518 - improve the handling of weight in FindFontForChar. r=jdaggett

This commit is contained in:
Jonathan Kew 2012-02-20 08:55:07 +00:00
Родитель b67d84a668
Коммит ca4b1491d5
1 изменённых файлов: 5 добавлений и 14 удалений

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

@ -743,25 +743,16 @@ gfxFontFamily::FindFontForChar(FontSearch *aMatchData)
if (aMatchData->mFontToMatch) {
const gfxFontStyle *style = aMatchData->mFontToMatch->GetStyle();
// italics
// matching italics takes precedence over weight
bool wantItalic =
((style->style & (FONT_STYLE_ITALIC | FONT_STYLE_OBLIQUE)) != 0);
if (fe->IsItalic() == wantItalic) {
rank += 5;
rank += 10;
}
// weight
PRInt32 targetWeight = style->ComputeWeight() * 100;
PRInt32 entryWeight = fe->Weight();
if (entryWeight == targetWeight) {
rank += 5;
} else {
PRUint32 diffWeight = abs(entryWeight - targetWeight);
if (diffWeight <= 100) // favor faces close in weight
rank += 2;
}
// measure of closeness of weight to the desired value
rank += 9 - abs(fe->Weight() / 100 - style->ComputeWeight());
} else {
// if no font to match, prefer non-bold, non-italic fonts
if (!fe->IsItalic()) {