[ft] Handle negative x_scale / y_scale
diff --git a/src/hb-ft.cc b/src/hb-ft.cc
index 7e75ba9..f57f566 100644
--- a/src/hb-ft.cc
+++ b/src/hb-ft.cc
@@ -99,6 +99,9 @@
   if (unlikely (FT_Get_Advance (ft_face, glyph, load_flags, &v)))
     return 0;
 
+  if (font->x_scale < 0)
+    v = -v;
+
   return (v + (1<<9)) >> 10;
 }
 
@@ -530,14 +533,19 @@
 
   FT_Select_Charmap (ft_face, FT_ENCODING_UNICODE);
 
-  assert (font->y_scale >= 0);
   FT_Set_Char_Size (ft_face,
-		    font->x_scale, font->y_scale,
+		    abs (font->x_scale), abs (font->y_scale),
 		    0, 0);
 #if 0
 		    font->x_ppem * 72 * 64 / font->x_scale,
 		    font->y_ppem * 72 * 64 / font->y_scale);
 #endif
+  if (font->x_scale < 0 || font->y_scale < 0)
+  {
+    FT_Matrix matrix = { font->x_scale < 0 ? -1 : +1, 0,
+			  0, font->y_scale < 0 ? -1 : +1};
+    FT_Set_Transform (ft_face, &matrix, NULL);
+  }
 
   ft_face->generic.data = blob;
   ft_face->generic.finalizer = (FT_Generic_Finalizer) _release_blob;