[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

X Strike Force SVN commit: rev 123 - in people/jch/xc/lib/font/FreeType: . module



Author: jch
Date: 2003-06-02 16:05:19 -0500 (Mon, 02 Jun 2003)
New Revision: 123

Modified:
   people/jch/xc/lib/font/FreeType/Imakefile
   people/jch/xc/lib/font/FreeType/ft.h
   people/jch/xc/lib/font/FreeType/ftenc.c
   people/jch/xc/lib/font/FreeType/ftfuncs.c
   people/jch/xc/lib/font/FreeType/ftfuncs.h
   people/jch/xc/lib/font/FreeType/ftmodule.h
   people/jch/xc/lib/font/FreeType/ftoption.h
   people/jch/xc/lib/font/FreeType/fttools.c
   people/jch/xc/lib/font/FreeType/module/Imakefile
   people/jch/xc/lib/font/FreeType/module/ftmodule.c
Log:
Made the FreeType backend grok bitmap fonts (PCF, BDF and SFNT).  This
corresponds to XFree86 bugzilla 325.

By itself, this won't do anything useful as the fontfile layer hasn't yet
been modified to pass bitmap entries to scalable backends.


Modified: people/jch/xc/lib/font/FreeType/ftenc.c
==============================================================================
--- people/jch/xc/lib/font/FreeType/ftenc.c	2003-06-02 20:47:31 UTC (rev 122)
+++ people/jch/xc/lib/font/FreeType/ftenc.c	2003-06-02 21:05:19 UTC (rev 123)
@@ -1,5 +1,5 @@
 /* 
-Copyright (c) 1998-2002 by Juliusz Chroboczek
+Copyright (c) 1998-2003 by Juliusz Chroboczek
  
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
@@ -35,6 +35,7 @@
 #include "freetype/ttnameid.h"
 #include "freetype/tttables.h"
 #include "freetype/t1tables.h"
+#include "freetype/ftbdf.h"
 #include "freetype/ftxf86.h"
 #include "ft.h"
 
@@ -45,6 +46,9 @@
 {
     char *p = encoding;
 
+    if(strcasecmp(encoding, "microsoft-symbol"))
+        return 1;
+       
     while(*p != '-') {
         if(*p == '\0')
             return 0;
@@ -62,29 +66,42 @@
     FontMapPtr mapping;
     FT_CharMap cmap;
     int ftrc;
-    
+    int symbol = 0;
+    const char *enc, *reg;
     char *encoding_name = 0;
+    char buf[20];
 
     if(xlfd)
       encoding_name = FontEncFromXLFD(xlfd, length);
     if(!encoding_name)
         encoding_name = "iso8859-1";
 
-    if(FTEncFontSpecific(encoding_name)) {
-        ftrc = FT_Select_Charmap(face, ft_encoding_adobe_custom);
-        if(ftrc != 0) {
-            ErrorF("FreeType: couldn't select custom Type 1 encoding\n");
+    symbol = FTEncFontSpecific(encoding_name);
+
+    ftrc = FT_Get_BDF_Charset_ID(face, &enc, &reg);
+    if(ftrc == 0) {
+        /* Disable reencoding for non-Unicode fonts.  This will
+           currently only work for BDFs. */
+        if(strlen(enc) + strlen(reg) > 18)
+            goto native;
+        strcpy(buf, enc);
+        strcat(buf, "-");
+        strcat(buf, reg);
+        ErrorF("%s %s\n", buf, encoding_name);
+        if(strcasecmp(buf, "iso10646-1") != 0) {
+            if(strcasecmp(buf, encoding_name) == 0)
+                goto native;
             return -1;
-        } else {
-            tm->named = 0;
-            tm->cmap = face->charmap;
-            tm->base = 0;
-            tm->mapping = NULL;
-            return 0;
         }
+    } else if(symbol) {
+        ftrc = FT_Select_Charmap(face, ft_encoding_adobe_custom);
+        if(ftrc == 0)
+            goto native;
     }
 
     encoding = FontEncFind(encoding_name, filename);
+    if(symbol && encoding == NULL)
+        encoding = FontEncFind("microsoft-symbol", filename);
     if(encoding == NULL) {
         ErrorF("FreeType: couldn't find encoding %s\n", encoding_name);
         encoding = FontEncFind("iso8859-1", filename);
@@ -110,8 +127,9 @@
                      &cmap)) {
             tm->named = 0;
             tm->cmap = cmap;
-            if(strcasecmp(encoding_name, "microsoft-symbol") == 0) {
-                /* deal with undocumented lossage */
+            if(symbol) {
+                /* deal with an undocumented ``feature'' of the
+                   Microsft-Symbol cmap */
                 TT_OS2 *os2;
                 os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2);
                 if(os2)
@@ -126,6 +144,13 @@
     }
     
     return -1;
+
+  native:
+    tm->named = 0;
+    tm->cmap = face->charmap;
+    tm->base = 0;
+    tm->mapping = NULL;
+    return 0;
 }
 
 static int 

Modified: people/jch/xc/lib/font/FreeType/module/ftmodule.c
==============================================================================
--- people/jch/xc/lib/font/FreeType/module/ftmodule.c	2003-06-02 20:47:31 UTC (rev 122)
+++ people/jch/xc/lib/font/FreeType/module/ftmodule.c	2003-06-02 21:05:19 UTC (rev 123)
@@ -44,7 +44,7 @@
 	MODINFOSTRING1,
 	MODINFOSTRING2,
 	XF86_VERSION_CURRENT,
-        2, 0, 3,
+        2, 0, 4,
 	ABI_CLASS_FONT,			/* Font module */
 	ABI_FONT_VERSION,
 	MOD_CLASS_FONT,

Modified: people/jch/xc/lib/font/FreeType/module/Imakefile
==============================================================================
--- people/jch/xc/lib/font/FreeType/module/Imakefile	2003-06-02 20:47:31 UTC (rev 122)
+++ people/jch/xc/lib/font/FreeType/module/Imakefile	2003-06-02 21:05:19 UTC (rev 123)
@@ -22,14 +22,18 @@
            -I$(FT2SOURCEDIR)/psnames \
            -I$(FT2SOURCEDIR)/pshinter \
            -I$(FT2SOURCEDIR)/autohint \
