Release 970616

Sat Jun 14 13:05:23 1997  Andreas Mohr <100.30936@germany.net>

	* [include/mmsystem.h]
	Avoided infinite loop in audio code when accessing
 	WAVEOUTCAPS/WAVEINCAPS/MIDIOUTCAPS/AUXCAPS with rigid variable
 	offsets (I applied WINE_PACKED).

	* [*/*]
	Added "WARNING:" and "ERROR:" to some printf's.
	Just grep for them with '-debugmsg +all'.

	* [multimedia/audio.c] [multimedia/mmsystem.c]
	Implemented wave callbacks: window and function callback.
	Fixed problem with WAVE_NotifyClient().
	Misc fixes.

	* [windows/winhelp.c]
	Fixed problem with windows help telling "Help topic doesn't exist".
	But this problem still remains when using Winword.

Wed Jun 11 09:14:20 1997  Alex Korobka <alex@trantor.pharm.sunysb.edu>

	* [wine.ini]
	New 'fonts' section format. Read documentation/fonts.

	* [controls/icontitle.c] [windows/winpos.c] [windows/nonclient.c]
	  [windows/win.c] [include/win.h]
	Implemented icon titles.

	* [graphics/x11drv/xfont.c] [objects/font.c] [objects/dc.c]
	  [include/x11drv.h] [include/x11font.h] [documentation/fonts]
	Rewrote font mapper from scratch.

	* [tools/fnt2bdf.c]
	Bug fixes. REPLACE FONTS CREATED BY THE PREVIOUS VERSIONS.

	* [windows/defwnd.c] [windows/nonclient.c]
	Word document window activation fix.

	* [windows/mdi.c] [windows/win.c]
	Replaced WCL lists with WIN_BuildWinArray().

Mon Jun  9 23:51:16 1997  Andrew Taylor <andrew@riscan.com>

	* [misc/error.c] [include/windows.h] [if1632/kernel.spec]
	Implemented LogParamError, LogError functions.

Tue Jun  3 23:46:04 1997  Michiel van Loon <mfvl@xs4all.nl>

	* [include/mmsystem.h] [multimedia/audio.c]
	Constants for asynchronous play and record.

	* [multimedia/time.c]
	Filled in some empty functions.

	* [multimedia/mmsystem.c]
	Fixed bugs in waveOutOpen.

	* [multimedia/mmsystem.c] [multimedia/audio.c]
	Implemented Window Callback for wave output at least.

	* [files/file.c]
	Corrected bug in FileDosSetError.
	NULL pointer checking added.

	* [misc/spy.c]
	Added Multimedia messages to SPY_GetMsgName.

Tue Jun 3 22:34:30 1997  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

	* [debugger/*.c][include/peexe.h][loader/*.c][tools/build.c]
	  [tools/fnt2bdf.c][library/sup.c]
	IMAGE_* structs/defines changed fit better to SDK naming
	Don't load non-i386 PE executables.
	%fs should already be initialised for the FIRST loaded PE module.

	* [if1632/advapi.spec][win32/advapi.c]
	Some small stubs added to bring win32 setup.exe a bit farther.

	* [if1632/kernel32.spec][scheduler/process.c]
	Adapted to match win95 kernel32.dll ordinals (NT doesn't use
 	ordinal import), some ordinal only exported functions added.

	* [if1632/relay.c]
	Added CallProc32W.

	* [misc/lzexpand.c]
	Fixed return values of GetExpandedName* (thanks to Andreas Mohr).

	* [objects/dib.c]
	Everything with more than 8 bit of color is a truecolor mode
	and doesn't have a colormap.

Tue Jun  3 09:24:53 1997  John Harvey <john@division.co.uk>

	* [graphics/win16drv/font.c] [graphics/win16drv/init.c]
	  [graphics/win16drv/prtdrv.c] [graphics/win16drv/text.c]
	  [include/win16drv.h]
	Changed some structures that are passed to and from the 16 bit
 	drivers to be allocated on the global heap.
	Implemented Escape(Control) 0x100 GetExtTextData properly to
	stop word from crashing.
	Postscript driver now prints on complete page instead of top
	left corner.
	Print spooling implemented.

	* [loader/module.c]
	MODULE_GetOrdinal changed char buffer to unsigned char to stop
	a loop that was happening when running the font control
	program from the control panel.

Sun Jun  1 19:05:02 1997  Peter Schlaile <up9n@rz.uni-karlsruhe.de>

	* [include/miscemu.h] [loader/main.c] [msdos/ioports.c]
	Added support for direct io port access.

Fri May 30 16:18:35 1997  David A. Cuthbert <dacut@dssc3353.ece.cmu.edu>

	* [misc/ver.c]
	Implemented VerFindFile16.

Tue May 27 22:00:39 1997  Rick Richardson <rick@dgii.com>

	* [misc/comm.c]
	Fixed GetCommError and GetCommEventMask.

Tue May 27  9:10:53 1997  Georg Beyerle <gbeyerle@awi-potsdam.de>

	* [scheduler/thread.c]
	Minor fix in thread database initialization.

Mon May 26 19:46:34 1997  Philippe De Muyter  <phdm@info.ucl.ac.be>

	* [objects/dc.c]
	In DC_SetupGCForPen, avoid to draw in GXxor mode with a 0 mask.

Mon May 26 15:22:42 1997  Bruce Milner <Bruce.Milner@genetics.utah.edu>

	* [loader/pe_image.c]
	Add code for modules that co-reference each other. Photodex's
	agds.exe (cpic32) has two dll's that make calls into each other.

Mon May 26 13:38:16 1997  Jody Goldberg <jodyg@idt.net>

	* [memory/virtual.c]
	Dont use stdio when reading /proc/self/maps.  It causes problems
	with libc6.

	* [windows/dialog.c]
	Translate messages in IsDialogMessage when DLGC_WANTMESSAGE
	is used.

Sun May 25 17:02:21 1997  Huw D M Davies <h.davies1@physics.oxford.ac.uk>

	* [objects/metafile.c]
	Resource cleanup in EnumMetaFile(). This was one reason Word was
	crashing after long periods of use. (Thanks to Chris Underhill for
	the logs)

Sun May 25 14:59:33 1997  Jimen Ching  <jching@flex.com>

	* [multimedia/mcistring.c]
	Initial support for compound MCI commands.
	Use case-insensitive compare for 'alias' and 'element' keywords.
	Fixed pointer copy of args keywords array.
diff --git a/objects/color.c b/objects/color.c
index 3442d91..074359d 100644
--- a/objects/color.c
+++ b/objects/color.c
@@ -31,8 +31,8 @@
  * because pixel values can be calculated without X server 
  * assistance.
  *
- * For some info about general Windows palette management read
- * http://198.105.232.5/MSDN/LIBRARY/TECHNOTE/CH3.HTM 
+ * Windows palette manager is described in the
+ * http://premium.microsoft.com/msdn/library/techart/f30/f34/f40/d4d/sa942.htm
  */
 
 typedef struct
@@ -41,7 +41,8 @@
     UINT16      size;
     UINT16      flags;
     INT32	monoPlane;	 /* bit plane different for white and black pixels */
-    BOOL32	bWhiteOn;	 /* monoPlane bit is 1 for the white pixel */
+
+    INT32	(*mapColor)( DC*, COLORREF );
 } CSPACE;
 
 static CSPACE cSpace = {0, 0, 0};
@@ -61,7 +62,6 @@
  * currently inactive window it changes only DC palette mappings.
  */
 
-#define NB_RESERVED_COLORS  		20 /* number of fixed colors in system palette */
 #define NB_COLORCUBE_START_INDEX	63
 
 Visual* 		visual = NULL;
@@ -143,6 +143,11 @@
     return cSpace.flags;
 }
 
+const PALETTEENTRY* COLOR_GetSystemPaletteTemplate(void)
+{
+    return __sysPalTemplate;
+}
+
 COLORREF COLOR_GetSystemPaletteEntry(UINT32 i)
 {
  return *(COLORREF*)(COLOR_sysPal + i) & 0x00ffffff;
@@ -176,7 +181,10 @@
   return 1;
 }
 
