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

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:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=IfRBBoWwF0KTCl4/
v2VVVFetYaH3tXCYar2jhPM2HtzeHOhJuadcaZhWALQmgASfo0rthF2/bE+JUdId
Wv+j3PodBnn6xNBOnQJjh8/ULgKlFbKIaj6EezIN0qQLHRw/T/ilXiISpasYIom0
eh7YKPwGpCYbcUuJ3crP3wcwYrE=
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:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=wY8CyL6iGOZwsMY1iRCD2c
QuL0I=; b=PFLKZAPmIUwOgD2QAAo+x8Ruo9syBXMhMDOGFVVtUdmdfQd3FbIIaZ
rM20231hZ8bnHKJNsS61XRkj39TDIu7I551cx/w9/v8W4OM45KlenC51Wd7lVc8m
UGis27rVlAzu1/vlhxmQZPrWmZKc47qFlkdPC53Sbydx0cuRXN53I=
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=-0.8 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 spammy=H*M:0236
X-HELO: mout.kundenserver.de
Subject: Re: Cygwin fails to utilize Unicode replacement character
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>
From: Thomas Wolff <towo AT towo DOT net>
Message-ID: <515ad501-3cb4-0236-ce03-0b7d9286bd24@towo.net>
Date: Mon, 3 Sep 2018 20:20:40 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1
MIME-Version: 1.0
In-Reply-To: <e3207913-84d8-901a-b5ff-020dd86eed61@towo.net>
X-IsSubscribed: yes
Note-from-DJ: This may be spam

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

- Raw text -


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