[util] Add --ft-load-flags
authorBehdad Esfahbod <behdad@behdad.org>
Tue, 11 Sep 2018 12:21:15 +0000 (14:21 +0200)
committerBehdad Esfahbod <behdad@behdad.org>
Tue, 11 Sep 2018 12:23:35 +0000 (14:23 +0200)
Useful for performance testing.

Not hooked to cairo yet.  Just changes shaping, not rasterization.

util/helper-cairo.cc
util/options.cc
util/options.hh

index 3eaf90a..5914ab7 100644 (file)
@@ -125,7 +125,7 @@ helper_cairo_create_scaled_font (const font_options_t *font_opts)
     }
 #endif
 
-    cairo_face = cairo_ft_font_face_create_for_ft_face (ft_face, 0);
+    cairo_face = cairo_ft_font_face_create_for_ft_face (ft_face, font_opts->ft_load_flags);
   }
   cairo_matrix_t ctm, font_matrix;
   cairo_font_options_t *font_options;
index 2902807..0ab16d6 100644 (file)
@@ -556,6 +556,7 @@ font_options_t::add_options (option_parser_t *parser)
     {"font-ppem",      0, 0, G_OPTION_ARG_CALLBACK,    (gpointer) &parse_font_ppem,    "Set x,y pixels per EM (default: 0; disabled)", "1/2 integers"},
     {"font-ptem",      0, 0, G_OPTION_ARG_DOUBLE,      &this->ptem,                    "Set font point-size (default: 0; disabled)",   "point-size"},
     {"font-funcs",     0, 0, G_OPTION_ARG_STRING,      &this->font_funcs,              text,                                           "impl"},
+    {"ft-load-flags",  0, 0, G_OPTION_ARG_INT,         &this->ft_load_flags,           "Set FreeType load-flags (default: 2)",         "integer"},
     {nullptr}
   };
   parser->add_group (entries,
@@ -717,6 +718,9 @@ font_options_t::get_font (void) const
     }
   }
   set_font_funcs (font);
+#ifdef HAVE_FREETYPE
+  hb_ft_font_set_load_flags (font, ft_load_flags);
+#endif
 
   return font;
 }
index 3457909..456e0a0 100644 (file)
@@ -454,6 +454,7 @@ struct font_options_t : option_group_t
     face_index = 0;
     font_size_x = font_size_y = default_font_size;
     font_funcs = nullptr;
+    ft_load_flags = 2;
 
     blob = nullptr;
     font = nullptr;
@@ -484,6 +485,7 @@ struct font_options_t : option_group_t
   mutable double font_size_x;
   mutable double font_size_y;
   char *font_funcs;
+  int ft_load_flags;
 
   private:
   mutable hb_font_t *font;