* src/smooth/ftgrays.c: adding experimental "gamma" support. This produces smoother glyphs at small sizes for very little cost * src/autohint/ahglyph.c, src/autohint/ahhint.c: various fixes to the auto-hinter. They merely improve the output of sans-serif fonts. Note that there are still problems with serifed fonts and composites (accented characters) * tests/gview.c: updated the debugging glyph viewer to show the hints generated by the "autohint" module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
diff --git a/ChangeLog b/ChangeLog
index 1a3d575..e7c5239 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2001-10-29 David Turner <david@freetype.org>
+
+ * src/smooth/ftgrays.c: adding experimental "gamma" support. This
+ produces smoother glyphs at small sizes for very little cost
+
+ * src/autohint/ahglyph.c, src/autohint/ahhint.c: various fixes to
+ the auto-hinter. They merely improve the output of sans-serif fonts.
+ Note that there are still problems with serifed fonts and composites
+ (accented characters)
+
+ * tests/gview.c: updated the debugging glyph viewer to show the
+ hints generated by the "autohint" module
+
+
2001-10-27 David Turner <david@freetype.org>
* src/cache/ftchunk.c (ftc_chunk_cache_lookup): fixed a bug that
diff --git a/src/autohint/ahglyph.c b/src/autohint/ahglyph.c
index 667f830..5c2f4f7 100644
--- a/src/autohint/ahglyph.c
+++ b/src/autohint/ahglyph.c
@@ -994,7 +994,7 @@
dist = -dist;
if ( len < 8 )
- score = 300 + dist;
+ score = 300*8 + dist - len*3;
else
score = dist + 300/len;
diff --git a/src/autohint/ahhint.c b/src/autohint/ahhint.c
index 11ace9f..1dd003c 100644
--- a/src/autohint/ahhint.c
+++ b/src/autohint/ahhint.c
@@ -169,10 +169,12 @@
if ( base->flags & ah_edge_done )
{
if ( dist >= 64 )
- dist = ( dist + 8 ) & -64;
+ dist = (dist+8) & -64;
else if ( dist <= 32 && !vertical )
dist = ( dist + 33 ) >> 1;
+ else
+ dist = 0;
}
serif->pos = base->pos + sign * dist;
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 54a814f..031a1d9 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -84,6 +84,10 @@
#include <string.h> /* for memcpy() */
#include <setjmp.h>
+
+/* experimental support for gamma correction within the rasterizer */
+#define GRAYS_USE_GAMMA
+
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@@ -305,6 +309,10 @@
void* memory;
jmp_buf jump_buffer;
+#ifdef GRAYS_USE_GAMMA
+ FT_Byte gamma[257];
+#endif
+
} TRaster, *PRaster;
@@ -1230,15 +1238,21 @@
for ( ; count > 0; count--, spans++ )
{
- if ( spans->coverage )
+ FT_UInt coverage = spans->coverage;
+
+#ifdef GRAYS_USE_GAMMA
+ coverage = raster->gamma[(FT_Byte)coverage];
+#endif
+
+ if ( coverage )
#if 1
- MEM_Set( p + spans->x, (unsigned char)spans->coverage, spans->len );
+ MEM_Set( p + spans->x, (unsigned char)coverage, spans->len );
#else /* 1 */
{
q = p + spans->x;
limit = q + spans->len;
for ( ; q < limit; q++ )
- q[0] = (unsigned char)spans->coverage;
+ q[0] = (unsigned char)coverage;
}
#endif /* 1 */
}
@@ -1960,6 +1974,33 @@
/**** RASTER OBJECT CREATION: In standalone mode, we simply use *****/
/**** a static object. *****/
+#ifdef GRAYS_USE_GAMMA
+
+ /* initialize the "gamma" table. Yes, this is really a crummy function */
+ /* but the results look pretty good for something that simple.. */
+ /* */
+#define M_MAX 255
+#define M_X 128
+#define M_Y 96
+
+ static void
+ grays_init_gamma( PRaster raster )
+ {
+ FT_UInt x, a;
+
+ for ( x = 0; x < 256; x++ )
+ {
+ if ( x <= M_X )
+ a = (x * M_Y + (M_X/2)) / M_X;
+ else
+ a = M_Y + ((x-M_X)*(M_MAX-M_Y) + (M_MAX-M_X)/2)/(M_MAX-M_X);
+
+ raster->gamma[x] = (FT_Byte)a;
+ }
+ }
+
+#endif /* GRAYS_USE_GAMMA */
+
#ifdef _STANDALONE_
static int
@@ -1974,6 +2015,10 @@
*araster = (FT_Raster)&the_raster;
MEM_Set( &the_raster, 0, sizeof ( the_raster ) );
+#ifdef GRAYS_USE_GAMMA
+ grays_init_gamma( (PRaster)*araster );
+#endif
+
return 0;
}
@@ -2000,6 +2045,10 @@
{
raster->memory = memory;
*araster = (FT_Raster)raster;
+
+#ifdef GRAYS_USE_GAMMA
+ grays_init_gamma( raster );
+#endif
}
return error;