+           -I$(FT2SOURCEDIR)/bdf \
+           -I$(FT2SOURCEDIR)/pcf \
            -I$(INCLUDESRC)
 
 FT2SRCS = ftbase.c ftinit.c ftglyph.c ftsystem.c fttype1.c ftxf86.c \
           ftgzip.c raster.c sfnt.c truetype.c cff.c type1.c \
-          psaux.c psnames.c pshinter.c  autohint.c
+          psaux.c psnames.c pshinter.c  autohint.c \
+          ftbdf.c bdf.c pcf.c
 FT2OBJS = ftbase.o ftinit.o ftglyph.o ftsystem.o fttype1.o ftxf86.o \
           ftgzip.o raster.o sfnt.o truetype.o cff.o type1.o \
-          psaux.o psnames.o pshinter.o autohint.o
+          psaux.o psnames.o pshinter.o autohint.o \
+          ftbdf.o bdf.o pcf.o
 
 SRCS = ftfuncs.c ftenc.c fttools.c $(FT2SRCS) ftmodule.c
 OBJS = ftfuncs.o ftenc.o fttools.o $(FT2OBJS) ftmodule.o
@@ -55,6 +59,9 @@
 LinkSourceFile(psnames.c,$(FT2SOURCEDIR)/psnames)
 LinkSourceFile(pshinter.c,$(FT2SOURCEDIR)/pshinter)
 LinkSourceFile(autohint.c,$(FT2SOURCEDIR)/autohint)
+LinkSourceFile(ftbdf.c,$(FT2SOURCEDIR)/base)
+LinkSourceFile(bdf.c,$(FT2SOURCEDIR)/bdf)
+LinkSourceFile(pcf.c,$(FT2SOURCEDIR)/pcf)
 
 ModuleObjectRule()
 LibraryModuleTarget(freetype,$(OBJS))

Modified: people/jch/xc/lib/font/FreeType/Imakefile
==============================================================================
--- people/jch/xc/lib/font/FreeType/Imakefile	2003-06-02 20:47:31 UTC (rev 122)
+++ people/jch/xc/lib/font/FreeType/Imakefile	2003-06-02 21:05:19 UTC (rev 123)
@@ -27,15 +27,20 @@
            -I$(FT2SOURCEDIR)/psaux \
            -I$(FT2SOURCEDIR)/psnames \
            -I$(FT2SOURCEDIR)/pshinter \
-           -I$(FT2SOURCEDIR)/autohint
+           -I$(FT2SOURCEDIR)/autohint \
+           -I$(FT2SOURCEDIR)/bdf \
+           -I$(FT2SOURCEDIR)/pcf
 
 FT2SRCS = ftbase.c ftinit.c ftglyph.c ftsystem.c fttype1.c ftxf86.c \
           ftgzip.c raster.c sfnt.c truetype.c cff.c type1.c \
-          psaux.c psnames.c pshinter.c  autohint.c
+          psaux.c psnames.c pshinter.c  autohint.c \
+          ftbdf.c bdf.c pcf.c
 
 FT2OBJS = ftbase.o ftinit.o ftglyph.o ftsystem.o fttype1.o ftxf86.o \
           ftgzip.o raster.o sfnt.o truetype.o cff.o type1.o \
-          psaux.o psnames.o pshinter.o autohint.o
+          psaux.o psnames.o pshinter.o autohint.o \
+          ftbdf.o bdf.o pcf.o
+
 #endif
 
 INCLUDES = -I. -I$(FONTINCSRC) -I../include -I$(XINCLUDESRC) \
@@ -59,7 +64,6 @@
 LinkSourceFile(ftbase.c,$(FT2SOURCEDIR)/base)
 LinkSourceFile(ftinit.c,$(FT2SOURCEDIR)/base)
 LinkSourceFile(ftglyph.c,$(FT2SOURCEDIR)/base)
-/* LinkSourceFile(ftsystem.c,$(FT2SOURCEDIR)/base) */
 LinkSourceFile(ftutil.c,$(FT2SOURCEDIR)/base)
 LinkSourceFile(fttype1.c,$(FT2SOURCEDIR)/base)
 LinkSourceFile(ftxf86.c,$(FT2SOURCEDIR)/base)
@@ -73,6 +77,9 @@
 LinkSourceFile(psnames.c,$(FT2SOURCEDIR)/psnames)
 LinkSourceFile(pshinter.c,$(FT2SOURCEDIR)/pshinter)
 LinkSourceFile(autohint.c,$(FT2SOURCEDIR)/autohint)
+LinkSourceFile(ftbdf.c,$(FT2SOURCEDIR)/base)
+LinkSourceFile(bdf.c,$(FT2SOURCEDIR)/bdf)
+LinkSourceFile(pcf.c,$(FT2SOURCEDIR)/pcf)
 #endif
 
 #endif

Modified: people/jch/xc/lib/font/FreeType/ftoption.h
==============================================================================
--- people/jch/xc/lib/font/FreeType/ftoption.h	2003-06-02 20:47:31 UTC (rev 122)
+++ people/jch/xc/lib/font/FreeType/ftoption.h	2003-06-02 21:05:19 UTC (rev 123)
@@ -1,3 +1,4 @@
+/* $XFree86: xc/extras/freetype2/include/freetype/config/ftoption.h,v 1.6 2003/05/29 02:13:03 dawes Exp $ */
 /***************************************************************************/
 /*                                                                         */
 /*  ftoption.h                                                             */
@@ -16,8 +17,8 @@
 /*  understand and accept it fully.                                        */
 /*                                                                         */
 /***************************************************************************/
-/* $XFree86: xc/lib/font/FreeType/ftoption.h,v 1.5 2003/05/29 14:53:28 dawes Exp $ */
 
+
 #ifndef __FTOPTION_H__
 #define __FTOPTION_H__
 
@@ -27,7 +28,6 @@
 
 FT_BEGIN_HEADER
 
-
   /*************************************************************************/
   /*                                                                       */
   /*                 USER-SELECTABLE CONFIGURATION MACROS                  */
@@ -80,115 +80,6 @@
 
   /*************************************************************************/
   /*                                                                       */
