Commit 960ba59ad95d67c56df4bf22aa1881c48548b2ee

Werner Lemberg 2006-12-01T08:20:47

* src/sfnt/sfobjs.c (tt_face_get_name): All Unicode strings are encoded in UTF-16BE. Patch from Rajeev Pahuja <rpahuja@esri.com>. (tt_name_entry_ascii_from_ucs4): Removed. * include/freetype/ftxf86.h: Fix and extend comment so that it appears in the documentation. * include/freetype/ftchapters.h: Add `font_format' section. * src/tools/docmaker/tohtml.py (HtmlFormatter::index_exit): Add link to TOC in index page. Formatting.

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
diff --git a/ChangeLog b/ChangeLog
index 9cb6e1a..463c3fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,30 +1,61 @@
-2006-11-28  David Turner    <david@freetype.org>
+2006-12-01  Werner Lemberg  <wl@gnu.org>
 
-    * src/smooth/ftgrays.c (gray_raster_render): return 0 when we're
-    trying to rendering into a zero-width/height bitmap, instead of an
-    error code.
+	* src/sfnt/sfobjs.c (tt_face_get_name): All Unicode strings are
+	encoded in UTF-16BE.  Patch from Rajeev Pahuja <rpahuja@esri.com>.
+	(tt_name_entry_ascii_from_ucs4): Removed.
 
-    * src/truetype/ttobjs.c (tt_face_init): Fix typo in previous patch
 
-    * src/smooth/ftgrays.c: remove hard-coded error values, use FreeType
-    ones instead
+	* include/freetype/ftxf86.h: Fix and extend comment so that it
+	appears in the documentation.
 
-    * src/autofit/afhints.c (af_glyph_hints_dump_segments): remove unused
-    variable
+	* include/freetype/ftchapters.h: Add `font_format' section.
+
+
+	* src/tools/docmaker/tohtml.py (HtmlFormatter::index_exit): Add link
+	to TOC in index page.
+
+2006-11-28  David Turner  <david@freetype.org>
+
+	* src/smooth/ftgrays.c (gray_raster_render): Return 0 when we are
+	trying to render into a zero-width/height bitmap, not an error code.
+
+	* src/truetype/ttobjs.c (tt_face_init): Fix typo in previous patch.
+
+	* src/smooth/ftgrays.c: Remove hard-coded error values; use FreeType
+	ones instead.
+
+	* src/autofit/afhints.c (af_glyph_hints_dump_segments): Remove unused
+	variable.
 
 2006-11-26  Pierre Hanser  <hanser@club-internet.fr>
 
 	* src/truetype/ttobjs.c (tt_face_init): Protect against NULL pointer.
 
-2006-11-25  David Turner    <david@freetype.org>
+2006-11-25  David Turner  <david@freetype.org>
 
