summaryrefslogtreecommitdiffstats
path: root/gfx/thebes/gfxFcPlatformFontList.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-03-27 21:20:57 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-03-27 21:20:57 +0200
commitb6a49b6623ae623f33ec2a16256c06ef62f09640 (patch)
tree20819b00e64f7f8f641c3afaeebffa4898b9c7e0 /gfx/thebes/gfxFcPlatformFontList.cpp
parentcb59151acd51f4317c563bc6a3448a9c02a24e12 (diff)
downloadUXP-b6a49b6623ae623f33ec2a16256c06ef62f09640.tar
UXP-b6a49b6623ae623f33ec2a16256c06ef62f09640.tar.gz
UXP-b6a49b6623ae623f33ec2a16256c06ef62f09640.tar.lz
UXP-b6a49b6623ae623f33ec2a16256c06ef62f09640.tar.xz
UXP-b6a49b6623ae623f33ec2a16256c06ef62f09640.zip
Allow bitmap fonts to force scaling and bypass tolerance check in gfxFcPlatformFontList.
Diffstat (limited to 'gfx/thebes/gfxFcPlatformFontList.cpp')
-rw-r--r--gfx/thebes/gfxFcPlatformFontList.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/gfx/thebes/gfxFcPlatformFontList.cpp b/gfx/thebes/gfxFcPlatformFontList.cpp
index 3d183798f..75e8fb76a 100644
--- a/gfx/thebes/gfxFcPlatformFontList.cpp
+++ b/gfx/thebes/gfxFcPlatformFontList.cpp
@@ -811,6 +811,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;
}
@@ -950,6 +959,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);
@@ -961,7 +976,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;
@@ -978,7 +995,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;
@@ -1012,7 +1029,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 ||