Commit 6b9034f0fdfcd84e62e7c0d29bfd458325f4ccd7

Werner Lemberg 2013-01-28T13:56:23

Formatting, comment improvements.

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
diff --git a/ChangeLog b/ChangeLog
index a80e26c..aa5d62c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,58 +18,61 @@
 
 	* src/truetype/ttsubpix.c: Updated.
 	(ALWAYS_SKIP_DELTAP_Rules): Remove rule for Trebuchet MS.
-	(sph_set_tweaks): Fix rasterizer_version logic.
+	(sph_set_tweaks): Fix `rasterizer_version' logic.
 
 2013-01-26  Infinality  <infinality@infinality.net>
 
 	[truetype] Align more to ClearType whitepaper for sph.
 
 	* include/freetype/internal/tttypes.h (TT_FaceRec): Add flags
-	for detected fdefs and compatibility mode.
+	for detected opcode patterns and compatibility mode.
 
 	* src/truetype/ttgload.c (tt_loader_init): Complete conditional.
 
-	* src/truetype/ttinterp.c: Updated. Remove SPH_DEBUG and replace 
-	with FT_TRACE7.
+	* src/truetype/ttinterp.c: Updated.
+	Remove SPH_DEBUG and replace with FT_TRACE7.
 	(DO_RS): More conditions.
-	(Ins_FDEF): Add more opcode detection patterns. More specific 
-	conditions when flagging a fdef. Make compatibility mode only turn 
-	on when delta fdefs are found.
-	(Ins_CALL, Ins_LOOPCALL): Set flags for currently executing fdef.
-	(Ins_SHPIX): Remove logic to handle ttfautohinted fonts.  Simplify
-	conditionals where possible. Use & instead of % operator for dumb
-	compilers.
-	(Ins_MIAP): Adjust twilight zone conditional. Ensure ingore_x_mode
-	is on when testing sph conditionals.
-	(Ins_MIRP): Ensure ingore_x_mode is on when testing sph conditionals.
-	Do cvt cutin always when in ignore_x_mode.  Remove test for 
-	ttfautohinted fonts.
-	(Ins_DELTAP): Ensure ingore_x_mode is on when testing sph conditionals.
-	Do cvt cutin always when in ignore_x_mode.  Remove test for 
-	ttfautohinted fonts. Use & instead of % operator for dumb
-	compilers.
+	(Ins_FDEF): Add more opcode detection patterns.
+	More specific conditions when flagging an fdef.
+	Make compatibility mode only turn on when delta fdefs are found.
+	(Ins_CALL, Ins_LOOPCALL): Set flags for currently executed fdef.
+	(Ins_SHPIX): Remove logic to handle ttfautohinted fonts.
+	Simplify conditionals where possible.
+	Use `&' instead of `%' operator for dumb compilers.
+	(Ins_MIAP): Adjust twilight zone conditional.
+	Ensure `ignore_x_mode' is on when testing sph conditionals.
+	(Ins_MIRP): Ensure `ignore_x_mode' is on when testing sph
+	conditionals.
+	Do cvt cutin always when `ignore_x_mode' is active.
+	Remove test for ttfautohinted fonts.
+	(Ins_DELTAP): Ensure `ignore_x_mode' is on when testing sph
+	conditionals.
+	Do cvt cutin always when `ignore_x_mode' is active.
+	Remove test for ttfautohinted fonts.
+	Use `&' instead of `%' operator for dumb compilers.
 	(Ins_GETINFO): Remove SPH_DEBUG and replace with FT_TRACE7.
 
 	* src/truetype/ttinterp.h: Updated.
-	(TT_ExecContextRec): Remove compatibility_mode variable.  Add variable
-	to indicate when executing in special fdefs for sph.
+	(TT_ExecContextRec): Remove compatibility_mode variable.
+	Add variable to indicate when executing in special fdefs for sph.
 
 	* src/truetype/ttobjs.h: Updated.
 	(TT_DefRecord): Add flags to identify special fdefs for sph.
 	(TT_SizeRec): Remove unnecessary ttfautohinted variable.
 
 	* src/truetype/ttsubpix.c: Updated.
