Index: win32ss/user/winsrv/consrv/frontends/gui/text.c =================================================================== --- win32ss/user/winsrv/consrv/frontends/gui/text.c (révision 63880) +++ win32ss/user/winsrv/consrv/frontends/gui/text.c (copie de travail) @@ -24,8 +24,7 @@ /* FUNCTIONS ******************************************************************/ -static COLORREF -PaletteRGBFromAttrib(PCONSOLE Console, WORD Attribute) +COLORREF PaletteRGBFromAttrib(PCONSOLE Console, WORD Attribute) { HPALETTE hPalette = Console->ActiveBuffer->PaletteHandle; PALETTEENTRY pe; @@ -36,44 +35,6 @@ return PALETTERGB(pe.peRed, pe.peGreen, pe.peBlue); } -static HFONT -ChangeFontAttributes(PGUI_CONSOLE_DATA GuiData, - // COORD FontSize, - ULONG FontWeight, - BOOLEAN bItalic, - BOOLEAN bUnderline, - BOOLEAN bStrikeOut) -{ - HFONT NewFont; - LOGFONT lf; - - /* Initialize the LOGFONT structure */ - RtlZeroMemory(&lf, sizeof(lf)); - - /* Retrieve the details of the current font */ - if (GetObject(GuiData->Font, sizeof(lf), &lf) == 0) - return NULL; // GuiData->Font; - - /* Change the font attributes */ - // lf.lfHeight = FontSize.Y; - // lf.lfWidth = FontSize.X; - lf.lfWeight = FontWeight; - lf.lfItalic = bItalic; - lf.lfUnderline = bUnderline; - lf.lfStrikeOut = bStrikeOut; - - /* Build a new font */ - NewFont = CreateFontIndirect(&lf); - if (NewFont == NULL) - return NULL; // GuiData->Font; - - // FIXME: Do we need to update GuiData->CharWidth and GuiData->CharHeight ?? - - /* Select it (return the old font) */ - // return SelectObject(GuiData->hMemDC, NewFont); - return NewFont; -} - static VOID CopyBlock(PTEXTMODE_SCREEN_BUFFER Buffer, PSMALL_RECT Selection) @@ -387,8 +348,7 @@ WORD LastAttribute, Attribute; ULONG CursorX, CursorY, CursorHeight; HBRUSH CursorBrush, OldBrush; - HFONT OldFont, NewFont; - BOOLEAN IsUnderscore; + HFONT OldFont; if (Buffer->Buffer == NULL) return; @@ -412,18 +372,7 @@ SetTextColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console, TextAttribFromAttrib(LastAttribute))); SetBkColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console, BkgdAttribFromAttrib(LastAttribute))); - // OldFont = ChangeFontAttributes(GuiData, /* {0}, */ GuiData->GuiInfo.FontWeight, FALSE, FALSE, FALSE); - IsUnderscore = !!(LastAttribute & COMMON_LVB_UNDERSCORE); - NewFont = ChangeFontAttributes(GuiData, /* {0}, */ GuiData->GuiInfo.FontWeight, - FALSE, - IsUnderscore, - FALSE); - if (NewFont == NULL) - { - DPRINT1("ChangeFontAttributes failed, use the original font\n"); - NewFont = GuiData->Font; - } - OldFont = SelectObject(GuiData->hMemDC, NewFont); + OldFont = SelectObject(GuiData->hMemDC, GuiData->Font); for (Line = TopLine; Line <= BottomLine; Line++) { @@ -450,31 +399,9 @@ Attribute = From->Attributes; if (Attribute != LastAttribute) { + SetTextColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console, TextAttribFromAttrib(Attribute))); + SetBkColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console, BkgdAttribFromAttrib(Attribute))); LastAttribute = Attribute; - SetTextColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console, TextAttribFromAttrib(LastAttribute))); - SetBkColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console, BkgdAttribFromAttrib(LastAttribute))); - - /* Change underscore state if needed */ - if (!!(LastAttribute & COMMON_LVB_UNDERSCORE) != IsUnderscore) - { - IsUnderscore = !!(LastAttribute & COMMON_LVB_UNDERSCORE); - - /* Delete the font we used up to now */ - // SelectObject(GuiData->hMemDC, OldFont); - if (NewFont != GuiData->Font) DeleteObject(NewFont); - /* Recreate it */ - NewFont = ChangeFontAttributes(GuiData, /* {0}, */ GuiData->GuiInfo.FontWeight, - FALSE, - IsUnderscore, - FALSE); - if (NewFont == NULL) - { - DPRINT1("ChangeFontAttributes failed, use the original font\n"); - NewFont = GuiData->Font; - } - /* Select it */ - /* OldFont = */ SelectObject(GuiData->hMemDC, NewFont); - } } } @@ -514,15 +441,12 @@ GuiData->CharWidth, CursorHeight, PATCOPY); - SelectObject(GuiData->hMemDC, OldBrush); DeleteObject(CursorBrush); } } - /* Restore the old font and delete the font we used up to now */ SelectObject(GuiData->hMemDC, OldFont); - if (NewFont != GuiData->Font) DeleteObject(NewFont); LeaveCriticalSection(&Console->Lock); } Index: win32ss/user/winsrv/consrv/include/settings.h =================================================================== --- win32ss/user/winsrv/consrv/include/settings.h (révision 63880) +++ win32ss/user/winsrv/consrv/include/settings.h (copie de travail) @@ -51,14 +51,10 @@ WCHAR ConsoleTitle[MAX_PATH + 1]; } CONSOLE_INFO, *PCONSOLE_INFO; -/* - * BYTE Foreground = LOBYTE(Attributes) & 0x0F; - * BYTE Background = (LOBYTE(Attributes) & 0xF0) >> 4; - */ #define RGBFromAttrib(Console, Attribute) ((Console)->Colors[(Attribute) & 0xF]) -#define TextAttribFromAttrib(Attribute) ( !((Attribute) & COMMON_LVB_REVERSE_VIDEO) ? (Attribute) & 0xF : ((Attribute) >> 4) & 0xF ) -#define BkgdAttribFromAttrib(Attribute) ( !((Attribute) & COMMON_LVB_REVERSE_VIDEO) ? ((Attribute) >> 4) & 0xF : (Attribute) & 0xF ) -#define MakeAttrib(TextAttrib, BkgdAttrib) (USHORT)((((BkgdAttrib) & 0xF) << 4) | ((TextAttrib) & 0xF)) +#define TextAttribFromAttrib(Attribute) ((Attribute) & 0xF) +#define BkgdAttribFromAttrib(Attribute) (((Attribute) >> 4) & 0xF) +#define MakeAttrib(TextAttrib, BkgdAttrib) (DWORD)((((BkgdAttrib) & 0xF) << 4) | ((TextAttrib) & 0xF)) /* * Structure used to communicate with console.dll