Commit c5cdf8bcf1bded63fbd57853ded641a42292a91c

David Turner 2000-07-27T21:40:22

re-adding a "unix-dev.mk". Debugging libtool output is just too much of a pain for me, I prefer a good old static lib without optimizations :-) "make devel" is back on Unix then..

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
diff --git a/CHANGES b/CHANGES
index d9d5816..8cec032 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,20 @@
 LATEST CHANGES
 
+  - fixed two memory leaks:
+       - the memory manager (16 bytes) isn't released in FT_Done_FreeType !!
+       
+       - using custom input streams, the copy of the original stream
+         was never released
+
+  - fixed the auto-hinter by performing automatic computation of the
+    "filling direction" of each glyph. This is done through a simple and
+    fast approximation, and seems to work (problems spotted by Werner
+    though). The Arphic fonts are a lot nicer though there are still a
+    lot of things to do to handle Asian fonts correctly..
+
+===========================================================================
+BETA-8 (RELEASE CANDIDATE) CHANGES
+
   - deactivated the trueType bytecode interpreter by default
   
   - deactivated the "src/type1" font driver. Now "src/type1z" is
diff --git a/builds/unix/detect.mk b/builds/unix/detect.mk
index dec1baa..6d7f6ea 100644
--- a/builds/unix/detect.mk
+++ b/builds/unix/detect.mk
@@ -22,30 +22,29 @@ ifeq ($(PLATFORM),ansi)
     COPY     := cp
     DELETE   := rm -f
 
-    # If a Unix platform is detected, the configure script is called and
-    # `unix.mk' is created.
-    #
-    # Arguments to `configure' should be in the CFG variable.  Example:
-    #
-    #   make CFG="--prefix=/usr --disable-static"
-    #
-    # If you need to set CFLAGS or LDFLAGS, do it here also.
-    #
-    # Feel free to add support for other platform specific compilers in this
-    # directory (e.g. solaris.mk + changes here to detect the platform).
-    #
-    CONFIG_FILE := unix.mk
-    setup: unix.mk
-    unix: setup
 
-    # If `devel' is the requested target, use `-g -O0' as the default value
-    # for CFLAGS if CFLAGS isn't set.
+    # If `devel' is the requested target, we use a special configuration
+    # file named "unix-dev.mk". It disables optimization and libtool..
     #
     ifneq ($(findstring devel,$(MAKECMDGOALS)),)
-      ifndef CFLAGS
-        USE_CFLAGS := CFLAGS="-g -O0"
-      endif
+      CONFIG_FILE := unix-dev.mk
       devel: setup
+    else
+      # If a Unix platform is detected, the configure script is called and
+      # `unix.mk' is created.
+      #
+      # Arguments to `configure' should be in the CFG variable.  Example:
+      #
+      #   make CFG="--prefix=/usr --disable-static"
+      #
+      # If you need to set CFLAGS or LDFLAGS, do it here also.
+      #
+      # Feel free to add support for other platform specific compilers in this
+      # directory (e.g. solaris.mk + changes here to detect the platform).
+      #
+      CONFIG_FILE := unix.mk
+      setup: unix.mk
+      unix: setup
     endif
 
     setup: std_setup
diff --git a/builds/unix/ftsystem.c b/builds/unix/ftsystem.c
index 9ecd95c..cb9ce8b 100644
--- a/builds/unix/ftsystem.c
+++ b/builds/unix/ftsystem.c
@@ -302,5 +302,21 @@
     return memory;
   }
 
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    FT_Done_Memory                                                     */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Discards memory manager.                                           */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    memory  :: handle to memory manager                                */
+  /*                                                                       */
+  FT_EXPORT_FUNC( void )  FT_Done_Memory( FT_Memory  memory )
+  {
+    free( memory );
+  }
+
 
 /* END */