-  /* CMap support                                                          */
-  /*                                                                       */
-  /*   Define this if you want generic cmap support.                       */
-  /*                                                                       */
-#define FT_CONFIG_OPTION_USE_CMAPS
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* Convenience functions support                                         */
-  /*                                                                       */
-  /*   Some functions of the FreeType 2 API are provided as a convenience  */
-  /*   for client applications and developers. However,  they are not      */
-  /*   required to build and run the library itself.                       */
-  /*                                                                       */
-  /*   By defining this configuration macro, you'll disable the            */
-  /*   compilation of these functions at build time.  This can be useful   */
-  /*   to reduce the library's code size when you don't need any of        */
-  /*   these functions.                                                    */
-  /*                                                                       */
-  /*   All convenience functions are declared as such in their             */
-  /*   documentation.                                                      */
-  /*                                                                       */
-#undef FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* Module errors                                                         */
-  /*                                                                       */
-  /*   If this macro is set (which is _not_ the default), the higher byte  */
-  /*   of an error code gives the module in which the error has occurred,  */
-  /*   while the lower byte is the real error code.                        */
-  /*                                                                       */
-  /*   Setting this macro makes sense for debugging purposes only, since   */
-  /*   it would break source compatibility of certain programs that use    */
-  /*   FreeType 2.                                                         */
-  /*                                                                       */
-  /*   More details can be found in the files ftmoderr.h and fterrors.h.   */
-  /*                                                                       */
-#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* Alternate Glyph Image Format support                                  */
-  /*                                                                       */
-  /*   By default, the glyph images returned by the FreeType glyph loader  */
-  /*   can either be a pixmap or a vectorial outline defined through       */
-  /*   Bezier control points.  When defining the following configuration   */
-  /*   macro, some font drivers will be able to register alternate         */
-  /*   glyph image formats.                                                */
-  /*                                                                       */
-  /*   Unset this macro if you are sure that you will never use a font     */
-  /*   driver with an alternate glyph format; this will reduce the size of */
-  /*   the base layer code.                                                */
-  /*                                                                       */
-  /*   Note that a few Type 1 fonts, as well as Windows `vector' fonts     */
-  /*   use a vector `plotter' format that isn't supported when this        */
-  /*   macro is undefined.                                                 */
-  /*                                                                       */
-#undef FT_CONFIG_OPTION_ALTERNATE_GLYPH_FORMATS
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* Glyph Postscript Names handling                                       */
-  /*                                                                       */
-  /*   By default, FreeType 2 is compiled with the `PSNames' module.  This */
-  /*   module is in charge of converting a glyph name string into a        */
-  /*   Unicode value, or return a Macintosh standard glyph name for the    */
-  /*   use with the TrueType `post' table.                                 */
-  /*                                                                       */
-  /*   Undefine this macro if you do not want `PSNames' compiled in your   */
-  /*   build of FreeType.  This has the following effects:                 */
-  /*                                                                       */
-  /*   - The TrueType driver will provide its own set of glyph names,      */
-  /*     if you build it to support postscript names in the TrueType       */
-  /*     `post' table.                                                     */
-  /*                                                                       */
-  /*   - The Type 1 driver will not be able to synthetize a Unicode        */
-  /*     charmap out of the glyphs found in the fonts.                     */
-  /*                                                                       */
-  /*   You would normally undefine this configuration macro when building  */
-  /*   a version of FreeType that doesn't contain a Type 1 or CFF driver.  */
-  /*                                                                       */
-#define FT_CONFIG_OPTION_POSTSCRIPT_NAMES
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* Postscript Names to Unicode Values support                            */
-  /*                                                                       */
-  /*   By default, FreeType 2 is built with the `PSNames' module compiled  */
-  /*   in.  Among other things, the module is used to convert a glyph name */
-  /*   into a Unicode value.  This is especially useful in order to        */
-  /*   synthetize on the fly a Unicode charmap from the CFF/Type 1 driver  */
-  /*   through a big table named the `Adobe Glyph List' (AGL).             */
-  /*                                                                       */
-  /*   Undefine this macro if you do not want the Adobe Glyph List         */
-  /*   compiled in your `PSNames' module.  The Type 1 driver will not be   */
-  /*   able to synthetize a Unicode charmap out of the glyphs found in the */
-  /*   fonts.                                                              */
-  /*                                                                       */
-#define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
-
-
-  /*************************************************************************/
-  /*                                                                       */
   /* Many compilers provide a non-ANSI 64-bit data type that can be used   */
   /* by FreeType to speed up some computations.  However, this will create */
   /* some problems when compiling the library in strict ANSI mode.         */
@@ -204,7 +95,7 @@
   /*         file "ftconfig.h" either statically, or through Autoconf      */
   /*         on platforms that support it.                                 */
   /*                                                                       */
-#define FT_CONFIG_OPTION_FORCE_INT64
+#undef  FT_CONFIG_OPTION_FORCE_INT64
 
 
   /*************************************************************************/
@@ -279,11 +170,85 @@
   /*   will be later automatically defined as `extern return_type' to      */
   /*   allow normal compilation.                                           */
   /*                                                                       */
-#undef FT_EXPORT
-#undef FT_EXPORT_DEF
+/* #define  FT_EXPORT(x)       extern x */
+/* #define  FT_EXPORT_DEF(x)   x */
 
+
   /*************************************************************************/
   /*                                                                       */
