diff options
| author | Khaled Hosny | 2018-12-22 11:02:40 +0200 |
|---|---|---|
| committer | Khaled Hosny | 2018-12-22 11:02:40 +0200 |
| commit | 8e424aa961adc4e4ab75e9ffb91532e7f4aab835 (patch) | |
| tree | a643ee8b3d539b5eaa1ee5b65b88523d3369bea6 /src | |
| parent | 47d1cdc2a5522142fcee226f05038601bffcbd41 (diff) | |
| download | emacs-8e424aa961adc4e4ab75e9ffb91532e7f4aab835.tar.gz emacs-8e424aa961adc4e4ab75e9ffb91532e7f4aab835.zip | |
Subclass default HarfBuzz Unicode functions
Instead of creating new functions from scratch, subclass the default
implementation and override the selected functions we want/can
override. (Bug#33729)
Diffstat (limited to 'src')
| -rw-r--r-- | src/ftfont.c | 47 |
1 files changed, 14 insertions, 33 deletions
diff --git a/src/ftfont.c b/src/ftfont.c index ba905ed4639..179e4e17987 100644 --- a/src/ftfont.c +++ b/src/ftfont.c | |||
| @@ -2769,48 +2769,29 @@ uni_mirroring (hb_unicode_funcs_t *funcs, hb_codepoint_t ch, void *user_data) | |||
| 2769 | return bidi_mirror_char (ch); | 2769 | return bidi_mirror_char (ch); |
| 2770 | } | 2770 | } |
| 2771 | 2771 | ||
| 2772 | static hb_script_t | ||
| 2773 | uni_script (hb_unicode_funcs_t *funcs, hb_codepoint_t ch, void *user_data) | ||
| 2774 | { | ||
| 2775 | Lisp_Object script = CHAR_TABLE_REF (Vchar_script_table, ch); | ||
| 2776 | |||
| 2777 | if (SYMBOLP (script)) | ||
| 2778 | { | ||
| 2779 | /* FIXME: from_string wants an ISO 15924 script tag here. */ | ||
| 2780 | return hb_script_from_string (SSDATA (SYMBOL_NAME (script)), | ||
| 2781 | SBYTES (SYMBOL_NAME (script))); | ||
| 2782 | } | ||
| 2783 | |||
| 2784 | return HB_SCRIPT_INVALID; | ||
| 2785 | } | ||
| 2786 | |||
| 2787 | static hb_bool_t | ||
| 2788 | uni_compose (hb_unicode_funcs_t *funcs, hb_codepoint_t a, hb_codepoint_t b, | ||
| 2789 | hb_codepoint_t *ab, void *user_data) | ||
| 2790 | { | ||
| 2791 | /* FIXME: implement */ | ||
| 2792 | return false; | ||
| 2793 | } | ||
| 2794 | |||
| 2795 | static hb_bool_t | ||
| 2796 | uni_decompose (hb_unicode_funcs_t *funcs, hb_codepoint_t ab, hb_codepoint_t *a, | ||
| 2797 | hb_codepoint_t *b, void *user_data) | ||
| 2798 | { | ||
| 2799 | /* FIXME: implement */ | ||
| 2800 | return false; | ||
| 2801 | } | ||
| 2802 | |||
| 2803 | static hb_unicode_funcs_t * | 2772 | static hb_unicode_funcs_t * |
| 2804 | get_hb_unicode_funcs (void) | 2773 | get_hb_unicode_funcs (void) |
| 2805 | { | 2774 | { |
| 2806 | hb_unicode_funcs_t *funcs = hb_unicode_funcs_create (NULL); | 2775 | /* Subclass HarfBuzz's default Unicode functions and override functions that |
| 2776 | * use data Emacs can provide. This way changing Emacs data is reflected in | ||
| 2777 | * the shaped output. | ||
| 2778 | */ | ||
| 2779 | hb_unicode_funcs_t *funcs = hb_unicode_funcs_create (hb_unicode_funcs_get_default ()); | ||
| 2807 | 2780 | ||
| 2808 | hb_unicode_funcs_set_combining_class_func (funcs, uni_combining, NULL, NULL); | 2781 | hb_unicode_funcs_set_combining_class_func (funcs, uni_combining, NULL, NULL); |
| 2809 | hb_unicode_funcs_set_general_category_func (funcs, uni_general, NULL, NULL); | 2782 | hb_unicode_funcs_set_general_category_func (funcs, uni_general, NULL, NULL); |
| 2810 | hb_unicode_funcs_set_mirroring_func (funcs, uni_mirroring, NULL, NULL); | 2783 | hb_unicode_funcs_set_mirroring_func (funcs, uni_mirroring, NULL, NULL); |
| 2811 | hb_unicode_funcs_set_script_func (funcs, uni_script, NULL, NULL); | 2784 | |
| 2785 | /* FIXME: I don't know how to get Unicode character composition and | ||
| 2786 | * decomposition from Emacs. | ||
| 2812 | hb_unicode_funcs_set_compose_func (funcs, uni_compose, NULL, NULL); | 2787 | hb_unicode_funcs_set_compose_func (funcs, uni_compose, NULL, NULL); |
| 2813 | hb_unicode_funcs_set_decompose_func (funcs, uni_decompose, NULL, NULL); | 2788 | hb_unicode_funcs_set_decompose_func (funcs, uni_decompose, NULL, NULL); |
| 2789 | */ | ||
| 2790 | |||
| 2791 | /* Emacs own script mapping for characters differs from Unicode, so we want | ||
| 2792 | * to keep the default HarfBuzz's implementation here. | ||
| 2793 | hb_unicode_funcs_set_script_func (funcs, uni_script, NULL, NULL); | ||
| 2794 | */ | ||
| 2814 | 2795 | ||
| 2815 | return funcs; | 2796 | return funcs; |
| 2816 | } | 2797 | } |