From 55bbb98f5c5a89230127d6b998a6e23e634b5d0e Mon Sep 17 00:00:00 2001
From: Behdad Esfahbod <behdad@behdad.org>
Date: Tue, 1 Aug 2017 09:17:02 +0200
Subject: [PATCH 077/132] [truetype] Fix loading of named instances.

* src/truetype/ttgxvar.c (TT_Get_MM_Var): Preserve file position
while loading the `avar' table.
---
 ChangeLog               |  7 +++++++
 include/freetype/ftmm.h |  2 +-
 src/truetype/ttgxvar.c  | 11 ++++++++++-
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 68458362e..df42b3bfd 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -2136,8 +2136,16 @@
         goto Exit;
 
       if ( fvar_head.instanceCount && !face->blend->avar_loaded )
+      {
+        FT_ULong  offset = FT_STREAM_POS();
+
+
         ft_var_load_avar( face );
 
+        if ( FT_STREAM_SEEK( offset ) )
+          goto Exit;
+      }
+
       ns  = mmvar->namedstyle;
       nsc = face->blend->normalized_stylecoords;
       for ( i = 0; i < fvar_head.instanceCount; i++, ns++ )
@@ -2171,7 +2179,7 @@
         SFNT_Service  sfnt = (SFNT_Service)face->sfnt;
 
         FT_Int   found, dummy1, dummy2;
-        FT_UInt  strid = 0xFFFFFFFFUL;
+        FT_UInt  strid = ~0U;
 
 
         /* the default instance is missing in array the   */
-- 
2.13.5