+  /* Glyph Postscript Names handling                                       */
+  /*                                                                       */
+  /*   By default, FreeType 2 is compiled with the `PSNames' module.  This */
+  /*   module is in charge of converting a glyph name string into a        */
+  /*   Unicode value, or return a Macintosh standard glyph name for the    */
+  /*   use with the TrueType `post' table.                                 */
+  /*                                                                       */
+  /*   Undefine this macro if you do not want `PSNames' compiled in your   */
+  /*   build of FreeType.  This has the following effects:                 */
+  /*                                                                       */
+  /*   - The TrueType driver will provide its own set of glyph names,      */
+  /*     if you build it to support postscript names in the TrueType       */
+  /*     `post' table.                                                     */
+  /*                                                                       */
+  /*   - The Type 1 driver will not be able to synthetize a Unicode        */
+  /*     charmap out of the glyphs found in the fonts.                     */
+  /*                                                                       */
+  /*   You would normally undefine this configuration macro when building  */
+  /*   a version of FreeType that doesn't contain a Type 1 or CFF driver.  */
+  /*                                                                       */
+#define FT_CONFIG_OPTION_POSTSCRIPT_NAMES
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* Postscript Names to Unicode Values support                            */
+  /*                                                                       */
+  /*   By default, FreeType 2 is built with the `PSNames' module compiled  */
+  /*   in.  Among other things, the module is used to convert a glyph name */
+  /*   into a Unicode value.  This is especially useful in order to        */
+  /*   synthetize on the fly a Unicode charmap from the CFF/Type 1 driver  */
+  /*   through a big table named the `Adobe Glyph List' (AGL).             */
+  /*                                                                       */
+  /*   Undefine this macro if you do not want the Adobe Glyph List         */
+  /*   compiled in your `PSNames' module.  The Type 1 driver will not be   */
+  /*   able to synthetize a Unicode charmap out of the glyphs found in the */
+  /*   fonts.                                                              */
+  /*                                                                       */
+#define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* Allow the use of FT_Incremental_Interface to load typefaces that      */
+  /* contain no glyph data, but supply it via a callback function.         */
+  /* This allows FreeType to be used with the PostScript language, using   */
+  /* the GhostScript interpreter.                                          */
+  /*                                                                       */
+/* #define  FT_CONFIG_OPTION_INCREMENTAL */
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* The size in bytes of the render pool used by the scan-line converter  */
+  /* to do all of its work.                                                */
+  /*                                                                       */
+  /* This must be greater than 4kByte.                                     */
+  /*                                                                       */
+#define FT_RENDER_POOL_SIZE  16384L
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* FT_MAX_MODULES                                                        */
+  /*                                                                       */
+  /*   The maximum number of modules that can be registered in a single    */
+  /*   FreeType library object.  32 is the default.                        */
+  /*                                                                       */
+#define FT_MAX_MODULES  32
+
+
+  /*************************************************************************/
+  /*                                                                       */
   /* Debug level                                                           */
   /*                                                                       */
   /*   FreeType can be compiled in debug or trace mode.  In debug mode,    */
@@ -296,8 +261,8 @@
   /*                                                                       */
   /*   Don't define any of these macros to compile in `release' mode!      */
   /*                                                                       */
-#undef  FT_DEBUG_LEVEL_ERROR
-#undef  FT_DEBUG_LEVEL_TRACE
+/* #define  FT_DEBUG_LEVEL_ERROR */
+/* #define  FT_DEBUG_LEVEL_TRACE */
 
 
   /*************************************************************************/
@@ -312,29 +277,28 @@
   /*   Note that the memory debugger is only activated at runtime when     */
   /*   when the _environment_ variable "FT_DEBUG_MEMORY" is also defined!  */
   /*                                                                       */
-#undef  FT_DEBUG_MEMORY
+/* #define  FT_DEBUG_MEMORY */
 
 
+
   /*************************************************************************/
   /*                                                                       */
-  /* The size in bytes of the render pool used by the scan-line converter  */
-  /* to do all of its work.                                                */
+  /* Module errors                                                         */
   /*                                                                       */
-  /* This must be greater than 4kByte.                                     */
+  /*   If this macro is set (which is _not_ the default), the higher byte  */
+  /*   of an error code gives the module in which the error has occurred,  */
+  /*   while the lower byte is the real error code.                        */
   /*                                                                       */
-#define FT_RENDER_POOL_SIZE  16384L
-
-
-  /*************************************************************************/
+  /*   Setting this macro makes sense for debugging purposes only, since   */
+  /*   it would break source compatibility of certain programs that use    */
+  /*   FreeType 2.                                                         */
   /*                                                                       */
-  /* FT_MAX_MODULES                                                        */
+  /*   More details can be found in the files ftmoderr.h and fterrors.h.   */
   /*                                                                       */
-  /*   The maximum number of modules that can be registered in a single    */
-  /*   FreeType library object.  16 is the default.                        */
-  /*                                                                       */
-#define FT_MAX_MODULES  16
+#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS
 
 
+
   /*************************************************************************/
   /*************************************************************************/
   /****                                                                 ****/
@@ -414,7 +378,10 @@
   /* By undefining this, you will only compile the code necessary to load  */
   /* TrueType glyphs without hinting.                                      */
   /*                                                                       */
-/* #define  TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
+  /*   do not #undef this macro here, since the build system might         */
+  /*   define for certain configurations                                   */
+  /*                                                                       */
+#define  TT_CONFIG_OPTION_BYTECODE_INTERPRETER
 
 
   /*************************************************************************/
@@ -431,7 +398,26 @@
 
 
   /*************************************************************************/
+  /*                                                                       */
+  /* Define TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED to compile the        */
+  /* TrueType glyph loader to use Apple's definition of how to handle      */
+  /* component offsets in composite glyphs.                                */
+  /*                                                                       */
+  /* Apple and MS disagree on the default behavior of component offsets    */
+  /* in composites.  Apple says that they should be scaled by the scale    */
+  /* factors in the transformation matrix (roughly, it's more complex)     */
+  /* while MS says they should not.  OpenType defines two bits in the      */
+  /* composite flags array which can be used to disambiguate, but old      */
+  /* fonts will not have them.                                             */
+  /*                                                                       */
+  /*   http://partners.adobe.com/asn/developer/opentype/glyf.html          */
+  /*   http://fonts.apple.com/TTRefMan/RM06/Chap6glyf.html                 */
+  /*                                                                       */
+#undef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED
+
+
   /*************************************************************************/
+  /*************************************************************************/
   /****                                                                 ****/
   /****      T Y P E 1   D R I V E R    C O N F I G U R A T I O N       ****/
   /****                                                                 ****/
@@ -468,14 +454,6 @@
 
   /*************************************************************************/
   /*                                                                       */
