Guest User

Untitled

a guest
Mar 17th, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 121.26 KB | None | 0 0
  1. diff -Nur builds/unix/configure.orig builds/unix/configure
  2. --- builds/unix/configure.orig  2011-11-15 00:53:50.000000000 -0600
  3. +++ builds/unix/configure   2011-12-23 19:35:33.334187810 -0600
  4. @@ -16,6 +16,8 @@
  5.  ## M4sh Initialization. ##
  6.  ## -------------------- ##
  7.  
  8. +CFLAGS="$CFLAGS -D_GNU_SOURCE=1"
  9. +
  10.  # Be more Bourne compatible
  11.  DUALCASE=1; export DUALCASE # for MKS sh
  12.  if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
  13. diff -Nur devel/ftoption.h.orig devel/ftoption.h
  14. --- devel/ftoption.h.orig   2011-07-19 23:46:00.000000000 -0500
  15. +++ devel/ftoption.h    2011-11-17 20:59:44.148885820 -0600
  16. @@ -560,6 +560,48 @@
  17.  
  18.    /*************************************************************************/
  19.    /*                                                                       */
  20. +  /* Define TT_CONFIG_OPTION_SUBPIXEL_HINTING if you want to compile       */
  21. +  /* EXPERIMENTAL subpixel hinting support into the TrueType driver.  This */
  22. +  /* replaces the native TrueType hinting mechanism when anything but      */
  23. +  /* FT_RENDER_MODE_MONO is requested.                                     */
  24. +  /*                                                                       */
  25. +  /* Enabling this causes the TrueType driver to ignore instructions under */
  26. +  /* certain conditions.  This is done in accordance with the guide here,  */
  27. +  /* with some minor differences:                                          */
  28. +  /*                                                                       */
  29. +  /*  http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx */
  30. +  /*                                                                       */
  31. +  /* By undefining this, you only compile the code necessary to hint       */
  32. +  /* TrueType glyphs with native TT hinting.                               */
  33. +  /*                                                                       */
  34. +  /*   This option requires TT_CONFIG_OPTION_BYTECODE_INTERPRETER to be    */
  35. +  /*   defined.                                                            */
  36. +  /*                                                                       */
  37. +#define TT_CONFIG_OPTION_SUBPIXEL_HINTING
  38. +
  39. +
  40. +  /*************************************************************************/
  41. +  /*                                                                       */
  42. +  /* Define TT_CONFIG_OPTION_SUBPIXEL_HINTING_ADDITIONAL_TWEAKS if you     */
  43. +  /* want to enable additional subpixel hinting tweaks of individual       */
  44. +  /* fonts, glyphs, styles and sizes.  The idea here is that some glyphs   */
  45. +  /* and fonts still do not render in a desirable way with                 */
  46. +  /* TT_CONFIG_OPTION_SUBPIXEL_HINTING.                                    */
  47. +  /*                                                                       */
  48. +  /* This is disabled by default, as some people may not care, or may not  */
  49. +  /* want the additional overhead involved in doing this.                  */
  50. +  /*                                                                       */
  51. +  /* By undefining this, you only compile the code necessary to do         */
  52. +  /* subpixel hinting as defined above.                                    */
  53. +  /*                                                                       */
  54. +  /*   This option requires TT_CONFIG_OPTION_SUBPIXEL_HINTING to be        */
  55. +  /*   defined.                                                            */
  56. +  /*                                                                       */
  57. +#define TT_CONFIG_OPTION_SUBPIXEL_HINTING_ADDITIONAL_TWEAKS
  58. +
  59. +
  60. +  /*************************************************************************/
  61. +  /*                                                                       */
  62.    /* If you define TT_CONFIG_OPTION_UNPATENTED_HINTING, a special version  */
  63.    /* of the TrueType bytecode interpreter is used that doesn't implement   */
  64.    /* any of the patented opcodes and algorithms.  The patents related to   */
  65. diff -Nur include/freetype/config/ftoption.h.orig include/freetype/config/ftoption.h
  66. --- include/freetype/config/ftoption.h.orig 2011-07-19 23:46:15.000000000 -0500
  67. +++ include/freetype/config/ftoption.h  2011-11-17 20:59:44.149885785 -0600
  68. @@ -560,6 +560,48 @@
  69.  
  70.    /*************************************************************************/
  71.    /*                                                                       */
  72. +  /* Define TT_CONFIG_OPTION_SUBPIXEL_HINTING if you want to compile       */
  73. +  /* EXPERIMENTAL subpixel hinting support into the TrueType driver.  This */
  74. +  /* replaces the native TrueType hinting mechanism when anything but      */
  75. +  /* FT_RENDER_MODE_MONO is requested.                                     */
  76. +  /*                                                                       */
  77. +  /* Enabling this causes the TrueType driver to ignore instructions under */
  78. +  /* certain conditions.  This is done in accordance with the guide here,  */
  79. +  /* with some minor differences:                                          */
  80. +  /*                                                                       */
  81. +  /*  http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx */
  82. +  /*                                                                       */
  83. +  /* By undefining this, you only compile the code necessary to hint       */
  84. +  /* TrueType glyphs with native TT hinting.                               */
  85. +  /*                                                                       */
  86. +  /*   This option requires TT_CONFIG_OPTION_BYTECODE_INTERPRETER to be    */
  87. +  /*   defined.                                                            */
  88. +  /*                                                                       */
  89. +/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  90. +
  91. +
  92. +  /*************************************************************************/
  93. +  /*                                                                       */
  94. +  /* Define TT_CONFIG_OPTION_SUBPIXEL_HINTING_ADDITIONAL_TWEAKS if you     */
  95. +  /* want to enable additional subpixel hinting tweaks of individual       */
  96. +  /* fonts, glyphs, styles and sizes.  The idea here is that some glyphs   */
  97. +  /* and fonts still do not render in a desirable way with                 */
  98. +  /* TT_CONFIG_OPTION_SUBPIXEL_HINTING.                                    */
  99. +  /*                                                                       */
  100. +  /* This is disabled by default, as some people may not care, or may not  */
  101. +  /* want the additional overhead involved in doing this.                  */
  102. +  /*                                                                       */
  103. +  /* By undefining this, you only compile the code necessary to do         */
  104. +  /* subpixel hinting as defined above.                                    */
  105. +  /*                                                                       */
  106. +  /*   This option requires TT_CONFIG_OPTION_SUBPIXEL_HINTING to be        */
  107. +  /*   defined.                                                            */
  108. +  /*                                                                       */
  109. +/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING_ADDITIONAL_TWEAKS */
  110. +
  111. +
  112. +  /*************************************************************************/
  113. +  /*                                                                       */
  114.    /* If you define TT_CONFIG_OPTION_UNPATENTED_HINTING, a special version  */
  115.    /* of the TrueType bytecode interpreter is used that doesn't implement   */
  116.    /* any of the patented opcodes and algorithms.  The patents related to   */
  117. diff -Nur include/freetype/internal/ftobjs.h.orig include/freetype/internal/ftobjs.h
  118. --- include/freetype/internal/ftobjs.h.orig 2010-07-18 11:07:31.000000000 -0500
  119. +++ include/freetype/internal/ftobjs.h  2011-11-17 20:59:44.150885751 -0600
  120. @@ -81,6 +81,14 @@
  121.  #define FT_PIX_ROUND( x )     FT_PIX_FLOOR( (x) + 32 )
  122.  #define FT_PIX_CEIL( x )      FT_PIX_FLOOR( (x) + 63 )
  123.  
  124. +  /*
  125. +   *  These are used in ttinterp.c for subpixel hinting with an
  126. +   *  adjustable grids-per-pixel value.
  127. +   */
  128. +#define FT_PIX_FLOOR_GRID( x, n )  ( (x) & ~( 64 / n - 1 ) )
  129. +#define FT_PIX_ROUND_GRID( x, n )  FT_PIX_FLOOR_GRID( (x) + 32 / n, n )
  130. +#define FT_PIX_CEIL_GRID( x, n )   FT_PIX_FLOOR_GRID( (x) + 63 / n, n )
  131. +
  132.  
  133.    /*
  134.     *  Return the highest power of 2 that is <= value; this correspond to
  135. diff -Nur src/truetype/rules.mk.orig src/truetype/rules.mk
  136. --- src/truetype/rules.mk.orig  2011-01-03 00:06:51.000000000 -0600
  137. +++ src/truetype/rules.mk   2011-11-17 20:59:44.152885682 -0600
  138. @@ -31,7 +31,8 @@
  139.                $(TT_DIR)/ttinterp.c \
  140.                $(TT_DIR)/ttobjs.c   \
  141.                $(TT_DIR)/ttpic.c    \
  142. -              $(TT_DIR)/ttpload.c
  143. +              $(TT_DIR)/ttpload.c  \
  144. +              $(TT_DIR)/ttsubpix.c
  145.  
  146.  # TrueType driver headers
  147.  #
  148. diff -Nur src/truetype/truetype.c.orig src/truetype/truetype.c
  149. --- src/truetype/truetype.c.orig    2009-07-03 08:28:24.000000000 -0500
  150. +++ src/truetype/truetype.c 2011-11-17 20:59:44.152885682 -0600
  151. @@ -27,6 +27,7 @@
  152.  
  153.  #ifdef TT_USE_BYTECODE_INTERPRETER
  154.  #include "ttinterp.c"
  155. +#include "ttsubpix.c"
  156.  #endif
  157.  
  158.  #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
  159. diff -Nur src/truetype/ttgload.c.orig src/truetype/ttgload.c
  160. --- src/truetype/ttgload.c.orig 2011-04-21 00:31:48.000000000 -0500
  161. +++ src/truetype/ttgload.c  2011-12-23 19:40:19.001348135 -0600
  162. @@ -32,6 +32,7 @@
  163.  #endif
  164.  
  165.  #include "tterrors.h"
  166. +#include "ttsubpix.h"
  167.  
  168.  
  169.    /*************************************************************************/
  170. @@ -149,6 +150,19 @@
  171.      loader->top_bearing  = top_bearing;
  172.      loader->vadvance     = advance_height;
  173.  
  174. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  175. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING_ADDITIONAL_TWEAKS
  176. +
  177. +    if ( loader->exec )
  178. +      loader->exec->sph_tweak_flags = 0;
  179. +
  180. +    /* this may not be the right place for this, but it works */
  181. +    if ( loader->exec && loader->exec->enhanced_mode )
  182. +      sph_set_tweaks( loader, glyph_index );
  183. +
  184. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING_ADDITIONAL_TWEAKS */
  185. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  186. +
  187.      if ( !loader->linear_def )
  188.      {
  189.        loader->linear_def = 1;
  190. @@ -920,6 +934,10 @@
  191.        error = TT_Hint_Glyph( loader, 0 );
  192.      }
  193.  
  194. +    /* crashy */
  195. +    /*if  ( loader->exec->sph_tweak_flags & SPH_TWEAK_DEEMBOLDEN )
  196. +      FT_Outline_Embolden(outline, 24);*/
  197. +
  198.      return error;
  199.    }
  200.  
  201. @@ -1651,12 +1669,23 @@
  202.      {
  203.        FT_Byte*  widthp;
  204.  
  205. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  206. +      FT_Bool   enhanced_mode;
  207. +
  208. +
  209. +      enhanced_mode = FT_BOOL( FT_LOAD_TARGET_MODE( loader->load_flags ) !=
  210. +                          FT_RENDER_MODE_MONO );
  211. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  212.  
  213.        widthp = tt_face_get_device_metrics( face,
  214.                                             size->root.metrics.x_ppem,
  215.                                             glyph_index );
  216.  
  217. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  218. +      if ( ( !enhanced_mode || SPH_OPTION_BITMAP_WIDTHS ) && widthp )
  219. +#else
  220.        if ( widthp )
  221. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  222.          glyph->metrics.horiAdvance = *widthp << 6;
  223.      }
  224.  
  225. @@ -1851,6 +1880,15 @@
  226.      {
  227.        TT_ExecContext  exec;
  228.        FT_Bool         grayscale;
  229. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  230. +      FT_Bool         subpixel_hinting;
  231. +      FT_Bool         grayscale_hinting;
  232. +#if 0
  233. +      FT_Bool         compatible_widths;
  234. +      FT_Bool         symmetrical_smoothing;
  235. +      FT_Bool         bgr;
  236. +#endif
  237. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  238.  
  239.  
  240.        if ( !size->cvt_ready )
  241. @@ -1868,11 +1906,88 @@
  242.        if ( !exec )
  243.          return TT_Err_Could_Not_Find_Context;
  244.  
  245. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  246. +
  247. +      subpixel_hinting = FT_BOOL( ( FT_LOAD_TARGET_MODE( load_flags )
  248. +                                    != FT_RENDER_MODE_MONO )          &&
  249. +                                  SPH_OPTION_SET_SUBPIXEL             );
  250. +
  251. +      if ( subpixel_hinting )
  252. +        grayscale = grayscale_hinting = FALSE;
  253. +
  254. +      else if ( SPH_OPTION_SET_GRAYSCALE )
  255. +      {
  256. +        grayscale = grayscale_hinting = TRUE;
  257. +        subpixel_hinting = FALSE;
  258. +      }
  259. +
  260. +      if ( FT_IS_TRICKY( glyph->face ) )
  261. +      {
  262. +        subpixel_hinting = grayscale_hinting = FALSE;
  263. +      }
  264. +
  265. +      exec->enhanced_mode      = subpixel_hinting || grayscale_hinting;
  266. +      exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
  267. +      if ( exec->sph_tweak_flags & SPH_TWEAK_RASTERIZER_35 )
  268. +        exec->rasterizer_version = 35;    
  269. +
  270. +#if 1
  271. +      exec->compatible_widths     = SPH_OPTION_SET_COMPATIBLE_WIDTHS;
  272. +      exec->symmetrical_smoothing = FALSE;
  273. +      exec->bgr                   = FALSE;
  274. +#else /* 0 */
  275. +      exec->compatible_widths =
  276. +        FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
  277. +                 TT_LOAD_COMPATIBLE_WIDTHS );
  278. +      exec->symmetrical_smoothing =
  279. +        FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
  280. +                 TT_LOAD_SYMMETRICAL_SMOOTHING );
  281. +      exec->bgr =
  282. +        FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
  283. +                 TT_LOAD_BGR );
  284. +#endif /* 0 */
  285. +
  286. +#else /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  287. +
  288.        grayscale =
  289.          FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) != FT_RENDER_MODE_MONO );
  290.  
  291. +#endif /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  292. +
  293.        TT_Load_Context( exec, face, size );
  294.  
  295. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  296. +
  297. +      /* a change from mono to subpixel rendering (and vice versa) */
  298. +      /* requires a re-execution of the CVT program                */
  299. +      if ( subpixel_hinting != exec->subpixel_hinting )
  300. +      {
  301. +        FT_UInt  i;
  302. +
  303. +
  304. +        exec->subpixel_hinting = subpixel_hinting;
  305. +
  306. +        for ( i = 0; i < size->cvt_size; i++ )
  307. +          size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
  308. +        tt_size_run_prep( size, pedantic );
  309. +      }
  310. +
  311. +      /* a change from mono to grayscale rendering (and vice versa) */
  312. +      /* requires a re-execution of the CVT program                 */
  313. +      if ( grayscale != exec->grayscale_hinting )
  314. +      {
  315. +        FT_UInt  i;
  316. +
  317. +
  318. +        exec->grayscale_hinting = grayscale_hinting;
  319. +
  320. +        for ( i = 0; i < size->cvt_size; i++ )
  321. +          size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
  322. +        tt_size_run_prep( size, pedantic );
  323. +      }
  324. +
  325. +#else /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  326. +
  327.        /* a change from mono to grayscale rendering (and vice versa) */
  328.        /* requires a re-execution of the CVT program                 */
  329.        if ( grayscale != exec->grayscale )
  330. @@ -1890,6 +2005,8 @@
  331.          tt_size_run_prep( size, pedantic );
  332.        }
  333.  
  334. +#endif /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  335. +
  336.        /* see whether the cvt program has disabled hinting */
  337.        if ( exec->GS.instruct_control & 1 )
  338.          load_flags |= FT_LOAD_NO_HINTING;
  339. diff -Nur src/truetype/ttinterp.c.orig src/truetype/ttinterp.c
  340. --- src/truetype/ttinterp.c.orig    2011-10-25 13:17:23.000000000 -0500
  341. +++ src/truetype/ttinterp.c 2011-12-23 19:46:15.342075740 -0600
  342. @@ -27,13 +27,16 @@
  343.  #include FT_SYSTEM_H
  344.  
  345.  #include "ttinterp.h"
  346. -
  347.  #include "tterrors.h"
  348. +#include "ttsubpix.h"
  349.  
  350.  
  351.  #ifdef TT_USE_BYTECODE_INTERPRETER
  352.  
  353.  
  354. +#define xxxSPH_DEBUG
  355. +#define xxxSPH_DEBUG_MORE_VERBOSE
  356. +
  357.  #define TT_MULFIX           FT_MulFix
  358.  #define TT_MULDIV           FT_MulDiv
  359.  #define TT_MULDIV_NO_ROUND  FT_MulDiv_No_Round
  360. @@ -153,11 +156,11 @@
  361.  #define NORMalize( x, y, v ) \
  362.            Normalize( EXEC_ARG_ x, y, v )
  363.  
  364. -#define SET_SuperRound( scale, flags ) \
  365. -          SetSuperRound( EXEC_ARG_ scale, flags )
  366. +#define SET_SuperRound( scale, flags, res ) \
  367. +          SetSuperRound( EXEC_ARG_ scale, flags, res )
  368.  
  369. -#define ROUND_None( d, c ) \
  370. -          Round_None( EXEC_ARG_ d, c )
  371. +#define ROUND_None( d, c, e ) \
  372. +          Round_None( EXEC_ARG_ d, c, e )
  373.  
  374.  #define INS_Goto_CodeRange( range, ip ) \
  375.            Ins_Goto_CodeRange( EXEC_ARG_ range, ip )
  376. @@ -168,8 +171,8 @@
  377.  #define CUR_Func_move_orig( z, p, d ) \
  378.            CUR.func_move_orig( EXEC_ARG_ z, p, d )
  379.  
  380. -#define CUR_Func_round( d, c ) \
  381. -          CUR.func_round( EXEC_ARG_ d, c )
  382. +#define CUR_Func_round( d, c, e ) \
  383. +          CUR.func_round( EXEC_ARG_ d, c, e )
  384.  
  385.  #define CUR_Func_read_cvt( index ) \
  386.            CUR.func_read_cvt( EXEC_ARG_ index )
  387. @@ -249,6 +252,14 @@
  388.  #define GUESS_VECTOR( V )
  389.  #endif
  390.  
  391. +
  392. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  393. +    /*FT_Int    CUR.num_delta_funcs;
  394. +    FT_ULong  inline_delta_funcs[5];
  395. +    FT_Long   CUR.in_delta_function;*/
  396. +#endif
  397. +
  398. +
  399.    /*************************************************************************/
  400.    /*                                                                       */
  401.    /*                        CODERANGE FUNCTIONS                            */
  402. @@ -1846,16 +1857,26 @@
  403.      FT_ASSERT( !CUR.face->unpatented_hinting );
  404.  #endif
  405.  
  406. -    v = CUR.GS.freeVector.x;
  407. -
  408. -    if ( v != 0 )
  409. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  410. +    if ( !CUR.enhanced_mode                                         ||
  411. +         ( CUR.sph_tweak_flags & SPH_TWEAK_ALLOW_DMOVE_FREEV ) )
  412.      {
  413. -      zone->cur[point].x += TT_MULDIV( distance,
  414. -                                       v * 0x10000L,
  415. -                                       CUR.F_dot_P );
  416. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  417. +
  418. +      v = CUR.GS.freeVector.x;
  419. +
  420. +      if ( v != 0 )
  421. +      {
  422. +        zone->cur[point].x += TT_MULDIV( distance,
  423. +                                         v * 0x10000L,
  424. +                                         CUR.F_dot_P );
  425.  
  426. -      zone->tags[point] |= FT_CURVE_TAG_TOUCH_X;
  427. +        zone->tags[point] |= FT_CURVE_TAG_TOUCH_X;
  428. +      }
  429. +
  430. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  431.      }
  432. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  433.  
  434.      v = CUR.GS.freeVector.y;
  435.  
  436. @@ -1932,8 +1953,18 @@
  437.    {
  438.      FT_UNUSED_EXEC;
  439.  
  440. -    zone->cur[point].x += distance;
  441. -    zone->tags[point]  |= FT_CURVE_TAG_TOUCH_X;
  442. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  443. +    if ( !CUR.enhanced_mode                                          ||
  444. +         ( CUR.sph_tweak_flags & SPH_TWEAK_ALLOW_DMOVEX_FREEV ) )
  445. +    {
  446. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  447. +
  448. +      zone->cur[point].x += distance;
  449. +      zone->tags[point]  |= FT_CURVE_TAG_TOUCH_X;
  450. +
  451. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  452. +    }
  453. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  454.    }
  455.  
  456.  
  457. @@ -1994,6 +2025,8 @@
  458.    /*                                                                       */
  459.    /*    compensation :: The engine compensation.                           */
  460.    /*                                                                       */
  461. +  /*    resolution   :: The grid resolution.                               */
  462. +  /*                                                                       */
  463.    /* <Return>                                                              */
  464.    /*    The compensated distance.                                          */
  465.    /*                                                                       */
  466. @@ -2005,11 +2038,13 @@
  467.    /*                                                                       */
  468.    static FT_F26Dot6
  469.    Round_None( EXEC_OP_ FT_F26Dot6  distance,
  470. -                       FT_F26Dot6  compensation )
  471. +                       FT_F26Dot6  compensation,
  472. +                       FT_Int      resolution )
  473.    {
  474.      FT_F26Dot6  val;
  475.  
  476.      FT_UNUSED_EXEC;
  477. +    FT_UNUSED( resolution );
  478.  
  479.  
  480.      if ( distance >= 0 )
  481. @@ -2024,6 +2059,7 @@
  482.        if ( val > 0 )
  483.          val = 0;
  484.      }
  485. +
  486.      return val;
  487.    }
  488.  
  489. @@ -2041,12 +2077,15 @@
  490.    /*                                                                       */
  491.    /*    compensation :: The engine compensation.                           */
  492.    /*                                                                       */
  493. +  /*    resolution   :: The grid resolution.                               */
  494. +  /*                                                                       */
  495.    /* <Return>                                                              */
  496.    /*    Rounded distance.                                                  */
  497.    /*                                                                       */
  498.    static FT_F26Dot6
  499.    Round_To_Grid( EXEC_OP_ FT_F26Dot6  distance,
  500. -                          FT_F26Dot6  compensation )
  501. +                          FT_F26Dot6  compensation,
  502. +                          FT_Int      resolution )
  503.    {
  504.      FT_F26Dot6  val;
  505.  
  506. @@ -2055,15 +2094,15 @@
  507.  
  508.      if ( distance >= 0 )
  509.      {
  510. -      val = distance + compensation + 32;
  511. +      val = distance + compensation + 32 / resolution;
  512.        if ( distance && val > 0 )
  513. -        val &= ~63;
  514. +        val &= ~( 64 / resolution - 1 );
  515.        else
  516.          val = 0;
  517.      }
  518.      else
  519.      {
  520. -      val = -FT_PIX_ROUND( compensation - distance );
  521. +      val = -FT_PIX_ROUND_GRID( compensation - distance, resolution );
  522.        if ( val > 0 )
  523.          val = 0;
  524.      }
  525. @@ -2085,12 +2124,15 @@
  526.    /*                                                                       */
  527.    /*    compensation :: The engine compensation.                           */
  528.    /*                                                                       */
  529. +  /*    resolution   :: The grid resolution.                               */
  530. +  /*                                                                       */
  531.    /* <Return>                                                              */
  532.    /*    Rounded distance.                                                  */
  533.    /*                                                                       */
  534.    static FT_F26Dot6
  535.    Round_To_Half_Grid( EXEC_OP_ FT_F26Dot6  distance,
  536. -                               FT_F26Dot6  compensation )
  537. +                               FT_F26Dot6  compensation,
  538. +                               FT_Int      resolution )
  539.    {
  540.      FT_F26Dot6  val;
  541.  
  542. @@ -2099,13 +2141,15 @@
  543.  
  544.      if ( distance >= 0 )
  545.      {
  546. -      val = FT_PIX_FLOOR( distance + compensation ) + 32;
  547. +      val = FT_PIX_FLOOR_GRID( distance + compensation, resolution ) +
  548. +            32 / resolution;
  549.        if ( distance && val < 0 )
  550.          val = 0;
  551.      }
  552.      else
  553.      {
  554. -      val = -( FT_PIX_FLOOR( compensation - distance ) + 32 );
  555. +      val = -( FT_PIX_FLOOR_GRID( compensation - distance, resolution ) +
  556. +               32 / resolution );
  557.        if ( val > 0 )
  558.          val = 0;
  559.      }
  560. @@ -2127,12 +2171,15 @@
  561.    /*                                                                       */
  562.    /*    compensation :: The engine compensation.                           */
  563.    /*                                                                       */
  564. +  /*    resolution   :: The grid resolution.                               */
  565. +  /*                                                                       */
  566.    /* <Return>                                                              */
  567.    /*    Rounded distance.                                                  */
  568.    /*                                                                       */
  569.    static FT_F26Dot6
  570.    Round_Down_To_Grid( EXEC_OP_ FT_F26Dot6  distance,
  571. -                               FT_F26Dot6  compensation )
  572. +                               FT_F26Dot6  compensation,
  573. +                               FT_Int      resolution )
  574.    {
  575.      FT_F26Dot6  val;
  576.  
  577. @@ -2143,13 +2190,13 @@
  578.      {
  579.        val = distance + compensation;
  580.        if ( distance && val > 0 )
  581. -        val &= ~63;
  582. +        val &= ~( 64 / resolution - 1 );
  583.        else
  584.          val = 0;
  585.      }
  586.      else
  587.      {
  588. -      val = -( ( compensation - distance ) & -64 );
  589. +      val = -( ( compensation - distance ) & -( 64 / resolution ) );
  590.        if ( val > 0 )
  591.          val = 0;
  592.      }
  593. @@ -2171,12 +2218,15 @@
  594.    /*                                                                       */
  595.    /*    compensation :: The engine compensation.                           */
  596.    /*                                                                       */
  597. +  /*    resolution   :: The grid resolution.                               */
  598. +  /*                                                                       */
  599.    /* <Return>                                                              */
  600.    /*    Rounded distance.                                                  */
  601.    /*                                                                       */
  602.    static FT_F26Dot6
  603.    Round_Up_To_Grid( EXEC_OP_ FT_F26Dot6  distance,
  604. -                             FT_F26Dot6  compensation )
  605. +                             FT_F26Dot6  compensation,
  606. +                             FT_Int      resolution )
  607.    {
  608.      FT_F26Dot6  val;
  609.  
  610. @@ -2185,15 +2235,15 @@
  611.  
  612.      if ( distance >= 0 )
  613.      {
  614. -      val = distance + compensation + 63;
  615. +      val = distance + compensation + ( 64 / resolution - 1 );
  616.        if ( distance && val > 0 )
  617. -        val &= ~63;
  618. +        val &= ~( 64 / resolution - 1 );
  619.        else
  620.          val = 0;
  621.      }
  622.      else
  623.      {
  624. -      val = - FT_PIX_CEIL( compensation - distance );
  625. +      val = -FT_PIX_CEIL_GRID( compensation - distance, resolution );
  626.        if ( val > 0 )
  627.          val = 0;
  628.      }
  629. @@ -2215,12 +2265,15 @@
  630.    /*                                                                       */
  631.    /*    compensation :: The engine compensation.                           */
  632.    /*                                                                       */
  633. +  /*    resolution   :: The grid resolution.                               */
  634. +  /*                                                                       */
  635.    /* <Return>                                                              */
  636.    /*    Rounded distance.                                                  */
  637.    /*                                                                       */
  638.    static FT_F26Dot6
  639.    Round_To_Double_Grid( EXEC_OP_ FT_F26Dot6  distance,
  640. -                                 FT_F26Dot6  compensation )
  641. +                                 FT_F26Dot6  compensation,
  642. +                                 FT_Int      resolution )
  643.    {
  644.      FT_F26Dot6 val;
  645.  
  646. @@ -2229,15 +2282,15 @@
  647.  
  648.      if ( distance >= 0 )
  649.      {
  650. -      val = distance + compensation + 16;
  651. +      val = distance + compensation + 16 / resolution;
  652.        if ( distance && val > 0 )
  653. -        val &= ~31;
  654. +        val &= ~( 32 / resolution - 1 );
  655.        else
  656.          val = 0;
  657.      }
  658.      else
  659.      {
  660. -      val = -FT_PAD_ROUND( compensation - distance, 32 );
  661. +      val = -FT_PAD_ROUND( compensation - distance, 32 / resolution );
  662.        if ( val > 0 )
  663.          val = 0;
  664.      }
  665. @@ -2259,6 +2312,8 @@
  666.    /*                                                                       */
  667.    /*    compensation :: The engine compensation.                           */
  668.    /*                                                                       */
  669. +  /*    resolution   :: The grid resolution.                               */
  670. +  /*                                                                       */
  671.    /* <Return>                                                              */
  672.    /*    Rounded distance.                                                  */
  673.    /*                                                                       */
  674. @@ -2270,10 +2325,13 @@
  675.    /*                                                                       */
  676.    static FT_F26Dot6
  677.    Round_Super( EXEC_OP_ FT_F26Dot6  distance,
  678. -                        FT_F26Dot6  compensation )
  679. +                        FT_F26Dot6  compensation,
  680. +                        FT_Int      resolution )
  681.    {
  682.      FT_F26Dot6  val;
  683.  
  684. +    FT_UNUSED( resolution );
  685. +
  686.  
  687.      if ( distance >= 0 )
  688.      {
  689. @@ -2309,6 +2367,8 @@
  690.    /*                                                                       */
  691.    /*    compensation :: The engine compensation.                           */
  692.    /*                                                                       */
  693. +  /*    resolution   :: The grid resolution.                               */
  694. +  /*                                                                       */
  695.    /* <Return>                                                              */
  696.    /*    Rounded distance.                                                  */
  697.    /*                                                                       */
  698. @@ -2318,10 +2378,13 @@
  699.    /*                                                                       */
  700.    static FT_F26Dot6
  701.    Round_Super_45( EXEC_OP_ FT_F26Dot6  distance,
  702. -                           FT_F26Dot6  compensation )
  703. +                           FT_F26Dot6  compensation,
  704. +                           FT_Int      resolution )
  705.    {
  706.      FT_F26Dot6  val;
  707.  
  708. +    FT_UNUSED( resolution );
  709. +
  710.  
  711.      if ( distance >= 0 )
  712.      {
  713. @@ -2404,32 +2467,38 @@
  714.    /*    Sets Super Round parameters.                                       */
  715.    /*                                                                       */
  716.    /* <Input>                                                               */
  717. -  /*    GridPeriod :: Grid period                                          */
  718. -  /*    selector   :: SROUND opcode                                        */
  719. +  /*    GridPeriod :: The grid period.                                     */
  720. +  /*                                                                       */
  721. +  /*    selector   :: The SROUND opcode.                                   */
  722. +  /*                                                                       */
  723. +  /*    resolution :: The grid resolution.                                 */
  724.    /*                                                                       */
  725.    static void
  726.    SetSuperRound( EXEC_OP_ FT_F26Dot6  GridPeriod,
  727. -                          FT_Long     selector )
  728. +                          FT_Long     selector,
  729. +                          FT_Int      resolution )
  730.    {
  731. +    FT_UNUSED( resolution );
  732. +
  733.      switch ( (FT_Int)( selector & 0xC0 ) )
  734.      {
  735. -      case 0:
  736. -        CUR.period = GridPeriod / 2;
  737. -        break;
  738. +    case 0:
  739. +      CUR.period = GridPeriod / 2;
  740. +      break;
  741.  
  742. -      case 0x40:
  743. -        CUR.period = GridPeriod;
  744. -        break;
  745. +    case 0x40:
  746. +      CUR.period = GridPeriod;
  747. +      break;
  748.  
  749. -      case 0x80:
  750. -        CUR.period = GridPeriod * 2;
  751. -        break;
  752. +    case 0x80:
  753. +      CUR.period = GridPeriod * 2;
  754. +      break;
  755.  
  756. -      /* This opcode is reserved, but... */
  757. +    /* This opcode is reserved, but... */
  758.  
  759. -      case 0xC0:
  760. -        CUR.period = GridPeriod;
  761. -        break;
  762. +    case 0xC0:
  763. +      CUR.period = GridPeriod;
  764. +      break;
  765.      }
  766.  
  767.      switch ( (FT_Int)( selector & 0x30 ) )
  768. @@ -3080,13 +3149,13 @@
  769.  
  770.  
  771.  #define DO_SROUND                                \
  772. -    SET_SuperRound( 0x4000, args[0] );           \
  773. +    SET_SuperRound( 0x4000, args[0], 1 );        \
  774.      CUR.GS.round_state = TT_Round_Super;         \
  775.      CUR.func_round = (TT_Round_Func)Round_Super;
  776.  
  777.  
  778.  #define DO_S45ROUND                                 \
  779. -    SET_SuperRound( 0x2D41, args[0] );              \
  780. +    SET_SuperRound( 0x2D41, args[0], 1 );           \
  781.      CUR.GS.round_state = TT_Round_Super_45;         \
  782.      CUR.func_round = (TT_Round_Func)Round_Super_45;
  783.  
  784. @@ -3256,12 +3325,12 @@
  785.      args[0] = ( args[0] != args[1] );
  786.  
  787.  
  788. -#define DO_ODD                                                  \
  789. -    args[0] = ( ( CUR_Func_round( args[0], 0 ) & 127 ) == 64 );
  790. +#define DO_ODD                                                     \
  791. +    args[0] = ( ( CUR_Func_round( args[0], 0, 1 ) & 127 ) == 64 );
  792.  
  793.  
  794. -#define DO_EVEN                                                \
  795. -    args[0] = ( ( CUR_Func_round( args[0], 0 ) & 127 ) == 0 );
  796. +#define DO_EVEN                                                   \
  797. +    args[0] = ( ( CUR_Func_round( args[0], 0, 1 ) & 127 ) == 0 );
  798.  
  799.  
  800.  #define DO_AND                        \
  801. @@ -3310,6 +3379,35 @@
  802.  #define DO_CEILING                    \
  803.      args[0] = FT_PIX_CEIL( args[0] );
  804.  
  805. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  806. +
  807. +#define DO_RS                                             \
  808. +   {                                                      \
  809. +     FT_ULong  I = (FT_ULong)args[0];                     \
  810. +                                                          \
  811. +                                                          \
  812. +     if ( BOUNDSL( I, CUR.storeSize ) )                   \
  813. +     {                                                    \
  814. +       if ( CUR.pedantic_hinting )                        \
  815. +         ARRAY_BOUND_ERROR;                               \
  816. +       else                                               \
  817. +         args[0] = 0;                                     \
  818. +     }                                                    \
  819. +     else                                                 \
  820. +     {                                                    \
  821. +       /* subpixel hinting - avoid Typeman Dstroke and */ \
  822. +       /* IStroke and Vacuform rounds                  */ \
  823. +                                                          \
  824. +       if ( CUR.enhanced_mode                               && \
  825. +            ( I == 24 || I == 22 || I == 8 )           && \
  826. +            !( CUR.sph_tweak_flags & SPH_TWEAK_DO_RS ) )  \
  827. +         args[0] = 0;                                     \
  828. +       else                                               \
  829. +         args[0] = CUR.storage[I];                        \
  830. +     }                                                    \
  831. +   }
  832. +
  833. +#else /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  834.  
  835.  #define DO_RS                           \
  836.     {                                    \
  837. @@ -3319,9 +3417,7 @@
  838.       if ( BOUNDSL( I, CUR.storeSize ) ) \
  839.       {                                  \
  840.         if ( CUR.pedantic_hinting )      \
  841. -       {                                \
  842.           ARRAY_BOUND_ERROR;             \
  843. -       }                                \
  844.         else                             \
  845.           args[0] = 0;                   \
  846.       }                                  \
  847. @@ -3329,6 +3425,8 @@
  848.         args[0] = CUR.storage[I];        \
  849.     }
  850.  
  851. +#endif /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  852. +
  853.  
  854.  #define DO_WS                           \
  855.     {                                    \
  856. @@ -3338,9 +3436,7 @@
  857.       if ( BOUNDSL( I, CUR.storeSize ) ) \
  858.       {                                  \
  859.         if ( CUR.pedantic_hinting )      \
  860. -       {                                \
  861.           ARRAY_BOUND_ERROR;             \
  862. -       }                                \
  863.       }                                  \
  864.       else                               \
  865.         CUR.storage[I] = args[1];        \
  866. @@ -3355,9 +3451,7 @@
  867.       if ( BOUNDSL( I, CUR.cvtSize ) )    \
  868.       {                                   \
  869.         if ( CUR.pedantic_hinting )       \
  870. -       {                                 \
  871.           ARRAY_BOUND_ERROR;              \
  872. -       }                                 \
  873.         else                              \
  874.           args[0] = 0;                    \
  875.       }                                   \
  876. @@ -3374,9 +3468,7 @@
  877.       if ( BOUNDSL( I, CUR.cvtSize ) )    \
  878.       {                                   \
  879.         if ( CUR.pedantic_hinting )       \
  880. -       {                                 \
  881.           ARRAY_BOUND_ERROR;              \
  882. -       }                                 \
  883.       }                                   \
  884.       else                                \
  885.         CUR_Func_write_cvt( I, args[1] ); \
  886. @@ -3391,9 +3483,7 @@
  887.       if ( BOUNDSL( I, CUR.cvtSize ) )                           \
  888.       {                                                          \
  889.         if ( CUR.pedantic_hinting )                              \
  890. -       {                                                        \
  891.           ARRAY_BOUND_ERROR;                                     \
  892. -       }                                                        \
  893.       }                                                          \
  894.       else                                                       \
  895.         CUR.cvt[I] = TT_MULFIX( args[1], CUR.tt_metrics.scale ); \
  896. @@ -3404,15 +3494,17 @@
  897.      CUR.error = TT_Err_Debug_OpCode;
  898.  
  899.  
  900. -#define DO_ROUND                                                   \
  901. -    args[0] = CUR_Func_round(                                      \
  902. -                args[0],                                           \
  903. -                CUR.tt_metrics.compensations[CUR.opcode - 0x68] );
  904. +#define DO_ROUND                                                 \
  905. +    args[0] = CUR_Func_round(                                    \
  906. +                args[0],                                         \
  907. +                CUR.tt_metrics.compensations[CUR.opcode - 0x68], \
  908. +                1 );
  909.  
  910.  
  911. -#define DO_NROUND                                                            \
  912. -    args[0] = ROUND_None( args[0],                                           \
  913. -                          CUR.tt_metrics.compensations[CUR.opcode - 0x6C] );
  914. +#define DO_NROUND                                                          \
  915. +    args[0] = ROUND_None( args[0],                                         \
  916. +                          CUR.tt_metrics.compensations[CUR.opcode - 0x6C], \
  917. +                          1 );
  918.  
  919.  
  920.  #define DO_MAX               \
  921. @@ -3430,10 +3522,11 @@
  922.  
  923.  #undef  ARRAY_BOUND_ERROR
  924.  #define ARRAY_BOUND_ERROR                   \
  925. +    do                                      \
  926.      {                                       \
  927.        CUR.error = TT_Err_Invalid_Reference; \
  928.        return;                               \
  929. -    }
  930. +    } while ( 0 )
  931.  
  932.  
  933.    /*************************************************************************/
  934. @@ -4586,6 +4679,23 @@
  935.      TT_DefRecord*  rec;
  936.      TT_DefRecord*  limit;
  937.  
  938. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  939. +    int  opcode_pattern[4][12] = {
  940. +           /* VacuFormRound function */
  941. +           {0x45,0x23,0x46,0x60,0x20},
  942. +           /* inline delta function 1 */
  943. +           {0x4B,0x53,0x23,0x4B,0x51,0x5A,0x58,0x38,0x1B,0x21,0x21,0x59},
  944. +           /* inline delta function 2 */
  945. +           {0x4B,0x54,0x58,0x38,0x1B,0x5A,0x21,0x21,0x59},
  946. +           /* diagonal stroke function */
  947. +           {0x20,0x20,0x40,0x60,0x47,0x40,0x23,0x42},
  948. +         };
  949. +    int  opcode_patterns = 4;
  950. +    int  i;
  951. +    int  opcode_pointer[4] = {0,0,0,0};
  952. +
  953. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  954. +
  955.  
  956.      /* some font programs are broken enough to redefine functions! */
  957.      /* We will then parse the current table.                       */
  958. @@ -4619,10 +4729,11 @@
  959.        return;
  960.      }
  961.  
  962. -    rec->range  = CUR.curRange;
  963. -    rec->opc    = (FT_UInt16)n;
  964. -    rec->start  = CUR.IP + 1;
  965. -    rec->active = TRUE;
  966. +    rec->range        = CUR.curRange;
  967. +    rec->opc          = (FT_UInt16)n;
  968. +    rec->start        = CUR.IP + 1;
  969. +    rec->active       = TRUE;
  970. +    rec->inline_delta = FALSE;
  971.  
  972.      if ( n > CUR.maxFunc )
  973.        CUR.maxFunc = (FT_UInt16)n;
  974. @@ -4632,6 +4743,83 @@
  975.  
  976.      while ( SKIP_Code() == SUCCESS )
  977.      {
  978. +#ifdef SPH_DEBUG_MORE_VERBOSE
  979. +      printf ("%d ", CUR.opcode);
  980. +#endif
  981. +
  982. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  983. +
  984. +      if (CUR.enhanced_mode && ( CUR.sph_tweak_flags & SPH_TWEAK_SKIP_INLINE_DELTAS ))
  985. +      for ( i = 0; i < opcode_patterns; i++ )
  986. +      {
  987. +        if ( CUR.opcode == opcode_pattern[i][opcode_pointer[i]] )
  988. +        {
  989. +#ifdef SPH_DEBUG_MORE_VERBOSE
  990. +          printf( "function %d, opcode ptrn: %d"
  991. +                  "  op# %d: %d FOUND \n",
  992. +                  n, i, opcode_pointer[i], CUR.opcode );
  993. +#endif
  994. +
  995. +          opcode_pointer[i] += 1;
  996. +
  997. +          if ( i == 0 && opcode_pointer[0] == 5 )
  998. +          {
  999. +
  1000. +            CUR.inline_delta_funcs[CUR.num_delta_funcs] = n;
  1001. +            CUR.num_delta_funcs++;
  1002. +#ifdef SPH_DEBUG            
  1003. +            printf( "Vacuform Round FUNCTION %d detected\n", n);
  1004. +#endif
  1005. +            /*rec->active = FALSE;*/
  1006. +            opcode_pointer[i] = 0;
  1007. +          }
  1008. +
  1009. +          if ( i == 1 && opcode_pointer[1] == 12 )
  1010. +          {
  1011. +            CUR.inline_delta_funcs[CUR.num_delta_funcs] = n;
  1012. +            CUR.num_delta_funcs++;
  1013. +#ifdef SPH_DEBUG
  1014. +            printf( "inline delta FUNCTION1 %d detected\n",
  1015. +                    n, CUR.num_delta_funcs);
  1016. +#endif
  1017. +
  1018. +            rec->inline_delta = TRUE;
  1019. +            opcode_pointer[i] = 0;
  1020. +          }
  1021. +
  1022. +          if ( i == 2 && opcode_pointer[1] == 9 )
  1023. +          {
  1024. +            CUR.inline_delta_funcs[CUR.num_delta_funcs] = n;
  1025. +            CUR.num_delta_funcs++;
  1026. +            rec->inline_delta = TRUE;
  1027. +#ifdef SPH_DEBUG
  1028. +            printf( "inline delta2 FUNCTION2 %d detected\n",
  1029. +                    n, CUR.num_delta_funcs);
  1030. +#endif
  1031. +
  1032. +            opcode_pointer[i] = 0;
  1033. +          }
  1034. +
  1035. +          if ( i == 4 && opcode_pointer[1] == 8 )
  1036. +          {
  1037. +            CUR.inline_delta_funcs[CUR.num_delta_funcs] = n;
  1038. +            CUR.num_delta_funcs++;
  1039. +            /*rec->active = FALSE;*/
  1040. +#ifdef SPH_DEBUG
  1041. +            printf( "diagonal stroke function %d detected\n",
  1042. +                    n, CUR.num_delta_funcs);
  1043. +#endif
  1044. +
  1045. +            opcode_pointer[i] = 0;
  1046. +          }
  1047. +        }
  1048. +
  1049. +        else
  1050. +          opcode_pointer[i] = 0;
  1051. +      }
  1052. +
  1053. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1054. +
  1055.        switch ( CUR.opcode )
  1056.        {
  1057.        case 0x89:    /* IDEF */
  1058. @@ -4674,6 +4862,15 @@
  1059.  
  1060.      CUR.step_ins = FALSE;
  1061.  
  1062. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1063. +    /*
  1064. +     *  CUR.enhanced_mode may be turned off prior to function calls.  This
  1065. +     *  ensures it is turned back on.
  1066. +     */
  1067. +    CUR.enhanced_mode = ( CUR.subpixel_hinting || CUR.grayscale_hinting )
  1068. +      && !( CUR.sph_tweak_flags & SPH_TWEAK_PIXEL_HINTING );
  1069. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1070. +
  1071.      if ( pRec->Cur_Count > 0 )
  1072.      {
  1073.        CUR.callTop++;
  1074. @@ -4707,6 +4904,10 @@
  1075.      TT_CallRec*    pCrec;
  1076.      TT_DefRecord*  def;
  1077.  
  1078. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1079. +    FT_Bool        oldF;
  1080. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1081. +
  1082.  
  1083.      /* first of all, check the index */
  1084.  
  1085. @@ -4744,6 +4945,26 @@
  1086.      if ( !def->active )
  1087.        goto Fail;
  1088.  
  1089. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1090. +    /* This is test code used to detect inline delta functions */
  1091. +    oldF = def->inline_delta;
  1092. +    if ( CUR.enhanced_mode )
  1093. +    {
  1094. +      if ( def->inline_delta )
  1095. +        CUR.in_delta_function = TRUE;
  1096. +    }
  1097. +
  1098. +    if (FALSE)
  1099. +    if ( F == 35 || F == 34 )
  1100. +    {
  1101. +      CUR.enhanced_mode = FALSE;
  1102. +#ifdef SPH_DEBUG
  1103. +      printf("Entering %d\n", F);
  1104. +#endif
  1105. +    }
  1106. +
  1107. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1108. +
  1109.      /* check the call stack */
  1110.      if ( CUR.callTop >= CUR.callSize )
  1111.      {
  1112. @@ -4764,6 +4985,19 @@
  1113.                          def->start );
  1114.  
  1115.      CUR.step_ins = FALSE;
  1116. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1117. +    CUR.in_delta_function = oldF;
  1118. +
  1119. +    if (FALSE)
  1120. +    if ( F == 35 || F == 34 )
  1121. +    {
  1122. +      CUR.enhanced_mode = !( CUR.sph_tweak_flags & SPH_TWEAK_PIXEL_HINTING );
  1123. +#ifdef SPH_DEBUG
  1124. +      printf("Leaving %d\n", F);
  1125. +#endif
  1126. +    }
  1127. +
  1128. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1129.      return;
  1130.  
  1131.    Fail:
  1132. @@ -4784,6 +5018,10 @@
  1133.      TT_CallRec*    pCrec;
  1134.      TT_DefRecord*  def;
  1135.  
  1136. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1137. +    FT_Bool        oldF;
  1138. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1139. +
  1140.  
  1141.      /* first of all, check the index */
  1142.      F = args[1];
  1143. @@ -4820,6 +5058,15 @@
  1144.      if ( !def->active )
  1145.        goto Fail;
  1146.  
  1147. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1148. +    oldF = def->inline_delta;
  1149. +    if ( CUR.enhanced_mode )
  1150. +    {
  1151. +      if ( def->inline_delta )
  1152. +        CUR.in_delta_function = TRUE;
  1153. +    }
  1154. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1155. +
  1156.      /* check stack */
  1157.      if ( CUR.callTop >= CUR.callSize )
  1158.      {
  1159. @@ -4842,6 +5089,11 @@
  1160.  
  1161.        CUR.step_ins = FALSE;
  1162.      }
  1163. +
  1164. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1165. +    CUR.in_delta_function = oldF;
  1166. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1167. +
  1168.      return;
  1169.  
  1170.    Fail:
  1171. @@ -5191,6 +5443,12 @@
  1172.        }
  1173.      }
  1174.  
  1175. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1176. +    /* Disable Type 2 Vacuform Rounds - e.g. Arial Narrow */
  1177. +    if ( CUR.enhanced_mode && FT_ABS( D ) == 64 )
  1178. +      D += 1;
  1179. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1180. +
  1181.      args[0] = D;
  1182.    }
  1183.  
  1184. @@ -5685,12 +5943,21 @@
  1185.      }
  1186.  #endif
  1187.  
  1188. -    if ( CUR.GS.freeVector.x != 0 )
  1189. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1190. +    if ( !CUR.enhanced_mode                                               ||
  1191. +         ( CUR.enhanced_mode                                            &&
  1192. +           ( CUR.sph_tweak_flags & SPH_TWEAK_ALLOW_MOVEZP2_FREEV ) ) )
  1193.      {
  1194. -      CUR.zp2.cur[point].x += dx;
  1195. -      if ( touch )
  1196. -        CUR.zp2.tags[point] |= FT_CURVE_TAG_TOUCH_X;
  1197. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1198. +      if ( CUR.GS.freeVector.x != 0 )
  1199. +      {
  1200. +        CUR.zp2.cur[point].x += dx;
  1201. +        if ( touch )
  1202. +          CUR.zp2.tags[point] |= FT_CURVE_TAG_TOUCH_X;
  1203. +      }
  1204. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1205.      }
  1206. +#endif
  1207.  
  1208.      if ( CUR.GS.freeVector.y != 0 )
  1209.      {
  1210. @@ -5879,6 +6146,9 @@
  1211.    {
  1212.      FT_F26Dot6  dx, dy;
  1213.      FT_UShort   point;
  1214. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1215. +    FT_Int      B1, B2;
  1216. +#endif
  1217.  
  1218.  
  1219.      if ( CUR.top < CUR.GS.loop + 1 )
  1220. @@ -5924,11 +6194,111 @@
  1221.          }
  1222.        }
  1223.        else
  1224. -        MOVE_Zp2_Point( point, dx, dy, TRUE );
  1225. +      {
  1226. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1227. +        /*
  1228. +         *  The conditionals here still do not do a perfect job and need
  1229. +         *  work.
  1230. +         *
  1231. +         *  If not using enhanced_mode rendering, allow ZP2 move.
  1232. +         *
  1233. +         *  If using enhanced_mode rendering, allow ZP2 point move if
  1234. +         *
  1235. +         *  - the glyph is composite
  1236. +         *  - the glyph is specifically set to allow SHPIX moves
  1237. +         *  - the move is in the Y direction on a previously touched point
  1238. +         *
  1239. +         *  It seems that what qualifies as a previously touched point varies
  1240. +         *  somewhat from font to font.  Some render better when either X
  1241. +         *  or Y must be touched (SPH_TWEAK_SHPIX_EITHER_TOUCHED) and some render
  1242. +         *  better when both must be touched.
  1243. +         */
  1244. +
  1245. +        if ( CUR.enhanced_mode )
  1246. +        {
  1247. +          if ( CUR.GS.freeVector.y != 0 )
  1248. +            B1 = CUR.zp2.cur[point].y;
  1249. +          else
  1250. +            B1 = CUR.zp2.cur[point].x;
  1251. +
  1252. +          if ( CUR.enhanced_mode                                                   &&
  1253. +              ( CUR.sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_INLINE_MOVES ) )
  1254. +          {
  1255. +            dx = FT_PIX_ROUND ( dx );                
  1256. +            dy = FT_PIX_ROUND ( dy );              
  1257. +          }
  1258. +          
  1259. +          if ( /* ORIG WAY  */
  1260. +               ( CUR.sph_tweak_flags & ~SPH_TWEAK_SKIP_INLINE_DELTAS ) && ( CUR.is_composite                                 ||
  1261. +               ( CUR.sph_tweak_flags &
  1262. +                   SPH_TWEAK_DO_SHPIX )                         ||
  1263. +               ( CUR.GS.freeVector.y != 0                     &&
  1264. +                 CUR.iup_called == 0                          &&
  1265. +                 CUR.iupy_called == 0                         &&
  1266. +                 ( ( ( CUR.sph_tweak_flags &
  1267. +                         SPH_TWEAK_SHPIX_EITHER_TOUCHED )       &&
  1268. +                     ( ( CUR.pts.tags[point] &
  1269. +                           FT_CURVE_TAG_TOUCH_X ) != 0 ||
  1270. +                       ( CUR.pts.tags[point] &
  1271. +                           FT_CURVE_TAG_TOUCH_Y ) != 0 ) ) ||
  1272. +                   ( !( CUR.sph_tweak_flags &
  1273. +                          SPH_TWEAK_SHPIX_EITHER_TOUCHED )      &&
  1274. +                     ( ( CUR.pts.tags[point] &
  1275. +                           FT_CURVE_TAG_TOUCH_X ) != 0 &&
  1276. +                       ( CUR.pts.tags[point] &
  1277. +                           FT_CURVE_TAG_TOUCH_Y ) != 0 ) ) )
  1278. +                        ) )
  1279. +            /*||    NEW WAY BUT CRASHES CHROME
  1280. +             CUR.sph_tweak_flags & SPH_TWEAK_SKIP_INLINE_DELTAS && ( CUR.is_composite                                ||
  1281. +              ( CUR.sph_tweak_flags & SPH_TWEAK_DO_SHPIX )       ||
  1282. +              ( CUR.GS.freeVector.y != 0                      
  1283. +                && CUR.iup_called == 0
  1284. +                && CUR.iupy_called == 0
  1285. +                && (
  1286. +                  ( CUR.in_delta_function
  1287. +                    && ( CUR.pts.tags[point] & FT_CURVE_TAG_TOUCH_X )
  1288. +                    && ( CUR.pts.tags[point] & FT_CURVE_TAG_TOUCH_Y ) )
  1289. +                 ||
  1290. +                  ( CUR.in_delta_function
  1291. +                    && ( CUR.sph_tweak_flags & SPH_TWEAK_SHPIX_EITHER_TOUCHED )
  1292. +                    && ( CUR.pts.tags[point] & FT_CURVE_TAG_TOUCH_X  
  1293. +                      || CUR.pts.tags[point] & FT_CURVE_TAG_TOUCH_Y ) )  
  1294. +                 ||
  1295. +                  !CUR.in_delta_function  )))*/
  1296. +          )
  1297. +            
  1298. +          {
  1299. +            MOVE_Zp2_Point( point, dx, dy, TRUE );
  1300. +            
  1301. +            if ( CUR.GS.freeVector.y != 0 )
  1302. +              B2 = CUR.zp2.cur[point].y;
  1303. +            else B2 = CUR.zp2.cur[point].x;
  1304. +
  1305. +            /* reverse moves that move the point off a pixel boundary */
  1306. +            if ( ( CUR.sph_tweak_flags &
  1307. +                    SPH_TWEAK_SKIP_NONPIXEL_INLINE_MOVES ) &&
  1308. +                B1 % 64 == 0                               &&
  1309. +                B2 % 64 != 0                               )
  1310. +            {
  1311. +#ifdef SPH_DEBUG
  1312. +              printf( "Reversing ZP2 move\n" );
  1313. +#endif
  1314. +              MOVE_Zp2_Point( point, -dx, -dy, TRUE );
  1315. +            }
  1316. +          }
  1317. +        }
  1318. +        else
  1319. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1320. +          MOVE_Zp2_Point( point, dx, dy, TRUE );
  1321. +      }
  1322.  
  1323.        CUR.GS.loop--;
  1324.      }
  1325.  
  1326. +#ifdef SPH_DEBUG_MORE_VERBOSE
  1327. +    printf( "SHPIX: %d\n", CUR.in_delta_function );
  1328. +#endif
  1329. +
  1330.    Fail:
  1331.      CUR.GS.loop = 1;
  1332.      CUR.new_top = CUR.args;
  1333. @@ -5946,8 +6316,19 @@
  1334.    {
  1335.      FT_UShort   point;
  1336.      FT_F26Dot6  distance;
  1337. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1338. +    FT_Int      resolution = 1;
  1339.  
  1340.  
  1341. +    if ( CUR.enhanced_mode )
  1342. +    {
  1343. +      if ( CUR.GS.freeVector.x != 0 )
  1344. +        resolution = SPH_OPTION_GRIDS_PER_PIXEL_X;
  1345. +      else if ( CUR.GS.freeVector.y != 0 )
  1346. +        resolution = SPH_OPTION_GRIDS_PER_PIXEL_Y;
  1347. +    }
  1348. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1349. +
  1350.      point = (FT_UShort)args[0];
  1351.  
  1352.      if ( BOUNDS( point,      CUR.zp1.n_points ) ||
  1353. @@ -5970,6 +6351,16 @@
  1354.      distance = CUR_Func_project( CUR.zp1.cur + point,
  1355.                                   CUR.zp0.cur + CUR.GS.rp0 );
  1356.  
  1357. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1358. +    /* subpixel hinting - make MSIRP respect CVT cut-in; */
  1359. +    /* this fixes `k' issue with Arial                   */
  1360. +    if ( CUR.enhanced_mode                              &&
  1361. +         CUR.GS.freeVector.x != 0                  &&
  1362. +         FT_ABS( distance - args[1] ) >=
  1363. +           CUR.GS.control_value_cutin / resolution )
  1364. +      distance = args[1];
  1365. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1366. +
  1367.      CUR_Func_move( &CUR.zp1, point, args[1] - distance );
  1368.  
  1369.      CUR.GS.rp1 = CUR.GS.rp0;
  1370. @@ -5992,8 +6383,22 @@
  1371.      FT_UShort   point;
  1372.      FT_F26Dot6  cur_dist,
  1373.                  distance;
  1374. +    FT_Int      resolution = 1;
  1375.  
  1376.  
  1377. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1378. +    if ( CUR.enhanced_mode )
  1379. +    {
  1380. +      if ( CUR.GS.freeVector.x != 0                               &&
  1381. +           !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND_MDAP ) )
  1382. +        resolution = SPH_OPTION_GRIDS_PER_PIXEL_X;
  1383. +
  1384. +      else if ( CUR.GS.freeVector.y != 0                               &&
  1385. +                !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND_MDAP ) )
  1386. +        resolution = SPH_OPTION_GRIDS_PER_PIXEL_Y;
  1387. +    }
  1388. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1389. +
  1390.      point = (FT_UShort)args[0];
  1391.  
  1392.      if ( BOUNDS( point, CUR.zp0.n_points ) )
  1393. @@ -6007,7 +6412,8 @@
  1394.      {
  1395.        cur_dist = CUR_fast_project( &CUR.zp0.cur[point] );
  1396.        distance = CUR_Func_round( cur_dist,
  1397. -                                 CUR.tt_metrics.compensations[0] ) - cur_dist;
  1398. +                                 CUR.tt_metrics.compensations[0],
  1399. +                                 resolution ) - cur_dist;
  1400.      }
  1401.      else
  1402.        distance = 0;
  1403. @@ -6032,7 +6438,21 @@
  1404.      FT_UShort   point;
  1405.      FT_F26Dot6  distance,
  1406.                  org_dist;
  1407. +    FT_Int      resolution = 1;
  1408. +
  1409. +
  1410. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1411. +    if ( CUR.enhanced_mode )
  1412. +    {
  1413. +      if ( CUR.GS.freeVector.x != 0                               &&
  1414. +           !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND_MIAP ) )
  1415. +        resolution = SPH_OPTION_GRIDS_PER_PIXEL_X;
  1416.  
  1417. +      else if ( CUR.GS.freeVector.y != 0                               &&
  1418. +                !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND_MIAP ) )
  1419. +        resolution = SPH_OPTION_GRIDS_PER_PIXEL_Y;
  1420. +    }
  1421. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1422.  
  1423.      cvtEntry = (FT_ULong)args[1];
  1424.      point    = (FT_UShort)args[0];
  1425. @@ -6078,12 +6498,15 @@
  1426.  
  1427.      org_dist = CUR_fast_project( &CUR.zp0.cur[point] );
  1428.  
  1429. -    if ( ( CUR.opcode & 1 ) != 0 )   /* rounding and control cutin flag */
  1430. +    if ( ( CUR.opcode & 1 ) != 0 )   /* rounding and control cut-in flag */
  1431.      {
  1432. -      if ( FT_ABS( distance - org_dist ) > CUR.GS.control_value_cutin )
  1433. +      if ( FT_ABS( distance - org_dist ) >
  1434. +             CUR.GS.control_value_cutin / resolution )
  1435.          distance = org_dist;
  1436.  
  1437. -      distance = CUR_Func_round( distance, CUR.tt_metrics.compensations[0] );
  1438. +      distance = CUR_Func_round( distance,
  1439. +                                 CUR.tt_metrics.compensations[0],
  1440. +                                 resolution );
  1441.      }
  1442.  
  1443.      CUR_Func_move( &CUR.zp0, point, distance - org_dist );
  1444. @@ -6105,6 +6528,24 @@
  1445.    {
  1446.      FT_UShort   point;
  1447.      FT_F26Dot6  org_dist, distance;
  1448. +    FT_Int      minimum_distance_factor = 64;
  1449. +    FT_Int      resolution              = 1;
  1450. +
  1451. +
  1452. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1453. +    if ( CUR.enhanced_mode )
  1454. +    {
  1455. +      if ( CUR.GS.freeVector.x != 0                               &&
  1456. +           !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND_MDRP ) )
  1457. +      {
  1458. +        resolution              = SPH_OPTION_GRIDS_PER_PIXEL_X;
  1459. +        minimum_distance_factor = 64 - resolution / 3;
  1460. +      }
  1461. +      else if ( CUR.GS.freeVector.y != 0                               &&
  1462. +                !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND_MDRP ) )
  1463. +        resolution = SPH_OPTION_GRIDS_PER_PIXEL_Y;
  1464. +    }
  1465. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1466.  
  1467.  
  1468.      point = (FT_UShort)args[0];
  1469. @@ -6170,11 +6611,13 @@
  1470.      if ( ( CUR.opcode & 4 ) != 0 )
  1471.        distance = CUR_Func_round(
  1472.                     org_dist,
  1473. -                   CUR.tt_metrics.compensations[CUR.opcode & 3] );
  1474. +                   CUR.tt_metrics.compensations[CUR.opcode & 3],
  1475. +                   resolution );
  1476.      else
  1477.        distance = ROUND_None(
  1478.                     org_dist,
  1479. -                   CUR.tt_metrics.compensations[CUR.opcode & 3] );
  1480. +                   CUR.tt_metrics.compensations[CUR.opcode & 3],
  1481. +                   resolution );
  1482.  
  1483.      /* minimum distance flag */
  1484.  
  1485. @@ -6182,13 +6625,17 @@
  1486.      {
  1487.        if ( org_dist >= 0 )
  1488.        {
  1489. -        if ( distance < CUR.GS.minimum_distance )
  1490. -          distance = CUR.GS.minimum_distance;
  1491. +        if ( distance < FT_MulDiv( minimum_distance_factor,
  1492. +                                   CUR.GS.minimum_distance, 64 ) )
  1493. +          distance = FT_MulDiv( minimum_distance_factor,
  1494. +                                CUR.GS.minimum_distance, 64 );
  1495.        }
  1496.        else
  1497.        {
  1498. -        if ( distance > -CUR.GS.minimum_distance )
  1499. -          distance = -CUR.GS.minimum_distance;
  1500. +        if ( distance > -FT_MulDiv( minimum_distance_factor,
  1501. +                                    CUR.GS.minimum_distance, 64 ) )
  1502. +          distance = -FT_MulDiv( minimum_distance_factor,
  1503. +                                 CUR.GS.minimum_distance, 64 );
  1504.        }
  1505.      }
  1506.  
  1507. @@ -6225,10 +6672,36 @@
  1508.                  cur_dist,
  1509.                  org_dist;
  1510.  
  1511. +    FT_Int      minimum_distance_factor = 64;
  1512. +    FT_Int      resolution              = 1;
  1513. +
  1514. +    FT_Int      B1;
  1515. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1516. +    FT_Int      B2;
  1517. +#endif
  1518.  
  1519.      point    = (FT_UShort)args[0];
  1520.      cvtEntry = (FT_ULong)( args[1] + 1 );
  1521.  
  1522. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1523. +    if ( CUR.enhanced_mode )
  1524. +    {
  1525. +      if ( CUR.GS.freeVector.x != 0                               &&
  1526. +           !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND_MIRP ) )
  1527. +      {
  1528. +        resolution = SPH_OPTION_GRIDS_PER_PIXEL_X;
  1529. +        /* high value emboldens glyphs at lower ppems (< 14); */
  1530. +        /* Courier looks better with 52 --                    */
  1531. +        /* MS ClearType Rasterizer supposedly uses 32         */
  1532. +        minimum_distance_factor = 64 - resolution / 3;
  1533. +      }
  1534. +
  1535. +      else if ( CUR.GS.freeVector.y != 0                               &&
  1536. +                !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND_MIRP ) )
  1537. +        resolution = SPH_OPTION_GRIDS_PER_PIXEL_Y;
  1538. +    }
  1539. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1540. +
  1541.      /* XXX: UNDOCUMENTED! cvt[-1] = 0 always */
  1542.  
  1543.      if ( BOUNDS( point,      CUR.zp1.n_points ) ||
  1544. @@ -6282,7 +6755,7 @@
  1545.          cvt_dist = -cvt_dist;
  1546.      }
  1547.  
  1548. -    /* control value cutin and round */
  1549. +    /* control value cut-in and round */
  1550.  
  1551.      if ( ( CUR.opcode & 4 ) != 0 )
  1552.      {
  1553. @@ -6303,18 +6776,21 @@
  1554.          /*      `ttinst2.doc', version 1.66, is thus incorrect since  */
  1555.          /*      it implies `>=' instead of `>'.                       */
  1556.  
  1557. -        if ( FT_ABS( cvt_dist - org_dist ) > CUR.GS.control_value_cutin )
  1558. +        if ( FT_ABS( cvt_dist - org_dist ) >
  1559. +               CUR.GS.control_value_cutin / resolution )
  1560.            cvt_dist = org_dist;
  1561.        }
  1562.  
  1563.        distance = CUR_Func_round(
  1564.                     cvt_dist,
  1565. -                   CUR.tt_metrics.compensations[CUR.opcode & 3] );
  1566. +                   CUR.tt_metrics.compensations[CUR.opcode & 3],
  1567. +                   resolution );
  1568.      }
  1569.      else
  1570.        distance = ROUND_None(
  1571.                     cvt_dist,
  1572. -                   CUR.tt_metrics.compensations[CUR.opcode & 3] );
  1573. +                   CUR.tt_metrics.compensations[CUR.opcode & 3],
  1574. +                   resolution );
  1575.  
  1576.      /* minimum distance test */
  1577.  
  1578. @@ -6322,18 +6798,44 @@
  1579.      {
  1580.        if ( org_dist >= 0 )
  1581.        {
  1582. -        if ( distance < CUR.GS.minimum_distance )
  1583. -          distance = CUR.GS.minimum_distance;
  1584. +        if ( distance < FT_MulDiv( minimum_distance_factor,
  1585. +                                   CUR.GS.minimum_distance, 64 ) )
  1586. +          distance = FT_MulDiv( minimum_distance_factor,
  1587. +                                CUR.GS.minimum_distance, 64 );
  1588.        }
  1589.        else
  1590.        {
  1591. -        if ( distance > -CUR.GS.minimum_distance )
  1592. -          distance = -CUR.GS.minimum_distance;
  1593. +        if ( distance > -FT_MulDiv( minimum_distance_factor,
  1594. +                                    CUR.GS.minimum_distance, 64 ) )
  1595. +          distance = -FT_MulDiv( minimum_distance_factor,
  1596. +                                 CUR.GS.minimum_distance, 64 );
  1597.        }
  1598.      }
  1599. +    
  1600. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1601. +    if ( CUR.enhanced_mode                                                   &&
  1602. +         ( CUR.sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_INLINE_MOVES ) )
  1603. +      distance = FT_PIX_ROUND( distance );  
  1604. +#endif
  1605. +    B1 = CUR.zp1.cur[point].y;
  1606.  
  1607.      CUR_Func_move( &CUR.zp1, point, distance - cur_dist );
  1608.  
  1609. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1610. +    if ( CUR.enhanced_mode                                                   &&
  1611. +         ( CUR.sph_tweak_flags & SPH_TWEAK_SKIP_NONPIXEL_INLINE_MOVES ) )
  1612. +    {
  1613. +      B2 = CUR.zp1.cur[point].y;
  1614. +
  1615. +      if ( ( CUR.GS.freeVector.x != 0 && B1 % 64 == 0 && B2 % 64 != 0 ) ||
  1616. +           ( CUR.GS.freeVector.y != 0 && B2 % 64 != 0 )                 )
  1617. +      {
  1618. +        /* reverse the MIRP move; ideally this could be implemented better */
  1619. +        CUR_Func_move( &CUR.zp1, point, -( distance - cur_dist ) );
  1620. +      }
  1621. +    }
  1622. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1623. +
  1624.    Fail:
  1625.      CUR.GS.rp1 = CUR.GS.rp0;
  1626.  
  1627. @@ -6357,8 +6859,14 @@
  1628.      FT_F26Dot6  distance;
  1629.  
  1630.      FT_UNUSED_ARG;
  1631. -
  1632. -
  1633. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1634. +    if ( CUR.enhanced_mode && CUR.iup_called                                &&
  1635. +         ( CUR.sph_tweak_flags & SPH_TWEAK_NO_ALIGNRP_AFTER_IUP ) )
  1636. +    {
  1637. +      CUR.error = TT_Err_Invalid_Reference;      
  1638. +      goto Fail;
  1639. +    }
  1640. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1641.      if ( CUR.top < CUR.GS.loop ||
  1642.           BOUNDS( CUR.GS.rp0, CUR.zp0.n_points ) )
  1643.      {
  1644. @@ -6829,6 +7337,15 @@
  1645.      contour = 0;
  1646.      point   = 0;
  1647.  
  1648. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1649. +    if ( CUR.enhanced_mode )
  1650. +    {
  1651. +      CUR.iup_called = 1;
  1652. +      if ( CUR.sph_tweak_flags & SPH_TWEAK_SKIP_IUP )
  1653. +        return;
  1654. +    }
  1655. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1656. +
  1657.      do
  1658.      {
  1659.        end_point   = CUR.pts.contours[contour] - CUR.pts.first_point;
  1660. @@ -6898,8 +7415,20 @@
  1661.      FT_UShort  A;
  1662.      FT_ULong   C;
  1663.      FT_Long    B;
  1664. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1665. +    /*FT_Int     resolution = 1;*/
  1666. +    FT_UShort  B1, B2;
  1667.  
  1668.  
  1669. +    /*if (CUR.enhanced_mode )
  1670. +    {
  1671. +      if ( CUR.GS.freeVector.x != 0 )
  1672. +        resolution = SPH_OPTION_GRIDS_PER_PIXEL_X;
  1673. +      else if ( CUR.GS.freeVector.y != 0 )
  1674. +        resolution = SPH_OPTION_GRIDS_PER_PIXEL_Y;
  1675. +    }*/
  1676. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1677. +
  1678.  #ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
  1679.      /* Delta hinting is covered by US Patent 5159668. */
  1680.      if ( CUR.face->unpatented_hinting )
  1681. @@ -6971,7 +7500,88 @@
  1682.              B++;
  1683.            B = B * 64 / ( 1L << CUR.GS.delta_shift );
  1684.  
  1685. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1686. +
  1687. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING_ADDITIONAL_TWEAKS
  1688. +          /*
  1689. +           *  Undocumented hack that rounds the point prior to or instead
  1690. +           *  of the delta move.  Fixes glitches in various fonts due to bad
  1691. +           *  y-hinting routines.
  1692. +           */
  1693. +          if ( CUR.enhanced_mode && CUR.GS.freeVector.y != 0 )
  1694. +          {
  1695. +            FT_Byte  orig_round_state = CUR.GS.round_state;
  1696. +
  1697. +
  1698. +            if ( CUR.sph_tweak_flags & SPH_TWEAK_DELTAP_RDTG )
  1699. +            {
  1700. +              COMPUTE_Round( TT_Round_Down_To_Grid );
  1701. +              B = CUR_Func_round( B, CUR.tt_metrics.compensations[0], 1 );
  1702. +            }
  1703. +
  1704. +            else if ( CUR.sph_tweak_flags & SPH_TWEAK_DELTAP_RTG )
  1705. +            {
  1706. +              COMPUTE_Round( TT_Round_To_Grid );
  1707. +              B = CUR_Func_round( B, CUR.tt_metrics.compensations[0], 1 );
  1708. +            }
  1709. +
  1710. +            COMPUTE_Round( orig_round_state );
  1711. +          }
  1712. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING_ADDITIONAL_TWEAKS */
  1713. +
  1714. +          /*
  1715. +           *  Allow delta move if
  1716. +           *
  1717. +           *  - not using enhanced_mode rendering
  1718. +           *  - glyph is specifically set to allow it
  1719. +           *  - glyph is composite
  1720. +           */
  1721. +          if ( !CUR.enhanced_mode                                        ||
  1722. +               ( CUR.sph_tweak_flags & SPH_TWEAK_ALWAYS_DO_DELTAP ) ||
  1723. +               CUR.is_composite                                     )
  1724. +            CUR_Func_move( &CUR.zp0, A, B );
  1725. +
  1726. +          else if ( !( CUR.sph_tweak_flags & SPH_TWEAK_ALWAYS_SKIP_DELTAP ) )
  1727. +          {
  1728. +            /* save the y value of the point now; compare after move */
  1729. +            B1 = CUR.zp0.cur[A].y;
  1730. +
  1731. +            if ( CUR.enhanced_mode                                                   &&
  1732. +                ( CUR.sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_INLINE_MOVES ) )
  1733. +              B = FT_PIX_ROUND( B );            
  1734. +                  
  1735. +            /*
  1736. +             *  Allow delta move if using enhanced_mode rendering, IUP has not
  1737. +             *  been called, and point is touched on X or Y.
  1738. +             *
  1739. +             *  Working code, but needs more features.
  1740. +             */
  1741. +            if ( CUR.enhanced_mode                                        &&
  1742. +                 CUR.GS.freeVector.y != 0                            &&
  1743. +                 CUR.iup_called == 0                                 &&
  1744. +                 CUR.iupy_called == 0                                &&
  1745. +                 ( ( CUR.pts.tags[A] & FT_CURVE_TAG_TOUCH_X ) != 0 ||
  1746. +                   ( CUR.pts.tags[A] & FT_CURVE_TAG_TOUCH_Y ) != 0 ) )
  1747. +              /* Should resolution always be 1 for this move? */
  1748. +              CUR_Func_move( &CUR.zp0, A, B );
  1749. +
  1750. +            B2 = CUR.zp0.cur[A].y;
  1751. +
  1752. +            /*
  1753. +             *  reverse this move if it results in a move off a pixel
  1754. +             *  boundary
  1755. +             */
  1756. +            if ( ( CUR.sph_tweak_flags &
  1757. +                     SPH_TWEAK_DELTAP_SKIP_EXAGGERATED_VALUES )
  1758. +                || ( ( CUR.sph_tweak_flags &
  1759. +                     SPH_TWEAK_SKIP_NONPIXEL_INLINE_MOVES ) &&
  1760. +                   B1 % 64 == 0 && B2 % 64 != 0 ) )
  1761. +
  1762. +              CUR_Func_move( &CUR.zp0, A, -B );
  1763. +          }
  1764. +#else
  1765.            CUR_Func_move( &CUR.zp0, A, B );
  1766. +#endif /* *TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1767.          }
  1768.        }
  1769.        else
  1770. @@ -7101,22 +7711,105 @@
  1771.  
  1772.      K = 0;
  1773.  
  1774. -    /* We return MS rasterizer version 1.7 for the font scaler. */
  1775. +    /********************************/
  1776. +    /* RASTERIZER VERSION           */
  1777. +    /* Selector Bit:  0             */
  1778. +    /* Return Bit(s): 0-7           */
  1779. +    /*                              */
  1780. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1781. +    if ( ( args[0] & 1 ) != 0 && CUR.enhanced_mode )
  1782. +    {
  1783. +      K = CUR.rasterizer_version;
  1784. +#ifdef SPH_DEBUG_MORE_VERBOSE
  1785. +      printf(" SETTING AS %d\n", CUR.rasterizer_version );
  1786. +#endif
  1787. +    }
  1788. +    else
  1789. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1790.      if ( ( args[0] & 1 ) != 0 )
  1791. +    {
  1792.        K = 35;
  1793. +#ifdef SPH_DEBUG_MORE_VERBOSE
  1794. +      printf(" SETTING AS 35\n" );
  1795. +#endif
  1796. +    }
  1797.  
  1798. -    /* Has the glyph been rotated? */
  1799. +    /********************************/
  1800. +    /* GLYPH ROTATED                */
  1801. +    /* Selector Bit:  1             */
  1802. +    /* Return Bit(s): 8             */
  1803. +    /*                              */
  1804.      if ( ( args[0] & 2 ) != 0 && CUR.tt_metrics.rotated )
  1805. -      K |= 0x80;
  1806. +      K |= 1 << 8;
  1807.  
  1808. -    /* Has the glyph been stretched? */
  1809. +    /********************************/
  1810. +    /* GLYPH STRETCHED              */
  1811. +    /* Selector Bit:  2             */
  1812. +    /* Return Bit(s): 9             */
  1813. +    /*                              */
  1814.      if ( ( args[0] & 4 ) != 0 && CUR.tt_metrics.stretched )
  1815. -      K |= 1 << 8;
  1816. +      K |= 1 << 9;
  1817.  
  1818. -    /* Are we hinting for grayscale? */
  1819. +    /********************************/
  1820. +    /* HINTING FOR GRAYSCALE        */
  1821. +    /* Selector Bit:  5             */
  1822. +    /* Return Bit(s): 12            */
  1823. +    /*                              */
  1824.      if ( ( args[0] & 32 ) != 0 && CUR.grayscale )
  1825.        K |= 1 << 12;
  1826.  
  1827. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1828. +    if ( CUR.enhanced_mode && CUR.rasterizer_version >= 35)
  1829. +    {
  1830. +      /********************************/
  1831. +      /* HINTING FOR GRAYSCALE        */
  1832. +      /* Selector Bit:  5             */
  1833. +      /* Return Bit(s): 12            */
  1834. +      /*                              */
  1835. +      if ( ( args[0] & 32 ) != 0 && CUR.grayscale_hinting )
  1836. +        K |= 1 << 12;
  1837. +
  1838. +      /********************************/
  1839. +      /* HINTING FOR SUBPIXEL         */
  1840. +      /* Selector Bit:  6             */
  1841. +      /* Return Bit(s): 13            */
  1842. +      /*                              */
  1843. +      if ( ( args[0] & 64 ) != 0 && CUR.subpixel_hinting && CUR.rasterizer_version >= 37)
  1844. +      {
  1845. +        K |= 1 << 13;
  1846. +
  1847. +        /* the stuff below is irrelevant if subpixel_hinting is not set */
  1848. +
  1849. +        /********************************/
  1850. +        /* COMPATIBLE WIDTHS ENABLED    */
  1851. +        /* Selector Bit:  7             */
  1852. +        /* Return Bit(s): 14            */
  1853. +        /*                              */
  1854. +        /* Functionality still needs to be added */
  1855. +        if ( ( args[0] & 128 ) != 0 && CUR.compatible_widths )
  1856. +          K |= 1 << 14;
  1857. +
  1858. +        /********************************/
  1859. +        /* SYMMETRICAL SMOOTHING        */
  1860. +        /* Selector Bit:  8             */
  1861. +        /* Return Bit(s): 15            */
  1862. +        /*                              */
  1863. +        /* Functionality still needs to be added */
  1864. +        if ( ( args[0] & 256 ) != 0 && CUR.symmetrical_smoothing )
  1865. +          K |= 1 << 15;
  1866. +
  1867. +        /********************************/
  1868. +        /* HINTING FOR BGR?             */
  1869. +        /* Selector Bit:  9             */
  1870. +        /* Return Bit(s): 16            */
  1871. +        /*                              */
  1872. +        /* Functionality still needs to be added */
  1873. +        if ( ( args[0] & 512 ) != 0 && CUR.bgr )
  1874. +          K |= 1 << 16;
  1875. +      }
  1876. +    }
  1877. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1878. +
  1879.      args[0] = K;
  1880.    }
  1881.  
  1882. @@ -7491,6 +8184,18 @@
  1883.      cur = *exc;
  1884.  #endif
  1885.  
  1886. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1887. +    if (CUR.enhanced_mode)
  1888. +    {
  1889. +      /* ensure some variables are set for this run */
  1890. +      CUR.iup_called        = FALSE;
  1891. +      CUR.iupy_called       = FALSE;
  1892. +      CUR.in_delta_function = FALSE;
  1893. +
  1894. +      /*if ( CUR.sph_tweak_flags & SPH_TWEAK_DONT_HINT ) return TT_Err_Ok;*/
  1895. +    }
  1896. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1897. +
  1898.      /* set CVT functions */
  1899.      CUR.tt_metrics.ratio = 0;
  1900.      if ( CUR.metrics.x_ppem != CUR.metrics.y_ppem )
  1901. @@ -7762,7 +8467,12 @@
  1902.            break;
  1903.  
  1904.          case 0x2B:  /* CALL */
  1905. -          Ins_CALL( EXEC_ARG_ args );
  1906. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING          
  1907. +        if ( !CUR.enhanced_mode
  1908. +          || !CUR.iup_called                                
  1909. +          || !( CUR.sph_tweak_flags & SPH_TWEAK_NO_CALL_AFTER_IUP ) )
  1910. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */          
  1911. +            Ins_CALL( EXEC_ARG_ args );
  1912.            break;
  1913.  
  1914.          case 0x2C:  /* FDEF */
  1915. @@ -7780,8 +8490,16 @@
  1916.  
  1917.  
  1918.          case 0x30:  /* IUP */
  1919. +          Ins_IUP( EXEC_ARG_ args );
  1920. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1921. +          if (CUR.enhanced_mode) CUR.iup_called = TRUE;
  1922. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1923. +          break;
  1924.          case 0x31:  /* IUP */
  1925.            Ins_IUP( EXEC_ARG_ args );
  1926. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1927. +          if (CUR.enhanced_mode) CUR.iupy_called = TRUE;
  1928. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING*/
  1929.            break;
  1930.  
  1931.          case 0x32:  /* SHP */
  1932. diff -Nur src/truetype/ttinterp.h.orig src/truetype/ttinterp.h
  1933. --- src/truetype/ttinterp.h.orig    2010-08-05 16:56:05.000000000 -0500
  1934. +++ src/truetype/ttinterp.h 2011-12-23 19:47:58.547521649 -0600
  1935. @@ -68,7 +68,8 @@
  1936.    /* Rounding function */
  1937.    typedef FT_F26Dot6
  1938.    (*TT_Round_Func)( EXEC_OP_ FT_F26Dot6  distance,
  1939. -                             FT_F26Dot6  compensation );
  1940. +                             FT_F26Dot6  compensation,
  1941. +                             FT_Int      resolution );
  1942.  
  1943.    /* Point displacement along the freedom vector routine */
  1944.    typedef void
  1945. @@ -106,6 +107,43 @@
  1946.    } TT_CallRec, *TT_CallStack;
  1947.  
  1948.  
  1949. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1950. +
  1951. +  /*************************************************************************/
  1952. +  /*                                                                       */
  1953. +  /* This structure defines a rule used to tweak subpixel hinting for      */
  1954. +  /* various fonts.  "", 0, "", NULL value indicates to match any value.   */
  1955. +  /*                                                                       */
  1956. +
  1957. +  typedef struct  SPH_TweakRule_
  1958. +  {
  1959. +    const char  family[32];
  1960. +    const int   ppem;
  1961. +    const char  style[32];
  1962. +    const FT_ULong  glyph;
  1963. +
  1964. +  } SPH_TweakRule;
  1965. +
  1966. +  
  1967. +  typedef struct  SPH_ScaleRule_
  1968. +  {
  1969. +    const char  family[32];
  1970. +    const int   ppem;
  1971. +    const char  style[32];
  1972. +    const FT_ULong  glyph;
  1973. +    const float scale;
  1974. +  } SPH_ScaleRule;  
  1975. +  
  1976. +  
  1977. +  typedef struct  Font_Class_
  1978. +  {
  1979. +    const char  name[32];
  1980. +    const char  family[7][32];
  1981. +  } Font_Class;    
  1982. +  
  1983. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  1984. +
  1985. +
  1986.    /*************************************************************************/
  1987.    /*                                                                       */
  1988.    /* The main structure for the interpreter which collects all necessary   */
  1989. @@ -217,6 +255,33 @@
  1990.  
  1991.      FT_Bool            grayscale;      /* are we hinting for grayscale? */
  1992.  
  1993. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  1994. +    TT_Round_Func      func_round_sphn;   /* subpixel rounding function */
  1995. +
  1996. +    FT_Bool            grayscale_hinting; /* use grayscale hinting?        */
  1997. +    FT_Bool            subpixel_hinting;  /* use subpixel hinting?         */
  1998. +    FT_Bool            enhanced_mode;     /* enhanced rendering on? (used  */
  1999. +                                          /* to enable/disable grayscale or*/
  2000. +                                          /* subpixel hinting at run time) */
  2001. +    FT_Bool            native_hinting;    /* native hinting?               */
  2002. +
  2003. +    /* the following 3 are unimplemented but here for future reference */
  2004. +    FT_Bool            compatible_widths;     /* compatible widths?     */
  2005. +    FT_Bool            symmetrical_smoothing; /* symmetrical_smoothing? */
  2006. +    FT_Bool            bgr;                   /* bgr instead of rgb?    */
  2007. +
  2008. +    FT_Int             rasterizer_version; /* MS rasterizer version */
  2009. +
  2010. +    FT_Bool            iup_called;        /* IUP[x] been called for glyph? */
  2011. +    FT_Bool            iupy_called;       /* IUP[y] been called for glyph? */
  2012. +    FT_Bool            in_delta_function; /* inside an inline delta func?  */
  2013. +
  2014. +    FT_ULong           sph_tweak_flags;   /* flags to control hint tweaks */
  2015. +
  2016. +    FT_Int             num_delta_funcs;
  2017. +    FT_ULong           inline_delta_funcs[5];
  2018. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  2019. +
  2020.    } TT_ExecContextRec;
  2021.  
  2022.  
  2023. diff -Nur src/truetype/ttobjs.h.orig src/truetype/ttobjs.h
  2024. --- src/truetype/ttobjs.h.orig  2011-01-31 23:51:20.000000000 -0600
  2025. +++ src/truetype/ttobjs.h   2011-11-17 20:59:44.159885439 -0600
  2026. @@ -173,10 +173,11 @@
  2027.    /*                                                                       */
  2028.    typedef struct  TT_DefRecord_
  2029.    {
  2030. -    FT_Int   range;      /* in which code range is it located? */
  2031. -    FT_Long  start;      /* where does it start?               */
  2032. -    FT_UInt  opc;        /* function #, or instruction code    */
  2033. -    FT_Bool  active;     /* is it active?                      */
  2034. +    FT_Int   range;        /* in which code range is it located?     */
  2035. +    FT_Long  start;        /* where does it start?                   */
  2036. +    FT_UInt  opc;          /* function #, or instruction code        */
  2037. +    FT_Bool  active;       /* is it active?                          */
  2038. +    FT_Bool  inline_delta; /* is function that defines inline delta? */
  2039.  
  2040.    } TT_DefRecord, *TT_DefArray;
  2041.  
  2042. @@ -189,7 +190,7 @@
  2043.    {
  2044.      FT_Fixed    xx, xy;     /* transformation matrix coefficients */
  2045.      FT_Fixed    yx, yy;
  2046. -    FT_F26Dot6  ox, oy;     /* offsets        */
  2047. +    FT_F26Dot6  ox, oy;     /* offsets                            */
  2048.  
  2049.    } TT_Transform;
  2050.  
  2051. diff -Nur src/truetype/ttsubpix.c src/truetype/ttsubpix.c
  2052. --- src/truetype/ttsubpix.c.orig    1969-12-31 18:00:00.000000000 -0600
  2053. +++ src/truetype/ttsubpix.c 2011-12-23 19:49:27.948443055 -0600
  2054. @@ -0,0 +1,170 @@
  2055. +/***************************************************************************/
  2056. +/*                                                                         */
  2057. +/*  ttsubpix.c                                                             */
  2058. +/*                                                                         */
  2059. +/*    TrueType Subpixel Hinting.                                           */
  2060. +/*                                                                         */
  2061. +/*  Copyright 2010-2011 by                                                 */
  2062. +/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
  2063. +/*                                                                         */
  2064. +/*  This file is part of the FreeType project, and may only be used,       */
  2065. +/*  modified, and distributed under the terms of the FreeType project      */
  2066. +/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
  2067. +/*  this file you indicate that you have read the license and              */
  2068. +/*  understand and accept it fully.                                        */
  2069. +/*                                                                         */
  2070. +/***************************************************************************/
  2071. +
  2072. +#include <ft2build.h>
  2073. +#include FT_INTERNAL_DEBUG_H
  2074. +#include FT_INTERNAL_CALC_H
  2075. +#include FT_INTERNAL_STREAM_H
  2076. +#include FT_INTERNAL_SFNT_H
  2077. +#include FT_TRUETYPE_TAGS_H
  2078. +#include FT_OUTLINE_H
  2079. +
  2080. +#include "ttsubpix.h"
  2081. +
  2082. +
  2083. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  2084. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING_ADDITIONAL_TWEAKS
  2085. +
  2086. +  FT_LOCAL_DEF( FT_Bool )
  2087. +  sph_test_tweak( TT_Face         face,
  2088. +                  FT_String*      family,
  2089. +                  int             ppem,
  2090. +                  FT_String*      style,
  2091. +                  FT_UInt         glyph_index,
  2092. +                  SPH_TweakRule*  rule,
  2093. +                  FT_UInt         num_rules )
  2094. +  {
  2095. +    FT_UInt  i;
  2096. +
  2097. +
  2098. +    /* rule checks may be able to be optimized further */
  2099. +    for ( i = 0; i < num_rules; i++ )
  2100. +    {
  2101. +      if ( family                                    &&
  2102. +           ( strcmp( rule[i].family, "" ) == 0     ||
  2103. +             strcmp( rule[i].family, family ) == 0 ) )
  2104. +        if ( rule[i].ppem == 0    ||
  2105. +             rule[i].ppem == ppem )
  2106. +          if ( ( style                            &&
  2107. +                 strcmp( rule[i].style, "" ) == 0 ) ||
  2108. +               strcmp( rule[i].style, style ) == 0  )
  2109. +            if ( rule[i].glyph == 0                                ||
  2110. +                 FT_Get_Char_Index( (FT_Face)face,
  2111. +                                    rule[i].glyph ) == glyph_index )
  2112. +      {
  2113. +        /* printf( "%s,%d,%s,%c ", family, ppem, style, rule[i].glyph ); */
  2114. +        return TRUE;
  2115. +      }
  2116. +    }
  2117. +    return FALSE;
  2118. +  }
  2119. +
  2120. +
  2121. +#define TWEAK_RULES( x )                                       \
  2122. +  if ( sph_test_tweak( face, family, ppem, style, glyph_index, \
  2123. +                       x##_Rules, x##_RULES_SIZE ) )           \
  2124. +    loader->exec->sph_tweak_flags |= SPH_TWEAK_##x;
  2125. +
  2126. +#define TWEAK_RULES_EXCEPTIONS( x )                                        \
  2127. +  if ( sph_test_tweak( face, family, ppem, style, glyph_index,             \
  2128. +                       x##_Rules_Exceptions, x##_RULES_EXCEPTIONS_SIZE ) ) \
  2129. +    loader->exec->sph_tweak_flags &= ~SPH_TWEAK_##x;
  2130. +
  2131. +
  2132. +  FT_LOCAL_DEF( void )
  2133. +  sph_set_tweaks( TT_Loader  loader,
  2134. +                  FT_UInt    glyph_index )
  2135. +  {
  2136. +    TT_Face     face   = (TT_Face)loader->face;
  2137. +    FT_String*  family = face->root.family_name;
  2138. +    int         ppem   = loader->size->metrics.x_ppem;
  2139. +    FT_String*  style  = face->root.style_name;
  2140. +
  2141. +    /* Don't apply rules if style isn't set */
  2142. +    if ( !face->root.style_name ) return;
  2143. +
  2144. +    /* loader->exec->sph_tweak_flags = 0; */
  2145. +
  2146. +    /* printf( "%s,%d,%s,%c=%d ", family, ppem, style, glyph_index, glyph_index ); */
  2147. +    TWEAK_RULES( PIXEL_HINTING );
  2148. +    
  2149. +    if ( loader->exec->sph_tweak_flags & SPH_TWEAK_PIXEL_HINTING )
  2150. +    {
  2151. +      loader->exec->enhanced_mode = FALSE;
  2152. +      return;
  2153. +    }
  2154. +    
  2155. +    TWEAK_RULES( NO_ALIGNRP_AFTER_IUP );
  2156. +    TWEAK_RULES( NO_CALL_AFTER_IUP );    
  2157. +    TWEAK_RULES( DEEMBOLDEN );
  2158. +    TWEAK_RULES( EMBOLDEN );
  2159. +    TWEAK_RULES( SKIP_INLINE_DELTAS );    
  2160. +
  2161. +    TWEAK_RULES( NORMAL_ROUND_MIRP );
  2162. +    TWEAK_RULES( NORMAL_ROUND_MDRP );
  2163. +    TWEAK_RULES( NORMAL_ROUND_MDAP );
  2164. +    TWEAK_RULES( NORMAL_ROUND_MIAP );
  2165. +
  2166. +    TWEAK_RULES( SKIP_IUP );
  2167. +
  2168. +    TWEAK_RULES( ALWAYS_SKIP_DELTAP );
  2169. +    TWEAK_RULES( ALWAYS_DO_DELTAP );
  2170. +    TWEAK_RULES( DELTAP_RTG );
  2171. +    TWEAK_RULES( DELTAP_SKIP_EXAGGERATED_VALUES );
  2172. +    TWEAK_RULES( DELTAP_RDTG );
  2173. +
  2174. +    TWEAK_RULES( ALLOW_DMOVEX_FREEV );
  2175. +    TWEAK_RULES( ALLOW_DMOVE_FREEV );
  2176. +    TWEAK_RULES_EXCEPTIONS( ALLOW_DMOVEX_FREEV );
  2177. +    TWEAK_RULES_EXCEPTIONS( ALLOW_DMOVE_FREEV );
  2178. +
  2179. +    TWEAK_RULES( RASTERIZER_35 );
  2180. +
  2181. +    TWEAK_RULES( ALLOW_MOVEZP2_FREEV );
  2182. +    TWEAK_RULES_EXCEPTIONS( ALLOW_MOVEZP2_FREEV );
  2183. +
  2184. +    TWEAK_RULES( DO_RS );
  2185. +
  2186. +    TWEAK_RULES( DO_SHPIX );
  2187. +
  2188. +    TWEAK_RULES( SKIP_NONPIXEL_INLINE_MOVES );
  2189. +    TWEAK_RULES_EXCEPTIONS( SKIP_NONPIXEL_INLINE_MOVES );    
  2190. +
  2191. +    TWEAK_RULES( ROUND_NONPIXEL_INLINE_MOVES );    
  2192. +    TWEAK_RULES_EXCEPTIONS( ROUND_NONPIXEL_INLINE_MOVES );  
  2193. +    
  2194. +    TWEAK_RULES( SHPIX_EITHER_TOUCHED );
  2195. +    TWEAK_RULES_EXCEPTIONS( SHPIX_EITHER_TOUCHED );
  2196. +    
  2197. +
  2198. +    if ( loader->exec->sph_tweak_flags & SPH_TWEAK_RASTERIZER_35 )
  2199. +    {
  2200. +      if ( loader->exec->rasterizer_version != 35 )
  2201. +      {
  2202. +        loader->exec->rasterizer_version = 35;    
  2203. +        /* must re-execute fpgm */
  2204. +        loader->exec->size->cvt_ready      = FALSE;    
  2205. +        tt_size_ready_bytecode( loader->exec->size, FT_BOOL( loader->load_flags & FT_LOAD_PEDANTIC ) );
  2206. +      }
  2207. +    }
  2208. +    else
  2209. +    {
  2210. +      if ( loader->exec->rasterizer_version == 35 )
  2211. +      {
  2212. +        loader->exec->rasterizer_version = 37;    
  2213. +        /* must re-execute fpgm */
  2214. +        loader->exec->size->cvt_ready      = FALSE;  
  2215. +        tt_size_ready_bytecode( loader->exec->size, FT_BOOL( loader->load_flags & FT_LOAD_PEDANTIC ) );        
  2216. +      }
  2217. +    }      
  2218. +  }
  2219. +
  2220. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING_ADDITIONAL_TWEAKS */
  2221. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  2222. +
  2223. +
  2224. +/* END */
  2225. diff -Nur src/truetype/ttsubpix.h.orig src/truetype/ttsubpix.h
  2226. --- src/truetype/ttsubpix.h.orig    1969-12-31 18:00:00.000000000 -0600
  2227. +++ src/truetype/ttsubpix.h 2011-12-23 19:52:30.830145677 -0600
  2228. @@ -0,0 +1,958 @@
  2229. +/***************************************************************************/
  2230. +/*                                                                         */
  2231. +/*  ttsubpix.h                                                             */
  2232. +/*                                                                         */
  2233. +/*    TrueType Subpixel Hinting.                                           */
  2234. +/*                                                                         */
  2235. +/*  Copyright 2010-2011 by                                                 */
  2236. +/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
  2237. +/*                                                                         */
  2238. +/*  This file is part of the FreeType project, and may only be used,       */
  2239. +/*  modified, and distributed under the terms of the FreeType project      */
  2240. +/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
  2241. +/*  this file you indicate that you have read the license and              */
  2242. +/*  understand and accept it fully.                                        */
  2243. +/*                                                                         */
  2244. +/***************************************************************************/
  2245. +
  2246. +#ifndef __TTSUBPIX_H__
  2247. +#define __TTSUBPIX_H__
  2248. +
  2249. +#include <ft2build.h>
  2250. +#include "ttobjs.h"
  2251. +#include "ttinterp.h"
  2252. +
  2253. +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
  2254. +
  2255. +  /*************************************************************************/
  2256. +  /*                                                                       */
  2257. +  /* Tweak flags that are set for each glyph                               */
  2258. +  /*                                                                       */
  2259. +  /*                                                                       */
  2260. +#define SPH_TWEAK_NORMAL_ROUND_MIRP           0x0000001
  2261. +#define SPH_TWEAK_NORMAL_ROUND_MDRP           0x0000002
  2262. +#define SPH_TWEAK_DELTAP_RDTG                 0x0000004
  2263. +#define SPH_TWEAK_DELTAP_RTG                  0x0000008
  2264. +#define SPH_TWEAK_DELTAP_SKIP_EXAGGERATED_VALUES   0x0000010
  2265. +#define SPH_TWEAK_ALLOW_DMOVEX_FREEV          0x0000020
  2266. +#define SPH_TWEAK_ALLOW_DMOVE_FREEV           0x0000040
  2267. +#define SPH_TWEAK_ALLOW_MOVEZP2_FREEV         0x0000080
  2268. +#define SPH_TWEAK_ALWAYS_SKIP_DELTAP          0x0000100
  2269. +#define SPH_TWEAK_SKIP_IUP                    0x0000200
  2270. +#define SPH_TWEAK_NORMAL_ROUND_MIAP           0x0000400
  2271. +#define SPH_TWEAK_NORMAL_ROUND_MDAP           0x0000800
  2272. +#define SPH_TWEAK_DO_RS                       0x0001000
  2273. +#define SPH_TWEAK_DO_SHPIX                    0x0002000
  2274. +#define SPH_TWEAK_ALWAYS_DO_DELTAP            0x0004000
  2275. +#define SPH_TWEAK_SKIP_NONPIXEL_INLINE_MOVES  0x0008000
  2276. +#define SPH_TWEAK_SHPIX_EITHER_TOUCHED        0x0010000
  2277. +#define SPH_TWEAK_RASTERIZER_35               0x0020000
  2278. +#define SPH_TWEAK_PIXEL_HINTING               0x0040000
  2279. +#define SPH_TWEAK_NO_ALIGNRP_AFTER_IUP        0x0080000
  2280. +#define SPH_TWEAK_DEEMBOLDEN                  0x0100000
  2281. +#define SPH_TWEAK_EMBOLDEN                    0x0200000
  2282. +#define SPH_TWEAK_ROUND_NONPIXEL_INLINE_MOVES 0x0400000
  2283. +#define SPH_TWEAK_NO_CALL_AFTER_IUP           0x0800000
  2284. +#define SPH_TWEAK_SKIP_INLINE_DELTAS          0x1000000
  2285. +
  2286. +
  2287. +  FT_LOCAL( FT_Bool )
  2288. +  sph_test_tweak( TT_Face         face,
  2289. +                  FT_String*      family,
  2290. +                  int             ppem,
  2291. +                  FT_String*      style,
  2292. +                  FT_UInt         glyph_index,
  2293. +                  SPH_TweakRule*  rule,
  2294. +                  FT_UInt         num_rules );
  2295. +
  2296. +  FT_LOCAL( void )
  2297. +  sph_set_tweaks( TT_Loader  loader,
  2298. +                  FT_UInt    glyph_index );
  2299. +
  2300. +
  2301. +  /*************************************************************************/
  2302. +  /*                                                                       */
  2303. +  /* These are groups of rules that affect how the TT Interpreter does     */
  2304. +  /* hinting.                                                              */
  2305. +  /*                                                                       */
  2306. +  /* "" string or 0 int/char indicates to apply to all.                    */
  2307. +  /* "-" used as dummy placeholders, but any non-matching string works.    */
  2308. +  /*                                                                       */
  2309. +  /* Remaining rules are tweaks for various fonts / glyphs.                */
  2310. +  /* Some of this could arguably be implemented in fontconfig, however:    */
  2311. +  /*                                                                       */
  2312. +  /*  - Fontconfig can't set things on a glyph-by-glyph basis.             */
  2313. +  /*  - The tweaks that happen here are very low-level, from an average    */
  2314. +  /*    user's point of view and are best implemented in the hinter        */
  2315. +  /*                                                                       */
  2316. +  /* Ideally, some of these should be generalized across affected fonts,   */
  2317. +  /* and enabled by default in the code.  The rule structure is designed   */
  2318. +  /* so that entirely new rules can easily be added when a new             */
  2319. +  /* compatibility feature is discovered.                                  */
  2320. +  /*                                                                       */
  2321. +
  2322. +
  2323. +  /*************************************************************************/
  2324. +  /*                                                                       */
  2325. +  /* TT_CONFIG_OPTION_SUBPIXEL_HINTING Rules                               */
  2326. +  /*                                                                       */
  2327. +  /* Simply, this attempts to duplicate the functionality described here   */
  2328. +  /* and nothing more:                                                     */
  2329. +  /*                                                                       */
  2330. +  /*  http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx */
  2331. +  /*                                                                       */
  2332. +  /* This mode is enabled if                                               */
  2333. +  /* TT_CONFIG_OPTION_SUBPIXEL_HINTING_ADDITIONAL_TWEAKS                   */
  2334. +  /* is undefined                                                          */
  2335. +  /*                                                                       */
  2336. +
  2337. +
  2338. +#ifndef TT_CONFIG_OPTION_SUBPIXEL_HINTING_ADDITIONAL_TWEAKS
  2339. +
  2340. +#if 0 /* this ruleset is not currently being used */
  2341. +
  2342. +#define SPH_OPTION_BITMAP_WIDTHS           FALSE
  2343. +#define SPH_OPTION_SET_SUBPIXEL            FALSE
  2344. +#define SPH_OPTION_SET_GRAYSCALE           TRUE
  2345. +#define SPH_OPTION_SET_COMPATIBLE_WIDTHS   TRUE
  2346. +#define SPH_OPTION_SET_RASTERIZER_VERSION  35
  2347. +#define SPH_OPTION_GRIDS_PER_PIXEL_X       1
  2348. +#define SPH_OPTION_GRIDS_PER_PIXEL_Y       1
  2349. +
  2350. +
  2351. +  /********** MOVE RULES *************/
  2352. +
  2353. +  /* allow a Direct_Move_X along freedom vector if matched */
  2354. +#define ALLOW_DMOVEX_FREEV_RULES_SIZE  1
  2355. +  SPH_TweakRule  ALLOW_DMOVEX_FREEV_Rules
  2356. +                   [ALLOW_DMOVEX_FREEV_RULES_SIZE] =
  2357. +                 {
  2358. +                   { "", 0, "", 0 },
  2359. +                 };
  2360. +
  2361. +  /* allow a Direct_Move along freedom vector if matched */
  2362. +#define ALLOW_DMOVE_FREEV_RULES_SIZE  1
  2363. +  SPH_TweakRule  ALLOW_DMOVE_FREEV_Rules
  2364. +                   [ALLOW_DMOVE_FREEV_RULES_SIZE] =
  2365. +                 {
  2366. +                   { "", 0, "", 0 },
  2367. +                 };
  2368. +
  2369. +  /* allow a ZP2 move along freedom vector if matched */
  2370. +#define ALLOW_MOVEZP2_FREEV_RULES_SIZE  1
  2371. +  SPH_TweakRule  ALLOW_MOVEZP2_FREEV_Rules
  2372. +                   [ALLOW_MOVEZP2_FREEV_RULES_SIZE] =
  2373. +                 {
  2374. +                   { "", 0, "", 0 },
  2375. +                 };
  2376. +
  2377. +  /* don't skip RS calls */
  2378. +#define DO_RS_RULES_SIZE  1
  2379. +  SPH_TweakRule  DO_RS_Rules
  2380. +                   [DO_RS_RULES_SIZE] =
  2381. +                 {
  2382. +                   { "-", 0, "", 0 },
  2383. +                 };
  2384. +
  2385. +  /* force requested SHPIX operations if matched */
  2386. +#define DO_SHPIX_RULES_SIZE  1
  2387. +  SPH_TweakRule  DO_SHPIX_Rules
  2388. +                   [DO_SHPIX_RULES_SIZE] =
  2389. +                 {
  2390. +                   { "-", 0, "", 0 },
  2391. +                 };
  2392. +
  2393. +#define SKIP_NONPIXEL_INLINE_MOVES_RULES_SIZE  1
  2394. +  SPH_TweakRule  SKIP_NONPIXEL_INLINE_MOVES_Rules
  2395. +                   [SKIP_NONPIXEL_INLINE_MOVES_RULES_SIZE] =
  2396. +                 {
  2397. +                   { "-", 0, "", 0 },
  2398. +                 };
  2399. +
  2400. +#define NORMAL_ROUND_MIRP_RULES_SIZE  1
  2401. +  SPH_TweakRule  NORMAL_ROUND_MIRP_Rules
  2402. +                   [NORMAL_ROUND_MIRP_RULES_SIZE] =
  2403. +                 {
  2404. +                   { "", 0, "", 0 },
  2405. +                 };
  2406. +
  2407. +#define NORMAL_ROUND_MIAP_RULES_SIZE  1
  2408. +  SPH_TweakRule  NORMAL_ROUND_MIAP_Rules
  2409. +                   [NORMAL_ROUND_MIAP_RULES_SIZE] =
  2410. +                 {
  2411. +                   { "", 0, "", 0 },
  2412. +                 };
  2413. +
  2414. +#define NORMAL_ROUND_MDRP_RULES_SIZE  1
  2415. +  SPH_TweakRule  NORMAL_ROUND_MDRP_Rules
  2416. +                   [NORMAL_ROUND_MDRP_RULES_SIZE] =
  2417. +                 {
  2418. +                   { "", 0, "", 0 },
  2419. +                 };
  2420. +
  2421. +#define NORMAL_ROUND_MDAP_RULES_SIZE  1
  2422. +  SPH_TweakRule  NORMAL_ROUND_MDAP_Rules
  2423. +                   [NORMAL_ROUND_MDAP_RULES_SIZE] =
  2424. +                 {
  2425. +                   { "", 0, "", 0 },
  2426. +                 };
  2427. +
  2428. +  /* indicate that SHPIX needs to match a touched point on x OR y */
  2429. +#define SHPIX_EITHER_TOUCHED_RULES_SIZE  1
  2430. +  SPH_TweakRule  SHPIX_EITHER_TOUCHED_Rules
  2431. +                   [SHPIX_EITHER_TOUCHED_RULES_SIZE] =
  2432. +                 {
  2433. +                   { "-", 0, "", 0 },
  2434. +                 };
  2435. +
  2436. +  /* mystery rules that make SHPIX work on certain fonts/glyphs;       */
  2437. +  /* indicates that SHPIX needs to match a touched point on x AND y -- */
  2438. +  /* this is dirty and needs to be generalized and incorporated        */
  2439. +#define SHPIX_EITHER_TOUCHED_RULES_EXCEPTIONS_SIZE  1
  2440. +  SPH_TweakRule  SHPIX_EITHER_TOUCHED_Rules_Exceptions
  2441. +                   [SHPIX_EITHER_TOUCHED_RULES_EXCEPTIONS_SIZE] =
  2442. +                 {
  2443. +                   { "-", 0, "", 0 },
  2444. +                 };
  2445. +
  2446. +#define ALLOW_DMOVEX_FREEV_RULES_EXCEPTIONS_SIZE  1
  2447. +  SPH_TweakRule  ALLOW_DMOVEX_FREEV_Rules_Exceptions
  2448. +                   [ALLOW_DMOVEX_FREEV_RULES_EXCEPTIONS_SIZE] =
  2449. +                 {
  2450. +                   { "-", 0, "", 0 },
  2451. +                 };
  2452. +
  2453. +#define ALLOW_DMOVE_FREEV_RULES_EXCEPTIONS_SIZE  1
  2454. +  SPH_TweakRule  ALLOW_DMOVE_FREEV_Rules_Exceptions
  2455. +                   [ALLOW_DMOVE_FREEV_RULES_EXCEPTIONS_SIZE] =
  2456. +                 {
  2457. +                   { "-", 0, "", 0 },
  2458. +                 };
  2459. +
  2460. +#define ALLOW_MOVEZP2_FREEV_RULES_EXCEPTIONS_SIZE  1
  2461. +  SPH_TweakRule  ALLOW_MOVEZP2_FREEV_Rules_Exceptions
  2462. +                   [ALLOW_MOVEZP2_FREEV_RULES_EXCEPTIONS_SIZE] =
  2463. +                 {
  2464. +                   { "-", 0, "", 0 },
  2465. +                 };
  2466. +
  2467. +  /* skip IUP instructions if matched */
  2468. +#define SKIP_IUP_RULES_SIZE  1
  2469. +  SPH_TweakRule  SKIP_IUP_Rules
  2470. +                   [SKIP_IUP_RULES_SIZE] =
  2471. +                 {
  2472. +                   { "-", 0, "", 0 },
  2473. +                 };
  2474. +
  2475. +  /* skip DELTAP instructions if matched */
  2476. +#define ALWAYS_SKIP_DELTAP_RULES_SIZE  1
  2477. +  SPH_TweakRule  ALWAYS_SKIP_DELTAP_Rules
  2478. +                   [ALWAYS_SKIP_DELTAP_RULES_SIZE] =
  2479. +                 {
  2480. +                   { "-", 0, "", 0 },
  2481. +                 };
  2482. +
  2483. +  /* always do DELTAP instructions if matched */
  2484. +#define ALWAYS_DO_DELTAP_RULES_SIZE  1
  2485. +  SPH_TweakRule  ALWAYS_DO_DELTAP_Rules
  2486. +                   [ALWAYS_DO_DELTAP_RULES_SIZE] =
  2487. +                 {
  2488. +                   { "-", 0, "", 0 },
  2489. +                 };
  2490. +
  2491. +  /* do an extra RTG instruction in DELTAP if matched */
  2492. +#define DELTAP_RTG_RULES_SIZE  1
  2493. +  SPH_TweakRule  DELTAP_RTG_Rules
  2494. +                   [DELTAP_RTG_RULES_SIZE] =
  2495. +                 {
  2496. +                   { "-", 0, "", 0 },
  2497. +                 };
  2498. +
  2499. +  /* do an extra RUTG instruction in DELTAP if matched */
  2500. +#define DELTAP_SKIP_EXAGGERATED_VALUES_RULES_SIZE  1
  2501. +  SPH_TweakRule  DELTAP_SKIP_EXAGGERATED_VALUES_Rules
  2502. +                   [DELTAP_SKIP_EXAGGERATED_VALUES_RULES_SIZE] =
  2503. +                 {
  2504. +                   { "-", 0, "", 0 },
  2505. +                 };
  2506. +
  2507. +  /* do an extra RDTG instruction in DELTAP if matched */
  2508. +#define DELTAP_RDTG_RULES_SIZE 1
  2509. +  SPH_TweakRule  DELTAP_RDTG_Rules
  2510. +                   [DELTAP_RDTG_RULES_SIZE] =
  2511. +                 {
  2512. +                   { "-", 0, "", 0 },
  2513. +                 };
  2514. +
  2515. +  /* return MS rasterizer version 35 if matched */
  2516. +#define RASTERIZER_35_RULES_SIZE 1
  2517. +  SPH_TweakRule  RASTERIZER_35_Rules
  2518. +                   [RASTERIZER_35_RULES_SIZE] =
  2519. +                 {
  2520. +                   { "-", 0, "", 0 },
  2521. +                 };
  2522. +
  2523. +
  2524. +#else /* 1 */
  2525. +
  2526. +
  2527. +#define SPH_OPTION_BITMAP_WIDTHS           FALSE
  2528. +#define SPH_OPTION_SET_SUBPIXEL            TRUE
  2529. +#define SPH_OPTION_SET_GRAYSCALE           FALSE
  2530. +#define SPH_OPTION_SET_COMPATIBLE_WIDTHS   FALSE
  2531. +#define SPH_OPTION_SET_RASTERIZER_VERSION  37
  2532. +#define SPH_OPTION_GRIDS_PER_PIXEL_X       64
  2533. +#define SPH_OPTION_GRIDS_PER_PIXEL_Y       1
  2534. +
  2535. +
  2536. +/********** MOVE RULES *************/
  2537. +
  2538. +  /* allow a Direct_Move_X along freedom vector if matched */
  2539. +#define ALLOW_DMOVEX_FREEV_RULES_SIZE  1
  2540. +  SPH_TweakRule  ALLOW_DMOVEX_FREEV_Rules
  2541. +                   [ALLOW_DMOVEX_FREEV_RULES_SIZE] =
  2542. +                 {
  2543. +                   { "-", 0, "", 0 },
  2544. +                 };
  2545. +
  2546. +  /* allow a Direct_Move along freedom vector if matched */
  2547. +#define ALLOW_DMOVE_FREEV_RULES_SIZE  1
  2548. +  SPH_TweakRule  ALLOW_DMOVE_FREEV_Rules
  2549. +                   [ALLOW_DMOVE_FREEV_RULES_SIZE] =
  2550. +                 {
  2551. +                   { "-", 0, "", 0 },
  2552. +                 };
  2553. +
  2554. +  /* allow a ZP2 move along freedom vector if matched */
  2555. +#define ALLOW_MOVEZP2_FREEV_RULES_SIZE  1
  2556. +  SPH_TweakRule  ALLOW_MOVEZP2_FREEV_Rules
  2557. +                   [ALLOW_MOVEZP2_FREEV_RULES_SIZE] =
  2558. +                 {
  2559. +                   { "-", 0, "", 0 },
  2560. +                 };
  2561. +
  2562. +  /* don't skip RS calls */
  2563. +#define DO_RS_RULES_SIZE  1
  2564. +  SPH_TweakRule  DO_RS_Rules
  2565. +                   [DO_RS_RULES_SIZE] =
  2566. +                 {
  2567. +                   { "-", 0, "", 0 },
  2568. +                 };
  2569. +
  2570. +  /* force requested SHPIX operations if matched  */
  2571. +#define DO_SHPIX_RULES_SIZE  1
  2572. +  SPH_TweakRule  DO_SHPIX_Rules
  2573. +                   [DO_SHPIX_RULES_SIZE] =
  2574. +                 {
  2575. +                   { "-", 0, "", 0 },
  2576. +                 };
  2577. +
  2578. +#define SKIP_NONPIXEL_INLINE_MOVES_RULES_SIZE  1
  2579. +  SPH_TweakRule  SKIP_NONPIXEL_INLINE_MOVES_Rules
  2580. +                   [SKIP_NONPIXEL_INLINE_MOVES_RULES_SIZE] =
  2581. +                 {
  2582. +                   { "-", 0, "", 0 },
  2583. +                 };
  2584. +
  2585. +#define NORMAL_ROUND_MIRP_RULES_SIZE  1
  2586. +  SPH_TweakRule  NORMAL_ROUND_MIRP_Rules
  2587. +                   [NORMAL_ROUND_MIRP_RULES_SIZE] =
  2588. +                 {
  2589. +                   { "-", 0, "", 0 },
  2590. +                 };
  2591. +
  2592. +#define NORMAL_ROUND_MIAP_RULES_SIZE  1
  2593. +  SPH_TweakRule  NORMAL_ROUND_MIAP_Rules
  2594. +                   [NORMAL_ROUND_MIAP_RULES_SIZE] =
  2595. +                 {
  2596. +                   { "-", 0, "", 0 },
  2597. +                 };
  2598. +
  2599. +#define NORMAL_ROUND_MDRP_RULES_SIZE  1
  2600. +  SPH_TweakRule  NORMAL_ROUND_MDRP_Rules
  2601. +                   [NORMAL_ROUND_MDRP_RULES_SIZE] =
  2602. +                 {
  2603. +                   { "-", 0, "", 0 },
  2604. +                 };
  2605. +
  2606. +#define NORMAL_ROUND_MDAP_RULES_SIZE  1
  2607. +  SPH_TweakRule  NORMAL_ROUND_MDAP_Rules
  2608. +                   [NORMAL_ROUND_MDAP_RULES_SIZE] =
  2609. +                 {
  2610. +                   { "-", 0, "", 0 },
  2611. +                 };
  2612. +
  2613. +  /* indicate that SHPIX needs to match a touched point on x OR y */
  2614. +#define SHPIX_EITHER_TOUCHED_RULES_SIZE  1
  2615. +  SPH_TweakRule  SHPIX_EITHER_TOUCHED_Rules
  2616. +                   [SHPIX_EITHER_TOUCHED_RULES_SIZE] =
  2617. +                 {
  2618. +                   { "-", 0, "", 0 },
  2619. +                 };
  2620. +
  2621. +  /* mystery rules that make SHPIX work on certain fonts/glyphs;       */
  2622. +  /* indicates that SHPIX needs to match a touched point on x AND y -- */
  2623. +  /* this is dirty and needs to be generalized and incorporated        */
  2624. +#define SHPIX_EITHER_TOUCHED_RULES_EXCEPTIONS_SIZE  1
  2625. +  SPH_TweakRule  SHPIX_EITHER_TOUCHED_Rules_Exceptions
  2626. +                   [SHPIX_EITHER_TOUCHED_RULES_EXCEPTIONS_SIZE] =
  2627. +                 {
  2628. +                   { "-", 0, "", 0 },
  2629. +                 };
  2630. +
  2631. +#define ALLOW_DMOVEX_FREEV_RULES_EXCEPTIONS_SIZE  1
  2632. +  SPH_TweakRule  ALLOW_DMOVEX_FREEV_Rules_Exceptions
  2633. +                   [ALLOW_DMOVEX_FREEV_RULES_EXCEPTIONS_SIZE] =
  2634. +                 {
  2635. +                   { "-", 0, "", 0 },
  2636. +                 };
  2637. +
  2638. +#define ALLOW_DMOVE_FREEV_RULES_EXCEPTIONS_SIZE  1
  2639. +  SPH_TweakRule  ALLOW_DMOVE_FREEV_Rules_Exceptions
  2640. +                   [ALLOW_DMOVE_FREEV_RULES_EXCEPTIONS_SIZE] =
  2641. +                 {
  2642. +                   { "-", 0, "", 0 },
  2643. +                 };
  2644. +
  2645. +#define ALLOW_MOVEZP2_FREEV_RULES_EXCEPTIONS_SIZE  1
  2646. +  SPH_TweakRule  ALLOW_MOVEZP2_FREEV_Rules_Exceptions
  2647. +                   [ALLOW_MOVEZP2_FREEV_RULES_EXCEPTIONS_SIZE] =
  2648. +                 {
  2649. +                   { "-", 0, "", 0 },
  2650. +                 };
  2651. +
  2652. +  /* skip IUP instructions if matched */
  2653. +#define SKIP_IUP_RULES_SIZE  1
  2654. +  SPH_TweakRule  SKIP_IUP_Rules
  2655. +                   [SKIP_IUP_RULES_SIZE] =
  2656. +                 {
  2657. +                   { "-", 0, "", 0 },
  2658. +                 };
  2659. +
  2660. +  /* skip DELTAP instructions if matched */
  2661. +#define ALWAYS_SKIP_DELTAP_RULES_SIZE  1
  2662. +  SPH_TweakRule  ALWAYS_SKIP_DELTAP_Rules
  2663. +                   [ALWAYS_SKIP_DELTAP_RULES_SIZE] =
  2664. +                 {
  2665. +                   { "-", 0, "", 0 },
  2666. +                 };
  2667. +
  2668. +  /* always do DELTAP instructions if matched */
  2669. +#define ALWAYS_DO_DELTAP_RULES_SIZE  1
  2670. +  SPH_TweakRule  ALWAYS_DO_DELTAP_Rules
  2671. +                   [ALWAYS_DO_DELTAP_RULES_SIZE] =
  2672. +                 {
  2673. +                   { "-", 0, "", 0 },
  2674. +                 };
  2675. +
  2676. +  /* do an extra RTG instruction in DELTAP if matched */
  2677. +#define DELTAP_RTG_RULES_SIZE  1
  2678. +  SPH_TweakRule  DELTAP_RTG_Rules
  2679. +                   [DELTAP_RTG_RULES_SIZE] =
  2680. +                 {
  2681. +                   { "-", 0, "", 0 },
  2682. +                 };
  2683. +
  2684. +  /* do an extra RUTG instruction in DELTAP if matched */
  2685. +#define DELTAP_SKIP_EXAGGERATED_VALUES_RULES_SIZE  1
  2686. +  SPH_TweakRule  DELTAP_SKIP_EXAGGERATED_VALUES_Rules
  2687. +                   [DELTAP_SKIP_EXAGGERATED_VALUES_RULES_SIZE] =
  2688. +                 {
  2689. +                   { "-", 0, "", 0 },
  2690. +                 };
  2691. +
  2692. +  /* do an extra RDTG instruction in DELTAP if matched */
  2693. +#define DELTAP_RDTG_RULES_SIZE 1
  2694. +  SPH_TweakRule  DELTAP_RDTG_Rules
  2695. +                   [DELTAP_RDTG_RULES_SIZE] =
  2696. +                 {
  2697. +                   { "-", 0, "", 0 },
  2698. +                 };
  2699. +
  2700. +  /* return MS rasterizer version 35 if matched */
  2701. +#define RASTERIZER_35_RULES_SIZE 1
  2702. +  SPH_TweakRule  RASTERIZER_35_Rules
  2703. +                   [RASTERIZER_35_RULES_SIZE] =
  2704. +                 {
  2705. +                   { "-", 0, "", 0 },
  2706. +                 };
  2707. +
  2708. +
  2709. +#endif /* 1 */
  2710. +
  2711. +
  2712. +#else /* TT_CONFIG_OPTION_SUBPIXEL_HINTING_ADDITIONAL_TWEAKS */
  2713. +
  2714. +
  2715. +  /*************************************************************************/
  2716. +  /*                                                                       */
  2717. +  /* TT_CONFIG_OPTION_SUBPIXEL_HINTING_ADDITIONAL_TWEAKS Rules             */
  2718. +  /*                                                                       */
  2719. +  /* This set of rules is an attempt at enhancing the basic subpixel rules */
  2720. +  /* defined above, to fix visual problems with individual fonts and       */
  2721. +  /* glyphs.                                                               */
  2722. +  /*                                                                       */
  2723. +  /* This mode is enabled if                                               */
  2724. +  /* TT_CONFIG_OPTION_SUBPIXEL_HINTING_ADDITIONAL_TWEAKS                   */
  2725. +  /* is defined                                                            */
  2726. +  /*                                                                       */
  2727. +  /*     ****************** WORK IN PROGRESS *******************           */
  2728. +  /*                                                                       */
  2729. +
  2730. +#define SPH_OPTION_BITMAP_WIDTHS           FALSE
  2731. +#define SPH_OPTION_SET_SUBPIXEL            TRUE
  2732. +#define SPH_OPTION_SET_GRAYSCALE           FALSE
  2733. +#define SPH_OPTION_SET_COMPATIBLE_WIDTHS   FALSE
  2734. +#define SPH_OPTION_SET_RASTERIZER_VERSION  37
  2735. +#define SPH_OPTION_GRIDS_PER_PIXEL_X       64
  2736. +#define SPH_OPTION_GRIDS_PER_PIXEL_Y       1
  2737. +
  2738. +  /* don't do subpixel hinting; do normal hinting */
  2739. +#define PIXEL_HINTING_RULES_SIZE  9
  2740. +  SPH_TweakRule  PIXEL_HINTING_Rules
  2741. +                   [PIXEL_HINTING_RULES_SIZE] =
  2742. +                 {
  2743. +                   { "-", 0, "", 0 },
  2744. +                   { "Courier New", 0, "", '<' },
  2745. +                   { "Courier New", 0, "", '>' },
  2746. +                   { "Verdana", 0, "", '<' },
  2747. +                   { "Verdana", 0, "", '>' },
  2748. +                   { "Trebuchet MS", 0, "Regular", '<' },
  2749. +                   { "Trebuchet MS", 0, "Regular", '>' },
  2750. +                   { "Tahoma", 0, "Bold", '<' },
  2751. +                   { "Tahoma", 0, "Bold", '>' },
  2752. +                 };
  2753. +
  2754. +
  2755. +  /* don't avoid RS Rules (as the basic subpixel hinting does) */
  2756. +#define DO_RS_RULES_SIZE  1
  2757. +  SPH_TweakRule  DO_RS_Rules
  2758. +                   [DO_RS_RULES_SIZE] =
  2759. +                 {
  2760. +                   { "-", 0, "", 0 },
  2761. +                 };
  2762. +
  2763. +
  2764. +  /******************* DELTA RULES *********************/
  2765. +
  2766. +  /* Do requested SHPIX operations if matched.  This requires ZP2 moves */
  2767. +  /* to be enabled in order to get SHPIX moves in the X direction.  Do  */
  2768. +  /* all `Optimized for ClearType' fonts need to be here?               */
  2769. +  /* The line below doesn't work because the bit is not set in MS       */
  2770. +  /* ClearType fonts.                                                   */
  2771. +  /*                                                                    */
  2772. +  /*   CUR.face->header.Flags & 0x10000                                 */
  2773. +
  2774. +#define SKIP_INLINE_DELTAS_RULES_SIZE  1
  2775. +  SPH_TweakRule  SKIP_INLINE_DELTAS_Rules
  2776. +                   [SKIP_INLINE_DELTAS_RULES_SIZE] =
  2777. +                 {
  2778. +                   { "-", 0, "", 0 },
  2779. +                 };
  2780. +
  2781. +#define DO_SHPIX_RULES_SIZE  5
  2782. +  SPH_TweakRule  DO_SHPIX_Rules
  2783. +                   [DO_SHPIX_RULES_SIZE] =
  2784. +                 {
  2785. +                   { "Verdana", 13, "Regular", 0 },
  2786. +                   { "Verdana", 9, "Regular", '4' },
  2787. +                   { "Verdana", 10, "Regular", '4' },
  2788. +                   { "Verdana", 18, "Regular", '4' },
  2789. +                   { "Segoe UI", 0, "", 0 },
  2790. +                 };
  2791. +
  2792. +  /* Default is that SHPIX needs to match a touched point on x AND y */
  2793. +  /* This indicates that SHPIX needs to match a touched point on x OR y */
  2794. +#define SHPIX_EITHER_TOUCHED_RULES_SIZE  23
  2795. +  SPH_TweakRule  SHPIX_EITHER_TOUCHED_Rules
  2796. +                   [SHPIX_EITHER_TOUCHED_RULES_SIZE] =
  2797. +                 {
  2798. +                   { "", 0, "", 'e' },
  2799. +                   { "Arial", 0, "", 'c' },
  2800. +                   { "Arial", 0, "Bold", '0' },
  2801. +                   { "Arial", 0, "Bold", '1' },
  2802. +                   { "Arial", 0, "Bold", '2' },
  2803. +                   { "Arial", 0, "Bold", '3' },
  2804. +                   { "Arial", 0, "Bold", '4' },
  2805. +                   { "Arial", 0, "Bold", '5' },
  2806. +                   { "Arial", 0, "Bold", '6' },
  2807. +                   { "Arial", 0, "Bold", '7' },
  2808. +                   { "Arial", 0, "Bold", '8' },
  2809. +                   { "Arial", 0, "Bold", '9' },
  2810. +                   { "Arial", 0, "Regular", 0 },
  2811. +                   { "Consolas", 0, "", 0 },
  2812. +                   { "Courier New", 0, "", 0 },
  2813. +                   { "Georgia", 0, "", 'i' },
  2814. +                   { "Lucida Grande", 0, "Regular", 0 },
  2815. +                   { "Paltino Linotype", 0, "", 0 },
  2816. +                   { "Tahoma", 0, "Regular", 0 },
  2817. +                   { "Times New Roman", 0, "Bold", 'a' },
  2818. +                   { "Times New Roman", 16, "Regular", 'u' },
  2819. +                   { "Trebuchet MS", 0, "", 0 },
  2820. +                   { "Verdana", 0, "", 0 },
  2821. +                 };
  2822. +
  2823. +#define SHPIX_EITHER_TOUCHED_RULES_EXCEPTIONS_SIZE  5
  2824. +  SPH_TweakRule  SHPIX_EITHER_TOUCHED_Rules_Exceptions
  2825. +                   [SHPIX_EITHER_TOUCHED_RULES_EXCEPTIONS_SIZE] =
  2826. +                 {
  2827. +                   { "Arial", 11, "Regular", 's' },
  2828. +                   { "Arial", 0, "Regular", 'c' },
  2829. +                   { "Consolas", 12, "", 0 },
  2830. +                   { "Consolas", 13, "", 0 },
  2831. +                   { "Consolas", 14, "", 0 },
  2832. +                 };
  2833. +
  2834. +  /* skip moves that don't move a point to a pixel boundary in various functions;   */
  2835. +  /* this fixes Tahoma, Trebuchet oddities and some issues with `$' */
  2836. +#define SKIP_NONPIXEL_INLINE_MOVES_RULES_SIZE  4
  2837. +  SPH_TweakRule  SKIP_NONPIXEL_INLINE_MOVES_Rules
  2838. +                   [SKIP_NONPIXEL_INLINE_MOVES_RULES_SIZE] =
  2839. +                 {
  2840. +                   { "", 0, "Regular", 0 },
  2841. +                   { "Courier New", 0, "Bold", 'w' },
  2842. +                   { "DejaVu Sans", 0, "Book", 'N' },
  2843. +                   { "Bitstream Vera Sans", 0, "Roman", 'N' },
  2844. +                 };
  2845. +
  2846. +
  2847. +#define SKIP_NONPIXEL_INLINE_MOVES_RULES_EXCEPTIONS_SIZE  8
  2848. +  SPH_TweakRule  SKIP_NONPIXEL_INLINE_MOVES_Rules_Exceptions
  2849. +                   [SKIP_NONPIXEL_INLINE_MOVES_RULES_EXCEPTIONS_SIZE] =
  2850. +                 {
  2851. +                   { "Droid Serif", 0, "", 0 },
  2852. +                   { "Droid Sans", 0, "Bold", 0 },
  2853. +                   { "Droid Sans Mono", 0, "Bold", 0 },
  2854. +                   { "Droid Sans", 0, "Bold Italic", 0 },
  2855. +                   { "Droid Sans Mono", 0, "Bold Italic", 0 },
  2856. +                   { "Courier New", 0, "Regular", '2' },
  2857. +                   { "Essential PragmataPro", 0, "", 0 },
  2858. +                   { "Geneva", 0, "", 0 },
  2859. +                 };
  2860. +
  2861. +
  2862. +  /* round moves that don't move a point to a pixel boundary in various functions;   */
  2863. +#define ROUND_NONPIXEL_INLINE_MOVES_RULES_SIZE  3
  2864. +  SPH_TweakRule  ROUND_NONPIXEL_INLINE_MOVES_Rules
  2865. +                   [ROUND_NONPIXEL_INLINE_MOVES_RULES_SIZE] =
  2866. +                 {
  2867. +                   { "-", 0, "Regular", 0 },
  2868. +                   { "Droid Sans", 0, "", 0 },
  2869. +                   { "Droid Sans Mono", 0, "", 0 },
  2870. +
  2871. +                };
  2872. +
  2873. +#define ROUND_NONPIXEL_INLINE_MOVES_RULES_EXCEPTIONS_SIZE  3
  2874. +  SPH_TweakRule  ROUND_NONPIXEL_INLINE_MOVES_Rules_Exceptions
  2875. +                   [ROUND_NONPIXEL_INLINE_MOVES_RULES_EXCEPTIONS_SIZE] =
  2876. +                 {
  2877. +                   { "Droid Sans", 12, "Bold", 0 },
  2878. +                   { "Droid Sans", 13, "Bold", 0 },
  2879. +                   { "Droid Sans", 16, "Bold", 0 },
  2880. +                 };
  2881. +
  2882. +
  2883. +  /********** MOVE RULES *************/
  2884. +
  2885. +  /* allow a Direct_Move_X along X freedom vector if matched */
  2886. +#define ALLOW_DMOVEX_FREEV_RULES_SIZE  7
  2887. +  SPH_TweakRule  ALLOW_DMOVEX_FREEV_Rules
  2888. +                   [ALLOW_DMOVEX_FREEV_RULES_SIZE] =
  2889. +                 {
  2890. +                   { "Arial Narrow", 0, "Regular", 0 },
  2891. +                   { "Arial", 13, "Regular", 0 },
  2892. +                   { "Arial", 14, "Regular", 0 },
  2893. +                   { "Verdana", 13, "Regular", 0 },
  2894. +                   { "Verdana", 9, "Regular", '4' },
  2895. +                   { "Verdana", 10, "Regular", '4' },
  2896. +                   { "Verdana", 18, "Regular", '4' },
  2897. +                 };
  2898. +
  2899. +  /* allow a Direct_Move along X freedom vector if matched */
  2900. +#define ALLOW_DMOVE_FREEV_RULES_SIZE  7
  2901. +  SPH_TweakRule  ALLOW_DMOVE_FREEV_Rules
  2902. +                   [ALLOW_DMOVE_FREEV_RULES_SIZE] =
  2903. +                 {
  2904. +                   { "Arial Narrow", 0, "Regular", 0 },
  2905. +                   { "Arial", 13, "Regular", 0 },
  2906. +                   { "Arial", 14, "Regular", 0 },
  2907. +                   { "Verdana", 13, "Regular", 0 },
  2908. +                   { "Verdana", 9, "Regular", '4' },
  2909. +                   { "Verdana", 10, "Regular", '4' },
  2910. +                   { "Verdana", 18, "Regular", '4' },
  2911. +                 };
  2912. +
  2913. +#define ALLOW_DMOVEX_FREEV_RULES_EXCEPTIONS_SIZE  3
  2914. +  SPH_TweakRule  ALLOW_DMOVEX_FREEV_Rules_Exceptions
  2915. +                   [ALLOW_DMOVEX_FREEV_RULES_EXCEPTIONS_SIZE] =
  2916. +                 {
  2917. +                   { "Arial", 0, "Regular", '4' },
  2918. +                   { "Arial", 0, "Regular", 's' },
  2919. +                   { "Arial", 0, "Regular", '^' },
  2920. +                 };
  2921. +
  2922. +#define ALLOW_DMOVE_FREEV_RULES_EXCEPTIONS_SIZE  3
  2923. +  SPH_TweakRule  ALLOW_DMOVE_FREEV_Rules_Exceptions
  2924. +                   [ALLOW_DMOVE_FREEV_RULES_EXCEPTIONS_SIZE] =
  2925. +                 {
  2926. +                   { "Arial", 0, "Regular", '4' },
  2927. +                   { "Arial", 0, "Regular", 's' },
  2928. +                   { "Arial", 0, "Regular", '^' },
  2929. +                 };
  2930. +
  2931. +
  2932. +  /* allow a ZP2 move along freedom vector if matched; */
  2933. +  /* this is called from SHP, SHPIX, SHC, SHZ          */
  2934. +#define ALLOW_MOVEZP2_FREEV_RULES_SIZE  6
  2935. +  SPH_TweakRule  ALLOW_MOVEZP2_FREEV_Rules
  2936. +                   [ALLOW_MOVEZP2_FREEV_RULES_SIZE] =
  2937. +                 {
  2938. +                   { "Arial", 13, "Regular", 0 },
  2939. +                   { "Arial", 14, "Regular", 0 },
  2940. +                   { "Verdana", 13, "Regular", 0 },
  2941. +                   { "Verdana", 9, "Regular", '4' },
  2942. +                   { "Verdana", 10, "Regular", '4' },
  2943. +                   { "Verdana", 18, "Regular", '4' },
  2944. +                   /* this needs a bit of work though */
  2945. +                   /*{ "Microsoft Sans Serif", 0, "Regular", 0 },*/
  2946. +                 };
  2947. +
  2948. +  /* return MS rasterizer version 35 if matched */
  2949. +#define RASTERIZER_35_RULES_SIZE 25
  2950. +  SPH_TweakRule  RASTERIZER_35_Rules
  2951. +                   [RASTERIZER_35_RULES_SIZE] =
  2952. +                 {
  2953. +                   { "Apple Chancery", 0, "", 0 },
  2954. +                   { "Century", 0, "", 0 },
  2955. +                   { "Chalkboard", 0, "", 0 },
  2956. +                   { "Frutiger Linotype", 0, "", 0 },
  2957. +                   { "Geneva CY", 0, "", 0 },
  2958. +                   { "Gill Sans", 0, "", 0 },
  2959. +                   { "Hard Gothic", 0, "", 0 },
  2960. +                   { "Herculanum", 0, "", 0 },
  2961. +                   { "Hoefler Text", 0, "", 0 },
  2962. +                   { "Lobster", 0, "", 0 },
  2963. +                   { "Marker Felt", 0, "", 0 },
  2964. +                   { "Neuton", 0, "", 0 },
  2965. +                   { "Pragmata", 0, "", 0 },
  2966. +                   { "Reenie Beanie", 0, "", 0 },
  2967. +                   { "Skia", 0, "", 0 },
  2968. +                   { "Sylfaen", 0, "", 0 },
  2969. +                   { "Tangerine", 0, "", 0 },
  2970. +                   { "Times New Roman", 0, "Regular", 'i' },
  2971. +                   { "Times New Roman", 0, "Regular", 'j' },
  2972. +                   { "Times New Roman", 0, "Regular", 'm' },
  2973. +                   { "Times New Roman", 0, "Regular", 'r' },
  2974. +                   { "Times", 0, "", 0 },
  2975. +                   { "Vollkorn", 0, "", 0 },
  2976. +                   { "Yanone Kaffeesatz", 0, "", 0 },
  2977. +                   { "Zapfino", 0, "", 0 },
  2978. +                 };
  2979. +
  2980. +  /************** DIRTY, DIRTY HACKS! ***************/
  2981. +
  2982. +#define ALLOW_MOVEZP2_FREEV_RULES_EXCEPTIONS_SIZE  8
  2983. +  SPH_TweakRule  ALLOW_MOVEZP2_FREEV_Rules_Exceptions
  2984. +                   [ALLOW_MOVEZP2_FREEV_RULES_EXCEPTIONS_SIZE] =
  2985. +                 {
  2986. +                   { "Times New Roman", 0, "Regular", 'a' },
  2987. +                   { "Verdana", 13, "Regular", 'N' },
  2988. +                   { "Verdana", 13, "Regular", 'f' },
  2989. +                   { "Verdana", 13, "Regular", 'v' },
  2990. +                   { "Verdana", 13, "Regular", 'w' },
  2991. +                   { "Verdana", 13, "Regular", 'x' },
  2992. +                   { "Verdana", 13, "Regular", 'y' },
  2993. +                   { "Verdana", 13, "Regular", 'z' },
  2994. +                 };
  2995. +
  2996. +  /*********** ROUNDING ***************/
  2997. +
  2998. +  /* these only have an effect on fonts that are allowed to move X */
  2999. +  /* (see above); it appears that all MS ClearType fonts may be OK */
  3000. +  /* using normal rounds                                           */
  3001. +#define NORMAL_ROUND_MIRP_RULES_SIZE  4
  3002. +  SPH_TweakRule  NORMAL_ROUND_MIRP_Rules
  3003. +                   [NORMAL_ROUND_MIRP_RULES_SIZE] =
  3004. +                 {
  3005. +                   { "Calibri", 0, "Bold Italic", 0 },
  3006. +                   { "Calibri", 0, "Italic", 0 },
  3007. +                   { "Courier New", 0, "", 0 },
  3008. +                   { "Verdana", 10, "Regular", '4' },
  3009. +                 };
  3010. +
  3011. +#define NORMAL_ROUND_MIAP_RULES_SIZE  4
  3012. +  SPH_TweakRule  NORMAL_ROUND_MIAP_Rules
  3013. +                   [NORMAL_ROUND_MIAP_RULES_SIZE] =
  3014. +                 {
  3015. +                   { "Calibri", 0, "Bold Italic", 0 },
  3016. +                   { "Calibri", 0, "Italic", 0 },
  3017. +                   { "Courier New", 0, "", 0 },
  3018. +                   { "Verdana", 10, "Regular", '4' },
  3019. +                 };
  3020. +
  3021. +#define NORMAL_ROUND_MDRP_RULES_SIZE  4
  3022. +  SPH_TweakRule  NORMAL_ROUND_MDRP_Rules
  3023. +                   [NORMAL_ROUND_MDRP_RULES_SIZE] =
  3024. +                 {
  3025. +                   { "Calibri", 0, "Bold Italic", 0 },
  3026. +                   { "Calibri", 0, "Italic", 0 },
  3027. +                   { "Courier New", 0, "", 0 },
  3028. +                   { "Verdana", 10, "Regular", '4' },
  3029. +                 };
  3030. +
  3031. +#define NORMAL_ROUND_MDAP_RULES_SIZE  4
  3032. +  SPH_TweakRule  NORMAL_ROUND_MDAP_Rules
  3033. +                   [NORMAL_ROUND_MDAP_RULES_SIZE] =
  3034. +                 {
  3035. +                   { "Calibri", 0, "Bold Italic", 0 },
  3036. +                   { "Calibri", 0, "Italic", 0 },
  3037. +                   { "Courier New", 0, "", 0 },
  3038. +                   { "Verdana", 10, "Regular", '4' },
  3039. +                 };
  3040. +
  3041. +
  3042. +  /* skip IUP instructions if matched */
  3043. +#define SKIP_IUP_RULES_SIZE  1
  3044. +  SPH_TweakRule  SKIP_IUP_Rules
  3045. +                   [SKIP_IUP_RULES_SIZE] =
  3046. +                 {
  3047. +                   { "Arial", 13, "Regular", 'a' },
  3048. +                 };
  3049. +
  3050. +  /* skip DELTAP instructions if matched */
  3051. +#define ALWAYS_SKIP_DELTAP_RULES_SIZE  11
  3052. +  SPH_TweakRule  ALWAYS_SKIP_DELTAP_Rules
  3053. +                   [ALWAYS_SKIP_DELTAP_RULES_SIZE] =
  3054. +                 {
  3055. +                   { "Georgia", 0, "Regular", '7' },
  3056. +                   { "Georgia", 0, "Regular", 'A' },
  3057. +                   { "Georgia", 0, "Regular", 'N' },
  3058. +                   { "Georgia", 0, "Regular", 'V' },
  3059. +                   { "Georgia", 0, "Regular", 'W' },
  3060. +                   { "Georgia", 0, "Regular", 'X' },
  3061. +                   { "Georgia", 0, "Regular", 'Y' },
  3062. +                   { "Georgia", 0, "Regular", 'k' },
  3063. +                   { "Trebuchet MS", 0, "Italic", 0 },
  3064. +                   { "Trebuchet MS", 14, "Regular", 'e' },
  3065. +                   { "Verdana", 10, "Regular", 0 },
  3066. +                 };
  3067. +
  3068. +  /* always do DELTAP instructions if matched */
  3069. +#define ALWAYS_DO_DELTAP_RULES_SIZE  8
  3070. +  SPH_TweakRule  ALWAYS_DO_DELTAP_Rules
  3071. +                   [ALWAYS_DO_DELTAP_RULES_SIZE] =
  3072. +                 {
  3073. +                   { "Bitstream Vera Sans", 14, "Roman", 'K' },
  3074. +                   { "Bitstream Vera Sans", 14, "Roman", 'k' },
  3075. +                   { "Bitstream Vera Sans", 17, "Roman", 'K' },
  3076. +                   { "Bitstream Vera Sans", 17, "Roman", 'k' },
  3077. +                   { "DejaVu Sans", 14, "Book", 'K' },
  3078. +                   { "DejaVu Sans", 14, "Book", 'k' },
  3079. +                   { "DejaVu Sans", 17, "Book", 'K' },
  3080. +                   { "DejaVu Sans", 17, "Book", 'k' },
  3081. +
  3082. +                 };
  3083. +
  3084. +  /* do an extra RTG instruction in DELTAP if matched */
  3085. +#define DELTAP_RTG_RULES_SIZE  1
  3086. +  SPH_TweakRule  DELTAP_RTG_Rules
  3087. +                   [DELTAP_RTG_RULES_SIZE] =
  3088. +                 {
  3089. +                   { "-", 0, "", 0 },
  3090. +                 };
  3091. +
  3092. +  /* do an extra RUTG instruction in DELTAP if matched */
  3093. +#define DELTAP_SKIP_EXAGGERATED_VALUES_RULES_SIZE  3
  3094. +  SPH_TweakRule  DELTAP_SKIP_EXAGGERATED_VALUES_Rules
  3095. +                   [DELTAP_SKIP_EXAGGERATED_VALUES_RULES_SIZE] =
  3096. +                 {
  3097. +                   { "Arial", 24, "Bold", 's' },
  3098. +                   { "Arial", 25, "Bold", 's' },
  3099. +                   { "--Arial", 0, "Bold", 0 },
  3100. +                 };
  3101. +
  3102. +
  3103. +#define NO_ALIGNRP_AFTER_IUP_RULES_SIZE  4
  3104. +  SPH_TweakRule  NO_ALIGNRP_AFTER_IUP_Rules
  3105. +                   [NO_ALIGNRP_AFTER_IUP_RULES_SIZE] =
  3106. +                 {
  3107. +                   { "Courier New", 0, "Bold", 'C' },
  3108. +                   { "Courier New", 0, "Bold", 'D' },
  3109. +                   { "Courier New", 0, "Bold", 'Q' },
  3110. +                   { "Courier New", 0, "Bold", '0' },
  3111. +                 };
  3112. +
  3113. +
  3114. +#define NO_CALL_AFTER_IUP_RULES_SIZE  3
  3115. +  SPH_TweakRule  NO_CALL_AFTER_IUP_Rules
  3116. +                   [NO_CALL_AFTER_IUP_RULES_SIZE] =
  3117. +                 {
  3118. +                   { "Courier New", 0, "Bold", 'O' },
  3119. +                   { "Courier New", 0, "Bold", 'Q' },
  3120. +                   { "Courier New", 0, "Bold", 'k' },
  3121. +                 };
  3122. +
  3123. +
  3124. +#define DEEMBOLDEN_RULES_SIZE  9
  3125. +  SPH_TweakRule  DEEMBOLDEN_Rules
  3126. +                   [DEEMBOLDEN_RULES_SIZE] =
  3127. +                 {
  3128. +                   { "Courier New", 0, "Bold", 'A' },
  3129. +                   { "Courier New", 0, "Bold", 'W' },
  3130. +                   { "Courier New", 0, "Bold", 'w' },
  3131. +                   { "Courier New", 0, "Bold", 'M' },
  3132. +                   { "Courier New", 0, "Bold", 'X' },
  3133. +                   { "Courier New", 0, "Bold", 'K' },
  3134. +                   { "Courier New", 0, "Bold", 'x' },
  3135. +                   { "Courier New", 0, "Bold", 'z' },
  3136. +                   { "Courier New", 0, "Bold", 'v' },
  3137. +                 };
  3138. +
  3139. +#define EMBOLDEN_RULES_SIZE  3
  3140. +  SPH_TweakRule  EMBOLDEN_Rules
  3141. +                   [EMBOLDEN_RULES_SIZE] =
  3142. +                 {
  3143. +                   { "Courier New", 12, "Italic", 'z' },
  3144. +                   { "Courier New", 11, "Italic", 'z' },
  3145. +                   { "Courier New", 10, "Italic", 'z' },
  3146. +                 };
  3147. +
  3148. +  /* do an extra RDTG instruction in DELTAP if matched */
  3149. +#define DELTAP_RDTG_RULES_SIZE 24
  3150. +  SPH_TweakRule  DELTAP_RDTG_Rules
  3151. +                   [DELTAP_RDTG_RULES_SIZE] =
  3152. +                 {
  3153. +                   { "Calibri", 0, "Italic", 0 },
  3154. +                   { "Comic Sans MS", 0, "Regular", 0 },
  3155. +                   { "Courier New", 0, "Regular", '2' },
  3156. +                   { "Lucida Grande", 0, "Regular", 'e' },
  3157. +                   { "Lucida Grande", 12, "Bold", 0 },
  3158. +                   { "Microsoft Sans Serif", 0, "Regular", '7' },
  3159. +                   { "Microsoft Sans Serif", 0, "Regular", 'O' },
  3160. +                   { "Microsoft Sans Serif", 0, "Regular", 'Q' },
  3161. +                   { "Microsoft Sans Serif", 0, "Regular", 'X' },
  3162. +                   { "Microsoft Sans Serif", 0, "Regular", 'e' },
  3163. +                   { "Microsoft Sans Serif", 0, "Regular", 'o' },
  3164. +                   { "Tahoma", 0, "Bold", '0' },
  3165. +                   { "Tahoma", 16, "Bold Italic", 'C' },
  3166. +                   { "Tahoma", 16, "Bold", 'C' },
  3167. +                   { "Trebuchet MS", 0, "", '0' },
  3168. +                   { "Trebuchet MS", 14, "Regular", 'e' },
  3169. +                   { "Verdana", 0, "", '0' },
  3170. +                   { "Verdana", 0, "Bold Italic", '7' },
  3171. +                   { "Verdana", 0, "Bold Italic", 'v' },
  3172. +                   { "Verdana", 0, "Bold Italic", 'w' },
  3173. +                   { "Verdana", 0, "Bold", 0 },
  3174. +                   { "Verdana", 0, "Italic", 'o' },
  3175. +                   { "Verdana", 0, "Regular", 'x' },
  3176. +                   { "Verdana", 10, "Regular", 'w' },
  3177. +                 };
  3178. +
  3179. +
  3180. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING_ADDITIONAL_TWEAKS */
  3181. +#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
  3182. +
  3183. +#endif /* __TTSUBPIX_H__ */
  3184. +
  3185. +
  3186. +/* END */
Advertisement
Add Comment
Please, Sign In to add comment