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=GkEGRbkkkZPFbJWt ArfzZCB3zJUggnsQT7/DOGs/hj4pMMeiUKIQmZIo1zOLGccwiIOYNK4Db5goTxhF VjQSt9hkKD2x7ZQ0r5bU+CcztZI/Qj9kSjOwYZeNOWrbPJKgR0ENCSbBZgxYoPD+ e10eNGA0adiX4o7Jhznq7ZM7pVU= 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=RrAlD2kTultHUa+b4N2bef GKOZc=; b=MaPR36ErAxGk2IhManUXvtEhfkcrD1RnEjpcLyXoMmi36UJ1I/y253 9+MidR0kKHybAK2BnVXSuOsWn6s+UAxDJUX2wUmStxpmo42e2k7j3VBFg3Nr9jJV 1/OFbMmjS7Cv0le2usyd/no9CuwwZCvLWr+u5iqZ6DIkosLMHzQeU= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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.1 required=5.0 tests=AWL,BAYES_00,KAM_ASCII_DIVIDERS,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 spammy=dejavu, DejaVu 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> <515ad501-3cb4-0236-ce03-0b7d9286bd24 AT towo DOT net> <20180903191437 DOT GZ6350 AT calimero DOT vinschen DOT de> <20180903202716 DOT GA6350 AT calimero DOT vinschen DOT de> From: Thomas Wolff Message-ID: <1575af94-78b3-681a-7dc1-0932969ac3e4@towo.net> Date: Mon, 3 Sep 2018 22:42:28 +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: <20180903202716.GA6350@calimero.vinschen.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Am 03.09.2018 um 22:27 schrieb Corinna Vinschen: > 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  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? >>>>> ¯\_(ツ)_/¯ >>>> 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. >> 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. > Well, it still doesn't work for me. I now have the following code: > > ===================== SNIP ====================== > #include > #include > #include > > int > main () > { > static const wchar_t replacement_char[2] = > { > 0xfffd, /* REPLACEMENT CHARACTER */ > 0x2592 /* MEDIUM SHADE */ > }; > > CONSOLE_FONT_INFOEX cfi; > HWND cwnd = GetConsoleWindow (); > HDC cdc = GetDC (cwnd); > int rp_idx = 1; > WORD gi[2] = { 0, 0 }; > > memset (&cfi, 0, sizeof cfi); > cfi.cbSize = sizeof cfi; > if (GetCurrentConsoleFontEx (GetStdHandle (STD_OUTPUT_HANDLE), FALSE, &cfi)) > { > printf ("font %ls\n", cfi.FaceName); > HFONT hf = 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 = SelectObject(cdc, hf); > if (GetGlyphIndicesW (cdc, replacement_char, 2, gi, > GGI_MARK_NONEXISTING_GLYPHS) != GDI_ERROR) > { > printf ("gi = %d %d\n", gi[0], gi[1]); > if (gi[0] != 0xffff) > rp_idx = 0; > } > if (old_f) > old_f = SelectObject (cdc, old_f); > DeleteObject (hf); > } > } > > printf ("rp_idx = %d\n", rp_idx); > return 0; > } > ===================== SNAP ====================== > > Supposedly none of the fonts support 0xfffd: > > $ gcc -g -o cons cons.c -lgdi32 > $ ./cons > font Consolas > gi = 65535 879 > rp_idx = 1 > $ ./cons > font Lucida Console > gi = 65535 620 > rp_idx = 1 > $ ./cons > font Courier New > gi = 65535 372 > rp_idx = 1 > > So I'm still doing something wrong, apparently. Any hint? Test with a font that has the glyph; those 3 don't. Try DejaVu. -- 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