-  /* Define T1_CONFIG_OPTION_DISABLE_HINTER if you want to generate a      */
-  /* driver with no hinter.  This can be useful to debug the parser.       */
-  /*                                                                       */
-#undef T1_CONFIG_OPTION_DISABLE_HINTER
-
-
-  /*************************************************************************/
-  /*                                                                       */
   /* Define this configuration macro if you want to prevent the            */
   /* compilation of `t1afm', which is in charge of reading Type 1 AFM      */
   /* files into an existing face.  Note that if set, the T1 driver will be */
@@ -490,10 +468,29 @@
   /* compilation of the Multiple Masters font support in the Type 1        */
   /* driver.                                                               */
   /*                                                                       */
-#undef T1_CONFIG_OPTION_NO_MM_SUPPORT
+#define T1_CONFIG_OPTION_NO_MM_SUPPORT
 
  /* */
 
+/*
+ * the FT_CONFIG_OPTION_CHESTER_XXXX macros are used to toggle some recent
+ * improvements to the auto-hinter contributed by David Chester. They will
+ * most likely disappear completely in the next release. For now, you should
+ * always keep them defined
+ *
+ */
+#define  FT_CONFIG_OPTION_CHESTER_HINTS
+
+#ifdef   FT_CONFIG_OPTION_CHESTER_HINTS
+
+#  define  FT_CONFIG_CHESTER_SMALL_F
+#  define  FT_CONFIG_CHESTER_ASCENDER
+#  define  FT_CONFIG_CHESTER_SERIF
+#  define  FT_CONFIG_CHESTER_STEM
+#  define  FT_CONFIG_CHESTER_BLUE_SCALE
+
+#endif /* FT_CONFIG_OPTION_CHESTER_HINTS */
+
 FT_END_HEADER
 
 

Modified: people/jch/xc/lib/font/FreeType/ftfuncs.c
==============================================================================
--- people/jch/xc/lib/font/FreeType/ftfuncs.c	2003-06-02 20:47:31 UTC (rev 122)
+++ people/jch/xc/lib/font/FreeType/ftfuncs.c	2003-06-02 21:05:19 UTC (rev 123)
@@ -1,6 +1,6 @@
 /*
 Copyright (c) 1997 by Mark Leisher
-Copyright (c) 1998-2002 by Juliusz Chroboczek
+Copyright (c) 1998-2003 by Juliusz Chroboczek
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
@@ -79,7 +79,7 @@
     int i;
     unsigned u = 0;
     for(i = 0; string[i] != '\0'; i++)
-        u = (u<<2) + (unsigned char)string[i];
+        u = (u<<5) + (u >> (NUMFACEBUCKETS - 5)) + (unsigned char)string[i];
     return u;
 }
 
@@ -155,9 +155,16 @@
         ErrorF("FreeType: couldn't open face %s: %d\n", fileName, ftrc);
         xfree(face->filename);
         xfree(face);
-        return BadFontPath;
+        return BadFontName;
     }
 
+    face->bitmap = ((face->face->face_flags & FT_FACE_FLAG_SCALABLE) == 0);
+    if(!face->bitmap) {
+        TT_MaxProfile *maxp;
+        maxp = FT_Get_Sfnt_Table(face->face, ft_sfnt_maxp);
+        if(maxp && maxp->maxContours == 0)
+            face->bitmap = 1;
+    }
     /* Insert face in hashtable and return it */
     face->next = faceTable[bucket];
     faceTable[bucket] = face;
@@ -263,21 +270,50 @@
     return Successful;
 }
 
+int
+FTFindSize(FT_Face face, FTNormalisedTransformationPtr trans,
+           int *x_return, int *y_return)
+{
+    int tx, ty, x, y;
+    int i, j;
+    int d, dd;
+
+    if(trans->nonIdentity)
+        return BadFontName;
+
+    tx = (int)(trans->scale * trans->xres / 72.0 + 0.5);
+    ty = (int)(trans->scale * trans->yres / 72.0 + 0.5);
+
+    d = 100;
+    j = -1;
+    for(i = 0; i < face->num_fixed_sizes; i++) {
+        x = face->available_sizes[i].width;
+        y = face->available_sizes[i].height;
+        if(ABS(x - tx) <= 1 && ABS(y - ty) <= 1) {
+            dd = ABS(x - tx) * ABS(x - tx) + ABS(y - ty) * ABS(y - ty);
+            if(dd < d) {
+                j = i;
+                d = dd;
+            }
+        }            
+    }
+    if(j < 0)
+        return BadFontName;
+
+    *x_return = face->available_sizes[j].width;
+    *y_return = face->available_sizes[j].height;
+    return Successful;
+}
+
 static int