-void COLOR_FillDefaultColors(void)
+/***********************************************************************
+ *      Colormap Initialization
+ */
+static void COLOR_FillDefaultColors(void)
 {
  /* initialize unused entries to what Windows uses as a color 
   * cube - based on Greg Kreider's code. 
@@ -530,58 +538,6 @@
    return TRUE;
 }
 
-
-/***********************************************************************
- *           COLOR_InitPalette
- *
- * Create the system palette.
- */
-static HPALETTE16 COLOR_InitPalette(void)
-{
-    int 		i;
-    HPALETTE16 		hpalette;
-    LOGPALETTE * 	palPtr;
-    PALETTEOBJ*         palObj;
-
-    memset(COLOR_freeList, 0, 256*sizeof(unsigned char));
-
-    if (cSpace.flags & COLOR_PRIVATE)
-	COLOR_BuildPrivateMap( &cSpace );
-    else
-	COLOR_BuildSharedMap( &cSpace );
-
-    /* Build free list */
-
-    if( COLOR_firstFree != -1 )
-	COLOR_FormatSystemPalette();
-
-    COLOR_FillDefaultColors();
-
-    /* create default palette (20 system colors) */
-
-    palPtr = xmalloc( sizeof(LOGPALETTE) + (NB_RESERVED_COLORS-1)*sizeof(PALETTEENTRY) );
-    if (!palPtr) return FALSE;
-
-    palPtr->palVersion = 0x300;
-    palPtr->palNumEntries = NB_RESERVED_COLORS;
-    for( i = 0; i < NB_RESERVED_COLORS; i ++ )
-    {
-        palPtr->palPalEntry[i].peRed = __sysPalTemplate[i].peRed;
-        palPtr->palPalEntry[i].peGreen = __sysPalTemplate[i].peGreen;
-        palPtr->palPalEntry[i].peBlue = __sysPalTemplate[i].peBlue;
-        palPtr->palPalEntry[i].peFlags = 0;  
-    }
-    hpalette = CreatePalette16( palPtr );
-
-    palObj = (PALETTEOBJ*) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
-
-    palObj->mapping = xmalloc( sizeof(int) * 20 );
-
-    free( palPtr );
-    return hpalette;
-}
-
-
 /***********************************************************************
  *	     COLOR_Computeshifts
  *
@@ -609,10 +565,9 @@
 /***********************************************************************
  *           COLOR_Init
  *
- * Initialize color map and system palette.
- *
+ * Initialize color management.
  */
-HPALETTE16 COLOR_Init(void)
+BOOL32 COLOR_Init(void)
 {
     int	mask, white, black;
 
@@ -680,7 +635,21 @@
     dprintf_palette(stddeb," visual class %i (%i)\n", 
 		    visual->class, cSpace.monoPlane);
 
-    return COLOR_InitPalette();
+    memset(COLOR_freeList, 0, 256*sizeof(unsigned char));
+
+    if (cSpace.flags & COLOR_PRIVATE)
+        COLOR_BuildPrivateMap( &cSpace );
+    else
+        COLOR_BuildSharedMap( &cSpace );
+
+    /* Build free list */
+
+    if( COLOR_firstFree != -1 )
+        COLOR_FormatSystemPalette();
+
+    COLOR_FillDefaultColors();
+
+    return TRUE;
 }
 
 /***********************************************************************
@@ -868,31 +837,8 @@
 int COLOR_ToPhysical( DC *dc, COLORREF color )
 {
     WORD 		 index = 0;
-    unsigned char	 spec_type;
     HPALETTE16		 hPal = (dc)? dc->w.hPalette: STOCK_DEFAULT_PALETTE;
-
-    spec_type = color >> 24;
-
-    if( spec_type == 0xff )
-    {
-	spec_type = 0; /* 'write' seems to need that for 'Page 1' text */
-	color &= 0xffffff;
-    }
-
-    if( spec_type > 2 )
-    {  
-	dprintf_palette(stddeb, "COLOR_ToPhysical : invalid RGB specifier for: %08lx\n", color);
-	spec_type = 0;
-    }
-
-    if (dc && (dc->w.bitsPerPixel == 1) && (spec_type == 0))
-    {
-	/* monochrome */
-        if (((color >> 16) & 0xff) +
-            ((color >> 8) & 0xff) + (color & 0xff) > 255*3/2)
-             return 1;   /* white */
-        else return 0;   /* black */
-    }
+    unsigned char	 spec_type = color >> 24;
 
     if ( cSpace.flags & COLOR_FIXED )
     {
@@ -919,7 +865,7 @@
 
           case 1: /* PALETTEINDEX */
 
-            if ( (idx = color & 0xffff) >= palPtr->logpalette.palNumEntries)
+            if( (idx = color & 0xffff) >= palPtr->logpalette.palNumEntries)
             {
                 fprintf(stderr, "\tRGB(%lx) : idx %d is out of bounds, assuming black\n", color, idx);
                 return 0;
@@ -928,11 +874,16 @@
             if( palPtr->mapping ) return palPtr->mapping[idx];
 
 	    color = *(COLORREF*)(palPtr->logpalette.palPalEntry + idx);
+	    break;
 
-	    /* fall through and out */
+	  default:
+	    color &= 0xffffff;
+	    /* fall through to RGB */
 
 	  case 0: /* RGB */
-	  default:
+	    if( dc && (dc->w.bitsPerPixel == 1) )
+		return (((color >> 16) & 0xff) +
+			((color >> 8) & 0xff) + (color & 0xff) > 255*3/2) ? 1 : 0;
 	}
 
         red = GetRValue(color); green = GetGValue(color); blue = GetBValue(color);
@@ -965,7 +916,14 @@
 	switch(spec_type)	/* we have to peruse DC and system palette */
     	{
 	    default:
+		color &= 0xffffff;
+		/* fall through to RGB */
+
        	    case 0:  /* RGB */
+		if( dc && (dc->w.bitsPerPixel == 1) )
+		    return (((color >> 16) & 0xff) +
+			    ((color >> 8) & 0xff) + (color & 0xff) > 255*3/2) ? 1 : 0;
+
 	    	index = COLOR_PaletteLookupPixel( COLOR_sysPal, 256, 
 						  COLOR_PaletteToPixel, color, FALSE);
 
diff --git a/objects/dc.c b/objects/dc.c
index 6d31cd8..4f25c90 100644
--- a/objects/dc.c
+++ b/objects/dc.c
@@ -14,6 +14,7 @@
 #include "color.h"
 #include "debug.h"
 #include "font.h"
+#include "x11font.h"
 
 extern void CLIPPING_UpdateGCRegion( DC * dc );     /* objects/clipping.c */
 
@@ -301,17 +302,28 @@
 
     if (dc->w.flags & DC_DIRTY) CLIPPING_UpdateGCRegion(dc); 
 
-    if ((screenDepth <= 8) &&  /* FIXME: Should check for palette instead */
-        ((dc->w.ROPmode == R2_BLACK) || (dc->w.ROPmode == R2_WHITE)))
+    switch (dc->w.ROPmode)
     {
-        val.function   = GXcopy;
-        val.foreground = COLOR_ToPhysical( NULL, (dc->w.ROPmode == R2_BLACK) ?
-                                               RGB(0,0,0) : RGB(255,255,255) );
-    }
-    else
-    {
-        val.function   = DC_XROPfunction[dc->w.ROPmode-1];
-        val.foreground = dc->u.x.pen.pixel;
+    case R2_BLACK :
+	val.foreground = BlackPixel(display, DefaultScreen(display));
+	val.function = GXcopy;
+	break;
+    case R2_WHITE :
+	val.foreground = WhitePixel(display, DefaultScreen(display));
+	val.function = GXcopy;
+	break;
+    case R2_XORPEN :
+	val.foreground = dc->u.x.pen.pixel;
+	/* It is very unlikely someone wants to XOR with 0 */
+	/* This fixes the rubber-drawings in paintbrush */
+	if (val.foreground == 0)
+	    val.foreground = BlackPixel(display, DefaultScreen(display))
+			    ^ WhitePixel(display, DefaultScreen(display));
+	val.function = GXxor;
+	break;
+    default :
+	val.foreground = dc->u.x.pen.pixel;
+	val.function   = DC_XROPfunction[dc->w.ROPmode-1];
     }
     val.background = dc->w.backgroundPixel;
     val.fill_style = FillSolid;
@@ -341,25 +353,27 @@
  */
 BOOL32 DC_SetupGCForText( DC * dc )
 {
-    XGCValues val;
+    XFontStruct* xfs = XFONT_GetFontStruct( dc->u.x.font );
 
-    if (!dc->u.x.font.fstruct)
+    if( xfs )
     {
-        fprintf( stderr, "DC_SetupGCForText: fstruct is NULL. Please report this\n" );
-        return FALSE;
-    }
-   
-    if (dc->w.flags & DC_DIRTY) CLIPPING_UpdateGCRegion(dc);
+	XGCValues val;
 
-    val.function   = GXcopy;  /* Text is always GXcopy */
-    val.foreground = dc->w.textPixel;
-    val.background = dc->w.backgroundPixel;
-    val.fill_style = FillSolid;
-    val.font       = dc->u.x.font.fstruct->fid;
-    XChangeGC( display, dc->u.x.gc, 
-	       GCFunction | GCForeground | GCBackground | GCFillStyle |
-	       GCFont, &val );
-    return TRUE;
+	if (dc->w.flags & DC_DIRTY) CLIPPING_UpdateGCRegion(dc);
+
+	val.function   = GXcopy;  /* Text is always GXcopy */
+	val.foreground = dc->w.textPixel;
+	val.background = dc->w.backgroundPixel;
+	val.fill_style = FillSolid;
+	val.font       = xfs->fid;
+
+	XChangeGC( display, dc->u.x.gc,
+		   GCFunction | GCForeground | GCBackground | GCFillStyle |
+		   GCFont, &val );
+	return TRUE;
+    } 
+    fprintf( stderr, "DC_SetupGCForText: physical font failure\n" );
+    return FALSE;
 }
 
 
diff --git a/objects/dib.c b/objects/dib.c
index a951745..94743db 100644
--- a/objects/dib.c
+++ b/objects/dib.c
@@ -49,6 +49,9 @@
 {
     int		i;
 
+    if (!ximageDepthTable[0]) {
+	    DIB_Init();
+    }
     for( i = 0; bitmapDepthTable[i] ; i++ )
 	 if( bitmapDepthTable[i] == depth )
 	     return (4 * ((width * ximageDepthTable[i] + 31)/32));
@@ -97,14 +100,14 @@
     if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
     {
         BITMAPCOREHEADER *core = (BITMAPCOREHEADER *)info;
-        colors = (core->bcBitCount != 24) ? 1 << core->bcBitCount : 0;
+        colors = (core->bcBitCount <= 8) ? 1 << core->bcBitCount : 0;
         return sizeof(BITMAPCOREHEADER) + colors *
              ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBTRIPLE) : sizeof(WORD));
     }
     else  /* assume BITMAPINFOHEADER */
     {
         colors = info->bmiHeader.biClrUsed;
-        if (!colors && (info->bmiHeader.biBitCount != 24))
+        if (!colors && (info->bmiHeader.biBitCount <= 8))
             colors = 1 << info->bmiHeader.biBitCount;
         return sizeof(BITMAPINFOHEADER) + colors *
                ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD));
@@ -590,10 +593,12 @@
 
       /* Build the color mapping table */
 
-    if (infoBpp == 24) colorMapping = NULL;
-    else
+    if (infoBpp > 8) {
+	    	colorMapping = NULL;
+    } else {
         if (!(colorMapping = DIB_BuildColorMap( dc, coloruse, depth, info )))
             return 0;
+    }
 
     if( dc->w.flags & DC_DIRTY ) CLIPPING_UpdateGCRegion(dc);
 
diff --git a/objects/font.c b/objects/font.c
index 3ac17db..e79c6b6 100644
--- a/objects/font.c
+++ b/objects/font.c
@@ -2,308 +2,206 @@
  * GDI font objects
  *
  * Copyright 1993 Alexandre Julliard
- *
- * Enhacements by Juergen Marquardt 1996
- *
- * Implementation of a second font cache which 
- * will be updated dynamically
+ *           1997 Alex Korobka
  */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <X11/Xatom.h>
 #include "font.h"
 #include "heap.h"
 #include "metafile.h"
 #include "options.h"
-#include "xmalloc.h"
 #include "stddebug.h"
 #include "debug.h"
 
-LPLOGFONT16 lpLogFontList[MAX_FONTS+1];
+#define ENUM_UNICODE	0x00000001
 
-
-#define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \
-			     (((cs)->rbearing|(cs)->lbearing| \
-			       (cs)->ascent|(cs)->descent) == 0))
-
-/* 
- * CI_GET_CHAR_INFO - return the charinfo struct for the indicated 8bit
- * character.  If the character is in the column and exists, then return the
- * appropriate metrics (note that fonts with common per-character metrics will
- * return min_bounds).  If none of these hold true, try again with the default
- * char.
- */
-#define CI_GET_CHAR_INFO(fs,col,def,cs) \
-{ \
-    cs = def; \
-    if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
-	if (fs->per_char == NULL) { \
-	    cs = &fs->min_bounds; \
-	} else { \
-	    cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \
-	    if (CI_NONEXISTCHAR(cs)) cs = def; \
-	} \
-    } \
-}
-
-#define CI_GET_DEFAULT_INFO(fs,cs) \
-  CI_GET_CHAR_INFO(fs, fs->default_char, NULL, cs)
-
-
-
-
-/***********************************************************************
- *           FONT_LOGFONT32AToLOGFONT16
- */
-static void FONT_LOGFONT32AToLOGFONT16( const LOGFONT32A *font,
-                                        LPLOGFONT16 font16 )
+typedef struct
 {
-    font16->lfHeight         = (INT16)font->lfHeight;
-    font16->lfWidth          = (INT16)font->lfWidth;
-    font16->lfEscapement     = (INT16)font->lfEscapement;
-    font16->lfOrientation    = (INT16)font->lfOrientation;
-    font16->lfWeight         = (INT16)font->lfWeight;
-    font16->lfItalic         = font->lfItalic;
-    font16->lfUnderline      = font->lfUnderline;
-    font16->lfStrikeOut      = font->lfStrikeOut;
-    font16->lfCharSet        = font->lfCharSet;
-    font16->lfOutPrecision   = font->lfOutPrecision;
-    font16->lfClipPrecision  = font->lfClipPrecision;
-    font16->lfQuality        = font->lfQuality;
-    font16->lfPitchAndFamily = font->lfPitchAndFamily;
-    lstrcpyn32A( font16->lfFaceName, font->lfFaceName, LF_FACESIZE );
-}
+  LPLOGFONT16           lpLogFontParam;
+  FONTENUMPROCEX16      lpEnumFunc;
+  LPARAM                lpData;
 
+  LPNEWTEXTMETRICEX16   lpTextMetric;
+  LPENUMLOGFONTEX16     lpLogFont;
+  SEGPTR                segTextMetric;
+  SEGPTR                segLogFont;
+} fontEnum16;
 
-/***********************************************************************
- *           FONT_LOGFONT32WToLOGFONT16
- */
-static void FONT_LOGFONT32WToLOGFONT16( const LOGFONT32W *font,
-                                        LPLOGFONT16 font16 )
+typedef struct
 {
-    font16->lfHeight         = (INT16)font->lfHeight;
-    font16->lfWidth          = (INT16)font->lfWidth;
-    font16->lfEscapement     = (INT16)font->lfEscapement;
-    font16->lfOrientation    = (INT16)font->lfOrientation;
-    font16->lfWeight         = (INT16)font->lfWeight;
-    font16->lfItalic         = font->lfItalic;
-    font16->lfUnderline      = font->lfUnderline;
-    font16->lfStrikeOut      = font->lfStrikeOut;
-    font16->lfCharSet        = font->lfCharSet;
-    font16->lfOutPrecision   = font->lfOutPrecision;
-    font16->lfClipPrecision  = font->lfClipPrecision;
-    font16->lfQuality        = font->lfQuality;
-    font16->lfPitchAndFamily = font->lfPitchAndFamily;
-    lstrcpynWtoA( font16->lfFaceName, font->lfFaceName, LF_FACESIZE );
-}
+  LPLOGFONT32W          lpLogFontParam;
+  FONTENUMPROC32W       lpEnumFunc;
+  LPARAM                lpData;
 
-
+  LPNEWTEXTMETRICEX32W  lpTextMetric;
+  LPENUMLOGFONTEX32W    lpLogFont;
+  DWORD                 dwFlags;
+} fontEnum32;
+ 
 /***********************************************************************
- *           FONT_LOGFONT16ToLOGFONT32A
+ *              LOGFONT conversion functions.
  */
-static void FONT_LOGFONT16ToLOGFONT32A( LPLOGFONT16 font,
-                                        LPLOGFONT32A font32A )
+static void __logfont32to16( INT16* plf16, INT32* plf32 )
 {
-    font32A->lfHeight         = (INT32)font->lfHeight;
-    font32A->lfWidth          = (INT32)font->lfWidth;
-    font32A->lfEscapement     = (INT32)font->lfEscapement;
-    font32A->lfOrientation    = (INT32)font->lfOrientation;
-    font32A->lfWeight         = (INT32)font->lfWeight;
-    font32A->lfItalic         = font->lfItalic;
-    font32A->lfUnderline      = font->lfUnderline;
-    font32A->lfStrikeOut      = font->lfStrikeOut;
-    font32A->lfCharSet        = font->lfCharSet;
-    font32A->lfOutPrecision   = font->lfOutPrecision;
-    font32A->lfClipPrecision  = font->lfClipPrecision;
-    font32A->lfQuality        = font->lfQuality;
-    font32A->lfPitchAndFamily = font->lfPitchAndFamily;
-    lstrcpyn32A( font32A->lfFaceName, font->lfFaceName, LF_FACESIZE );
+    int  i;
+    for( i = 0; i < 5; i++ ) *plf16++ = *plf32++;
+   *((INT32*)plf16)++ = *plf32++;
+   *((INT32*)plf16)   = *plf32;
 }
 
-
-/***********************************************************************
- *           FONT_LOGFONT16ToLOGFONT32W
- */
-static void FONT_LOGFONT16ToLOGFONT32W( LPLOGFONT16 font,
-                                        LPLOGFONT32W font32W )
+static void __logfont16to32( INT32* plf32, INT16* plf16 )
 {
-    font32W->lfHeight         = (INT32)font->lfHeight;
-    font32W->lfWidth          = (INT32)font->lfWidth;
-    font32W->lfEscapement     = (INT32)font->lfEscapement;
-    font32W->lfOrientation    = (INT32)font->lfOrientation;
-    font32W->lfWeight         = (INT32)font->lfWeight;
-    font32W->lfItalic         = font->lfItalic;
-    font32W->lfUnderline      = font->lfUnderline;
-    font32W->lfStrikeOut      = font->lfStrikeOut;
-    font32W->lfCharSet        = font->lfCharSet;
-    font32W->lfOutPrecision   = font->lfOutPrecision;
-    font32W->lfClipPrecision  = font->lfClipPrecision;
-    font32W->lfQuality        = font->lfQuality;
-    font32W->lfPitchAndFamily = font->lfPitchAndFamily;
-    lstrcpynAtoW( font32W->lfFaceName, font->lfFaceName, LF_FACESIZE );
+    int i;
+    for( i = 0; i < 5; i++ ) *plf32++ = *plf16++;
+   *plf32++ = *((INT32*)plf16)++;
+   *plf32   = *((INT32*)plf16);
 }
 
-
-/***********************************************************************
- *           FONT_GetMetrics
- */
-void FONT_GetMetrics( LOGFONT16 * logfont, XFontStruct * xfont,
-		      TEXTMETRIC16 * metrics )
-{    
-    int average, i, count;
-    unsigned long prop;
-	
-    metrics->tmAscent  = xfont->ascent;
-    metrics->tmDescent = xfont->descent;
-    metrics->tmHeight  = xfont->ascent + xfont->descent;
-
-    metrics->tmInternalLeading  = 0;
-    if (XGetFontProperty( xfont, XA_CAP_HEIGHT, &prop ))
-	metrics->tmInternalLeading = xfont->ascent+xfont->descent-(INT16)prop;
-
-    metrics->tmExternalLeading  = 0;
-    metrics->tmMaxCharWidth     = xfont->max_bounds.width;
-    metrics->tmWeight           = logfont->lfWeight;
-    metrics->tmItalic           = logfont->lfItalic;
-    metrics->tmUnderlined       = logfont->lfUnderline;
-    metrics->tmStruckOut        = logfont->lfStrikeOut;
-    metrics->tmFirstChar        = xfont->min_char_or_byte2;
-    metrics->tmLastChar         = xfont->max_char_or_byte2;
-    metrics->tmDefaultChar      = xfont->default_char;
-    metrics->tmBreakChar        = ' ';
-    metrics->tmCharSet          = logfont->lfCharSet;
-    metrics->tmOverhang         = 0;
-    metrics->tmDigitizedAspectX = 1;
-    metrics->tmDigitizedAspectY = 1;
-    metrics->tmPitchAndFamily   = (logfont->lfPitchAndFamily&0xf0)|TMPF_DEVICE;
-
-    /* TMPF_FIXED_PITCH bit means variable pitch...Don't you love Microsoft? */
-    if (xfont->min_bounds.width != xfont->max_bounds.width)
-        metrics->tmPitchAndFamily |= TMPF_FIXED_PITCH;
-
-    if (!xfont->per_char) average = metrics->tmMaxCharWidth;
-    else
-    {
-	XCharStruct * charPtr = xfont->per_char;
-	average = count = 0;
-	for (i = metrics->tmFirstChar; i <= metrics->tmLastChar; i++)
-	{
-	    if (!CI_NONEXISTCHAR( charPtr ))
-	    {
-		average += charPtr->width;
-		count++;
-	    }
-	    charPtr++;
-	}
-	if (count) average = (average + count/2) / count;
-    }
-    metrics->tmAveCharWidth = average;
-}
-
-
-/***********************************************************************
- *           GetGlyphOutline16    (GDI.309)
- */
-DWORD GetGlyphOutline16( HDC16 hdc, UINT16 uChar, UINT16 fuFormat,
-                         LPGLYPHMETRICS16 lpgm, DWORD cbBuffer,
-                         LPVOID lpBuffer, const MAT2 *lpmat2 )
+void FONT_LogFont32ATo16( const LOGFONT32A* font32, LPLOGFONT16 font16 )
 {
-    fprintf( stdnimp,"GetGlyphOutLine16(%04x, '%c', %04x, %p, %ld, %p, %p) // - empty stub!\n",
-             hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
-    return (DWORD)-1; /* failure */
+  __logfont32to16( (INT16*)font16, (INT32*)font32 );
+    lstrcpyn32A( font16->lfFaceName, font32->lfFaceName, LF_FACESIZE );
 }
 
-
-/***********************************************************************
- *           GetGlyphOutline32A    (GDI32.186)
- */
-DWORD GetGlyphOutline32A( HDC32 hdc, UINT32 uChar, UINT32 fuFormat,
-                         LPGLYPHMETRICS32 lpgm, DWORD cbBuffer,
-                         LPVOID lpBuffer, const MAT2 *lpmat2 )
+void FONT_LogFont32WTo16( const LOGFONT32W* font32, LPLOGFONT16 font16 )
 {
-    fprintf( stdnimp,"GetGlyphOutLine32A(%04x, '%c', %04x, %p, %ld, %p, %p) // - empty stub!\n",
-             hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
-    return (DWORD)-1; /* failure */
+  __logfont32to16( (INT16*)font16, (INT32*)font32 );
+    lstrcpynWtoA( font16->lfFaceName, font32->lfFaceName, LF_FACESIZE );
 }
 
-
-/***********************************************************************
- *           GetGlyphOutline32W    (GDI32.187)
- */
-DWORD GetGlyphOutline32W( HDC32 hdc, UINT32 uChar, UINT32 fuFormat,
-                         LPGLYPHMETRICS32 lpgm, DWORD cbBuffer,
-                         LPVOID lpBuffer, const MAT2 *lpmat2 )
+void FONT_LogFont16To32A( LPLOGFONT16 font16, LPLOGFONT32A font32 )
 {
-    fprintf( stdnimp,"GetGlyphOutLine32W(%04x, '%c', %04x, %p, %ld, %p, %p) // - empty stub!\n",
-             hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
-    return (DWORD)-1; /* failure */
+  __logfont16to32( (INT32*)font32, (INT16*)font16 );
+    lstrcpyn32A( font32->lfFaceName, font16->lfFaceName, LF_FACESIZE );
 }
 
-
-/***********************************************************************
- *           CreateScalableFontResource16   (GDI.310)
- */
-BOOL16 CreateScalableFontResource16( UINT16 fHidden, LPCSTR lpszResourceFile,
-                                     LPCSTR fontFile, LPCSTR path )
+void FONT_LogFont16To32W( LPLOGFONT16 font16, LPLOGFONT32W font32 )
 {
-    return CreateScalableFontResource32A( fHidden, lpszResourceFile,
-                                          fontFile, path );
+  __logfont16to32( (INT32*)font32, (INT16*)font16 );
+    lstrcpynAtoW( font32->lfFaceName, font16->lfFaceName, LF_FACESIZE );
 }
 
 /***********************************************************************
- *           CreateScalableFontResource32A   (GDI32.62)
+ *              TEXTMETRIC conversion functions.
  */
-BOOL32 CreateScalableFontResource32A( DWORD fHidden, LPCSTR lpszResourceFile,
-                                      LPCSTR lpszFontFile,
-                                      LPCSTR lpszCurrentPath )
+void FONT_TextMetric32Ato16( LPTEXTMETRIC32A ptm32, LPTEXTMETRIC16 ptm16 )
 {
-    /* fHidden=1 - only visible for the calling app, read-only, not
-     * enumbered with EnumFonts/EnumFontFamilies
-     * lpszCurrentPath can be NULL
-     */
-    fprintf(stdnimp,"CreateScalableFontResource(%ld,%s,%s,%s) // empty stub\n",
-            fHidden, lpszResourceFile, lpszFontFile, lpszCurrentPath );
-    return FALSE; /* create failed */
+    int         i;
+    INT16*      pi16 = (INT16*)ptm16;
+
+   *(INT32*)&ptm16->tmFirstChar = *(INT32*)&ptm32->tmFirstChar;
+   *(INT32*)&ptm16->tmItalic = *(INT32*)&ptm32->tmItalic;
+   *(INT16*)&ptm16->tmPitchAndFamily = *(INT16*)&ptm32->tmPitchAndFamily;
+#define pi32 ((INT32*)ptm32)
+    for( i = 0; i < 8; i++ ) *pi16++ = *pi32++;
+    ptm16->tmOverhang = pi32[0];
+    ptm16->tmDigitizedAspectX = pi32[1];
+    ptm16->tmDigitizedAspectY = pi32[2];
+#undef  pi32
 }
 
-
-/***********************************************************************
- *           CreateScalableFontResource32W   (GDI32.63)
- */
-BOOL32 CreateScalableFontResource32W( DWORD fHidden, LPCWSTR lpszResourceFile,
-                                      LPCWSTR lpszFontFile,
-                                      LPCWSTR lpszCurrentPath )
+void FONT_TextMetric32Wto16( LPTEXTMETRIC32W ptm32, LPTEXTMETRIC16 ptm16 )
 {
-    fprintf(stdnimp,"CreateScalableFontResource32W(%ld,%p,%p,%p) // empty stub\n",
-            fHidden, lpszResourceFile, lpszFontFile, lpszCurrentPath );
-    return FALSE; /* create failed */
+    int         i;
+    INT16*      pi16 = (INT16*)ptm16;
+
+    ptm16->tmFirstChar = ptm32->tmFirstChar;
+    ptm16->tmLastChar = ptm32->tmLastChar;
+    ptm16->tmDefaultChar = ptm32->tmDefaultChar;
+    ptm16->tmBreakChar = ptm32->tmBreakChar;
+   *(INT32*)&ptm16->tmItalic = *(INT32*)&ptm32->tmItalic;
+   *(INT16*)&ptm16->tmPitchAndFamily = *(INT16*)&ptm32->tmPitchAndFamily;
+#define pi32 ((INT32*)ptm32)
+    for( i = 0; i < 8; i++ ) *pi16++ = *pi32++;
+    ptm16->tmOverhang = pi32[0];
+    ptm16->tmDigitizedAspectX = pi32[1];
+    ptm16->tmDigitizedAspectY = pi32[2];
+#undef  pi32
 }
 
+void FONT_TextMetric16to32A( LPTEXTMETRIC16 ptm16, LPTEXTMETRIC32A ptm32 )
+{
+    int         i;
+    INT16*      pi16 = (INT16*)ptm16;
+
+   *(INT32*)&ptm32->tmFirstChar = *(INT32*)&ptm16->tmFirstChar;
+   *(INT32*)&ptm32->tmItalic = *(INT32*)&ptm16->tmItalic;
+   *(INT16*)&ptm32->tmPitchAndFamily = *(INT16*)&ptm16->tmPitchAndFamily;
+#define pi32 ((INT32*)ptm32)
+    for( i = 0; i < 8; i++ ) *pi32++ = *pi16++;
+    pi32[0] = ptm16->tmOverhang;
+    pi32[1] = ptm16->tmDigitizedAspectX;
+    pi32[2] = ptm16->tmDigitizedAspectY;
+#undef  pi32
+}
+
+void FONT_TextMetric16to32W( LPTEXTMETRIC16 ptm16, LPTEXTMETRIC32W ptm32 )
+{
+    int         i;
+    INT16*      pi16 = (INT16*)ptm16;
+
+    ptm32->tmFirstChar = ptm16->tmFirstChar;
+    ptm32->tmLastChar = ptm16->tmLastChar;
+    ptm32->tmDefaultChar = ptm16->tmDefaultChar;
+    ptm32->tmBreakChar = ptm16->tmBreakChar;
+   *(INT32*)&ptm32->tmItalic = *(INT32*)&ptm16->tmItalic;
+   *(INT16*)&ptm32->tmPitchAndFamily = *(INT16*)&ptm16->tmPitchAndFamily;
+#define pi32 ((INT32*)ptm32)
+    for( i = 0; i < 8; i++ ) *pi32++ = *pi16++;
+    pi32[0] = ptm16->tmOverhang;
+    pi32[1] = ptm16->tmDigitizedAspectX;
+    pi32[2] = ptm16->tmDigitizedAspectY;
+#undef  pi32
+}
+
+void FONT_TextMetric32Ato32W( LPTEXTMETRIC32A ptm32A, LPTEXTMETRIC32W ptm32W )
+{
+    int         i;
+#define pi32A ((INT32*)ptm32A)
+#define pi32W ((INT32*)ptm32W)
+    for( i = 0; i < 8; i++ ) *pi32W++ = *pi32A++;
+#undef pi32W
+#undef pi32A
+#define pch32A ((BYTE*)ptm32A)
+#define pch32W ((WCHAR*)ptm32W)
+   for( i = 0; i < 4; i++ ) *pch32W++ = *pch32A++;
+#undef pch32W
+#define pch32W ((BYTE*)ptm32W)
+   for( i = 0; i < 5; i++ ) *pch32W++ = *pch32A++;
+#undef pch32W
+#undef pch32A
+}
 
 /***********************************************************************
  *           CreateFontIndirect16   (GDI.57)
  */
 HFONT16 CreateFontIndirect16( const LOGFONT16 *font )
 {
-    FONTOBJ * fontPtr;
-    HFONT16 hfont;
+    HFONT16 hFont = 0;
 
-    if (!font)
+    if (font)
     {
-	fprintf(stderr,"CreateFontIndirect: font is NULL : returning NULL\n");
-	return 0;
-    }
-    hfont = GDI_AllocObject( sizeof(FONTOBJ), FONT_MAGIC );
-    if (!hfont) return 0;
-    fontPtr = (FONTOBJ *) GDI_HEAP_LIN_ADDR( hfont );
-    memcpy( &fontPtr->logfont, font, sizeof(LOGFONT16) );
-    dprintf_font(stddeb,"CreateFontIndirect(%p (%d,%d)); return %04x\n",
-	font, font->lfHeight, font->lfWidth, hfont);
-    return hfont;
-}
+	hFont = GDI_AllocObject( sizeof(FONTOBJ), FONT_MAGIC );
+	if( hFont )
+	{
+	    FONTOBJ* fontPtr;
+	    fontPtr = (FONTOBJ *) GDI_HEAP_LIN_ADDR( hFont );
+	    memcpy( &fontPtr->logfont, font, sizeof(LOGFONT16) );
 
+	    dprintf_font(stddeb,"CreateFontIndirect(%i %i) '%s' %s %s => %04x\n",
+				 font->lfHeight, font->lfWidth, 
+				 font->lfFaceName ? font->lfFaceName : "NULL",
+				 font->lfWeight > 400 ? "Bold" : "",
+				 font->lfItalic ? "Italic" : "",
+				 hFont);
+	}
+    }
+    else fprintf(stderr,"CreateFontIndirect(NULL) => NULL\n");
+
+    return hFont;
+}
 
 /***********************************************************************
  *           CreateFontIndirect32A   (GDI32.44)
@@ -312,12 +210,10 @@
 {
     LOGFONT16 font16;
 
-    FONT_LOGFONT32AToLOGFONT16(font,&font16);
-
+    FONT_LogFont32ATo16( font, &font16 );
     return CreateFontIndirect16( &font16 );
 }
 
-
 /***********************************************************************
  *           CreateFontIndirect32W   (GDI32.45)
  */
@@ -325,11 +221,10 @@
 {
     LOGFONT16 font16;
 
-    FONT_LOGFONT32WToLOGFONT16(font,&font16);
+    FONT_LogFont32WTo16( font, &font16 );
     return CreateFontIndirect16( &font16 );
 }
 
-
 /***********************************************************************
  *           CreateFont16    (GDI.56)
  */
@@ -338,16 +233,17 @@
                       BYTE strikeout, BYTE charset, BYTE outpres,
                       BYTE clippres, BYTE quality, BYTE pitch, LPCSTR name )
 {
-    LOGFONT16 logfont = {height, width, esc, orient, weight, italic, underline,
-                      strikeout, charset, outpres, clippres, quality, pitch, };
-    dprintf_font(stddeb,"CreateFont16(%d,%d)\n", height, width);
-    if (name) lstrcpyn32A(logfont.lfFaceName,name,sizeof(logfont.lfFaceName));
-    else logfont.lfFaceName[0] = '\0';
+    LOGFONT16 logfont = { height, width, esc, orient, weight, italic, underline,
+                          strikeout, charset, outpres, clippres, quality, pitch, };
+
+    dprintf_font(stddeb,"CreateFont16('%s',%d,%d)\n", name, height, width);
+    if (name) 
+	lstrcpyn32A(logfont.lfFaceName,name,sizeof(logfont.lfFaceName));
+    else 
+	logfont.lfFaceName[0] = '\0';
     return CreateFontIndirect16( &logfont );
 }
 
