From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21477 invoked by alias); 3 Sep 2018 20:27:23 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 21457 invoked by uid 89); 3 Sep 2018 20:27:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-100.4 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,KAM_ASCII_DIVIDERS,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=Courier, lucida, Lucida, consolas X-HELO: mout.kundenserver.de Received: from mout.kundenserver.de (HELO mout.kundenserver.de) (212.227.126.135) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Sep 2018 20:27:20 +0000 Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.167]) with ESMTPSA (Nemesis) id 0MSFeJ-1gLUjO3KsV-00TWj8 for ; Mon, 03 Sep 2018 22:27:17 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id CD66EA820B4; Mon, 3 Sep 2018 22:27:16 +0200 (CEST) Date: Mon, 03 Sep 2018 20:27:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: Cygwin fails to utilize Unicode replacement character Message-ID: <20180903202716.GA6350@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <7942b18e-96bf-a824-4dac-82715d87af55@towo.net> <5b8bdcc4.1c69fb81.84d1a.e6b9@mx.google.com> <20180903124616.GT6350@calimero.vinschen.de> <20180903145919.GU6350@calimero.vinschen.de> <126ebbde-2432-f19b-6c5c-fe61f31e4647@towo.net> <20180903171659.GY6350@calimero.vinschen.de> <515ad501-3cb4-0236-ce03-0b7d9286bd24@towo.net> <20180903191437.GZ6350@calimero.vinschen.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="309evMHi/619oHyA" Content-Disposition: inline In-Reply-To: <20180903191437.GZ6350@calimero.vinschen.de> User-Agent: Mutt/1.9.2 (2017-12-15) X-SW-Source: 2018-09/txt/msg00056.txt.bz2 --309evMHi/619oHyA Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 3687 On Sep 3 21:14, Corinna Vinschen wrote: > On Sep 3 20:20, Thomas Wolff wrote: > > Am 03.09.2018 um 19:56 schrieb Thomas Wolff: > > > Am 03.09.2018 um 19:16 schrieb Corinna Vinschen: > > > > On Sep=C2=A0 3 18:34, Thomas Wolff wrote: > > > > > Am 03.09.2018 um 16:59 schrieb Corinna Vinschen: > > > > > > Does anybody have an idea what I'm doing wrong? > > > > > This works in mintty, just uploaded a patch. Maybe somehow the > > > > > GetConsole > > > > > "dc" does not support this usage? > > > > =C2=AF\_(=E3=83=84)_/=C2=AF > > > Dito; hold on, sorry, your code does *not* work inside mintty. > > > Mine looks a bit different and I thought to have manually verified it= 's > > > functionally equivalent, but indeed there must be something fishy... > > You still need to > > =C2=A0 SelectObject(cdc, f); > > where f is the HFONT of the font you want to check. > > To compare, you may check out function win_check_glyphs in file wintext= .c in > > mintty. >=20 > Thanks but I don't know how to get a HFONT for the current console font. >=20 > In the meantime I figured out why my GetCurrentConsoleFontEx call > failed with error 87: >=20 > When looking again I realized there's a member called cbSize. The MSDN > docs neglect to tell that the cbSize member has to be primed with > sizeof(CONSOLE_FONT_INFOEX). As soon as I tried that, the function > succeeded. >=20 > Well, it's a start. I now have the actual font name. No idea how to > get a HFONT from there, though. From what I can tell ATM, I'd have to > call CreateFont to get a new HFONT and then destroy it again after > usage. This looks pretty wasteful. Well, it still doesn't work for me. I now have the following code: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D SNIP =3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D #include #include #include int main () { static const wchar_t replacement_char[2] =3D { 0xfffd, /* REPLACEMENT CHARACTER */ 0x2592 /* MEDIUM SHADE */ }; CONSOLE_FONT_INFOEX cfi; HWND cwnd =3D GetConsoleWindow (); HDC cdc =3D GetDC (cwnd); int rp_idx =3D 1; WORD gi[2] =3D { 0, 0 }; memset (&cfi, 0, sizeof cfi); cfi.cbSize =3D sizeof cfi; if (GetCurrentConsoleFontEx (GetStdHandle (STD_OUTPUT_HANDLE), FALSE, &cf= i)) { printf ("font %ls\n", cfi.FaceName); HFONT hf =3D CreateFontW (cfi.dwFontSize.Y, cfi.dwFontSize.X, 0, 0, cfi.FontWeight, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FIXED_PITCH | FF_DONTCARE, cfi.FaceName); if (hf) { HFONT old_f =3D SelectObject(cdc, hf); if (GetGlyphIndicesW (cdc, replacement_char, 2, gi, GGI_MARK_NONEXISTING_GLYPHS) !=3D GDI_ERROR) { printf ("gi =3D %d %d\n", gi[0], gi[1]); if (gi[0] !=3D 0xffff) rp_idx =3D 0; } if (old_f) old_f =3D SelectObject (cdc, old_f); DeleteObject (hf); } } printf ("rp_idx =3D %d\n", rp_idx); return 0; } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D SNAP =3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Supposedly none of the fonts support 0xfffd: $ gcc -g -o cons cons.c -lgdi32 $ ./cons font Consolas gi =3D 65535 879 rp_idx =3D 1 $ ./cons font Lucida Console gi =3D 65535 620 rp_idx =3D 1 $ ./cons font Courier New gi =3D 65535 372 rp_idx =3D 1 So I'm still doing something wrong, apparently. Any hint? Thanks, Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --309evMHi/619oHyA Content-Type: application/pgp-signature; name="signature.asc" Content-length: 833 -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAluNmSQACgkQ9TYGna5E T6DxCg/9G//b+lsgskWgWqRdQzafXbHHLzfgWKbBPueCoe2NE1yuhokrC+zfvmw3 8s/h7VQ+O8ud6QYFmU60KbTLOAjYXSIlZB0H8pY020n8tlVHakwihuzLZ4XFeXPw Il1FX7vdLcUa3hMBxqW+jBI/pSlMJhz0v4H1rAsczNmGJ/XAAQYzL7TLD+lo4X7l rkZCykc/mPuLB7+mQK93P2u8SA0SSsHWezzFB14AbZJ/4t1jb0aJT/2nqclDlFh7 BD228vPdHc+0VzTpKLV3Y3p/gifLYVa1088TDxBWBBZi908aTHbKtSG2ipSKXs0b gZw5Cv/EPuyA46zgJuDokYH8TuhAQe1dyTNWDimUOcyHEYa40WyYlYEHfHEWbZbM KgDMToxQDjXjsLURLDa5lnJn1PTmFGsQilZfN5TfHCwxeQtBVkiJWNBKiwsUQEJz nMmdF3H3N6kfLb3VRdBYIa8mRn603FfrgETazbxw1FXeSXtE1iLqLFykpZoPoR4d tdK0miHnMRwMf84ogfMa3MrCyPMkjy7O+jVOYnJFRMvgVxO4lbfRPGdGZM8MkrLU DJHqIzrAEw5KT7oJoPysmJO2BRJxzIs3S9b4UX97uE2mwRCl0Eb7AoPFkffD1qnZ LwQLwOz9+UOiHc2U2l+8sZ56ZfjBCFbmJrLITY7F3u3BBSJkIxE= =iMCH -----END PGP SIGNATURE----- --309evMHi/619oHyA--