-        * src/autofit/afhints.c: add stubs to link the "ftgrid" test program
-        when debugging is disabled in the auto-hinter
+	* src/autofit/afhints.c	(af_glyph_hints_dump_points,
+	af_glyph_hints_dump_segments, af_glyph_hints_dumpedges) [!AF_DEBUG]:
+	Add stubs to link the `ftgrid' test program when debugging is
+	disabled in the auto-hinter.
 
-2006-11-23  David Turner    <david@freetype.org>
+2006-11-23  David Turner  <david@freetype.org>
 
 	* src/autofit/afhints.c, src/autofit/afhints.h, src/autofit/aflatin.c,
-	src/autofit/aftypes.h: Misc. auto-hinter improvements
+	src/autofit/aftypes.h: Miscellaneous auto-hinter improvements.
+
+	* src/autofit/afhints.c (af_glyph_hints_dump_segments) [AF_DEBUG]:
+	Emit more sensible information.
+
+	* src/autofit/afhints.h (AF_SegmentRec): Add `height' member.
+
+	* src/autofit/aflatin.c (af_latin_metrics_scale_dim): Improve
+	rounding of blue values.
+	(af_latin_hints_compute_segments): Hint segment heights.
+	(af_latin_hints_link_segments): Reduce `len_score' value.
+	(af_latin_hints_compute_edges): Increase `segment_length_threshold'
+	value and use `height' member for comparisons.
+	(af_latin_hint_edges): Extend logging message.
+	Improve handling of remaining edges.
 
 2006-11-22  Werner Lemberg  <wl@gnu.org>
 
diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
index c6caa1b..c590ddc 100644
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -77,7 +77,7 @@ FT_BEGIN_HEADER
 
   /*************************************************************************/
   /*                                                                       */
-  /* Uncomment the line below if you want to active sub-pixel rendering    */
+  /* Uncomment the line below if you want to activate sub-pixel rendering  */
   /* (a.k.a. LCD rendering, or ClearType) in this build of the library.    */
   /*                                                                       */
   /* Note that this feature is covered by several Microsoft patents        */
diff --git a/include/freetype/ftchapters.h b/include/freetype/ftchapters.h
index 477daa5..f950cee 100644
--- a/include/freetype/ftchapters.h
+++ b/include/freetype/ftchapters.h
@@ -56,6 +56,7 @@
 /*    bdf_fonts                                                            */
 /*    pfr_fonts                                                            */
 /*    winfnt_fonts                                                         */
+/*    font_formats                                                         */
 /*                                                                         */
 /***************************************************************************/
 
diff --git a/include/freetype/ftlcdfil.h b/include/freetype/ftlcdfil.h
index 3a311d4..a6559da 100644
--- a/include/freetype/ftlcdfil.h
+++ b/include/freetype/ftlcdfil.h
@@ -102,13 +102,13 @@ FT_BEGIN_HEADER
    *   @FT_LCD_FILTER_NONE in order to enable it.
    *
    *   Due to *PATENTS* covering subpixel rendering, this function doesn't
-   *   do anything except returning @FT_Err_Unimplemented_Feature if the
+   *   do anything except returning `FT_Err_Unimplemented_Feature' if the
    *   configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not
    *   defined in your build of the library, which should correspond to all
    *   default builds of the library.
    *
    *   The filter affects glyph bitmaps rendered through @FT_Render_Glyph,
-   *   @FT_Glyph_Get_Bitmap, @FT_Load_Glyph, and @FT_Load_Char.
+   *   @FT_Outline_Get_Bitmap, @FT_Load_Glyph, and @FT_Load_Char.
    *
    *   It does _not_ affect the output of @FT_Outline_Render and
    *   @FT_Outline_Get_Bitmap.
diff --git a/include/freetype/ftxf86.h b/include/freetype/ftxf86.h
index 3362883..bf1c693 100644
--- a/include/freetype/ftxf86.h
+++ b/include/freetype/ftxf86.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Support functions for X11.                                           */
 /*                                                                         */
-/*  Copyright 2002, 2003, 2004 by                                          */
+/*  Copyright 2002, 2003, 2004, 2006 by                                    */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -31,24 +31,44 @@
 
 FT_BEGIN_HEADER
 
-  /* this comment is intentionally disabled for now, to prevent this       */
-  /* function from appearing in the API Reference.                         */
 
-  /*@***********************************************************************/
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Section>                                                             */
+  /*   font_formats                                                        */
+  /*                                                                       */
+  /* <Title>                                                               */
+  /*   Font Formats                                                        */
+  /*                                                                       */
+  /* <Abstract>                                                            */
+  /*   Getting the font format.                                            */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*   The single function in this section can be used to get the font     */
+  /*   format.  Note that this information is not needed normally;         */
+  /*   however, there are special cases (like in PDF devices) where it is  */
+  /*   important to differentiate, inspite of FreeType's uniform API.      */
+  /*                                                                       */
+  /*************************************************************************/
+
+
+  /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
-  /*    FT_Get_X11_Font_Format                                             */
+  /*   FT_Get_X11_Font_Format                                              */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    Return a string describing the format of a given face as an X11    */
-  /*    FONT_PROPERTY.  It should only be used by the FreeType 2 font      */
-  /*    backend of the XFree86 font server.                                */
+  /*   Return a string describing the format of a given face, using values */
+  /*   which can be used as an X11 FONT_PROPERTY.  Possible values are     */
+  /*   `TrueType', `Type 1', `BDF', `PCF', `Type 42', `CID Type 1', `CFF', */
+  /*   `PFR', and `Windows FNT'.                                           */
   /*                                                                       */
   /* <Input>                                                               */
-  /*    face :: Input face handle.                                         */
+  /*   face ::                                                             */
+  /*     Input face handle.                                                */
   /*                                                                       */
   /* <Return>                                                              */