-
-
 /*************************************************************************
  *           CreateFont32A    (GDI32.43)
  */
@@ -361,7 +257,6 @@
                                   clippres, quality, pitch, name );
 }
 
-
 /*************************************************************************
  *           CreateFont32W    (GDI32.46)
  */
@@ -391,7 +286,6 @@
     return count;
 }
 
-
 /***********************************************************************
  *           FONT_GetObject32A
  */
@@ -399,22 +293,7 @@
 {
     LOGFONT32A fnt32;
 
-    memset(&fnt32, 0, sizeof(fnt32));
-    fnt32.lfHeight         = font->logfont.lfHeight;
-    fnt32.lfWidth          = font->logfont.lfWidth;
-    fnt32.lfEscapement     = font->logfont.lfEscapement;
-    fnt32.lfOrientation    = font->logfont.lfOrientation;
-    fnt32.lfWeight         = font->logfont.lfWeight;
-    fnt32.lfItalic         = font->logfont.lfItalic;
-    fnt32.lfUnderline      = font->logfont.lfUnderline;
-    fnt32.lfStrikeOut      = font->logfont.lfStrikeOut;
-    fnt32.lfCharSet        = font->logfont.lfCharSet;
-    fnt32.lfOutPrecision   = font->logfont.lfOutPrecision;
-    fnt32.lfClipPrecision  = font->logfont.lfClipPrecision;
-    fnt32.lfQuality        = font->logfont.lfQuality;
-    fnt32.lfPitchAndFamily = font->logfont.lfPitchAndFamily;
-    strncpy( fnt32.lfFaceName, font->logfont.lfFaceName,
-             sizeof(fnt32.lfFaceName) );
+    FONT_LogFont16To32A( &font->logfont, &fnt32 );
 
     if (count > sizeof(fnt32)) count = sizeof(fnt32);
     memcpy( buffer, &fnt32, count );
@@ -422,6 +301,207 @@
 }
 
 
+/***********************************************************************
+ *              FONT_EnumInstance16
+ *
+ * Called by the device driver layer to pass font info
+ * down to the application.
+ */
+static INT32 FONT_EnumInstance16( LPENUMLOGFONT16 plf, 
+				  LPNEWTEXTMETRIC16 ptm, UINT16 fType, LPARAM lp )
+{
+#define pfe ((fontEnum16*)lp)
+    if( pfe->lpLogFontParam->lfCharSet == DEFAULT_CHARSET || 
+	pfe->lpLogFontParam->lfCharSet == plf->elfLogFont.lfCharSet )
+    {
+	memcpy( pfe->lpLogFont, plf, sizeof(ENUMLOGFONT16) );
+	memcpy( pfe->lpTextMetric, ptm, sizeof(NEWTEXTMETRIC16) );
+
+        return pfe->lpEnumFunc( pfe->segLogFont, pfe->segTextMetric, fType, (LPARAM)(pfe->lpData) );
+    }
+#undef pfe
+    return 1;
+}
+
+/***********************************************************************
+ *              FONT_EnumInstance32
+ */
+static INT32 FONT_EnumInstance32( LPENUMLOGFONT16 plf,
+				  LPNEWTEXTMETRIC16 ptm, UINT16 fType, LPARAM lp )
+{
+    /* lfCharSet is at the same offset in both LOGFONT32A and LOGFONT32W */
+
+#define pfe ((fontEnum32*)lp)
+    if( pfe->lpLogFontParam->lfCharSet == DEFAULT_CHARSET || 
+	pfe->lpLogFontParam->lfCharSet == plf->elfLogFont.lfCharSet )
+    {
+	/* convert font metrics */
+
+	if( pfe->dwFlags & ENUM_UNICODE )
+	{
+	    FONT_LogFont16To32W( &plf->elfLogFont, (LPLOGFONT32W)(pfe->lpLogFont) );
+	    FONT_TextMetric16to32W( (LPTEXTMETRIC16)ptm, (LPTEXTMETRIC32W)(pfe->lpTextMetric) );
+	}
+	else
+	{
+	    FONT_LogFont16To32A( &plf->elfLogFont, (LPLOGFONT32A)pfe->lpLogFont );
+	    FONT_TextMetric16to32A( (LPTEXTMETRIC16)ptm, (LPTEXTMETRIC32A)pfe->lpTextMetric );
+	}
+
+        return pfe->lpEnumFunc( (LPENUMLOGFONT32W)pfe->lpLogFont, 
+				(LPNEWTEXTMETRIC32W)pfe->lpTextMetric, fType, pfe->lpData );
+    }
+#undef pfe
+    return 1;
+}
+
+/***********************************************************************
+ *              EnumFontFamiliesEx16	(GDI.613)
+ */
+INT16 EnumFontFamiliesEx16( HDC16 hDC, LPLOGFONT16 plf, FONTENUMPROCEX16 efproc, LPARAM lParam, DWORD dwFlags)
+{
+    INT16	retVal = 0;
+    DC* 	dc = (DC*) GDI_GetObjPtr( hDC, DC_MAGIC );
+
+    if( dc && dc->funcs->pEnumDeviceFonts )
+    {
+	LPNEWTEXTMETRICEX16	lptm16 = SEGPTR_ALLOC( sizeof(NEWTEXTMETRICEX16) );
+	if( lptm16 )
+	{
+	    LPENUMLOGFONTEX16	lplf16 = SEGPTR_ALLOC( sizeof(ENUMLOGFONTEX16) );
+	    if( lplf16 )
+	    {
+		fontEnum16	fe16 = { plf, efproc, lParam, lptm16, lplf16, 
+					 SEGPTR_GET(lptm16), SEGPTR_GET(lplf16) };
+
+		retVal = dc->funcs->pEnumDeviceFonts( dc, plf, FONT_EnumInstance16, (LPARAM)&fe16 );
+
+		SEGPTR_FREE(lplf16);
+	    }
+	    SEGPTR_FREE(lptm16);
+	}
+    }
+    return retVal;
+}
+
+/***********************************************************************
+ *		FONT_EnumFontFamiliesEx32
+ */
+static INT32 FONT_EnumFontFamiliesEx32( HDC32 hDC, LPLOGFONT32W plf, FONTENUMPROC32W efproc, 
+					           LPARAM lParam, DWORD dwUnicode)
+{
+    DC*		dc = (DC*) GDI_GetObjPtr( hDC, DC_MAGIC );
+
+    if( dc && dc->funcs->pEnumDeviceFonts )
+    {
+	LOGFONT16		lf16;
+	NEWTEXTMETRICEX32W 	tm32w;
+	ENUMLOGFONTEX32W	lf32w;
+	fontEnum32		fe32 = { plf, efproc, lParam, &tm32w, &lf32w, dwUnicode }; 
+
+	/* the only difference between LOGFONT32A and LOGFONT32W is in the lfFaceName */
+
+	if( plf->lfFaceName[0] )
+	{
+	    if( dwUnicode )
+		lstrcpynWtoA( lf16.lfFaceName, plf->lfFaceName, LF_FACESIZE );
+	    else
+		lstrcpyn32A( lf16.lfFaceName, (LPCSTR)plf->lfFaceName, LF_FACESIZE );
+	}
+	else lf16.lfFaceName[0] = '\0';
+	lf16.lfCharSet = plf->lfCharSet;
+
+	return dc->funcs->pEnumDeviceFonts( dc, &lf16, FONT_EnumInstance32, (LPARAM)&fe32 );
+    }
+    return 0;
+}
+
+/***********************************************************************
+ *              EnumFontFamiliesEx32W	(GDI32.82)
+ */
+INT32 EnumFontFamiliesEx32W( HDC32 hDC, LPLOGFONT32W plf, FONTENUMPROCEX32W efproc, 
+					LPARAM lParam, DWORD dwFlags )
+{
+    return  FONT_EnumFontFamiliesEx32( hDC, plf, (FONTENUMPROC32W)efproc, 
+						  lParam, ENUM_UNICODE );
+}
+
+/***********************************************************************
+ *              EnumFontFamiliesEx32A	(GDI32.81)
+ */
+INT32 EnumFontFamiliesEx32A( HDC32 hDC, LPLOGFONT32A plf, FONTENUMPROCEX32A efproc, 
+					LPARAM lParam, DWORD dwFlags)
+{
+    return  FONT_EnumFontFamiliesEx32( hDC, (LPLOGFONT32W)plf, 
+				      (FONTENUMPROC32W)efproc, lParam, 0);
+}
+
+/***********************************************************************
+ *              EnumFontFamilies16	(GDI.330)
+ */
+INT16 EnumFontFamilies16( HDC16 hDC, LPCSTR lpFamily, FONTENUMPROC16 efproc, LPARAM lpData )
+{
+    LOGFONT16	lf;
+
+    lf.lfCharSet = DEFAULT_CHARSET;
+    if( lpFamily ) lstrcpyn32A( lf.lfFaceName, lpFamily, LF_FACESIZE );
+    else lf.lfFaceName[0] = '\0';
+
+    return EnumFontFamiliesEx16( hDC, &lf, (FONTENUMPROCEX16)efproc, lpData, 0 );
+}
+
+/***********************************************************************
+ *              EnumFontFamilies32A	(GDI32.80)
+ */
+INT32 EnumFontFamilies32A( HDC32 hDC, LPCSTR lpFamily, FONTENUMPROC32A efproc, LPARAM lpData )
+{
+    LOGFONT32A	lf;
+
+    lf.lfCharSet = DEFAULT_CHARSET;
+    if( lpFamily ) lstrcpyn32A( lf.lfFaceName, lpFamily, LF_FACESIZE );
+    else lf.lfFaceName[0] = lf.lfFaceName[1] = '\0';
+
+    return FONT_EnumFontFamiliesEx32( hDC, (LPLOGFONT32W)&lf, 
+					   (FONTENUMPROC32W)efproc, lpData, 0 );
+}
+
+/***********************************************************************
+ *              EnumFontFamilies32W	(GDI32.83)
+ */
+INT32 EnumFontFamilies32W( HDC32 hDC, LPCWSTR lpFamily, FONTENUMPROC32W efproc, LPARAM lpData )
+{
+    LOGFONT32W  lf;
+
+    lf.lfCharSet = DEFAULT_CHARSET;
+    if( lpFamily ) lstrcpyn32W( lf.lfFaceName, lpFamily, LF_FACESIZE );
+    else lf.lfFaceName[0] = 0;
+
+    return FONT_EnumFontFamiliesEx32( hDC, &lf, efproc, lpData, ENUM_UNICODE );
+}
+
+/***********************************************************************
+ *              EnumFonts16		(GDI.70)
+ */
+INT16 EnumFonts16( HDC16 hDC, LPCSTR lpName, FONTENUMPROC16 efproc, LPARAM lpData )
+{
+    return EnumFontFamilies16( hDC, lpName, (FONTENUMPROCEX16)efproc, lpData );
+}
+
+/***********************************************************************
+ *              EnumFonts32A		(GDI32.84)
+ */
+INT32 EnumFonts32A( HDC32 hDC, LPCSTR lpName, FONTENUMPROC32A efproc, LPARAM lpData )
+{
+    return EnumFontFamilies32A( hDC, lpName, efproc, lpData );
+}
+
+/***********************************************************************
+ *              EnumFonts32W		(GDI32.85)
+ */
+INT32 EnumFonts32W( HDC32 hDC, LPCWSTR lpName, FONTENUMPROC32W efproc, LPARAM lpData )
+{
+    return EnumFontFamilies32W( hDC, lpName, efproc, lpData );
+}
 
 
 /***********************************************************************
@@ -432,7 +512,7 @@
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) return 0;
     return abs( (dc->w.charExtra * dc->wndExtX + dc->vportExtX / 2)
-	         / dc->vportExtX );
+                 / dc->vportExtX );
 }
 
 
@@ -444,7 +524,7 @@
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) return 0;
     return abs( (dc->w.charExtra * dc->wndExtX + dc->vportExtX / 2)
-	         / dc->vportExtX );
+                 / dc->vportExtX );
 }
 
 
@@ -465,7 +545,7 @@
     INT32 prev;
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) return 0;
-    extra = (extra * dc->vportExtX + dc->wndExtX / 2) / dc->wndExtX;    
+    extra = (extra * dc->vportExtX + dc->wndExtX / 2) / dc->wndExtX;
     prev = dc->w.charExtra;
     dc->w.charExtra = abs(extra);
     return (prev * dc->wndExtX + dc->vportExtX / 2) / dc->vportExtX;
@@ -494,14 +574,14 @@
     dc->w.breakTotalExtra = extra;
     dc->w.breakCount = breaks;
     if (breaks)
-    {	
-	dc->w.breakExtra = extra / breaks;
-	dc->w.breakRem   = extra - (dc->w.breakCount * dc->w.breakExtra);
+    {
+        dc->w.breakExtra = extra / breaks;
+        dc->w.breakRem   = extra - (dc->w.breakCount * dc->w.breakExtra);
     }
     else
     {
-	dc->w.breakExtra = 0;
-	dc->w.breakRem   = 0;
+        dc->w.breakExtra = 0;
+        dc->w.breakRem   = 0;
     }
     return 1;
 }
@@ -512,7 +592,7 @@
  */
 INT16 GetTextFace16( HDC16 hdc, INT16 count, LPSTR name )
 {
-	return GetTextFace32A(hdc,count,name);
+        return GetTextFace32A(hdc,count,name);
 }
 
 /***********************************************************************
@@ -579,7 +659,7 @@
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc)
     {
-	if (!(dc = (DC *)GDI_GetObjPtr( hdc, METAFILE_DC_MAGIC )))
+        if (!(dc = (DC *)GDI_GetObjPtr( hdc, METAFILE_DC_MAGIC )))
             return FALSE;
     }
 
@@ -588,7 +668,7 @@
         return FALSE;
 
     dprintf_font(stddeb,"GetTextExtentPoint(%08x '%.*s' %d %p): returning %d,%d\n",
-		 hdc, count, str, count, size, size->cx, size->cy );
+                 hdc, count, str, count, size, size->cx, size->cy );
     return TRUE;
 }
 
@@ -605,11 +685,12 @@
     return ret;
 }
 
+
 /***********************************************************************
  *           GetTextExtentPoint32ABuggy    (GDI32.232)
  */
 BOOL32 GetTextExtentPoint32ABuggy( HDC32 hdc, LPCSTR str, INT32 count,
-				   LPSIZE32 size )
+                                   LPSIZE32 size )
 {
     dprintf_font( stddeb, "GetTextExtentPoint32ABuggy: not bug compatible.\n");
     return GetTextExtentPoint32A( hdc, str, count, size );
@@ -619,7 +700,7 @@
  *           GetTextExtentPoint32WBuggy    (GDI32.233)
  */
 BOOL32 GetTextExtentPoint32WBuggy( HDC32 hdc, LPCWSTR str, INT32 count,
-				   LPSIZE32 size )
+                                   LPSIZE32 size )
 {
     dprintf_font( stddeb, "GetTextExtentPoint32WBuggy: not bug compatible.\n");
     return GetTextExtentPoint32W( hdc, str, count, size );
@@ -633,39 +714,40 @@
                                 INT32 maxExt,LPINT32 lpnFit, LPINT32 alpDx,
                                 LPSIZE32 size )
 {
-  int index;
-  SIZE32 tSize;
-  int nFit=0;
-  int extent=0;
-  DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
-  if (!dc)
-    {
-      if (!(dc = (DC *)GDI_GetObjPtr( hdc, METAFILE_DC_MAGIC )))
-	return FALSE;
-    }
-  if (!dc->funcs->pGetTextExtentPoint) return FALSE;
+    int index, nFit, extent;
+    SIZE32 tSize;
+    DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
 
-  size->cx=0; size->cy=0;
-  for(index=0;index<count;index++)
+    if (!dc)
     {
-      if(!dc->funcs->pGetTextExtentPoint( dc, str, 1, &tSize )) return FALSE;
-      if(extent+tSize.cx<maxExt)
-	{
-	  extent+=tSize.cx;
-	  nFit++;
-	  str++;
-	  if(alpDx) alpDx[index]=extent;
-	  if(tSize.cy > size->cy) size->cy=tSize.cy;
-	}
-      else break;
+	if (!(dc = (DC *)GDI_GetObjPtr( hdc, METAFILE_DC_MAGIC )))
+	    return FALSE;
     }
-  size->cx=extent;
-  *lpnFit=nFit;
-  dprintf_font(stddeb,"GetTextExtentExPoint32A(%08x '%.*s' %d) returning %d %d %d\n",
+    if (!dc->funcs->pGetTextExtentPoint) return FALSE;
+
+    size->cx = size->cy = nFit = extent = 0;
+    for(index = 0; index < count; index++)
+    {
+ 	if(!dc->funcs->pGetTextExtentPoint( dc, str, 1, &tSize )) return FALSE;
+	if( extent+tSize.cx < maxExt )
+        {
+	    extent+=tSize.cx;
+	    nFit++;
+	    str++;
+	    if( alpDx ) alpDx[index] = extent;
+	    if( tSize.cy > size->cy ) size->cy = tSize.cy;
+        }
+        else break;
+    }
+    size->cx = extent;
+   *lpnFit = nFit;
+
+    dprintf_font(stddeb,"GetTextExtentExPoint32A(%08x '%.*s' %d) returning %d %d %d\n",
                hdc,count,str,maxExt,nFit, size->cx,size->cy);
-  return TRUE;
+    return TRUE;
 }
 
+
 /***********************************************************************
  *           GetTextExtentExPoint32W    (GDI32.229)
  */
@@ -676,7 +758,7 @@
 {
     LPSTR p = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
     BOOL32 ret = GetTextExtentExPoint32A( hdc, p, count, maxExt,
-					lpnFit, alpDx, size);
+                                        lpnFit, alpDx, size);
     HeapFree( GetProcessHeap(), 0, p );
     return ret;
 }