diff --git a/builds/unix/unix-dev.mk b/builds/unix/unix-dev.mk
new file mode 100644
index 0000000..6f24a58
--- /dev/null
+++ b/builds/unix/unix-dev.mk
@@ -0,0 +1,140 @@
+#
+# FreeType 2 Configuration rules for Unix + GCC
+#
+#   Development version without optimizations & libtool
+#
+
+
+# Copyright 1996-2000 by
+# David Turner, Robert Wilhelm, and Werner Lemberg.
+#
+# 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.
+#
+# NOTE: This version requires that GNU Make is invoked from the Windows
+#       Shell (_not_ Cygwin BASH)!
+#
+
+ifndef TOP
+  TOP := .
+endif
+
+DELETE   := rm -f
+SEP      := /
+HOSTSEP  := $(SEP)
+BUILD    := $(TOP)/builds/unix
+PLATFORM := unixdev  # do not set it to "unix", or libtool will trick you..
+CC       := gcc
+
+# The directory where all object files are placed.
+#
+# Note that this is not $(TOP)/obj!
+# This lets you build the library in your own directory with something like
+#
+#   set TOP=.../path/to/freetype2/top/dir...
+#   mkdir obj
+#   make -f %TOP%/Makefile setup [options]
+#   make -f %TOP%/Makefile
+#
+OBJ_DIR := obj
+
+
+# The directory where all library files are placed.
+#
+# By default, this is the same as $(OBJ_DIR), however, this can be changed
+# to suit particular needs.
+#
+LIB_DIR := $(OBJ_DIR)
+
+
+# The object file extension (for standard and static libraries).  This can be
+# .o, .tco, .obj, etc., depending on the platform.
+#
+O  := o
+SO := o
+
+# The library file extension (for standard and static libraries).  This can
+# be .a, .lib, etc., depending on the platform.
+#
+A  := a
+SA := a
+
+
+# The name of the final library file.  Note that the DOS-specific Makefile
+# uses a shorter (8.3) name.
+#
+LIBRARY := libfreetype
+
+
+# Path inclusion flag.  Some compilers use a different flag than `-I' to
+# specify an additional include path.  Examples are `/i=' or `-J'.
+#
+I := -I
+
+
+# C flag used to define a macro before the compilation of a given source
+# object.  Usually is `-D' like in `-DDEBUG'.
+#
+D := -D
+
+
+# The link flag used to specify a given library file on link.  Note that
+# this is only used to compile the demo programs, not the library itself.
+#
+L := -l
+
+
+# Target flag.
+#
+T := -o # Don't remove this comment line!  We need the space after `-o'.
+
+
+# C flags
+#
+#   These should concern: debug output, optimization & warnings.
+#
+#   Use the ANSIFLAGS variable to define the compiler flags used to enfore
+#   ANSI compliance.
+#
+ifndef CFLAGS
+  CFLAGS := -c -g -O0 -Wall -W
+endif
+
+# ANSIFLAGS: Put there the flags used to make your compiler ANSI-compliant.
+#
+ANSIFLAGS := -ansi -pedantic
+
+
+ifdef BUILD_FREETYPE
+
+  # Now include the main sub-makefile.  It contains all the rules used to
+  # build the library with the previous variables defined.
+  #
+  include $(TOP)/builds/freetype.mk
+
+  # The cleanup targets.
+  #
+  clean_freetype: clean_freetype_std
+  distclean_freetype: distclean_freetype_std
+
+  # Librarian to use to build the static library
+  #
+  FT_LIBRARIAN := $(AR) -r
+
+
+  # This final rule is used to link all object files into a single library. 
+  # It is part of the system-specific sub-Makefile because not all
+  # librarians accept a simple syntax like
+  #
+  #   librarian library_file {list of object files} 
+  #
+  $(FT_LIBRARY): $(OBJECTS_LIST)
+	  -$(DELETE) $(subst $(SEP),$(HOSTSEP),$(FT_LIBRARY)) 2> nul
+	  $(FT_LIBRARIAN) $@ $(OBJECTS_LIST)
+
+endif
+
+# EOF
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index 0d0f5d8..05b8dcf 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -506,6 +506,7 @@
 
   FT_EXPORT_DEF( FT_Memory )  FT_New_Memory( void );
 
