Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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;
        }
Example #4
0
        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);
        }
Example #5
0
        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.
            }
        }
Example #6
0
 internal static extern bool GetCurrentConsoleFontEx(IntPtr consoleOutput, bool bMaximumWindow, ref CONSOLE_FONT_INFO_EX consoleFontInfo);
Example #7
0
        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;
        }
Example #8
0
 internal static extern bool GetCurrentConsoleFontEx(IntPtr consoleOutput, bool bMaximumWindow, ref CONSOLE_FONT_INFO_EX consoleFontInfo);