emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] harfbuzz 066a2b4: Always set explicit HarfBuzz buffer dire


From: Khaled Hosny
Subject: [Emacs-diffs] harfbuzz 066a2b4: Always set explicit HarfBuzz buffer direction
Date: Sat, 5 Jan 2019 16:04:01 -0500 (EST)

branch: harfbuzz
commit 066a2b4914592478153983b587a36d226061dd89
Author: Khaled Hosny <address@hidden>
Commit: Khaled Hosny <address@hidden>

    Always set explicit HarfBuzz buffer direction
    
    If no direction was given by the caller, I assume the text will be drawn
    left to right, if this is not the case then callers must provide
    sensible direction. Letting HarfBuzz guess the direction is not
    appropriate since shaping and drawing must use the same direction.
    
    Also move hb_buffer_guess_segment_properties() call to the end, so it
    only guessing unset properties, until we completely get rid of it.
---
 src/ftfont.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/ftfont.c b/src/ftfont.c
index 5a8adfd..c266287 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -2836,23 +2836,20 @@ ftfont_shape_by_hb (Lisp_Object lgstring, FT_Face 
ft_face, hb_font_t *hb_font,
   hb_buffer_set_content_type (hb_buffer, HB_BUFFER_CONTENT_TYPE_UNICODE);
   hb_buffer_set_cluster_level (hb_buffer, 
HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
 
-  /* Set the default properties for when they cannot be determined
-     below.  */
-  hb_buffer_guess_segment_properties (hb_buffer);
-  hb_direction_t dir = HB_DIRECTION_INVALID;
+  /* If the caller didn't provide a meaningful DIRECTION, default to L2R. */
+  hb_direction_t dir = HB_DIRECTION_LTR;
   if (EQ (direction, QL2R))
     dir = HB_DIRECTION_LTR;
   else if (EQ (direction, QR2L))
     dir = HB_DIRECTION_RTL;
-  /* If the caller didn't provide a meaningful DIRECTION, let HarfBuzz
-     guess it.  */
-  if (dir != HB_DIRECTION_INVALID)
-    hb_buffer_set_direction (hb_buffer, dir);
+  hb_buffer_set_direction (hb_buffer, dir);
+
   /* Leave the script determination to HarfBuzz, until Emacs has a
      better idea of the script of LGSTRING.  FIXME. */
 #if 0
   hb_buffer_set_script (hb_buffer, XXX);
 #endif
+
   /* FIXME: This can only handle the single global language, which
      normally comes from the locale.  In addition, if
      current-iso639-language is a list, we arbitrarily use the first
@@ -2869,6 +2866,10 @@ ftfont_shape_by_hb (Lisp_Object lgstring, FT_Face 
ft_face, hb_font_t *hb_font,
                                                       SBYTES (lang_str)));
     }
 
+  /* Guess the default properties for when they cannot be determined
+     above. FIXME: drop once script handling is fixed above. */
+  hb_buffer_guess_segment_properties (hb_buffer);
+
   if (!hb_shape_full (hb_font, hb_buffer, NULL, 0, NULL))
     return Qnil;
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]