+  FT_EXPORT_DEF( void )       FT_Done_Memory( FT_Memory  memory );
 
 #endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */
 
diff --git a/src/autohint/ahglyph.c b/src/autohint/ahglyph.c
index 7e0ad47..2037f42 100644
--- a/src/autohint/ahglyph.c
+++ b/src/autohint/ahglyph.c
@@ -322,10 +322,13 @@
       outline->max_contours = new_contours;
     }
 
-    /* then, realloc the points, segments & edges arrays if needed */
-    if ( num_points > outline->max_points )
+    /* then, realloc the points, segments & edges arrays if needed   */
+    /* note that we reserved two additional point positions, used to */
+    /* hint metrics appropriately..                                  */
+    /*                                                               */
+    if ( num_points+2 > outline->max_points )
     {
-      FT_Int  news = ( num_points + 7 ) & -8;
+      FT_Int  news = ( num_points+2 + 7 ) & -8;
       FT_Int  max  = outline->max_points;
 
 
diff --git a/src/base/ftinit.c b/src/base/ftinit.c
index cc754eb..cba8f7c 100644
--- a/src/base/ftinit.c
+++ b/src/base/ftinit.c
@@ -152,4 +152,38 @@ const FT_Module_Class*  ft_default_modules[] =
   }
 
 
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    FT_Done_FreeType                                                   */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Destroys a given FreeType library object and all of its childs,    */
+  /*    including resources, drivers, faces, sizes, etc.                   */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    library :: A handle to the target library object.                  */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    FreeType error code.  0 means success.                             */
+  /*                                                                       */
+  FT_EXPORT_FUNC( FT_Error )  FT_Done_FreeType( FT_Library  library )
+  {
+    if (library)
+    {
+      FT_Memory  memory = library->memory;
+
+
+      /* Discard the library object */
+      FT_Done_Library( library );
+      
+      /* discard memory manager */
+      FT_Done_Memory( memory );
+    }
+
+    return FT_Err_Ok;
+  }
+
+
+
 /* END */
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index de74882..3ddd5c7 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -265,8 +265,10 @@
     }
     else if ( args->flags & ft_open_stream && args->stream )
     {
-      *stream        = *(args->stream);
-      stream->memory = memory;
+      /* in this case, we do not need to allocate a new stream      */
+      /* object. The caller is responsible for closing it himself!! */
+      FREE(stream);
+      stream = args->stream;
     }
     else
       error = FT_Err_Invalid_Argument;
@@ -300,16 +302,19 @@
 
 
   static
-  void  ft_done_stream( FT_Stream*  astream )
+  void  ft_done_stream( FT_Stream*  astream, FT_Int  external )
   {
     FT_Stream  stream = *astream;
-    FT_Memory  memory = stream->memory;
 
 
     if ( stream->close )
       stream->close( stream );
 
-    FREE( stream );
+    if (!external)
+    {
+      FT_Memory  memory = stream->memory;
+      FREE( stream );
+    }
     *astream = 0;
   }
 
@@ -1146,8 +1151,8 @@
       clazz->done_face( face );
 
     /* close the stream for this face if needed */
-    if ( ( face->face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) == 0 )
-      ft_done_stream( &face->stream );
+    ft_done_stream( &face->stream,
+                    (face->face_flags & FT_FACE_FLAG_EXTERNAL_STREAM) != 0 );
 
     /* get rid of it */
     FREE( face );
@@ -1392,7 +1397,7 @@
     FT_Stream    stream;
     FT_Face      face = 0;
     FT_ListNode  node = 0;
-
+    FT_Bool      external_stream;
 
     /* test for valid `library' and `args' delayed to */
     /* ft_new_input_stream()                          */
@@ -1402,6 +1407,8 @@
 
     *aface = 0;
 
+    external_stream = ( args->flags & ft_open_stream && args->stream );
+
     /* create input stream */
     error = ft_new_input_stream( library, args, &stream );
     if ( error )
@@ -1436,7 +1443,7 @@
       else
         error = FT_Err_Invalid_Handle;
 
-      ft_done_stream( &stream );
+      ft_done_stream( &stream, external_stream );
       goto Fail;
     }
     else
