Commit f6c120f8267ac44e2b8a022e28bbf297b9f310b7

Werner Lemberg 2007-06-11T04:55:58

* docs/CHANGES: Document FT_Face_CheckTrueTypePatents). Formatting, reformulations.

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
diff --git a/ChangeLog b/ChangeLog
index ee6ba16..56dd24d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,16 +1,34 @@
+2007-06-11  Werner Lemberg  <wl@gnu.org>
+
+	* docs/CHANGES: Document FT_Face_CheckTrueTypePatents).
+
 2007-06-10  David Turner  <david@freetype.org>
 
-	* src/truetype/ttgload.c: slight speed-up to the TrueType glyph loader
+	* src/truetype/ttgload.c (TT_Load_Simple_Glyph): Slight speed-up to
+	the TrueType glyph loader.
 
-	* include/freetype/config/ftoption.h: clarify documentation regarding
-	unpatented hinting
+	* include/freetype/config/ftoption.h: Clarify documentation
+	regarding unpatented hinting.
 
-	* include/freetype/freetype.h, src/base/ftpatent.c, src/truetype/ttdriver.c,
-	include/freetype/internal/services/svttglyf.h, modules.cfg,:
-	include/freetype/internal/ftserv.h,:
-	Fonts without a cmap must be handled correctly by FreeType (anything
-	Adding the FT_Face_CheckTrueTypePatents API to FT_FREETYPE_H, it is
-	implemented by the optional src/base/ftpatent.c
+
+	Add new `FT_Face_CheckTrueTypePatents' API.
+
+	* include/freetype/freetype.h (FT_Face_CheckTrueTypePatents): New
+	declaration.
+
+	* include/freetype/internal/services/svttglyf.h,
+	src/base/ftpatent.c: New files.
+
+	* include/freetype/internal/ftserv.h (FT_SERVICE_TRUETYPE_GLYF_H):
+	New macro.
+
+	* src/truetype/ttdriver.c: Include FT_SERVICE_TRUETYPE_GLYF_H and
+	`ttpload.h'.
+	(tt_service_truetype_glyf): New service structure.
+	(tt_services): Register it.
+
+	* modules.cfg (BASE_EXTENSIONS), src/base/Jamfile (_sources): Add
+	`ftpatent.c'.
 
 2007-06-08  Werner Lemberg  <wl@gnu.org>
 
diff --git a/docs/CHANGES b/docs/CHANGES
index 59b9319..6a2d7a6 100644
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -28,6 +28,10 @@ CHANGES BETWEEN 2.3.5 and 2.3.4
       hinting module  as the default instead of the Latin one.  Thanks
       to Rahul Bhalerao for this suggestion.
 
+    - A new API `FT_Face_CheckTrueTypePatents'  has been added to find
+      out  whether  a  given  TrueType  font  uses  patented  bytecode
+      instructions.
+
 
   III. MISCELLANEOUS
 
diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
index dc96f37..9d1a743 100644
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -463,26 +463,47 @@ FT_BEGIN_HEADER
 
   /*************************************************************************/
   /*                                                                       */
-  /* The TT_CONFIG_OPTION_UNPATENTED_HINTING macro is *ignored* if you     */
-  /* have defined TT_CONFIG_OPTION_BYTECODE_INTERPRETER. If not, it will   */
-  /* compile a special work-around TrueType bytecode interpreter that      */
-  /* doesn't implement any of the patented opcodes/algorithms.             */
+  /* If you define TT_CONFIG_OPTION_UNPATENTED_HINTING, a special version  */
+  /* of the TrueType bytecode interpreter is used that doesn't implement   */
+  /* any of the patented opcodes and algorithms.  Note that the            */
+  /* the TT_CONFIG_OPTION_UNPATENTED_HINTING macro is *ignored* if you     */
+  /* define TT_CONFIG_OPTION_BYTECODE_INTERPRETER; with other words,       */
+  /* either define TT_CONFIG_OPTION_BYTECODE_INTERPRETER or                */
+  /* TT_CONFIG_OPTION_UNPATENTED_HINTING but not both at the same time.    */
+  /*                                                                       */
+  /* This macro is only useful for a small number of font files (mostly    */
+  /* for Asian scripts) that require bytecode interpretation to properly   */
+  /* load glyphs.  For all other fonts, this produces unpleasant results,  */
+  /* thus the unpatented interpreter is never used to load glyphs from     */
+  /* TrueType fonts unless one of the following two options is used.       */
+  /*                                                                       */
+  /*   - The unpatented interpreter is explicitly activated by the user    */
+  /*     through the FT_PARAM_TAG_UNPATENTED_HINTING parameter tag         */
+  /*     when opening the FT_Face.                                         */
   /*                                                                       */
-  /* this is only useful for a small number of font files (mostly Asian)   */
-  /* that require bytecode interpretation to properly load glyphs. For all */
-  /* other fonts, this will produce unpleasant results.                    */
+  /*   - FreeType detects that the FT_Face corresponds to one of the       */
+  /*     `trick' fonts (e.g., `Mingliu') it knows about.  The font engine  */
+  /*     contains a hard-coded list of font names and other matching       */
+  /*     parameters (see function `tt_face_init' in file                   */
+  /*     `src/truetype/ttobjs.c').                                         */
   /*                                                                       */
-  /* for this reason, the unpatented interpreter is never used by to load  */
-  /* glyphs from TrueType fonts, unless one of the following happens:      */
+  /* Here a sample code snippet for using FT_PARAM_TAG_UNPATENTED_HINTING. */
   /*                                                                       */
-  /*   - the unpatented interpreter is explicitely activated by the        */
-  /*     user through the FT_PARAM_TAG_UNPATENTED_HINTING parameter tag    */
-  /*     when opening the FT_Face                                          */
+  /*   {                                                                   */
+  /*     FT_Parameter  parameter;                                          */
+  /*     FT_Open_Args  open_args;                                          */
   /*                                                                       */
-  /*   - FreeType detects that the FT_Face corresponds to one of the       */
-  /*     'trick' fonts (e.g. Mingliu) it knows about. The font engine      */
-  /*     contains a hard-coded list of font names and other matching       */
-  /*     parameters.                                                       */
+  /*                                                                       */
+  /*     parameter.tag = FT_PARAM_TAG_UNPATENTED_HINTING;                  */
+  /*                                                                       */
+  /*     open_args.flags      = FT_OPEN_PATHNAME | FT_OPEN_PARAMS;         */
+  /*     open_args.pathname   = my_font_pathname;                          */
+  /*     open_args.num_params = 1;                                         */
+  /*     open_args.params     = &parameter;                                */
+  /*                                                                       */
+  /*     error = FT_Open_Face( library, &open_args, index, &face );        */
+  /*     ...                                                               */
+  /*   }                                                                   */
   /*                                                                       */
 #define TT_CONFIG_OPTION_UNPATENTED_HINTING
 
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index e52e39f..2ff95f7 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -2738,8 +2738,7 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /* <Description>                                                         */
   /*    Retrieve the ASCII name of a given glyph in a face.  This only     */
-  /*    works for those faces where @FT_HAS_GLYPH_NAMES(face) returns      */
-  /*    TRUE.                                                              */
+  /*    works for those faces where @FT_HAS_GLYPH_NAMES(face) returns 1.   */
   /*                                                                       */
   /* <Input>                                                               */
   /*    face        :: A handle to a source face object.                   */
@@ -3375,23 +3374,23 @@ FT_BEGIN_HEADER
   /*    FT_Face_CheckTrueTypePatents                                       */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    Parses the whole content of a TrueType font file and returns       */
-  /*    true if it uses any of the patented opcodes. this is only useful   */
+  /*    Parse all bytecode instructions of a TrueType font file to check   */
+  /*    whether any of the patented opcodes are used.  This is only useful */
   /*    if you want to be able to use the unpatented hinter with           */
   /*    fonts that do *not* use these opcodes.                             */
   /*                                                                       */
-  /*    note that this function parses *all* glyph instructions in the     */
-  /*    font file, and may be *slow*                                       */
+  /*    Note that this function parses *all* glyph instructions in the     */
+  /*    font file, which may be slow.                                      */
   /*                                                                       */
   /* <Input>                                                               */
-  /*    face :: a face handle                                              */
+  /*    face :: A face handle.                                             */
   /*                                                                       */
   /* <Return>                                                              */
-  /*    TRUE if this is a TrueType font that uses one of the patented       */
-  /*    opcodes. FALSE otherwise                                           */
+  /*    1 if this is a TrueType font that uses one of the patented         */
+  /*    opcodes, 0 otherwise.                                              */
   /*                                                                       */
   FT_EXPORT( FT_Bool )
-  FT_Face_CheckTrueTypePatents( FT_Face   face );
+  FT_Face_CheckTrueTypePatents( FT_Face  face );
 
   /* */
 
diff --git a/include/freetype/ftcache.h b/include/freetype/ftcache.h
index e713b25..721aa16 100644
--- a/include/freetype/ftcache.h
+++ b/include/freetype/ftcache.h
@@ -411,14 +411,14 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /*    height  :: The character height.                                   */
   /*                                                                       */
-  /*    pixel   :: A Boolean.  If TRUE, the `width' and `height' fields    */
-  /*               are interpreted as integer pixel character sizes.       */
+  /*    pixel   :: A Boolean.  If 1, the `width' and `height' fields are   */
+  /*               interpreted as integer pixel character sizes.           */
   /*               Otherwise, they are expressed as 1/64th of points.      */
   /*                                                                       */
-  /*    x_res   :: Only used when `pixel' is FALSE to indicate the         */
+  /*    x_res   :: Only used when `pixel' is value 0 to indicate the       */
   /*               horizontal resolution in dpi.                           */
   /*                                                                       */
-  /*    y_res   :: Only used when `pixel' is FALSE to indicate the         */
+  /*    y_res   :: Only used when `pixel' is value 0 to indicate the       */
   /*               vertical resolution in dpi.                             */
   /*                                                                       */
   /* <Note>                                                                */
diff --git a/include/freetype/ftstroke.h b/include/freetype/ftstroke.h
index 6e75921..738b43c 100644
--- a/include/freetype/ftstroke.h
+++ b/include/freetype/ftstroke.h
@@ -297,8 +297,8 @@ FT_BEGIN_HEADER
    *     The source outline.
    *
    *   opened ::
-   *     A boolean.  If TRUE, the outline is treated as an open path
-   *     instead of a closed one.
+   *     A boolean.  If 1, the outline is treated as an open path instead
+   *     of a closed one.
    *
    * @return:
    *   FreeType error code.  0 means success.
@@ -334,7 +334,7 @@ FT_BEGIN_HEADER
    *     A pointer to the start vector.
    *
    *   open ::
-   *     A boolean.  If TRUE, the sub-path is treated as an open one.
+   *     A boolean.  If 1, the sub-path is treated as an open one.
    *
    * @return:
    *   FreeType error code.  0 means success.
@@ -649,7 +649,7 @@ FT_BEGIN_HEADER
    *     A stroker handle.
    *
    *   destroy ::
-   *     A Boolean.  If TRUE, the source glyph object is destroyed
+   *     A Boolean.  If 1, the source glyph object is destroyed
    *     on success.
    *
    * @return:
@@ -682,11 +682,11 @@ FT_BEGIN_HEADER
    *     A stroker handle.
    *
    *   inside ::
-   *     A Boolean.  If TRUE, return the inside border, otherwise
+   *     A Boolean.  If 1, return the inside border, otherwise
    *     the outside border.
    *
    *   destroy ::
-   *     A Boolean.  If TRUE, the source glyph object is destroyed
+   *     A Boolean.  If 1, the source glyph object is destroyed
    *     on success.
    *
    * @return:
diff --git a/include/freetype/fttypes.h b/include/freetype/fttypes.h
index bd036f9..2340bac 100644
--- a/include/freetype/fttypes.h
+++ b/include/freetype/fttypes.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType simple types definitions (specification only).              */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2004, 2006 by                               */
+/*  Copyright 1996-2001, 2002, 2004, 2006, 2007 by                         */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -94,7 +94,8 @@ FT_BEGIN_HEADER
   /*    FT_Bool                                                            */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    A typedef of unsigned char, used for simple booleans.              */
+  /*    A typedef of unsigned char, used for simple booleans.  As usual,   */
+  /*    values 1 and 0 represent true and false, respectively.             */
   /*                                                                       */
   typedef unsigned char  FT_Bool;
 
diff --git a/include/freetype/internal/ftserv.h b/include/freetype/internal/ftserv.h
index ed3e3f0..45d2fa9 100644
--- a/include/freetype/internal/ftserv.h
+++ b/include/freetype/internal/ftserv.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    The FreeType services (specification only).                          */
 /*                                                                         */
-/*  Copyright 2003, 2004, 2005, 2006 by                                    */
+/*  Copyright 2003, 2004, 2005, 2006, 2007 by                              */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
diff --git a/include/freetype/internal/services/svttglyf.h b/include/freetype/internal/services/svttglyf.h
index a91e9ee..e57d484 100644
--- a/include/freetype/internal/services/svttglyf.h
+++ b/include/freetype/internal/services/svttglyf.h
@@ -1,6 +1,6 @@
 /***************************************************************************/
 /*                                                                         */
-/*  svsttglyf.h                                                            */
+/*  svttglyf.h                                                             */
 /*                                                                         */
 /*    The FreeType TrueType glyph service.                                 */
 /*                                                                         */
@@ -42,7 +42,7 @@ FT_BEGIN_HEADER
 
 FT_END_HEADER
 
-#endif /* __SVTTCMAP_H__ */
+#endif /* __SVTTGLYF_H__ */
 
 
 /* END */
diff --git a/modules.cfg b/modules.cfg
index 2311aad..6d8a95e 100644
--- a/modules.cfg
+++ b/modules.cfg
@@ -220,7 +220,7 @@ BASE_EXTENSIONS += ftlcdfil.c
 # See include/freetype/ftgasp.h for the API.
 BASE_EXTENSIONS += ftgasp.c
 
-# Support for FT_Face_CheckTrueTypePatents
+# Support for FT_Face_CheckTrueTypePatents.
 #
 # See include/freetype.h for the API.
 BASE_EXTENSIONS += ftpatent.c
diff --git a/src/base/ftpatent.c b/src/base/ftpatent.c
index 22d0531..a2bda8f 100644
--- a/src/base/ftpatent.c
+++ b/src/base/ftpatent.c
@@ -1,3 +1,20 @@
+/***************************************************************************/
+/*                                                                         */
+/*  ftpatent.c                                                             */
+/*                                                                         */
+/*    FreeType API for checking patented TrueType bytecode instructions    */
+/*    (body).                                                              */
+/*                                                                         */
+/*  Copyright 2007 by David Turner.                                        */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
 #include <ft2build.h>
 #include FT_FREETYPE_H
 #include FT_TRUETYPE_TAGS_H
@@ -6,21 +23,23 @@
 #include FT_SERVICE_SFNT_H
 #include FT_SERVICE_TRUETYPE_GLYF_H
 
+
   static FT_Bool
   _tt_check_patents_in_range( FT_Stream  stream,
                               FT_ULong   size )
   {
-    FT_Bool   result = 0;
+    FT_Bool   result = FALSE;
     FT_Error  error;
     FT_Bytes  p, end;
 
-    if ( FT_FRAME_ENTER(size) )
+
+    if ( FT_FRAME_ENTER( size ) )
       return 0;
 
     p   = stream->cursor;
     end = p + size;
 
-    while (p < end)
+    while ( p < end )
     {
       switch (p[0])
       {
@@ -28,23 +47,23 @@
       case 0x07:  /* SPvTL +  */
       case 0x08:  /* SFvTL // */
       case 0x09:  /* SFvTL +  */
-      case 0x0A:  /* SPvFS */
-      case 0x0B:  /* SFvFS */
-        result = 1;
+      case 0x0A:  /* SPvFS    */
+      case 0x0B:  /* SFvFS    */
+        result = TRUE;
         goto Exit;
 
       case 0x40:
-        if ( p+1 >= end )
+        if ( p + 1 >= end )
           goto Exit;
 
         p += p[1] + 2;
         break;
 
       case 0x41:
-        if ( p+1 >= end )
+        if ( p + 1 >= end )
           goto Exit;
 
-        p += p[1]*2 + 2;
+        p += p[1] * 2 + 2;
         break;
 
       case 0x71:  /* DELTAP2 */
@@ -52,7 +71,7 @@
       case 0x73:  /* DELTAC0 */
       case 0x74:  /* DELTAC1 */
       case 0x75:  /* DELTAC2 */
-        result = 1;
+        result = TRUE;
         goto Exit;
 
       case 0xB0:
@@ -63,7 +82,7 @@
       case 0xB5:
       case 0xB6:
       case 0xB7:
-        p += (p[0] - 0xB0) + 2;
+        p += ( p[0] - 0xB0 ) + 2;
         break;
 
       case 0xB8:
@@ -74,7 +93,7 @@
       case 0xBD:
       case 0xBE:
       case 0xBF:
-        p += (p[0] - 0xB8) * 2 + 3;
+        p += ( p[0] - 0xB8 ) * 2 + 3;
         break;
 
       default:
@@ -96,14 +115,16 @@
     FT_Stream              stream = face->stream;
     FT_Error               error;
     FT_Service_SFNT_Table  service;
-    FT_Bool                result = 0;
+    FT_Bool                result = FALSE;
+
 
     FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
 
-    if (service)
+    if ( service )
     {
       FT_ULong  offset, size;
 
+
       error = service->table_info( face, tag, &offset, &size );
       if ( error                    ||
            FT_STREAM_SEEK( offset ) )
@@ -111,6 +132,7 @@
 
       result = _tt_check_patents_in_range( stream, size );
     }
+
   Exit:
     return result;
   }
@@ -126,40 +148,43 @@
 
     FT_Service_TTGlyf  service;
 
+
     result = _tt_check_patents_in_table( face, TTAG_fpgm );
-    if (result)
+    if ( result )
       goto Exit;
 
     result = _tt_check_patents_in_table( face, TTAG_prep );
-    if (result)
+    if ( result )
       goto Exit;
 
     FT_FACE_FIND_SERVICE( face, service, TT_GLYF );
-    if (service == NULL)
+    if ( service == NULL )
       goto Exit;
 
-    for (gindex = 0; gindex < (FT_UInt)face->num_glyphs; gindex++)
+    for ( gindex = 0; gindex < (FT_UInt)face->num_glyphs; gindex++ )
     {
       FT_ULong  offset, num_ins, size;
       FT_Int    num_contours;
 
+
       offset = service->get_location( face, gindex, &size );
-      if (size == 0)
+      if ( size == 0 )
         continue;
 
-      if ( FT_STREAM_SEEK(offset)      ||
-           FT_READ_SHORT(num_contours) )
+      if ( FT_STREAM_SEEK( offset )      ||
+           FT_READ_SHORT( num_contours ) )
         continue;
 
-      if (num_contours >= 0)  /* simple glyph */
+      if ( num_contours >= 0 )  /* simple glyph */
       {
-        if ( FT_STREAM_SKIP( 8 + num_contours*2 ) )
+        if ( FT_STREAM_SKIP( 8 + num_contours * 2 ) )
           continue;
       }
       else  /* compound glyph */
       {
         FT_Bool  has_instr = 0;
 
+
         if ( FT_STREAM_SKIP( 8 ) )
           continue;
 
@@ -168,56 +193,65 @@
         {
           FT_UInt  flags, toskip;
 
-          if( FT_READ_USHORT(flags) )
+
+          if( FT_READ_USHORT( flags ) )
             break;
 
           toskip = 2 + 1 + 1;
 
-          if ((flags & (1 << 0)) != 0)  /* ARGS_ARE_WORDS */
+          if ( ( flags & ( 1 << 0 ) ) != 0 )       /* ARGS_ARE_WORDS */
             toskip += 2;
 
-          if ((flags & (1 << 3)) != 0)  /* WE_HAVE_A_SCALE */
+          if ( ( flags & ( 1 << 3 ) ) != 0 )       /* WE_HAVE_A_SCALE */
             toskip += 2;
-          else if ((flags & (1 << 6)) != 0)  /* WE_HAVE_X_Y_SCALE */
+          else if ( ( flags & ( 1 << 6 ) ) != 0 )  /* WE_HAVE_X_Y_SCALE */
             toskip += 4;
-          else if ((flags & (1 << 7)) != 0)  /* WE_HAVE_A_2x2 */
+          else if ( ( flags & ( 1 << 7 ) ) != 0 )  /* WE_HAVE_A_2x2 */
             toskip += 8;
 
-          if ((flags & (1 << 8)) != 0)  /* WE_HAVE_INSTRUCTIONS */
+          if ( ( flags & ( 1 << 8 ) ) != 0 )       /* WE_HAVE_INSTRUCTIONS */
             has_instr = 1;
 
           if ( FT_STREAM_SKIP( toskip ) )
             goto NextGlyph;
 
-          if ((flags & (1 << 5)) == 0)  /* MORE_COMPONENTS */
+          if ( ( flags & ( 1 << 5 ) ) == 0 )       /* MORE_COMPONENTS */
             break;
         }
-        if (!has_instr)
+
+        if ( !has_instr )
           goto NextGlyph;
       }
 
-      if ( FT_READ_USHORT(num_ins) )
+      if ( FT_READ_USHORT( num_ins ) )
         continue;
 
       result = _tt_check_patents_in_range( stream, num_ins );
-      if (result)
+      if ( result )
         goto Exit;
 
     NextGlyph:
       ;
     }
+
   Exit:
     return result;
   }
 
+
+  /* documentation is in freetype.h */
+
   FT_EXPORT_DEF( FT_Bool )
-  FT_Face_CheckTrueTypePatents( FT_Face   face )
+  FT_Face_CheckTrueTypePatents( FT_Face  face )
   {
-    FT_Bool  result = 0;
+    FT_Bool  result = FALSE;
 
-    if ( face && FT_IS_SFNT(face) )
-    {
+  
+    if ( face && FT_IS_SFNT( face ) )
       result = _tt_face_check_patents( face );
-    }
-    return  result;
+
+    return result;
   }
+
+
+/* END */
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index 43fc1fe..c2cf452 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -317,7 +317,7 @@
 
   static const FT_Service_TTGlyfRec  tt_service_truetype_glyf =
   {
-    (TT_Glyf_GetLocationFunc)     tt_face_get_location
+    (TT_Glyf_GetLocationFunc)tt_face_get_location
   };
 
   static const FT_ServiceDescRec  tt_services[] =
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 234ecaa..8947055 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -374,7 +374,7 @@
 
       if ( f & 2 )
       {
-        if (p + 1 > limit)
+        if ( p + 1 > limit )
           goto Invalid_Outline;
 
         y = (FT_Pos)FT_NEXT_BYTE( p );
@@ -383,7 +383,7 @@
       }
       else if ( ( f & 16 ) == 0 )
       {
-        if (p + 2 > limit)
+        if ( p + 2 > limit )
           goto Invalid_Outline;
 
         y = (FT_Pos)FT_NEXT_SHORT( p );
@@ -391,7 +391,7 @@
 
       x     += y;
       vec->x = x;
-      *flag  = f & ~(2|16);
+      *flag  = f & ~( 2 | 16 );
     }
 
     /* reading the Y coordinates */
@@ -409,7 +409,7 @@
 
       if ( f & 4 )
       {
-        if (p + 1 > limit)
+        if ( p + 1 > limit )
           goto Invalid_Outline;
 
         y = (FT_Pos)FT_NEXT_BYTE( p );
@@ -418,7 +418,7 @@
       }
       else if ( ( f & 32 ) == 0 )
       {
-        if (p + 2 > limit)
+        if ( p + 2 > limit )
           goto Invalid_Outline;
 
         y = (FT_Pos)FT_NEXT_SHORT( p );
@@ -426,7 +426,7 @@
 
       x     += y;
       vec->y = x;
-      *flag  = f & ~(4|32);
+      *flag  = f & ~( 4 | 32 );
     }
 
     outline->n_points   = (FT_UShort)n_points;