-  /*    Font format string.  NULL in case of error.                        */
+  /*   Font format string.  NULL in case of error.                         */
   /*                                                                       */
   FT_EXPORT( const char* )
   FT_Get_X11_Font_Format( FT_Face  face );
diff --git a/src/autofit/afhints.c b/src/autofit/afhints.c
index 264a70b..d682ddb 100644
--- a/src/autofit/afhints.c
+++ b/src/autofit/afhints.c
@@ -216,7 +216,7 @@
                  AF_INDEX_NUM( seg->link, segments ),
                  AF_INDEX_NUM( seg->serif, segments ),
                  seg->height,
-                 seg->height - (seg->max_coord - seg->min_coord) );
+                 seg->height - ( seg->max_coord - seg->min_coord ) );
       }
       printf( "\n" );
     }
@@ -263,29 +263,32 @@
     }
   }
 
-#else
- /* these empty stubs are only used to link the "ftgrid" test program
-  * when debugging is disabled
-  */
+#else /* !AF_DEBUG */
+
+  /* these empty stubs are only used to link the `ftgrid' test program */
+  /* when debugging is disabled                                        */
+
   void
   af_glyph_hints_dump_points( AF_GlyphHints  hints )
   {
-    FT_UNUSED(hints);
+    FT_UNUSED( hints );
   }
 
+
   void
   af_glyph_hints_dump_segments( AF_GlyphHints  hints )
   {
-    FT_UNUSED(hints);
+    FT_UNUSED( hints );
   }
 
+
   void
   af_glyph_hints_dump_edges( AF_GlyphHints  hints )
   {
-    FT_UNUSED(hints);
+    FT_UNUSED( hints );
   }
 
-#endif /* AF_DEBUG */
+#endif /* !AF_DEBUG */
 
 
   /* compute the direction value of a given vector */
diff --git a/src/autofit/afhints.h b/src/autofit/afhints.h
index 3bde12f..c889aad 100644
--- a/src/autofit/afhints.h
+++ b/src/autofit/afhints.h
@@ -125,7 +125,7 @@ FT_BEGIN_HEADER
     FT_Short    pos;         /* position of segment                 */
     FT_Short    min_coord;   /* minimum coordinate of segment       */
     FT_Short    max_coord;   /* maximum coordinate of segment       */
-    FT_Short    height;
+    FT_Short    height;      /* the hinted segment height           */
 
     AF_Edge     edge;        /* the segment's parent edge           */
     AF_Segment  edge_next;   /* link to next segment in parent edge */
diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c
index 91391fc..c97fc62 100644
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -471,7 +471,7 @@
       if ( blue )
       {
         FT_Pos  scaled = FT_MulFix( blue->shoot.org, scaler->y_scale );
-        FT_Pos  fitted = (scaled + 40) & ~63;
+        FT_Pos  fitted = ( scaled + 40 ) & ~63;
 
 
         if ( scaled != fitted )
@@ -772,20 +772,21 @@
     } /* contours */
 
 
-   /* now slightly increase the height of segments when this makes sense
-    * this is used to better detect and ignore serifs
-    */
+    /* now slightly increase the height of segments when this makes */
+    /* sense -- this is used to better detect and ignore serifs     */
     {
-      AF_Segment  segments      = axis->segments;
+      AF_Segment  segments     = axis->segments;
       AF_Segment  segments_end = segments + axis->num_segments;
 
+
       for ( segment = segments; segment < segments_end; segment++ )
       {
-        AF_Point  first = segment->first;
-        AF_Point  last  = segment->last;
+        AF_Point  first   = segment->first;
+        AF_Point  last    = segment->last;
         FT_Pos    first_v = first->v;
         FT_Pos    last_v  = last->v;
 
+
         if ( first == last )
           continue;
 
@@ -793,25 +794,27 @@
         {
           AF_Point  p;
 
+
           p = first->prev;
           if ( p->v < first_v )
-            segment->height += (first_v - p->v) >> 1;
+            segment->height += ( first_v - p->v ) >> 1;
 
           p = last->next;
           if ( p->v > last_v )
-            segment->height += (p->v - last_v) >> 1;
+            segment->height += ( p->v - last_v ) >> 1;
         }
         else
         {
           AF_Point  p;
 
+
           p = first->prev;
           if ( p->v > first_v )
-            segment->height += (p->v - first_v) >> 1;
+            segment->height += ( p->v - first_v ) >> 1;
 
           p = last->next;
           if ( p->v < last_v )
-            segment->height += (last_v - p->v) >> 1;
+            segment->height += ( last_v - p->v ) >> 1;
         }
       }
     }
