Commit ed6508c41a23831ae173accb5b124da0b6cc3f6d

Infinality 2012-06-26T17:20:27

[truetype] Remove unused rounding functionality.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
diff --git a/ChangeLog b/ChangeLog
index 6228ae8..a213a5d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2012-06-26  Infinality  <infinality@infinality.net>
+
+	[truetype] Remove unused rounding functionality.
+
+	The subpixel hinting patch contained the concept of an adjustable
+	number of gridlines per pixel.  This is no longer used due to x
+	being completely ignored instead.  This will return some of the
+	code to its existing state prior to the original Infinality
+	commit.
+
+	* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
+	FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): Removed.
+
+	* src/truetype/ttinterp.c: Updated.
+	(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
+	Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
+	SetSuperRound): Remove parameter to handle the number of grid lines per
+	pixel.
+	(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
+	(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
+	(DO_ROUND, DO_NROUND): Updated.
+	(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
+	Ins_MDRP, Ins_MIRP): Perform Round_None instead of calling a modified
+	rounding function.  Remove gridlines_per_pixel.  Create a local
+	variable to store control value cutin. Simplify the conditional for 
+	ignore_x_mode.  Adjust rounding calls to pass only two values.
+
 2012-06-25  Werner Lemberg  <wl@gnu.org>
 
 	[cff] Fix Savannah bug #36705.
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index d4da5da..eee3d24 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -81,14 +81,6 @@ FT_BEGIN_HEADER
 #define FT_PIX_ROUND( x )     FT_PIX_FLOOR( (x) + 32 )
 #define FT_PIX_CEIL( x )      FT_PIX_FLOOR( (x) + 63 )
 
-  /*
-   *  These are used in ttinterp.c for subpixel hinting with an
-   *  adjustable grids-per-pixel value.
-   */
-#define FT_PIX_FLOOR_GRID( x, n )  ( (x) & ~( 64 / (n) - 1 ) )
-#define FT_PIX_ROUND_GRID( x, n )  FT_PIX_FLOOR_GRID( (x) + 32 / (n), (n) )
-#define FT_PIX_CEIL_GRID( x, n )   FT_PIX_FLOOR_GRID( (x) + 63 / (n), (n) )
-
 
   /*
    *  Return the highest power of 2 that is <= value; this correspond to
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index bba2853..46ffc51 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -156,11 +156,11 @@
 #define NORMalize( x, y, v ) \
           Normalize( EXEC_ARG_ x, y, v )
 
-#define SET_SuperRound( scale, flags, res ) \
-          SetSuperRound( EXEC_ARG_ scale, flags, res )
+#define SET_SuperRound( scale, flags ) \
+          SetSuperRound( EXEC_ARG_ scale, flags )
 
-#define ROUND_None( d, c, e ) \
-          Round_None( EXEC_ARG_ d, c, e )
+#define ROUND_None( d, c ) \
+          Round_None( EXEC_ARG_ d, c )
 
 #define INS_Goto_CodeRange( range, ip ) \
           Ins_Goto_CodeRange( EXEC_ARG_ range, ip )
@@ -171,8 +171,8 @@
 #define CUR_Func_move_orig( z, p, d ) \
           CUR.func_move_orig( EXEC_ARG_ z, p, d )
 
-#define CUR_Func_round( d, c, e ) \
-          CUR.func_round( EXEC_ARG_ d, c, e )
+#define CUR_Func_round( d, c ) \
+          CUR.func_round( EXEC_ARG_ d, c )
 
 #define CUR_Func_read_cvt( index ) \
           CUR.func_read_cvt( EXEC_ARG_ index )
@@ -2005,8 +2005,6 @@
   /*                                                                       */
   /*    compensation :: The engine compensation.                           */
   /*                                                                       */
-  /*    resolution   :: The number of grid lines per pixel.                */
-  /*                                                                       */
   /* <Return>                                                              */
   /*    The compensated distance.                                          */
   /*                                                                       */
@@ -2018,13 +2016,11 @@
   /*                                                                       */
   static FT_F26Dot6
   Round_None( EXEC_OP_ FT_F26Dot6  distance,
-                       FT_F26Dot6  compensation,
-                       FT_Int      resolution )
+                       FT_F26Dot6  compensation )
   {
     FT_F26Dot6  val;
 
     FT_UNUSED_EXEC;
-    FT_UNUSED( resolution );
 
 
     if ( distance >= 0 )
@@ -2039,7 +2035,6 @@
       if ( val > 0 )
         val = 0;
     }
-
     return val;
   }
 
