зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1360862 - allow bitmap fonts to force scaling and bypass tolerance check in gfxFcPlatformFontList. r=jfkthame
MozReview-Commit-ID: Ly5ori9HKqc
This commit is contained in:
Родитель
0882cf1e24
Коммит
67d5414f9c
|
@ -850,6 +850,15 @@ ChooseFontSize(gfxFontconfigFontEntry* aEntry,
|
|||
bestSize = size;
|
||||
}
|
||||
}
|
||||
// If the font has bitmaps but wants to be scaled, then let it scale.
|
||||
if (bestSize >= 0.0) {
|
||||
FcBool scalable;
|
||||
if (FcPatternGetBool(aEntry->GetPattern(),
|
||||
FC_SCALABLE, 0, &scalable) == FcResultMatch &&
|
||||
scalable) {
|
||||
return requestedSize;
|
||||
}
|
||||
}
|
||||
return bestSize;
|
||||
}
|
||||
|
||||
|
@ -1012,6 +1021,12 @@ gfxFontconfigFontFamily::AddFontPattern(FcPattern* aFontPattern)
|
|||
if (FcPatternGetBool(aFontPattern, FC_OUTLINE, 0, &outline) != FcResultMatch ||
|
||||
!outline) {
|
||||
mHasNonScalableFaces = true;
|
||||
|
||||
FcBool scalable;
|
||||
if (FcPatternGetBool(aFontPattern, FC_SCALABLE, 0, &scalable) == FcResultMatch &&
|
||||
scalable) {
|
||||
mForceScalable = true;
|
||||
}
|
||||
}
|
||||
|
||||
nsCountedRef<FcPattern> pattern(aFontPattern);
|
||||
|
@ -1023,7 +1038,9 @@ static const double kRejectDistance = 10000.0;
|
|||
// Calculate a distance score representing the size disparity between the
|
||||
// requested style's size and the font entry's size.
|
||||
static double
|
||||
SizeDistance(gfxFontconfigFontEntry* aEntry, const gfxFontStyle& aStyle)
|
||||
SizeDistance(gfxFontconfigFontEntry* aEntry,
|
||||
const gfxFontStyle& aStyle,
|
||||
bool aForceScalable)
|
||||
{
|
||||
double requestedSize = SizeForStyle(aEntry, aStyle);
|
||||
double bestDist = -1.0;
|
||||
|
@ -1040,7 +1057,7 @@ SizeDistance(gfxFontconfigFontEntry* aEntry, const gfxFontStyle& aStyle)
|
|||
if (bestDist < 0.0) {
|
||||
// No size means scalable
|
||||
return -1.0;
|
||||
} else if (5.0 * bestDist < requestedSize) {
|
||||
} else if (aForceScalable || 5.0 * bestDist < requestedSize) {
|
||||
// fontconfig prefers a matching family or lang to pixelsize of bitmap
|
||||
// fonts. CSS suggests a tolerance of 20% on pixelsize.
|
||||
return bestDist;
|
||||
|
@ -1074,7 +1091,7 @@ gfxFontconfigFontFamily::FindAllFontsForStyle(const gfxFontStyle& aFontStyle,
|
|||
for (size_t i = 0; i < aFontEntryList.Length(); i++) {
|
||||
gfxFontconfigFontEntry* entry =
|
||||
static_cast<gfxFontconfigFontEntry*>(aFontEntryList[i]);
|
||||
double dist = SizeDistance(entry, aFontStyle);
|
||||
double dist = SizeDistance(entry, aFontStyle, mForceScalable);
|
||||
// If the entry is scalable or has a style that does not match
|
||||
// the group of unscalable fonts, then start a new group.
|
||||
if (dist < 0.0 ||
|
||||
|
|
|
@ -195,7 +195,8 @@ public:
|
|||
explicit gfxFontconfigFontFamily(const nsAString& aName) :
|
||||
gfxFontFamily(aName),
|
||||
mContainsAppFonts(false),
|
||||
mHasNonScalableFaces(false)
|
||||
mHasNonScalableFaces(false),
|
||||
mForceScalable(false)
|
||||
{ }
|
||||
|
||||
void FindStyleVariations(FontInfoData *aFontInfoData = nullptr) override;
|
||||
|
@ -221,6 +222,7 @@ protected:
|
|||
|
||||
bool mContainsAppFonts;
|
||||
bool mHasNonScalableFaces;
|
||||
bool mForceScalable;
|
||||
};
|
||||
|
||||
class gfxFontconfigFont : public gfxFontconfigFontBase {
|
||||
|
|
Загрузка…
Ссылка в новой задаче