[HarfBuzz] harfbuzz: Branch 'master'

Behdad Esfahbod behdad at kemper.freedesktop.org
Mon Nov 26 04:02:43 PST 2012


 src/hb-ot-layout-common-private.hh |   36 ++++++++++++++++++++++++++++++++++--
 src/hb-ot-layout.cc                |   31 +++++++++++++++++++++++++++++++
 src/hb-ot-layout.h                 |    5 +++++
 3 files changed, 70 insertions(+), 2 deletions(-)

New commits:
commit f54cce3c6a0432268ce159dbe6c5c6b7f583b87a
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Nov 26 14:02:31 2012 +0200

    [OTLayout] Implement 'size' feature

diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 3a97f06..0b753b8 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -248,6 +248,33 @@ struct Script
 
 typedef RecordListOf<Script> ScriptList;
 
+struct FeatureParamsSize
+{
+  inline bool sanitize (hb_sanitize_context_t *c) {
+    TRACE_SANITIZE (this);
+    return TRACE_RETURN (c->check_struct (this));
+  }
+
+  USHORT params[5];
+  public:
+  DEFINE_SIZE_STATIC (10);
+};
+
+struct FeatureParams
+{
+  /* Note: currently the only feature with params is 'size', so we hardcode
+   * the length of the table to that of the FeatureParamsSize. */
+
+  inline bool sanitize (hb_sanitize_context_t *c) {
+    TRACE_SANITIZE (this);
+    return TRACE_RETURN (c->check_struct (this));
+  }
+
+  union {
+  FeatureParamsSize size;
+  } u;
+  DEFINE_SIZE_STATIC (10);
+};
 
 struct Feature
 {
@@ -260,12 +287,17 @@ struct Feature
 					  unsigned int *lookup_tags /* OUT */) const
   { return lookupIndex.get_indexes (start_index, lookup_count, lookup_tags); }
 
+  inline const FeatureParams &get_feature_params (void) const
+  { return this+featureParams; }
+
   inline bool sanitize (hb_sanitize_context_t *c) {
     TRACE_SANITIZE (this);
-    return TRACE_RETURN (c->check_struct (this) && lookupIndex.sanitize (c));
+    return TRACE_RETURN (c->check_struct (this) && lookupIndex.sanitize (c) &&
+			 featureParams.sanitize (c, this));
   }
 
-  Offset	featureParams;	/* Offset to Feature Parameters table (if one
+  OffsetTo<FeatureParams>
+		 featureParams;	/* Offset to Feature Parameters table (if one
 				 * has been defined for the feature), relative
 				 * to the beginning of the Feature Table; = Null
 				 * if not required */
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 11d3060..2572c00 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -639,3 +639,34 @@ hb_ot_layout_position_finish (hb_font_t *font, hb_buffer_t *buffer, hb_bool_t ze
 {
   OT::GPOS::position_finish (font, buffer, zero_width_attached_marks);
 }
+
+hb_bool_t
+hb_ot_layout_position_get_size (hb_face_t *face,
+				uint16_t  *data /* OUT, 5 items */)
+{
+  const OT::GPOS &gpos = _get_gpos (face);
+  unsigned int script_index;
+  gpos.find_script_index (HB_OT_TAG_DEFAULT_SCRIPT, &script_index);
+  const OT::LangSys &l = gpos.get_script (script_index).get_lang_sys (HB_OT_TAG_DEFAULT_LANGUAGE);
+
+  unsigned int num_features = l.get_feature_count ();
+  for (unsigned int i = 0; i < num_features; i++) {
+    unsigned int f_index = l.get_feature_index (i);
+
+    if (HB_TAG ('s','i','z','e') == gpos.get_feature_tag (f_index))
+    {
+      const OT::Feature &f = gpos.get_feature (f_index);
+      const OT::FeatureParams &params = f.get_feature_params ();
+
+      for (unsigned int i = 0; i < 5; i++)
+	data[i] = params.u.size.params[i];
+
+      return true;
+    }
+  }
+
+  for (unsigned int i = 0; i < 5; i++)
+    data[i] = 0;
+
+  return false;
+}
diff --git a/src/hb-ot-layout.h b/src/hb-ot-layout.h
index ed7298c..adb483c 100644
--- a/src/hb-ot-layout.h
+++ b/src/hb-ot-layout.h
@@ -277,6 +277,11 @@ Xhb_ot_layout_lookup_position (hb_font_t            *font,
 			      hb_glyph_position_t  *positions /* IN / OUT */);
 #endif
 
+/* Optical 'size' feature info.  Returns true if found. */
+hb_bool_t
+hb_ot_layout_position_get_size (hb_face_t *face,
+				uint16_t  *data /* OUT, 5 items */);
+
 
 HB_END_DECLS
 



More information about the HarfBuzz mailing list