diff options
Diffstat (limited to 'win/tkWinFont.c')
-rw-r--r-- | win/tkWinFont.c | 57 |
1 files changed, 20 insertions, 37 deletions
diff --git a/win/tkWinFont.c b/win/tkWinFont.c index ad7738f..948ca10 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -26,9 +26,9 @@ * Under Windows, a "font family" is uniquely identified by its face name. */ -#define FONTMAP_SHIFT 10 +#define FONTMAP_SHIFT 12 -#define FONTMAP_PAGES (1 << (sizeof(Tcl_UniChar)*8 - FONTMAP_SHIFT)) +#define FONTMAP_PAGES (1 << (21 - FONTMAP_SHIFT)) #define FONTMAP_BITSPERPAGE (1 << FONTMAP_SHIFT) typedef struct FontFamily { @@ -50,11 +50,11 @@ typedef struct FontFamily { int isSymbolFont; /* Non-zero if this is a symbol font. */ int isWideFont; /* 1 if this is a double-byte font, 0 * otherwise. */ - BOOL (WINAPI *textOutProc)(HDC hdc, int x, int y, TCHAR *str, int len); + BOOL (WINAPI *textOutProc)(HDC hdc, int x, int y, WCHAR *str, int len); /* The procedure to use to draw text after it * has been converted from UTF-8 to the * encoding of this font. */ - BOOL (WINAPI *getTextExtentPoint32Proc)(HDC, TCHAR *, int, LPSIZE); + BOOL (WINAPI *getTextExtentPoint32Proc)(HDC, WCHAR *, int, LPSIZE); /* The procedure to use to measure text after * it has been converted from UTF-8 to the * encoding of this font. */ @@ -446,7 +446,7 @@ TkWinSetupSystemFonts( { LOGFONT lfFixed = { 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, - 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, TEXT("") + 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"" }; long pointSize, dpi; HDC hdc = GetDC(NULL); @@ -858,7 +858,7 @@ Tk_MeasureChars( (int) (p - start), &runString); size.cx = 0; familyPtr->getTextExtentPoint32Proc(hdc, - (TCHAR *)Tcl_DStringValue(&runString), + (WCHAR *)Tcl_DStringValue(&runString), Tcl_DStringLength(&runString) >> familyPtr->isWideFont, &size); Tcl_DStringFree(&runString); @@ -885,7 +885,7 @@ Tk_MeasureChars( Tcl_UtfToExternalDString(familyPtr->encoding, start, (int) (p - start), &runString); size.cx = 0; - familyPtr->getTextExtentPoint32Proc(hdc, (TCHAR *) Tcl_DStringValue(&runString), + familyPtr->getTextExtentPoint32Proc(hdc, (WCHAR *) Tcl_DStringValue(&runString), Tcl_DStringLength(&runString) >> familyPtr->isWideFont, &size); Tcl_DStringFree(&runString); @@ -919,7 +919,7 @@ Tk_MeasureChars( Tcl_DStringAppend(&runString,buf,dstWrote); size.cx = 0; familyPtr->getTextExtentPoint32Proc(hdc, - (TCHAR *) Tcl_DStringValue(&runString), + (WCHAR *) Tcl_DStringValue(&runString), Tcl_DStringLength(&runString) >> familyPtr->isWideFont, &size); if ((curX+size.cx) > maxLength) { @@ -1469,10 +1469,10 @@ MultiFontTextOut( Tcl_UtfToExternalDString(familyPtr->encoding, source, (int) (p - source), &runString); familyPtr->textOutProc(hdc, x-(tm.tmOverhang/2), y, - (TCHAR *)Tcl_DStringValue(&runString), + (WCHAR *)Tcl_DStringValue(&runString), Tcl_DStringLength(&runString)>>familyPtr->isWideFont); familyPtr->getTextExtentPoint32Proc(hdc, - (TCHAR *)Tcl_DStringValue(&runString), + (WCHAR *)Tcl_DStringValue(&runString), Tcl_DStringLength(&runString) >> familyPtr->isWideFont, &size); x += size.cx; @@ -1490,7 +1490,7 @@ MultiFontTextOut( Tcl_UtfToExternalDString(familyPtr->encoding, source, (int) (p - source), &runString); familyPtr->textOutProc(hdc, x-(tm.tmOverhang/2), y, - (TCHAR *)Tcl_DStringValue(&runString), + (WCHAR *)Tcl_DStringValue(&runString), Tcl_DStringLength(&runString) >> familyPtr->isWideFont); Tcl_DStringFree(&runString); } @@ -1565,7 +1565,7 @@ InitFont( Tcl_Encoding encoding; Tcl_DString faceString; TkFontAttributes *faPtr; - TCHAR buf[LF_FACESIZE]; + WCHAR buf[LF_FACESIZE]; window = Tk_WindowId(tkwin); hwnd = (window == None) ? NULL : TkWinGetHWND(window); @@ -1761,7 +1761,7 @@ AllocFontFamily( FontFamily *familyPtr; Tcl_DString faceString; Tcl_Encoding encoding; - TCHAR buf[LF_FACESIZE]; + WCHAR buf[LF_FACESIZE]; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); @@ -1825,15 +1825,15 @@ AllocFontFamily( if (encoding == NULL) { encoding = TkWinGetUnicodeEncoding(); familyPtr->textOutProc = - (BOOL (WINAPI *)(HDC, int, int, TCHAR *, int)) TextOutW; + (BOOL (WINAPI *)(HDC, int, int, WCHAR *, int)) TextOutW; familyPtr->getTextExtentPoint32Proc = - (BOOL (WINAPI *)(HDC, TCHAR *, int, LPSIZE)) GetTextExtentPoint32W; + (BOOL (WINAPI *)(HDC, WCHAR *, int, LPSIZE)) GetTextExtentPoint32W; familyPtr->isWideFont = 1; } else { familyPtr->textOutProc = - (BOOL (WINAPI *)(HDC, int, int, TCHAR *, int)) TextOutA; + (BOOL (WINAPI *)(HDC, int, int, WCHAR *, int)) TextOutA; familyPtr->getTextExtentPoint32Proc = - (BOOL (WINAPI *)(HDC, TCHAR *, int, LPSIZE)) GetTextExtentPoint32A; + (BOOL (WINAPI *)(HDC, WCHAR *, int, LPSIZE)) GetTextExtentPoint32A; familyPtr->isWideFont = 0; } @@ -1943,8 +1943,7 @@ FindSubFontForChar( SubFont *subFontPtr; Tcl_DString ds; - - if ((ch < BASE_CHARS) || (ch >= 0x10000)) { + if (ch < BASE_CHARS) { return &fontPtr->subFontArray[0]; } @@ -2495,7 +2494,7 @@ GetScreenFont( lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; Tcl_UtfToExternalDString(systemEncoding, faceName, -1, &ds); - _tcsncpy(lf.lfFaceName, (TCHAR *)Tcl_DStringValue(&ds), LF_FACESIZE-1); + wcsncpy(lf.lfFaceName, (WCHAR *)Tcl_DStringValue(&ds), LF_FACESIZE-1); Tcl_DStringFree(&ds); lf.lfFaceName[LF_FACESIZE-1] = 0; hFont = CreateFontIndirect(&lf); @@ -2529,22 +2528,6 @@ FamilyExists( int result; Tcl_DString faceString; - /* - * Just immediately rule out the following fonts, because they look so - * ugly on windows. The caller's fallback mechanism will cause the - * corresponding appropriate TrueType fonts to be selected. - */ - - if (strcasecmp(faceName, "Courier") == 0) { - return 0; - } - if (strcasecmp(faceName, "Times") == 0) { - return 0; - } - if (strcasecmp(faceName, "Helvetica") == 0) { - return 0; - } - Tcl_UtfToExternalDString(systemEncoding, faceName, -1, &faceString); /* @@ -2554,7 +2537,7 @@ FamilyExists( * non-zero value. */ - result = EnumFontFamilies(hdc, (TCHAR*) Tcl_DStringValue(&faceString), + result = EnumFontFamilies(hdc, (WCHAR*) Tcl_DStringValue(&faceString), (FONTENUMPROC) WinFontExistProc, 0); Tcl_DStringFree(&faceString); return (result == 0); |