From: Thomas Wolff <towo@towo.net>
To: cygwin@cygwin.com
Subject: Re: Cygwin fails to utilize Unicode replacement character
Date: Mon, 03 Sep 2018 18:20:00 -0000 [thread overview]
Message-ID: <515ad501-3cb4-0236-ce03-0b7d9286bd24@towo.net> (raw)
In-Reply-To: <e3207913-84d8-901a-b5ff-020dd86eed61@towo.net>
Am 03.09.2018 um 19:56 schrieb Thomas Wolff:
> Am 03.09.2018 um 19:16 schrieb Corinna Vinschen:
>> On Sep 3 18:34, Thomas Wolff wrote:
>>> Am 03.09.2018 um 16:59 schrieb Corinna Vinschen:
>>>> On Sep 3 14:46, Corinna Vinschen wrote:
>>>>> On Sep 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:
>>>>>>
>>>>>> 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.
>>>>>
>>>>> Not sure how feasible that is, but it doesn't seem to be overly
>>>>> complicated. I'm just looking into a solution for the Cygwin
>>>>> console.
>>>> Only, I can't get this working. In theory the GDI function
>>>> GetGlyphIndicesW is supposed to allow checking if a certain character
>>>> exists. But I'm getting a weird result. This code:
>>>>
>>>> Â Â Â static const wchar_t replacement_char[2] =
>>>> Â Â Â Â Â {
>>>> Â Â Â Â Â Â Â 0xfffd, /* REPLACEMENT CHARACTER */
>>>> Â Â Â Â Â Â Â 0x2592Â /* MEDIUM SHADE */
>>>> Â Â Â Â Â };
>>>> Â Â Â HWND cwnd = GetConsoleWindow ();
>>>> Â Â Â HDC cdc = GetDC (cwnd);
>>>> Â Â Â int rp_idx = 0;
>>>> Â Â Â WORD gi = 0;
>>>> Â Â Â DWORD ret = GetGlyphIndicesW (cdc, replacement_char, 1, &gi,
>>>> GGI_MARK_NONEXISTING_GLYPHS);
>>>> Â Â Â if (ret != GDI_ERROR && gi == 0xffff)
>>>> Â Â Â Â Â rp_idx = 1;
>>>>
>>>> always sets rp_idx to 1 when called from inside the Cygwin DLL,
>>>> independently of the actual console font. 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.
>>>>
>>>> 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?
>> ¯\_(ã)_/¯
> 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
 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.
Thomas
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
next prev parent reply other threads:[~2018-09-03 18:20 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-01 16:13 Steven Penny
2018-09-01 18:11 ` Thomas Wolff
2018-09-01 18:46 ` Steven Penny
2018-09-01 21:07 ` Thomas Wolff
2018-09-01 19:40 ` Corinna Vinschen
2018-09-01 21:50 ` Doug Henderson
2018-09-01 22:49 ` Steven Penny
2018-09-02 8:07 ` Thomas Wolff
2018-09-02 12:51 ` Steven Penny
2018-09-03 12:46 ` Corinna Vinschen
2018-09-03 14:59 ` Corinna Vinschen
2018-09-03 16:34 ` Thomas Wolff
2018-09-03 17:17 ` Corinna Vinschen
2018-09-03 17:56 ` Thomas Wolff
2018-09-03 18:20 ` Thomas Wolff [this message]
2018-09-03 19:14 ` Corinna Vinschen
2018-09-03 20:27 ` Corinna Vinschen
2018-09-03 20:42 ` Thomas Wolff
2018-09-03 21:03 ` Corinna Vinschen
2018-09-03 22:15 ` Steven Penny
2018-09-04 6:06 ` Brian Inglis
2018-09-04 9:00 ` Corinna Vinschen
2018-09-04 11:40 ` Steven Penny
2018-09-05 7:55 ` Corinna Vinschen
2018-09-05 9:22 ` Thomas Wolff
2018-09-05 11:58 ` Steven Penny
2018-09-05 13:18 ` Marco Atzeri
2018-09-05 15:20 ` Andrey Repin
2018-09-05 15:58 ` Corinna Vinschen
2018-09-05 20:15 ` Corinna Vinschen
2018-09-06 1:35 ` Steven Penny
2018-09-06 7:01 ` Corinna Vinschen
2018-09-07 8:20 ` Corinna Vinschen
2018-09-07 10:34 ` Thomas Wolff
2018-09-07 11:29 ` Corinna Vinschen
2018-09-07 11:42 ` Thomas Wolff
2018-09-07 11:51 ` Thomas Wolff
2018-09-07 11:54 ` Corinna Vinschen
2018-09-07 16:22 ` Brian Inglis
2018-09-07 16:48 ` Brian Inglis
2018-09-07 17:01 ` Marco Atzeri
2018-09-07 18:21 ` Corinna Vinschen
2018-09-07 18:20 ` Corinna Vinschen
2018-09-05 13:35 ` Andrey Repin
2018-09-05 14:04 ` Houder
2018-09-05 15:05 ` Andrey Repin
2018-09-04 12:50 ` David Macek
2018-09-04 14:18 ` Thomas Wolff
2018-09-04 14:46 ` David Macek
2018-09-04 18:20 ` Steven Penny
2018-09-04 18:41 ` Thomas Wolff
2018-09-04 19:50 ` Andrey Repin
2018-09-04 19:53 ` Steven Penny
2018-09-04 21:43 ` Thomas Wolff
2018-09-04 23:29 ` Steven Penny
2018-09-04 20:40 ` Brian Inglis
2018-09-05 8:32 ` Corinna Vinschen
2018-09-04 13:05 ` Andrey Repin
2018-10-04 0:25 ` Steven Penny
2018-09-03 16:05 ` Brian Inglis
2018-09-04 19:59 ` Doug Henderson
2018-09-04 21:05 ` Steven Penny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=515ad501-3cb4-0236-ce03-0b7d9286bd24@towo.net \
--to=towo@towo.net \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).