@@ -686,29 +768,10 @@
  */
 BOOL16 GetTextMetrics16( HDC16 hdc, TEXTMETRIC16 *metrics )
 {
-    TEXTMETRIC32A tm;
-    
-    if (!GetTextMetrics32A( (HDC32)hdc, &tm )) return FALSE;
-    metrics->tmHeight           = tm.tmHeight;
-    metrics->tmAscent           = tm.tmAscent;
-    metrics->tmDescent          = tm.tmDescent;
-    metrics->tmInternalLeading  = tm.tmInternalLeading;
-    metrics->tmExternalLeading  = tm.tmExternalLeading;
-    metrics->tmAveCharWidth     = tm.tmAveCharWidth;
-    metrics->tmMaxCharWidth     = tm.tmMaxCharWidth;
-    metrics->tmWeight           = tm.tmWeight;
-    metrics->tmOverhang         = tm.tmOverhang;
-    metrics->tmDigitizedAspectX = tm.tmDigitizedAspectX;
-    metrics->tmDigitizedAspectY = tm.tmDigitizedAspectY;
-    metrics->tmFirstChar        = tm.tmFirstChar;
-    metrics->tmLastChar         = tm.tmLastChar;
-    metrics->tmDefaultChar      = tm.tmDefaultChar;
-    metrics->tmBreakChar        = tm.tmBreakChar;
-    metrics->tmItalic           = tm.tmItalic;
-    metrics->tmUnderlined       = tm.tmUnderlined;
-    metrics->tmStruckOut        = tm.tmStruckOut;
-    metrics->tmPitchAndFamily   = tm.tmPitchAndFamily;
-    metrics->tmCharSet          = tm.tmCharSet;
+    TEXTMETRIC32A tm32;
+
+    if (!GetTextMetrics32A( (HDC32)hdc, &tm32 )) return FALSE;
+    FONT_TextMetric32Ato16( &tm32, metrics );
     return TRUE;
 }
 
@@ -718,57 +781,35 @@
  */
 BOOL32 GetTextMetrics32A( HDC32 hdc, TEXTMETRIC32A *metrics )
 {
-DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
+    DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc)
     {
-	if (!(dc = (DC *)GDI_GetObjPtr( hdc, METAFILE_DC_MAGIC )))
+        if (!(dc = (DC *)GDI_GetObjPtr( hdc, METAFILE_DC_MAGIC )))
             return FALSE;
     }
 
     if (!dc->funcs->pGetTextMetrics ||
         !dc->funcs->pGetTextMetrics( dc,metrics ))
         return FALSE;
-    dprintf_font(stdnimp,"text metrics:\n
-	InternalLeading = %i
-	ExternalLeading = %i
-	MaxCharWidth = %i
-	Weight = %i
-	Italic = %i
-	Underlined = %i
-	StruckOut = %i
-	FirstChar = %i
-	LastChar = %i
-	DefaultChar = %i
-	BreakChar = %i
-	CharSet = %i
-	Overhang = %i
-	DigitizedAspectX = %i
-	DigitizedAspectY = %i
-	AveCharWidth = %i
-	MaxCharWidth = %i
-	Ascent = %i
-	Descent = %i
-	Height = %i\n",
-                 metrics->tmInternalLeading,
-                 metrics->tmExternalLeading,
-                 metrics->tmMaxCharWidth,
-                 metrics->tmWeight,
-                 metrics->tmItalic,
-                 metrics->tmUnderlined,
-                 metrics->tmStruckOut,
-                 metrics->tmFirstChar,
-                 metrics->tmLastChar,
-                 metrics->tmDefaultChar,
-                 metrics->tmBreakChar,
-                 metrics->tmCharSet,
-                 metrics->tmOverhang,
-                 metrics->tmDigitizedAspectX,
-                 metrics->tmDigitizedAspectY,
-                 metrics->tmAveCharWidth,
-                 metrics->tmMaxCharWidth,
-                 metrics->tmAscent,
-                 metrics->tmDescent,
-                 metrics->tmHeight);
+
+    dprintf_font(stdnimp,"text metrics:
+    Weight = %03i\t FirstChar = %03i\t AveCharWidth = %i
+    Italic = % 3i\t LastChar = %03i\t\t MaxCharWidth = %i
+    UnderLined = %01i\t DefaultChar = %03i\t Overhang = %i
+    StruckOut = %01i\t BreakChar = %03i\t CharSet = %i
+    --------------------
+    InternalLeading = %i
+    Ascent = %i
+    Descent = %i
+    Height = %i\n",
+    metrics->tmWeight, metrics->tmFirstChar, metrics->tmAveCharWidth,
+    metrics->tmItalic, metrics->tmLastChar, metrics->tmMaxCharWidth,
+    metrics->tmUnderlined, metrics->tmDefaultChar, metrics->tmOverhang,
+    metrics->tmStruckOut, metrics->tmBreakChar, metrics->tmCharSet,
+    metrics->tmInternalLeading,
+    metrics->tmAscent,
+    metrics->tmDescent,
+    metrics->tmHeight );
     return TRUE;
 }
 
