Discussion:
[newlib-cygwin] Cygwin: console: don't hang in check_font with raster fonts
Corinna Vinschen
2018-09-07 11:50:10 UTC
Permalink
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=60471176fd37102139ddc55b3e7ce9561ea56fc5

commit 60471176fd37102139ddc55b3e7ce9561ea56fc5
Author: Corinna Vinschen <***@vinschen.de>
Date: Fri Sep 7 13:43:48 2018 +0200

Cygwin: console: don't hang in check_font with raster fonts

EnumFontFamiliesExW fails if the font is "Terminal" (aka "Raster Fonts")
and lfCharSet requests ANSI_CHARSET. Using DEFAULT_CHARSET fixes this.

Signed-off-by: Corinna Vinschen <***@vinschen.de>

Diff:
---
winsup/cygwin/fhandler_console.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index dfb78d4..d53b53e 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -2009,7 +2009,7 @@ check_font (HANDLE hdl)
return;
/* Some FaceNames like DejaVu Sans Mono are sometimes returned with stray
trailing chars. Fix it. */
- lf.lfCharSet = ANSI_CHARSET;
+ lf.lfCharSet = DEFAULT_CHARSET;
lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
wchar_t *cp = wcpcpy (lf.lfFaceName, cfi.FaceName) - 1;
int done = 0;
@@ -2023,7 +2023,7 @@ check_font (HANDLE hdl)
/* Yes. Check for the best replacement char. */
HFONT f = CreateFontW (0, 0, 0, 0,
cfi.FontWeight, FALSE, FALSE, FALSE,
- ANSI_CHARSET, OUT_DEFAULT_PRECIS,
+ DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
FIXED_PITCH | FF_DONTCARE, lf.lfFaceName);
if (!f)

Loading...