delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2018/09/03/16:27:33

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; q=dns; s=
default; b=B2vKOCZ6SNwiszU7k/PD+kXR/jviwu3NEJKKSvyG1521qK0qYid5v
SXxxoLhPrqoxKwika/xVPvucLmL4SJO/ENoMtTg8KAtfoNnRG7O5xoUeSDeiJ+RX
G6KCxb5vjIfqsFrNq86/OgeBDUac9GeevCA/rcKr5wymSUftvDRyL4=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; s=default;
bh=QwZP+jEtNBQlycHAZPA2Bb6f6+0=; b=w7dS/OHavRPtQd1v6ohYWBEnGf/m
gwxTOkOFLKgGZIa8lfspqjOOawryvmCnT2spF9gRhp87HnMmz2QSHa+fEDOJ/P8V
o+Mu2jaizvuFuO4D1loop6PbgV/pu8IWRa+D2z9gYbYq1poTXRacMd+KIKm2bP4P
Bd2B6xC3eq4RulM=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
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
Date: Mon, 3 Sep 2018 22:27:16 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Cygwin fails to utilize Unicode replacement character
Message-ID: <20180903202716.GA6350@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <7942b18e-96bf-a824-4dac-82715d87af55 AT towo DOT net> <5b8bdcc4 DOT 1c69fb81 DOT 84d1a DOT e6b9 AT mx DOT google DOT com> <20180903124616 DOT GT6350 AT calimero DOT vinschen DOT de> <20180903145919 DOT GU6350 AT calimero DOT vinschen DOT de> <126ebbde-2432-f19b-6c5c-fe61f31e4647 AT towo DOT net> <20180903171659 DOT GY6350 AT calimero DOT vinschen DOT de> <e3207913-84d8-901a-b5ff-020dd86eed61 AT towo DOT net> <515ad501-3cb4-0236-ce03-0b7d9286bd24 AT towo DOT net> <20180903191437 DOT GZ6350 AT calimero DOT vinschen DOT de>
MIME-Version: 1.0
In-Reply-To: <20180903191437.GZ6350@calimero.vinschen.de>
User-Agent: Mutt/1.9.2 (2017-12-15)

--309evMHi/619oHyA
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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 <windows.h>
#include <stdio.h>
#include <wchar.h>

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"

-----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--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019