@@ -780,31 +821,82 @@
 {
     TEXTMETRIC32A tm;
     if (!GetTextMetrics32A( (HDC16)hdc, &tm )) return FALSE;
-    metrics->tmHeight           = tm.tmHeight;
-    metrics->tmAscent           = tm.tmAscent;
-    metrics->tmDescent          = tm.tmDescent;
-    metrics->tmInternalLeading  = tm.tmInternalLeading;
-    metrics->tmExternalLeading  = tm.tmExternalLeading;
-    metrics->tmAveCharWidth     = tm.tmAveCharWidth;
-    metrics->tmMaxCharWidth     = tm.tmMaxCharWidth;
-    metrics->tmWeight           = tm.tmWeight;
-    metrics->tmOverhang         = tm.tmOverhang;
-    metrics->tmDigitizedAspectX = tm.tmDigitizedAspectX;
-    metrics->tmDigitizedAspectY = tm.tmDigitizedAspectY;
-    metrics->tmFirstChar        = tm.tmFirstChar;
-    metrics->tmLastChar         = tm.tmLastChar;
-    metrics->tmDefaultChar      = tm.tmDefaultChar;
-    metrics->tmBreakChar        = tm.tmBreakChar;
-    metrics->tmItalic           = tm.tmItalic;
-    metrics->tmUnderlined       = tm.tmUnderlined;
-    metrics->tmStruckOut        = tm.tmStruckOut;
-    metrics->tmPitchAndFamily   = tm.tmPitchAndFamily;
-    metrics->tmCharSet          = tm.tmCharSet;
+    FONT_TextMetric32Ato32W( &tm, metrics );
     return TRUE;
 }
 
 
 /***********************************************************************
+ *           GetCharWidth16    (GDI.350)
+ */
+BOOL16 GetCharWidth16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar,
+                       LPINT16 buffer )
+{
+    BOOL32	retVal = FALSE;
+
+    if( firstChar != lastChar )
+    {
+	LPINT32	buf32 = (LPINT32)HeapAlloc(SystemHeap, 0,
+				 sizeof(INT32)*(1 + (lastChar - firstChar)));
+	if( buf32 )
+	{
+	    LPINT32	obuf32 = buf32;
+	    int		i;
+
+            retVal = GetCharWidth32A(hdc, firstChar, lastChar, buf32);
+	    if (retVal)
+	    {
+		for (i = firstChar; i <= lastChar; i++)
+		    *buffer++ = *buf32++;
+	    }
+	    HeapFree(SystemHeap, 0, obuf32);
+	}
+    }
+    else
+    {
+	INT32 chWidth;
+	retVal = GetCharWidth32A(hdc, firstChar, lastChar, &chWidth );
+	*buffer = chWidth;
+    }
+    return retVal;
+}
+
+
+/***********************************************************************
+ *           GetCharWidth32A    (GDI32.155)
+ */
+BOOL32 GetCharWidth32A( HDC32 hdc, UINT32 firstChar, UINT32 lastChar,
+                        LPINT32 buffer )
+{
+    DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
+    if (!dc)
+    {
+        if (!(dc = (DC *)GDI_GetObjPtr( hdc, METAFILE_DC_MAGIC )))
+            return FALSE;
+    }
+
+    if (!dc->funcs->pGetCharWidth ||
+        !dc->funcs->pGetCharWidth( dc, firstChar, lastChar, buffer))
+        return FALSE;
+
+    return TRUE;
+}
+
+
+/***********************************************************************
+ *           GetCharWidth32W    (GDI32.158)
+ */
+BOOL32 GetCharWidth32W( HDC32 hdc, UINT32 firstChar, UINT32 lastChar,
+                        LPINT32 buffer )
+{
+    return GetCharWidth32A( hdc, firstChar, lastChar, buffer );
+}
+
+
+
+/* FIXME: all following APIs *******************************************
+ *
+ *
  *           SetMapperFlags16    (GDI.349)
  */
 DWORD SetMapperFlags16( HDC16 hDC, DWORD dwFlag )
@@ -818,12 +910,12 @@
  */
 DWORD SetMapperFlags32( HDC32 hDC, DWORD dwFlag )
 {
-    dprintf_font(stdnimp,"SetmapperFlags(%04x, %08lX) // Empty Stub !\n", 
-		 hDC, dwFlag); 
+    dprintf_font(stdnimp,"SetmapperFlags(%04x, %08lX) // Empty Stub !\n",
+                 hDC, dwFlag);
     return 0L;
 }
 
- 
+
 /***********************************************************************
  *           GetCharABCWidths16   (GDI.307)
  */
@@ -863,558 +955,78 @@
 
 
 /***********************************************************************
- *           GetCharWidth16    (GDI.350)
+ *           GetGlyphOutline16    (GDI.309)
  */
