Use linear metrics with new FreeType light autohint.
Starting in FreeType 2.8 the light hinting setting only hints in the y direction and can be used with linear metrics and subpixel positioning. Change-Id: I6e478a904001216ade7f319fe98aa863ac6bd672 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/211105 Auto-Submit: Ben Wagner <bungeman@google.com> Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
494aa3db9e
commit
c752054981
@ -129,6 +129,7 @@ public:
|
|||||||
, fGetVarAxisFlags(nullptr)
|
, fGetVarAxisFlags(nullptr)
|
||||||
, fLibrary(nullptr)
|
, fLibrary(nullptr)
|
||||||
, fIsLCDSupported(false)
|
, fIsLCDSupported(false)
|
||||||
|
, fLightHintingIsYOnly(false)
|
||||||
, fLCDExtra(0)
|
, fLCDExtra(0)
|
||||||
{
|
{
|
||||||
if (FT_New_Library(&gFTMemory, &fLibrary)) {
|
if (FT_New_Library(&gFTMemory, &fLibrary)) {
|
||||||
@ -176,6 +177,16 @@ public:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// The 'light' hinting is vertical only starting in 2.8.0.
|
||||||
|
#if SK_FREETYPE_MINIMUM_RUNTIME_VERSION >= 0x02080000
|
||||||
|
fLightHintingIsYOnly = true;
|
||||||
|
#else
|
||||||
|
if (major > 2 || ((major == 2 && minor > 8) || (major == 2 && minor == 8 && patch >= 0))) {
|
||||||
|
fLightHintingIsYOnly = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if SK_FREETYPE_MINIMUM_RUNTIME_VERSION >= 0x02080100
|
#if SK_FREETYPE_MINIMUM_RUNTIME_VERSION >= 0x02080100
|
||||||
fGetVarAxisFlags = FT_Get_Var_Axis_Flags;
|
fGetVarAxisFlags = FT_Get_Var_Axis_Flags;
|
||||||
#elif SK_FREETYPE_MINIMUM_RUNTIME_VERSION & SK_FREETYPE_DLOPEN
|
#elif SK_FREETYPE_MINIMUM_RUNTIME_VERSION & SK_FREETYPE_DLOPEN
|
||||||
@ -205,6 +216,7 @@ public:
|
|||||||
FT_Library library() { return fLibrary; }
|
FT_Library library() { return fLibrary; }
|
||||||
bool isLCDSupported() { return fIsLCDSupported; }
|
bool isLCDSupported() { return fIsLCDSupported; }
|
||||||
int lcdExtra() { return fLCDExtra; }
|
int lcdExtra() { return fLCDExtra; }
|
||||||
|
bool lightHintingIsYOnly() { return fLightHintingIsYOnly; }
|
||||||
|
|
||||||
// FT_Get_{MM,Var}_{Blend,Design}_Coordinates were added in FreeType 2.7.1.
|
// FT_Get_{MM,Var}_{Blend,Design}_Coordinates were added in FreeType 2.7.1.
|
||||||
// Prior to this there was no way to get the coordinates out of the FT_Face.
|
// Prior to this there was no way to get the coordinates out of the FT_Face.
|
||||||
@ -222,6 +234,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
FT_Library fLibrary;
|
FT_Library fLibrary;
|
||||||
bool fIsLCDSupported;
|
bool fIsLCDSupported;
|
||||||
|
bool fLightHintingIsYOnly;
|
||||||
int fLCDExtra;
|
int fLCDExtra;
|
||||||
|
|
||||||
// FT_Library_SetLcdFilterWeights was introduced in FreeType 2.4.0.
|
// FT_Library_SetLcdFilterWeights was introduced in FreeType 2.4.0.
|
||||||
@ -864,6 +877,9 @@ SkScalerContext_FreeType::SkScalerContext_FreeType(sk_sp<SkTypeface> typeface,
|
|||||||
break;
|
break;
|
||||||
case kSlight_SkFontHinting:
|
case kSlight_SkFontHinting:
|
||||||
loadFlags = FT_LOAD_TARGET_LIGHT; // This implies FORCE_AUTOHINT
|
loadFlags = FT_LOAD_TARGET_LIGHT; // This implies FORCE_AUTOHINT
|
||||||
|
if (gFTLibrary->lightHintingIsYOnly()) {
|
||||||
|
linearMetrics = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case kNormal_SkFontHinting:
|
case kNormal_SkFontHinting:
|
||||||
loadFlags = FT_LOAD_TARGET_NORMAL;
|
loadFlags = FT_LOAD_TARGET_NORMAL;
|
||||||
|
Loading…
Reference in New Issue
Block a user