Imported Upstream version 2.4.0
[platform/upstream/harfbuzz.git] / src / hb-ot-hdmx-table.hh
index 95229c5..953ccab 100644 (file)
@@ -57,16 +57,19 @@ struct DeviceRecord
     }
 
     unsigned int len () const
-    { return this->subset_plan->glyphs.length; }
+    { return this->subset_plan->num_output_glyphs (); }
 
-    const HBUINT8* operator [] (unsigned int i) const
+    const HBUINT8* operator [] (unsigned int new_gid) const
     {
-      if (unlikely (i >= len ())) return nullptr;
-      hb_codepoint_t gid = this->subset_plan->glyphs [i];
+      if (unlikely (new_gid >= len ())) return nullptr;
 
-      if (gid >= sizeDeviceRecord - DeviceRecord::min_size)
+      hb_codepoint_t old_gid;
+      if (!this->subset_plan->old_gid_for_new_gid (new_gid, &old_gid))
+        return &Null(HBUINT8);
+
+      if (old_gid >= sizeDeviceRecord - DeviceRecord::min_size)
         return nullptr;
-      return &(this->source_device_record->widthsZ[gid]);
+      return &(this->source_device_record->widthsZ[old_gid]);
     }
   };
 
@@ -140,7 +143,7 @@ struct hdmx
 
     this->version.set (source_hdmx->version);
     this->numRecords.set (source_hdmx->numRecords);
-    this->sizeDeviceRecord.set (DeviceRecord::get_size (plan->glyphs.length));
+    this->sizeDeviceRecord.set (DeviceRecord::get_size (plan->num_output_glyphs ()));
 
     for (unsigned int i = 0; i < source_hdmx->numRecords; i++)
     {
@@ -156,7 +159,7 @@ struct hdmx
 
   static size_t get_subsetted_size (const hdmx *source_hdmx, hb_subset_plan_t *plan)
   {
-    return min_size + source_hdmx->numRecords * DeviceRecord::get_size (plan->glyphs.length);
+    return min_size + source_hdmx->numRecords * DeviceRecord::get_size (plan->num_output_glyphs ());
   }
 
   bool subset (hb_subset_plan_t *plan) const