comparison win/dw.c @ 439:7f39be80dec3

Hopefully better method of removing the font modifiers.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 29 May 2003 09:53:04 +0000
parents fac2afe7bda3
children 9af47c551a56
comparison
equal deleted inserted replaced
438:fac2afe7bda3 439:7f39be80dec3
3382 if(buflen > len) 3382 if(buflen > len)
3383 { 3383 {
3384 for(z=0;z<=(buflen-len);z++) 3384 for(z=0;z<=(buflen-len);z++)
3385 { 3385 {
3386 if(memcmp(text, &buffer[z], len) == 0) 3386 if(memcmp(text, &buffer[z], len) == 0)
3387 return 1; 3387 return z;
3388 } 3388 }
3389 } 3389 }
3390 return 0; 3390 return 0;
3391 } 3391 }
3392 3392
3402 } 3402 }
3403 3403
3404 HFONT _acquire_font(HWND handle, char *fontname) 3404 HFONT _acquire_font(HWND handle, char *fontname)
3405 { 3405 {
3406 HFONT hfont; 3406 HFONT hfont;
3407 int z, size = 9;
3408 LOGFONT lf;
3409 char *myFontName;
3410 3407
3411 if(fontname == DefaultFont || !fontname[0]) 3408 if(fontname == DefaultFont || !fontname[0])
3412 hfont = GetStockObject(DEFAULT_GUI_FONT); 3409 hfont = GetStockObject(DEFAULT_GUI_FONT);
3413 else 3410 else
3414 { 3411 {
3412 int Italic, Bold;
3413 char *myFontName;
3414 int z, size = 9;
3415 LOGFONT lf;
3415 #if 0 3416 #if 0
3416 HDC hDC = GetDC(handle); 3417 HDC hDC = GetDC(handle);
3417 #endif 3418 #endif
3418 for(z=0;z<strlen(fontname);z++) 3419 for(z=0;z<strlen(fontname);z++)
3419 { 3420 {
3420 if(fontname[z]=='.') 3421 if(fontname[z]=='.')
3421 break; 3422 break;
3422 } 3423 }
3423 size = atoi(fontname) + 5; 3424 size = atoi(fontname) + 5;
3424 3425 Italic = instring(" Italic", &fontname[z+1]);
3426 Bold = instring(" Bold", &fontname[z+1]);
3425 #if 0 3427 #if 0
3426 lf.lfHeight = -MulDiv(size, GetDeviceCaps(hDC, LOGPIXELSY), 72); 3428 lf.lfHeight = -MulDiv(size, GetDeviceCaps(hDC, LOGPIXELSY), 72);
3427 #endif 3429 #endif
3428 lf.lfHeight = size; 3430 lf.lfHeight = size;
3429 lf.lfWidth = 0; 3431 lf.lfWidth = 0;
3430 lf.lfEscapement = 0; 3432 lf.lfEscapement = 0;
3431 lf.lfOrientation = 0; 3433 lf.lfOrientation = 0;
3432 lf.lfItalic = instring(" Italic", &fontname[z+1]); 3434 lf.lfItalic = Italic ? TRUE : FALSE;
3433 lf.lfUnderline = 0; 3435 lf.lfUnderline = 0;
3434 lf.lfStrikeOut = 0; 3436 lf.lfStrikeOut = 0;
3435 lf.lfWeight = instring(" Bold", &fontname[z+1]) ? FW_BOLD : FW_NORMAL; 3437 lf.lfWeight = Bold ? FW_BOLD : FW_NORMAL;
3436 lf.lfCharSet = DEFAULT_CHARSET; 3438 lf.lfCharSet = DEFAULT_CHARSET;
3437 lf.lfOutPrecision = 0; 3439 lf.lfOutPrecision = 0;
3438 lf.lfClipPrecision = 0; 3440 lf.lfClipPrecision = 0;
3439 lf.lfQuality = DEFAULT_QUALITY; 3441 lf.lfQuality = DEFAULT_QUALITY;
3440 lf.lfPitchAndFamily = DEFAULT_PITCH | FW_DONTCARE; 3442 lf.lfPitchAndFamily = DEFAULT_PITCH | FW_DONTCARE;
3441 /* 3443 /*
3442 * remove any font modifiers by truncating at the first space 3444 * remove any font modifiers
3443 * - this may not be enough!; what about "Courier New" ???
3444 */ 3445 */
3445 myFontName = strdup(&fontname[z+1]); 3446 myFontName = strdup(&fontname[z+1]);
3446 for(z=0;z<strlen(myFontName);z++) 3447 if(Italic)
3447 if(myFontName[z] == ' ') 3448 myFontName[Italic] = 0;
3448 { 3449 if(Bold)
3449 myFontName[z]='\0'; 3450 myFontName[Bold] = 0;
3450 break;
3451 }
3452 strcpy(lf.lfFaceName, myFontName); 3451 strcpy(lf.lfFaceName, myFontName);
3453 free(myFontName); 3452 free(myFontName);
3454 3453
3455 hfont = CreateFontIndirect(&lf); 3454 hfont = CreateFontIndirect(&lf);
3456 #if 0 3455 #if 0