Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

misc.c File Reference

#include "precomp.h"

Go to the source code of this file.

Classes

struct  _FONTENUMDC

Defines

#define FONT_BUFFER_SIZE   12
#define FE_ABANDONFONT   1
#define FE_FONTOK   2
#define NOT_CREATED_NOR_FOUND   -1
#define CREATED_BUT_NOT_FOUND   -2

Typedefs

typedef _FONTENUMDC FONTENUMDC
typedef _FONTENUMDCPFONTENUMDC

Functions

NTSTATUS GetMouseButtons (PULONG NumButtons)
VOID InitializeMouseButtons (VOID)
PFACENODE AddFaceNode (PFACENODE *ppStart, LPWSTR pwsz)
VOID InitializeFonts (VOID)
int CALLBACK FontEnum (LPENUMLOGFONTW lpLogFont, LPNEWTEXTMETRICW lpTextMetric, int nFontType, LPARAM lParam)
BOOL DoFontEnum (HDC hDC, LPWSTR pwszFace, SHORT TTPointSize)
NTSTATUS EnumerateFonts (DWORD Flags)
int FindCreateFont (DWORD Family, LPWSTR pwszFace, COORD Size, LONG Weight, UINT CodePage)
NTSTATUS FindTextBufferFontInfo (IN PSCREEN_INFORMATION ScreenInfo, IN UINT CodePage, OUT PTEXT_BUFFER_FONT_INFO TextFontInfo)
NTSTATUS StoreTextBufferFontInfo (IN PSCREEN_INFORMATION ScreenInfo, IN ULONG FontIndex, IN COORD FontSize, IN BYTE FontFamily, IN LONG FontWeight, IN LPWSTR FaceName, IN UINT CodePage)
NTSTATUS RemoveTextBufferFontInfo (IN PSCREEN_INFORMATION ScreenInfo)
NTSTATUS GetNumFonts (OUT PULONG NumFonts)
NTSTATUS GetAvailableFonts (IN PSCREEN_INFORMATION ScreenInfo, IN BOOLEAN MaximumWindow, OUT PVOID Buffer, IN OUT PULONG NumFonts)
NTSTATUS GetFontSize (IN DWORD FontIndex, OUT PCOORD FontSize)
NTSTATUS GetCurrentFont (IN PSCREEN_INFORMATION ScreenInfo, IN BOOLEAN MaximumWindow, OUT PULONG FontIndex, OUT PCOORD FontSize)
NTSTATUS SetScreenBufferFont (IN PSCREEN_INFORMATION ScreenInfo, IN ULONG FontIndex, IN UINT CodePage)
NTSTATUS SetFont (IN OUT PSCREEN_INFORMATION ScreenInfo)
int ConvertToOem (IN UINT Codepage, IN LPWSTR Source, IN int SourceLength, OUT LPSTR Target, IN int TargetLength)
int ConvertInputToUnicode (IN UINT Codepage, IN LPSTR Source, IN int SourceLength, OUT LPWSTR Target, IN int TargetLength)
int ConvertOutputToUnicode (IN UINT Codepage, IN LPSTR Source, IN int SourceLength, OUT LPWSTR Target, IN int TargetLength)
WCHAR CharToWcharGlyph (IN UINT Codepage, IN char Ch)
WCHAR CharToWchar (IN UINT Codepage, IN char Ch)
char WcharToChar (IN UINT Codepage, IN WCHAR Wchar)
int ConvertOutputToOem (IN UINT Codepage, IN LPWSTR Source, IN int SourceLength, OUT LPSTR Target, IN int TargetLength)
NTSTATUS RealUnicodeToFalseUnicode (IN OUT LPWSTR Source, IN int SourceLength, IN UINT Codepage)
NTSTATUS FalseUnicodeToRealUnicode (IN OUT LPWSTR Source, IN int SourceLength, IN UINT Codepage)
BOOL InitializeCustomCP ()

Variables

ULONG NumberOfMouseButtons
PFONT_INFO FontInfo
ULONG FontInfoLength
ULONG NumberOfFonts
WCHAR DefaultFaceName [LF_FACESIZE]
COORD DefaultFontSize
BYTE DefaultFontFamily
ULONG DefaultFontIndex = 0
CPTABLEINFO GlyphCP
USHORT GlyphTable [256]
PFACENODE gpFaceNames


Define Documentation

#define CREATED_BUT_NOT_FOUND   -2
 

Referenced by FindCreateFont().

#define FE_ABANDONFONT   1
 

Definition at line 56 of file w32/ntcon/server/misc.c.

#define FE_FONTOK   2
 

Definition at line 57 of file w32/ntcon/server/misc.c.

Referenced by DoFontEnum(), and FontEnum().

#define FONT_BUFFER_SIZE   12
 

Definition at line 54 of file w32/ntcon/server/misc.c.

#define NOT_CREATED_NOR_FOUND   -1
 

Referenced by FindCreateFont().


Typedef Documentation

typedef struct _FONTENUMDC FONTENUMDC
 

typedef struct _FONTENUMDC * PFONTENUMDC
 

Referenced by FontEnum().


Function Documentation

PFACENODE AddFaceNode PFACENODE ppStart,
LPWSTR  pwsz
 

Definition at line 80 of file w32/ntcon/server/misc.c.

References tagFACENODE::awch, ConsoleHeapAlloc, tagFACENODE::dwFlag, FONT_TAG, MAKE_TAG, NULL, and tagFACENODE::pNext.

Referenced by EnumerateFonts(), and FontEnum().