-FreeTypeOpenInstance(FTInstancePtr *instance_return, 
+FreeTypeOpenInstance(FTInstancePtr *instance_return, FTFacePtr face,
                      char *fileName, FTNormalisedTransformationPtr trans,
                      int charcell, FontBitmapFormatPtr bmfmt)
 {
     FT_Error ftrc;
     int xrc;
     FTInstancePtr instance, otherInstance;
-    FTFacePtr face;
 
-    xrc = FreeTypeOpenFace(&face, fileName);
-    if(xrc != Successful) {
-        return xrc;
-    }
-
     /* Search for a matching instance */
     for(otherInstance = face->instances;
         otherInstance;
@@ -319,10 +355,18 @@
         return FTtoXReturnCode(ftrc);
     }
     FreeTypeActivateInstance(instance);
-    ftrc = FT_Set_Char_Size(instance->face->face, 
-                            (int)(trans->scale*(1<<6)+0.5),
-                            (int)(trans->scale*(1<<6)+0.5),
-                            trans->xres, trans->yres);
+    if(!face->bitmap) {
+        ftrc = FT_Set_Char_Size(instance->face->face,
+                                (int)(trans->scale*(1<<6) + 0.5),
+                                (int)(trans->scale*(1<<6) + 0.5),
+                                trans->xres, trans->yres);
+    } else {
+        int xsize, ysize;
+        xrc = FTFindSize(face->face, trans, &xsize, &ysize);
+        if(xrc != Successful)
+            return xrc;
+        ftrc = FT_Set_Pixel_Sizes(instance->face->face, xsize, ysize);
+    }
     if(ftrc != 0) {
         FT_Done_Size(instance->size);
         FreeTypeFreeFace(instance->face);
@@ -617,7 +661,7 @@
         for(i = MAX(0, -dy); i < bitmap->rows && i + dy < ht; i++)
             memcpy(raster + (i + dy) * bpr,
                    bitmap->buffer + i * bitmap->pitch,
-                   bitmap->pitch);
+                   MIN(bpr, bitmap->pitch));
     } else {
         for(i = MAX(0, -dy); i < bitmap->rows && i + dy < ht; i++) {
             for(j = MAX(0, -dx); j < bitmap->width && j + dx < wd; j++) {
@@ -725,8 +769,7 @@
 
 static int
 FreeTypeAddProperties(FTFontPtr font, FontScalablePtr vals, FontInfoPtr info, 
-                      char *fontname, 
-                      int rawAverageWidth)
+                      char *fontname, int rawAverageWidth)
 {
     int i, j, maxprops;
     char *sp, *ep, val[MAXFONTNAMELEN], *vp;
@@ -745,7 +788,11 @@
     face = instance->face;
     smetrics = instance->size->metrics;
     trans = &instance->transformation;
-    upm =  face->face->units_per_EM;
+    upm = face->face->units_per_EM;
+    if(upm == 0) {
+        /* Work around FreeType bug */
+        upm = 2048;
+    }
 
     os2 = FT_Get_Sfnt_Table(face->face, ft_sfnt_os2);
     post = FT_Get_Sfnt_Table(face->face, ft_sfnt_post);
@@ -841,27 +888,33 @@
         }
     }
 
-    info->props[i].name = MakeAtom("RAW_AVERAGE_WIDTH", 17, TRUE);
-    info->props[i].value = rawAverageWidth;
-    i++;
+    if(!face->bitmap) {
+        info->props[i].name = MakeAtom("RAW_AVERAGE_WIDTH", 17, TRUE);
+        info->props[i].value = rawAverageWidth;
+        i++;
+    }
 
     info->props[i].name = MakeAtom("FONT_ASCENT", 11, TRUE);
     info->props[i].value = info->fontAscent;
     i++;
 
-    info->props[i].name = MakeAtom("RAW_ASCENT", 15, TRUE);
-    info->props[i].value = 
-      ((double)face->face->ascender/(double)upm*1000.0);
-    i++;
+    if(!face->bitmap) {
+        info->props[i].name = MakeAtom("RAW_ASCENT", 15, TRUE);
+        info->props[i].value = 
+            ((double)face->face->ascender/(double)upm*1000.0);
+        i++;
+    }
 
     info->props[i].name = MakeAtom("FONT_DESCENT", 12, TRUE);
     info->props[i].value = info->fontDescent;
     i++;
 
-    info->props[i].name = MakeAtom("RAW_DESCENT", 16, TRUE);
-    info->props[i].value = 
-      -((double)face->face->descender/(double)upm*1000.0);
-    i++;
+    if(!face->bitmap) {
+        info->props[i].name = MakeAtom("RAW_DESCENT", 16, TRUE);
+        info->props[i].value = 
+            -((double)face->face->descender/(double)upm*1000.0);
+        i++;
+    }
 
     j = FTGetEnglishName(face->face, TT_NAME_ID_COPYRIGHT,
                          val, MAXFONTNAMELEN);
@@ -975,7 +1028,7 @@
         i++;
 
         info->props[i].name = MakeAtom("UNDERLINE_POSITION",18,TRUE);
-        info->props[i].value = underlinePosition;
+        info->props[i].value = -underlinePosition;
         i++;
 
         /* The italic angle is often unreliable for Type 1 fonts */
@@ -1102,7 +1155,8 @@
 }
 
 static int
-FreeTypeLoadFont(FTFontPtr *font_return, char *fileName, 
+FreeTypeLoadFont(FTFontPtr *font_return, FTFacePtr face,
+                 char *fileName,
                  FontScalablePtr vals, FontEntryPtr entry,
                  FontBitmapFormatPtr bmfmt)
 {
@@ -1110,7 +1164,7 @@
     FTFontPtr font;
     FTNormalisedTransformationRec trans;
     int charcell;
-    
+
     font = (FTFontPtr)xalloc(sizeof(FTFontRec));
     if(font == NULL)
         return AllocError;
@@ -1173,8 +1227,8 @@
             }
         }
     }
