[xorg-commit-diffs] xc/extras/freetype2/src/winfonts rules.mk, 1.1, 1.1.4.1 winfnt.c, 1.1.4.1, 1.1.4.2 winfnt.h, 1.1, 1.1.4.1

Egbert Eich xorg-commit at pdx.freedesktop.org
Thu Apr 15 03:14:50 PDT 2004


Committed by: eich

Update of /cvs/xorg/xc/extras/freetype2/src/winfonts
In directory pdx:/home/eich/tstbuild/xc/extras/freetype2/src/winfonts

Modified Files:
      Tag: XORG-CURRENT
	rules.mk winfnt.c winfnt.h 
Log Message:
2004-04-15  Egbert Eich  <eich at freedesktop.org>
        Merged changes from RELEASE-1 branch
	


Index: rules.mk
===================================================================
RCS file: /cvs/xorg/xc/extras/freetype2/src/winfonts/rules.mk,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -d -r1.1 -r1.1.4.1
--- a/rules.mk	14 Nov 2003 16:48:24 -0000	1.1
+++ b/rules.mk	15 Apr 2004 10:14:45 -0000	1.1.4.1
@@ -3,7 +3,7 @@
 #
 
 
-# Copyright 1996-2000, 2001 by
+# Copyright 1996-2000, 2001, 2003 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -15,21 +15,20 @@
 
 # Windows driver directory
 #
-FNT_DIR  := $(SRC_)winfonts
-FNT_DIR_ := $(FNT_DIR)$(SEP)
+FNT_DIR := $(SRC_DIR)/winfonts
 
 
-FNT_COMPILE := $(FT_COMPILE) $I$(FNT_DIR)
+FNT_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(FNT_DIR))
 
 
 # Windows driver sources (i.e., C files)
 #
-FNT_DRV_SRC := $(FNT_DIR_)winfnt.c
+FNT_DRV_SRC := $(FNT_DIR)/winfnt.c
 
 # Windows driver headers
 #
 FNT_DRV_H := $(FNT_DRV_SRC:%.c=%.h) \
-             $(FNT_DIR_)fnterrs.h
+             $(FNT_DIR)/fnterrs.h
 
 
 # Windows driver object(s)
@@ -37,24 +36,24 @@
 #   FNT_DRV_OBJ_M is used during `multi' builds
 #   FNT_DRV_OBJ_S is used during `single' builds
 #
-FNT_DRV_OBJ_M := $(FNT_DRV_SRC:$(FNT_DIR_)%.c=$(OBJ_)%.$O)
-FNT_DRV_OBJ_S := $(OBJ_)winfnt.$O
+FNT_DRV_OBJ_M := $(FNT_DRV_SRC:$(FNT_DIR)/%.c=$(OBJ_DIR)/%.$O)
+FNT_DRV_OBJ_S := $(OBJ_DIR)/winfnt.$O
 
 # Windows driver source file for single build
 #
-FNT_DRV_SRC_S := $(FNT_DIR_)winfnt.c
+FNT_DRV_SRC_S := $(FNT_DIR)/winfnt.c
 
 
 # Windows driver - single object
 #
 $(FNT_DRV_OBJ_S): $(FNT_DRV_SRC_S) $(FNT_DRV_SRC) $(FREETYPE_H) $(FNT_DRV_H)
-	$(FNT_COMPILE) $T$@ $(FNT_DRV_SRC_S)
+	$(FNT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(FNT_DRV_SRC_S))
 
 
 # Windows driver - multiple objects
 #
