Bug 418479. Allow antialiased text rendering to be disabled for small text sizes via a pref. r+sr=vlad, a=damons

This commit is contained in:
jdaggett@mozilla.com 2008-05-01 02:07:17 -07:00
parent 05b913ced9
commit 9a2ab9c8d7
4 changed files with 51 additions and 0 deletions

View File

@ -80,14 +80,21 @@ public:
// Ex: Mac OS X 10.4.x ==> 0x104x
PRInt32 OSXVersion();
// lower threshold on font anti-aliasing
PRUint32 GetAntiAliasingThreshold() { return mFontAntiAliasingThreshold; }
private:
void gfxPlatformMac::AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], PRUint32 &aLen,
eFontPrefLang aCharLang, eFontPrefLang aPageLang);
virtual cmsHPROFILE GetPlatformCMSOutputProfile();
// read in the pref value for the lower threshold on font anti-aliasing
static PRUint32 ReadAntiAliasingThreshold();
nsTArray<PRUint32> mCJKPrefLangs;
PRInt32 mOSXVersion;
PRUint32 mFontAntiAliasingThreshold;
};
#endif /* GFX_PLATFORM_MAC_H */

View File

@ -140,6 +140,13 @@ gfxAtsuiFont::gfxAtsuiFont(MacOSFontEntry *aFontEntry,
}
cairo_font_options_t *fontOptions = cairo_font_options_create();
// turn off font anti-aliasing based on user pref setting
if (mAdjustedSize <= (float) gfxPlatformMac::GetPlatform()->GetAntiAliasingThreshold()) {
cairo_font_options_set_antialias(fontOptions, CAIRO_ANTIALIAS_NONE);
//printf("font: %s, size: %f, disabling anti-aliasing\n", NS_ConvertUTF16toUTF8(mName).get(), mAdjustedSize);
}
mScaledFont = cairo_scaled_font_create(mFontFace, &sizeMatrix, &ctm, fontOptions);
cairo_font_options_destroy(fontOptions);
NS_ASSERTION(cairo_scaled_font_status(mScaledFont) == CAIRO_STATUS_SUCCESS,

View File

@ -65,6 +65,7 @@ gfxPlatformMac::gfxPlatformMac()
glitz_agl_init();
#endif
mOSXVersion = 0;
mFontAntiAliasingThreshold = ReadAntiAliasingThreshold();
}
already_AddRefed<gfxASurface>
@ -336,6 +337,39 @@ gfxPlatformMac::AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], PRUint32 &aLen, e
}
PRUint32
gfxPlatformMac::ReadAntiAliasingThreshold()
{
PRUint32 threshold = 0; // default == no threshold
// first read prefs flag to determine whether to use the setting or not
PRBool useAntiAliasingThreshold = PR_FALSE;
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefs) {
PRBool enabled;
nsresult rv =
prefs->GetBoolPref("gfx.use_text_smoothing_setting", &enabled);
if (NS_SUCCEEDED(rv)) {
useAntiAliasingThreshold = enabled;
}
}
// if the pref setting is disabled, return 0 which effectively disables this feature
if (!useAntiAliasingThreshold)
return threshold;
// value set via Appearance pref panel, "Turn off text smoothing for font sizes xxx and smaller"
CFNumberRef prefValue = (CFNumberRef)CFPreferencesCopyAppValue(CFSTR("AppleAntiAliasingThreshold"), kCFPreferencesCurrentApplication);
if (prefValue) {
if (!CFNumberGetValue(prefValue, kCFNumberIntType, &threshold)) {
threshold = 0;
}
CFRelease(prefValue);
}
return threshold;
}
cmsHPROFILE
gfxPlatformMac::GetPlatformCMSOutputProfile()

View File

@ -172,6 +172,9 @@ pref("accessibility.typeaheadfind.soundURL", "beep");
pref("accessibility.typeaheadfind.enablesound", true);
pref("accessibility.typeaheadfind.prefillwithselection", true);
// use Mac OS X Appearance panel text smoothing setting when rendering text, disabled by default
pref("gfx.use_text_smoothing_setting", false);
pref("browser.history_expire_days", 9);
// loading and rendering of framesets and iframes