summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorthomasanderson <thomasanderson@google.com>2016-05-17 12:30:07 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-17 12:30:07 -0700
commit992def065be348d6f8157fab75aee312f5f45558 (patch)
treef28f6e6eefd24e7d42ab8b63681e7eaff39b316f /core
parent61a4544a812813922493e00a5fed4ca775498329 (diff)
downloadpdfium-992def065be348d6f8157fab75aee312f5f45558.tar.xz
Don't use LCD antialiasing if Fontconfig doesn't support hinting
Some Freetype implementations (like the one packaged with Fedora) do not support hinting due to patents 6219025, 6239783, 6307566, 6225973, 6243070, 6393145, 6421054, 6282327, and 6624828; the latest one expires 10/7/19. This makes LCD antialiasing very ugly, so we instead fall back on NORMAL antialiasing. A before/after on Fedora: https://bugs.chromium.org/p/chromium/issues/detail?id=479400#c31 BUG=479400 Review-Url: https://codereview.chromium.org/1982263004
Diffstat (limited to 'core')
-rw-r--r--core/fxge/ge/fx_ge_fontmap.cpp6
-rw-r--r--core/fxge/ge/fx_ge_text.cpp9
-rw-r--r--core/fxge/include/fx_font.h2
3 files changed, 15 insertions, 2 deletions
diff --git a/core/fxge/ge/fx_ge_fontmap.cpp b/core/fxge/ge/fx_ge_fontmap.cpp
index e8af2dce53..7938e10984 100644
--- a/core/fxge/ge/fx_ge_fontmap.cpp
+++ b/core/fxge/ge/fx_ge_fontmap.cpp
@@ -454,7 +454,8 @@ int CTTFontDesc::ReleaseFace(FXFT_Face face) {
return 0;
}
-CFX_FontMgr::CFX_FontMgr() : m_FTLibrary(nullptr) {
+CFX_FontMgr::CFX_FontMgr()
+ : m_FTLibrary(nullptr), m_FTLibrarySupportsHinting(false) {
m_pBuiltinMapper.reset(new CFX_FontMapper(this));
}
@@ -472,6 +473,9 @@ void CFX_FontMgr::InitFTLibrary() {
if (m_FTLibrary)
return;
FXFT_Init_FreeType(&m_FTLibrary);
+ m_FTLibrarySupportsHinting =
+ FXFT_Library_SetLcdFilter(m_FTLibrary, FT_LCD_FILTER_DEFAULT) !=
+ FT_Err_Unimplemented_Feature;
}
void CFX_FontMgr::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) {
diff --git a/core/fxge/ge/fx_ge_text.cpp b/core/fxge/ge/fx_ge_text.cpp
index b0f6a6e63a..46edaf7cbe 100644
--- a/core/fxge/ge/fx_ge_text.cpp
+++ b/core/fxge/ge/fx_ge_text.cpp
@@ -257,7 +257,14 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
} else {
bClearType = text_flags & FXTEXT_CLEARTYPE;
}
- if ((m_RenderCaps & (FXRC_ALPHA_OUTPUT | FXRC_CMYK_OUTPUT))) {
+ if (!CFX_GEModule::Get()->GetFontMgr()->FTLibrarySupportsHinting()) {
+ // Some Freetype implementations (like the one packaged with Fedora) do
+ // not support hinting due to patents 6219025, 6239783, 6307566,
+ // 6225973, 6243070, 6393145, 6421054, 6282327, and 6624828; the latest
+ // one expires 10/7/19. This makes LCD antialiasing very ugly, so we
+ // instead fall back on NORMAL antialiasing.
+ anti_alias = FXFT_RENDER_MODE_NORMAL;
+ } else if ((m_RenderCaps & (FXRC_ALPHA_OUTPUT | FXRC_CMYK_OUTPUT))) {
anti_alias = FXFT_RENDER_MODE_LCD;
bNormal = TRUE;
} else if (m_bpp < 16) {
diff --git a/core/fxge/include/fx_font.h b/core/fxge/include/fx_font.h
index dad10f2ccb..6bc9b2e4c2 100644
--- a/core/fxge/include/fx_font.h
+++ b/core/fxge/include/fx_font.h
@@ -280,11 +280,13 @@ class CFX_FontMgr {
bool GetBuiltinFont(size_t index, const uint8_t** pFontData, uint32_t* size);
CFX_FontMapper* GetBuiltinMapper() const { return m_pBuiltinMapper.get(); }
FXFT_Library GetFTLibrary() const { return m_FTLibrary; }
+ bool FTLibrarySupportsHinting() const { return m_FTLibrarySupportsHinting; }
private:
std::unique_ptr<CFX_FontMapper> m_pBuiltinMapper;
std::map<CFX_ByteString, CTTFontDesc*> m_FaceMap;
FXFT_Library m_FTLibrary;
+ bool m_FTLibrarySupportsHinting;
};
class CFX_FontMapper {