зеркало из https://github.com/mozilla/gecko-dev.git
Bug 725240: Re-enable hinting on 'mobile' when non-reflowing-zoom isn't going to be used. r=jfkthame
This commit is contained in:
Родитель
40765d660b
Коммит
b560fc0e45
|
@ -276,6 +276,9 @@ CPPSRCS += \
|
|||
gfxPDFSurface.cpp \
|
||||
nsUnicodeRange.cpp \
|
||||
$(NULL)
|
||||
# This is set for "normal Android", that is, when Gecko is running on
|
||||
# top of the android java runtime.
|
||||
DEFINES += -DMOZ_USING_ANDROID_JAVA_WIDGETS
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),gonk)
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include "gfxFT2FontList.h"
|
||||
#include "gfxImageSurface.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
|
@ -195,3 +196,28 @@ gfxAndroidPlatform::GetScaledFontForFont(gfxFont *aFont)
|
|||
return scaledFont;
|
||||
}
|
||||
|
||||
bool
|
||||
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.
|
||||
return false;
|
||||
#else
|
||||
// Otherwise, if we're in a content process, assume we don't want
|
||||
// hinting.
|
||||
//
|
||||
// XXX when we use content processes to load "apps", we'll want to
|
||||
// configure this dynamically based on whether we're an "app
|
||||
// content process" or a "browser content process". The former
|
||||
// wants hinting, the latter doesn't since it might be
|
||||
// non-reflow-zoomed.
|
||||
return (XRE_GetProcessType() != GeckoProcessType_Content);
|
||||
#endif // MOZ_USING_ANDROID_JAVA_WIDGETS
|
||||
}
|
||||
|
|
|
@ -99,6 +99,8 @@ public:
|
|||
const gfxFontStyle *aStyle,
|
||||
gfxUserFontSet* aUserFontSet);
|
||||
|
||||
virtual bool FontHintingEnabled() MOZ_OVERRIDE;
|
||||
|
||||
FT_Library GetFTLibrary();
|
||||
};
|
||||
|
||||
|
|
|
@ -154,9 +154,9 @@ FT2FontEntry::CreateScaledFont(const gfxFontStyle *aStyle)
|
|||
|
||||
cairo_font_options_t *fontOptions = cairo_font_options_create();
|
||||
|
||||
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
|
||||
cairo_font_options_set_hint_metrics(fontOptions, CAIRO_HINT_METRICS_OFF);
|
||||
#endif
|
||||
if (!gfxPlatform::GetPlatform()->FontHintingEnabled()) {
|
||||
cairo_font_options_set_hint_metrics(fontOptions, CAIRO_HINT_METRICS_OFF);
|
||||
}
|
||||
|
||||
scaledFont = cairo_scaled_font_create(CairoFontFace(),
|
||||
&sizeMatrix,
|
||||
|
@ -279,11 +279,10 @@ FT2FontEntry::CreateFontEntry(FT_Face aFace,
|
|||
FT2FontEntry *fe = new FT2FontEntry(fontName);
|
||||
fe->mItalic = aFace->style_flags & FT_STYLE_FLAG_ITALIC;
|
||||
fe->mFTFace = aFace;
|
||||
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
|
||||
fe->mFontFace = cairo_ft_font_face_create_for_ft_face(aFace, FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING);
|
||||
#else
|
||||
fe->mFontFace = cairo_ft_font_face_create_for_ft_face(aFace, 0);
|
||||
#endif
|
||||
int flags = gfxPlatform::GetPlatform()->FontHintingEnabled() ?
|
||||
FT_LOAD_DEFAULT :
|
||||
(FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING);
|
||||
fe->mFontFace = cairo_ft_font_face_create_for_ft_face(aFace, flags);
|
||||
fe->mFilename = aFilename;
|
||||
fe->mFTFontIndex = aIndex;
|
||||
FTUserFontData *userFontData = new FTUserFontData(aFace, aFontData);
|
||||
|
@ -330,11 +329,10 @@ FT2FontEntry::CairoFontFace()
|
|||
FT_Face face;
|
||||
FT_New_Face(gfxToolkitPlatform::GetPlatform()->GetFTLibrary(), mFilename.get(), mFTFontIndex, &face);
|
||||
mFTFace = face;
|
||||
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
|
||||
mFontFace = cairo_ft_font_face_create_for_ft_face(face, FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING);
|
||||
#else
|
||||
mFontFace = cairo_ft_font_face_create_for_ft_face(face, 0);
|
||||
#endif
|
||||
int flags = gfxPlatform::GetPlatform()->FontHintingEnabled() ?
|
||||
FT_LOAD_DEFAULT :
|
||||
(FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING);
|
||||
mFontFace = cairo_ft_font_face_create_for_ft_face(face, flags);
|
||||
FTUserFontData *userFontData = new FTUserFontData(face, nsnull);
|
||||
cairo_font_face_set_user_data(mFontFace, &key,
|
||||
userFontData, FTFontDestroyFunc);
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
#include "nsTArray.h"
|
||||
#include "nsUnicodeRange.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
#include "prlog.h"
|
||||
#include "prinit.h"
|
||||
|
@ -641,11 +642,10 @@ gfxFT2Font::FillGlyphDataForChar(PRUint32 ch, CachedGlyphData *gd)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
|
||||
FT_Error err = FT_Load_Glyph(face, gid, FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING);
|
||||
#else
|
||||
FT_Error err = FT_Load_Glyph(face, gid, FT_LOAD_DEFAULT);
|
||||
#endif
|
||||
FT_Int32 flags = gfxPlatform::GetPlatform()->FontHintingEnabled() ?
|
||||
FT_LOAD_DEFAULT :
|
||||
(FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING);
|
||||
FT_Error err = FT_Load_Glyph(face, gid, flags);
|
||||
|
||||
if (err) {
|
||||
// hmm, this is weird, we failed to load a glyph that we had?
|
||||
|
|
|
@ -310,6 +310,15 @@ public:
|
|||
*/
|
||||
bool SanitizeDownloadedFonts();
|
||||
|
||||
/**
|
||||
* True when hinting should be enabled. 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 FontHintingEnabled() { return true; }
|
||||
|
||||
#ifdef MOZ_GRAPHITE
|
||||
/**
|
||||
* Whether to use the SIL Graphite rendering engine
|
||||
|
|
Загрузка…
Ссылка в новой задаче