Changeset 10373 for trunk/src/gdi32/font.cpp
- Timestamp:
- Jan 11, 2004, 12:42:14 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gdi32/font.cpp
r10372 r10373 1 /* $Id: font.cpp,v 1.3 4 2004-01-08 11:11:55sandervl Exp $ */1 /* $Id: font.cpp,v 1.35 2004-01-11 11:42:11 sandervl Exp $ */ 2 2 3 3 /* … … 7 7 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl) 8 8 * Copyright 1998 Patrick Haller 9 * Copyright 2003 Innotek Systemberatung GmbH (stauff@innotek.de) 9 10 * 10 11 * TODO: EnumFontsA/W, EnumFontFamiliesExA/W not complete … … 32 33 #include <ctype.h> 33 34 #include <string.h> 34 #include "misc.h"35 #include <dbglog.h> 35 36 #include "unicode.h" 36 37 #include <heapstring.h> … … 40 41 #include <stats.h> 41 42 #include "oslibgpi.h" 43 #include "font.h" 44 #include "ft2supp.h" 42 45 43 46 #define DBG_LOCALLOG DBG_font … … 45 48 46 49 ODINDEBUGCHANNEL(GDI32-FONT) 47 48 50 49 51 typedef struct { … … 95 97 /* reserved for system */ 96 98 { DEFAULT_CHARSET, 0, FS(0)}, 97 { DEFAULT_CHARSET, 0, FS(0)},99 { SYMBOL_CHARSET, CP_SYMBOL, FS(31)}, 98 100 }; 99 101 … … 146 148 LF_FACESIZE); 147 149 } 148 /*********************************************************************** 149 * FONT_mbtowc 150 * 151 * Returns a '\0' terminated Unicode translation of str using the 152 * charset of the currently selected font in hdc. If count is -1 then 153 * str is assumed to be '\0' terminated, otherwise it contains the 154 * number of bytes to convert. If plenW is non-NULL, on return it 155 * will point to the number of WCHARs (excluding the '\0') that have 156 * been written. If pCP is non-NULL, on return it will point to the 157 * codepage used in the conversion (NB, this may be CP_SYMBOL so watch 158 * out). The caller should free the returned LPWSTR from the process 159 * heap itself. 160 */ 161 LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP) 162 { 163 UINT cp = CP_ACP; 164 INT lenW, i; 165 LPWSTR strW; 166 CHARSETINFO csi; 167 int charset = GetTextCharset(hdc); 168 169 if( IsDBCSEnv() && ( charset == 0 )) 170 cp = CP_ACP; 171 else 172 /* Hmm, nicely designed api this one! */ 173 if(TranslateCharsetInfo((DWORD*)charset, &csi, TCI_SRCCHARSET)) 174 cp = csi.ciACP; 175 else { 176 switch(charset) { 177 case OEM_CHARSET: 178 cp = GetOEMCP(); 179 break; 180 case DEFAULT_CHARSET: 181 cp = GetACP(); 182 break; 183 184 case VISCII_CHARSET: 185 case TCVN_CHARSET: 186 case KOI8_CHARSET: 187 case ISO3_CHARSET: 188 case ISO4_CHARSET: 189 /* FIXME: These have no place here, but because x11drv 190 enumerates fonts with these (made up) charsets some apps 191 might use them and then the FIXME below would become 192 annoying. Now we could pick the intended codepage for 193 each of these, but since it's broken anyway we'll just 194 use CP_ACP and hope it'll go away... 195 */ 196 cp = CP_ACP; 197 break; 198 199 200 default: 201 dprintf(("Can't find codepage for charset %d\n", charset)); 202 break; 203 } 204 } 205 206 dprintf(("cp == %d\n", cp)); 207 208 if(count == -1) count = strlen(str); 209 if(cp != CP_SYMBOL) { 210 lenW = MultiByteToWideChar(cp, 0, str, count, NULL, 0); 211 strW = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, (lenW + 1) * sizeof(WCHAR)); 212 MultiByteToWideChar(cp, 0, str, count, strW, lenW); 213 } else { 214 lenW = count; 215 strW = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, (lenW + 1) * sizeof(WCHAR)); 216 for(i = 0; i < count; i++) strW[i] = (BYTE)str[i]; 217 } 218 strW[lenW] = '\0'; 219 dprintf(("mapped %s -> %ls\n", str, strW)); 220 if(plenW) *plenW = lenW; 221 if(pCP) *pCP = cp; 222 return strW; 223 } 150 #ifdef DEBUG 151 //****************************************************************************** 152 //****************************************************************************** 153 void dprintfLogFont(LOGFONTA *lplf) 154 { 155 dprintf(("GDI32: lfHeight = %d\n", lplf->lfHeight)); 156 dprintf(("GDI32: lfWidth = %d\n", lplf->lfWidth)); 157 dprintf(("GDI32: lfEscapement = %d\n", lplf->lfEscapement)); 158 dprintf(("GDI32: lfOrientation = %d\n", lplf->lfOrientation)); 159 dprintf(("GDI32: lfWeight = %d\n", lplf->lfWeight)); 160 dprintf(("GDI32: lfItalic = %d\n", lplf->lfItalic)); 161 dprintf(("GDI32: lfUnderline = %d\n", lplf->lfUnderline)); 162 dprintf(("GDI32: lfStrikeOut = %d\n", lplf->lfStrikeOut)); 163 dprintf(("GDI32: lfCharSet = %X\n", lplf->lfCharSet)); 164 dprintf(("GDI32: lfOutPrecision = %X\n", lplf->lfOutPrecision)); 165 dprintf(("GDI32: lfClipPrecision = %X\n", lplf->lfClipPrecision)); 166 dprintf(("GDI32: lfQuality = %X\n", lplf->lfQuality)); 167 dprintf(("GDI32: lfPitchAndFamily= %X\n", lplf->lfPitchAndFamily)); 168 dprintf(("GDI32: lfFaceName = %s\n", lplf->lfFaceName)); 169 } 170 //****************************************************************************** 171 //****************************************************************************** 172 void dprintfTextMetrics(TEXTMETRICA *pwtm) 173 { 174 dprintf(("pwtm->tmHeight %d", pwtm->tmHeight)); 175 dprintf(("pwtm->tmAscent %d", pwtm->tmAscent)); 176 dprintf(("pwtm->tmDescent %d", pwtm->tmDescent)); 177 dprintf(("pwtm->tmInternalLeading %d", pwtm->tmInternalLeading)); 178 dprintf(("pwtm->tmExternalLeading %d", pwtm->tmExternalLeading)); 179 dprintf(("pwtm->tmAveCharWidth %d", pwtm->tmAveCharWidth)); 180 dprintf(("pwtm->tmMaxCharWidth %d", pwtm->tmMaxCharWidth)); 181 dprintf(("pwtm->tmWeight %d", pwtm->tmWeight)); 182 dprintf(("pwtm->tmOverhang %d", pwtm->tmOverhang)); 183 dprintf(("pwtm->tmDigitizedAspectX %d", pwtm->tmDigitizedAspectX)); 184 dprintf(("pwtm->tmDigitizedAspectY %d", pwtm->tmDigitizedAspectY)); 185 dprintf(("pwtm->tmFirstChar %d", pwtm->tmFirstChar)); 186 dprintf(("pwtm->tmLastChar %d", pwtm->tmLastChar)); 187 dprintf(("pwtm->tmDefaultChar %d", pwtm->tmDefaultChar)); 188 dprintf(("pwtm->tmBreakChar %d", pwtm->tmBreakChar)); 189 dprintf(("pwtm->tmItalic %x", pwtm->tmItalic)); 190 dprintf(("pwtm->tmUnderlined %x", pwtm->tmUnderlined)); 191 dprintf(("pwtm->tmStruckOut %x", pwtm->tmStruckOut)); 192 dprintf(("pwtm->tmPitchAndFamily %x", pwtm->tmPitchAndFamily)); 193 dprintf(("pwtm->tmCharSet %x", pwtm->tmCharSet)); 194 } 195 #else 196 #define dprintfLogFont(a) 197 #define dprintfTextMetrics(a) 198 #endif 224 199 //****************************************************************************** 225 200 //****************************************************************************** … … 336 311 dprintf(("lpszFace = (%x) %s -> %s\n", lplf->lfFaceName, lplf->lfFaceName, afont.lfFaceName)); 337 312 338 dprintf(("GDI32: CreateFontIndirectA\n"));339 dprintf(("GDI32: lfHeight = %d\n", lplf->lfHeight));340 dprintf(("GDI32: lfWidth = %d\n", lplf->lfWidth));341 dprintf(("GDI32: lfEscapement = %d\n", lplf->lfEscapement));342 dprintf(("GDI32: lfOrientation = %d\n", lplf->lfOrientation));343 dprintf(("GDI32: lfWeight = %d\n", lplf->lfWeight));344 dprintf(("GDI32: lfItalic = %d\n", lplf->lfItalic));345 dprintf(("GDI32: lfUnderline = %d\n", lplf->lfUnderline));346 dprintf(("GDI32: lfStrikeOut = %d\n", lplf->lfStrikeOut));347 dprintf(("GDI32: lfCharSet = %X\n", lplf->lfCharSet));348 dprintf(("GDI32: lfOutPrecision = %X\n", lplf->lfOutPrecision));349 dprintf(("GDI32: lfClipPrecision = %X\n", lplf->lfClipPrecision));350 dprintf(("GDI32: lfQuality = %X\n", lplf->lfQuality));351 dprintf(("GDI32: lfPitchAndFamily= %X\n", lplf->lfPitchAndFamily));352 dprintf(("GDI32: lfFaceName = %s\n", lplf->lfFaceName));353 354 313 if( IsDBCSEnv()) 355 314 { … … 362 321 } 363 322 323 dprintf(("GDI32: CreateFontIndirectA\n")); 324 dprintfLogFont((LOGFONTA *)lplf); 325 364 326 hFont = O32_CreateFontIndirect(&afont); 365 327 if(hFont) { 366 328 STATS_CreateFontIndirect(hFont, &afont); 329 RegisterFont(hFont, (LPSTR)lplf->lfFaceName); 367 330 } 368 331 return(hFont); … … 387 350 //****************************************************************************** 388 351 int EXPENTRY_O32 EnumFontProcA(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA 389 lpTextM, DWORD arg3, LPARAM arg4) 390 { 391 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4; 392 FONTENUMPROCA proc = (FONTENUMPROCA)lpEnumData->userProc; 393 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel 352 lpTextM, DWORD arg3, LPARAM arg4) 353 { 354 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4; 355 FONTENUMPROCA proc = (FONTENUMPROCA)lpEnumData->userProc; 356 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel 357 358 if(FT2Module.Ft2QueryFontType(0, lpLogFont->elfLogFont.lfFaceName) == FT2_FONTTYPE_TRUETYPE) { 359 lpTextM->tmPitchAndFamily |= TMPF_TRUETYPE; 360 } 361 362 dprintfLogFont(&lpLogFont->elfLogFont); 363 dprintfTextMetrics((TEXTMETRICA *)lpTextM); 394 364 395 365 int rc = proc(lpLogFont, lpTextM, arg3, lpEnumData->userData); … … 408 378 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel 409 379 int rc; 380 381 if(FT2Module.Ft2QueryFontType(0, lpLogFont->elfLogFont.lfFaceName) == FT2_FONTTYPE_TRUETYPE) { 382 lpTextM->tmPitchAndFamily |= TMPF_TRUETYPE; 383 } 384 385 dprintfLogFont(&lpLogFont->elfLogFont); 386 dprintfTextMetrics((TEXTMETRICA *)lpTextM); 410 387 411 388 memcpy(&LogFont, lpLogFont, ((ULONG)&LogFont.elfLogFont.lfFaceName - … … 448 425 //****************************************************************************** 449 426 int EXPENTRY_O32 EnumFontProcExA(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA 450 lpTextM, DWORD arg3, LPARAM arg4)427 lpTextM, DWORD FontType, LPARAM arg4) 451 428 { 452 429 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4; … … 456 433 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel 457 434 435 if(FT2Module.Ft2QueryFontType(0, lpLogFont->elfLogFont.lfFaceName) == FT2_FONTTYPE_TRUETYPE) { 436 lpTextM->tmPitchAndFamily |= TMPF_TRUETYPE; 437 } 438 439 dprintfLogFont(&lpLogFont->elfLogFont); 440 dprintfTextMetrics((TEXTMETRICA *)lpTextM); 441 458 442 memcpy(&logFont, lpLogFont, sizeof(ENUMLOGFONTA)); 459 443 memset(logFont.elfScript, 0, sizeof(logFont.elfScript)); … … 461 445 memset(&textM.ntmFontSig, 0, sizeof(textM.ntmFontSig)); 462 446 463 dprintf(("EnumFontProcExA %s height %d", logFont.elfLogFont.lfFaceName, textM.ntmTm.tmHeight));464 465 int rc = proc(&logFont, &textM, arg3, lpEnumData->userData);447 dprintf(("EnumFontProcExA %s type %x height %d", logFont.elfLogFont.lfFaceName, FontType, textM.ntmTm.tmHeight)); 448 449 int rc = proc(&logFont, &textM, FontType, lpEnumData->userData); 466 450 SetFS(selTIB); // switch back to the saved FS selector 467 451 return rc; … … 471 455 //****************************************************************************** 472 456 int EXPENTRY_O32 EnumFontProcExW(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA lpTextM, 473 DWORD arg3, LPARAM arg4)457 DWORD FontType, LPARAM arg4) 474 458 { 475 459 ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4; … … 479 463 USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel 480 464 int rc; 465 466 if(FT2Module.Ft2QueryFontType(0, lpLogFont->elfLogFont.lfFaceName) == FT2_FONTTYPE_TRUETYPE) { 467 lpTextM->tmPitchAndFamily |= TMPF_TRUETYPE; 468 } 469 470 dprintfLogFont(&lpLogFont->elfLogFont); 471 dprintfTextMetrics((TEXTMETRICA *)lpTextM); 481 472 482 473 memcpy(&LogFont, lpLogFont, ((ULONG)&LogFont.elfLogFont.lfFaceName - (ULONG)&LogFont)); … … 512 503 memset(&textM.ntmFontSig, 0, sizeof(textM.ntmFontSig)); 513 504 514 dprintf(("EnumFontProcExW %s height %d", lpLogFont->elfLogFont.lfFaceName, textM.ntmTm.tmHeight));515 rc = proc(&LogFont, &textM, arg3, lpEnumData->userData);505 dprintf(("EnumFontProcExW %s type %x height %d charset %d/%d", lpLogFont->elfLogFont.lfFaceName, FontType, textM.ntmTm.tmHeight, lpTextM->tmCharSet, lpLogFont->elfLogFont.lfCharSet)); 506 rc = proc(&LogFont, &textM, FontType, lpEnumData->userData); 516 507 SetFS(selTIB); // switch back to the saved FS selector 517 508 return rc; … … 586 577 //****************************************************************************** 587 578 INT WIN32API EnumFontFamiliesExA(HDC hdc, 588 LPLOGFONTA arg2,579 LPLOGFONTA lpLogFont, 589 580 FONTENUMPROCEXA arg3, 590 581 LPARAM arg4, … … 594 585 int rc; 595 586 596 dprintf(("GDI32: EnumFontFamiliesExA not complete %s", arg2->lfFaceName)); 587 dprintf(("GDI32: EnumFontFamiliesExA not complete %s", lpLogFont->lfFaceName)); 588 dprintf(("GDI32: EnumFontFamiliesExA font name %s character set %x", lpLogFont->lfFaceName, lpLogFont->lfCharSet)); 597 589 598 590 enumData.userProc = (DWORD)arg3; … … 600 592 enumData.dwFlags = dwFlags; 601 593 602 rc = O32_EnumFontFamilies(hdc, arg2->lfFaceName, &EnumFontProcExA, (LPARAM)&enumData);594 rc = O32_EnumFontFamilies(hdc, lpLogFont->lfFaceName, &EnumFontProcExA, (LPARAM)&enumData); 603 595 604 596 return rc; … … 607 599 //****************************************************************************** 608 600 INT WIN32API EnumFontFamiliesExW(HDC hdc, 609 LPLOGFONTW arg2,601 LPLOGFONTW lpLogFont, 610 602 FONTENUMPROCEXW arg3, 611 603 LPARAM arg4, … … 614 606 ENUMUSERDATA enumData; 615 607 int rc; 616 char *astring = UnicodeToAsciiString((LPWSTR) arg2->lfFaceName);608 char *astring = UnicodeToAsciiString((LPWSTR)lpLogFont->lfFaceName); 617 609 618 610 dprintf(("GDI32: EnumFontFamiliesExW not complete %s", astring)); 611 dprintf(("GDI32: EnumFontFamiliesExW font name %s character set %x", astring, lpLogFont->lfCharSet)); 619 612 620 613 enumData.userProc = (DWORD)arg3; … … 627 620 return rc; 628 621 } 629 //******************************************************************************630 //******************************************************************************631 DWORD WIN32API GetFontData(HDC hdc, DWORD dwTable,632 DWORD dwOffset,633 LPVOID lpvBuffer,634 DWORD dbData)635 {636 dprintf(("GDI32: GetFontData, not implemented (GDI_ERROR)\n"));637 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);638 639 return(GDI_ERROR);640 }641 //******************************************************************************642 //******************************************************************************643 int WIN32API AddFontResourceA(LPCSTR szFont)644 {645 HINSTANCE hInstance;646 647 dprintf(("GDI32: AddFontResourceA %s", szFont));648 hInstance = LoadLibraryA(szFont);649 if(hInstance) {650 dprintf(("AddFontResourceA: executable file; NOT IMPLEMENTED"));651 FreeLibrary(hInstance);652 return 1;653 }654 return 1;655 }656 //******************************************************************************657 //******************************************************************************658 int WIN32API AddFontResourceW(LPCWSTR szFont)659 {660 char *astring = UnicodeToAsciiString((LPWSTR)szFont);661 BOOL rc;662 663 dprintf(("GDI32: AddFontResourceW"));664 // NOTE: This will not work as is (needs UNICODE support)665 rc = AddFontResourceA(astring);666 FreeAsciiString(astring);667 return rc;668 }669 //******************************************************************************670 //******************************************************************************671 BOOL WIN32API RemoveFontResourceA(LPCSTR lpszFont)672 {673 dprintf(("GDI32: RemoveFontResourceA %s", lpszFont));674 return FALSE;675 }676 //******************************************************************************677 //******************************************************************************678 BOOL WIN32API RemoveFontResourceW(LPCWSTR szFont)679 {680 char *astring = UnicodeToAsciiString((LPWSTR)szFont);681 BOOL rc;682 683 dprintf(("GDI32: RemoveFontResourceW"));684 rc = RemoveFontResourceA(astring);685 FreeAsciiString(astring);686 return(rc);687 }688 /*****************************************************************************689 * Name : BOOL CreateScalableFontResourceA690 * Purpose : The CreateScalableFontResourceA function creates a font resource691 * file for a scalable font.692 * Parameters: DWORD fdwHidden flag for read-only embedded font693 * LPCSTR lpszFontRes address of filename for font resource694 * LPCSTR lpszFontFile address of filename for scalable font695 * LPCSTR lpszCurrentPath address of path to font file696 * Variables :697 * Result : TRUE / FALSE698 * Remark :699 * Status : UNTESTED STUB700 *701 * Author : Patrick Haller [Mon, 1998/06/15 08:00]702 *****************************************************************************/703 704 BOOL WIN32API CreateScalableFontResourceA(DWORD fdwHidden,705 LPCSTR lpszFontRes,706 LPCSTR lpszFontFile,707 LPCSTR lpszCurrentPath)708 {709 dprintf(("GDI32: CreateScalableFontResourceA %x %s %s %s not implemented", fdwHidden, lpszFontRes, lpszFontFile, lpszCurrentPath));710 711 // return OSLibGpiLoadFonts((LPSTR)lpszFontFile);712 return FALSE;713 }714 715 716 /*****************************************************************************717 * Name : BOOL CreateScalableFontResourceW718 * Purpose : The CreateScalableFontResourceW function creates a font resource719 * file for a scalable font.720 * Parameters: DWORD fdwHidden flag for read-only embedded font721 * LPCSTR lpszFontRes address of filename for font resource722 * LPCSTR lpszFontFile address of filename for scalable font723 * LPCSTR lpszCurrentPath address of path to font file724 * Variables :725 * Result : TRUE / FALSE726 * Remark :727 * Status : UNTESTED STUB728 *729 * Author : Patrick Haller [Mon, 1998/06/15 08:00]730 *****************************************************************************/731 732 BOOL WIN32API CreateScalableFontResourceW(DWORD fdwHidden,733 LPCWSTR lpszFontRes,734 LPCWSTR lpszFontFile,735 LPCWSTR lpszCurrentPath)736 {737 LPSTR lpszFontFileA = NULL, lpszFontResA = NULL, lpszCurrentPathA = NULL;738 739 dprintf(("GDI32: CreateScalableFontResourceW %x %ls %ls %ls not implemented", fdwHidden, lpszFontRes, lpszFontFile, lpszCurrentPath));740 741 STACK_strdupWtoA(lpszFontFile, lpszFontFileA);742 STACK_strdupWtoA(lpszFontRes, lpszFontResA);743 STACK_strdupWtoA(lpszCurrentPath, lpszCurrentPathA);744 return CreateScalableFontResourceA(fdwHidden, lpszFontResA, lpszFontFileA, lpszCurrentPathA);745 }746 747 622 748 623 /***************************************************************************** … … 819 694 820 695 rc = O32_GetTextMetrics(hdc, pwtm); 821 dprintf(("GDI32: GetTextMetricsA %x %x returned %d", hdc, pwtm, rc)); 696 697 if(rc == TRUE) { 698 if(FT2Module.Ft2QueryFontType(hdc, NULL) == FT2_FONTTYPE_TRUETYPE) { 699 pwtm->tmPitchAndFamily |= TMPF_TRUETYPE; 700 } 701 } 702 dprintfTextMetrics(pwtm); 822 703 return(rc); 823 704 } … … 826 707 BOOL WIN32API GetTextMetricsW( HDC hdc, LPTEXTMETRICW pwtm) 827 708 { 828 BOOL rc; 829 TEXTMETRICA atm; 830 831 dprintf(("GDI32: GetTextMetricsW")); 832 833 rc = O32_GetTextMetrics(hdc, &atm); 709 BOOL rc; 710 TEXTMETRICA atm; 711 712 rc = GetTextMetricsA(hdc, &atm); 834 713 pwtm->tmHeight = atm.tmHeight; 835 714 pwtm->tmAscent = atm.tmAscent; … … 853 732 pwtm->tmCharSet = atm.tmCharSet; 854 733 855 dprintf(("GDI32: GetTextMetricsW %x %x returned %d", hdc, pwtm, rc));856 734 return(rc); 857 735 } 858 736 //****************************************************************************** 859 737 //****************************************************************************** 860 int WIN32API GetTextFaceA( HDC hdc, int arg2, LPSTR arg3) 861 { 862 dprintf(("GDI32: GetTextFaceA %x %d %x", hdc, arg2, arg3)); 863 return O32_GetTextFace(hdc, arg2, arg3); 864 } 865 //****************************************************************************** 866 //****************************************************************************** 867 int WIN32API GetTextFaceW( HDC hdc, int arg2, LPWSTR arg3) 868 { 869 char *astring = NULL; 870 int lenA = GetTextFaceA( hdc, 0, NULL ); 871 int rc; 872 873 dprintf(("GDI32: GetTextFaceW")); 738 int WIN32API GetTextFaceA( HDC hdc, int nCount, LPSTR lpFaceName) 739 { 740 int ret; 741 742 dprintf(("GDI32: GetTextFaceA %x %d %x", hdc, nCount, lpFaceName)); 743 ret = O32_GetTextFace(hdc, nCount, lpFaceName); 744 if(ret > 0 && lpFaceName) { 745 dprintf(("GDI32: GetTextFaceA returned %s", lpFaceName)); 746 } 747 //We should return the length including null terminator (WGSS doesn't) 748 if(!lpFaceName) ret++; 749 750 return ret; 751 } 752 //****************************************************************************** 753 //****************************************************************************** 754 int WIN32API GetTextFaceW( HDC hdc, int nCount, LPWSTR lpFaceName) 755 { 756 char *astring = NULL; 757 int lenA = GetTextFaceA( hdc, 0, NULL ); 758 int rc; 759 874 760 astring = ( char * )malloc( lenA ); 875 if( astring )761 if( astring == NULL ) //@@VP:2003-11-05 was 'if ( astring )' 876 762 return 0; 877 763 … … 880 766 if( rc ) 881 767 { 882 if( arg3)768 if( lpFaceName ) 883 769 { 884 AsciiToUnicodeN(astring, arg3, arg2);885 rc = lstrlenW( arg3);770 AsciiToUnicodeN(astring, lpFaceName, nCount); 771 rc = lstrlenW( lpFaceName ); 886 772 } 887 773 else … … 911 797 return 0; 912 798 } 913 //****************************************************************************** 914 //****************************************************************************** 799 /***************************************************************************** 800 * Name : DWORD GetCharacterPlacementA 801 * Purpose : The GetCharacterPlacementA function retrieves information about 802 * a character string, such as character widths, caret positioning, 803 * ordering within the string, and glyph rendering. The type of 804 * information returned depends on the dwFlags parameter and is 805 * based on the currently selected font in the given display context. 806 * The function copies the information to the specified GCP_RESULTSA 807 * structure or to one or more arrays specified by the structure. 808 * Parameters: HDC hdc handle to device context 809 * LPCSTR lpString pointer to string 810 * int nCount number of characters in string 811 * int nMaxExtent maximum extent for displayed string 812 * LPGCP_RESULTSA *lpResults pointer to buffer for placement result 813 * DWORD dwFlags placement flags 814 * Variables : 815 * Result : 816 * Remark : 817 * Status : UNTESTED STUB 818 * 819 * Author : Patrick Haller [Mon, 1998/06/15 08:00] 820 *****************************************************************************/ 821 822 DWORD WIN32API GetCharacterPlacementA(HDC hdc, 823 LPCSTR lpString, 824 int nCount, 825 int nMaxExtent, 826 GCP_RESULTSA * lpResults, 827 DWORD dwFlags) 828 { 829 dprintf(("GDI32: GetCharacterPlacementA(%08xh,%s,%08xh,%08xh,%08xh,%08xh) not implemented.\n", 830 hdc, 831 lpString, 832 nCount, 833 nMaxExtent, 834 lpResults, 835 dwFlags)); 836 837 return (0); 838 } 839 840 /***************************************************************************** 841 * Name : DWORD GetCharacterPlacementW 842 * Purpose : The GetCharacterPlacementW function retrieves information about 843 * a character string, such as character widths, caret positioning, 844 * ordering within the string, and glyph rendering. The type of 845 * information returned depends on the dwFlags parameter and is 846 * based on the currently selected font in the given display context. 847 * The function copies the information to the specified GCP_RESULTSW 848 * structure or to one or more arrays specified by the structure. 849 * Parameters: HDC hdc handle to device context 850 * LPCSTR lpString pointer to string 851 * int nCount number of characters in string 852 * int nMaxExtent maximum extent for displayed string 853 * GCP_RESULTSW *lpResults pointer to buffer for placement result 854 * DWORD dwFlags placement flags 855 * Variables : 856 * Result : 857 * Remark : 858 * Status : Partly working 859 * 860 * Author : Borrowed Rewind Code 861 *****************************************************************************/ 862 863 DWORD WIN32API GetCharacterPlacementW(HDC hdc, 864 LPCWSTR lpString, 865 int uCount, 866 int nMaxExtent, 867 GCP_RESULTSW *lpResults, 868 DWORD dwFlags) 869 { 870 return FT2Module.Ft2GetCharacterPlacementW(hdc, lpString, uCount, nMaxExtent, lpResults, dwFlags); 871 } 872 873 874 /*********************************************************************** 875 * FONT_mbtowc 876 * 877 * Returns a '\0' terminated Unicode translation of str using the 878 * charset of the currently selected font in hdc. If count is -1 then 879 * str is assumed to be '\0' terminated, otherwise it contains the 880 * number of bytes to convert. If plenW is non-NULL, on return it 881 * will point to the number of WCHARs (excluding the '\0') that have 882 * been written. If pCP is non-NULL, on return it will point to the 883 * codepage used in the conversion (NB, this may be CP_SYMBOL so watch 884 * out). The caller should free the returned LPWSTR from the process 885 * heap itself. 886 */ 887 LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP) 888 { 889 UINT cp = CP_ACP; 890 INT lenW, i; 891 LPWSTR strW; 892 CHARSETINFO csi; 893 int charset = GetTextCharset(hdc); 894 895 if( IsDBCSEnv() && ( charset == 0 )) 896 cp = CP_ACP; 897 else 898 /* Hmm, nicely designed api this one! */ 899 if(TranslateCharsetInfo((DWORD*)charset, &csi, TCI_SRCCHARSET)) 900 cp = csi.ciACP; 901 else { 902 switch(charset) { 903 case OEM_CHARSET: 904 cp = GetOEMCP(); 905 break; 906 case DEFAULT_CHARSET: 907 cp = GetACP(); 908 break; 909 910 case VISCII_CHARSET: 911 case TCVN_CHARSET: 912 case KOI8_CHARSET: 913 case ISO3_CHARSET: 914 case ISO4_CHARSET: 915 /* FIXME: These have no place here, but because x11drv 916 enumerates fonts with these (made up) charsets some apps 917 might use them and then the FIXME below would become 918 annoying. Now we could pick the intended codepage for 919 each of these, but since it's broken anyway we'll just 920 use CP_ACP and hope it'll go away... 921 */ 922 cp = CP_ACP; 923 break; 924 925 926 default: 927 dprintf(("Can't find codepage for charset %d\n", charset)); 928 break; 929 } 930 } 931 932 dprintf(("cp == %d\n", cp)); 933 934 if(count == -1) count = strlen(str); 935 if(cp != CP_SYMBOL) { 936 lenW = MultiByteToWideChar(cp, 0, str, count, NULL, 0); 937 strW = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, (lenW + 1) * sizeof(WCHAR)); 938 MultiByteToWideChar(cp, 0, str, count, strW, lenW); 939 } else { 940 lenW = count; 941 strW = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, (lenW + 1) * sizeof(WCHAR)); 942 for(i = 0; i < count; i++) strW[i] = (BYTE)str[i]; 943 } 944 strW[lenW] = '\0'; 945 dprintf(("mapped %s -> %ls\n", str, strW)); 946 if(plenW) *plenW = lenW; 947 if(pCP) *pCP = cp; 948 return strW; 949 } 950 951 /************************************************************************* 952 * GetGlyphIndicesA [GDI32.@] 953 */ 954 DWORD WINAPI GetGlyphIndicesA(HDC hdc, LPCSTR lpstr, INT count, 955 LPWORD pgi, DWORD flags) 956 { 957 DWORD ret; 958 WCHAR *lpstrW; 959 INT countW; 960 961 dprintf(("GDI32: GetGlyphIndicesA (%p, %s, %d, %p, 0x%lx)\n", 962 hdc, lpstr, count, pgi, flags)); 963 964 lpstrW = FONT_mbtowc(hdc, lpstr, count, &countW, NULL); 965 ret = GetGlyphIndicesW(hdc, lpstrW, countW, pgi, flags); 966 HeapFree(GetProcessHeap(), 0, lpstrW); 967 968 return ret; 969 } 970 971 /************************************************************************* 972 * GetGlyphIndicesW [GDI32.@] 973 */ 974 DWORD WINAPI GetGlyphIndicesW(HDC hdc, LPCWSTR lpstr, INT count, 975 LPWORD pgi, DWORD flags) 976 { 977 DWORD ret; 978 979 dprintf(("GDI32: GetGlyphIndicesW (%ls, %d, %p, 0x%lx)", 980 lpstr, count, pgi, flags)); 981 982 if(!hdc) return GDI_ERROR; 983 984 ret = FT2Module.Ft2GetGlyphIndices(hdc, lpstr, count , pgi, flags); 985 if(ret != GDI_ERROR) { 986 for(int i=0;i<ret;i++) { 987 dprintf(("GetGlyphIndices: %c (%x)-> %d", lpstr[i], lpstr[i], pgi[i])); 988 } 989 } 990 return ret; 991 } 992 993 /*********************************************************************** 994 * GetGlyphOutlineA (GDI32.@) 995 */ 996 DWORD WINAPI GetGlyphOutlineA( HDC hdc, UINT uChar, UINT fuFormat, 997 LPGLYPHMETRICS lpgm, DWORD cbBuffer, 998 LPVOID lpBuffer, const MAT2 *lpmat2 ) 999 { 1000 LPWSTR p = NULL; 1001 DWORD ret; 1002 UINT c; 1003 1004 if ((fuFormat & GGO_GLYPH_INDEX) == 0) 1005 { 1006 p = FONT_mbtowc(hdc, (char*)&uChar, 1, NULL, NULL); 1007 if (p) 1008 { 1009 c = p[0]; 1010 } 1011 else 1012 { 1013 SetLastError(ERROR_NOT_ENOUGH_MEMORY); 1014 return GDI_ERROR; 1015 } 1016 } 1017 else 1018 { 1019 c = uChar; 1020 } 1021 1022 ret = GetGlyphOutlineW (hdc, c, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2); 1023 1024 if (p != NULL) 1025 { 1026 HeapFree (GetProcessHeap(), 0, p); 1027 } 1028 1029 return ret; 1030 } 1031 1032 /*********************************************************************** 1033 * GetGlyphOutlineW (GDI32.@) 1034 */ 1035 DWORD WINAPI GetGlyphOutlineW( HDC hdc, UINT uChar, UINT fuFormat, 1036 LPGLYPHMETRICS lpgm, DWORD cbBuffer, 1037 LPVOID lpBuffer, const MAT2 *lpmat2 ) 1038 { 1039 pDCData pHps = (pDCData)OSLibGpiQueryDCData(hdc); 1040 1041 dprintf(("GDI32: GetGlyphOutlineW(%p, %04x, %04x, %p, %ld, %p, %p)\n", 1042 pHps, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 )); 1043 1044 if (!hdc || !pHps) 1045 { 1046 SetLastError(ERROR_INVALID_PARAMETER); 1047 return GDI_ERROR; 1048 } 1049 1050 return FT2Module.Ft2GetGlyphOutline(pHps->hps, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2); 1051 } 1052 //****************************************************************************** 1053 //****************************************************************************** 1054 DWORD WIN32API GetKerningPairsA( HDC hdc, DWORD nNumPairs, LPKERNINGPAIR lpkrnpair) 1055 { 1056 return O32_GetKerningPairs(hdc, nNumPairs, lpkrnpair); 1057 } 1058 //****************************************************************************** 1059 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.