Description: Use new hb-subset api with harfbuzz >= 2.9.0 in order to prepeare for removal of legacy API in 3.0
Origin: upstream, r24696 + r24707
Bug: https://bugs.scribus.net/view.php?id=16635
Acked-By: Mattia Rizzolo <mattia@debian.org>
Last-Update: 2021-09-19

--- a/scribus/fonts/sfnt.cpp
+++ b/scribus/fonts/sfnt.cpp
@@ -1256,16 +1256,30 @@
 
 		for (int i = 0; i < cids.count(); ++i)
 			hb_set_add(glyphSet, cids.at(i));
-	
+
+#if HB_VERSION_ATLEAST(2, 9, 0)
+		uint32_t subsetFlags = (uint32_t) hb_subset_input_get_flags(hbSubsetInput.get());
+		subsetFlags |= HB_SUBSET_FLAGS_RETAIN_GIDS;
+		subsetFlags &= ~HB_SUBSET_FLAGS_NO_HINTING;
+		subsetFlags |= HB_SUBSET_FLAGS_NAME_LEGACY;
+		hb_subset_input_set_flags(hbSubsetInput.get(), subsetFlags);
+#else
 		hb_subset_input_set_retain_gids(hbSubsetInput.get(), true);
 		hb_subset_input_set_drop_hints(hbSubsetInput.get(), false);
 #if HB_VERSION_ATLEAST(2, 6, 5)
 		hb_subset_input_set_name_legacy(hbSubsetInput.get(), true);
 #endif
+#endif
 
+#if HB_VERSION_ATLEAST(2, 9, 0)
+		QScopedPointer<hb_face_t, HbFaceDeleter> hbSubsetFace(hb_subset_or_fail(hbFullFace.get(), hbSubsetInput.get()));
+		if (hbSubsetFace.isNull())
+			return QByteArray();
+#else
 		QScopedPointer<hb_face_t, HbFaceDeleter> hbSubsetFace(hb_subset(hbFullFace.get(), hbSubsetInput.get()));
 		if (hbSubsetFace.isNull())
 			return QByteArray();
+#endif
 
 		QScopedPointer<hb_blob_t, HbBlobDeleter> hbSubsetBlob(hb_face_reference_blob(hbSubsetFace.get()));
 		if (hbSubsetBlob.isNull())
