On Sat, 07 Mar 2020 01:32:40 +0900, Robert Pluim wrote: > > /* Don't use a color bitmap font unless its family is > explicitly specified. */ > if ((sym_traits & kCTFontTraitColorGlyphs) && NILP (family)) > continue; > > Yamamoto-san, Iʼm not sure I understand the rationale for excluding > colour fonts unless explicitly requested, could you elaborate? I wrote this part originally for the Mac port when I added the Variation Selectors 15 and 16 support in 2013. In the Mac port, the "Apple Color Emoji" font is specified as a fallback so text style is preferred for the characters having both text and emoji styles (IIRC, there was no concept of Emoji_Presentation=Yes at that time). The exceptions are VS16, Regional Indicators, and Emoji Modifiers, so as to avoid lots of font lookups until it reaches to the fallback one: (when (and (string-match "darwin\\([0-9]+\\)" system-configuration) (>= (string-to-number (match-string 1 system-configuration)) 11)) ;; Built on Mac OS X 10.7 or later. (let ((spec (font-spec :family "Apple Color Emoji" :registry "iso10646-1"))) (set-fontset-font t nil spec nil 'append) ;; Work around lots of font lookups in emoji compositions. (set-fontset-font t #xFE0F spec) ; Variation Selector 16 (set-fontset-font t '(#x1F1E6 . #x1F1FF) spec) ; Regional Indicator Syms (set-fontset-font t '(#x1F3FB . #x1F3FF) spec))) ; Emoji Modifiers There is another reason for assigning an Emoji font to VS16. I'll explain it later. The Mac port also extended composition-function-table so the composition rule can be a 4-element vector as well as the usual 3-element one: @@ -1966,7 +2012,8 @@ syms_of_composite (void) a function to call to compose that character. The element at index C in the table, if non-nil, is a list of -composition rules of this form: ([PATTERN PREV-CHARS FUNC] ...) +composition rules where each rule is a vector of the form [PATTERN +PREV-CHARS FUNC] or [PATTERN PREV-CHARS FUNC FONT-POS]. PATTERN is a regular expression which C and the surrounding characters must match. @@ -1983,6 +2030,10 @@ syms_of_composite (void) composition of the characters that match PATTERN. It is called with one argument GSTRING. +FONT-POS is an integer specifying the position of the character from +which the font object passed to FUNC as a part of GSTRING is obtained. +The value is relative to the position of C. + GSTRING is a template of a glyph-string to return. It is already filled with a proper header for the characters to compose, and glyphs corresponding to those characters one by one. The The value of FONT-POS is 0 for the entry for VS16, so the font for VS16, which is explicitly set to "Apple Color Emoji" as above, is used even if the font for the character preceeding VS16 is in text style. (set-char-table-range composition-function-table ?\uFE0F `([,regexp-keycap 1 mac-compose-gstring-for-variation-with-trailer 0] [,regexp-modified 1 mac-compose-gstring-for-variation-with-trailer 0] [,regexp-all 1 mac-compose-gstring-for-emoji-style-variation 0]))) (See https://bitbucket.org/mituharu/emacs-mac/src/83969d9b8c3f093341c294f0dfbe6dd98e58f70c/lisp/term/mac-win.el for the full code.) For VS15, the FONT-POS value is either 1 (so the font for U+20E3 is used for the keycap cases such as U+0023 U+FE0E U+20E3) or -1 (for non-keycap cases): (set-char-table-range composition-function-table ?\uFE0E `([,regexp-keycap 1 mac-compose-gstring-for-variation-with-trailer 1] [,regexp-modified 1 mac-compose-gstring-for-variation-with-trailer -1] [,regexp-all 1 mac-compose-gstring-for-text-style-variation -1])) Attached is a sample screenshot. YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp