summaryrefslogtreecommitdiffstats
path: root/src/base
diff options
context:
space:
mode:
authorSteve Kondik <shade@chemlab.org>2012-08-28 22:24:56 -0700
committerSteve Kondik <shade@chemlab.org>2012-08-29 00:08:19 -0700
commit4d3876eef9f90a75f2ae55e880759937482e6b3f (patch)
treed11d43d70415c861aabf09e1c77a2fc6c49cfd8e /src/base
parent8bef833fa7b6f73a362a99dcaa83ee5a98f58e4d (diff)
downloadandroid_external_freetype-4d3876eef9f90a75f2ae55e880759937482e6b3f.tar.gz
android_external_freetype-4d3876eef9f90a75f2ae55e880759937482e6b3f.tar.bz2
android_external_freetype-4d3876eef9f90a75f2ae55e880759937482e6b3f.zip
freetype: Add Infinality patchesjellybean-stablejellybean
* See here for details: * http://www.infinality.net/blog/infinality-freetype-patches/ Change-Id: I4f747e45332fc7f16fb22ac3499069519017035f
Diffstat (limited to 'src/base')
-rw-r--r--src/base/ftlcdfil.c46
-rw-r--r--src/base/ftobjs.c69
-rw-r--r--src/base/ftoutln.c22
-rw-r--r--src/base/ftsynth.c27
4 files changed, 161 insertions, 3 deletions
diff --git a/src/base/ftlcdfil.c b/src/base/ftlcdfil.c
index 0da4ba1..09a9551 100644
--- a/src/base/ftlcdfil.c
+++ b/src/base/ftlcdfil.c
@@ -21,6 +21,9 @@
#include FT_IMAGE_H
#include FT_INTERNAL_OBJECTS_H
+#include <math.h>
+#include <string.h>
+#include <strings.h>
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
@@ -287,10 +290,51 @@
{ 0x00, 0x55, 0x56, 0x55, 0x00 };
/* the values here sum up to a value larger than 256, */
/* providing a cheap gamma correction */
- static const FT_Byte default_filter[5] =
+ static FT_Byte default_filter[5] =
{ 0x10, 0x40, 0x70, 0x40, 0x10 };
+#ifdef FT_CONFIG_OPTION_INFINALITY_PATCHSET
+ int checked_filter_params_env = 0;
+ if ( checked_filter_params_env == 0 )
+ {
+ char *filter_params = getenv( "INFINALITY_FT_FILTER_PARAMS" );
+ if ( filter_params != NULL && strcmp(filter_params, "") != 0 )
+ {
+ float f1, f2, f3, f4, f5;
+ if ( strcasecmp(filter_params, "default" ) != 0)
+ {
+ int args_assigned = 0;
+ args_assigned = sscanf ( filter_params, "%f %f %f %f %f", &f1, &f2, &f3, &f4, &f5 );
+
+ if ( args_assigned == 5 )
+ {
+ if ( f1 + f2 + f3 + f4 + f5 > 5 )
+ {
+ /* Assume we were given integers instead of floats */
+ /* 0 to 100 */
+ default_filter[0] = (FT_Byte) (f1 * 2.55f + 0.5f);
+ default_filter[1] = (FT_Byte) (f2 * 2.55f + 0.5f);
+ default_filter[2] = (FT_Byte) (f3 * 2.55f + 0.5f);
+ default_filter[3] = (FT_Byte) (f4 * 2.55f + 0.5f);
+ default_filter[4] = (FT_Byte) (f5 * 2.55f + 0.5f);
+ }
+ else
+ {
+ /* Assume we were given floating point values */
+ /* 0 to 1.0 */
+ default_filter[0] = (FT_Byte) (f1 * 255.0f + 0.5f);
+ default_filter[1] = (FT_Byte) (f2 * 255.0f + 0.5f);
+ default_filter[2] = (FT_Byte) (f3 * 255.0f + 0.5f);
+ default_filter[3] = (FT_Byte) (f4 * 255.0f + 0.5f);
+ default_filter[4] = (FT_Byte) (f5 * 255.0f + 0.5f);
+ }
+ }
+ }
+ }
+ checked_filter_params_env = 1;
+ }
+#endif
if ( !library )
return FT_Err_Invalid_Argument;
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 36ee797..66a199a 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -513,6 +513,22 @@
ft_lookup_glyph_renderer( FT_GlyphSlot slot );
+#ifdef FT_CONFIG_OPTION_INFINALITY_PATCHSET
+ static void
+ ft_glyphslot_enlarge_metrics( FT_GlyphSlot slot,
+ FT_Render_Mode mode )
+ {
+ FT_Glyph_Metrics* metrics = &slot->metrics;
+ FT_Pos enlarge_cbox = 0;
+ /* enlarge for grayscale rendering */
+ if ( mode == FT_RENDER_MODE_NORMAL ) enlarge_cbox = 64;
+
+ metrics->horiBearingX -= enlarge_cbox;
+ metrics->width += 2*enlarge_cbox;
+ }
+#endif /* FT_CONFIG_OPTION_INFINALITY_PATCHSET */
+
+
#ifdef GRID_FIT_METRICS
static void
ft_glyphslot_grid_fit_metrics( FT_GlyphSlot slot,
@@ -571,8 +587,33 @@
FT_Bool autohint = FALSE;
FT_Module hinter;
TT_Face ttface = (TT_Face)face;
+#ifdef FT_CONFIG_OPTION_INFINALITY_PATCHSET
+ int checked_use_various_tweaks_env = FALSE;
+ FT_Bool use_various_tweaks = FALSE;
+
+ if ( !checked_use_various_tweaks_env )
+ {
+ char *use_various_tweaks_env = getenv( "INFINALITY_FT_USE_VARIOUS_TWEAKS" );
+ if ( use_various_tweaks_env != NULL )
+ {
+ if ( strcasecmp(use_various_tweaks_env, "default" ) != 0 )
+ {
+ if ( strcasecmp(use_various_tweaks_env, "true") == 0) use_various_tweaks = TRUE;
+ else if ( strcasecmp(use_various_tweaks_env, "1") == 0) use_various_tweaks = TRUE;
+ else if ( strcasecmp(use_various_tweaks_env, "on") == 0) use_various_tweaks = TRUE;
+ else if ( strcasecmp(use_various_tweaks_env, "yes") == 0) use_various_tweaks = TRUE;
+ }
+ }
+ checked_use_various_tweaks_env = 1;
+ }
+ /* Force autohint if no tt instructions */
+ if ( use_various_tweaks &&
+ ttface->num_locations &&
+ ttface->max_profile.maxSizeOfInstructions == 0 )
+ load_flags |= FT_LOAD_FORCE_AUTOHINT;
+#endif
if ( !face || !face->size || !face->glyph )
return FT_Err_Invalid_Face_Handle;
@@ -652,8 +693,18 @@
if ( autohint )
{
FT_AutoHinter_Service hinting;
-
-
+#ifdef FT_CONFIG_OPTION_INFINALITY_PATCHSET
+ if ( use_various_tweaks )
+ {
+ /* Force slight hinting over full hinting always */
+ load_flags &= ~FT_LOAD_TARGET_LCD;
+ load_flags &= ~FT_LOAD_TARGET_LCD_V;
+ load_flags &= ~FT_LOAD_TARGET_MONO;
+ load_flags &= ~FT_LOAD_TARGET_NORMAL;
+ load_flags |= FT_LOAD_TARGET_LIGHT;
+ /*printf("%d ", load_flags);*/
+ }
+#endif
/* try to load embedded bitmaps first if available */
/* */
/* XXX: This is really a temporary hack that should disappear */
@@ -691,6 +742,10 @@
}
else
{
+#ifdef FT_CONFIG_OPTION_INFINALITY_PATCHSET
+ char* c1 = "CUR_WIDTH";
+ char* c2 = "0";
+#endif
error = driver->clazz->load_glyph( slot,
face->size,
glyph_index,
@@ -698,6 +753,16 @@
if ( error )
goto Exit;
+#ifdef FT_CONFIG_OPTION_INFINALITY_PATCHSET
+ setenv(c1, c2, 1);
+
+ {
+ /* fix for sdl_ttf */
+ FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags );
+ ft_glyphslot_enlarge_metrics( slot, mode );
+ }
+#endif
+
if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
{
/* check that the loaded outline is correct */
diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c
index 76e2b04..fa4ee0d 100644
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -897,7 +897,29 @@
FT_Vector v_prev, v_first, v_next, v_cur;
FT_Int c, n, first;
FT_Int orientation;
+#ifdef FT_CONFIG_OPTION_INFINALITY_PATCHSET
+ int checked_use_various_tweaks_env = 0;
+ FT_Bool use_various_tweaks = FALSE;
+ if ( checked_use_various_tweaks_env == 0 )
+ {
+ char *use_various_tweaks_env = getenv( "INFINALITY_FT_USE_VARIOUS_TWEAKS" );
+ if ( use_various_tweaks_env != NULL )
+ {
+ if ( strcasecmp(use_various_tweaks_env, "default" ) != 0 )
+ {
+ if ( strcasecmp(use_various_tweaks_env, "true") == 0) use_various_tweaks = TRUE;
+ else if ( strcasecmp(use_various_tweaks_env, "1") == 0) use_various_tweaks = TRUE;
+ else if ( strcasecmp(use_various_tweaks_env, "on") == 0) use_various_tweaks = TRUE;
+ else if ( strcasecmp(use_various_tweaks_env, "yes") == 0) use_various_tweaks = TRUE;
+ }
+ }
+ checked_use_various_tweaks_env = 1;
+ }
+
+ if ( use_various_tweaks )
+ ystrength = FT_PIX_FLOOR ( ystrength );
+#endif
if ( !outline )
return FT_Err_Invalid_Argument;
diff --git a/src/base/ftsynth.c b/src/base/ftsynth.c
index 81e2ed2..b186d8d 100644
--- a/src/base/ftsynth.c
+++ b/src/base/ftsynth.c
@@ -88,7 +88,26 @@
FT_Face face = slot->face;
FT_Error error;
FT_Pos xstr, ystr;
+#ifdef FT_CONFIG_OPTION_INFINALITY_PATCHSET
+ int checked_use_various_tweaks_env = 0;
+ FT_Bool use_various_tweaks = FALSE;
+ if ( checked_use_various_tweaks_env == 0 )
+ {
+ char *use_various_tweaks_env = getenv( "INFINALITY_FT_USE_VARIOUS_TWEAKS" );
+ if ( use_various_tweaks_env != NULL )
+ {
+ if ( strcasecmp(use_various_tweaks_env, "default" ) != 0 )
+ {
+ if ( strcasecmp(use_various_tweaks_env, "true") == 0) use_various_tweaks = TRUE;
+ else if ( strcasecmp(use_various_tweaks_env, "1") == 0) use_various_tweaks = TRUE;
+ else if ( strcasecmp(use_various_tweaks_env, "on") == 0) use_various_tweaks = TRUE;
+ else if ( strcasecmp(use_various_tweaks_env, "yes") == 0) use_various_tweaks = TRUE;
+ }
+ }
+ checked_use_various_tweaks_env = 1;
+ }
+#endif
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE &&
slot->format != FT_GLYPH_FORMAT_BITMAP )
@@ -101,6 +120,11 @@
if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
{
+#ifdef FT_CONFIG_OPTION_INFINALITY_PATCHSET
+ if ( use_various_tweaks )
+ (void)FT_Outline_EmboldenXY( &slot->outline, xstr, FT_PIX_FLOOR( ystr ) );
+ else
+#endif
/* ignore error */
(void)FT_Outline_EmboldenXY( &slot->outline, xstr, ystr );
}
@@ -141,6 +165,9 @@
slot->metrics.width += xstr;
slot->metrics.height += ystr;
+#ifdef FT_CONFIG_OPTION_INFINALITY_PATCHSET
+ /*if ( !use_various_tweaks ) */
+#endif
slot->metrics.horiAdvance += xstr;
slot->metrics.vertAdvance += ystr;