Subject: Re: bug#20140: 24.4; M17n shaper output rejected

From: Eli Zaretskii <[email-masked]>
Date: Sun, 13 Feb 2022 18:04:11 +0200

> Date: Sat, 5 Feb 2022 22:52:51 +0000
> From: Richard Wordingham <[email-masked]>
> Cc: Lars Ingebrigtsen <[email-masked]>, [email-masked]
> 
> You're welcome to include my composition rules.

Thanks.  I started with your code:

> (defvar tai-tham-composable-pattern
>   (let ((table
> 	 ;; C is letters, independent vowels, digits, punctuation and symbols.
> 	 '(("C" . "[\u1A20-\u1A54\u1A80-\u1A89\u1A90-\u1A99\u1AA0-\u1AAD]")
> 	   ("M" . "[\u1A55-\u1A57\u1A59-\u1A5E\u1A61-\u1A7C\u1A7F]"); Mark
> 	   ("H" . "\u1A60") ; sakot
>            ("S" . "[\u1A75-\u1A7C]") ; Marks commuting with sakot
> 	   ("N" . "\u1A58"))) ; mai kang lai
> 	(basic_syllable "C\\(N*\\(M\\|HS*C\\)\\)*")
>         (regexp "X\\(N\\(X\\)?\\)*H?")) ; X is basic syllable
>     (let ((case-fold-search nil))
>       (setq regexp (replace-regexp-in-string "X" basic_syllable regexp t t))
>       (dolist (elt table)
> 	(setq regexp (replace-regexp-in-string (car elt) (cdr elt)
> 					       regexp t t))))
>     regexp))
> 
> (let ((elt (list (vector tai-tham-composable-pattern 0 'font-shape-gstring)
> 		 (vector "." 0 'font-shape-gstring)
> 		 )))
>   (set-char-table-range composition-function-table '(#x1A20 . #x1AAD) elt))

But that didn't seem to work well enough: e.g., some marks in your
"sample text" didn't combine with letters, as I think they should.
Then I tried this simplistic setting:

  (set-char-table-range composition-function-table
			'(#x1a20 . #x1aaf)
			(list (vector "[\u1a20-\u1aaf]+" 0 'font-shape-gstring)))

and it worked much better, including passing a small number of the
tests from your renderer test page that I threw on Emacs.  This is on
MS-Windows with Emacs 29 and HarfBuzz 2.4.0 (which is not even the
latest release of HarfBuzz), and with the A Tai Tham KH New V3 font.

Any reason not to use the above simple setup for Tai Tham text
composition?

I needed a couple more additions to Emacs to make Tai Tham support
work OOTB: for example, script-representative-chars lacked an entry
for Tai Tham, and the default fontset needed an addition.  (And on
MS-Windows, one needs to run the w32-find-non-USB-fonts magic once, to
notice the newly installed Tai Tham font.)

Other than that, assuming the above setting of
composition-function-table is okay, we are ready to officially add Tai
Tham to scripts supported by Emacs.

Btw, is there a way to get all the examples from your
https://wrdingham.co.uk/lanna/renderer_test.htm as a UTF-8 encoded
text file?  I'd like to test the Emacs rendering with all of the
examples, but copy-pasting each example separately from the browser is
not my idea of useful time investment.  So if you could provide the
examples as a downloadable text file, I'd appreciate.