@@ -2057,15 +2052,12 @@
   /*                                                                       */
   /*    compensation :: The engine compensation.                           */
   /*                                                                       */
-  /*    resolution   :: The number of grid lines per pixel.                */
-  /*                                                                       */
   /* <Return>                                                              */
   /*    Rounded distance.                                                  */
   /*                                                                       */
   static FT_F26Dot6
   Round_To_Grid( EXEC_OP_ FT_F26Dot6  distance,
-                          FT_F26Dot6  compensation,
-                          FT_Int      resolution )
+                          FT_F26Dot6  compensation )
   {
     FT_F26Dot6  val;
 
@@ -2074,15 +2066,15 @@
 
     if ( distance >= 0 )
     {
-      val = distance + compensation + 32 / resolution;
+      val = distance + compensation + 32;
       if ( distance && val > 0 )
-        val &= ~( 64 / resolution - 1 );
+        val &= ~63;
       else
         val = 0;
     }
     else
     {
-      val = -FT_PIX_ROUND_GRID( compensation - distance, resolution );
+      val = -FT_PIX_ROUND( compensation - distance );
       if ( val > 0 )
         val = 0;
     }
@@ -2104,15 +2096,12 @@
   /*                                                                       */
   /*    compensation :: The engine compensation.                           */
   /*                                                                       */
-  /*    resolution   :: The number of grid lines per pixel.                */
-  /*                                                                       */
   /* <Return>                                                              */
   /*    Rounded distance.                                                  */
   /*                                                                       */
   static FT_F26Dot6
   Round_To_Half_Grid( EXEC_OP_ FT_F26Dot6  distance,
-                               FT_F26Dot6  compensation,
-                               FT_Int      resolution )
+                               FT_F26Dot6  compensation )
   {
     FT_F26Dot6  val;
 
@@ -2121,15 +2110,13 @@
 
     if ( distance >= 0 )
     {
-      val = FT_PIX_FLOOR_GRID( distance + compensation, resolution ) +
-            32 / resolution;
+      val = FT_PIX_FLOOR( distance + compensation ) + 32;
       if ( distance && val < 0 )
         val = 0;
     }
     else
     {
-      val = -( FT_PIX_FLOOR_GRID( compensation - distance, resolution ) +
-               32 / resolution );
+      val = -( FT_PIX_FLOOR( compensation - distance ) + 32 );
       if ( val > 0 )
         val = 0;
     }
@@ -2151,15 +2138,12 @@
   /*                                                                       */
   /*    compensation :: The engine compensation.                           */
   /*                                                                       */
-  /*    resolution   :: The number of grid lines per pixel.                */
-  /*                                                                       */
   /* <Return>                                                              */
   /*    Rounded distance.                                                  */
   /*                                                                       */
   static FT_F26Dot6
   Round_Down_To_Grid( EXEC_OP_ FT_F26Dot6  distance,
-                               FT_F26Dot6  compensation,
-                               FT_Int      resolution )
+                               FT_F26Dot6  compensation )
   {
     FT_F26Dot6  val;
 
@@ -2170,13 +2154,13 @@
     {
       val = distance + compensation;
       if ( distance && val > 0 )
-        val &= ~( 64 / resolution - 1 );
+        val &= ~63;
       else
         val = 0;
     }
     else
     {
-      val = -( ( compensation - distance ) & -( 64 / resolution ) );
+      val = -( ( compensation - distance ) & -64 );
       if ( val > 0 )
         val = 0;
     }
@@ -2198,15 +2182,12 @@
   /*                                                                       */
   /*    compensation :: The engine compensation.                           */
   /*                                                                       */
-  /*    resolution   :: The number of grid lines per pixel.                */
-  /*                                                                       */
   /* <Return>                                                              */
   /*    Rounded distance.                                                  */
   /*                                                                       */
   static FT_F26Dot6
   Round_Up_To_Grid( EXEC_OP_ FT_F26Dot6  distance,
-                             FT_F26Dot6  compensation,
-                             FT_Int      resolution )
+                             FT_F26Dot6  compensation )
   {
     FT_F26Dot6  val;
 
@@ -2215,15 +2196,15 @@
 
     if ( distance >= 0 )
     {
-      val = distance + compensation + ( 64 / resolution - 1 );
+      val = distance + compensation + 63;
       if ( distance && val > 0 )
-        val &= ~( 64 / resolution - 1 );
+        val &= ~63;
       else
         val = 0;
     }
     else
     {
-      val = -FT_PIX_CEIL_GRID( compensation - distance, resolution );
+      val = - FT_PIX_CEIL( compensation - distance );
       if ( val > 0 )
         val = 0;
     }
@@ -2245,15 +2226,12 @@
   /*                                                                       */
   /*    compensation :: The engine compensation.                           */
   /*                                                                       */
-  /*    resolution   :: The number of grid lines per pixel.                */
-  /*                                                                       */
   /* <Return>                                                              */
   /*    Rounded distance.                                                  */
   /*                                                                       */
   static FT_F26Dot6
   Round_To_Double_Grid( EXEC_OP_ FT_F26Dot6  distance,
-                                 FT_F26Dot6  compensation,
-                                 FT_Int      resolution )
+                                 FT_F26Dot6  compensation )
   {
     FT_F26Dot6 val;
 
@@ -2262,15 +2240,15 @@
 
     if ( distance >= 0 )
     {
-      val = distance + compensation + 16 / resolution;
+      val = distance + compensation + 16;
       if ( distance && val > 0 )
-        val &= ~( 32 / resolution - 1 );
+        val &= ~31;
       else
         val = 0;
     }
     else
     {
-      val = -FT_PAD_ROUND( compensation - distance, 32 / resolution );
+      val = -FT_PAD_ROUND( compensation - distance, 32 );
       if ( val > 0 )
         val = 0;
     }
@@ -2292,8 +2270,6 @@
   /*                                                                       */
   /*    compensation :: The engine compensation.                           */
   /*                                                                       */
-  /*    resolution   :: The number of grid lines per pixel.                */
-  /*                                                                       */
   /* <Return>                                                              */
   /*    Rounded distance.                                                  */
   /*                                                                       */
@@ -2305,13 +2281,10 @@
   /*                                                                       */
   static FT_F26Dot6
   Round_Super( EXEC_OP_ FT_F26Dot6  distance,
-                        FT_F26Dot6  compensation,
-                        FT_Int      resolution )
+                        FT_F26Dot6  compensation )
   {
     FT_F26Dot6  val;
 
-    FT_UNUSED( resolution );
-
 
     if ( distance >= 0 )
     {
@@ -2347,8 +2320,6 @@
   /*                                                                       */
   /*    compensation :: The engine compensation.                           */
   /*                                                                       */
-  /*    resolution   :: The number of grid lines per pixel.                */
-  /*                                                                       */
   /* <Return>                                                              */
   /*    Rounded distance.                                                  */
   /*                                                                       */
@@ -2358,13 +2329,10 @@
   /*                                                                       */
   static FT_F26Dot6
   Round_Super_45( EXEC_OP_ FT_F26Dot6  distance,
-                           FT_F26Dot6  compensation,
-                           FT_Int      resolution )
+                           FT_F26Dot6  compensation )
   {
     FT_F26Dot6  val;
 
-    FT_UNUSED( resolution );
-
 
     if ( distance >= 0 )
     {
@@ -2447,19 +2415,13 @@
   /*    Sets Super Round parameters.                                       */
   /*                                                                       */
   /* <Input>                                                               */
-  /*    GridPeriod :: The grid period.                                     */
-  /*                                                                       */
-  /*    selector   :: The SROUND opcode.                                   */
-  /*                                                                       */
-  /*    resolution :: The number of grid lines per pixel.                  */
+  /*    GridPeriod :: Grid period                                          */
+  /*    selector   :: SROUND opcode                                        */
   /*                                                                       */
   static void
   SetSuperRound( EXEC_OP_ FT_F26Dot6  GridPeriod,
-                          FT_Long     selector,
-                          FT_Int      resolution )
+                          FT_Long     selector )
   {
-    FT_UNUSED( resolution );
-
     switch ( (FT_Int)( selector & 0xC0 ) )
     {
       case 0:
@@ -3129,13 +3091,13 @@
 
 
 #define DO_SROUND                                \
-    SET_SuperRound( 0x4000, args[0], 1 );        \
+    SET_SuperRound( 0x4000, args[0] );           \
     CUR.GS.round_state = TT_Round_Super;         \
     CUR.func_round = (TT_Round_Func)Round_Super;
 
 
 #define DO_S45ROUND                                 \
-    SET_SuperRound( 0x2D41, args[0], 1 );           \
+    SET_SuperRound( 0x2D41, args[0] );              \
     CUR.GS.round_state = TT_Round_Super_45;         \
     CUR.func_round = (TT_Round_Func)Round_Super_45;
 
@@ -3306,12 +3268,12 @@
     args[0] = ( args[0] != args[1] );
 
 
-#define DO_ODD                                                     \
-    args[0] = ( ( CUR_Func_round( args[0], 0, 1 ) & 127 ) == 64 );
+#define DO_ODD                                                  \
+    args[0] = ( ( CUR_Func_round( args[0], 0 ) & 127 ) == 64 );
 
 
-#define DO_EVEN                                                   \
-    args[0] = ( ( CUR_Func_round( args[0], 0, 1 ) & 127 ) == 0 );
+#define DO_EVEN                                                \
+    args[0] = ( ( CUR_Func_round( args[0], 0 ) & 127 ) == 0 );
 
 
 #define DO_AND                        \
@@ -3484,17 +3446,15 @@
     CUR.error = TT_Err_Debug_OpCode;
 
 
-#define DO_ROUND                                                 \
-    args[0] = CUR_Func_round(                                    \
-                args[0],                                         \
-                CUR.tt_metrics.compensations[CUR.opcode - 0x68], \
-                1 );
+#define DO_ROUND                                                   \
+    args[0] = CUR_Func_round(                                      \
+                args[0],                                           \
+                CUR.tt_metrics.compensations[CUR.opcode - 0x68] );
 
 
-#define DO_NROUND                                                          \
-    args[0] = ROUND_None( args[0],                                         \
-                          CUR.tt_metrics.compensations[CUR.opcode - 0x6C], \
-                          1 );
+#define DO_NROUND                                                            \
+    args[0] = ROUND_None( args[0],                                           \
+                          CUR.tt_metrics.compensations[CUR.opcode - 0x6C] );
 
 
 #define DO_MAX               \
@@ -6243,18 +6203,17 @@
   Ins_MSIRP( INS_ARG )
   {
     FT_UShort   point;
-    FT_F26Dot6  distance;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
-    FT_Int      gridlines_per_pixel = 1;
+    FT_F26Dot6  distance,
+                control_value_cutin;
 
 
-    if ( CUR.ignore_x_mode )
-    {
-      if ( CUR.GS.freeVector.x != 0 )
-        gridlines_per_pixel = SPH_OPTION_GRIDLINES_PER_PIXEL_X;
-      else if ( CUR.GS.freeVector.y != 0 )
-        gridlines_per_pixel = SPH_OPTION_GRIDLINES_PER_PIXEL_Y;
-    }
+    control_value_cutin = CUR.GS.control_value_cutin;
+
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+    if ( CUR.ignore_x_mode                                 &&
+         CUR.GS.freeVector.x != 0                          &&
+         !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
+        control_value_cutin = 0;
 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
 
     point = (FT_UShort)args[0];
@@ -6281,10 +6240,9 @@
 
 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
     /* subpixel hinting - make MSIRP respect CVT cut-in; */
-    if ( CUR.ignore_x_mode                                  &&
-         CUR.GS.freeVector.x != 0                           &&
-         FT_ABS( distance - args[1] ) >=
-           CUR.GS.control_value_cutin / gridlines_per_pixel )
+    if ( CUR.ignore_x_mode                                   &&
+         CUR.GS.freeVector.x != 0                            &&
+         FT_ABS( distance - args[1] ) >= control_value_cutin )
       distance = args[1];
 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
 
@@ -6310,22 +6268,8 @@
     FT_UShort   point;
     FT_F26Dot6  cur_dist,
                 distance;
-    FT_Int      gridlines_per_pixel = 1;
 
 
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
-    if ( CUR.ignore_x_mode )
-    {
-      if ( CUR.GS.freeVector.x != 0                          &&
-           !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
-        gridlines_per_pixel = SPH_OPTION_GRIDLINES_PER_PIXEL_X;
-
-      else if ( CUR.GS.freeVector.y != 0                          &&
-                !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
-        gridlines_per_pixel = SPH_OPTION_GRIDLINES_PER_PIXEL_Y;
-    }
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
-
     point = (FT_UShort)args[0];
 
     if ( BOUNDS( point, CUR.zp0.n_points ) )
@@ -6338,9 +6282,14 @@
     if ( ( CUR.opcode & 1 ) != 0 )
     {
       cur_dist = CUR_fast_project( &CUR.zp0.cur[point] );
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+      if ( CUR.ignore_x_mode && CUR.GS.freeVector.x != 0 )
+        distance = ROUND_None( cur_dist,
+                               CUR.tt_metrics.compensations[0] ) - cur_dist;
+      else
+#endif
       distance = CUR_Func_round( cur_dist,
-                                 CUR.tt_metrics.compensations[0],
-                                 gridlines_per_pixel ) - cur_dist;
+                                 CUR.tt_metrics.compensations[0] ) - cur_dist;
     }
     else
       distance = 0;
@@ -6364,26 +6313,21 @@
     FT_ULong    cvtEntry;
     FT_UShort   point;
     FT_F26Dot6  distance,
-                org_dist;
-    FT_Int      gridlines_per_pixel = 1;
+                org_dist,
+                control_value_cutin;
 
 
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
-    if ( CUR.ignore_x_mode )
-    {
-      if ( CUR.GS.freeVector.x != 0                          &&
-           !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
-        gridlines_per_pixel = SPH_OPTION_GRIDLINES_PER_PIXEL_X;
-
-      else if ( CUR.GS.freeVector.y != 0                          &&
-                !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
-        gridlines_per_pixel = SPH_OPTION_GRIDLINES_PER_PIXEL_Y;
-    }
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
-
+    control_value_cutin = CUR.GS.control_value_cutin;
     cvtEntry = (FT_ULong)args[1];
     point    = (FT_UShort)args[0];
 
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+    if ( CUR.ignore_x_mode                                 &&
+         CUR.GS.freeVector.x != 0                          &&
+         !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
+        control_value_cutin = 0;
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
     if ( BOUNDS( point,     CUR.zp0.n_points ) ||
          BOUNDSL( cvtEntry, CUR.cvtSize )      )
     {
@@ -6437,13 +6381,16 @@
 
     if ( ( CUR.opcode & 1 ) != 0 )   /* rounding and control cutin flag */
     {
-      if ( FT_ABS( distance - org_dist ) >
-             CUR.GS.control_value_cutin / gridlines_per_pixel )
+      if ( FT_ABS( distance - org_dist ) > control_value_cutin )
         distance = org_dist;
 
-      distance = CUR_Func_round( distance,
-                                 CUR.tt_metrics.compensations[0],
-                                 gridlines_per_pixel );
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+      if ( CUR.ignore_x_mode && CUR.GS.freeVector.x != 0 )
+        distance = ROUND_None( distance,
+                               CUR.tt_metrics.compensations[0] );
+      else
+#endif
+      distance = CUR_Func_round( distance, CUR.tt_metrics.compensations[0] );
     }
 
     CUR_Func_move( &CUR.zp0, point, distance - org_dist );
@@ -6464,24 +6411,16 @@
   Ins_MDRP( INS_ARG )
   {
     FT_UShort   point;
-    FT_F26Dot6  org_dist, distance, new_distance;
-    FT_Int      minimum_distance_factor = 64;
-    FT_Int      gridlines_per_pixel     = 1;
+    FT_F26Dot6  org_dist, distance, minimum_distance;
 
 
+    minimum_distance    = CUR.GS.minimum_distance;
+
 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
-    if ( CUR.ignore_x_mode )
-    {
-      if ( CUR.GS.freeVector.x != 0                          &&
-           !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
-      {
-        gridlines_per_pixel     = SPH_OPTION_GRIDLINES_PER_PIXEL_X;
-        minimum_distance_factor = 64 - gridlines_per_pixel / 3;
-      }
-      else if ( CUR.GS.freeVector.y != 0                          &&
-                !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
-        gridlines_per_pixel = SPH_OPTION_GRIDLINES_PER_PIXEL_Y;
-    }
+    if ( CUR.ignore_x_mode                                 &&
+         CUR.GS.freeVector.x != 0                          &&
+         !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
+        minimum_distance = 0;
 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
 
 
@@ -6546,15 +6485,22 @@
     /* round flag */
 
     if ( ( CUR.opcode & 4 ) != 0 )
+    {
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+      if ( CUR.ignore_x_mode && CUR.GS.freeVector.x != 0 )
+        distance = ROUND_None(
+                     org_dist,
+                     CUR.tt_metrics.compensations[CUR.opcode & 3] );
+      else
+#endif
       distance = CUR_Func_round(
                    org_dist,
-                   CUR.tt_metrics.compensations[CUR.opcode & 3],
-                   gridlines_per_pixel );
+                   CUR.tt_metrics.compensations[CUR.opcode & 3] );
+    }
     else
       distance = ROUND_None(
                    org_dist,
-                   CUR.tt_metrics.compensations[CUR.opcode & 3],
-                   gridlines_per_pixel );
+                   CUR.tt_metrics.compensations[CUR.opcode & 3] );
 
     /* minimum distance flag */
 
@@ -6562,17 +6508,13 @@
     {
       if ( org_dist >= 0 )
       {
-        new_distance = FT_MulDiv( minimum_distance_factor,
-                                  CUR.GS.minimum_distance, 64 );
-        if ( distance < new_distance )
-          distance = new_distance;
+        if ( distance < minimum_distance )
+          distance = minimum_distance;
       }
       else
       {
-        new_distance = -FT_MulDiv( minimum_distance_factor,
-                                  CUR.GS.minimum_distance, 64 );
-        if ( distance > new_distance )
-          distance = new_distance;
+        if ( distance > -minimum_distance )
+          distance = -minimum_distance;
       }
     }
 
@@ -6606,13 +6548,10 @@
 
     FT_F26Dot6  cvt_dist,
                 distance,
-                new_distance,
                 cur_dist,
-                org_dist;
-
-    FT_Int      minimum_distance_factor = 64;
-    FT_Int      gridlines_per_pixel     = 1;
-
+                org_dist,
+                control_value_cutin,
+                minimum_distance;
 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
     FT_Int      B1;
     FT_Int      B2;
@@ -6620,26 +6559,16 @@
 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
 
 
+    minimum_distance    = CUR.GS.minimum_distance;
+    control_value_cutin = CUR.GS.control_value_cutin;
     point    = (FT_UShort)args[0];
     cvtEntry = (FT_ULong)( args[1] + 1 );
 
 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
-    if ( CUR.ignore_x_mode )
-    {
-      if ( CUR.GS.freeVector.x != 0                          &&
-           !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
-      {
-        gridlines_per_pixel = SPH_OPTION_GRIDLINES_PER_PIXEL_X;
-        /* high value emboldens glyphs at lower ppems (< 14); */
-        /* Courier looks better with 52 --                    */
-        /* MS ClearType Rasterizer supposedly uses 32         */
-        minimum_distance_factor = 64 - gridlines_per_pixel / 3;
-      }
-
-      else if ( CUR.GS.freeVector.y != 0                          &&
-                !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
-        gridlines_per_pixel = SPH_OPTION_GRIDLINES_PER_PIXEL_Y;
-    }
+    if ( CUR.ignore_x_mode                                 &&
+         CUR.GS.freeVector.x != 0                          &&
+         !( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
+        control_value_cutin = minimum_distance = 0;
 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
 
     /* XXX: UNDOCUMENTED! cvt[-1] = 0 always */
@@ -6729,21 +6658,25 @@
         /*      `ttinst2.doc', version 1.66, is thus incorrect since  */
         /*      it implies `>=' instead of `>'.                       */
 
-        if ( FT_ABS( cvt_dist - org_dist ) >
-               CUR.GS.control_value_cutin / gridlines_per_pixel )
+        if ( FT_ABS( cvt_dist - org_dist ) > control_value_cutin )
           cvt_dist = org_dist;
       }
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+      if ( CUR.ignore_x_mode && CUR.GS.freeVector.x != 0 )
+        distance = ROUND_None(
+                     cvt_dist,
+                     CUR.tt_metrics.compensations[CUR.opcode & 3] );
+      else
+#endif
 
       distance = CUR_Func_round(
                    cvt_dist,
-                   CUR.tt_metrics.compensations[CUR.opcode & 3],
-                   gridlines_per_pixel );
+                   CUR.tt_metrics.compensations[CUR.opcode & 3] );
     }
     else
       distance = ROUND_None(
                    cvt_dist,
-                   CUR.tt_metrics.compensations[CUR.opcode & 3],
-                   gridlines_per_pixel );
+                   CUR.tt_metrics.compensations[CUR.opcode & 3] );
 
     /* minimum distance test */
 
@@ -6751,17 +6684,13 @@
     {
       if ( org_dist >= 0 )
       {
-        new_distance = FT_MulDiv( minimum_distance_factor,
-                                  CUR.GS.minimum_distance, 64 );
-        if ( distance < new_distance )
-          distance = new_distance;
+        if ( distance < minimum_distance )
+          distance = minimum_distance;
       }
       else
       {
-        new_distance = -FT_MulDiv( minimum_distance_factor,
-                                  CUR.GS.minimum_distance, 64 );
-        if ( distance > new_distance )
-          distance = new_distance;
+        if ( distance > -minimum_distance )
+          distance = -minimum_distance;
       }
     }
 
diff --git a/src/truetype/ttinterp.h b/src/truetype/ttinterp.h
index adaab23..2fc476d 100644
--- a/src/truetype/ttinterp.h
+++ b/src/truetype/ttinterp.h
@@ -68,8 +68,7 @@ FT_BEGIN_HEADER
   /* Rounding function */
   typedef FT_F26Dot6
   (*TT_Round_Func)( EXEC_OP_ FT_F26Dot6  distance,
-                             FT_F26Dot6  compensation,
-                             FT_Int      resolution );
+                             FT_F26Dot6  compensation );
 
   /* Point displacement along the freedom vector routine */
   typedef void