delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2018/09/03/15:14:53

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=nZThhGIOmgupL2/ME5fOI9rnBlWXRYcnccN9tSquhdxrf7IKVgKaf
MlHPcFugLYlKsnp2XtUpkkaeVHNebPs4AElYRHXohvYf4MdOkcSzvO9o7+KmobcC
ijdUvJPhEr1xDkN+Jpc/mHforxqOlkr5IK+NVWT/15WWvIC2UvOyMk=
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=SMvfwwGRHS3HsVTbCtSaQxEJSBI=; b=lX6EWBTWe7HuVy7cR02uSUZef9St
2kQXPvkRM5nMoPYFzDvJrC5Tr8u+mk/Ah+HCfZq5BR7N46RC0t//sexdJr2+IB5F
kqDpx7UFkKTtWB8EDnleWCFUJoCOu4vMgxtAIOzjvmz/o+eRddizXxraQUG5cdCm
n3irEJIRR4Qej4I=
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=-101.2 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=meantime
X-HELO: mout.kundenserver.de
Date: Mon, 3 Sep 2018 21:14:37 +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: <20180903191437.GZ6350@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>
MIME-Version: 1.0
In-Reply-To: <515ad501-3cb4-0236-ce03-0b7d9286bd24@towo.net>
User-Agent: Mutt/1.9.2 (2017-12-15)

--0ywUhQCikZ2Y3PNw
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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:
> > > > > On Sep=C2=A0 3 14:46, Corinna Vinschen wrote:
> > > > > > On Sep=C2=A0 2 05:51, Steven Penny wrote:
> > > > > > > On Sun, 2 Sep 2018 10:07:10, Thomas Wolff wrote:
> > > > > > > > Actually, the width problem I suggested in my
> > > > > > > > other response (and even
> > > > > > > > referring to the wrong character) does not apply as mintty =
enforces
> > > > > > > > proper width in that case.
> > > > > > > > Also, even with fonts that do not provide the
> > > > > > > > glyph, you will usually
> > > > > > > > still see it by the Windows font fallback mechanism.
> > > > > > > > Shall I make it configurable?
> > > > > > > your call - here are the possible resolutions - in
> > > > > > > order of my preference:
> > > > > > >=20
> > > > > > > 1. Change the default to U+FFFD with no option
> > > > > > > 2. Change the default to U+FFFD with option to change
> > > > > > > 3. Leave default as is with option to change
> > > > > > Ideally we could check if the current font supports a visual
> > > > > > representation of 0xfffd and if not, fall back to 0x2592.
> > > > > >=20
> > > > > > Not sure how feasible that is, but it doesn't seem to be overly
> > > > > > complicated.=C2=A0 I'm just looking into a solution for the Cyg=
win
> > > > > > console.
> > > > > Only, I can't get this working.=C2=A0 In theory the GDI function
> > > > > GetGlyphIndicesW is supposed to allow checking if a certain chara=
cter
> > > > > exists.=C2=A0 But I'm getting a weird result.=C2=A0 This code:
> > > > >=20
> > > > > =C2=A0=C2=A0=C2=A0 static const wchar_t replacement_char[2] =3D
> > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 {
> > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0xfffd, /* REPLACEMENT=
 CHARACTER */
> > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0x2592=C2=A0 /* MEDIUM=
 SHADE */
> > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 };
> > > > > =C2=A0=C2=A0=C2=A0 HWND cwnd =3D GetConsoleWindow ();
> > > > > =C2=A0=C2=A0=C2=A0 HDC cdc =3D GetDC (cwnd);
> > > > > =C2=A0=C2=A0=C2=A0 int rp_idx =3D 0;
> > > > > =C2=A0=C2=A0=C2=A0 WORD gi =3D 0;
> > > > > =C2=A0=C2=A0=C2=A0 DWORD ret =3D GetGlyphIndicesW (cdc, replaceme=
nt_char, 1, &gi,
> > > > > GGI_MARK_NONEXISTING_GLYPHS);
> > > > > =C2=A0=C2=A0=C2=A0 if (ret !=3D GDI_ERROR && gi =3D=3D 0xffff)
> > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rp_idx =3D 1;
> > > > >=20
> > > > > always sets rp_idx to 1 when called from inside the Cygwin DLL,
> > > > > independently of the actual console font.=C2=A0 And, here's the
> > > > > really weird
> > > > > thing, it always sets rp_idx to 0 when called directly from an
> > > > > application, likewise independently of the actual console font.
> > > > >=20
> > > > > 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.

Thanks but I don't know how to get a HFONT for the current console font.

In the meantime I figured out why my GetCurrentConsoleFontEx call
failed with error 87:

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.

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.


Thanks,
Corinna

--=20
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--0ywUhQCikZ2Y3PNw
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAluNiBwACgkQ9TYGna5E
T6Cgsg/+J+Zx8aC6Md1IONifaeNXSJdlcMuBLZsfDdHTvnskg2oQzGX6iiYaU/05
sfS4SWHXD0KzjDk9KufDo8FnHl2V8KawhLR5GXzBfDNi9Ll9/nOPxta4wTs5jhBD
VRNJJCkpbqXvWsVVnSeWHuFdXENPS9jPcSkPRAM9AWfkQtrvRRBDYumJ+2xdB0r1
nPLhVtX1RN7DZp7gFS7MykHY3fM5SVp1ZnvXiH/sB+MJjO2hkyQ5pYydGiQ3df40
G8Nm3YZ+o+CCVspKWxLCwtGTuSVWhLUehGXoLxA3OHJ+OCBOeViWwn+tE9qJ16Hu
1PVf+lYBmWPfEzSkI77RDB4wuHSeGbZFJeFGhhEX+PvcjUvY7KxEWlgi1ghpFYqJ
ql7Bk6MWE5/mLCOXhsTR21cMnu+EcraDKTDaeazRLqQiUIApY8Cd7L3hxhX2OByJ
gt5NibHWxOEJESe9UvdO5geEaK8L4EgV+md7DWpMGs6d0F+djVGwR9oTSMAJ1NRD
8WU7pSTpxLDpoIVKvf50m2MCOsIvvSaCc72wuvjttSU7vY+LbITrlqoLBIDsO/A8
IhrTEx4WdPQ0NjgIgFqOJRhtxfA+Qa6bmhkv/twHGtqSfc7dd8eG6q6lP3oWrQ2W
y+WykPHH3VyAsLUCn3J7pP2WFmxpmMZLv33KQAfu3A/VurZjTpM=
=0Qr6
-----END PGP SIGNATURE-----

--0ywUhQCikZ2Y3PNw--

- Raw text -


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