-    
-    xrc = FreeTypeOpenInstance(&font->instance, 
+
+    xrc = FreeTypeOpenInstance(&font->instance, face,
                                fileName, &trans, charcell, bmfmt);
     if(xrc != Successful)
         return xrc;
@@ -1182,11 +1236,11 @@
     if(entry->name.ndashes == 14) {
         if(FTPickMapping(entry->name.name, entry->name.length, fileName,
                          font->instance->face->face, &font->mapping))
-            return BadFontFormat;
+            return BadFontName;
     } else {
         if(FTPickMapping(0, 0, fileName, 
                          font->instance->face->face, &font->mapping))
-            return BadFontFormat;
+            return BadFontName;
     }
     
 
@@ -1341,24 +1395,34 @@
   ((long) \
    ceil(((double)(value)/(double)upm) * 1000.0))
 
-
     FTFontPtr font;
     FTInstancePtr instance;
-    FT_Size_Metrics smetrics;
+    FT_Size_Metrics *smetrics;
     FTFacePtr face;
     int xrc, i;
     int charcell, constantWidth;
-    long rawWidth, rawAverageWidth, aw, code, lastCode, firstCode;
+    long rawWidth, rawAverageWidth, code, lastCode, firstCode;
     int upm, minLsb, maxRsb, ascent, descent, width, averageWidth;
+    int ourvals = 0;
   
+    xrc = FreeTypeOpenFace(&face, fileName);
+    if(xrc != Successful) {
+        return xrc;
+    }
 
-    xrc = FreeTypeLoadFont(&font, fileName, vals, entry, bmfmt);
-    if(xrc != Successful)
+    if(MAX(hypot(vals->pixel_matrix[0], vals->pixel_matrix[1]),
+           hypot(vals->pixel_matrix[2], vals->pixel_matrix[3])) < 1.0) {
+        FreeTypeFreeFace(face);
+        return BadFontName;
+    }
+
+    xrc = FreeTypeLoadFont(&font, face, fileName, vals, entry, bmfmt);
+    if(xrc != Successful) {
         return xrc;
+    }
 
     instance = font->instance;
-    face = instance->face;
-    smetrics = instance->size->metrics;
+    smetrics = &instance->size->metrics;
 
     upm = face->face->units_per_EM;
     charcell = (instance->monospaced == FT_CHARCELL);
@@ -1371,24 +1435,26 @@
        for monospaced fonts, and try to provide a reasonable
        approximation for others. */
 
-    if(constantWidth)
-        aw = face->face->max_advance_width;
-    else
-        aw = face->face->max_advance_width / 2;
+    averageWidth = (smetrics->max_advance * 10) / 64;
+    if(!face->bitmap)
+        rawAverageWidth =
+            TRANSFORM_FUNITS_RAW(face->face->max_advance_width * 10L);
+    
+    if(!constantWidth) {
+        averageWidth /= 2;
+        rawAverageWidth /= 2;
+    }
 
-    if(constantWidth)
-        averageWidth = 10*TRANSFORM_FUNITS_X(aw);
+
+    /* Preserve average width for bitmap fonts */
+    if(vals->width == 0)
+        vals->width = averageWidth;
     else
-        averageWidth = TRANSFORM_FUNITS_X(aw*10L);
-    rawAverageWidth = TRANSFORM_FUNITS_RAW(aw*10L);
-
-    vals->width = averageWidth;
+        averageWidth = vals->width;
   
     if(info) {
-        info->fontAscent = 
-            TRANSFORM_FUNITS_Y(face->face->ascender);
-        info->fontDescent = 
-            -TRANSFORM_FUNITS_Y(face->face->descender);
+        info->fontAscent = smetrics->ascender / 64;
+        info->fontDescent = -smetrics->descender / 64;
         firstCode = 0;
         lastCode = 0xFFFFL;
         if(font->nranges) {
@@ -1430,23 +1496,36 @@
         /* firstCode and lastCode are not valid in case of a matrix
            encoding */
 
-        transformBBox(&instance->transformation, upm,
-                      smetrics.x_ppem, smetrics.y_ppem,
-                      charcell? 0 :
-                      face->face->bbox.xMin,
-                      face->face->bbox.yMin,
-                      charcell ?
-                      face->face->max_advance_width :
-                      face->face->bbox.xMax,
-                      face->face->bbox.yMax,
-                      &minLsb, &descent, &maxRsb, &ascent);
-        descent = -descent;
-
-        width = TRANSFORM_FUNITS_X(face->face->max_advance_width);
-        rawWidth = 
-            TRANSFORM_FUNITS_RAW(face->face->max_advance_width);
+        width = smetrics->max_advance / 64;
+        if(!face->bitmap)
+            rawWidth = 
+                TRANSFORM_FUNITS_RAW(face->face->max_advance_width);
         instance->width = width;
 
+        if(!face->bitmap) {
+            transformBBox(&instance->transformation, upm,
+                          smetrics->x_ppem, smetrics->y_ppem,
+                          charcell? 0 :
+                          face->face->bbox.xMin,
+                          face->face->bbox.yMin,
+                          charcell ?
+                          face->face->max_advance_width :
+                          face->face->bbox.xMax,
+                          face->face->bbox.yMax,
+                          &minLsb, &descent, &maxRsb, &ascent);
+        }
+
+        descent = -smetrics->descender / 64;
+        ascent = smetrics->ascender / 64;
+        if(charcell) {
+            minLsb = 0;
+            maxRsb = width;
+        } else if(!face->bitmap) {
+            /* For now */
+            minLsb = -width / 2;
+            maxRsb = width * 3 / 2;
+        }
+
         info->constantWidth=constantWidth;
         info->constantMetrics=charcell;
 
@@ -1658,13 +1737,6 @@
 #endif
     MUMBLE("\n");
 
-    /* Reject ridiculously small values.  Singular matrices are okay. */
-    if(MAX(hypot(vals->pixel_matrix[0], vals->pixel_matrix[1]),
-           hypot(vals->pixel_matrix[2], vals->pixel_matrix[3]))
-       <1.0)
-        return BadFontName;
-
-    /* Create an X11 server-side font. */
     xf = CreateFontRec();
     if (xf == NULL)
         return AllocError;
@@ -1674,16 +1746,13 @@
         DestroyFontRec(xf);
         return xrc;
     }
-    /* Load the font and fill its info structure. */
     xrc = FreeTypeLoadXFont(fileName, vals, xf, &xf->info, &bmfmt, entry);
     if(xrc != Successful) {
-        /* Free everything up at this level and return the error code. */
         MUMBLE1("Error during load: %d\n",xrc);
         DestroyFontRec(xf);
         return xrc;
     }
 
-    /* Set the font and return. */
     *ppFont = xf;
 
     return xrc;
@@ -1705,10 +1774,6 @@
 #endif
     MUMBLE("\n");
 
-    if(MAX(hypot(vals->pixel_matrix[0], vals->pixel_matrix[1]),
-           hypot(vals->pixel_matrix[2], vals->pixel_matrix[3])) < 1.0)
-        return BadFontName;
-
     xrc = FreeTypeSetUpFont(fpe, 0, info, 0, 0, &bmfmt);
     if(xrc != Successful) {
         return xrc;
@@ -1760,6 +1825,21 @@
 };
 static int num_renderers = sizeof(renderers) / sizeof(renderers[0]);
 
+static FontRendererRec alt_renderers[] = {
+    {".bdf", 4, 0, FreeTypeOpenScalable, 0,
+     FreeTypeGetInfoScalable, 0, CAPABILITIES},
+    {".BDF", 4, 0, FreeTypeOpenScalable, 0,
+     FreeTypeGetInfoScalable, 0, CAPABILITIES},
+    {".pcf", 4, 0, FreeTypeOpenScalable, 0,
+     FreeTypeGetInfoScalable, 0, CAPABILITIES},
+    {".PCF", 4, 0, FreeTypeOpenScalable, 0,
+     FreeTypeGetInfoScalable, 0, CAPABILITIES},
+};
+
+static int num_alt_renderers =  
+sizeof(alt_renderers) / sizeof(alt_renderers[0]);
+    
+
 void
 FreeTypeRegisterFontFileFunctions(void)
 {
@@ -1767,4 +1847,7 @@
 
     for (i = 0; i < num_renderers; i++)
         FontFileRegisterRenderer(&renderers[i]);
+
+    for (i = 0; i < num_alt_renderers; i++)
+        FontFilePriorityRegisterRenderer(&alt_renderers[i], -10);
 }

Modified: people/jch/xc/lib/font/FreeType/ftfuncs.h
==============================================================================
--- people/jch/xc/lib/font/FreeType/ftfuncs.h	2003-06-02 20:47:31 UTC (rev 122)
+++ people/jch/xc/lib/font/FreeType/ftfuncs.h	2003-06-02 21:05:19 UTC (rev 123)
@@ -45,6 +45,7 @@
 typedef struct _FTFace {
     char *filename;
     FT_Face face;
+    int bitmap;
     struct _FTInstance *instances;
     struct _FTInstance *active_instance;
     struct _FTFace *next;       /* link to next face in bucket */
@@ -99,12 +100,12 @@
 static int FreeTypeOpenFace(FTFacePtr *facep, char *fileName);
 static void FreeTypeFreeFace(FTFacePtr face);
 static int 
- FreeTypeOpenInstance(FTInstancePtr *instancep,
-                      char *fileName, FTNormalisedTransformationPtr trans,
-                      int charcell, FontBitmapFormatPtr bmfmt);
+FreeTypeOpenInstance(FTInstancePtr *instancep, FTFacePtr face,
+                     char *fileName, FTNormalisedTransformationPtr trans,
+                     int charcell, FontBitmapFormatPtr bmfmt);
 static void FreeTypeFreeInstance(FTInstancePtr instance);
 static int
- FreeTypeInstanceGetGlyph(unsigned idx, CharInfoPtr *g, FTInstancePtr instance);
+FreeTypeInstanceGetGlyph(unsigned idx, CharInfoPtr *g, FTInstancePtr instance);
 static int 
 FreeTypeRasteriseGlyph(CharInfoPtr tgp, FTInstancePtr instance, int hasMetrics);
 static void FreeTypeFreeFont(FTFontPtr font);
@@ -117,6 +118,6 @@
 static int FreeTypeFontGetGlyph(unsigned code, CharInfoPtr *g, FTFontPtr font);
 static int FreeTypeFontGetDefaultGlyph(CharInfoPtr *g, FTFontPtr font);
 static int
-FreeTypeLoadFont(FTFontPtr *fontp, char *fileName,
+FreeTypeLoadFont(FTFontPtr *fontp, FTFacePtr face, char *fileName,
                  FontScalablePtr vals, FontEntryPtr entry,
                  FontBitmapFormatPtr bmfmt);

Modified: people/jch/xc/lib/font/FreeType/ft.h
==============================================================================
--- people/jch/xc/lib/font/FreeType/ft.h	2003-06-02 20:47:31 UTC (rev 122)
+++ people/jch/xc/lib/font/FreeType/ft.h	2003-06-02 21:05:19 UTC (rev 123)
@@ -52,6 +52,8 @@
 /* Is x significantly different from 0 w.r.t. y? */
 #define DIFFER0(x,y) (fabs(x)>=NEGLIGIBLE*fabs(y))
 
+#define ABS(x) ((x) >= 0 ? (x) : -(x))
+
 /* Two to the sixteenth power, as a double. */
 #define TWO_SIXTEENTH ((double)(1<<16))
 #define TWO_SIXTH ((double)(1<<6))

Modified: people/jch/xc/lib/font/FreeType/ftmodule.h
==============================================================================
--- people/jch/xc/lib/font/FreeType/ftmodule.h	2003-06-02 20:47:31 UTC (rev 122)
+++ people/jch/xc/lib/font/FreeType/ftmodule.h	2003-06-02 21:05:19 UTC (rev 123)
@@ -1,17 +1,19 @@
-/* $XFree86: xc/lib/font/FreeType/ftmodule.h,v 1.3 2002/10/01 00:02:10 alanh Exp $ */
 FT_USE_MODULE(autohint_module_class)
 FT_USE_MODULE(cff_driver_class)
 /* FT_USE_MODULE(t1cid_driver_class) */
-/* FT_USE_MODULE(pcf_driver_class) */
-/* FT_USE_MODULE(bdf_driver_class) */
+FT_USE_MODULE(pcf_driver_class)
+FT_USE_MODULE(bdf_driver_class)
 FT_USE_MODULE(psaux_module_class)
 FT_USE_MODULE(psnames_module_class)
 FT_USE_MODULE(pshinter_module_class)
 FT_USE_MODULE(ft_raster1_renderer_class)
 FT_USE_MODULE(sfnt_module_class)
 /* FT_USE_MODULE(ft_smooth_renderer_class) */
+/* FT_USE_MODULE(ft_smooth_lcd_renderer_class) */
+/* FT_USE_MODULE(ft_smooth_lcdv_renderer_class) */
 FT_USE_MODULE(tt_driver_class)
 FT_USE_MODULE(t1_driver_class)
 /* FT_USE_MODULE(t42_driver_class) */
 /* FT_USE_MODULE(pfr_driver_class) */
 /* FT_USE_MODULE(winfnt_driver_class) */
+

Modified: people/jch/xc/lib/font/FreeType/fttools.c
==============================================================================
--- people/jch/xc/lib/font/FreeType/fttools.c	2003-06-02 20:47:31 UTC (rev 122)
+++ people/jch/xc/lib/font/FreeType/fttools.c	2003-06-02 21:05:19 UTC (rev 123)
@@ -51,7 +51,9 @@
 {
     if(rc == 0x40)
         return AllocError;
-    else return BadFontFormat;
+    /* Anything else stops the font matching mechanism */
+    else return BadFontName;
+
 }
 
 /* Convert slen bytes from UCS-2 to ISO 8859-1.  Byte specifies the
@@ -132,7 +134,7 @@
         len = name.string_len;
         if(len > name_len)
             len = name_len;
-        memcpy(name_return, name.string, name_len);
+        memcpy(name_return, name.string, len);
         return len;
     }
 



Reply to: