[pango] Simplify hb_buffer_set_flags()



commit f0cb1dde12ab12411da2feb54025cf1fab306a68
Author: Behdad Esfahbod <behdad behdad org>
Date:   Thu Aug 10 19:50:16 2017 -0700

    Simplify hb_buffer_set_flags()
    
    From a 2014 HarfBuzz commit:
    
    commit 763e5466c0a03a7c27020e1e2598e488612529a7
    Author: Behdad Esfahbod <behdad behdad org>
    Date:   Sat Aug 2 16:17:44 2014 -0400
    
        Make it easier to use HB_BUFFER_FLAG_BOT/EOT
    
        Previously, we expected users to provide BOT/EOT flags when the
        text *segment* was at paragraph boundaries.  This meant that for
        clients that provide full paragraph to HarfBuzz (eg. Pango), they
        had code like this:
    
          hb_buffer_set_flags (hb_buffer,
                               (item_offset == 0 ? HB_BUFFER_FLAG_BOT : 0) |
                               (item_offset + item_length == paragraph_length ?
                                HB_BUFFER_FLAG_EOT : 0));
    
          hb_buffer_add_utf8 (hb_buffer,
                              paragraph_text, paragraph_length,
                              item_offset, item_length);
    
        After this change such clients can simply say:
    
          hb_buffer_set_flags (hb_buffer,
                               HB_BUFFER_FLAG_BOT | HB_BUFFER_FLAG_EOT);
    
          hb_buffer_add_utf8 (hb_buffer,
                              paragraph_text, paragraph_length,
                              item_offset, item_length);
    
        Ie, HarfBuzz itself checks whether the segment is at the beginning/end
        of the paragraph.  Clients that only pass item-at-a-time to HarfBuzz
        continue not setting any flags whatsoever.
    
        Another way to put it is: if there's pre-context text in the buffer,
        HarfBuzz ignores the BOT flag.  If there's post-context, it ignores
        EOT flag.

 pango/pangofc-shape.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
---
diff --git a/pango/pangofc-shape.c b/pango/pangofc-shape.c
index a18fa73..6ba7fb3 100644
--- a/pango/pangofc-shape.c
+++ b/pango/pangofc-shape.c
@@ -346,9 +346,7 @@ _pango_fc_shape (PangoFont           *font,
 #if HB_VERSION_ATLEAST(1,0,3)
   hb_buffer_set_cluster_level (hb_buffer, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
 #endif
-  hb_buffer_set_flags (hb_buffer,
-                      (item_offset == 0 ? HB_BUFFER_FLAG_BOT : 0) |
-                      (item_offset + item_length == paragraph_length ? HB_BUFFER_FLAG_EOT : 0));
+  hb_buffer_set_flags (hb_buffer, HB_BUFFER_FLAG_BOT | HB_BUFFER_FLAG_EOT);
 
   hb_buffer_add_utf8 (hb_buffer, paragraph_text, paragraph_length, item_offset, item_length);
 


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