Subject: bug#39482: 26.3; set-fontset-font with emacs charset does not work correctly

From: [email-masked]
Date: Sat, 08 Feb 2020 11:27:53 +0900

Eli Zaretskii <[email-masked]> writes:

>> From: [email-masked]
>> Date: Sat, 08 Feb 2020 00:11:23 +0900
>> 
>> (let* ((base "Courier New")
>>        (size 18)
>>        (un-spec "SimHei")
>>        (tc-spec '("MingLiU"   . "big5"))
>>        (sc-spec '("SimSun"    . "gb2312.1980"))
>>        (jp-spec '("MS Mincho" . "jisx0208"))
>>        (kr-spec '("BatangChe" . "ksc5601.1987"))
>>        )
>>   (set-charset-priority 'ascii)
>>   (set-frame-font (format "%s-%g" base size t))
>>   (set-frame-size nil 80 28)
>>   (set-fontset-font t '(#x80 . #x10FFFF) un-spec)
>>   (set-fontset-font t 'chinese-gb2312    sc-spec nil 'append)
>>   (set-fontset-font t 'big5              tc-spec nil 'append)
>>   (set-fontset-font t 'japanese-jisx0208 jp-spec nil 'append)
>>   (set-fontset-font t 'korean-ksc5601    kr-spec nil 'append)
>
> Why are you using 'append here?  AFAIU, that means the default fontset
> settings, which are set up in fontset.el, are used first, and your
> settings are only used as fallback, when the defaults fail to find a
> glyph for a charcater.  That could explain why you see what you see.
>
> Also, since we've already established that Uniscribe on Windows 10
> sometimes fails in strange ways, please switch to Emacs 27 with
> HarfBuzz, because otherwise investigating these problems could be a
> huge waste of our time for no good reason.  You can find a relatively
> recent build of the Emacs 27 snapshot here:
>
>   https://alpha.gnu.org/gnu/emacs/pretest/windows/emacs-27/
>
> Thanks.

I installed emacs-27.0.60-snapshot-emacs-27-2019-12-28-x86_64-installer.exe
and tested the same form. It looks like there is no difference.
Replacing 'append with 'prepend makes no difference.

#'setfontset-font does not work well if ADD argument is non-nil.
In the example below, dummy3 should be added for both 199 and 200,
but it is not added for 200.

(progn (set-fontset-font t 199 "dummy1")
       (set-fontset-font t 200 "dummy2")
       (set-fontset-font t '(199 . 200) "dummy3" nil 'append)
       (mapcar (lambda (c) (cons c (aref (fontset-info t) c)))
               '(199 200)))
=> ((199 ("-*-dummy1-*-*-*-*-*-*-*-*-*-*-*-*")
         ("-*-dummy3-*-*-*-*-*-*-*-*-*-*-*-*"))
    (200 ("-*-dummy2-*-*-*-*-*-*-*-*-*-*-*-*")))

>>        (kr-spec '("BatangChe" . "ksc5601.1987"))

Replacing "ksc5601.1987" with "ksc5601.1987-0" makes most of
'korean-ksc5601 characters displayed with BatangChe font.
(Some characters are displayed with SimHei.)

I think "ksc5601", "ksc5601*" or "ksc5601.1987" should be accepted.