On Mon, Dec 18, 2017 at 1:39 PM, Behdad Esfahbod <beh...@behdad.org> wrote:
> Hi Werner, > > Is there any chance you can modify FT_Set_Var_Design_Coordinates() to > detect when the set face coordinates are not changed and shortcircuit out > early? Currently, if one calls that function too often (say, for every > glyph load, which is how we want to call it in cairo), it causes font > metrics and autohinter reinitialization even if the coordinates didn't > change. Can you please fix that? Matthias and I are hacking together this > week, trying to finish font variations support in the Pango stack. > > Thanks, > > -- > behdad > http://behdad.org/ > Here is a quick hack to demonstrate the idea
diff --git a/src/base/ftmm.c b/src/base/ftmm.c index e0131ece3..1f2be46f8 100644 --- a/src/base/ftmm.c +++ b/src/base/ftmm.c @@ -24,6 +24,7 @@ #include FT_SERVICE_MULTIPLE_MASTERS_H #include FT_SERVICE_METRICS_VARIATIONS_H +#include <alloca.h> /*************************************************************************/ /* */ @@ -201,6 +202,25 @@ if ( !error ) { error = FT_ERR( Invalid_Argument ); + if ( service_mm->get_var_design ) + { + FT_Fixed *my_coords; + FT_UInt i; + + my_coords = alloca (sizeof(FT_Fixed) * num_coords); + + error = service_mm->get_var_design( face, num_coords, my_coords ); + if (error) + return error; + + for (i = 0; i < num_coords; i++) + { + if (coords[i] != my_coords[i]) + break; + } + if (i == num_coords) + return 0; + } if ( service_mm->set_var_design ) error = service_mm->set_var_design( face, num_coords, coords ); }
_______________________________________________ Freetype-devel mailing list Freetype-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/freetype-devel