@@ -1841,9 +1844,11 @@
         else
           edge->pos = FT_PIX_ROUND( edge->opos );
 
-        AF_LOG(( "ANCHOR: edge %d (opos=%.2f) and %d (opos=%.2f) snapped to (%.2f) (%.2f)\n",
-                 edge-edges, edge->opos / 64., edge2-edges, edge2->opos/64.,
-                 edge->pos / 64., edge2->pos / 64. ));
+        AF_LOG(( "ANCHOR: edge %d (opos=%.2f) and %d (opos=%.2f) "
+                 "snapped to (%.2f) (%.2f)\n",
+                 edge-edges, edge->opos / 64.0,
+                 edge2-edges, edge2->opos / 64.0,
+                 edge->pos / 64.0, edge2->pos / 64.0 ));
         anchor = edge;
 
         edge->flags |= AF_EDGE_DONE;
@@ -2020,10 +2025,12 @@
       {
         FT_Pos  delta;
 
+
         if ( edge->flags & AF_EDGE_DONE )
           continue;
 
         delta = 1000;
+
         if ( edge->serif )
         {
           delta = edge->serif->opos - edge->opos;
@@ -2031,45 +2038,49 @@
             delta = -delta;
         }
 
-        if ( delta < 64+16 )
+        if ( delta < 64 + 16 )
         {
           af_latin_align_serif_edge( hints, edge->serif, edge );
-          AF_LOG(( "SERIF: edge %d (opos=%.2f) serif to %d (opos=%.2f) aligned to (%.2f)\n", edge-edges,
-                   edge->opos/64., edge->serif - edges, edge->serif->opos/64., edge->pos/64.0 ));
+          AF_LOG(( "SERIF: edge %d (opos=%.2f) serif to %d (opos=%.2f) "
+                   "aligned to (%.2f)\n",
+                   edge-edges, edge->opos / 64.0,
+                   edge->serif - edges, edge->serif->opos / 64.0,
+                   edge->pos / 64.0 ));
         }
         else if ( !anchor )
         {
           AF_LOG(( "SERIF_ANCHOR: edge %d (opos=%.2f) snapped to (%.2f)\n",
-                   edge-edges, edge->opos/64., edge->pos/64. ));
+                   edge-edges, edge->opos / 64.0, edge->pos / 64.0 ));
           edge->pos = FT_PIX_ROUND( edge->opos );
           anchor    = edge;
         }
         else
         {
-          AF_Edge   before, after;
+          AF_Edge  before, after;
 
-          for ( before = edge-1; before >= edges; before-- )
+
+          for ( before = edge - 1; before >= edges; before-- )
             if ( before->flags & AF_EDGE_DONE )
-                break;
+              break;
 
-          for ( after = edge+1; after < edge_limit; after++ )
+          for ( after = edge + 1; after < edge_limit; after++ )
             if ( after->flags & AF_EDGE_DONE )
-                break;
+              break;
 
-          if ( before >= edges && before < edge &&
-               after  < edge_limit && after > edge )
-          {
-              edge->pos = before->pos + FT_MulDiv( edge->opos - before->opos,
-                                                   after->pos - before->pos,
-                                                   after->opos - before->opos );
-          }
+          if ( before >= edges && before < edge   &&
+               after < edge_limit && after > edge )
+            edge->pos = before->pos +
+                          FT_MulDiv( edge->opos - before->opos,
+                                     after->pos - before->pos,
+                                     after->opos - before->opos );
           else
-              edge->pos = anchor->pos +
+            edge->pos = anchor->pos +
                           FT_PIX_ROUND( edge->opos - anchor->opos );
 
           AF_LOG(( "SERIF_LINK: edge %d (opos=%.2f) snapped to (%.2f)\n",
-                   edge-edges, edge->opos/64., edge->pos/64. ));
+                   edge-edges, edge->opos / 64.0, edge->pos / 64.0 ));
         }