00080 { 00081 PFACENODE pNew; 00082 PFACENODE *ppTmp; 00083 int cb; 00084 00085 /* 00086 * Is it already here? 00087 */ 00088 for (ppTmp = ppStart; *ppTmp; ppTmp = &((*ppTmp)->pNext)) { 00089 if (wcscmp(((*ppTmp)->awch), pwsz) == 0) { 00090 // already there ! 00091 return *ppTmp; 00092 } 00093 } 00094 00095 cb = (wcslen(pwsz) + 1) * sizeof(WCHAR); 00096 pNew = (PFACENODE)ConsoleHeapAlloc(MAKE_TAG( FONT_TAG ),sizeof(FACENODE) + cb); 00097 if (pNew == NULL) { 00098 return NULL; 00099 } 00100 00101 pNew->pNext = NULL; 00102 pNew->dwFlag = 0; 00103 wcscpy(pNew->awch, pwsz); 00104 *ppTmp = pNew; 00105 return pNew; 00106 }

WCHAR CharToWchar IN UINT  Codepage,
IN char  Ch
 

Definition at line 1469 of file w32/ntcon/server/misc.c.

References DBGCHARS, NULL, OEMCP, and RtlOemToUnicodeN().

Referenced by GetChar(), SB_TranslateOutputToUnicode(), SrvScrollConsoleScreenBuffer(), and TranslateInputToUnicode().

01473 { 01474 WCHAR wch; 01475 if (Codepage == OEMCP) { 01476 RtlOemToUnicodeN(&wch, sizeof(wch), NULL, &Ch, sizeof(Ch)); 01477 } else { 01478 MultiByteToWideChar(Codepage, 0, &Ch, 1, &wch, 1); 01479 } 01480 #ifdef DEBUG_PRINT 01481 if (Ch > 0x7F) { 01482 DBGCHARS(("CharToWchar %d 0x%02x -> 0x%04x\n",Codepage,(UCHAR)Ch,wch)); 01483 } 01484 #endif 01485 return wch; 01486 }

WCHAR CharToWcharGlyph IN UINT  Codepage,
IN char  Ch
 

Definition at line 1443 of file w32/ntcon/server/misc.c.

References DBGCHARS, GlyphCP, NULL, OEMCP, and RtlCustomCPToUnicodeN().

01447 { 01448 WCHAR wch; 01449 if (Codepage == OEMCP) { 01450 RtlCustomCPToUnicodeN(&GlyphCP, &wch, sizeof(wch), NULL, &Ch, sizeof(Ch)); 01451 } else { 01452 MultiByteToWideChar(Codepage, MB_USEGLYPHCHARS, &Ch, 1, &wch, 1); 01453 } 01454 #ifdef DEBUG_PRINT 01455 if (Ch > 0x7F) { 01456 DBGCHARS(("CharToWcharGlyph %d 0x%02x -> 0x%04x\n",Codepage,(UCHAR)Ch,wch)); 01457 } 01458 #endif 01459 return wch; 01460 }

int ConvertInputToUnicode IN UINT  Codepage,
IN LPSTR  Source,
IN int  SourceLength,
OUT LPWSTR  Target,
IN int  TargetLength
 

Definition at line 1345 of file w32/ntcon/server/misc.c.

References DBGCHARS, NT_SUCCESS, NTSTATUS(), OEMCP, RtlOemToUnicodeN(), and Status.

Referenced by AddExeAliasList(), FindExe(), FindExeCommandHistory(), SrvAddConsoleAlias(), SrvGetConsoleAlias(), and SrvSetConsoleTitle().

01355 { 01356 DBGCHARS(("ConvertInputToUnicode %d->U %.*s\n", Codepage, 01357 SourceLength > 10 ? 10 : SourceLength, Source)); 01358 if (Codepage == OEMCP) { 01359 ULONG Length; 01360 NTSTATUS Status; 01361 01362 Status = RtlOemToUnicodeN(Target, 01363 TargetLength * sizeof(WCHAR), 01364 &Length, 01365 Source, 01366 SourceLength 01367 ); 01368 if (!NT_SUCCESS(Status)) { 01369 return 0; 01370 } else { 01371 return Length / sizeof(WCHAR); 01372 } 01373 } else { 01374 return MultiByteToWideChar(Codepage, 01375 0, 01376 Source, 01377 SourceLength, 01378 Target, 01379 TargetLength); 01380 } 01381 }

int ConvertOutputToOem IN UINT  Codepage,
IN LPWSTR  Source,
IN int  SourceLength,
OUT LPSTR  Target,
IN int  TargetLength
 

Definition at line 1508 of file w32/ntcon/server/misc.c.

References ASSERT, CHAR, ConsoleHeapAlloc, ConsoleHeapFree, DBGCHARS, MAKE_TAG, NT_SUCCESS, NTSTATUS(), NULL, OEMCP, RtlUnicodeToOemN(), STACK_BUFFER_SIZE, Status, and TMP_TAG.

Referenced by ReadOutputString(), and TranslateOutputToOem().

01521 { 01522 if (Codepage == OEMCP) { 01523 NTSTATUS Status; 01524 ULONG Length; 01525 // Can do this in place 01526 Status = RtlUnicodeToOemN(Target, 01527 TargetLength, 01528 &Length, 01529 Source, 01530 SourceLength * sizeof(WCHAR) 01531 ); 01532 if (NT_SUCCESS(Status)) { 01533 return Length; 01534 } else { 01535 return 0; 01536 } 01537 } else { 01538 ASSERT (Source != (LPWSTR)Target); 01539 #ifdef SOURCE_EQ_TARGET 01540 LPSTR pszDestTmp; 01541 CHAR StackBuffer[STACK_BUFFER_SIZE]; 01542 01543 DBGCHARS(("ConvertOutputToOem U->%d %.*ls\n", Codepage, 01544 SourceLength > 10 ? 10 : SourceLength, Source)); 01545 01546 if (TargetLength > STACK_BUFFER_SIZE) { 01547 pszDestTmp = (LPSTR)ConsoleHeapAlloc(MAKE_TAG( TMP_TAG ),TargetLength); 01548 if (pszDestTmp == NULL) { 01549 return 0; 01550 } 01551 } else { 01552 pszDestTmp = StackBuffer; 01553 } 01554 TargetLength = WideCharToMultiByte(Codepage, 0, 01555 Source, SourceLength, 01556 pszDestTmp, TargetLength, NULL, NULL); 01557 01558 RtlCopyMemory(Target, pszDestTmp, TargetLength); 01559 if (pszDestTmp != StackBuffer) { 01560 ConsoleHeapFree(pszDestTmp); 01561 } 01562 return TargetLength; 01563 #else 01564 DBGCHARS(("ConvertOutputToOem U->%d %.*ls\n", Codepage, 01565 SourceLength > 10 ? 10 : SourceLength, Source)); 01566 return WideCharToMultiByte(Codepage, 0, 01567 Source, SourceLength, Target, TargetLength, NULL, NULL); 01568 #endif 01569 } 01570 }

int ConvertOutputToUnicode IN UINT  Codepage,
IN LPSTR  Source,
IN int  SourceLength,
OUT LPWSTR  Target,
IN int  TargetLength
 

Definition at line 1384 of file w32/ntcon/server/misc.c.

References CHAR, ConsoleHeapAlloc, ConsoleHeapFree, DBGCHARS, GlyphCP, MAKE_TAG, NT_SUCCESS, NTSTATUS(), NULL, OEMCP, RtlCustomCPToUnicodeN(), STACK_BUFFER_SIZE, Status, and TMP_TAG.

Referenced by WWSB_DoSrvWriteConsole(), WWSB_FillOutput(), WWSB_WriteChars(), WWSB_WriteOutputString(), and WWSB_WriteRectToScreenBuffer().

01396 { 01397 NTSTATUS Status; 01398 ULONG Length; 01399 CHAR StackBuffer[STACK_BUFFER_SIZE]; 01400 LPSTR pszT; 01401 01402 DBGCHARS(("ConvertOutputToUnicode %d->U %.*s\n", Codepage, 01403 SourceLength > 10 ? 10 : SourceLength, Source)); 01404 if (Codepage == OEMCP) { 01405 Status = RtlCustomCPToUnicodeN(&GlyphCP, 01406 Target, 01407 TargetLength * sizeof(WCHAR), 01408 &Length, 01409 Source, 01410 SourceLength 01411 ); 01412 if (!NT_SUCCESS(Status)) { 01413 return 0; 01414 } else { 01415 return Length / sizeof(WCHAR); 01416 } 01417 } 01418 01419 if (TargetLength > STACK_BUFFER_SIZE) { 01420 pszT = (LPSTR)ConsoleHeapAlloc(MAKE_TAG( TMP_TAG ),SourceLength); 01421 if (pszT == NULL) { 01422 return 0; 01423 } 01424 } else { 01425 pszT = StackBuffer; 01426 } 01427 RtlCopyMemory(pszT, Source, SourceLength); 01428 Length = MultiByteToWideChar(Codepage, MB_USEGLYPHCHARS, 01429 pszT, SourceLength, Target, TargetLength); 01430 if (pszT != StackBuffer) { 01431 ConsoleHeapFree(pszT); 01432 } 01433 return Length; 01434 }

int ConvertToOem IN UINT  Codepage,
IN LPWSTR  Source,
IN int  SourceLength,
OUT LPSTR  Target,
IN int  TargetLength
 

Definition at line 1307 of file w32/ntcon/server/misc.c.

References DBGCHARS, NT_SUCCESS, NTSTATUS(), NULL, OEMCP, RtlUnicodeToOemN(), and Status.

Referenced by CookedRead(), DoStringPaste(), ProcessCommandListInput(), RawReadWaitRoutine(), ReadChars(), SrvGetConsoleAlias(), SrvGetConsoleAliases(), SrvGetConsoleAliasExes(), SrvGetConsoleCommandHistory(), and SrvGetConsoleTitle().

01314 { 01315 DBGCHARS(("ConvertToOem U->%d %.*ls\n", Codepage, 01316 SourceLength > 10 ? 10 : SourceLength, Source)); 01317 if (Codepage == OEMCP) { 01318 ULONG Length; 01319 NTSTATUS Status; 01320 01321 Status = RtlUnicodeToOemN(Target, 01322 TargetLength, 01323 &Length, 01324 Source, 01325 SourceLength * sizeof(WCHAR) 01326 ); 01327 if (!NT_SUCCESS(Status)) { 01328 return 0; 01329 } else { 01330 return Length; 01331 } 01332 } else { 01333 return WideCharToMultiByte(Codepage, 01334 0, 01335 Source, 01336 SourceLength, 01337 Target, 01338 TargetLength, 01339 NULL, 01340 NULL); 01341 } 01342 }

BOOL DoFontEnum HDC  hDC,
LPWSTR  pwszFace,
SHORT  TTPointSize
 

Definition at line 478 of file w32/ntcon/server/misc.c.

References _FONTENUMDC::bFindFaces, BOOL, DBGFONTS, FALSE, FE_FONTOK, FontEnum(), _FONTENUMDC::hDC, L, NULL, TRUE, _FONTENUMDC::TTPointSize, and _FONTENUMDC::ulFE.

Referenced by EnumerateFonts(), and FindCreateFont().

00482 { 00483 ULONG ulFE = 0; 00484 BOOL bDeleteDC = FALSE; 00485 BOOL bFindFaces = (pwszFace == NULL); 00486 FONTENUMDC fed; 00487 LOGFONTW LogFont; 00488 00489 DBGFONTS(("DoFontEnum \"%ls\"\n", pwszFace)); 00490 if (hDC == NULL) { 00491 hDC = CreateDCW(L"DISPLAY",NULL,NULL,NULL); 00492 bDeleteDC = TRUE; 00493 } 00494 00495 fed.hDC = hDC; 00496 fed.bFindFaces = bFindFaces; 00497 fed.ulFE = 0; 00498 fed.TTPointSize = TTPointSize; 00499 RtlZeroMemory(&LogFont, sizeof(LOGFONT)); 00500 LogFont.lfCharSet = DEFAULT_CHARSET; 00501 if (pwszFace) 00502 wcscpy(LogFont.lfFaceName, pwszFace); 00503 /* 00504 * EnumFontFamiliesEx function enumerates one font in every face in every character set. 00505 */ 00506 EnumFontFamiliesExW(hDC, &LogFont, (FONTENUMPROC)FontEnum, (LPARAM)&fed, 0); 00507 if (bDeleteDC) { 00508 DeleteDC(hDC); 00509 } 00510 return (fed.ulFE & FE_FONTOK) != 0; 00511 }

NTSTATUS EnumerateFonts DWORD  Flags  ) 
 

Definition at line 515 of file w32/ntcon/server/misc.c.

References AddFaceNode(), ASSERT, tagFACENODE::awch, CONSOLE_IS_DBCS_ENABLED, ConsoleHeapAlloc, DBGFONTS, DefaultFaceName, DefaultFontFamily, DefaultFontIndex, DefaultFontSize, DoFontEnum(), tagFACENODE::dwFlag, DWORD, EF_DEFFACE, EF_ENUMERATED, EF_NEW, EF_OEMFONT, EF_OLD, EF_TTFONT, _FONT_INFO::Family, FONT_TAG, FontInfo, FontInfoLength, gpFaceNames, INITIAL_FONTS, L, MAKE_TAG, NULL, NumberOfFonts, tagFACENODE::pNext, SHORT, and _FONT_INFO::Size.

Referenced by ConsoleInputThread().

00517 { 00518 TEXTMETRIC tmi; 00519 HDC hDC; 00520 PFACENODE pFN; 00521 ULONG ulOldEnumFilter; 00522 DWORD FontIndex; 00523 DWORD dwFontType = 0; 00524 00525 DBGFONTS(("EnumerateFonts %lx\n", Flags)); 00526 00527 dwFontType = (EF_TTFONT|EF_OEMFONT|EF_DEFFACE) & Flags; 00528 00529 if (FontInfo == NULL) { 00530 // 00531 // allocate memory for the font array 00532 // 00533 NumberOfFonts = 0; 00534 00535 FontInfo = (PFONT_INFO)ConsoleHeapAlloc(MAKE_TAG( FONT_TAG ),sizeof(FONT_INFO) * INITIAL_FONTS); 00536 if (FontInfo == NULL) 00537 return STATUS_NO_MEMORY; 00538 FontInfoLength = INITIAL_FONTS; 00539 } 00540 00541 hDC = CreateDCW(L"DISPLAY",NULL,NULL,NULL); 00542 00543 // Before enumeration, turn off font enumeration filters. 00544 ulOldEnumFilter = SetFontEnumeration(0); 00545 // restore all the other flags 00546 SetFontEnumeration(ulOldEnumFilter & ~FE_FILTER_TRUETYPE); 00547 00548 if (Flags & EF_DEFFACE) { 00549 SelectObject(hDC,GetStockObject(OEM_FIXED_FONT)); 00550 00551 if (GetTextMetricsW(hDC, &tmi)) { 00552 DefaultFontSize.X = (SHORT)(tmi.tmMaxCharWidth); 00553 DefaultFontSize.Y = (SHORT)(tmi.tmHeight+tmi.tmExternalLeading); 00554 DefaultFontFamily = tmi.tmPitchAndFamily; 00555 #if defined(FE_SB) 00556 if (IS_ANY_DBCS_CHARSET(tmi.tmCharSet)) 00557 DefaultFontSize.X /= 2; 00558 #endif 00559 } 00560 GetTextFaceW(hDC, LF_FACESIZE, DefaultFaceName); 00561 #if defined(FE_SB) 00562 DBGFONTS(("Default (OEM) Font %ls (%d,%d) CharSet 0x%02X\n", DefaultFaceName, 00563 DefaultFontSize.X, DefaultFontSize.Y, 00564 tmi.tmCharSet)); 00565 #else 00566 DBGFONTS(("Default (OEM) Font %ls (%d,%d)\n", DefaultFaceName, 00567 DefaultFontSize.X, DefaultFontSize.Y)); 00568 #endif 00569 00570 // Make sure we are going to enumerate the OEM face. 00571 pFN = AddFaceNode(&gpFaceNames, DefaultFaceName); 00572 pFN->dwFlag |= EF_DEFFACE | EF_OEMFONT; 00573 } 00574 00575 // Use DoFontEnum to get all fonts from the system. Our FontEnum 00576 // proc puts just the ones we want into an array 00577 // 00578 for (pFN = gpFaceNames; pFN; pFN = pFN->pNext) { 00579 DBGFONTS(("\"%ls\" is %s%s%s%s%s%s\n", pFN->awch, 00580 pFN->dwFlag & EF_NEW ? "NEW " : " ", 00581 pFN->dwFlag & EF_OLD ? "OLD " : " ", 00582 pFN->dwFlag & EF_ENUMERATED ? "ENUMERATED " : " ", 00583 pFN->dwFlag & EF_OEMFONT ? "OEMFONT " : " ", 00584 pFN->dwFlag & EF_TTFONT ? "TTFONT " : " ", 00585 pFN->dwFlag & EF_DEFFACE ? "DEFFACE " : " ")); 00586 00587 if ((pFN->dwFlag & dwFontType) == 0) { 00588 // not the kind of face we want 00589 continue; 00590 } 00591 if (pFN->dwFlag & EF_ENUMERATED) { 00592 // we already enumerated this face 00593 continue; 00594 } 00595 00596 DoFontEnum(hDC, pFN->awch, DefaultFontSize.Y); 00597 pFN->dwFlag |= EF_ENUMERATED; 00598 } 00599 00600 00601 // After enumerating fonts, restore the font enumeration filter. 00602 SetFontEnumeration(ulOldEnumFilter); 00603 00604 DeleteDC(hDC); 00605 00606 // Make sure the default font is set correctly 00607 if (NumberOfFonts > 0 && DefaultFontSize.X == 0 && DefaultFontSize.Y == 0) { 00608 DefaultFontSize.X = FontInfo[0].Size.X; 00609 DefaultFontSize.Y = FontInfo[0].Size.Y; 00610 DefaultFontFamily = FontInfo[0].Family; 00611 } 00612 00613 for (FontIndex = 0; FontIndex < NumberOfFonts; FontIndex++) { 00614 if (FontInfo[FontIndex].Size.X == DefaultFontSize.X && 00615 FontInfo[FontIndex].Size.Y == DefaultFontSize.Y && 00616 FontInfo[FontIndex].Family == DefaultFontFamily) { 00617 #if defined(FE_SB) 00618 if (CONSOLE_IS_DBCS_ENABLED() && 00619 !IS_ANY_DBCS_CHARSET(FontInfo[FontIndex].tmCharSet)) 00620 { 00621 continue ; 00622 } 00623 #endif 00624 break; 00625 } 00626 } 00627 ASSERT(FontIndex < NumberOfFonts); 00628 if (FontIndex < NumberOfFonts) { 00629 DefaultFontIndex = FontIndex; 00630 } else { 00631 DefaultFontIndex = 0; 00632 } 00633 DBGFONTS(("EnumerateFonts : DefaultFontIndex = %ld\n", DefaultFontIndex)); 00634 00635 return STATUS_SUCCESS; 00636 }

NTSTATUS FalseUnicodeToRealUnicode IN OUT LPWSTR  Source,
IN int  SourceLength,
IN UINT  Codepage
 

Definition at line 1676 of file w32/ntcon/server/misc.c.

References BOOL, CHAR, CONSOLE_IS_DBCS_ENABLED, ConsoleHeapAlloc, ConsoleHeapFree, DBGCHARS, FALSE, GlyphCP, MAKE_TAG, NT_SUCCESS, NTSTATUS(), NULL, OEMCP, RtlCustomCPToUnicodeN(), RtlUnicodeToMultiByteN(), STACK_BUFFER_SIZE, Status, TMP_TAG, TRUE, USACP, USHORT, and WINDOWSCP.

Referenced by ConvertToFullScreen(), DrawCommandListPopup(), ReadOutputString(), SB_TranslateOutputToOemUnicode(), SetScreenBufferFont(), and StoreSelection().

01689 { 01690 NTSTATUS Status; 01691 LPSTR Temp; 01692 ULONG TempLength; 01693 ULONG Length; 01694 CHAR StackBuffer[STACK_BUFFER_SIZE]; 01695 BOOL NormalChars; 01696 int i; 01697 01698 DBGCHARS(("UnicodeAnsiToUnicodeAnsi U->ACP:%d->U %.*ls\n", Codepage, 01699 SourceLength > 10 ? 10 : SourceLength, Source)); 01700 #if defined(FE_SB) 01701 if (OEMCP == WINDOWSCP && Codepage == WINDOWSCP) 01702 return STATUS_SUCCESS; 01703 if (SourceLength == 0 ) 01704 return STATUS_SUCCESS; 01705 #endif 01706 NormalChars = TRUE; 01707 /* 01708 * Test for characters < 0x20 or >= 0x7F. If none are found, we don't have 01709 * any conversion to do! 01710 */ 01711 for (i=0;i<SourceLength;i++) { 01712 if ((USHORT)(Source[i] - 0x20) > 0x5e) { 01713 NormalChars = FALSE; 01714 break; 01715 } 01716 } 01717 if (NormalChars) { 01718 return STATUS_SUCCESS; 01719 } 01720 01721 TempLength = SourceLength; 01722 if (TempLength > STACK_BUFFER_SIZE) { 01723 Temp = (LPSTR)ConsoleHeapAlloc(MAKE_TAG( TMP_TAG ),TempLength); 01724 if (Temp == NULL) { 01725 return STATUS_NO_MEMORY; 01726 } 01727 } else { 01728 Temp = StackBuffer; 01729 } 01730 if (CONSOLE_IS_DBCS_ENABLED()) { 01731 Status = WideCharToMultiByte(USACP, 01732 0, 01733 Source, 01734 SourceLength, 01735 Temp, 01736 TempLength, 01737 NULL, 01738 NULL); 01739 } else { 01740 Status = RtlUnicodeToMultiByteN(Temp, 01741 TempLength, 01742 &Length, 01743 Source, 01744 SourceLength * sizeof(WCHAR) 01745 ); 01746 } 01747 01748 if (!NT_SUCCESS(Status)) { 01749 if (TempLength > STACK_BUFFER_SIZE) { 01750 ConsoleHeapFree(Temp); 01751 } 01752 return Status; 01753 } 01754 if (Codepage == OEMCP) { 01755 Status = RtlCustomCPToUnicodeN(&GlyphCP, 01756 Source, 01757 SourceLength * sizeof(WCHAR), 01758 &Length, 01759 Temp, 01760 TempLength 01761 ); 01762 } else { 01763 Status = MultiByteToWideChar(Codepage, 01764 MB_USEGLYPHCHARS, 01765 Temp, 01766 TempLength*sizeof(WCHAR), 01767 Source, 01768 SourceLength); 01769 } 01770 #if defined(FE_SB) 01771 if (SourceLength > STACK_BUFFER_SIZE) { 01772 ConsoleHeapFree(Temp); 01773 } 01774 #else 01775 if (TempLength > STACK_BUFFER_SIZE) { 01776 ConsoleHeapFree(Temp); 01777 } 01778 #endif 01779 if (!NT_SUCCESS(Status)) { 01780 return Status; 01781 } else { 01782 return STATUS_SUCCESS; 01783 } 01784 }

int FindCreateFont DWORD  Family,
LPWSTR  pwszFace,
COORD  Size,
LONG  Weight,
UINT  CodePage
 

Definition at line 650 of file w32/ntcon/server/misc.c.

References BOOL, BYTE, CodePageToCharSet(), CONSOLE_IS_DBCS_ENABLED, CREATED_BUT_NOT_FOUND, DBGFONTS, DefaultFaceName, DefaultFontIndex, DefaultFontSize, DoFontEnum(), _FONT_INFO::Family, FontInfo, GetAltFaceName(), IsAvailableFarEastCodePage(), IsAvailableTTFont(), L, MakeAltRasterFont(), NOT_CREATED_NOR_FOUND, NULL, NumberOfFonts, _FONT_INFO::Size, Size, SIZE_EQUAL, _FONT_INFO::SizeWant, TM_IS_TT_FONT, and _FONT_INFO::Weight.

Referenced by DoCreateScreenBuffer(), PropertiesUpdate(), SetFont(), and SrvCreateConsoleScreenBuffer().

00656 { 00657 #define NOT_CREATED_NOR_FOUND -1 00658 #define CREATED_BUT_NOT_FOUND -2 00659 00660 int i; 00661 int FontIndex = NOT_CREATED_NOR_FOUND; 00662 int BestMatch = NOT_CREATED_NOR_FOUND; 00663 BOOL bFontOK; 00664 WCHAR AltFaceName[LF_FACESIZE]; 00665 COORD AltFontSize; 00666 BYTE AltFontFamily; 00667 ULONG AltFontIndex = 0; 00668 LPWSTR pwszAltFace = NULL; 00669 00670 BYTE CharSet = CodePageToCharSet(CodePage); 00671 00672 DBGFONTS(("FindCreateFont Family=%x %ls (%d,%d) %d %d %x\n", 00673 Family, pwszFace, Size.X, Size.Y, Weight, CodePage, CharSet)); 00674 00675 if (CONSOLE_IS_DBCS_ENABLED() && 00676 !IS_ANY_DBCS_CHARSET(CharSet)) 00677 { 00678 MakeAltRasterFont(CodePage, FontInfo[DefaultFontIndex].Size, 00679 &AltFontSize, &AltFontFamily, &AltFontIndex, AltFaceName); 00680 00681 if (pwszFace == NULL || *pwszFace == L'\0') { 00682 pwszFace = AltFaceName; 00683 } 00684 if (Size.Y == 0) { 00685 Size.X = AltFontSize.X; 00686 Size.Y = AltFontSize.Y; 00687 } 00688 } 00689 else { 00690 if (pwszFace == NULL || *pwszFace == L'\0') { 00691 pwszFace = DefaultFaceName; 00692 } 00693 if (Size.Y == 0) { 00694 Size.X = DefaultFontSize.X; 00695 Size.Y = DefaultFontSize.Y; 00696 } 00697 } 00698 00699 if (IsAvailableTTFont(pwszFace)) { 00700 pwszAltFace = GetAltFaceName(pwszFace); 00701 } 00702 else { 00703 pwszAltFace = pwszFace; 00704 } 00705 00706 /* 00707 * Try to find the exact font 00708 */ 00709 TryFindExactFont: 00710 for (i=0; i < (int)NumberOfFonts; i++) { 00711 /* 00712 * If looking for a particular Family, skip non-matches 00713 */ 00714 if ((Family != 0) && 00715 ((BYTE)Family != FontInfo[i].Family)) { 00716 continue; 00717 } 00718 00719 /* 00720 * Skip non-matching sizes 00721 */ 00722 if ((FontInfo[i].SizeWant.Y != Size.Y) && 00723 !SIZE_EQUAL(FontInfo[i].Size, Size)) { 00724 continue; 00725 } 00726 00727 /* 00728 * Skip non-matching weights 00729 */ 00730 if ((Weight != 0) && (Weight != FontInfo[i].Weight)) { 00731 continue; 00732 } 00733 #if defined(FE_SB) 00734 if (!TM_IS_TT_FONT(FontInfo[i].Family) && 00735 FontInfo[i].tmCharSet != CharSet) { 00736 continue; 00737 } 00738 #endif 00739 00740 /* 00741 * Size (and maybe Family) match. 00742 * If we don't care about the name, or if it matches, use this font. 00743 * Else if name doesn't match and it is a raster font, consider it. 00744 */ 00745 if ((pwszFace == NULL) || (pwszFace[0] == L'\0') || 00746 wcscmp(FontInfo[i].FaceName, pwszFace) == 0 || 00747 wcscmp(FontInfo[i].FaceName, pwszAltFace) == 0 00748 ) { 00749 FontIndex = i; 00750 goto FoundFont; 00751 } else if (!TM_IS_TT_FONT(FontInfo[i].Family)) { 00752 BestMatch = i; 00753 } 00754 } 00755 00756 /* 00757 * Didn't find the exact font, so try to create it 00758 */ 00759 if (FontIndex == NOT_CREATED_NOR_FOUND) { 00760 ULONG ulOldEnumFilter; 00761 ulOldEnumFilter = SetFontEnumeration(0); 00762 // restore all the other flags 00763 SetFontEnumeration(ulOldEnumFilter & ~FE_FILTER_TRUETYPE); 00764 if (Size.Y < 0) { 00765 Size.Y = -Size.Y; 00766 } 00767 bFontOK = DoFontEnum(NULL, pwszFace, Size.Y); 00768 SetFontEnumeration(ulOldEnumFilter); 00769 if (bFontOK) { 00770 DBGFONTS(("FindCreateFont created font!\n")); 00771 FontIndex = CREATED_BUT_NOT_FOUND; 00772 goto TryFindExactFont; 00773 } else { 00774 DBGFONTS(("FindCreateFont failed to create font!\n")); 00775 } 00776 } 00777 00778 /* 00779 * Failed to find exact match, but we have a close Raster Font 00780 * fit - only the name doesn't match. 00781 */ 00782 if (BestMatch >= 0) { 00783 FontIndex = BestMatch; 00784 goto FoundFont; 00785 } 00786 00787 /* 00788 * Failed to find exact match, even after enumeration, so now try 00789 * to find a font of same family and same size or bigger 00790 */ 00791 for (i=0; i < (int)NumberOfFonts; i++) { 00792 #if defined(FE_SB) 00793 if (CONSOLE_IS_DBCS_ENABLED()) { 00794 if ((Family != 0) && 00795 ((BYTE)Family != FontInfo[i].Family)) { 00796 continue; 00797 } 00798 00799 if (!TM_IS_TT_FONT(FontInfo[i].Family) && 00800 FontInfo[i].tmCharSet != CharSet) { 00801 continue; 00802 } 00803 } 00804 else { 00805 #endif 00806 if ((BYTE)Family != FontInfo[i].Family) { 00807 continue; 00808 } 00809 #if defined(FE_SB) 00810 } 00811 #endif 00812 00813 if (FontInfo[i].Size.Y >= Size.Y && 00814 FontInfo[i].Size.X >= Size.X) { 00815 // Same family, size >= desired. 00816 FontIndex = i; 00817 break; 00818 } 00819 } 00820 00821 if (FontIndex < 0) { 00822 DBGFONTS(("FindCreateFont defaults!\n")); 00823 #if defined(FE_SB) 00824 if (CONSOLE_IS_DBCS_ENABLED() && 00825 !IsAvailableFarEastCodePage(CodePage)) 00826 { 00827 FontIndex = AltFontIndex; 00828 } 00829 else 00830 #endif 00831 FontIndex = DefaultFontIndex; 00832 } 00833 00834 FoundFont: 00835 DBGFONTS(("FindCreateFont returns %x : %ls (%d,%d)\n", FontIndex, 00836 FontInfo[FontIndex].FaceName, 00837 FontInfo[FontIndex].Size.X, FontInfo[FontIndex].Size.Y)); 00838 return FontIndex; 00839 00840 #undef NOT_CREATED_NOR_FOUND 00841 #undef CREATED_BUT_NOT_FOUND 00842 }

NTSTATUS FindTextBufferFontInfo IN PSCREEN_INFORMATION  ScreenInfo,
IN UINT  CodePage,
OUT PTEXT_BUFFER_FONT_INFO  TextFontInfo
 

Definition at line 846 of file w32/ntcon/server/misc.c.

References _TEXT_BUFFER_FONT_INFO::FontCodePage, _TEXT_BUFFER_FONT_INFO::NextTextBufferFont, and NULL.

00854 : 00855 00856 This routine find a font information which correspond to code page value. 00857 00858 Arguments: 00859 00860 Return Value: 00861 00862 --*/ 00863 00864 { 00865 PTEXT_BUFFER_FONT_INFO CurrentFont; 00866 00867 CurrentFont = ScreenInfo->BufferInfo.TextInfo.ListOfTextBufferFont; 00868 00869 while (CurrentFont != NULL) { 00870 if (CurrentFont->FontCodePage == CodePage) { 00871 *TextFontInfo = *CurrentFont; 00872 return STATUS_SUCCESS; 00873 } 00874 CurrentFont = CurrentFont->NextTextBufferFont; 00875 } 00876 00877 return STATUS_UNSUCCESSFUL; 00878 }

int CALLBACK FontEnum LPENUMLOGFONTW  lpLogFont,
LPNEWTEXTMETRICW  lpTextMetric,
int  nFontType,
LPARAM  lParam
 

Definition at line 152 of file w32/ntcon/server/misc.c.

References AddFaceNode(), tagFACENODE::awch, _FONTENUMDC::bFindFaces, BOOL, BYTE, CONSOLE_IS_DBCS_ENABLED, ConsoleHeapReAlloc, DBGFONTS, DBGFONTS2, DefaultFontIndex, tagFACENODE::dwFlag, EF_OEMFONT, EF_TTFONT, _FONT_INFO::FaceName, FALSE, _FONT_INFO::Family, FE_FONTOK, FONT_INCREMENT, FONT_TAG, FontInfo, FontInfoLength, gpFaceNames, _FONTENUMDC::hDC, _FONT_INFO::hFont, IS_BOLD, IsAvailableTTFont(), IsAvailableTTFontCP(), L, MAKE_TAG, NULL, NumberOfFonts, PFONTENUMDC, SHORT, _FONT_INFO::Size, Size, SIZE_EQUAL, _FONT_INFO::SizeWant, TM_IS_TT_FONT, TRUE, _FONTENUMDC::TTPointSize, _FONTENUMDC::ulFE, and _FONT_INFO::Weight.

Referenced by DoFontEnum().

00166 { 00167 PFONTENUMDC pfed = (PFONTENUMDC)lParam; 00168 HDC hDC = pfed->hDC; 00169 BOOL bFindFaces = pfed->bFindFaces; 00170 HFONT hFont; 00171 TEXTMETRICW tmi; 00172 LONG nFont; 00173 LONG nFontNew; 00174 COORD SizeToShow; 00175 COORD SizeActual; 00176 COORD SizeWant; 00177 BYTE tmFamily; 00178 SIZE Size; 00179 LPWSTR pwszFace = lpLogFont->elfLogFont.lfFaceName; 00180 PFACENODE pFN; 00181 00182 DBGFONTS((" FontEnum \"%ls\" (%d,%d) weight 0x%lx(%d) -- %s\n", 00183 pwszFace, 00184 lpLogFont->elfLogFont.lfWidth, lpLogFont->elfLogFont.lfHeight, 00185 lpLogFont->elfLogFont.lfWeight, lpLogFont->elfLogFont.lfWeight, 00186 bFindFaces ? "Finding Faces" : "Creating Fonts")); 00187 00188 // 00189 // reject variable width and italic fonts, also tt fonts with neg ac 00190 // 00191 00192 if 00193 ( 00194 !(lpLogFont->elfLogFont.lfPitchAndFamily & FIXED_PITCH) || 00195 (lpLogFont->elfLogFont.lfItalic) || 00196 !(lpTextMetric->ntmFlags & NTM_NONNEGATIVE_AC) 00197 ) 00198 { 00199 if (!IsAvailableTTFont(pwszFace)) 00200 { 00201 DBGFONTS((" REJECT face (variable pitch, italic, or neg a&c)\n")); 00202 return bFindFaces ? TRUE : FALSE; // unsuitable font 00203 } 00204 } 00205 00206 if (nFontType == TRUETYPE_FONTTYPE) { 00207 lpLogFont->elfLogFont.lfHeight = pfed->TTPointSize; 00208 lpLogFont->elfLogFont.lfWidth = 0; 00209 lpLogFont->elfLogFont.lfWeight = FW_NORMAL; 00210 } 00211 00212 /* 00213 * reject TT fonts for whoom family is not modern, that is do not use 00214 * FF_DONTCARE // may be surprised unpleasantly 00215 * FF_DECORATIVE // likely to be symbol fonts 00216 * FF_SCRIPT // cursive, inappropriate for console 00217 * FF_SWISS OR FF_ROMAN // variable pitch 00218 */ 00219 00220 if ((nFontType == TRUETYPE_FONTTYPE) && 00221 ((lpLogFont->elfLogFont.lfPitchAndFamily & 0xf0) != FF_MODERN)) { 00222 DBGFONTS((" REJECT face (TT but not FF_MODERN)\n")); 00223 return bFindFaces ? TRUE : FALSE; // unsuitable font 00224 } 00225 00226 /* 00227 * reject non-TT fonts that aren't OEM 00228 */ 00229 if ((nFontType != TRUETYPE_FONTTYPE) && 00230 #if defined(FE_SB) 00231 (!CONSOLE_IS_DBCS_ENABLED() || 00232 !IS_ANY_DBCS_CHARSET(lpLogFont->elfLogFont.lfCharSet)) && 00233 #endif 00234 (lpLogFont->elfLogFont.lfCharSet != OEM_CHARSET)) { 00235 DBGFONTS((" REJECT face (not TT nor OEM)\n")); 00236 return bFindFaces ? TRUE : FALSE; // unsuitable font 00237 } 00238 00239 /* 00240 * reject non-TT fonts that are virtical font 00241 */ 00242 if ((nFontType != TRUETYPE_FONTTYPE) && 00243 (pwszFace[0] == L'@')) { 00244 DBGFONTS((" REJECT face (not TT and TATEGAKI)\n")); 00245 return bFindFaces ? TRUE : FALSE; // unsuitable font 00246 } 00247 00248 /* 00249 * reject non-TT fonts that aren't Terminal 00250 */ 00251 if (CONSOLE_IS_DBCS_ENABLED() && 00252 (nFontType != TRUETYPE_FONTTYPE) && 00253 (wcscmp(pwszFace, L"Terminal") != 0)) { 00254 DBGFONTS((" REJECT face (not TT nor Terminal)\n")); 00255 return bFindFaces ? TRUE : FALSE; // unsuitable font 00256 } 00257 00258 /* 00259 * reject Far East TT fonts that aren't Far East charset. 00260 */ 00261 if (IsAvailableTTFont(pwszFace) && 00262 !IS_ANY_DBCS_CHARSET(lpLogFont->elfLogFont.lfCharSet) && 00263 !IsAvailableTTFontCP(pwszFace,0) 00264 ) { 00265 DBGFONTS((" REJECT face (Far East TT and not Far East charset)\n")); 00266 return TRUE; // should be enumerate next charset. 00267 } 00268 00269 /* 00270 * Add or find the facename 00271 */ 00272 pFN = AddFaceNode(&gpFaceNames, pwszFace); 00273 if (pFN == NULL) { 00274 return FALSE; 00275 } 00276 00277 if (bFindFaces) { 00278 if (nFontType == TRUETYPE_FONTTYPE) { 00279 DBGFONTS(("NEW TT FACE %ls\n", pwszFace)); 00280 pFN->dwFlag |= EF_TTFONT; 00281 } else if (nFontType == RASTER_FONTTYPE) { 00282 DBGFONTS(("NEW OEM FACE %ls\n",pwszFace)); 00283 pFN->dwFlag |= EF_OEMFONT; 00284 } 00285 return 0; 00286 } 00287 00288 00289 if (IS_BOLD(lpLogFont->elfLogFont.lfWeight)) { 00290 DBGFONTS2((" A bold font (weight %d)\n", lpLogFont->elfLogFont.lfWeight)); 00291 // return 0; 00292 } 00293 00294 /* get font info */ 00295 SizeWant.Y = (SHORT)lpLogFont->elfLogFont.lfHeight; 00296 SizeWant.X = (SHORT)lpLogFont->elfLogFont.lfWidth; 00297 CreateBoldFont: 00298 lpLogFont->elfLogFont.lfQuality = NONANTIALIASED_QUALITY; 00299 hFont = CreateFontIndirectW(&lpLogFont->elfLogFont); 00300 if (!hFont) { 00301 DBGFONTS((" REJECT font (can't create)\n")); 00302 RIPMSG0(RIP_WARNING, "FontEnum: CreateFontIndirectW returned NULL hFont."); 00303 return 0; // same font in other sizes may still be suitable 00304 } 00305 00306 DBGFONTS2((" hFont = %lx\n", hFont)); 00307 00308 // 00309 // for reasons unbeknownst to me, removing this code causes GDI 00310 // to yack, claiming that the font is owned by another process. 00311 // 00312 00313 SelectObject(hDC,hFont); 00314 if (!GetTextMetricsW(hDC, &tmi)) { 00315 tmi = *((LPTEXTMETRICW)lpTextMetric); 00316 } 00317 00318 if (GetTextExtentPoint32W(hDC, L"0", 1, &Size)) { 00319 SizeActual.X = (SHORT)Size.cx; 00320 } else { 00321 SizeActual.X = (SHORT)(tmi.tmMaxCharWidth); 00322 } 00323 SizeActual.Y = (SHORT)(tmi.tmHeight + tmi.tmExternalLeading); 00324 DBGFONTS2((" actual size %d,%d\n", SizeActual.X, SizeActual.Y)); 00325 tmFamily = tmi.tmPitchAndFamily; 00326 if (TM_IS_TT_FONT(tmFamily) && (SizeWant.Y >= 0)) { 00327 SizeToShow = SizeWant; 00328 if (SizeWant.X == 0) { 00329 // Asking for zero width height gets a default aspect-ratio width 00330 // It's better to show that width rather than 0. 00331 SizeToShow.X = SizeActual.X; 00332 } 00333 } else { 00334 SizeToShow = SizeActual; 00335 } 00336 DBGFONTS2((" SizeToShow = (%d,%d), SizeActual = (%d,%d)\n", 00337 SizeToShow.X, SizeToShow.Y, SizeActual.X, SizeActual.Y)); 00338 00339 // there's a GDI bug - this assert fails occasionally 00340 //ASSERT (tmi.tmw.tmMaxCharWidth == lpTextMetric->tmMaxCharWidth); 00341 00342 /* 00343 * NOW, determine whether this font entry has already been cached 00344 * LATER : it may be possible to do this before creating the font, if 00345 * we can trust the dimensions & other info from lpTextMetric. 00346 * Sort by size: 00347 * 1) By pixelheight (negative Y values) 00348 * 2) By height (as shown) 00349 * 3) By width (as shown) 00350 */ 00351 for (nFont = 0; nFont < (LONG)NumberOfFonts; ++nFont) { 00352 COORD SizeShown; 00353 00354 if (FontInfo[nFont].hFont == NULL) { 00355 DBGFONTS(("! Font %x has a NULL hFont\n", nFont)); 00356 continue; 00357 } 00358 00359 00360 if (FontInfo[nFont].SizeWant.X > 0) { 00361 SizeShown.X = FontInfo[nFont].SizeWant.X; 00362 } else { 00363 SizeShown.X = FontInfo[nFont].Size.X; 00364 } 00365 00366 if (FontInfo[nFont].SizeWant.Y > 0) { 00367 // This is a font specified by cell height. 00368 SizeShown.Y = FontInfo[nFont].SizeWant.Y; 00369 } else { 00370 SizeShown.Y = FontInfo[nFont].Size.Y; 00371 if (FontInfo[nFont].SizeWant.Y < 0) { 00372 // This is a TT font specified by character height. 00373 if (SizeWant.Y < 0 && SizeWant.Y > FontInfo[nFont].SizeWant.Y) { 00374 // Requested pixelheight is smaller than this one. 00375 DBGFONTS(("INSERT %d pt at %x, before %d pt\n", 00376 -SizeWant.Y, nFont, -FontInfo[nFont].SizeWant.Y)); 00377 nFontNew = nFont; 00378 goto InsertNewFont; 00379 } 00380 } 00381 } 00382 00383 // DBGFONTS((" SizeShown(%x) = (%d,%d)\n",nFont,SizeShown.X,SizeShown.Y)); 00384 00385 if (SIZE_EQUAL(SizeShown, SizeToShow) && 00386 FontInfo[nFont].Family == tmFamily && 00387 FontInfo[nFont].Weight == tmi.tmWeight && 00388 wcscmp(FontInfo[nFont].FaceName, pwszFace) == 0) { 00389 /* 00390 * Already have this font 00391 */ 00392 DBGFONTS2((" Already have the font\n")); 00393 DeleteObject(hFont); 00394 pfed->ulFE |= FE_FONTOK; 00395 return TRUE; 00396 } 00397 00398 00399 if ((SizeToShow.Y < SizeShown.Y) || 00400 (SizeToShow.Y == SizeShown.Y && SizeToShow.X < SizeShown.X)) { 00401 /* 00402 * This new font is smaller than nFont 00403 */ 00404 DBGFONTS(("INSERT at %x, SizeToShow = (%d,%d)\n", nFont, 00405 SizeToShow.X,SizeToShow.Y)); 00406 nFontNew = nFont; 00407 goto InsertNewFont; 00408 } 00409 } 00410 00411 /* 00412 * The font we are adding should be appended to the list, 00413 * since it is bigger (or equal) to the last one. 00414 */ 00415 nFontNew = (LONG)NumberOfFonts; 00416 00417 InsertNewFont: // at nFontNew 00418 00419 // ASSERT ((lpTextMetric->tmPitchAndFamily & 1) == 0); 00420 /* If we have to grow our font table, do it */ 00421 00422 if (NumberOfFonts == FontInfoLength) { 00423 PFONT_INFO Temp; 00424 00425 FontInfoLength += FONT_INCREMENT; 00426 Temp = (PFONT_INFO)ConsoleHeapReAlloc(MAKE_TAG( FONT_TAG ),FontInfo,sizeof(FONT_INFO) * FontInfoLength); 00427 if (Temp == NULL) { 00428 RIPMSG0(RIP_WARNING, "FontEnum: failed to allocate PFONT_INFO"); 00429 FontInfoLength -= FONT_INCREMENT; 00430 return FALSE; 00431 } 00432 FontInfo = Temp; 00433 } 00434 00435 if (nFontNew < (LONG)NumberOfFonts) { 00436 RtlMoveMemory(&FontInfo[nFontNew+1], 00437 &FontInfo[nFontNew], 00438 sizeof(FONT_INFO)*(NumberOfFonts - nFontNew)); 00439 // 00440 // Fix up DefaultFontIndex if nFontNew less than DefaultFontIndex. 00441 // 00442 if (nFontNew < (LONG)DefaultFontIndex && 00443 DefaultFontIndex+1 < NumberOfFonts) { 00444 DefaultFontIndex++; 00445 } 00446 } 00447 00448 /* 00449 * Store the font info 00450 */ 00451 FontInfo[nFontNew].hFont = hFont; 00452 FontInfo[nFontNew].Family = tmFamily; 00453 FontInfo[nFontNew].Size = SizeActual; 00454 if (TM_IS_TT_FONT(tmFamily)) { 00455 FontInfo[nFontNew].SizeWant = SizeWant; 00456 } else { 00457 FontInfo[nFontNew].SizeWant.X = 0; 00458 FontInfo[nFontNew].SizeWant.Y = 0; 00459 } 00460 FontInfo[nFontNew].Weight = tmi.tmWeight; 00461 FontInfo[nFont].FaceName = pFN->awch; 00462 #if defined(FE_SB) 00463 FontInfo[nFontNew].tmCharSet = tmi.tmCharSet; 00464 #endif 00465 00466 ++NumberOfFonts; 00467 00468 if (nFontType == TRUETYPE_FONTTYPE && !IS_BOLD(FontInfo[nFontNew].Weight)) { 00469 lpLogFont->elfLogFont.lfWeight = FW_BOLD; 00470 goto CreateBoldFont; 00471 } 00472 00473 pfed->ulFE |= FE_FONTOK; // and continue enumeration 00474 return TRUE; 00475 }

NTSTATUS GetAvailableFonts IN PSCREEN_INFORMATION  ScreenInfo,
IN BOOLEAN  MaximumWindow,
OUT PVOID  Buffer,
IN OUT PULONG  NumFonts
 

Definition at line 998 of file w32/ntcon/server/misc.c.

References Buffer, CONSOLE_WINDOW_SIZE_X, CONSOLE_WINDOW_SIZE_Y, FontInfo, GetWindowLimits(), _WINDOW_LIMITS::MaximumWindowSize, NumberOfFonts, SCR_FONTSIZE(), SHORT, and _FONT_INFO::Size.

Referenced by SrvGetConsoleFontInfo().

01004 { 01005 PCONSOLE_FONT_INFO BufPtr; 01006 ULONG i; 01007 COORD WindowSize; 01008 WINDOW_LIMITS WindowLimits; 01009 01010 // 01011 // if the buffer is too small to return all the fonts, return 01012 // the number that will fit. 01013 // 01014 01015 *NumFonts = (*NumFonts > NumberOfFonts) ? NumberOfFonts : *NumFonts; 01016 01017 // 01018 // convert font size in pixels to font size in rows/columns 01019 // 01020 01021 BufPtr = (PCONSOLE_FONT_INFO)Buffer; 01022 01023 if (MaximumWindow) { 01024 GetWindowLimits(ScreenInfo, &WindowLimits); 01025 WindowSize = WindowLimits.MaximumWindowSize; 01026 } 01027 else { 01028 WindowSize.X = (SHORT)CONSOLE_WINDOW_SIZE_X(ScreenInfo); 01029 WindowSize.Y = (SHORT)CONSOLE_WINDOW_SIZE_Y(ScreenInfo); 01030 } 01031 for (i=0;i<*NumFonts;i++,BufPtr++) { 01032 BufPtr->nFont = i; 01033 BufPtr->dwFontSize.X = WindowSize.X * SCR_FONTSIZE(ScreenInfo).X / FontInfo[i].Size.X; 01034 BufPtr->dwFontSize.Y = WindowSize.Y * SCR_FONTSIZE(ScreenInfo).Y / FontInfo[i].Size.Y; 01035 } 01036 01037 return STATUS_SUCCESS; 01038 }

NTSTATUS GetCurrentFont IN PSCREEN_INFORMATION  ScreenInfo,
IN BOOLEAN  MaximumWindow,
OUT PULONG  FontIndex,
OUT PCOORD  FontSize
 

Definition at line 1053 of file w32/ntcon/server/misc.c.

References CONSOLE_WINDOW_SIZE_X, CONSOLE_WINDOW_SIZE_Y, GetWindowLimits(), _WINDOW_LIMITS::MaximumWindowSize, SCR_FONTNUMBER(), and SHORT.

Referenced by SrvGetConsoleCurrentFont().

01059 { 01060 COORD WindowSize; 01061 WINDOW_LIMITS WindowLimits; 01062 01063 if (MaximumWindow) { 01064 GetWindowLimits(ScreenInfo, &WindowLimits); 01065 WindowSize = WindowLimits.MaximumWindowSize; 01066 } 01067 else { 01068 WindowSize.X = (SHORT)CONSOLE_WINDOW_SIZE_X(ScreenInfo); 01069 WindowSize.Y = (SHORT)CONSOLE_WINDOW_SIZE_Y(ScreenInfo); 01070 } 01071 *FontIndex = SCR_FONTNUMBER(ScreenInfo); 01072 *FontSize = WindowSize; 01073 return STATUS_SUCCESS; 01074 }

NTSTATUS GetFontSize IN DWORD  FontIndex,
OUT PCOORD  FontSize
 

Definition at line 1041 of file w32/ntcon/server/misc.c.

References FontInfo, NumberOfFonts, and _FONT_INFO::Size.

Referenced by SetScreenBufferFont(), and SrvGetConsoleFontSize().

01045 { 01046 if (FontIndex >= NumberOfFonts) 01047 return STATUS_INVALID_PARAMETER; 01048 *FontSize = FontInfo[FontIndex].Size; 01049 return STATUS_SUCCESS; 01050 }

NTSTATUS GetMouseButtons PULONG  NumButtons  ) 
 

Definition at line 66 of file w32/ntcon/server/misc.c.

References NumberOfMouseButtons.

Referenced by SrvGetConsoleMouseInfo().

00069 { 00070 *NumButtons = NumberOfMouseButtons; 00071 return STATUS_SUCCESS; 00072 }

NTSTATUS GetNumFonts OUT PULONG  NumFonts  ) 
 

Definition at line 988 of file w32/ntcon/server/misc.c.

References NumberOfFonts.

Referenced by SrvGetConsoleNumberOfFonts().

00991 { 00992 *NumFonts = NumberOfFonts; 00993 return STATUS_SUCCESS; 00994 }

BOOL InitializeCustomCP  ) 
 

Definition at line 1787 of file w32/ntcon/server/misc.c.

References BOOL, FALSE, GlyphCP, GlyphTable, NULL, RtlInitCodePageTable(), TRUE, and USHORT.

Referenced by ConsoleInputThread().

01787 { 01788 PPEB pPeb; 01789 01790 pPeb = NtCurrentPeb(); 01791 if ((pPeb == NULL) || (pPeb->OemCodePageData == NULL)) { 01792 return FALSE; 01793 } 01794 01795 /* 01796 * Fill in the CPTABLEINFO struct 01797 */ 01798 RtlInitCodePageTable(pPeb->OemCodePageData, &GlyphCP); 01799 01800 /* 01801 * Make a copy of the MultiByteToWideChar table 01802 */ 01803 RtlCopyMemory(GlyphTable, GlyphCP.MultiByteTable, 256 * sizeof(USHORT)); 01804 01805 /* 01806 * Modify the first 0x20 bytes so that they are glyphs. 01807 */ 01808 MultiByteToWideChar(CP_OEMCP, MB_USEGLYPHCHARS, 01809 "\x20\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F" 01810 "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F", 01811 0x20, GlyphTable, 0x20); 01812 MultiByteToWideChar(CP_OEMCP, MB_USEGLYPHCHARS, 01813 "\x7f", 1, &GlyphTable[0x7f], 1); 01814 01815 01816 /* 01817 * Point the Custom CP at the glyph table 01818 */ 01819 GlyphCP.MultiByteTable = GlyphTable; 01820 01821 #if defined(FE_SB) && defined(i386) 01822 if (ISNECPC98(gdwMachineId)) { 01823 InitializeNEC_OS2_CP(); 01824 } 01825 #endif 01826 return TRUE; 01827 }

VOID InitializeFonts VOID   ) 
 

Definition at line 109 of file w32/ntcon/server/misc.c.

References CONSOLE_MAX_FONT_NAME_LENGTH, L, NELEM, and NULL.

Referenced by ConServerDllInitialization().

00110 { 00111 WCHAR FontName[CONSOLE_MAX_FONT_NAME_LENGTH]; 00112 int i; 00113 static CONST LPWSTR FontList[] = {L"woafont", 00114 L"ega80woa.fon", 00115 L"ega40woa.fon", 00116 L"cga80woa.fon", 00117 L"cga40woa.fon"}; 00118 00119 // 00120 // Read software.ini to get the values for "woafont", 00121 // "ega80woa.fon", "ega40woa.fon", "cga80woa.fon", and 00122 // "cga40woa.fon", respectively, to pass to AddFontResource. 00123 // 00124 // If any of the entries are empty or non-existent, 00125 // GetPrivateProfileString will return a NULL (empty) string. 00126 // If such is the case, the call to AddPermanentFontResource will 00127 // simply fail. 00128 // 00129 00130 OpenProfileUserMapping(); 00131 00132 for (i = 0; i < NELEM(FontList); i++) { 00133 GetPrivateProfileString(L"386enh", FontList[i], L"", 00134 FontName, NELEM(FontName), L"system.ini"); 00135 GdiAddFontResourceW(FontName, AFRW_ADD_LOCAL_FONT,NULL); 00136 } 00137 00138 CloseProfileUserMapping(); 00139 }

VOID InitializeMouseButtons VOID   ) 
 

Definition at line 75 of file w32/ntcon/server/misc.c.

References GetSystemMetrics(), and NumberOfMouseButtons.

Referenced by InitializeScreenInfo().

00076 { 00077 NumberOfMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS); 00078 }

NTSTATUS RealUnicodeToFalseUnicode IN OUT LPWSTR  Source,
IN int  SourceLength,
IN UINT  Codepage
 

Definition at line 1573 of file w32/ntcon/server/misc.c.

References BOOL, CHAR, CONSOLE_IS_DBCS_ENABLED, ConsoleHeapAlloc, ConsoleHeapFree, DBGCHARS, FALSE, MAKE_TAG, NT_SUCCESS, NTSTATUS(), NULL, OEMCP, RtlMultiByteToUnicodeN(), RtlUnicodeToOemN(), STACK_BUFFER_SIZE, Status, TMP_TAG, TRUE, USACP, and WINDOWSCP.

Referenced by ConvertToWindowed(), FE_TranslateOutputToAnsiUnicodeInternal(), SB_TranslateOutputToAnsiUnicode(), SetScreenBufferFont(), SrvScrollConsoleScreenBuffer(), WWSB_DoSrvWriteConsole(), WWSB_FillOutput(), WWSB_WriteChars(), and WWSB_WriteOutputString().

01588 { 01589 NTSTATUS Status; 01590 LPSTR Temp; 01591 ULONG TempLength; 01592 ULONG Length; 01593 CHAR StackBuffer[STACK_BUFFER_SIZE]; 01594 BOOL NormalChars; 01595 int i; 01596 01597 DBGCHARS(("RealUnicodeToFalseUnicode U->%d:ACP->U %.*ls\n", Codepage, 01598 SourceLength > 10 ? 10 : SourceLength, Source)); 01599 #if defined(FE_SB) 01600 if (OEMCP == WINDOWSCP && Codepage == WINDOWSCP) 01601 return STATUS_SUCCESS; 01602 if (SourceLength == 0 ) 01603 return STATUS_SUCCESS; 01604 #endif 01605 NormalChars = TRUE; 01606 for (i=0;i<SourceLength;i++) { 01607 if (Source[i] > 0x7f) { 01608 NormalChars = FALSE; 01609 break; 01610 } 01611 } 01612 if (NormalChars) { 01613 return STATUS_SUCCESS; 01614 } 01615 TempLength = SourceLength; 01616 if (TempLength > STACK_BUFFER_SIZE) { 01617 Temp = (LPSTR)ConsoleHeapAlloc(MAKE_TAG( TMP_TAG ),TempLength); 01618 if (Temp == NULL) { 01619 return STATUS_NO_MEMORY; 01620 } 01621 } else { 01622 Temp = StackBuffer; 01623 } 01624 if (Codepage == OEMCP) { 01625 Status = RtlUnicodeToOemN(Temp, 01626 TempLength, 01627 &Length, 01628 Source, 01629 SourceLength * sizeof(WCHAR) 01630 ); 01631 } else { 01632 Status = WideCharToMultiByte(Codepage, 01633 0, 01634 Source, 01635 SourceLength, 01636 Temp, 01637 TempLength, 01638 NULL, 01639 NULL); 01640 } 01641 if (!NT_SUCCESS(Status)) { 01642 if (TempLength > STACK_BUFFER_SIZE) { 01643 ConsoleHeapFree(Temp); 01644 } 01645 return Status; 01646 } 01647 01648 if (CONSOLE_IS_DBCS_ENABLED()) { 01649 MultiByteToWideChar(USACP, 01650 0, 01651 Temp, 01652 TempLength, 01653 Source, 01654 SourceLength 01655 ); 01656 } else { 01657 Status = RtlMultiByteToUnicodeN(Source, 01658 SourceLength * sizeof(WCHAR), 01659 &Length, 01660 Temp, 01661 TempLength 01662 ); 01663 } 01664 01665 if (TempLength > STACK_BUFFER_SIZE) { 01666 ConsoleHeapFree(Temp); 01667 } 01668 if (!NT_SUCCESS(Status)) { 01669 return Status; 01670 } else { 01671 return STATUS_SUCCESS; 01672 } 01673 }

NTSTATUS RemoveTextBufferFontInfo IN PSCREEN_INFORMATION  ScreenInfo  ) 
 

Definition at line 952 of file w32/ntcon/server/misc.c.

References ConsoleHeapFree, _TEXT_BUFFER_FONT_INFO::NextTextBufferFont, and NULL.

Referenced by CreateScreenBuffer(), and FreeScreenBuffer().

00958 : 00959 00960 This routine all remove a font information in ListOfTextBufferFont. 00961 00962 Arguments: 00963 00964 Return Value: 00965 00966 --*/ 00967 00968 { 00969 PTEXT_BUFFER_FONT_INFO CurrentFont; 00970 00971 CurrentFont = ScreenInfo->BufferInfo.TextInfo.ListOfTextBufferFont; 00972 00973 while (CurrentFont != NULL) { 00974 PTEXT_BUFFER_FONT_INFO NextFont; 00975 00976 NextFont = CurrentFont->NextTextBufferFont; 00977 ConsoleHeapFree(CurrentFont); 00978 00979 CurrentFont = NextFont; 00980 } 00981 00982 ScreenInfo->BufferInfo.TextInfo.ListOfTextBufferFont = NULL; 00983 00984 return STATUS_SUCCESS; 00985 }

NTSTATUS SetFont IN OUT PSCREEN_INFORMATION  ScreenInfo  ) 
 

Definition at line 1260 of file w32/ntcon/server/misc.c.

References ACTIVE_SCREEN_BUFFER, ASSERT, ConvertAttrToRGB, DWORD, FindCreateFont(), FontInfo, _FONT_INFO::hFont, LOBYTE, NT_SUCCESS, NTSTATUS(), SCR_FACENAME(), SCR_FAMILY(), SCR_FONTCODEPAGE(), SCR_FONTNUMBER(), SCR_FONTSIZE(), SCR_FONTWEIGHT(), Size, Status, and StoreTextBufferFontInfo().

Referenced by ConvertToWindowed(), CreateWindowsWindow(), SetActiveScreenBuffer(), and SetScreenBufferFont().

01263 { 01264 if (ACTIVE_SCREEN_BUFFER(ScreenInfo)) { 01265 int FontIndex = FindCreateFont(SCR_FAMILY(ScreenInfo), 01266 SCR_FACENAME(ScreenInfo), 01267 SCR_FONTSIZE(ScreenInfo), 01268 SCR_FONTWEIGHT(ScreenInfo), 01269 SCR_FONTCODEPAGE(ScreenInfo)); 01270 if (SelectObject(ScreenInfo->Console->hDC,FontInfo[FontIndex].hFont)==0) 01271 return STATUS_INVALID_PARAMETER; 01272 01273 if ((DWORD)FontIndex != SCR_FONTNUMBER(ScreenInfo)) { 01274 NTSTATUS Status; 01275 Status = StoreTextBufferFontInfo(ScreenInfo, 01276 FontIndex, 01277 FontInfo[FontIndex].Size, 01278 FontInfo[FontIndex].Family, 01279 FontInfo[FontIndex].Weight, 01280 FontInfo[FontIndex].FaceName, 01281 ScreenInfo->Console->OutputCP); 01282 if (!NT_SUCCESS(Status)) { 01283 return((ULONG) Status); 01284 } 01285 } 01286 01287 // hack to get text realized into DC. this is to force the 01288 // attribute cache to get flushed to the server side, since 01289 // we select the font with a client side DC and call ExtTextOut 01290 // with a server side DC. 01291 // we then need to reset the text color, since the incorrect 01292 // client side color has been flushed to the server. 01293 { 01294 TEXTMETRIC tmi; 01295 01296 GetTextMetricsW( ScreenInfo->Console->hDC, &tmi); 01297 ASSERT ((tmi.tmPitchAndFamily & 1) == 0); 01298 ScreenInfo->Console->LastAttributes = ScreenInfo->Attributes; 01299 SetTextColor(ScreenInfo->Console->hDC,ConvertAttrToRGB(ScreenInfo->Console, LOBYTE(ScreenInfo->Attributes))); 01300 SetBkColor(ScreenInfo->Console->hDC,ConvertAttrToRGB(ScreenInfo->Console, LOBYTE(ScreenInfo->Attributes >> 4))); 01301 } 01302 } 01303 return STATUS_SUCCESS; 01304 }

NTSTATUS SetScreenBufferFont IN PSCREEN_INFORMATION  ScreenInfo,
IN ULONG  FontIndex,
IN UINT  CodePage
 

Definition at line 1077 of file w32/ntcon/server/misc.c.

References ACTIVE_SCREEN_BUFFER, CONSOLE_OEMFONT_DISPLAY, CONSOLE_TEXTMODE_BUFFER, CONSOLE_WINDOW_SIZE_X, CONSOLE_WINDOW_SIZE_Y, DBGCHARS, DBGFONTS, FALSE, FalseUnicodeToRealUnicode(), FontInfo, GetFontSize(), GetWindowLimits(), _WINDOW_LIMITS::MaximumWindowSize, _WINDOW_LIMITS::MinimumWindowSize, NT_SUCCESS, NTSTATUS(), NULL, RealUnicodeToFalseUnicode(), ResizeScreenBuffer(), SCR_FACENAME(), SCR_FAMILY(), SCR_FONTCODEPAGE(), SCR_FONTNUMBER(), SCR_FONTSIZE(), SCR_FONTWEIGHT(), SetCursorInformation(), SetFont(), SetLineChar(), SetWindowSize(), SHORT, Status, StoreTextBufferFontInfo(), TM_IS_TT_FONT, and WriteToScreen.

Referenced by PropertiesUpdate(), and SrvSetConsoleFont().

01082 { 01083 COORD FontSize; 01084 WINDOW_LIMITS WindowLimits; 01085 NTSTATUS Status; 01086 ULONG ulFlagPrev; 01087 DBGFONTS(("SetScreenBufferFont %lx %x\n", ScreenInfo, FontIndex)); 01088 01089 if (ScreenInfo == NULL) { 01090 /* If shutdown occurs with font dlg up */ 01091 return STATUS_SUCCESS; 01092 } 01093 01094 /* 01095 * Don't try to set the font if we're not in text mode 01096 */ 01097 if (!(ScreenInfo->Flags & CONSOLE_TEXTMODE_BUFFER)) { 01098 return STATUS_UNSUCCESSFUL; 01099 } 01100 01101 Status = GetFontSize(FontIndex, &FontSize); 01102 if (!NT_SUCCESS(Status)) { 01103 return((ULONG) Status); 01104 } 01105 01106 ulFlagPrev = ScreenInfo->Flags; 01107 if (TM_IS_TT_FONT(FontInfo[FontIndex].Family)) { 01108 ScreenInfo->Flags &= ~CONSOLE_OEMFONT_DISPLAY; 01109 } else { 01110 ScreenInfo->Flags |= CONSOLE_OEMFONT_DISPLAY; 01111 } 01112 01113 /* 01114 * Convert from UnicodeOem to Unicode or vice-versa if necessary 01115 */ 01116 if ((ulFlagPrev & CONSOLE_OEMFONT_DISPLAY) != (ScreenInfo->Flags & CONSOLE_OEMFONT_DISPLAY)) { 01117 if (ulFlagPrev & CONSOLE_OEMFONT_DISPLAY) { 01118 /* 01119 * Must convert from UnicodeOem to real Unicode 01120 */ 01121 DBGCHARS(("SetScreenBufferFont converts UnicodeOem to Unicode\n")); 01122 FalseUnicodeToRealUnicode( 01123 ScreenInfo->BufferInfo.TextInfo.TextRows, 01124 ScreenInfo->ScreenBufferSize.X * ScreenInfo->ScreenBufferSize.Y, 01125 ScreenInfo->Console->OutputCP); 01126 } else { 01127 /* 01128 * Must convert from real Unicode to UnicodeOem 01129 */ 01130 DBGCHARS(("SetScreenBufferFont converts Unicode to UnicodeOem\n")); 01131 RealUnicodeToFalseUnicode( 01132 ScreenInfo->BufferInfo.TextInfo.TextRows, 01133 ScreenInfo->ScreenBufferSize.X * ScreenInfo->ScreenBufferSize.Y, 01134 ScreenInfo->Console->OutputCP); 01135 } 01136 } 01137 01138 /* 01139 * Store font properties 01140 */ 01141 Status = StoreTextBufferFontInfo(ScreenInfo, 01142 FontIndex, 01143 FontSize, 01144 FontInfo[FontIndex].Family, 01145 FontInfo[FontIndex].Weight, 01146 FontInfo[FontIndex].FaceName, 01147 CodePage); 01148 if (!NT_SUCCESS(Status)) { 01149 return((ULONG) Status); 01150 } 01151 01152 // 01153 // set font 01154 // 01155 Status = SetFont(ScreenInfo); 01156 if (!NT_SUCCESS(Status)) { 01157 return((ULONG) Status); 01158 } 01159 01160 // 01161 // if window is growing, make sure it's not bigger than the screen. 01162 // 01163 01164 GetWindowLimits(ScreenInfo, &WindowLimits); 01165 if (WindowLimits.MaximumWindowSize.X < CONSOLE_WINDOW_SIZE_X(ScreenInfo)) { 01166 ScreenInfo->Window.Right -= CONSOLE_WINDOW_SIZE_X(ScreenInfo) - WindowLimits.MaximumWindowSize.X; 01167 ScreenInfo->WindowMaximizedX = (ScreenInfo->Window.Left == 0 && 01168 (SHORT)(ScreenInfo->Window.Right+1) == ScreenInfo->ScreenBufferSize.X); 01169 } 01170 if (WindowLimits.MaximumWindowSize.Y < CONSOLE_WINDOW_SIZE_Y(ScreenInfo)) { 01171 ScreenInfo->Window.Bottom -= CONSOLE_WINDOW_SIZE_Y(ScreenInfo) - WindowLimits.MaximumWindowSize.Y; 01172 if (ScreenInfo->BufferInfo.TextInfo.CursorPosition.Y > ScreenInfo->Window.Bottom) { 01173 ScreenInfo->Window.Top += ScreenInfo->BufferInfo.TextInfo.CursorPosition.Y - ScreenInfo->Window.Bottom; 01174 ScreenInfo->Window.Bottom += ScreenInfo->BufferInfo.TextInfo.CursorPosition.Y - ScreenInfo->Window.Bottom; 01175 } 01176 ScreenInfo->WindowMaximizedY = (ScreenInfo->Window.Top == 0 && 01177 (SHORT)(ScreenInfo->Window.Bottom+1) == ScreenInfo->ScreenBufferSize.Y); 01178 } 01179 if (WindowLimits.MinimumWindowSize.X > CONSOLE_WINDOW_SIZE_X(ScreenInfo)) { 01180 if (WindowLimits.MinimumWindowSize.X > ScreenInfo->ScreenBufferSize.X) { 01181 COORD NewBufferSize; 01182 01183 NewBufferSize.X = WindowLimits.MinimumWindowSize.X; 01184 NewBufferSize.Y = ScreenInfo->ScreenBufferSize.Y; 01185 ResizeScreenBuffer(ScreenInfo, 01186 NewBufferSize, 01187 FALSE 01188 ); 01189 } 01190 if ((ScreenInfo->Window.Left+WindowLimits.MinimumWindowSize.X) > ScreenInfo->ScreenBufferSize.X) { 01191 ScreenInfo->Window.Left = 0; 01192 ScreenInfo->Window.Right = WindowLimits.MinimumWindowSize.X-1; 01193 } else { 01194 ScreenInfo->Window.Right = ScreenInfo->Window.Left+WindowLimits.MinimumWindowSize.X-1; 01195 } 01196 ScreenInfo->WindowMaximizedX = (ScreenInfo->Window.Left == 0 && 01197 (SHORT)(ScreenInfo->Window.Right+1) == ScreenInfo->ScreenBufferSize.X); 01198 } 01199 01200 SetLineChar(ScreenInfo); 01201 { 01202 COORD WindowedWindowSize; 01203 01204 WindowedWindowSize.X = CONSOLE_WINDOW_SIZE_X(ScreenInfo); 01205 WindowedWindowSize.Y = CONSOLE_WINDOW_SIZE_Y(ScreenInfo); 01206 01207 01208 #if defined(FE_IME) 01209 if (CONSOLE_IS_DBCS_OUTPUTCP(ScreenInfo->Console)) 01210 { 01211 PCONVERSIONAREA_INFORMATION ConvAreaInfo; 01212 01213 ConvAreaInfo = ScreenInfo->Console->ConsoleIme.ConvAreaRoot; 01214 while (ConvAreaInfo) { 01215 01216 Status = StoreTextBufferFontInfo(ConvAreaInfo->ScreenBuffer, 01217 SCR_FONTNUMBER(ScreenInfo), 01218 SCR_FONTSIZE(ScreenInfo), 01219 SCR_FAMILY(ScreenInfo), 01220 SCR_FONTWEIGHT(ScreenInfo), 01221 SCR_FACENAME(ScreenInfo), 01222 SCR_FONTCODEPAGE(ScreenInfo)); 01223 if (!NT_SUCCESS(Status)) { 01224 return((ULONG) Status); 01225 } 01226 01227 ConvAreaInfo->ScreenBuffer->Window = ScreenInfo->Window; 01228 ConvAreaInfo->ScreenBuffer->BufferInfo.TextInfo.ModeIndex = ScreenInfo->BufferInfo.TextInfo.ModeIndex; 01229 01230 ConvAreaInfo = ConvAreaInfo->ConvAreaNext; 01231 } 01232 } 01233 #endif // FE_IME 01234 } 01235 01236 // 01237 // resize window. this will take care of the scroll bars too. 01238 // 01239 01240 if (ACTIVE_SCREEN_BUFFER(ScreenInfo)) { 01241 SetWindowSize(ScreenInfo); 01242 } 01243 01244 // 01245 // adjust cursor size. 01246 // 01247 01248 SetCursorInformation(ScreenInfo, 01249 ScreenInfo->BufferInfo.TextInfo.CursorSize, 01250 (BOOLEAN)ScreenInfo->BufferInfo.TextInfo.CursorVisible 01251 ); 01252 01253 WriteToScreen(ScreenInfo, 01254 &ScreenInfo->Window); 01255 return STATUS_SUCCESS; 01256 }

NTSTATUS StoreTextBufferFontInfo IN PSCREEN_INFORMATION  ScreenInfo,
IN ULONG  FontIndex,
IN COORD  FontSize,
IN BYTE  FontFamily,
IN LONG  FontWeight,
IN LPWSTR  FaceName,
IN UINT  CodePage
 

Definition at line 881 of file w32/ntcon/server/misc.c.

References ConsoleHeapAlloc, _TEXT_BUFFER_FONT_INFO::FaceName, _TEXT_BUFFER_FONT_INFO::Family, FONT_TAG, _TEXT_BUFFER_FONT_INFO::FontCodePage, _TEXT_BUFFER_FONT_INFO::FontNumber, _TEXT_BUFFER_FONT_INFO::FontSize, MAKE_TAG, _TEXT_BUFFER_FONT_INFO::NextTextBufferFont, NULL, and _TEXT_BUFFER_FONT_INFO::Weight.

Referenced by ConvertToFullScreen(), ConvertToWindowed(), CreateScreenBuffer(), SetFont(), and SetScreenBufferFont().

00893 : 00894 00895 This routine store a font information in CurrentTextBufferFont and ListOfTextBufferFont. 00896 If specified code page does not exist in ListOfTextBufferFont, then create new list. 00897 00898 Arguments: 00899 00900 Return Value: 00901 00902 --*/ 00903 00904 { 00905 PTEXT_BUFFER_FONT_INFO CurrentFont, PrevFont; 00906 00907 CurrentFont = ScreenInfo->BufferInfo.TextInfo.ListOfTextBufferFont; 00908 00909 while (CurrentFont != NULL) { 00910 if (CurrentFont->FontCodePage == CodePage) { 00911 CurrentFont->FontNumber = FontIndex; 00912 CurrentFont->FontSize = FontSize; 00913 CurrentFont->Family = FontFamily; 00914 CurrentFont->Weight = FontWeight; 00915 // CurrentFont->FontCodePage = CodePage; // Redundant 00916 wcscpy(CurrentFont->FaceName, FaceName); 00917 break; 00918 } 00919 PrevFont = CurrentFont; 00920 CurrentFont = CurrentFont->NextTextBufferFont; 00921 } 00922 00923 if (CurrentFont == NULL) { 00924 CurrentFont = ConsoleHeapAlloc(MAKE_TAG( FONT_TAG ), sizeof(TEXT_BUFFER_FONT_INFO)); 00925 if (CurrentFont == NULL) { 00926 return STATUS_NO_MEMORY; 00927 } 00928 00929 CurrentFont->NextTextBufferFont = NULL; 00930 CurrentFont->FontNumber = FontIndex; 00931 CurrentFont->FontSize = FontSize; 00932 CurrentFont->Family = FontFamily; 00933 CurrentFont->Weight = FontWeight; 00934 CurrentFont->FontCodePage = CodePage; 00935 wcscpy(CurrentFont->FaceName, FaceName); 00936 00937 if (ScreenInfo->BufferInfo.TextInfo.ListOfTextBufferFont == NULL) { 00938 ScreenInfo->BufferInfo.TextInfo.ListOfTextBufferFont = CurrentFont; 00939 } 00940 else { 00941 PrevFont->NextTextBufferFont = CurrentFont; 00942 } 00943 } 00944 00945 ScreenInfo->BufferInfo.TextInfo.CurrentTextBufferFont = *CurrentFont; 00946 ScreenInfo->BufferInfo.TextInfo.CurrentTextBufferFont.NextTextBufferFont = NULL; 00947 00948 return STATUS_SUCCESS; 00949 }

char WcharToChar IN UINT  Codepage,
IN WCHAR  Wchar
 

Definition at line 1489 of file w32/ntcon/server/misc.c.

References DBGCHARS, NULL, OEMCP, and RtlUnicodeToOemN().

Referenced by FE_WriteRegionToScreenHW(), ReadOutputString(), SB_TranslateOutputToOem(), and TranslateInputToOem().

01492 { 01493 char ch; 01494 if (Codepage == OEMCP) { 01495 RtlUnicodeToOemN(&ch, sizeof(ch), NULL, &Wchar, sizeof(Wchar)); 01496 } else { 01497 WideCharToMultiByte(Codepage, 0, &Wchar, 1, &ch, 1, NULL, NULL); 01498 } 01499 #ifdef DEBUG_PRINT 01500 if (Wchar > 0x007F) { 01501 DBGCHARS(("WcharToChar %d 0x%04x -> 0x%02x\n",Codepage,Wchar,(UCHAR)ch)); 01502 } 01503 #endif 01504 return ch; 01505 }


Variable Documentation

WCHAR DefaultFaceName[LF_FACESIZE]
 

Definition at line 35 of file w32/ntcon/server/misc.c.

Referenced by EnumerateFonts(), and FindCreateFont().

BYTE DefaultFontFamily
 

Definition at line 37 of file w32/ntcon/server/misc.c.

Referenced by EnumerateFonts().

ULONG DefaultFontIndex = 0
 

Definition at line 38 of file w32/ntcon/server/misc.c.

Referenced by EnumerateFonts(), FindCreateFont(), and FontEnum().

COORD DefaultFontSize
 

Definition at line 36 of file w32/ntcon/server/misc.c.

Referenced by EnumerateFonts(), and FindCreateFont().

PFONT_INFO FontInfo
 

Definition at line 31 of file w32/ntcon/server/misc.c.

Referenced by CreateScreenBuffer(), df(), DoCreateScreenBuffer(), EnumerateFonts(), FindCreateFont(), FontEnum(), GetAvailableFonts(), GetFontSize(), PropertiesDlgShow(), SetFont(), SetRAMFont(), SetRAMFontCodePage(), and SetScreenBufferFont().

ULONG FontInfoLength
 

Definition at line 32 of file w32/ntcon/server/misc.c.

Referenced by df(), EnumerateFonts(), and FontEnum().

CPTABLEINFO GlyphCP
 

Definition at line 50 of file w32/ntcon/server/misc.c.

Referenced by CharToWcharGlyph(), ConvertOutputToUnicode(), FalseUnicodeToRealUnicode(), and InitializeCustomCP().

USHORT GlyphTable[256]
 

Definition at line 51 of file w32/ntcon/server/misc.c.

Referenced by InitializeCustomCP().

PFACENODE gpFaceNames
 

Definition at line 62 of file w32/ntcon/server/misc.c.

Referenced by EnumerateFonts(), and FontEnum().

ULONG NumberOfFonts
 

Definition at line 33 of file w32/ntcon/server/misc.c.

Referenced by CreateScreenBuffer(), df(), EnumerateFonts(), FindCreateFont(), FontEnum(), GetAvailableFonts(), GetFontSize(), GetNumFonts(), and PropertiesDlgShow().

ULONG NumberOfMouseButtons
 

Definition at line 29 of file w32/ntcon/server/misc.c.

Referenced by GetMouseButtons(), and InitializeMouseButtons().


Generated on Sat May 15 19:44:43 2004 for test by doxygen 1.3.7