Web lists-archives.com

Re: Cygwin fails to utilize Unicode replacement character




On Sep  3 15:15, Steven Penny wrote:
> On Mon, 3 Sep 2018 23:02:58, Corinna Vinschen wrote:
> > I can't. I only have a limited set of fonts available in the console.
> 
> http://superuser.com/questions/390933/add-font-cmd-window-choices/956818
> 
> > What I just did was calling the GetFontUnicodeRanges function
> > for each font, and it turns out that none of the fonts support
> > 0xfffd "REPLACEMENT CHARACTER", but all three support 0xfffc
> > "OBJECT REPLACEMENT CHARACTER".  I expanded the testcase to check
> > for this with GetGlyphIndicesW and, lo and behold, the result
> > makes sense.
> 
> Here is my code if it helps:
> 
>    #include <stdio.h>
>    #include <windows.h>
>    int main()
>    {
>      CONSOLE_FONT_INFOEX ta;
>      ta.cbSize = sizeof ta;
>      GetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), 0, &ta);
>      HDC wh = GetDC(0);
>      SelectObject(wh,
>        CreateFontW(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ta.FaceName));
>      WCHAR xr = 0xFFFD;
>      WORD zu[1];
>      GetGlyphIndicesW(wh, &xr, 1, zu, 1);
>      printf("%ls: %s\n", ta.FaceName, *zu == 0xFFFF ? "FAILURE" : "SUCCESS");
>    }

In how far does that add information to the code I posted in
https://cygwin.com/ml/cygwin/2018-09/msg00056.html ?

> Result:
> 
>    DejaVu Sans Mono: SUCCESS

Whereever you get DejaVu Sans Mono from.  My W10 console only allows to
specify a handful of fonts, Consolas, Courier New, Lucida, MS Gothic,
NSimSun, Raster Fonts, SimSun-ExtB.

>    Consolas: FAILURE
> 
> > On the other hand, during testing I saw a 0xfffd character printed for
> > these fonts.  None of them actually supports 0xfffd, so apparently the
> > Windows console already uses replacement fonts if possible.
> > 
> > I guess I just stop here and always print 0xfffd.  I seriously doubt
> > it makes sense to add so much code just to print a single char in a
> > border case.
> 
> this is not possible; most likely you were seeing the ".notdef glyph":
> 
> http://docs.microsoft.com/typography/opentype/spec/recom

Yeah, that's it then.  Whatever.  The fact that none of the default
fonts available for the console provide 0xfffd REPLACEMENT CHARACTER
doesn't really contribute to my willingness to add lots of code for
a border case.

We either keep 0xfffd now and the user gets the nodef glyph, or I revert
the patch and let the console print 0x2592 MEDIUM SHADE again.

Decision has to be made today.  I will release 2.11.1 tomorrow.


Corinna

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

Attachment: signature.asc
Description: PGP signature