* This is called when making the switch to a symset * with a UTF8 handler to allow any operating system * specific changes to be carried out. */
| 1876 | * specific changes to be carried out. |
| 1877 | */ |
| 1878 | void |
| 1879 | tty_utf8graphics_fixup(void) |
| 1880 | { |
| 1881 | CONSOLE_FONT_INFOEX console_font_info; |
| 1882 | if ((tty_procs.wincap2 & WC2_U_UTF8STR) && SYMHANDLING(H_UTF8)) { |
| 1883 | char *localestr = 0; |
| 1884 | |
| 1885 | if (!console.hConOut) |
| 1886 | console.hConOut = GetStdHandle(STD_OUTPUT_HANDLE); |
| 1887 | /* the locale */ |
| 1888 | if (console.localestr) { |
| 1889 | free(console.localestr); |
| 1890 | console.localestr = NULL; |
| 1891 | } |
| 1892 | localestr = setlocale(LC_ALL, ".UTF8"); |
| 1893 | if (localestr) |
| 1894 | console.localestr = dupstr(localestr); |
| 1895 | /* the code page */ |
| 1896 | SetConsoleOutputCP(65001); |
| 1897 | console.code_page = GetConsoleOutputCP(); |
| 1898 | /* the font */ |
| 1899 | console_font_info.cbSize = sizeof(console_font_info); |
| 1900 | BOOL success = GetCurrentConsoleFontEx(console.hConOut, FALSE, |
| 1901 | &console_font_info); |
| 1902 | /* Try DejaVu Sans Mono for Powerline */ |
| 1903 | wcscpy_s(console_font_info.FaceName, |
| 1904 | sizeof(console_font_info.FaceName) |
| 1905 | / sizeof(console_font_info.FaceName[0]), |
| 1906 | L"DejaVu Sans Mono for Powerline"); |
| 1907 | console_font_info.cbSize = sizeof(console_font_info); |
| 1908 | success = SetCurrentConsoleFontEx(console.hConOut, FALSE, |
| 1909 | &console_font_info); |
| 1910 | if (!success) { |
| 1911 | /* Next, try Lucida Console */ |
| 1912 | wcscpy_s(console_font_info.FaceName, |
| 1913 | sizeof(console_font_info.FaceName) |
| 1914 | / sizeof(console_font_info.FaceName[0]), |
| 1915 | L"Lucida Console"); |
| 1916 | console_font_info.cbSize = sizeof(console_font_info); |
| 1917 | success = SetCurrentConsoleFontEx(console.hConOut, FALSE, |
| 1918 | &console_font_info); |
| 1919 | } |
| 1920 | nhassert(success); |
| 1921 | if (success) { |
| 1922 | console.font_info = console_font_info; |
| 1923 | console.font_changed = TRUE; |
| 1924 | } |
| 1925 | /* the console mode */ |
| 1926 | GetConsoleMode(console.hConOut, &console.out_cmode); |
| 1927 | #if 1 |
| 1928 | if ((console.out_cmode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) == 0) { |
| 1929 | /* recognize escape sequences */ |
| 1930 | console.out_cmode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; |
| 1931 | SetConsoleMode(console.hConOut, console.out_cmode); |
| 1932 | } |
| 1933 | #else |
| 1934 | console.out_cmode &= ~ENABLE_VIRTUAL_TERMINAL_PROCESSING; |
| 1935 | #endif |