[ft] Add hb_ft_font_changed()

When the font size or variations settings on underlying FT_Face change,
one can call hb_ft_font_changed() and continue using hb_font created using
hb_ft_font_create().

Fixes https://github.com/behdad/harfbuzz/issues/559

New API:
hb_ft_font_changed()
diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt
index 6d86d94..06a78f5 100644
--- a/docs/harfbuzz-sections.txt
+++ b/docs/harfbuzz-sections.txt
@@ -291,6 +291,7 @@
 hb_ft_face_create_referenced
 hb_ft_font_create
 hb_ft_font_create_referenced
+hb_ft_font_changed
 hb_ft_font_get_face
 hb_ft_font_set_load_flags
 hb_ft_font_get_load_flags
diff --git a/src/hb-ft.cc b/src/hb-ft.cc
index c560b21..83af994 100644
--- a/src/hb-ft.cc
+++ b/src/hb-ft.cc
@@ -610,6 +610,19 @@
   font = hb_font_create (face);
   hb_face_destroy (face);
   _hb_ft_font_set_funcs (font, ft_face, false);
+  hb_ft_font_changed (font);
+  return font;
+}
+
+void
+hb_ft_font_changed (hb_font_t *font)
+{
+  if (font->destroy != _hb_ft_font_destroy)
+    return;
+
+  hb_ft_font_t *ft_font = (hb_ft_font_t *) font->user_data;
+  FT_Face ft_face = ft_font->ft_face;
+
   hb_font_set_scale (font,
 		     (int) (((uint64_t) ft_face->size->metrics.x_scale * (uint64_t) ft_face->units_per_EM + (1u<<15)) >> 16),
 		     (int) (((uint64_t) ft_face->size->metrics.y_scale * (uint64_t) ft_face->units_per_EM + (1u<<15)) >> 16));
@@ -640,8 +653,6 @@
     free (mm_var);
   }
 #endif
-
-  return font;
 }
 
 /**
diff --git a/src/hb-ft.h b/src/hb-ft.h
index dc8ef85..94013ee 100644
--- a/src/hb-ft.h
+++ b/src/hb-ft.h
@@ -116,7 +116,13 @@
 HB_EXTERN int
 hb_ft_font_get_load_flags (hb_font_t *font);
 
-/* Makes an hb_font_t use FreeType internally to implement font functions. */
+/* Call when size or variations settings on underlying FT_Face change. */
+HB_EXTERN void
+hb_ft_font_changed (hb_font_t *font);
+
+/* Makes an hb_font_t use FreeType internally to implement font functions.
+ * Note: this internally creates an FT_Face.  Use it when you create your
+ * hb_face_t using hb_face_create(). */
 HB_EXTERN void
 hb_ft_font_set_funcs (hb_font_t *font);