-BOOL16 GetCharWidth16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar,
-                       LPINT16 buffer )
+DWORD GetGlyphOutline16( HDC16 hdc, UINT16 uChar, UINT16 fuFormat,
+                         LPGLYPHMETRICS16 lpgm, DWORD cbBuffer,
+                         LPVOID lpBuffer, const MAT2 *lpmat2 )
 {
-    LPINT32	 buf32 = (LPINT32)xmalloc(sizeof(INT32)*(1 + (lastChar-firstChar)));
-    LPINT32	 obuf32;
-    BOOL32	 retVal;
-    int		 i;
-    if (!buf32)
-      return FALSE;
-    obuf32 = buf32;
-    retVal = GetCharWidth32A(hdc, firstChar, lastChar, buf32);
-    if (retVal)
-    {
-	for (i = firstChar; i <= lastChar; i++)
-	{
-	    *buffer++ = *buf32++;
-	}
-    }
-    free (obuf32);
-    return retVal;
+    fprintf( stdnimp,"GetGlyphOutLine16(%04x, '%c', %04x, %p, %ld, %p, %p) // - empty stub!\n",
+             hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
+    return (DWORD)-1; /* failure */
 }
 
 
 /***********************************************************************
- *           GetCharWidth32A    (GDI32.155)
+ *           GetGlyphOutline32A    (GDI32.186)
  */
-BOOL32 GetCharWidth32A( HDC32 hdc, UINT32 firstChar, UINT32 lastChar,
-                        LPINT32 buffer )
+DWORD GetGlyphOutline32A( HDC32 hdc, UINT32 uChar, UINT32 fuFormat,
+                         LPGLYPHMETRICS32 lpgm, DWORD cbBuffer,
+                         LPVOID lpBuffer, const MAT2 *lpmat2 )
 {
-    DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
-    if (!dc)
-    {
-	if (!(dc = (DC *)GDI_GetObjPtr( hdc, METAFILE_DC_MAGIC )))
-            return FALSE;
-    }
-
-    if (!dc->funcs->pGetCharWidth ||
-        !dc->funcs->pGetCharWidth( dc, firstChar, lastChar, buffer))
-        return FALSE;
-
-    return TRUE;
+    fprintf( stdnimp,"GetGlyphOutLine32A(%04x, '%c', %04x, %p, %ld, %p, %p) // - empty stub!\n",
+             hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
+    return (DWORD)-1; /* failure */
 }
 
-
 /***********************************************************************
- *           GetCharWidth32W    (GDI32.158)
+ *           GetGlyphOutline32W    (GDI32.187)
  */
-BOOL32 GetCharWidth32W( HDC32 hdc, UINT32 firstChar, UINT32 lastChar,
-                        LPINT32 buffer )
+DWORD GetGlyphOutline32W( HDC32 hdc, UINT32 uChar, UINT32 fuFormat,
+                         LPGLYPHMETRICS32 lpgm, DWORD cbBuffer,
+                         LPVOID lpBuffer, const MAT2 *lpmat2 )
 {
-    return GetCharWidth32A( hdc, firstChar, lastChar, buffer );
+    fprintf( stdnimp,"GetGlyphOutLine32W(%04x, '%c', %04x, %p, %ld, %p, %p) // - empty stub!\n",
+             hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
+    return (DWORD)-1; /* failure */
 }
 
-
 /***********************************************************************
- *           AddFontResource16    (GDI.119)
+ *           CreateScalableFontResource16   (GDI.310)
  */
-INT16 AddFontResource16( LPCSTR str )
+BOOL16 CreateScalableFontResource16( UINT16 fHidden, LPCSTR lpszResourceFile,
+                                     LPCSTR fontFile, LPCSTR path )
 {
-    return AddFontResource32A( str );
+    return CreateScalableFontResource32A( fHidden, lpszResourceFile,
+                                          fontFile, path );
 }
 
-
 /***********************************************************************
- *           AddFontResource32A    (GDI32.2)
+ *           CreateScalableFontResource32A   (GDI32.62)
  */
-INT32 AddFontResource32A( LPCSTR str )
+BOOL32 CreateScalableFontResource32A( DWORD fHidden, LPCSTR lpszResourceFile,
+                                      LPCSTR lpszFontFile,
+                                      LPCSTR lpszCurrentPath )
 {
-    if (HIWORD(str))
-        fprintf( stdnimp, "STUB: AddFontResource('%s')\n", str );
-    else
-        fprintf( stdnimp, "STUB: AddFontResource(%04x)\n", LOWORD(str) );
-    return 1;
+    /* fHidden=1 - only visible for the calling app, read-only, not
+     * enumbered with EnumFonts/EnumFontFamilies
+     * lpszCurrentPath can be NULL
+     */
+    fprintf(stdnimp,"CreateScalableFontResource(%ld,%s,%s,%s) // empty stub\n",
+            fHidden, lpszResourceFile, lpszFontFile, lpszCurrentPath );
+    return FALSE; /* create failed */
 }
 
-
 /***********************************************************************
- *           AddFontResource32W    (GDI32.4)
+ *           CreateScalableFontResource32W   (GDI32.63)
  */
-INT32 AddFontResource32W( LPCWSTR str )
+BOOL32 CreateScalableFontResource32W( DWORD fHidden, LPCWSTR lpszResourceFile,
+                                      LPCWSTR lpszFontFile,
+                                      LPCWSTR lpszCurrentPath )
 {
-    fprintf( stdnimp, "STUB: AddFontResource32W(%p)\n", str );
-    return 1;
-}
-
-
-/***********************************************************************
- *           RemoveFontResource16    (GDI.136)
- */
-BOOL16 RemoveFontResource16( LPCSTR str )
-{
-    return RemoveFontResource32A( str );
-}
-
-
-/***********************************************************************
- *           RemoveFontResource32A    (GDI32.284)
- */
-BOOL32 RemoveFontResource32A( LPCSTR str )
-{
-    if (HIWORD(str))
-        fprintf( stdnimp, "STUB: RemoveFontResource('%s')\n", str );
-    else
-        fprintf( stdnimp, "STUB: RemoveFontResource(%04x)\n", LOWORD(str) );
-    return TRUE;
-}
-
-
-/***********************************************************************
- *           RemoveFontResource32W    (GDI32.286)
- */
-BOOL32 RemoveFontResource32W( LPCWSTR str )
-{
-    fprintf( stdnimp, "STUB: RemoveFontResource32W(%p)\n", str );
-    return TRUE;
-}
-
-
-/*************************************************************************
- *				FONT_ParseFontParms		[internal]
- */
-int FONT_ParseFontParms(LPSTR lpFont, WORD wParmsNo, LPSTR lpRetStr, WORD wMaxSiz)
-{
-	int 	i;
-	if (lpFont == NULL) return 0;
-	if (lpRetStr == NULL) return 0;
-	for (i = 0; (*lpFont != '\0' && i != wParmsNo); ) {
-		if (*lpFont == '-') i++;
-		lpFont++;
-		}
-	if (i == wParmsNo) {
-		if (*lpFont == '-') lpFont++;
-		wMaxSiz--;
-		for (i = 0; (*lpFont != '\0' && *lpFont != '-' && i < wMaxSiz); i++)
-			*(lpRetStr + i) = *lpFont++;
-		*(lpRetStr + i) = '\0';
-		return i;
-		}
-	else
-		lpRetStr[0] = '\0';
-	return 0;
-}
-
-
-
-/*************************************************************************
- *				InitFontsList		[internal]
- */
-
-static int logfcmp(const void *a,const void *b) 
-{
-  return lstrcmpi32A( (*(LPLOGFONT16 *)a)->lfFaceName,
-                      (*(LPLOGFONT16 *)b)->lfFaceName );
-}
-
-void InitFontsList(void)
-{
-  char 	str[32];
-  char 	pattern[100];
-  char 	*family, *weight, *charset;
-  char 	**names;
-  char 	slant, spacing;
-  int 	i, count;
-  LPLOGFONT16 lpNewFont;
-
-  dprintf_font(stddeb,"InitFontsList !\n");
-
-  weight = "medium";
-  slant = 'r';
-  spacing = '*';
-  charset = "*";
-  family = "*-*";
-
-  sprintf( pattern, "-%s-%s-%c-normal-*-*-*-*-*-%c-*-%s",
-	  family, weight, slant, spacing, charset);
-  names = XListFonts( display, pattern, MAX_FONTS, &count );
-  dprintf_font(stddeb,"InitFontsList // count=%d \n", count);
-
-  lpNewFont = malloc((sizeof(LOGFONT16)+LF_FACESIZE)*count);
-  if (lpNewFont == NULL) {
-      dprintf_font(stddeb,
-		   "InitFontsList // Error alloc new font structure !\n");
-      XFreeFontNames(names);
-      return;
-  }
-
-  for (i = 0; i < count; i++) {
-    dprintf_font(stddeb,"InitFontsList // names[%d]='%s' \n", i, names[i]);
-
-    FONT_ParseFontParms(names[i], 2, str, sizeof(str));
-    strcpy(lpNewFont->lfFaceName, str);
-    FONT_ParseFontParms(names[i], 8, str, sizeof(str));
-    lpNewFont->lfHeight = atoi(str) / 10;
-    FONT_ParseFontParms(names[i], 12, str, sizeof(str));
-    lpNewFont->lfWidth = atoi(str) / 10;
-    lpNewFont->lfEscapement = 0;
-    lpNewFont->lfOrientation = 0;
-    lpNewFont->lfWeight = FW_REGULAR;
-    lpNewFont->lfItalic = 0;
-    lpNewFont->lfUnderline = 0;
-    lpNewFont->lfStrikeOut = 0;
-    FONT_ParseFontParms(names[i], 13, str, sizeof(str));
-    if (strcmp(str, "iso8859") == 0)  {
-      lpNewFont->lfCharSet = ANSI_CHARSET;
-    } else  {
-      lpNewFont->lfCharSet = OEM_CHARSET;
-    }
-    lpNewFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
-    lpNewFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
-    lpNewFont->lfQuality = DEFAULT_QUALITY;
-    FONT_ParseFontParms(names[i], 11, str, sizeof(str));
-    switch(str[0]) {
-     case 'p':
-      lpNewFont->lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS;
-      break;
-     case 'm':
-     case 'c':
-      lpNewFont->lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
-      break;
-     default:
-      lpNewFont->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
-      break;
-    }
-    dprintf_font( stddeb,
-		  "InitFontsList // lpNewFont->lfHeight=%d\n",
-		  lpNewFont->lfHeight );
-    dprintf_font( stddeb,
-		  "InitFontsList // lpNewFont->lfWidth=%d\n",
-		  lpNewFont->lfWidth );
-    dprintf_font( stddeb,
-		  "InitFontsList // lfFaceName='%s'\n",
-		  lpNewFont->lfFaceName );
-    lpLogFontList[i] = lpNewFont;
-    lpNewFont = (LPLOGFONT16)
-      ((char *)lpNewFont + sizeof(LOGFONT16)+LF_FACESIZE);
-  }
-  lpLogFontList[i] = NULL;
-
-  qsort(lpLogFontList,count,sizeof(*lpLogFontList),logfcmp);
-  XFreeFontNames(names);
-}
-
-/*************************************************************************
- *				EnumFonts			[GDI.70]
- * We reuse EnumFontFamilies* for the callback function get the same
- * structs (+ extra stuff at the end which will be ignored by the enum funcs)
- */
-INT16 EnumFonts16(HDC16 hDC, LPCSTR lpFaceName, FONTENUMPROC16 lpEnumFunc, LPARAM lpData)
-{
-  return EnumFontFamilies16(hDC,lpFaceName,lpEnumFunc,lpData);
-}
-
-/*************************************************************************
- *				EnumFontsA			[GDI32.84]
- */
-INT32 EnumFonts32A(HDC32 hDC, LPCSTR lpFaceName, FONTENUMPROC32A lpEnumFunc, LPARAM lpData)
-{
-  return EnumFontFamilies32A(hDC,lpFaceName,lpEnumFunc,lpData);
-}
-
-/*************************************************************************
- *				EnumFontsA			[GDI32.84]
- */
-INT32 EnumFonts32W(HDC32 hDC, LPCWSTR lpFaceName, FONTENUMPROC32W lpEnumFunc, LPARAM lpData)
-{
-  return EnumFontFamilies32W(hDC,lpFaceName,lpEnumFunc,lpData);
-}
-
-/*************************************************************************
- *				EnumFontFamilies	[GDI.330]
- */
-INT16 EnumFontFamilies16(HDC16 hDC, LPCSTR lpszFamily, FONTENUMPROC16 lpEnumFunc, LPARAM lpData)
-{
-  LOGFONT16	LF;
-
-  if (lpszFamily)
-     strcpy(LF.lfFaceName,lpszFamily);
-  else
-     LF.lfFaceName[0]='\0';
-  LF.lfCharSet = DEFAULT_CHARSET;
-
-  return EnumFontFamiliesEx16(hDC,&LF,(FONTENUMPROCEX16)lpEnumFunc,lpData,0);
-}
-
-/*************************************************************************
- *				EnumFontFamiliesA	[GDI32.80]
- */
-INT32 EnumFontFamilies32A(HDC32 hDC, LPCSTR lpszFamily, FONTENUMPROC32A lpEnumFunc, LPARAM lpData)
-{
-  LOGFONT32A	LF;
-
-  if (lpszFamily)
-     strcpy(LF.lfFaceName,lpszFamily);
-  else
-     LF.lfFaceName[0]='\0';
-  LF.lfCharSet = DEFAULT_CHARSET;
-
-  return EnumFontFamiliesEx32A(hDC,&LF,(FONTENUMPROCEX32A)lpEnumFunc,lpData,0);
-}
-
-/*************************************************************************
- *				EnumFontFamiliesW	[GDI32.83]
- */
-INT32 EnumFontFamilies32W(HDC32 hDC, LPCWSTR lpszFamilyW, FONTENUMPROC32W lpEnumFunc, LPARAM lpData)
-{
-  LOGFONT32W	LF;
-
-  if (lpszFamilyW)
-  	lstrcpy32W(LF.lfFaceName,lpszFamilyW);
-  else
-  	LF.lfFaceName[0]=0;
-  LF.lfCharSet = DEFAULT_CHARSET;
-  return EnumFontFamiliesEx32W(hDC,&LF,(FONTENUMPROCEX32W)lpEnumFunc,lpData,0);
-}
-
-/*************************************************************************
- *				EnumFontFamiliesEx	[GDI.618]
- * FIXME: fill the rest of the NEWTEXTMETRICEX and ENUMLOGFONTEX structures.
- *        (applies to all EnumFontFamiliesEx*)
- *        winelib/16 support.
- */
-INT16 EnumFontFamiliesEx16(HDC16 hDC, LPLOGFONT16 lpLF, FONTENUMPROCEX16 lpEnumFunc, LPARAM lpData,DWORD reserved)
-{
-  HLOCAL16     	hLog;
-  HLOCAL16     	hMet;
-  HFONT16 hFont;
-  HFONT16 hOldFont;
-  LPENUMLOGFONTEX16 lpEnumLogFont;
-  LPNEWTEXTMETRICEX16 lptm;
-  LPSTR	       	lpOldName;
-  char	       	FaceName[LF_FACESIZE];
-  int	       	nRet = 0;
-  int	       	i;
-  
-  dprintf_font(stddeb,"EnumFontFamiliesEx(%04x, '%s', %08lx, %08lx, %08lx)\n",
-	       hDC, lpLF->lfFaceName, (DWORD)lpEnumFunc, lpData, reserved);
-  if (lpEnumFunc == 0) return 0;
-  hLog = GDI_HEAP_ALLOC( sizeof(ENUMLOGFONTEX16) );
-  lpEnumLogFont = (LPENUMLOGFONTEX16) GDI_HEAP_LIN_ADDR(hLog);
-  if (lpEnumLogFont == NULL) {
-    fprintf(stderr,"EnumFontFamiliesEx // can't alloc LOGFONT struct !\n");
-    return 0;
-  }
-  hMet = GDI_HEAP_ALLOC( sizeof(NEWTEXTMETRICEX16) );
-  lptm = (LPNEWTEXTMETRICEX16) GDI_HEAP_LIN_ADDR(hMet);
-  if (lptm == NULL) {
-    GDI_HEAP_FREE(hLog);
-    fprintf(stderr,"EnumFontFamiliesEx // can't alloc TEXTMETRIC struct !\n");
-    return 0;
-  }
-  lpOldName = NULL;
-  strcpy(FaceName,lpLF->lfFaceName);
-
-  if (lpLogFontList[0] == NULL) InitFontsList();
-  for(i = 0; lpLogFontList[i] != NULL; i++) {
-    /* lfCharSet */
-    if (lpLF->lfCharSet!=DEFAULT_CHARSET)
-    	if (lpLogFontList[i]->lfCharSet != lpLF->lfCharSet)
-	   continue;
-
-    /* lfPitchAndFamily only of importance in Hebrew and Arabic versions. */
-    /* lfFaceName */
-    if (FaceName[0])
-    {
-    	if (lstrcmpi32A(FaceName,lpLogFontList[i]->lfFaceName))
-	   continue;
-    }
-    else
-    {
-    	if ((lpOldName!=NULL) &&
-            !lstrcmpi32A(lpOldName,lpLogFontList[i]->lfFaceName))
-	   continue;
-	lpOldName=lpLogFontList[i]->lfFaceName;
-    }
-
-    memcpy(lpEnumLogFont, lpLogFontList[i], sizeof(LOGFONT16));
-    strcpy(lpEnumLogFont->elfFullName,"");
-    strcpy(lpEnumLogFont->elfStyle,"");
-    hFont = CreateFontIndirect16((LPLOGFONT16)lpEnumLogFont);
-    hOldFont = SelectObject32(hDC, hFont);
-    GetTextMetrics16(hDC, (LPTEXTMETRIC16)lptm);
-    SelectObject32(hDC, hOldFont);
-    DeleteObject32(hFont);
-    dprintf_font(stddeb, "EnumFontFamiliesEx // i=%d lpLogFont=%p lptm=%p\n", i, lpEnumLogFont, lptm);
-    
-    nRet = lpEnumFunc( GDI_HEAP_SEG_ADDR(hLog), GDI_HEAP_SEG_ADDR(hMet),
-                       0, lpData );
-    if (nRet == 0) {
-      dprintf_font(stddeb,"EnumFontFamilies // EnumEnd requested by application !\n");
-      break;
-    }
-  }
-  GDI_HEAP_FREE(hMet);
-  GDI_HEAP_FREE(hLog);
-  return nRet;
-}
-
-
-/*************************************************************************
- *				EnumFontFamiliesExA	[GDI32.81]
- * FIXME: Don't use 16 bit GDI heap functions (applies to EnumFontFamiliesEx32*)
- */
-INT32 EnumFontFamiliesEx32A(HDC32 hDC, LPLOGFONT32A lpLF,FONTENUMPROCEX32A lpEnumFunc, LPARAM lpData,DWORD reserved)
-{
-  HLOCAL16     	hLog;
-  HLOCAL16     	hMet;
-  HFONT32	hFont;
-  HFONT32	hOldFont;
-  LPENUMLOGFONTEX32A	lpEnumLogFont;
-  LPNEWTEXTMETRICEX32A	lptm;
-  LPSTR	       	lpOldName;
-  char	       	FaceName[LF_FACESIZE];
-  int	       	nRet = 0;
-  int	       	i;
-  
-  dprintf_font(stddeb,"EnumFontFamilies32A(%04x, %p, %08lx, %08lx, %08lx)\n",
-	       hDC, lpLF->lfFaceName, (DWORD)lpEnumFunc, lpData,reserved);
-  if (lpEnumFunc == 0) return 0;
-  hLog = GDI_HEAP_ALLOC( sizeof(ENUMLOGFONTEX32A) );
-  lpEnumLogFont = (LPENUMLOGFONTEX32A) GDI_HEAP_LIN_ADDR(hLog);
-  if (lpEnumLogFont == NULL) {
-    fprintf(stderr,"EnumFontFamilies // can't alloc LOGFONT struct !\n");
-    return 0;
-  }
-  hMet = GDI_HEAP_ALLOC( sizeof(NEWTEXTMETRICEX32A) );
-  lptm = (LPNEWTEXTMETRICEX32A) GDI_HEAP_LIN_ADDR(hMet);
-  if (lptm == NULL) {
-    GDI_HEAP_FREE(hLog);
-    fprintf(stderr,"EnumFontFamilies32A // can't alloc TEXTMETRIC struct !\n");
-    return 0;
-  }
-  lpOldName = NULL;
-  strcpy(FaceName,lpLF->lfFaceName);
-
-  if (lpLogFontList[0] == NULL) InitFontsList();
-  for(i = 0; lpLogFontList[i] != NULL; i++) {
-    /* lfCharSet */
-    if (lpLF->lfCharSet!=DEFAULT_CHARSET)
-    	if (lpLogFontList[i]->lfCharSet != lpLF->lfCharSet)
-	   continue;
-
-    /* lfPitchAndFamily only of importance in Hebrew and Arabic versions. */
-    /* lfFaceName */
-    if (FaceName[0]) {
-    	if (lstrcmpi32A(FaceName,lpLogFontList[i]->lfFaceName))
-	   continue;
-    } else {
-    	if ((lpOldName!=NULL) &&
-            !lstrcmpi32A(lpOldName,lpLogFontList[i]->lfFaceName))
-	   continue;
-	lpOldName=lpLogFontList[i]->lfFaceName;
-    }
-
-    FONT_LOGFONT16ToLOGFONT32A(lpLogFontList[i],&(lpEnumLogFont->elfLogFont));
-    strcpy(lpEnumLogFont->elfFullName,"");
-    strcpy(lpEnumLogFont->elfStyle,"");
-    strcpy(lpEnumLogFont->elfScript,"");
-    hFont = CreateFontIndirect32A((LPLOGFONT32A)lpEnumLogFont);
-    hOldFont = SelectObject32(hDC, hFont);
-    GetTextMetrics32A(hDC, (LPTEXTMETRIC32A)lptm);
-    SelectObject32(hDC, hOldFont);
-    DeleteObject32(hFont);
-    dprintf_font(stddeb, "EnumFontFamiliesEx32A // i=%d lpLogFont=%p lptm=%p\n", i, lpEnumLogFont, lptm);
-    
-    nRet = lpEnumFunc(lpEnumLogFont,lptm,0,lpData);
-    if (nRet == 0) {
-      dprintf_font(stddeb,"EnumFontFamiliesEx32A // EnumEnd requested by application !\n");
-      break;
-    }
-  }
-  GDI_HEAP_FREE(hMet);
-  GDI_HEAP_FREE(hLog);
-  return nRet;
-}
-
-
-/*************************************************************************
- *				EnumFontFamiliesW	[GDI32.82]
- */
-INT32 EnumFontFamiliesEx32W(HDC32 hDC, LPLOGFONT32W lpLF, FONTENUMPROCEX32W lpEnumFunc, LPARAM lpData, DWORD reserved)
-{
-  HLOCAL16     	hLog;
-  HLOCAL16     	hMet;
-  HFONT32	hFont;
-  HFONT32	hOldFont;
-  LPENUMLOGFONTEX32W	lpEnumLogFont;
-  LPNEWTEXTMETRICEX32W	lptm;
-  LPSTR	       	lpOldName;
-  int	       	nRet = 0;
-  int	       	i;
-  LPSTR	lpszFamily;
-  
-  dprintf_font(stddeb,"EnumFontFamiliesEx32W(%04x, %p, %08lx, %08lx, %08lx)\n",
-	       hDC, lpLF, (DWORD)lpEnumFunc, lpData,reserved);
-  if (lpEnumFunc == 0) return 0;
-  hLog = GDI_HEAP_ALLOC( sizeof(ENUMLOGFONTEX32W) );
-  lpEnumLogFont = (LPENUMLOGFONTEX32W) GDI_HEAP_LIN_ADDR(hLog);
-  if (lpEnumLogFont == NULL) {
-    fprintf(stderr,"EnumFontFamilies32W // can't alloc LOGFONT struct !\n");
-    return 0;
-  }
-  hMet = GDI_HEAP_ALLOC( sizeof(NEWTEXTMETRICEX32W) );
-  lptm = (LPNEWTEXTMETRICEX32W) GDI_HEAP_LIN_ADDR(hMet);
-  if (lptm == NULL) {
-    GDI_HEAP_FREE(hLog);
-    fprintf(stderr,"EnumFontFamilies32W // can't alloc TEXTMETRIC struct !\n");
-    return 0;
-  }
-  lpOldName = NULL;
-  lpszFamily = HEAP_strdupWtoA( GetProcessHeap(), 0, lpLF->lfFaceName );
-  if (lpLogFontList[0] == NULL) InitFontsList();
-  for(i = 0; lpLogFontList[i] != NULL; i++) {
-    /* lfCharSet */
-    if (lpLF->lfCharSet!=DEFAULT_CHARSET)
-    	if (lpLogFontList[i]->lfCharSet != lpLF->lfCharSet)
-	   continue;
-
-    /* lfPitchAndFamily only of importance in Hebrew and Arabic versions. */
-    /* lfFaceName */
-    if (lpszFamily[0]) {
-    	if (lstrcmpi32A(lpszFamily,lpLogFontList[i]->lfFaceName))
-	   continue;
-    } else {
-    	if ((lpOldName!=NULL) &&
-            !lstrcmpi32A(lpOldName,lpLogFontList[i]->lfFaceName))
-	   continue;
-	lpOldName=lpLogFontList[i]->lfFaceName;
-    }
-
-    FONT_LOGFONT16ToLOGFONT32W(lpLogFontList[i],&(lpEnumLogFont->elfLogFont));
-    lpEnumLogFont->elfFullName[0] = 0;
-    lpEnumLogFont->elfStyle[0] = 0;
-    lpEnumLogFont->elfScript[0] = 0;
-    hFont = CreateFontIndirect32W((LPLOGFONT32W)lpEnumLogFont);
-    hOldFont = SelectObject32(hDC, hFont);
-    GetTextMetrics32W(hDC, (LPTEXTMETRIC32W)lptm);
-    SelectObject32(hDC, hOldFont);
-    DeleteObject32(hFont);
-    dprintf_font(stddeb, "EnumFontFamilies32W // i=%d lpLogFont=%p lptm=%p\n", i, lpEnumLogFont, lptm);
-    
-    nRet = lpEnumFunc(lpEnumLogFont,lptm,0,lpData);
-    if (nRet == 0) {
-      dprintf_font(stddeb,"EnumFontFamilies32W // EnumEnd requested by application !\n");
-      break;
-    }
-  }
-  GDI_HEAP_FREE(hMet);
-  GDI_HEAP_FREE(hLog);
-  HeapFree( GetProcessHeap(), 0, lpszFamily );
-  return nRet;
+    fprintf(stdnimp,"CreateScalableFontResource32W(%ld,%p,%p,%p) // empty stub\n",
+            fHidden, lpszResourceFile, lpszFontFile, lpszCurrentPath );
+    return FALSE; /* create failed */
 }
 
 
@@ -1432,9 +1044,8 @@
  */
 BOOL32 GetRasterizerCaps32( LPRASTERIZER_STATUS lprs, UINT32 cbNumBytes )
 {
-  /* This is not much more than a dummy */
   RASTERIZER_STATUS rs;
-  
+
   rs.nSize = sizeof(rs);
   rs.wFlags = 0;
   rs.nLanguageID = 0;
@@ -1448,10 +1059,7 @@
 INT16 GetKerningPairs16( HDC16 hDC, INT16 cPairs,
                          LPKERNINGPAIR16 lpKerningPairs )
 {
-    /* This has to be dealt with when proper font handling is in place 
-     *
-     * At this time kerning is ignored (set to 0)
-     */
+    /* At this time kerning is ignored (set to 0) */
     int i;
     fprintf(stdnimp,"GetKerningPairs16: almost empty stub!\n");
     for (i = 0; i < cPairs; i++) lpKerningPairs[i].iKernAmount = 0;
@@ -1459,16 +1067,13 @@
 }
 
 
+
 /*************************************************************************
  *             GetKerningPairs32A   (GDI32.192)
  */
 DWORD GetKerningPairs32A( HDC32 hDC, DWORD cPairs,
                           LPKERNINGPAIR32 lpKerningPairs )
 {
-    /* This has to be dealt with when proper font handling is in place 
-     *
-     * At this time kerning is ignored (set to 0)
-     */
     int i;
     fprintf(stdnimp,"GetKerningPairs32: almost empty stub!\n");
     for (i = 0; i < cPairs; i++) lpKerningPairs[i].iKernAmount = 0;
@@ -1484,3 +1089,4 @@
 {
     return GetKerningPairs32A( hDC, cPairs, lpKerningPairs );
 }
+
diff --git a/objects/gdiobj.c b/objects/gdiobj.c
index 89aad65..52c8bd5 100644
--- a/objects/gdiobj.c
+++ b/objects/gdiobj.c
@@ -100,14 +100,14 @@
 {
     { 0, FONT_MAGIC, 1 },   /* header */
     { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
-      0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, "" }
+      0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, "MS Sans Serif" }
 };
 
 static FONTOBJ SystemFont =
 {
-    { 0, FONT_MAGIC, 1 },   /* header */
+    { 0, FONT_MAGIC, 1 },
     { 12, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
-      0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, "" }
+      0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, "System" }
 };
 
 static FONTOBJ DeviceDefaultFont =
@@ -142,7 +142,7 @@
     (GDIOBJHDR *) &AnsiVarFont,
     (GDIOBJHDR *) &SystemFont,
     (GDIOBJHDR *) &DeviceDefaultFont,
-    NULL,            /* DEFAULT_PALETTE created by COLOR_Init */
+    NULL,            /* DEFAULT_PALETTE created by PALETTE_Init */
     (GDIOBJHDR *) &SystemFixedFont
 };
 
@@ -154,21 +154,26 @@
  */
 BOOL32 GDI_Init(void)
 {
-    HPALETTE16 hpalette;
     extern BOOL32 X11DRV_Init(void);
     extern BOOL32 DIB_Init(void);
 
     /* Initialize drivers */
 
-    if (!X11DRV_Init()) return FALSE;
-    if (!DIB_Init()) return FALSE;
+    DIB_Init();	/* always before X11DRV_Init() */
 
-      /* Create default palette */
+    if( X11DRV_Init() )
+    {
+	/* Create default palette */
 
-    if (!(hpalette = COLOR_Init())) return FALSE;
-    StockObjects[DEFAULT_PALETTE] = (GDIOBJHDR *)GDI_HEAP_LIN_ADDR( hpalette );
+	HPALETTE16 hpalette = PALETTE_Init();
 
-    return TRUE;
+	if( hpalette )
+	{
+	    StockObjects[DEFAULT_PALETTE] = (GDIOBJHDR *)GDI_HEAP_LIN_ADDR( hpalette );
+	    return TRUE;
+	}
+    }
+    return FALSE;
 }
 
 
diff --git a/objects/metafile.c b/objects/metafile.c
index 5c5da99..87e0b34 100644
--- a/objects/metafile.c
+++ b/objects/metafile.c
@@ -304,18 +304,29 @@
 {
     METAHEADER *mh = (METAHEADER *)GlobalLock16(hmf);
     METARECORD *mr;
+    HANDLETABLE16 *ht;
     HGLOBAL16 hHT;
-    SEGPTR ht, spRecord;
+    SEGPTR spht, spRecord;
     int offset = 0;
-  
+    WORD i;
+    HPEN32 hPen;
+    HBRUSH32 hBrush;
+    HFONT32 hFont;
+    DC *dc;
+    
     dprintf_metafile(stddeb,"EnumMetaFile(%04x, %04x, %08lx, %08lx)\n",
 		     hdc, hmf, (DWORD)lpEnumFunc, lpData);
+
+    if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
+    hPen = dc->w.hPen;
+    hBrush = dc->w.hBrush;
+    hFont = dc->w.hFont;
    
     /* create the handle table */
     
     hHT = GlobalAlloc16(GMEM_MOVEABLE | GMEM_ZEROINIT,
 		     sizeof(HANDLETABLE16) * mh->mtNoObjects);
-    ht = WIN16_GlobalLock16(hHT);
+    spht = WIN16_GlobalLock16(hHT);
    
     offset = mh->mtHeaderSize * 2;
     
@@ -325,7 +336,7 @@
     while (offset < (mh->mtSize * 2))
     {
 	mr = (METARECORD *)((char *)mh + offset);
-        if (!lpEnumFunc( hdc, (HANDLETABLE16 *)ht,
+        if (!lpEnumFunc( hdc, (HANDLETABLE16 *)spht,
                          (METARECORD *)((UINT32)spRecord + offset),
                          mh->mtNoObjects, (LONG)lpData))
 	    break;
@@ -333,6 +344,17 @@
 	offset += (mr->rdSize * 2);
     }
 
+    SelectObject32(hdc, hBrush);
+    SelectObject32(hdc, hPen);
+    SelectObject32(hdc, hFont);
+
+    ht = (HANDLETABLE16 *)GlobalLock16(hHT);
+
+    /* free objects in handle table */
+    for(i = 0; i < mh->mtNoObjects; i++)
+      if(*(ht->objectHandle + i) != 0)
+        DeleteObject32(*(ht->objectHandle + i));
+
     /* free handle table */
     GlobalFree16(hHT);
 
@@ -1165,9 +1187,13 @@
     DWORD len;
     HGLOBAL16 hmr;
     METARECORD *mr;
-
+    
+    if((!flags && rect) || (flags && !rect))
+	fprintf(stderr, "MF_ExtTextOut: Inconsistent flags and rect\n");
     len = sizeof(METARECORD) + (((count + 1) >> 1) * 2) + 2 * sizeof(short)
-	    + sizeof(UINT16) + sizeof(RECT16);
+	    + sizeof(UINT16);
+    if(rect)
+        len += sizeof(RECT16);
     if (lpDx)
      len+=count*sizeof(INT16);
     if (!(hmr = GlobalAlloc16(GMEM_MOVEABLE, len)))
@@ -1182,9 +1208,10 @@
     *(mr->rdParam + 2) = count;
     *(mr->rdParam + 3) = flags;
     if (rect) memcpy(mr->rdParam + 4, rect, sizeof(RECT16));
-    memcpy(mr->rdParam + 8, str, count);
+    memcpy(mr->rdParam + (rect ? 8 : 4), str, count);
     if (lpDx)
-     memcpy(mr->rdParam + 8+ ((count + 1) >> 1),lpDx,count*sizeof(INT16));
+     memcpy(mr->rdParam + (rect ? 8 : 4) + ((count + 1) >> 1),lpDx,
+      count*sizeof(INT16));
     ret = MF_WriteRecord( dc, mr, mr->rdSize * 2);
     GlobalFree16(hmr);
     return ret;
diff --git a/objects/palette.c b/objects/palette.c
index 75e11a6..74207b8 100644
--- a/objects/palette.c
+++ b/objects/palette.c
@@ -4,6 +4,8 @@
  * Copyright 1993,1994 Alexandre Julliard
  * Copyright 1996 Alex Korobka
  *
+ * PALETTEOBJ is documented in the Dr. Dobbs Journal May 1993.
+ * Information in the "Undocumented Windows" is incorrect.
  */
 
 #include <stdlib.h>
@@ -28,6 +30,45 @@
 
 
 /***********************************************************************
+ *           PALETTE_Init
+ *
+ * Create the system palette.
+ */
+HPALETTE16 PALETTE_Init(void)
+{
+    extern const PALETTEENTRY* COLOR_GetSystemPaletteTemplate(void);
+
+    int                 i;
+    HPALETTE16          hpalette;
+    LOGPALETTE *        palPtr;
+    PALETTEOBJ*         palObj;
+    const PALETTEENTRY* __sysPalTemplate = COLOR_GetSystemPaletteTemplate();
+
+    /* create default palette (20 system colors) */
+
+    palPtr = xmalloc( sizeof(LOGPALETTE) + (NB_RESERVED_COLORS-1)*sizeof(PALETTEENTRY) );
+    if (!palPtr) return FALSE;
+
+    palPtr->palVersion = 0x300;
+    palPtr->palNumEntries = NB_RESERVED_COLORS;
+    for( i = 0; i < NB_RESERVED_COLORS; i ++ )
+    {
+        palPtr->palPalEntry[i].peRed = __sysPalTemplate[i].peRed;
+        palPtr->palPalEntry[i].peGreen = __sysPalTemplate[i].peGreen;
+        palPtr->palPalEntry[i].peBlue = __sysPalTemplate[i].peBlue;
+        palPtr->palPalEntry[i].peFlags = 0;
+    }
+    hpalette = CreatePalette16( palPtr );
+
+    palObj = (PALETTEOBJ*) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
+
+    palObj->mapping = xmalloc( sizeof(int) * 20 );
+
+    free( palPtr );
+    return hpalette;
+}
+
+/***********************************************************************
  *           PALETTE_ValidateFlags
  */
 void PALETTE_ValidateFlags(PALETTEENTRY* lpPalE, int size)
diff --git a/objects/region.c b/objects/region.c
index 3575132..9148e6d 100644
--- a/objects/region.c
+++ b/objects/region.c
@@ -2,6 +2,8 @@
  * GDI region objects
  *
  * Copyright 1993, 1994, 1995 Alexandre Julliard
+ *
+ * RGNOBJ is documented in the Dr. Dobbs Journal March 1993.
  */
 
 #include <stdlib.h>