+
         edge->flags |= AF_EDGE_DONE;
 
         if ( edge > edges && edge->pos < edge[-1].pos )
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index 0b9a6e7..32a5848 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -75,37 +75,6 @@
   }
 
 
-  /* convert a UCS-4 name entry to ASCII */
-  static FT_String*
-  tt_name_entry_ascii_from_ucs4( TT_NameEntry  entry,
-                                 FT_Memory     memory )
-  {
-    FT_String*  string;
-    FT_UInt     len, code, n;
-    FT_Byte*    read = (FT_Byte*)entry->string;
-    FT_Error    error;
-
-
-    len = (FT_UInt)entry->stringLength / 4;
-
-    if ( FT_NEW_ARRAY( string, len + 1 ) )
-      return NULL;
-
-    for ( n = 0; n < len; n++ )
-    {
-      code = (FT_UInt)FT_NEXT_ULONG( read );
-      if ( code < 32 || code > 127 )
-        code = '?';
-
-      string[n] = (char)code;
-    }
-
-    string[len] = 0;
-
-    return string;
-  }
-
-
   /* convert an Apple Roman or symbol name entry to ASCII */
   static FT_String*
   tt_name_entry_ascii_from_other( TT_NameEntry  entry,
@@ -253,13 +222,11 @@
       rec = face->name_table.names + found_win;
       switch ( rec->encodingID )
       {
+        /* all Unicode strings are encoded using UTF-16BE */
       case TT_MS_ID_UNICODE_CS:
       case TT_MS_ID_SYMBOL_CS:
-        convert = tt_name_entry_ascii_from_utf16;
-        break;
-
       case TT_MS_ID_UCS_4:
-        convert = tt_name_entry_ascii_from_ucs4;
+        convert = tt_name_entry_ascii_from_utf16;
         break;
 
       default:
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index e17a5b5..e616795 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -1783,17 +1783,17 @@
       return ErrRaster_Invalid_Outline;
 
     /* if direct mode is not set, we must have a target bitmap */
-    if ( (params->flags & FT_RASTER_FLAG_DIRECT) == 0 )
+    if ( ( params->flags & FT_RASTER_FLAG_DIRECT ) == 0 )
     {
-        if ( !target_map )
-            return ErrRaster_Invalid_Argument;
+      if ( !target_map )
+        return ErrRaster_Invalid_Argument;
 
-        /* nothing to do */
-        if ( !target_map->width || !target_map->rows )
-            return 0;
+      /* nothing to do */
+      if ( !target_map->width || !target_map->rows )
+        return 0;
 
-        if ( !target_map->buffer )
-            return ErrRaster_Invalid_Argument;
+      if ( !target_map->buffer )
+        return ErrRaster_Invalid_Argument;
     }
 
     /* this version does not support monochrome rendering */
diff --git a/src/tools/docmaker/tohtml.py b/src/tools/docmaker/tohtml.py
index bf4f609..63c123d 100644
--- a/src/tools/docmaker/tohtml.py
+++ b/src/tools/docmaker/tohtml.py
@@ -107,6 +107,16 @@ chapter_header = '<br><table align=center width="75%"><tr><td><h2>'
 chapter_inter  = '</h2><ul class="empty"><li>'
 chapter_footer = '</li></ul></td></tr></table>'
 
+# Index footer.
+index_footer_start = """\
+<hr>
+<table><tr><td width="100%"></td>
+<td><font size=-2>[<a href="
+"""
+index_footer_end = """\
+">TOC</a>]</font></td></tr></table>
+"""
+
 
 # source language keyword coloration/styling
 #
@@ -360,7 +370,7 @@ class HtmlFormatter(Formatter):
 
         # block_index already contains the sorted list of index names
         count = len( self.block_index )
-        rows  = (count + self.columns - 1)/self.columns
+        rows  = (count + self.columns - 1) / self.columns
 
         print "<table align=center border=0 cellpadding=0 cellspacing=0>"
         for r in range(rows):
@@ -377,7 +387,11 @@ class HtmlFormatter(Formatter):
             print line
 
         print "</table>"
-        print self.html_footer
+
+        print index_footer_start + \
+              self.file_prefix + "toc.html" + \
+              index_footer_end
+
         self.index_items = {}
 
     def  index_dump( self, index_filename = None ):