Release 970202

Sun Feb  2 12:31:03 1997  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [files/drive.c]
	Fixed SetCurrentDirectory() to also change the current drive.

	* [win32/except.c] [tools/build.c]
	Use Win32 register functions to implement exception handling.
	Fixed UnhandledExceptionFilter.

Fri Jan 31 15:42:41  1997  David Faure  <david.faure@ihamy.insa-lyon.fr>

	* [windows/keyboard.c]
	Added KEYBOARD_GenerateMsg to generate Caps Lock and NumLock events
	Added calls to KEYBOARD_GenerateMsg when the key is pressed/released
	or when the state has changed, out of wine.
	Changed type 3-state 'ToggleKeyState' to boolean. The On/Off is given
	by InputKeyStateTable.

Wed Jan 29 21:53:04 1997  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

	* [loader/*resource.c][if1632/thunk.c]
	EnumResource* added.

	* [loader/pe_resource.] [loader/resource.c]
	SizeofResource32(), LoadAccelerators32() added.

	* [misc/lstr.c]
	FormatMessage %n added.

	* [misc/crtdll.c][include/ctrdll.h][if1632/crtdll.spec]
	_chdrive,_errno,_isctype added.

	* [misc/cpu.c]
	Replaced runtime_cpu by GetSystemInfo().

	* [windows/hook.c][include/hook.h]
	Fixed mapping of hooks to win32/unicode.

	* [windows/keyboard.c] [windows/defwnd.c]
	Updated to win32 standard.
	ALT-<Menukey> fixed.

	* [windows/queue.c]
	GetWindowThreadProcessId() implemented.

Mon Jan 27 16:42:49 1997  John Harvey <john@division.co.uk>

	* [graphics/metafiledrv/*] [graphics/x11drv/*]
	  [objects/bitmap.c] [objects/brush.c] [objects/font.c]
	  [objects/gdiobj.c] [objects/pen.c]
	Moved SelectObject to graphics drivers. Printer support now works
	in a few cases but is definitely not complete. Generic/text driver
	works. The postscript driver works if true type fonts are disabled
	from the control panel. To enable printer support add Printer=on
	to the wine section of your wine.conf file. This causes write not
	to work properly. I know that several other printer drivers do not
	work.

	* [tools/build.c]
	Make .stabs not used for svr4 since it doesn't use GNU assembler.

	* [misc/fontengine.c]
	Make sure a printf doesn't crash the system.

Sat Jan 25 15:53:35 1997  Huw D M Davies <h.davies1@physics.oxford.ac.uk>

	* [objects/metafile.c]
	Fixed some problems with PlayMetaFileRecord().

	* [objects/dc.c]
	hClipRgn gets initialized in GetDCState().

Fri Jan 24 21:22:26 1997  Philippe De Muyter  <phdm@info.ucl.ac.be>

	* [debugger/stabs.c]
	Handle file names beginning with '/'.

Fri Jan 24 18:33:04 1997  Robert Pouliot <krynos@clic.net>

	* [*/*]
	Some more patches for OS/2 support.

Fri Jan 24 11:30:41 1997  Bang Jun-Young  <bangjy@nownuri.nowcom.co.kr>

	* [resources/sysres_Ko.rc]
	Updated support for Korean (Ko) language.
diff --git a/objects/font.c b/objects/font.c
index 2489e4d..b4a3a32 100644
--- a/objects/font.c
+++ b/objects/font.c
@@ -21,11 +21,8 @@
 #include "stddebug.h"
 #include "debug.h"
 
-#define FONTCACHE 	32	/* dynamic font cache size */
-#define MAX_FONTS	256
-static LPLOGFONT16 lpLogFontList[MAX_FONTS+1];
+LPLOGFONT16 lpLogFontList[MAX_FONTS+1];
 
