internal static CONSOLE_FONT_INFO_EX GetConsoleFontInfo(SafeFileHandle consoleHandle) { CONSOLE_FONT_INFO_EX fontInfo = new CONSOLE_FONT_INFO_EX(); fontInfo.cbSize = Marshal.SizeOf(fontInfo); bool result = true; if (_getCurrentConsoleFontExApiAvailable) { try { result = NativeMethods.GetCurrentConsoleFontEx(consoleHandle.DangerousGetHandle(), false, ref fontInfo); } catch (System.EntryPointNotFoundException) { _getCurrentConsoleFontExApiAvailable = false; // api not available on NanoServer } } if (result == false) { int err = Marshal.GetLastWin32Error(); Win32Exception innerException = new Win32Exception(err); throw new Exception("Failed to get console font information.", innerException); } return(fontInfo); }
internal static CONSOLE_FONT_INFO_EX GetConsoleFontInfo(SafeFileHandle consoleHandle) { CONSOLE_FONT_INFO_EX fontInfo = new CONSOLE_FONT_INFO_EX(); fontInfo.cbSize = Marshal.SizeOf(fontInfo); bool result = true; if (_getCurrentConsoleFontExApiAvailable) { try { result = NativeMethods.GetCurrentConsoleFontEx(consoleHandle.DangerousGetHandle(), false, ref fontInfo); } catch (System.EntryPointNotFoundException) { _getCurrentConsoleFontExApiAvailable = false; // api not available on NanoServer } } if (result == false) { _getCurrentConsoleFontExApiAvailable = false; // api not supported on ServerCore } return(fontInfo); }
public void StartRender() { _codePage = NativeMethods.GetConsoleOutputCP(); _istmInitialized = false; var consoleHandle = _outputHandle.Value; CONSOLE_FONT_INFO_EX fontInfo = ConhostConsole.GetConsoleFontInfo(consoleHandle); int fontType = fontInfo.FontFamily & NativeMethods.FontTypeMask; _trueTypeInUse = (fontType & NativeMethods.TrueTypeFont) == NativeMethods.TrueTypeFont; }
internal static CONSOLE_FONT_INFO_EX GetConsoleFontInfo(SafeFileHandle consoleHandle) { CONSOLE_FONT_INFO_EX fontInfo = new CONSOLE_FONT_INFO_EX(); fontInfo.cbSize = Marshal.SizeOf(fontInfo); bool result = NativeMethods.GetCurrentConsoleFontEx(consoleHandle.DangerousGetHandle(), false, ref fontInfo); if (result == false) { int err = Marshal.GetLastWin32Error(); Win32Exception innerException = new Win32Exception(err); throw new Exception("Failed to get console font information.", innerException); } return(fontInfo); }
public void StartRender() { _codePage = NativeMethods.GetConsoleOutputCP(); _istmInitialized = false; var consoleHandle = _outputHandle.Value; try { CONSOLE_FONT_INFO_EX fontInfo = ConhostConsole.GetConsoleFontInfo(consoleHandle); int fontType = fontInfo.FontFamily & NativeMethods.FontTypeMask; _trueTypeInUse = (fontType & NativeMethods.TrueTypeFont) == NativeMethods.TrueTypeFont; } catch (Exception e) { // Ignore failures to get font information. In Windows Server containers, // the font information cannot be queried. } }
internal static extern bool GetCurrentConsoleFontEx(IntPtr consoleOutput, bool bMaximumWindow, ref CONSOLE_FONT_INFO_EX consoleFontInfo);
internal static CONSOLE_FONT_INFO_EX GetConsoleFontInfo(SafeFileHandle consoleHandle) { CONSOLE_FONT_INFO_EX fontInfo = new CONSOLE_FONT_INFO_EX(); fontInfo.cbSize = Marshal.SizeOf(fontInfo); bool result = NativeMethods.GetCurrentConsoleFontEx(consoleHandle.DangerousGetHandle(), false, ref fontInfo); if (result == false) { int err = Marshal.GetLastWin32Error(); Win32Exception innerException = new Win32Exception(err); throw new Exception("Failed to get console font information.", innerException); } return fontInfo; }