-$(OBJ_)%.$O: $(FNT_DIR_)%.c $(FREETYPE_H) $(FNT_DRV_H)
-	$(FNT_COMPILE) $T$@ $<
+$(OBJ_DIR)/%.$O: $(FNT_DIR)/%.c $(FREETYPE_H) $(FNT_DRV_H)
+	$(FNT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
 
 
 # update main driver object lists
@@ -62,4 +61,5 @@
 DRV_OBJS_S += $(FNT_DRV_OBJ_S)
 DRV_OBJS_M += $(FNT_DRV_OBJ_M)
 
+
 # EOF

Index: winfnt.c
===================================================================
RCS file: /cvs/xorg/xc/extras/freetype2/src/winfonts/winfnt.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/winfnt.c	26 Nov 2003 22:48:28 -0000	1.1.4.1
+++ b/winfnt.c	15 Apr 2004 10:14:45 -0000	1.1.4.2
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType font driver for Windows FNT/FON files                       */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002 by                                           */
+/*  Copyright 1996-2001, 2002, 2003 by                                     */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -21,12 +21,11 @@
 #include FT_INTERNAL_DEBUG_H
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_OBJECTS_H
-#include FT_INTERNAL_FNT_TYPES_H
 
 #include "winfnt.h"
-
 #include "fnterrs.h"
-
+#include FT_SERVICE_WINFNT_H
+#include FT_SERVICE_XFREE86_NAME_H
 
   /*************************************************************************/
   /*                                                                       */
@@ -38,8 +37,7 @@
 #define FT_COMPONENT  trace_winfnt
 
 
-  static
-  const FT_Frame_Field  winmz_header_fields[] =
+  static const FT_Frame_Field  winmz_header_fields[] =
   {
 #undef  FT_STRUCTURE
 #define FT_STRUCTURE  WinMZ_HeaderRec
@@ -51,8 +49,7 @@
     FT_FRAME_END
   };
 
-  static
-  const FT_Frame_Field  winne_header_fields[] =
+  static const FT_Frame_Field  winne_header_fields[] =
   {
 #undef  FT_STRUCTURE
 #define FT_STRUCTURE  WinNE_HeaderRec
@@ -65,13 +62,12 @@
     FT_FRAME_END
   };
 
-  static
-  const FT_Frame_Field  winfnt_header_fields[] =
+  static const FT_Frame_Field  winfnt_header_fields[] =
   {
 #undef  FT_STRUCTURE
 #define FT_STRUCTURE  FT_WinFNT_HeaderRec
 
-    FT_FRAME_START( 146 ),
+    FT_FRAME_START( 148 ),
       FT_FRAME_USHORT_LE( version ),
       FT_FRAME_ULONG_LE ( file_size ),
       FT_FRAME_BYTES    ( copyright, 60 ),
@@ -106,21 +102,28 @@
       FT_FRAME_USHORT_LE( A_space ),
       FT_FRAME_USHORT_LE( B_space ),
       FT_FRAME_USHORT_LE( C_space ),
-      FT_FRAME_USHORT_LE( color_table_offset ),
+      FT_FRAME_ULONG_LE ( color_table_offset ),
       FT_FRAME_BYTES    ( reserved1, 16 ),
     FT_FRAME_END
   };
 
 
   static void
-  fnt_font_done( FNT_Font   font,
-                 FT_Stream  stream )
+  fnt_font_done( FNT_Face face )
   {
+    FT_Memory  memory = FT_FACE( face )->memory;
+    FT_Stream  stream = FT_FACE( face )->stream;
+    FNT_Font   font   = face->font;
+
+
+    if ( !font )
+      return;
+
     if ( font->fnt_frame )
       FT_FRAME_RELEASE( font->fnt_frame );
 
-    font->fnt_size  = 0;
-    font->fnt_frame = 0;
+    FT_FREE( font );
+    face->font = 0;
   }
 
 
@@ -130,10 +133,12 @@
   {
     FT_Error          error;
     FT_WinFNT_Header  header = &font->header;
+    FT_Bool           new_format;
+    FT_UInt           size;
 
 
     /* first of all, read the FNT header */
-    if ( FT_STREAM_SEEK( font->offset )                   ||
+    if ( FT_STREAM_SEEK( font->offset )                        ||
          FT_STREAM_READ_FIELDS( winfnt_header_fields, header ) )
       goto Exit;
 
@@ -146,6 +151,16 @@
       goto Exit;
     }
 
+    new_format = FT_BOOL( font->header.version == 0x300 );
+    size       = new_format ? 148 : 118;
+
+    if ( header->file_size < size )
+    {
+      FT_TRACE2(( "[not a valid FNT file]\n" ));
+      error = FNT_Err_Unknown_File_Format;
+      goto Exit;
+    }
+
     /* Version 2 doesn't have these fields */
     if ( header->version == 0x200 )
     {
@@ -164,11 +179,7 @@
       goto Exit;
     }
 
-    /* small fixup -- some fonts have the `pixel_width' field set to 0 */
-    if ( header->pixel_width == 0 )
-      header->pixel_width = header->pixel_height;
-
-    /* this is a FNT file/table, we now extract its frame */
+    /* this is a FNT file/table; extract its frame */
     if ( FT_STREAM_SEEK( font->offset )                         ||
          FT_FRAME_EXTRACT( header->file_size, font->fnt_frame ) )
       goto Exit;
@@ -178,25 +189,9 @@
   }
 
 
-  static void
-  fnt_face_done_fonts( FNT_Face  face )
-  {
-    FT_Memory  memory = FT_FACE( face )->memory;
-    FT_Stream  stream = FT_FACE( face )->stream;
-    FNT_Font   cur    = face->fonts;
-    FNT_Font   limit  = cur + face->num_fonts;
-
-
-    for ( ; cur < limit; cur++ )
-      fnt_font_done( cur, stream );
-
-    FT_FREE( face->fonts );
-    face->num_fonts = 0;
-  }
-
-
   static FT_Error
-  fnt_face_get_dll_fonts( FNT_Face  face )
+  fnt_face_get_dll_font( FNT_Face  face,
+                         FT_Int    face_index )
   {
     FT_Error         error;
     FT_Stream        stream = FT_FACE( face )->stream;
@@ -204,38 +199,36 @@
     WinMZ_HeaderRec  mz_header;
 
 
-    face->fonts     = 0;
-    face->num_fonts = 0;
+    face->font = 0;
 
-    /* does it begin with a MZ header? */
-    if ( FT_STREAM_SEEK( 0 )                                 ||
+    /* does it begin with an MZ header? */
+    if ( FT_STREAM_SEEK( 0 )                                      ||
          FT_STREAM_READ_FIELDS( winmz_header_fields, &mz_header ) )
       goto Exit;
 
     error = FNT_Err_Unknown_File_Format;
     if ( mz_header.magic == WINFNT_MZ_MAGIC )
     {
-      /* yes, now look for a NE header in the file */
+      /* yes, now look for an NE header in the file */
       WinNE_HeaderRec  ne_header;
 
 
-      if ( FT_STREAM_SEEK( mz_header.lfanew )                  ||
+      if ( FT_STREAM_SEEK( mz_header.lfanew )                       ||
            FT_STREAM_READ_FIELDS( winne_header_fields, &ne_header ) )
         goto Exit;
 
       error = FNT_Err_Unknown_File_Format;
       if ( ne_header.magic == WINFNT_NE_MAGIC )
       {
-        /* good, now look in the resource table for each FNT resource */
-        FT_ULong   res_offset = mz_header.lfanew +
-                                ne_header.resource_tab_offset;
-
+        /* good, now look into the resource table for each FNT resource */
+        FT_ULong   res_offset  = mz_header.lfanew +
+                                   ne_header.resource_tab_offset;
         FT_UShort  size_shift;
         FT_UShort  font_count  = 0;
         FT_ULong   font_offset = 0;
 
 
-        if ( FT_STREAM_SEEK( res_offset ) ||
+        if ( FT_STREAM_SEEK( res_offset )                    ||
              FT_FRAME_ENTER( ne_header.rname_tab_offset -
                              ne_header.resource_tab_offset ) )
           goto Exit;
@@ -253,7 +246,7 @@
 
           count = FT_GET_USHORT_LE();
 
-          if ( type_id == 0x8008 )
+          if ( type_id == 0x8008U )
           {
             font_count  = count;
             font_offset = (FT_ULong)( FT_STREAM_POS() + 4 +
@@ -263,6 +256,7 @@
 
           stream->cursor += 4 + count * 12;
         }
+
         FT_FRAME_EXIT();
 
         if ( !font_count || !font_offset )
@@ -272,57 +266,42 @@
           goto Exit;
         }
 
-        if ( FT_STREAM_SEEK( font_offset )           ||
-             FT_NEW_ARRAY( face->fonts, font_count ) )
-          goto Exit;
-
-        face->num_fonts = font_count;
+        face->root.num_faces = font_count;
 
-        if ( FT_FRAME_ENTER( (FT_Long)font_count * 12 ) )
+        if ( face_index >= font_count )
+        {
+          error = FNT_Err_Bad_Argument;
           goto Exit;
+        }
 
-        /* now read the offset and position of each FNT font */
-        {
-          FNT_Font  cur   = face->fonts;
-          FNT_Font  limit = cur + font_count;
+        if ( FT_NEW( face->font ) )
+          goto Exit;
 
+        if ( FT_STREAM_SEEK( font_offset + face_index * 12 ) ||
+             FT_FRAME_ENTER( 12 )                            )
+          goto Fail;
 
-          for ( ; cur < limit; cur++ )
-          {
-            cur->offset     = (FT_ULong)FT_GET_USHORT_LE() << size_shift;
-            cur->fnt_size   = (FT_ULong)FT_GET_USHORT_LE() << size_shift;
-            cur->size_shift = size_shift;
-            stream->cursor += 8;
-          }
-        }
-        FT_FRAME_EXIT();
+        face->font->offset     = (FT_ULong)FT_GET_USHORT_LE() << size_shift;
+        face->font->fnt_size   = (FT_ULong)FT_GET_USHORT_LE() << size_shift;
+        face->font->size_shift = size_shift;
 
-        /* finally, try to load each font there */
-        {
-          FNT_Font  cur   = face->fonts;
-          FNT_Font  limit = cur + font_count;
+        stream->cursor += 8;
 
+        FT_FRAME_EXIT();
 
-          for ( ; cur < limit; cur++ )
-          {
-            error = fnt_font_load( cur, stream );
-            if ( error )
-              goto Fail;
-          }
-        }
+        error = fnt_font_load( face->font, stream );
       }
     }
 
   Fail:
     if ( error )
-      fnt_face_done_fonts( face );
+      fnt_font_done( face );
 
   Exit:
     return error;
   }
 
 
-
   typedef struct  FNT_CMapRec_
   {
     FT_CMapRec  cmap;
@@ -336,7 +315,7 @@
   fnt_cmap_init( FNT_CMap  cmap )
   {
     FNT_Face  face = (FNT_Face)FT_CMAP_FACE( cmap );
-    FNT_Font  font = face->fonts;
+    FNT_Font  font = face->font;
 
 
     cmap->first = (FT_UInt32)  font->header.first_char;
@@ -355,8 +334,8 @@
 
     char_code -= cmap->first;
     if ( char_code < cmap->count )
-      gindex = char_code + 1;
-
+      gindex = char_code + 1; /* we artificially increase the glyph index; */
+                              /* FNT_Load_Glyph reverts to the right one   */
     return gindex;
   }
 
@@ -390,7 +369,7 @@
   }
 
 
-  static FT_CMap_ClassRec  fnt_cmap_class_rec =
+  static const FT_CMap_ClassRec  fnt_cmap_class_rec =
   {
     sizeof ( FNT_CMapRec ),
 
@@ -400,8 +379,7 @@
     (FT_CMap_CharNextFunc) fnt_cmap_char_next
   };
 
-  static FT_CMap_Class  fnt_cmap_class = &fnt_cmap_class_rec;
-
+  static FT_CMap_Class const  fnt_cmap_class = &fnt_cmap_class_rec;
 
 
   static void
@@ -410,7 +388,7 @@
     FT_Memory  memory = FT_FACE_MEMORY( face );
 
 
-    fnt_face_done_fonts( face );
+    fnt_font_done( face );
 
     FT_FREE( face->root.available_sizes );
     face->root.num_fixed_sizes = 0;
@@ -429,23 +407,22 @@
 
     FT_UNUSED( num_params );
     FT_UNUSED( params );
-    FT_UNUSED( face_index );
 
 
-    /* try to load several fonts from a DLL */
-    error = fnt_face_get_dll_fonts( face );
+    /* try to load font from a DLL */
+    error = fnt_face_get_dll_font( face, face_index );
     if ( error )
     {
-      /* this didn't work, now try to load a single FNT font */
+      /* this didn't work; try to load a single FNT font */
       FNT_Font  font;
 
 
-      if ( FT_NEW( face->fonts ) )
+      if ( FT_NEW( face->font ) )
         goto Exit;
 
-      face->num_fonts = 1;
-      font            = face->fonts;
+      face->root.num_faces = 1;
 
+      font           = face->font;
       font->offset   = 0;
       font->fnt_size = stream->size;
 
@@ -454,48 +431,51 @@
         goto Fail;
     }
 
-    /* all right, one or more fonts were loaded; we now need to */
-    /* fill the root FT_Face fields with relevant information   */
+    /* we now need to fill the root FT_Face fields */
+    /* with relevant information                   */
     {
-      FT_Face   root  = FT_FACE( face );
-      FNT_Font  fonts = face->fonts;
-      FNT_Font  limit = fonts + face->num_fonts;
-      FNT_Font  cur;
+      FT_Face   root = FT_FACE( face );
+      FNT_Font  font = face->font;
 
 
-      root->num_faces  = 1;
       root->face_flags = FT_FACE_FLAG_FIXED_SIZES |
                          FT_FACE_FLAG_HORIZONTAL;
 
-      if ( fonts->header.avg_width == fonts->header.max_width )
+      if ( font->header.avg_width == font->header.max_width )
         root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
 
-      if ( fonts->header.italic )
+      if ( font->header.italic )
         root->style_flags |= FT_STYLE_FLAG_ITALIC;
 
-      if ( fonts->header.weight >= 800 )
+      if ( font->header.weight >= 800 )
         root->style_flags |= FT_STYLE_FLAG_BOLD;
 
-      /* Setup the `fixed_sizes' array */
-      if ( FT_NEW_ARRAY( root->available_sizes, face->num_fonts ) )
+      /* set up the `fixed_sizes' array */
+      if ( FT_NEW_ARRAY( root->available_sizes, 1 ) )
         goto Fail;
 
-      root->num_fixed_sizes = face->num_fonts;
+      root->num_fixed_sizes = 1;
 
       {
-        FT_Bitmap_Size*  size = root->available_sizes;
+        FT_Bitmap_Size*  bsize = root->available_sizes;
 
 
-        for ( cur = fonts; cur < limit; cur++, size++ )
-        {
-          size->width  = cur->header.pixel_width;
-          size->height = cur->header.pixel_height;
-        }
+        bsize->width  = font->header.avg_width;
+        bsize->height = (FT_Short)(
+          font->header.pixel_height + font->header.external_leading );
+        bsize->size   = font->header.nominal_point_size << 6;
+        bsize->x_ppem =
+          (FT_Pos)( ( font->header.horizontal_resolution * bsize->size + 36 )
+                    / 72 );
+        bsize->y_ppem =
+          (FT_Pos)( ( font->header.vertical_resolution* bsize->size + 36 )
+                    / 72 );
       }
 
       {
         FT_CharMapRec  charmap;
 
+
         charmap.encoding    = FT_ENCODING_UNICODE;
         charmap.platform_id = 3;
         charmap.encoding_id = 1;
@@ -514,11 +494,13 @@
       }
 
       /* setup remaining flags */
-      root->num_glyphs = fonts->header.last_char -
-                         fonts->header.first_char + 1;
 
-      root->family_name = (FT_String*)fonts->fnt_frame +
-                          fonts->header.face_name_offset;
+      /* reserve one slot for the .notdef glyph at index 0 */
+      root->num_glyphs = font->header.last_char -
+                           font->header.first_char + 1 + 1;
+
+      root->family_name = (FT_String*)font->fnt_frame +
+                            font->header.face_name_offset;
       root->style_name  = (char *)"Regular";
 
       if ( root->style_flags & FT_STYLE_FLAG_BOLD )
@@ -542,69 +524,64 @@
 
 
   static FT_Error
-  FNT_Size_Set_Pixels( FNT_Size  size )
+  FNT_Size_Set_Pixels( FT_Size  size )
   {
-    /* look up a font corresponding to the current pixel size */
-    FNT_Face  face  = (FNT_Face)FT_SIZE_FACE( size );
-    FNT_Font  cur   = face->fonts;
-    FNT_Font  limit = cur + face->num_fonts;
+    FNT_Face  face = (FNT_Face)FT_SIZE_FACE( size );
+    FT_Face   root = FT_FACE( face );
 
 
-    size->font = 0;
-    for ( ; cur < limit; cur++ )
+    if ( size->metrics.y_ppem == root->available_sizes->height )
     {
-      /* we only compare the character height, as fonts used some strange */
-      /* values                                                           */
-      if ( cur->header.pixel_height == size->root.metrics.y_ppem )
-      {
-        size->font = cur;
+      FNT_Font  font = face->font;
 
-        size->root.metrics.ascender  = cur->header.ascent * 64;
-        size->root.metrics.descender = ( cur->header.pixel_height -
-                                           cur->header.ascent ) * 64;
-        size->root.metrics.height    = cur->header.pixel_height * 64;
-        break;
-      }
-    }
 
-    return ( size->font ? FNT_Err_Ok : FNT_Err_Invalid_Pixel_Size );
+      size->metrics.ascender    = font->header.ascent * 64;
+      size->metrics.descender   = ( font->header.pixel_height -
+                                      font->header.ascent ) * 64;
+      size->metrics.height      = font->header.pixel_height * 64;
+      size->metrics.max_advance = font->header.max_width * 64;
+
+      return FNT_Err_Ok;
+    }
+    else
+      return FNT_Err_Invalid_Pixel_Size;
   }
 
 
   static FT_Error
   FNT_Load_Glyph( FT_GlyphSlot  slot,
-                  FNT_Size      size,
+                  FT_Size       size,
                   FT_UInt       glyph_index,
                   FT_Int32      load_flags )
   {
-    FNT_Font    font  = size->font;
-    FT_Error    error = 0;
+    FNT_Face    face   = (FNT_Face)FT_SIZE_FACE( size );
+    FNT_Font    font   = face->font;
+    FT_Error    error  = FNT_Err_Ok;
     FT_Byte*    p;
     FT_Int      len;
     FT_Bitmap*  bitmap = &slot->bitmap;
     FT_ULong    offset;
     FT_Bool     new_format;
 
-    FT_UNUSED( slot );
     FT_UNUSED( load_flags );
 
 
-    if ( !font )
+    if ( !face || !font )
     {
       error = FNT_Err_Invalid_Argument;
       goto Exit;
     }
 
     if ( glyph_index > 0 )
-      glyph_index--;
+      glyph_index--;                           /* revert to real index */
     else
-      glyph_index = font->header.default_char - font->header.first_char;
+      glyph_index = font->header.default_char; /* the .notdef glyph */
 
     new_format = FT_BOOL( font->header.version == 0x300 );
     len        = new_format ? 6 : 4;
 
     /* jump to glyph entry */
-    p = font->fnt_frame + ( new_format ? 146 : 118 ) + len * glyph_index;
+    p = font->fnt_frame + ( new_format ? 148 : 118 ) + len * glyph_index;
 
     bitmap->width = FT_NEXT_SHORT_LE( p );
 
@@ -613,26 +590,49 @@
     else
       offset = FT_NEXT_USHORT_LE( p );
 
+    if ( offset >= font->header.file_size )
+    {
+      FT_TRACE2(( "invalid FNT offset!\n" ));
+      error = FNT_Err_Invalid_File_Format;
+      goto Exit;
+    }
+
     /* jump to glyph data */
     p = font->fnt_frame + /* font->header.bits_offset */ + offset;
 
     /* allocate and build bitmap */
     {
+      FT_Memory  memory = FT_FACE_MEMORY( slot->face );
       FT_Int     pitch  = ( bitmap->width + 7 ) >> 3;
+      FT_Byte*   column;
+      FT_Byte*   write;
 
 
       bitmap->pitch      = pitch;
       bitmap->rows       = font->header.pixel_height;
       bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
 
-      /* note: we don't allocate a new buffer for the bitmap since we */
-      /*       already store the images in the FT_Face                */
-      ft_glyphslot_set_bitmap( slot, p );
+      /* note: since glyphs are stored in columns and not in rows we */
+      /*       can't use ft_glyphslot_set_bitmap                     */
+      if ( FT_ALLOC( bitmap->buffer, pitch * bitmap->rows ) )
+        goto Exit;
+
+      column = (FT_Byte*)bitmap->buffer;
+
+      for ( ; pitch > 0; pitch--, column++ )
+      {
+        FT_Byte*  limit = p + bitmap->rows;
+
+
+        for ( write = column; p < limit; p++, write += bitmap->pitch )
+          *write = *p;
+      }
     }
 
-    slot->bitmap_left = 0;
-    slot->bitmap_top  = font->header.ascent;
-    slot->format      = FT_GLYPH_FORMAT_BITMAP;
+    slot->internal->flags = FT_GLYPH_OWN_BITMAP;
+    slot->bitmap_left     = 0;
+    slot->bitmap_top      = font->header.ascent;
+    slot->format          = FT_GLYPH_FORMAT_BITMAP;
 
     /* now set up metrics */
     slot->metrics.horiAdvance  = bitmap->width << 6;
@@ -647,11 +647,55 @@
   }
 
 
+  static FT_Error
+  winfnt_get_header( FT_Face               face,
+                     FT_WinFNT_HeaderRec  *aheader )
+  {
+    FNT_Font  font = ((FNT_Face)face)->font;
+
+
+    *aheader = font->header;
+
+    return 0;
+  }
+
+
+  static const FT_Service_WinFntRec  winfnt_service_rec =
+  {
+    winfnt_get_header
+  };
+
+ /*
+  *  SERVICE LIST
+  *
+  */
+
+  static const FT_ServiceDescRec  winfnt_services[] =
+  {
+    { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_WINFNT },
+    { FT_SERVICE_ID_WINFNT,    &winfnt_service_rec },
+    { NULL, NULL }
+  };
+
+
+  static FT_Module_Interface
+  winfnt_get_service( FT_Driver         driver,
+                      const FT_String*  service_id )
+  {
+    FT_UNUSED( driver );
+
+    return ft_service_list_lookup( winfnt_services, service_id );
+  }
+
+
+
+
   FT_CALLBACK_TABLE_DEF
   const FT_Driver_ClassRec  winfnt_driver_class =
   {
     {
-      ft_module_font_driver,
+      FT_MODULE_FONT_DRIVER        |
+      FT_MODULE_DRIVER_NO_OUTLINES,
       sizeof ( FT_DriverRec ),
 
       "winfonts",
@@ -662,11 +706,11 @@
 
       (FT_Module_Constructor)0,
       (FT_Module_Destructor) 0,
-      (FT_Module_Requester)  0
+      (FT_Module_Requester)  winfnt_get_service
     },
 
     sizeof( FNT_FaceRec ),
-    sizeof( FNT_SizeRec ),
+    sizeof( FT_SizeRec ),
     sizeof( FT_GlyphSlotRec ),
 
     (FT_Face_InitFunc)        FNT_Face_Init,

Index: winfnt.h
===================================================================
RCS file: /cvs/xorg/xc/extras/freetype2/src/winfonts/winfnt.h,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -d -r1.1 -r1.1.4.1
--- a/winfnt.h	14 Nov 2003 16:48:24 -0000	1.1
+++ b/winfnt.h	15 Apr 2004 10:14:45 -0000	1.1.4.1
@@ -21,11 +21,78 @@
 
 
 #include <ft2build.h>
+#include FT_WINFONTS_H
 #include FT_INTERNAL_DRIVER_H
 
 
 FT_BEGIN_HEADER
 
+  typedef struct  WinMZ_HeaderRec_
+  {
+    FT_UShort  magic;
+    /* skipped content */
+    FT_UShort  lfanew;
+
+  } WinMZ_HeaderRec;
+
+
+  typedef struct  WinNE_HeaderRec_
+  {
+    FT_UShort  magic;
+    /* skipped content */
+    FT_UShort  resource_tab_offset;
+    FT_UShort  rname_tab_offset;
+
+  } WinNE_HeaderRec;
+
+
+  typedef struct  WinNameInfoRec_
+  {
+    FT_UShort  offset;
+    FT_UShort  length;
+    FT_UShort  flags;
+    FT_UShort  id;
+    FT_UShort  handle;
+    FT_UShort  usage;
+
+  } WinNameInfoRec;
+
+
+  typedef struct  WinResourceInfoRec_
+  {
+    FT_UShort  type_id;
+    FT_UShort  count;
+
+  } WinResourceInfoRec;
+
+
+#define WINFNT_MZ_MAGIC  0x5A4D
+#define WINFNT_NE_MAGIC  0x454E
+
+
+  typedef struct  FNT_FontRec_
+  {
+    FT_ULong             offset;
+    FT_Int               size_shift;
+
+    FT_WinFNT_HeaderRec  header;
+
+    FT_Byte*             fnt_frame;
+    FT_ULong             fnt_size;
+
+  } FNT_FontRec, *FNT_Font;
+
+
+  typedef struct  FNT_FaceRec_
+  {
+    FT_FaceRec     root;
+    FNT_Font       font;
+
+    FT_CharMap     charmap_handle;
+    FT_CharMapRec  charmap;  /* a single charmap per face */
+
+  } FNT_FaceRec, *FNT_Face;
+
 
   FT_EXPORT_VAR( const FT_Driver_ClassRec )  winfnt_driver_class;
 




More information about the xorg-commit-diffs mailing list