-	(COMPATIBILITY_MODE_Rules): Remove all. Auto-detected now.
-	(PIXEL_HINTING_Rules): Remove all. Unnecessary after fixes.
+	(COMPATIBILITY_MODE_Rules): Remove all.  Auto-detected now.
+	(PIXEL_HINTING_Rules): Remove all.  Unnecessary after fixes.
 	(SKIP_NONPIXEL_Y_MOVES_Rules): Remove Ubuntu.
 	(SKIP_NONPIXEL_Y_MOVES_Rules_Exceptions): Add Arial Bold `N'.
-	(SKIP_OFFPIXEL_Y_MOVES_Rules): Remove all. Happens automatically now.
+	(SKIP_OFFPIXEL_Y_MOVES_Rules): Remove all.  Happens automatically
+	now.
 	(ROUND_NONPIXEL_Y_MOVES_Rules): Remove Ubuntu.
 	(ROUND_NONPIXEL_Y_MOVES_Rules_Exceptions): Remove all.
 	(NORMAL_ROUND_Rules): Remove Verdana.
 	(NO_DELTAP_AFTER_IUP_Rules): Remove all.
-	(sph_set_tweaks): Performance fix. Don't run prep always. Adjust
-	conditional for sph_compatibility_mode.
+	(sph_set_tweaks): Performance fix.  Don't run prep always.
+	Adjust conditional for sph_compatibility_mode.
 
 	* src/truetype/ttsubpix.h: Add new fdef flags for sph.
 
diff --git a/include/freetype/internal/tttypes.h b/include/freetype/internal/tttypes.h
index a29fd14..545708b 100644
--- a/include/freetype/internal/tttypes.h
+++ b/include/freetype/internal/tttypes.h
@@ -5,7 +5,7 @@
 /*    Basic SFNT/TrueType type definitions and interface (specification    */
 /*    only).                                                               */
 /*                                                                         */
-/*  Copyright 1996-2002, 2004-2008, 2012 by                                */
+/*  Copyright 1996-2002, 2004-2008, 2012-2013 by                           */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -1429,8 +1429,9 @@ FT_BEGIN_HEADER
     FT_ULong              vert_metrics_offset;
 
 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
-    FT_ULong              sph_found_func_flags; /* special funcs identified */
-                                                /* for this face            */
+    /* since 2.4.12 */
+    FT_ULong              sph_found_func_flags; /* special functions found */
+                                                /* for this face           */
     FT_Bool               sph_compatibility_mode;
 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
 
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index ba5e533..e8f6258 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -1943,7 +1943,6 @@
 
       if ( subpixel_hinting )
         grayscale = grayscale_hinting = FALSE;
-
       else if ( SPH_OPTION_SET_GRAYSCALE )
       {
         grayscale = grayscale_hinting = TRUE;
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index c687144..d1fd805 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -3182,6 +3182,7 @@
          args[0] = CUR.storage[I];                        \
      }                                                    \
    }
+
 #else /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
 
 #define DO_RS                           \
@@ -4581,11 +4582,11 @@
       return;
     }
 
-    rec->range        = CUR.curRange;
-    rec->opc          = (FT_UInt16)n;
-    rec->start        = CUR.IP + 1;
-    rec->active       = TRUE;
-    rec->inline_delta = FALSE;
+    rec->range          = CUR.curRange;
+    rec->opc            = (FT_UInt16)n;
+    rec->start          = CUR.IP + 1;
+    rec->active         = TRUE;
+    rec->inline_delta   = FALSE;
     rec->sph_fdef_flags = 0x0000;
 
     if ( n > CUR.maxFunc )
@@ -4614,8 +4615,8 @@
 
           if ( opcode_pointer[i] == opcode_size[i] )
           {
-
-            FT_TRACE7(( "sph: Function %d, opcode ptrn: %d, %s %s\n", i, n,
+            FT_TRACE7(( "sph: Function %d, opcode ptrn: %d, %s %s\n",
+                        i, n,
                         CUR.face->root.family_name,
                         CUR.face->root.style_name ));
 
@@ -4683,7 +4684,6 @@
                 CUR.face->sph_found_func_flags |= SPH_FDEF_SPACING_2;
               }
               break;
-
             }
             opcode_pointer[i] = 0;
           }
@@ -4694,10 +4694,9 @@
       }
 
       /* Set sph_compatibility_mode only when deltas are detected */
-      CUR.face->sph_compatibility_mode = ( ( CUR.face->sph_found_func_flags &
-                                             SPH_FDEF_INLINE_DELTA_1 )        |
-                                           ( CUR.face->sph_found_func_flags &
-                                             SPH_FDEF_INLINE_DELTA_2 ) );
+      CUR.face->sph_compatibility_mode =
+        ( ( CUR.face->sph_found_func_flags & SPH_FDEF_INLINE_DELTA_1 ) |
+          ( CUR.face->sph_found_func_flags & SPH_FDEF_INLINE_DELTA_2 ) );
 
 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
 
@@ -6035,7 +6034,8 @@
                ( CUR.sph_tweak_flags & SPH_TWEAK_SKIP_INLINE_DELTAS ) )
             goto Skip;
 
-          if ( !CUR.face->sph_compatibility_mode && CUR.GS.freeVector.y != 0 )
+          if ( !CUR.face->sph_compatibility_mode &&
+               CUR.GS.freeVector.y != 0          )
             MOVE_Zp2_Point( point, dx, dy, TRUE );
 
           else if ( CUR.face->sph_compatibility_mode )
@@ -6069,7 +6069,7 @@
                  CUR.GS.freeVector.y != 0                                  &&
                  ( B1 & 63 ) == 0                                          &&
                  ( B2 & 63 ) != 0                                          &&
-                 B1 != B2                                                ) )
+                 B1 != B2                                                  ) )
             MOVE_Zp2_Point( point, -dx, -dy, TRUE );
       }
         else
@@ -6260,8 +6260,8 @@
     if ( CUR.GS.gep0 == 0 )   /* If in twilight zone */
     {
 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
-      /* Only adjust when not in sph_compatibility_mode or ignore_x_mode */
-      /* Determined via experimentation and may be incorrect             */
+      /* Only adjust if not in sph_compatibility_mode or ignore_x_mode. */
+      /* Determined via experimentation and may be incorrect...         */
       if ( !CUR.ignore_x_mode || !CUR.face->sph_compatibility_mode )
 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
         CUR.zp0.org[point].x = TT_MulFix14( (FT_UInt32)distance,
@@ -6643,7 +6643,7 @@
            ( B1 & 63 ) != 0                                          )
         reverse_move = TRUE;
 
-      if ( ( CUR.sph_tweak_flags &
+      if ( ( CUR.sph_tweak_flags                      &
              SPH_TWEAK_DELTAP_SKIP_EXAGGERATED_VALUES ) &&
            !reverse_move                                &&
            FT_ABS( B1 - B2 ) >= 64                      )
@@ -7371,15 +7371,15 @@
             else
               B1 = CUR.zp0.cur[A].x;
 #if 0
-            /* Standard Subpixel Hinting:  Allow y move    */
-            /* This messes up dejavu and may not be needed */
+            /* Standard Subpixel Hinting: Allow y move.       */
+            /* This messes up dejavu and may not be needed... */
             if ( !CUR.face->sph_compatibility_mode &&
                  CUR.GS.freeVector.y != 0           )
               CUR_Func_move( &CUR.zp0, A, B );
             else
 #endif
-            /* Compatibility Mode: Allow x or y move if point touched in
-                Y direction */
+            /* Compatibility Mode: Allow x or y move if point touched in */
+            /* Y direction.                                              */
             if ( CUR.face->sph_compatibility_mode                      &&
                  !( CUR.sph_tweak_flags & SPH_TWEAK_ALWAYS_SKIP_DELTAP ) )
             {
@@ -7389,10 +7389,8 @@
               if ( ( CUR.sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES ) )
                 B = FT_PIX_ROUND( B1 + B ) - B1;
 
-              /*
-              *  Allow delta move if using sph_compatibility_mode, IUP has not
-              *  been called, and point is touched on Y.
-              */
+              /* Allow delta move if using sph_compatibility_mode,   */
+              /* IUP has not been called, and point is touched on Y. */
               if ( !CUR.iup_called                            &&
                    ( CUR.zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) )
                 CUR_Func_move( &CUR.zp0, A, B );
@@ -7401,14 +7399,14 @@
             B2 = CUR.zp0.cur[A].y;
 
             /* Reverse this move if it results in a disallowed move */
-            if ( CUR.GS.freeVector.y != 0                     &&
-                 ( ( CUR.face->sph_compatibility_mode     &&
-                        ( B1 & 63 ) == 0                  &&
-                        ( B2 & 63 ) != 0                  ) ||
-                   ( ( CUR.sph_tweak_flags &
-                        SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES ) &&
-                        ( B1 & 63 ) != 0                  &&
-                        ( B2 & 63 ) != 0                  ) ) )
+            if ( CUR.GS.freeVector.y != 0                    &&
+                 ( ( CUR.face->sph_compatibility_mode    &&
+                     ( B1 & 63 ) == 0                    &&
+                     ( B2 & 63 ) != 0                    ) ||
+                   ( ( CUR.sph_tweak_flags             &
+                       SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES ) &&
+                     ( B1 & 63 ) != 0                    &&
+                     ( B2 & 63 ) != 0                    ) ) )
               CUR_Func_move( &CUR.zp0, A, -B );
           }
 #else
@@ -7552,7 +7550,8 @@
     if ( ( args[0] & 1 ) != 0 && CUR.ignore_x_mode )
     {
       K = CUR.rasterizer_version;
-      FT_TRACE7(( "Setting rasterizer version %d\n", CUR.rasterizer_version ));
+      FT_TRACE7(( "Setting rasterizer version %d\n",
+                  CUR.rasterizer_version ));
     }
     else
 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
@@ -8024,7 +8023,7 @@
 #endif
 
 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
-    CUR.iup_called        = FALSE;
+    CUR.iup_called = FALSE;
 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
 
     /* set CVT functions */
diff --git a/src/truetype/ttinterp.h b/src/truetype/ttinterp.h
index 8460210..69f5011 100644
--- a/src/truetype/ttinterp.h
+++ b/src/truetype/ttinterp.h
@@ -278,15 +278,15 @@ FT_BEGIN_HEADER
     FT_Bool            subpixel_positioned;   /* subpixel positioned       */
                                               /* (DirectWrite ClearType)?  */
 
-    FT_Int             rasterizer_version;    /* MS rasterizer version */
+    FT_Int             rasterizer_version;    /* MS rasterizer version     */
 
-    FT_Bool            iup_called;            /* IUP called for glyph?  */
+    FT_Bool            iup_called;            /* IUP called for glyph?     */
 
-    FT_ULong           sph_tweak_flags;       /* flags to control  */
-                                              /* hint tweaks       */
+    FT_ULong           sph_tweak_flags;       /* flags to control          */
+                                              /* hint tweaks               */
 
-    FT_ULong           sph_in_func_flags;     /* flags to indicate if in */
-                                              /* special functions       */
+    FT_ULong           sph_in_func_flags;     /* flags to indicate if in   */
+                                              /* special functions         */
 
 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
 
diff --git a/src/truetype/ttobjs.h b/src/truetype/ttobjs.h
index 98a69aa..030a552 100644
--- a/src/truetype/ttobjs.h
+++ b/src/truetype/ttobjs.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Objects manager (specification).                                     */
 /*                                                                         */
-/*  Copyright 1996-2009, 2011-2012 by                                      */
+/*  Copyright 1996-2009, 2011-2013 by                                      */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -173,13 +173,13 @@ FT_BEGIN_HEADER
   /*                                                                       */
   typedef struct  TT_DefRecord_
   {
-    FT_Int   range;        /* in which code range is it located?     */
-    FT_Long  start;        /* where does it start?                   */
-    FT_Long  end;          /* where does it end?                     */
-    FT_UInt  opc;          /* function #, or instruction code        */
-    FT_Bool  active;       /* is it active?                          */
-    FT_Bool  inline_delta; /* is function that defines inline delta? */
-    FT_ULong sph_fdef_flags; /* flags to identify special functions  */
+    FT_Int    range;          /* in which code range is it located?     */
+    FT_Long   start;          /* where does it start?                   */
+    FT_Long   end;            /* where does it end?                     */
+    FT_UInt   opc;            /* function #, or instruction code        */
+    FT_Bool   active;         /* is it active?                          */
+    FT_Bool   inline_delta;   /* is function that defines inline delta? */
+    FT_ULong  sph_fdef_flags; /* flags to identify special functions    */
 
   } TT_DefRecord, *TT_DefArray;
 
diff --git a/src/truetype/ttsubpix.c b/src/truetype/ttsubpix.c
index 6d88ef0..53d3ed5 100644
--- a/src/truetype/ttsubpix.c
+++ b/src/truetype/ttsubpix.c
@@ -275,7 +275,7 @@
   };
 
 
-  /* Force special legacy fixes for fonts;                                 */
+  /* Force special legacy fixes for fonts.                                 */
 #define COMPATIBILITY_MODE_RULES_SIZE  1
 
   const SPH_TweakRule  COMPATIBILITY_MODE_Rules
@@ -1030,22 +1030,29 @@
       if ( loader->exec->rasterizer_version != 35 )
       {
         loader->exec->rasterizer_version = 35;
-        loader->exec->size->cvt_ready = FALSE;
-        tt_size_ready_bytecode( loader->exec->size,
-                            FT_BOOL( loader->load_flags & FT_LOAD_PEDANTIC ) );
+        loader->exec->size->cvt_ready    = FALSE;
+
+        tt_size_ready_bytecode(
+          loader->exec->size,
+          FT_BOOL( loader->load_flags & FT_LOAD_PEDANTIC ) );
       }
-      else loader->exec->rasterizer_version = 35;
+      else
+        loader->exec->rasterizer_version = 35;
     }
     else
     {
-      if ( loader->exec->rasterizer_version != SPH_OPTION_SET_RASTERIZER_VERSION )
+      if ( loader->exec->rasterizer_version  !=
+           SPH_OPTION_SET_RASTERIZER_VERSION )
       {
         loader->exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
-        loader->exec->size->cvt_ready = FALSE;
-        tt_size_ready_bytecode( loader->exec->size,
-                            FT_BOOL( loader->load_flags & FT_LOAD_PEDANTIC ) );
+        loader->exec->size->cvt_ready    = FALSE;
+
+        tt_size_ready_bytecode(
+          loader->exec->size,
+          FT_BOOL( loader->load_flags & FT_LOAD_PEDANTIC ) );
       }
-      else loader->exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
+      else
+        loader->exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
     }
 
     if ( IS_HINTED( loader->load_flags ) )
diff --git a/src/truetype/ttsubpix.h b/src/truetype/ttsubpix.h
index ba39916..5e5d8e6 100644
--- a/src/truetype/ttsubpix.h
+++ b/src/truetype/ttsubpix.h
@@ -34,14 +34,14 @@ FT_BEGIN_HEADER
   /* ID flags to identify special functions at FDEF and runtime.           */
   /*                                                                       */
   /*                                                                       */
-#define SPH_FDEF_INLINE_DELTA_1                   0x0000001
-#define SPH_FDEF_INLINE_DELTA_2                   0x0000002
-#define SPH_FDEF_DIAGONAL_STROKE                  0x0000004
-#define SPH_FDEF_VACUFORM_ROUND_1                 0x0000008
-#define SPH_FDEF_TTFAUTOHINT_1                    0x0000010
-#define SPH_FDEF_SPACING_1                        0x0000020
-#define SPH_FDEF_SPACING_2                        0x0000040
-#define SPH_FDEF_TYPEMAN_STROKES                  0x0000080
+#define SPH_FDEF_INLINE_DELTA_1    0x0000001
+#define SPH_FDEF_INLINE_DELTA_2    0x0000002
+#define SPH_FDEF_DIAGONAL_STROKE   0x0000004
+#define SPH_FDEF_VACUFORM_ROUND_1  0x0000008
+#define SPH_FDEF_TTFAUTOHINT_1     0x0000010
+#define SPH_FDEF_SPACING_1         0x0000020
+#define SPH_FDEF_SPACING_2         0x0000040
+#define SPH_FDEF_TYPEMAN_STROKES   0x0000080
 
 
   /*************************************************************************/