From de8be21859ce52b5f9b4d9e33687c42c9ea79fb1 Mon Sep 17 00:00:00 2001 From: Andrew Weintraub Date: Thu, 4 Jan 2018 16:23:07 -0500 Subject: Always enable hinting with versions of Freetype >= 2.8.1, which include subpixel rendering unencumbered by patents. Bug: Change-Id: Idaff1bf21a1d17b6ea40b9fecec04c5f2d0c9392 Reviewed-on: https://pdfium-review.googlesource.com/22012 Reviewed-by: dsinclair Commit-Queue: dsinclair --- core/fxge/cfx_fontmgr.cpp | 10 +++++++++- core/fxge/fx_freetype.h | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/fxge/cfx_fontmgr.cpp b/core/fxge/cfx_fontmgr.cpp index d9b03549e0..0d4524c954 100644 --- a/core/fxge/cfx_fontmgr.cpp +++ b/core/fxge/cfx_fontmgr.cpp @@ -98,9 +98,17 @@ void CFX_FontMgr::InitFTLibrary() { if (m_FTLibrary) return; FXFT_Init_FreeType(&m_FTLibrary); + FT_Int major; + FT_Int minor; + FT_Int patch; + FXFT_Library_Version(m_FTLibrary, &major, &minor, &patch); + // Freetype versions >= 2.8.1 support hinting even if subpixel rendering is + // disabled. https://sourceforge.net/projects/freetype/files/freetype2/2.8.1/ m_FTLibrarySupportsHinting = + major > 2 || (major >= 2 && minor > 8) || + (major >= 2 && minor >= 8 && patch >= 1) || FXFT_Library_SetLcdFilter(m_FTLibrary, FT_LCD_FILTER_DEFAULT) != - FT_Err_Unimplemented_Feature; + FT_Err_Unimplemented_Feature; } void CFX_FontMgr::SetSystemFontInfo( diff --git a/core/fxge/fx_freetype.h b/core/fxge/fx_freetype.h index 97d5407eb9..8a5fd5dda3 100644 --- a/core/fxge/fx_freetype.h +++ b/core/fxge/fx_freetype.h @@ -69,6 +69,9 @@ using FXFT_Outline_Funcs = FT_Outline_Funcs; FT_Done_FreeType(static_cast(library)) #define FXFT_Init_FreeType(library) \ FT_Init_FreeType(reinterpret_cast(library)) +#define FXFT_Library_Version(library, amajor, aminor, apatch) \ + FT_Library_Version(reinterpret_cast(library), amajor, aminor, \ + apatch) #define FXFT_New_Memory_Face(library, base, size, index, face) \ FT_New_Memory_Face(static_cast(library), base, size, index, \ static_cast(face)) -- cgit v1.2.3