bug 829523 - disable font hinting on b2g, but retain pixel-snapped metrics except in the browser app. r=cjones

This commit is contained in:
Jonathan Kew 2013-01-15 09:06:47 +00:00
parent 770c146e49
commit c7f92c82b3
4 changed files with 58 additions and 8 deletions

View File

@ -247,20 +247,53 @@ gfxAndroidPlatform::FontHintingEnabled()
{
// In "mobile" builds, we sometimes use non-reflow-zoom, so we
// might not want hinting. Let's see.
#ifdef MOZ_USING_ANDROID_JAVA_WIDGETS
// On android-java, we currently only use gecko to render web
// content that can always be be non-reflow-zoomed. So turn off
// hinting.
//
// XXX when gecko-android-java is used as an "app runtime", we'll
// want to re-enable hinting.
// XXX when gecko-android-java is used as an "app runtime", we may
// want to re-enable hinting for non-browser processes there.
return false;
#endif
#ifdef MOZ_B2G
// On B2G, the UX preference is currently to keep hinting disabled
// for all text (see bug 829523).
return false;
#else
// Otherwise, enable hinting unless we're in a content process
// that might be used for non-reflowing zoom.
return XRE_GetProcessType() != GeckoProcessType_Content ||
!ContentChild::GetSingleton()->IsForBrowser();
#endif // MOZ_USING_ANDROID_JAVA_WIDGETS
// Currently, we don't have any other targets, but if/when we do,
// decide how to handle them here.
NS_NOTREACHED("oops, what platform is this?");
return gfxPlatform::FontHintingEnabled();
}
bool
gfxAndroidPlatform::RequiresLinearZoom()
{
#ifdef MOZ_USING_ANDROID_JAVA_WIDGETS
// On android-java, we currently only use gecko to render web
// content that can always be be non-reflow-zoomed.
//
// XXX when gecko-android-java is used as an "app runtime", we may
// want to treat it like B2G and use linear zoom only for the web
// browser process, not other apps.
return true;
#endif
#ifdef MOZ_B2G
// On B2G, we need linear zoom for the browser, but otherwise prefer
// the improved glyph spacing that results from respecting the device
// pixel resolution for glyph layout (see bug 816614).
return XRE_GetProcessType() == GeckoProcessType_Content &&
ContentChild::GetSingleton()->IsForBrowser();
#endif
NS_NOTREACHED("oops, what platform is this?");
return gfxPlatform::RequiresLinearZoom();
}
int

View File

@ -65,6 +65,7 @@ public:
gfxUserFontSet* aUserFontSet);
virtual bool FontHintingEnabled() MOZ_OVERRIDE;
virtual bool RequiresLinearZoom() MOZ_OVERRIDE;
FT_Library GetFTLibrary();

View File

@ -128,7 +128,7 @@ FT2FontEntry::CreateScaledFont(const gfxFontStyle *aStyle)
cairo_font_options_t *fontOptions = cairo_font_options_create();
if (!gfxPlatform::GetPlatform()->FontHintingEnabled()) {
if (gfxPlatform::GetPlatform()->RequiresLinearZoom()) {
cairo_font_options_set_hint_metrics(fontOptions, CAIRO_HINT_METRICS_OFF);
}

View File

@ -329,6 +329,22 @@ public:
*/
virtual bool FontHintingEnabled() { return true; }
/**
* True when zooming should not require reflow, so glyph metrics and
* positioning should not be adjusted for device pixels.
* If this is TRUE, then FontHintingEnabled() should be FALSE,
* but the converse is not necessarily required; in particular,
* B2G always has FontHintingEnabled FALSE, but RequiresLinearZoom
* is only true for the browser process, not Gaia or other apps.
*
* Like FontHintingEnabled (above), this setting shouldn't
* change per gecko process, while the process is live. If so the
* results are not defined.
*
* NB: this bit is only honored by the FT2 backend, currently.
*/
virtual bool RequiresLinearZoom() { return false; }
bool UsesSubpixelAATextRendering() {
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
return false;