[HarfBuzz] harfbuzz: Branch 'master' - 2 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Aug 6 11:45:57 PDT 2013


 src/hb-private.hh   |   14 ++++++++++---
 src/hb-uniscribe.cc |   54 +++++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 54 insertions(+), 14 deletions(-)

New commits:
commit 38d5c58d23fce38221689cda98cea1c3e42ed615
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Aug 6 14:45:36 2013 -0400

    [uniscribe] Half-support user features
    
    Turning features on globally works now.

diff --git a/src/hb-uniscribe.cc b/src/hb-uniscribe.cc
index 5176abd..7f32770 100644
--- a/src/hb-uniscribe.cc
+++ b/src/hb-uniscribe.cc
@@ -659,11 +659,27 @@ retry:
 
 #undef MAX_ITEMS
 
-  int *range_char_counts = NULL;
-  TEXTRANGE_PROPERTIES **range_properties = NULL;
-  int range_count = 0;
-  if (num_features) {
-    /* TODO setup ranges */
+  hb_auto_array_t<OPENTYPE_FEATURE_RECORD> feature_records;
+  hb_auto_array_t<TEXTRANGE_PROPERTIES> range_records;
+  hb_auto_array_t<TEXTRANGE_PROPERTIES*> range_properties;
+  hb_auto_array_t<int> range_char_counts;
+  if (num_features)
+  {
+    for (unsigned int i = 0; i < num_features; i++)
+    {
+      OPENTYPE_FEATURE_RECORD *record = feature_records.push ();
+      if (likely (record))
+      {
+	record->tagFeature = hb_uint32_swap (features[i].tag);
+	record->lParameter = features[i].value;
+      }
+    }
+    TEXTRANGE_PROPERTIES *range_record = range_records.push ();
+    if (likely (range_record))
+    {
+      range_record->potfRecords = feature_records.array;
+      range_record->cotfRecords = feature_records.len;
+    }
   }
 
   OPENTYPE_TAG language_tag = hb_uint32_swap (hb_ot_tag_from_language (buffer->props.language));
@@ -677,15 +693,31 @@ retry:
     unsigned int chars_offset = items[i].iCharPos;
     unsigned int item_chars_len = items[i + 1].iCharPos - chars_offset;
 
+    if (num_features)
+    {
+      /* XXX We currently ignore feature ranges and apply all features to all characters.
+       * Also, turning off a previously turned-on feature doesn't work.  We have to do
+       * that part ourselves and pass the active features down to Uniscribe. */
+
+      range_char_counts.shrink (0);
+      range_properties.shrink (0);
+
+      range_char_counts.push (); /* Can't fail. */
+      range_properties.push (); /* Can't fail. */
+
+      range_char_counts.array[0] = item_chars_len;
+      range_properties.array[0] = range_records.array;
+    }
+
   retry_shape:
     hr = funcs->ScriptShapeOpenType (font_data->hdc,
 				     &font_data->script_cache,
 				     &items[i].a,
 				     script_tags[i],
 				     language_tag,
-				     range_char_counts,
-				     range_properties,
-				     range_count,
+				     range_char_counts.array,
+				     range_properties.array,
+				     range_properties.len,
 				     wchars + chars_offset,
 				     item_chars_len,
 				     glyphs_size - glyphs_offset,
@@ -725,9 +757,9 @@ retry:
 				     &items[i].a,
 				     script_tags[i],
 				     language_tag,
-				     range_char_counts,
-				     range_properties,
-				     range_count,
+				     range_char_counts.array,
+				     range_properties.array,
+				     range_properties.len,
 				     wchars + chars_offset,
 				     log_clusters + chars_offset,
 				     char_props + chars_offset,
commit 639afdc690c681a302080239a1967ce735ba5be5
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Aug 6 14:28:12 2013 -0400

    Minor

diff --git a/src/hb-private.hh b/src/hb-private.hh
index 13465c6..4152e27 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -321,14 +321,22 @@ struct hb_prealloced_array_t
   inline void pop (void)
   {
     len--;
-    /* TODO: shrink array if needed */
+  }
+
+  inline void remove (unsigned int i)
+  {
+     if (unlikely (i >= len))
+       return;
+     memmove (static_cast<void *> (&array[i]),
+	      static_cast<void *> (&array[i + 1]),
+	      (len - i - 1) * sizeof (Type));
+     len--;
   }
 
   inline void shrink (unsigned int l)
   {
      if (l < len)
        len = l;
-    /* TODO: shrink array if needed */
   }
 
   template <typename T>
@@ -376,7 +384,7 @@ struct hb_prealloced_array_t
   }
 };
 
-#define HB_AUTO_ARRAY_PREALLOCED 64
+#define HB_AUTO_ARRAY_PREALLOCED 16
 template <typename Type>
 struct hb_auto_array_t : hb_prealloced_array_t <Type, HB_AUTO_ARRAY_PREALLOCED>
 {



More information about the HarfBuzz mailing list