[truetype] Simplify logic of rendering modes. This patch unifies the subpixel and non-subpixel cases. * src/truetype/ttinterp.h (TT_ExecContextRec): Remove `grayscale_hinting'; all code should refer to `grayscale' instead. Remove unused `native_hinting' member. Rename `subpixel_hinting' member to `subpixel. * src/truetype/ttgload.c (TT_LOADER_SET_PP): Updated. (tt_loader_init): Updated. * src/truetype/ttinterp.c (Ins_GETINFO): Simplify. Updated.
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 161 162 163 164 165 166 167 168
diff --git a/ChangeLog b/ChangeLog
index a53d7dc..b282e4f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2013-12-11 Infinality <infinality@infinality.net>
+
+ [truetype] Simplify logic of rendering modes.
+
+ This patch unifies the subpixel and non-subpixel cases.
+
+ * src/truetype/ttinterp.h (TT_ExecContextRec): Remove
+ `grayscale_hinting'; all code should refer to `grayscale' instead.
+ Remove unused `native_hinting' member.
+ Rename `subpixel_hinting' member to `subpixel.
+
+ * src/truetype/ttgload.c (TT_LOADER_SET_PP): Updated.
+ (tt_loader_init): Updated.
+
+ * src/truetype/ttinterp.c (Ins_GETINFO): Simplify.
+ Updated.
+
2013-12-11 Werner Lemberg <wl@gnu.org>
[documentation] Add section how to include FreeType header files.
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 1f82a1d..b10e390 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -1352,12 +1352,10 @@
#define TT_LOADER_SET_PP( loader ) \
do \
{ \
- FT_Bool subpixel_ = loader->exec \
- ? loader->exec->subpixel_hinting \
- : 0; \
- FT_Bool grayscale_ = loader->exec \
- ? loader->exec->grayscale_hinting \
- : 0; \
+ FT_Bool subpixel_ = loader->exec ? loader->exec->subpixel \
+ : 0; \
+ FT_Bool grayscale_ = loader->exec ? loader->exec->grayscale \
+ : 0; \
FT_Bool use_aw_2_ = (FT_Bool)( subpixel_ && grayscale_ ); \
\
\
@@ -2108,8 +2106,7 @@
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
- FT_Bool subpixel_hinting = FALSE;
- FT_Bool grayscale_hinting = TRUE;
+ FT_Bool subpixel = FALSE;
#if 0
/* not used yet */
@@ -2142,24 +2139,24 @@
if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
{
- subpixel_hinting = FT_BOOL( ( FT_LOAD_TARGET_MODE( load_flags )
- != FT_RENDER_MODE_MONO ) &&
- SPH_OPTION_SET_SUBPIXEL );
+ subpixel = FT_BOOL( ( FT_LOAD_TARGET_MODE( load_flags ) !=
+ FT_RENDER_MODE_MONO ) &&
+ SPH_OPTION_SET_SUBPIXEL );
- if ( subpixel_hinting )
- grayscale = grayscale_hinting = FALSE;
+ if ( subpixel )
+ grayscale = FALSE;
else if ( SPH_OPTION_SET_GRAYSCALE )
{
- grayscale = grayscale_hinting = TRUE;
- subpixel_hinting = FALSE;
+ grayscale = TRUE;
+ subpixel = FALSE;
}
else
- grayscale = grayscale_hinting = FALSE;
+ grayscale = FALSE;
if ( FT_IS_TRICKY( glyph->face ) )
- subpixel_hinting = grayscale_hinting = FALSE;
+ subpixel = FALSE;
- exec->ignore_x_mode = subpixel_hinting || grayscale_hinting;
+ exec->ignore_x_mode = subpixel || grayscale;
exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
if ( exec->sph_tweak_flags & SPH_TWEAK_RASTERIZER_35 )
exec->rasterizer_version = TT_INTERPRETER_VERSION_35;
@@ -2202,24 +2199,24 @@
{
/* a change from mono to subpixel rendering (and vice versa) */
/* requires a re-execution of the CVT program */
- if ( subpixel_hinting != exec->subpixel_hinting )
+ if ( subpixel != exec->subpixel )
{
FT_TRACE4(( "tt_loader_init: subpixel hinting change,"
" re-executing `prep' table\n" ));
- exec->subpixel_hinting = subpixel_hinting;
- reexecute = TRUE;
+ exec->subpixel = subpixel;
+ reexecute = TRUE;
}
/* a change from mono to grayscale rendering (and vice versa) */
/* requires a re-execution of the CVT program */
- if ( grayscale != exec->grayscale_hinting )
+ if ( grayscale != exec->grayscale )
{
FT_TRACE4(( "tt_loader_init: grayscale hinting change,"
" re-executing `prep' table\n" ));
- exec->grayscale_hinting = grayscale_hinting;
- reexecute = TRUE;
+ exec->grayscale = grayscale;
+ reexecute = TRUE;
}
}
else
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index 92e6d43..3f110c2 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -7820,13 +7820,6 @@
CUR.ignore_x_mode &&
CUR.rasterizer_version >= TT_INTERPRETER_VERSION_35 )
{
- /********************************/
- /* HINTING FOR GRAYSCALE */
- /* Selector Bit: 5 */
- /* Return Bit(s): 12 */
- /* */
- if ( ( args[0] & 32 ) != 0 && CUR.grayscale_hinting )
- K |= 1 << 12;
if ( CUR.rasterizer_version >= 37 )
{
@@ -7835,7 +7828,7 @@
/* Selector Bit: 6 */
/* Return Bit(s): 13 */
/* */
- if ( ( args[0] & 64 ) != 0 && CUR.subpixel_hinting )
+ if ( ( args[0] & 64 ) != 0 && CUR.subpixel )
K |= 1 << 13;
/********************************/
diff --git a/src/truetype/ttinterp.h b/src/truetype/ttinterp.h
index b3916ac..1d8825d 100644
--- a/src/truetype/ttinterp.h
+++ b/src/truetype/ttinterp.h
@@ -263,12 +263,10 @@ FT_BEGIN_HEADER
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
TT_Round_Func func_round_sphn; /* subpixel rounding function */
- FT_Bool grayscale_hinting; /* Using grayscale hinting? */
- FT_Bool subpixel_hinting; /* Using subpixel hinting? */
- FT_Bool native_hinting; /* Using native hinting? */
+ FT_Bool subpixel; /* Using subpixel hinting? */
FT_Bool ignore_x_mode; /* Standard rendering mode for */
/* subpixel hinting. On if gray */
- /* or subpixel hinting is on ) */
+ /* or subpixel hinting is on. */
/* The following 4 aren't fully implemented but here for MS rasterizer */
/* compatibility. */