@@ -1473,7 +1480,7 @@
         }
       }
 
-      ft_done_stream( &stream );
+      ft_done_stream( &stream, external_stream );
 
       /* no driver is able to handle this format */
       error = FT_Err_Unknown_File_Format;
@@ -1484,7 +1491,7 @@
     FT_TRACE4(( "FT_New_Face: New face object, adding to list\n" ));
 
     /* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */
-    if ( args->flags & ft_open_stream && args->stream )
+    if ( external_stream )
       face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM;
 
     /* add the face object to its driver's list */
@@ -1654,8 +1661,9 @@
       error = clazz->attach_file( face, stream );
 
     /* close the attached stream */
-    if ( !parameters->stream || ( parameters->flags & ft_open_stream ) )
-      ft_done_stream( &stream );
+    ft_done_stream( &stream,
+                    (FT_Bool)(parameters->stream &&
+                             (parameters->flags & ft_open_stream)) );
 
   Exit:
     return error;
@@ -3217,30 +3225,4 @@
   }
 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    FT_Done_FreeType                                                   */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Destroys a given FreeType library object and all of its childs,    */
-  /*    including resources, drivers, faces, sizes, etc.                   */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    library :: A handle to the target library object.                  */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    FreeType error code.  0 means success.                             */
-  /*                                                                       */
-  FT_EXPORT_FUNC( FT_Error )  FT_Done_FreeType( FT_Library  library )
-  {
-    /* test for valid `library' delayed to FT_Done_Library() */
-
-    /* Discard the library object */
-    FT_Done_Library( library );
-
-    return FT_Err_Ok;
-  }
-
-
 /* END */
diff --git a/src/base/ftsystem.c b/src/base/ftsystem.c
index b99b0ea..52167b0 100644
--- a/src/base/ftsystem.c
+++ b/src/base/ftsystem.c
@@ -296,4 +296,20 @@
   }
 
 
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    FT_Done_Memory                                                     */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Discards memory manager.                                           */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    memory  :: handle to memory manager                                */
+  /*                                                                       */
+  FT_EXPORT_FUNC( void )  FT_Done_Memory( FT_Memory  memory )
+  {
+    free( memory );
+  }
+
 /* END */
diff --git a/src/psnames/psnames.c b/src/psnames/psnames.c
index 0491b48..0344129 100644
--- a/src/psnames/psnames.c
+++ b/src/psnames/psnames.c
@@ -18,7 +18,7 @@
 
 #define FT_MAKE_OPTION_SINGLE_OBJECT
 
-#include <psmodule.c>
+#include <psnames/psmodule.c>
 
 
 /* END */
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 6823cb1..afdc157 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -539,6 +539,8 @@
     FT_Error         error    = FT_Err_Ok;
 
 
+    FT_UNUSED(debug);  /* used by truetype interpreter only */
+    
     n_ins = load->glyph->control_len;
 
     /* add shadow points */
@@ -674,7 +676,8 @@
     FT_GlyphLoader*  gloader = loader->gloader;
     FT_Bool          opened_frame = 0;
 
-
+    FT_UNUSED(stream);  /* used with bytecode interpreter only */
+    
     /* check glyph index */
     index = glyph_index;
     if ( index >= (FT_UInt)face->root.num_glyphs )
diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c
index b477366..01685f2 100644
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -143,7 +143,6 @@
 
     return error;
   }
-
 #endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
 
 
@@ -730,7 +729,8 @@
       TT_Destroy_Context( driver->context, driver->root.root.memory );
       driver->context = NULL;
     }
-
+#else
+    FT_UNUSED(driver);
 #endif
 
   }
diff --git a/src/truetype/ttobjs.h b/src/truetype/ttobjs.h
index bb00d08..8f0759d 100644
--- a/src/truetype/ttobjs.h
+++ b/src/truetype/ttobjs.h
@@ -119,6 +119,7 @@
 #endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
 
 
+
   /*************************************************************************/
   /*                                                                       */
   /*  EXECUTION SUBTABLES                                                  */