-static int ParseFontParms(LPSTR lpFont, WORD wParmsNo, LPSTR lpRetStr, WORD wMaxSiz);
 
 #define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \
 			     (((cs)->rbearing|(cs)->lbearing| \
@@ -54,238 +51,8 @@
 #define CI_GET_DEFAULT_INFO(fs,cs) \
   CI_GET_CHAR_INFO(fs, fs->default_char, NULL, cs)
 
-struct FontStructure {
-	char *window;
-	char *x11;
-} FontNames[32];
-int FontSize;
 
 
-/***********************************************************************
- *           FONT_Init
- */
-BOOL32 FONT_Init( void )
-{
-  char  temp[1024];
-  LPSTR ptr;
-  int i;
-
-  if (PROFILE_GetWineIniString( "fonts", NULL, "*", temp, sizeof(temp) ) > 2 )
-  {
-    for( ptr = temp, i = 1; strlen(ptr) != 0; ptr += strlen(ptr) + 1 )
-      if( strcmp( ptr, "default" ) )
-	FontNames[i++].window = xstrdup( ptr );
-    FontSize = i;
-
-    for( i = 1; i < FontSize; i++ )
-    {
-        PROFILE_GetWineIniString( "fonts", FontNames[i].window, "*",
-                                  temp, sizeof(temp) );
-        FontNames[i].x11 = xstrdup( temp );
-    }
-    PROFILE_GetWineIniString( "fonts", "default", "*", temp, sizeof(temp) );
-    FontNames[0].x11 = xstrdup( temp );
-
-  } else {
-    FontNames[0].window = NULL; FontNames[0].x11 = "*-helvetica";
-    FontNames[1].window = "ms sans serif"; FontNames[1].x11 = "*-helvetica";
-    FontNames[2].window = "ms serif"; FontNames[2].x11 = "*-times";
-    FontNames[3].window = "fixedsys"; FontNames[3].x11 = "*-fixed";
-    FontNames[4].window = "arial"; FontNames[4].x11 = "*-helvetica";
-    FontNames[5].window = "helv"; FontNames[5].x11 = "*-helvetica";
-    FontNames[6].window = "roman"; FontNames[6].x11 = "*-times";
-    FontNames[7].window = "system"; FontNames[7].x11 = "*-helvetica";
-    FontSize = 8;
-  }
-  return TRUE;
-}
-
-/***********************************************************************
- *           FONT_ChkX11Family
- *
- * returns a valid X11 equivalent if a Windows face name 
- * is like a X11 family  - or NULL if translation is needed
- */
-static char *FONT_ChkX11Family(char *winFaceName )
-{
-  static char x11fam[32+2];   /* will be returned */
-  int i;
-
-  for(i = 0; lpLogFontList[i] != NULL; i++)
-    if( !lstrcmpi32A(winFaceName, lpLogFontList[i]->lfFaceName) )
-    {
-	strcpy(x11fam,"*-");
-	return strcat(x11fam,winFaceName);
-    }    
-  return NULL;               /* a FONT_TranslateName() call is needed */
-}
-
-
-
-/***********************************************************************
- *           FONT_TranslateName
- *
- * Translate a Windows face name to its X11 equivalent.
- * This will probably have to be customizable.
- */
-static const char *FONT_TranslateName( char *winFaceName )
-{
-  int i;
-
-  for (i = 1; i < FontSize; i ++)
-    if( !lstrcmpi32A( winFaceName, FontNames[i].window ) ) {
-      dprintf_font(stddeb, "---- Mapped %s to %s\n", winFaceName, FontNames[i].x11 );
-      return FontNames[i].x11;
-    }
-  return FontNames[0].x11;
-}
-
-
-/***********************************************************************
- *           FONT_MatchFont
- *
- * Find a X font matching the logical font.
- */
-static XFontStruct * FONT_MatchFont( LOGFONT16 * font, DC * dc )
-{
-    char pattern[100];
-    const char *family, *weight, *charset;
-    char **names;
-    char slant, oldspacing, spacing;
-    int width, height, oldheight, count;
-    XFontStruct * fontStruct;
-    
-    dprintf_font(stddeb,
-	"FONT_MatchFont(H,W = %d,%d; Weight = %d; Italic = %d; FaceName = '%s'\n",
-	font->lfHeight, font->lfWidth, font->lfWeight, font->lfItalic, font->lfFaceName);
-    weight = (font->lfWeight > 550) ? "bold" : "medium";
-    slant = font->lfItalic ? 'i' : 'r';
-    if (font->lfHeight == -1)
-	height = 0;
-    else
-	height = font->lfHeight * dc->vportExtX / dc->wndExtX;
-    if (height == 0) height = 120;  /* Default height = 12 */
-    else if (height < 0)
-    {
-        /* If height is negative, it means the height of the characters */
-        /* *without* the internal leading. So we adjust it a bit to     */
-        /* compensate. 5/4 seems to give good results for small fonts.  */
-	/* 
-         * J.M.: This causes wrong font size for bigger fonts e.g. in Winword & Write 
-        height = 10 * (-height * 9 / 8);
-	 * may be we have to use an non linear function
-	*/
-	/* assume internal leading is 2 pixels. Else small fonts will become
-         * very small. */
-        height = (height-2) * -10; 
-    }
-    else height *= 10;
-    width  = 10 * (font->lfWidth * dc->vportExtY / dc->wndExtY);
-    if (width < 0) {
-	dprintf_font( stddeb, "FONT_MatchFont: negative width %d(%d)\n",
-		      width, font->lfWidth );
-	width = -width;
-    }
-
-    spacing = (font->lfPitchAndFamily & FIXED_PITCH) ? 'm' :
-	      (font->lfPitchAndFamily & VARIABLE_PITCH) ? 'p' : '*';
-    
-  
-    charset = (font->lfCharSet == ANSI_CHARSET) ? "iso8859-1" : "*-*";
-    if (*font->lfFaceName) {
-	family = FONT_ChkX11Family(font->lfFaceName);
-	/*--do _not_ translate if lfFaceName is family from X11  A.K.*/
-	if (!family) 
-	  family = FONT_TranslateName( font->lfFaceName );
-	/* FIX ME: I don't if that's correct but it works J.M. */
-	spacing = '*';
-	}
-    else switch(font->lfPitchAndFamily & 0xf0)
-    {
-    case FF_ROMAN:
-      family = FONT_TranslateName( "roman" );
-      break;
-    case FF_SWISS:
-      family = FONT_TranslateName( "swiss" );
-      break;
-    case FF_MODERN:
-      family = FONT_TranslateName( "modern" );
-      break;
-    case FF_SCRIPT:
-      family = FONT_TranslateName( "script" );
-      break;
-    case FF_DECORATIVE:
-      family = FONT_TranslateName( "decorative" );
-      break;
-    default:
-      family = "*-*";
-      break;
-    }
-    sprintf( pattern, "-%s-%s-*-normal-*-*-*-*-*-*-*-%s",
-	    family, weight, charset);
-    dprintf_font(stddeb, "FONT_MatchFont: '%s'\n", pattern );
-    names = XListFonts( display, pattern, 1, &count );
-    if (names) XFreeFontNames( names );
-    else
-    {
-        if (strcmp(family, "*-*") == 0)
-        {
-            fprintf(stderr, "FONT_MatchFont(%s) : returning NULL\n", pattern);
-            return NULL;
-        }
-        else family = "*-*";
-    }
-    oldheight = height;
-    oldspacing = spacing;
-    while (TRUE) {
-	    /* Width==0 seems not to be a valid wildcard on SGI's, using * instead */
-	    if ( width == 0 )
-	      sprintf( pattern, "-%s-%s-%c-normal-*-*-%d-*-*-%c-*-%s",
-		      family, weight, slant, height, spacing, charset);
-	    else
-	      sprintf( pattern, "-%s-%s-%c-normal-*-*-%d-*-*-%c-%d-%s",
-		      family, weight, slant, height, spacing, width, charset);
-	    dprintf_font(stddeb, "FONT_MatchFont: '%s'\n", pattern );
-	    names = XListFonts( display, pattern, 1, &count );
-	    if (count > 0) break;
-            if (spacing == 'm') /* try 'c' if no 'm' found */ {
-
-                spacing = 'c';
-                continue;
-            } else if (spacing == 'p') /* try '*' if no 'p' found */ {
-                spacing = '*';
-                continue;
-            }
-            spacing = oldspacing;
-            height -= 10;		
-            if (height < 10) {
-                if (slant == 'i') {
-		    /* try oblique if no italic font */
-		    slant = 'o';
-		    height = oldheight;
-		    continue;
-		}
-		if (spacing == 'm' && strcmp(family, "*-*") != 0) {
-		    /* If a fixed spacing font could not be found, ignore
-		     * the family */
-		    family = "*-*";
-		    height = oldheight;
-		    continue;
-		}
-                fprintf(stderr, "FONT_MatchFont(%s) : returning NULL\n", pattern);
-		return NULL;
-            }
-    }
-    dprintf_font(stddeb,"        Found '%s'\n", *names );
-    if (!*font->lfFaceName)
-      ParseFontParms(*names, 2, font->lfFaceName , LF_FACESIZE-1);
-    /* we need a font name for function GetTextFace() even if there isn't one ;-) */  
-
-    fontStruct = XLoadQueryFont( display, *names );
-    XFreeFontNames( names );
-    return fontStruct;
-}
-
 
 /***********************************************************************
  *           FONT_LOGFONT32AToLOGFONT16
@@ -604,165 +371,6 @@
 }
 
 
-/***********************************************************************
- *           FONT_SelectObject
- */
-HFONT16 FONT_SelectObject( DC * dc, HFONT16 hfont, FONTOBJ * font )
-{
-    static X_PHYSFONT stockFonts[LAST_STOCK_FONT-FIRST_STOCK_FONT+1];
-
-    static struct {
-		HFONT16		id;
-		LOGFONT16	logfont;
-		int		access;
-		int		used;
-		X_PHYSFONT	cacheFont; } cacheFonts[FONTCACHE], *cacheFontsMin;
-    int 	i;
-
-    X_PHYSFONT * stockPtr;
-    HFONT16 prevHandle = dc->w.hFont;
-    XFontStruct * fontStruct;
-    dprintf_font(stddeb,"FONT_SelectObject(%p, %04x, %p)\n", dc, hfont, font);
-
-#if 0 /* From the code in SelectObject, this can not happen */
-      /* Load font if necessary */
-    if (!font)
-    {
-	HFONT16 hnewfont;
-
-	hnewfont = CreateFont16(10, 7, 0, 0, FW_DONTCARE,
-			      FALSE, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
-			      DEFAULT_QUALITY, FF_DONTCARE, "*" );
-	font = (FONTOBJ *) GDI_HEAP_LIN_ADDR( hnewfont );
-    }
-#endif
-
-    if (dc->header.wMagic == METAFILE_DC_MAGIC)
-      if (MF_CreateFontIndirect(dc, hfont, &(font->logfont)))
-	return prevHandle;
-      else
-	return 0;
-
-    if ((hfont >= FIRST_STOCK_FONT) && (hfont <= LAST_STOCK_FONT))
-	stockPtr = &stockFonts[hfont - FIRST_STOCK_FONT];
-    else {
-	stockPtr = NULL;
-	/*
-	 * Ok, It's not a stock font but 
-	 * may be it's cached in dynamic cache
-	 */
-	for(i=0; i<FONTCACHE; i++) /* search for same handle */
-	     if (cacheFonts[i].id==hfont) { /* Got the handle */
-		/*
-		 * Check if Handle matches the font 
-		 */
-		if(memcmp(&cacheFonts[i].logfont,&(font->logfont), sizeof(LOGFONT16))) {
-			/* No: remove handle id from dynamic font cache */
-			cacheFonts[i].access=0;
-			cacheFonts[i].used=0;
-			cacheFonts[i].id=0;
-			/* may be there is an unused handle which contains the font */
-			for(i=0; i<FONTCACHE; i++) {
-				if((cacheFonts[i].used == 0) &&
-				  (memcmp(&cacheFonts[i].logfont,&(font->logfont), sizeof(LOGFONT16)))== 0) {
-					/* got it load from cache and set new handle id */
-					stockPtr = &cacheFonts[i].cacheFont;
-					cacheFonts[i].access=1;
-					cacheFonts[i].used=1;
-					cacheFonts[i].id=hfont;
-					dprintf_font(stddeb,"FONT_SelectObject: got font from unused handle\n");
-					break;
-					}
-				}
-	
-			}
-		else {
-			/* Yes: load from dynamic font cache */
-			stockPtr = &cacheFonts[i].cacheFont;
-			cacheFonts[i].access++;
-			cacheFonts[i].used++;
-			}
-		break;
-		}
-	}
-    if (!stockPtr || !stockPtr->fstruct)
-    {
-	if (!(fontStruct = FONT_MatchFont( &font->logfont, dc )))
-        {
-              /* If it is not a stock font, we can simply return 0 */
-            if (!stockPtr) return 0;
-              /* Otherwise we must try to find a substitute */
-            dprintf_font(stddeb,"Loading font 'fixed' for %04x\n", hfont );
-            font->logfont.lfPitchAndFamily &= ~VARIABLE_PITCH;
-            font->logfont.lfPitchAndFamily |= FIXED_PITCH;
-            fontStruct = XLoadQueryFont( display, "fixed" );
-            if (!fontStruct)
-            {
-                fprintf( stderr, "No system font could be found. Please check your font path.\n" );
-                exit( 1 );
-            }
-        }
-    }
-    else
-    {
-	fontStruct = stockPtr->fstruct;
-	dprintf_font(stddeb,
-                     "FONT_SelectObject: Loaded font from cache %04x %p\n",
-		     hfont, fontStruct );
-    }	
-
-      /* Unuse previous font */
-	for (i=0; i < FONTCACHE; i++) {
-		if (cacheFonts[i].id == prevHandle) {
-			if(cacheFonts[i].used == 0)
-				fprintf(stderr, "Trying to decrement a use count of 0.\n");
-			else 
-				cacheFonts[i].used--;
-		}
-	}
-
-      /* Store font */
-    dc->w.hFont = hfont;
-    if (stockPtr)
-    {
-	if (!stockPtr->fstruct)
-	{
-	    stockPtr->fstruct = fontStruct;
-	    FONT_GetMetrics( &font->logfont, fontStruct, &stockPtr->metrics );
-	}
-	memcpy( &dc->u.x.font, stockPtr, sizeof(*stockPtr) );
-    }
-    else
-    {
-	/* 
-	 * Check in cacheFont
-	 */
-	cacheFontsMin=NULL;
-	for (i=0; i < FONTCACHE; i++) {
-		if (cacheFonts[i].used==0) 
-			if ((!cacheFontsMin) || ((cacheFontsMin) && (cacheFontsMin->access > cacheFonts[i].access)))
-				cacheFontsMin=&cacheFonts[i];
-		}
-	if (!cacheFontsMin) {
-		fprintf(stderr,"No unused font cache entry !!!!\n" );
-		return prevHandle;
-	}
-	if (cacheFontsMin->id!=0) {
-		dprintf_font(stddeb,
-			"FONT_SelectObject: Freeing %04x \n",cacheFontsMin->id );
-		XFreeFont( display, cacheFontsMin->cacheFont.fstruct );
-		}
-	cacheFontsMin->cacheFont.fstruct = fontStruct;
-	FONT_GetMetrics( &font->logfont, fontStruct, &cacheFontsMin->cacheFont.metrics );
-	cacheFontsMin->access=1;
-	cacheFontsMin->used=1;
-	cacheFontsMin->id=hfont;
-	memcpy( &dc->u.x.font, &(cacheFontsMin->cacheFont), sizeof(cacheFontsMin->cacheFont) );
-	memcpy(&cacheFontsMin->logfont,&(font->logfont), sizeof(LOGFONT16));
-
-    }
-    return prevHandle;
-}
 
 
 /***********************************************************************
@@ -1277,7 +885,10 @@
  */
 INT AddFontResource( LPCSTR str )
 {
-    fprintf( stdnimp, "STUB: AddFontResource('%s')\n", str );
+    if (HIWORD(str))
+        fprintf( stdnimp, "STUB: AddFontResource('%s')\n", str );
+    else
+        fprintf( stdnimp, "STUB: AddFontResource(%04x)\n", LOWORD(str) );
     return 1;
 }
 
@@ -1287,15 +898,17 @@
  */
 BOOL RemoveFontResource( LPSTR str )
 {
-    fprintf( stdnimp, "STUB: RemoveFontResource('%s')\n", str );
+    if (HIWORD(str))
+        fprintf( stdnimp, "STUB: RemoveFontResource('%s')\n", str );
+    else
+        fprintf( stdnimp, "STUB: RemoveFontResource(%04x)\n", LOWORD(str) );
     return TRUE;
 }
 
-
 /*************************************************************************
- *				ParseFontParms		[internal]
+ *				FONT_ParseFontParms		[internal]
  */
-int ParseFontParms(LPSTR lpFont, WORD wParmsNo, LPSTR lpRetStr, WORD wMaxSiz)
+int FONT_ParseFontParms(LPSTR lpFont, WORD wParmsNo, LPSTR lpRetStr, WORD wMaxSiz)
 {
 	int 	i;
 	if (lpFont == NULL) return 0;
@@ -1318,6 +931,7 @@
 }
 
 
+
 /*************************************************************************
  *				InitFontsList		[internal]
  */
@@ -1362,11 +976,11 @@
   for (i = 0; i < count; i++) {
     dprintf_font(stddeb,"InitFontsList // names[%d]='%s' \n", i, names[i]);
 
-    ParseFontParms(names[i], 2, str, sizeof(str));
+    FONT_ParseFontParms(names[i], 2, str, sizeof(str));
     strcpy(lpNewFont->lfFaceName, str);
-    ParseFontParms(names[i], 8, str, sizeof(str));
+    FONT_ParseFontParms(names[i], 8, str, sizeof(str));
     lpNewFont->lfHeight = atoi(str) / 10;
-    ParseFontParms(names[i], 12, str, sizeof(str));
+    FONT_ParseFontParms(names[i], 12, str, sizeof(str));
     lpNewFont->lfWidth = atoi(str) / 10;
     lpNewFont->lfEscapement = 0;
     lpNewFont->lfOrientation = 0;
@@ -1374,7 +988,7 @@
     lpNewFont->lfItalic = 0;
     lpNewFont->lfUnderline = 0;
     lpNewFont->lfStrikeOut = 0;
-    ParseFontParms(names[i], 13, str, sizeof(str));
+    FONT_ParseFontParms(names[i], 13, str, sizeof(str));
     if (strcmp(str, "iso8859") == 0)  {
       lpNewFont->lfCharSet = ANSI_CHARSET;
     } else  {
@@ -1383,7 +997,7 @@
     lpNewFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
     lpNewFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
     lpNewFont->lfQuality = DEFAULT_QUALITY;
-    ParseFontParms(names[i], 11, str, sizeof(str));
+    FONT_ParseFontParms(names[i], 11, str, sizeof(str));
     switch(str[0]) {
      case 'p':
       lpNewFont->lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS;
@@ -1570,6 +1184,7 @@
   return nRet;
 }
 
+
 /*************************************************************************
  *				EnumFontFamiliesExA	[GDI32.81]
  * FIXME: Don't use 16 bit GDI heap functions (applies to EnumFontFamiliesEx32*)
@@ -1755,3 +1370,4 @@
     for (i = 0; i < cPairs; i++) lpKerningPairs[i].iKernAmount = 0;
     return 0;
 }
+