diff options
| author | Eli Zaretskii | 2018-12-29 16:35:09 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2018-12-29 16:35:09 +0200 |
| commit | 48776b70115edf3775df19d80f734048dadff198 (patch) | |
| tree | 10a7e72a45bbbdf8dbfed4afce59fc9a5b975110 /src/macfont.m | |
| parent | 1a80b5d9b8cfa0e523b596db5d1e7e6074dbee46 (diff) | |
| download | emacs-48776b70115edf3775df19d80f734048dadff198.tar.gz emacs-48776b70115edf3775df19d80f734048dadff198.zip | |
Provide text directionality and language to HarfBuzz shaper
* lisp/language/tv-util.el (tai-viet-composition-function):
* lisp/language/ethio-util.el (ethio-composition-function):
* lisp/language/japanese.el (compose-gstring-for-variation-glyph):
* lisp/language/thai-util.el (thai-composition-function):
* lisp/language/misc-lang.el (arabic-shape-gstring):
* lisp/language/lao-util.el (lao-composition-function):
* lisp/language/hebrew.el (hebrew-shape-gstring):
* lisp/composite.el (compose-gstring-for-graphic)
(compose-gstring-for-dotted-circle, auto-compose-chars)
(compose-gstring-for-terminal): Accept 2nd argument DIRECTION; all
callers changed.
* src/composite.c (composition_reseat_it): Call
auto-composition-function with one more argument DIRECTION.
(syms_of_composite) <auto-composition-function>: Update the doc
string.
* src/ftfont.c (ftfont_shape_by_hb): Compute language and
direction, and set buffer properties accordingly.
* src/composite.c (autocmp_chars):
* src/w32uniscribe.c (uniscribe_shape):
* src/xftfont.c (xftfont_shape):
* src/ftfont.c (ftfont_shape, ftfont_shape_by_hb):
* src/font.c (Ffont_shape_gstring): Accept an additional argument
DIRECTION.
* src/macfont.m (lgstring_direction): New enum.
(mac_font_shape_1, mac_screen_font_shape, mac_font_shape):
Accept an additional argument specifying text direction. All
callers changed.
* src/font.c (syms_of_font): New symbols QL2R and QR2L.
* src/font.h (shape): Accept new argument DIRECTION. All
implementations changed. (Bug#33729)
(ftfont_shape): Update prototype.
Diffstat (limited to 'src/macfont.m')
| -rw-r--r-- | src/macfont.m | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/macfont.m b/src/macfont.m index d137648937c..ee6c1737269 100644 --- a/src/macfont.m +++ b/src/macfont.m | |||
| @@ -38,6 +38,12 @@ Original author: YAMAMOTO Mitsuharu | |||
| 38 | 38 | ||
| 39 | #include <libkern/OSByteOrder.h> | 39 | #include <libkern/OSByteOrder.h> |
| 40 | 40 | ||
| 41 | /* Values for `dir' argument to shaper functions. */ | ||
| 42 | enum lgstring_direction | ||
| 43 | { | ||
| 44 | DIR_R2L = -1, DIR_UNKNOWN = 0, DIR_L2R = 1, | ||
| 45 | }; | ||
| 46 | |||
| 41 | static double mac_font_get_advance_width_for_glyph (CTFontRef, CGGlyph); | 47 | static double mac_font_get_advance_width_for_glyph (CTFontRef, CGGlyph); |
| 42 | static CGRect mac_font_get_bounding_rect_for_glyph (CTFontRef, CGGlyph); | 48 | static CGRect mac_font_get_bounding_rect_for_glyph (CTFontRef, CGGlyph); |
| 43 | static CFArrayRef mac_font_create_available_families (void); | 49 | static CFArrayRef mac_font_create_available_families (void); |
| @@ -48,7 +54,8 @@ static Boolean mac_font_descriptor_supports_languages (CTFontDescriptorRef, | |||
| 48 | CFArrayRef); | 54 | CFArrayRef); |
| 49 | static CFStringRef mac_font_create_preferred_family_for_attributes (CFDictionaryRef); | 55 | static CFStringRef mac_font_create_preferred_family_for_attributes (CFDictionaryRef); |
| 50 | static CFIndex mac_font_shape (CTFontRef, CFStringRef, | 56 | static CFIndex mac_font_shape (CTFontRef, CFStringRef, |
| 51 | struct mac_glyph_layout *, CFIndex); | 57 | struct mac_glyph_layout *, CFIndex, |
| 58 | enum lgstring_direction); | ||
| 52 | static CFArrayRef mac_font_copy_default_descriptors_for_language (CFStringRef); | 59 | static CFArrayRef mac_font_copy_default_descriptors_for_language (CFStringRef); |
| 53 | static CFStringRef mac_font_copy_default_name_for_charset_and_languages (CFCharacterSetRef, CFArrayRef); | 60 | static CFStringRef mac_font_copy_default_name_for_charset_and_languages (CFCharacterSetRef, CFArrayRef); |
| 54 | #if USE_CT_GLYPH_INFO | 61 | #if USE_CT_GLYPH_INFO |
| @@ -317,7 +324,8 @@ mac_screen_font_get_metrics (ScreenFontRef font, CGFloat *ascent, | |||
| 317 | 324 | ||
| 318 | static CFIndex | 325 | static CFIndex |
| 319 | mac_font_shape_1 (NSFont *font, NSString *string, | 326 | mac_font_shape_1 (NSFont *font, NSString *string, |
| 320 | struct mac_glyph_layout *glyph_layouts, CFIndex glyph_len) | 327 | struct mac_glyph_layout *glyph_layouts, CFIndex glyph_len, |
| 328 | enum lgstring_direction dir) | ||
| 321 | { | 329 | { |
| 322 | NSUInteger i; | 330 | NSUInteger i; |
| 323 | CFIndex result = 0; | 331 | CFIndex result = 0; |
| @@ -581,11 +589,11 @@ mac_font_shape_1 (NSFont *font, NSString *string, | |||
| 581 | static CFIndex | 589 | static CFIndex |
| 582 | mac_screen_font_shape (ScreenFontRef font, CFStringRef string, | 590 | mac_screen_font_shape (ScreenFontRef font, CFStringRef string, |
| 583 | struct mac_glyph_layout *glyph_layouts, | 591 | struct mac_glyph_layout *glyph_layouts, |
| 584 | CFIndex glyph_len) | 592 | CFIndex glyph_len, enum lgstring_direction dir) |
| 585 | { | 593 | { |
| 586 | return mac_font_shape_1 ([(NSFont *)font printerFont], | 594 | return mac_font_shape_1 ([(NSFont *)font printerFont], |
| 587 | (NSString *) string, | 595 | (NSString *) string, |
| 588 | glyph_layouts, glyph_len); | 596 | glyph_layouts, glyph_len, dir); |
| 589 | } | 597 | } |
| 590 | 598 | ||
| 591 | static CGColorRef | 599 | static CGColorRef |
| @@ -2916,7 +2924,7 @@ macfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 2916 | } | 2924 | } |
| 2917 | 2925 | ||
| 2918 | static Lisp_Object | 2926 | static Lisp_Object |
| 2919 | macfont_shape (Lisp_Object lgstring) | 2927 | macfont_shape (Lisp_Object lgstring, Lisp_Object direction) |
| 2920 | { | 2928 | { |
| 2921 | struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring)); | 2929 | struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring)); |
| 2922 | struct macfont_info *macfont_info = (struct macfont_info *) font; | 2930 | struct macfont_info *macfont_info = (struct macfont_info *) font; |
| @@ -2966,12 +2974,18 @@ macfont_shape (Lisp_Object lgstring) | |||
| 2966 | kCFAllocatorNull); | 2974 | kCFAllocatorNull); |
| 2967 | if (string) | 2975 | if (string) |
| 2968 | { | 2976 | { |
| 2977 | enum lgstring_direction dir = DIR_UNKNOWN; | ||
| 2978 | |||
| 2979 | if (EQ (direction, QL2R)) | ||
| 2980 | dir = DIR_L2R; | ||
| 2981 | else if (EQ (direction, QR2L)) | ||
| 2982 | dir = DIR_R2L; | ||
| 2969 | glyph_layouts = alloca (sizeof (struct mac_glyph_layout) * glyph_len); | 2983 | glyph_layouts = alloca (sizeof (struct mac_glyph_layout) * glyph_len); |
| 2970 | if (macfont_info->screen_font) | 2984 | if (macfont_info->screen_font) |
| 2971 | used = mac_screen_font_shape (macfont_info->screen_font, string, | 2985 | used = mac_screen_font_shape (macfont_info->screen_font, string, |
| 2972 | glyph_layouts, glyph_len); | 2986 | glyph_layouts, glyph_len, dir); |
| 2973 | else | 2987 | else |
| 2974 | used = mac_font_shape (macfont, string, glyph_layouts, glyph_len); | 2988 | used = mac_font_shape (macfont, string, glyph_layouts, glyph_len, dir); |
| 2975 | CFRelease (string); | 2989 | CFRelease (string); |
| 2976 | } | 2990 | } |
| 2977 | 2991 | ||
| @@ -3652,7 +3666,8 @@ mac_font_create_line_with_string_and_font (CFStringRef string, | |||
| 3652 | 3666 | ||
| 3653 | static CFIndex | 3667 | static CFIndex |
| 3654 | mac_font_shape (CTFontRef font, CFStringRef string, | 3668 | mac_font_shape (CTFontRef font, CFStringRef string, |
| 3655 | struct mac_glyph_layout *glyph_layouts, CFIndex glyph_len) | 3669 | struct mac_glyph_layout *glyph_layouts, CFIndex glyph_len, |
| 3670 | lgstring_direction dir) | ||
| 3656 | { | 3671 | { |
| 3657 | CFIndex used, result = 0; | 3672 | CFIndex used, result = 0; |
| 3658 | CTLineRef ctline = mac_font_create_line_with_string_and_font (string, font); | 3673 | CTLineRef ctline = mac_font_create_line_with_string_and_font (string, font); |