Remove FT_Done_MM_Var() workaround

FT_Done_MM_Var() has been around since FreeType 2.9 from early 2018. Use
it directly to simplify code instead of assuming that it may not exist.
The default build, which uses a bundled FreeType, is up-to-date, so the
issue of FT_Done_MM_Var() being missing could only happen if someone is
building the code with an old system FreeType.

Bug: pdfium:1400
Change-Id: I7642de8884969484ff90a4cf865acc67e07e419b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/107510
Reviewed-by: Dominik Röttsches <drott@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp
index a2a44df..8b5f4fc 100644
--- a/core/fxge/cfx_font.cpp
+++ b/core/fxge/cfx_font.cpp
@@ -45,30 +45,6 @@
   float m_CoordUnit;
 };
 
-// TODO(crbug.com/pdfium/1400): When FT_Done_MM_Var() is more likely to be
-// available to all users in the future, remove FreeMMVar() and use
-// FT_Done_MM_Var() directly.
-//
-// Use weak symbols to check if FT_Done_MM_Var() is available at runtime.
-#if !BUILDFLAG(IS_WIN)
-extern "C" __attribute__((weak)) decltype(FT_Done_MM_Var) FT_Done_MM_Var;
-#endif
-
-void FreeMMVar(FXFT_FaceRec* rec, FXFT_MM_VarPtr variation_desc) {
-#if BUILDFLAG(IS_WIN)
-  // Assume `use_system_freetype` GN var is never set on Windows.
-  constexpr bool has_ft_done_mm_var_func = true;
-#else
-  static const bool has_ft_done_mm_var_func = !!FT_Done_MM_Var;
-#endif
-  if (has_ft_done_mm_var_func) {
-    FT_Done_MM_Var(CFX_GEModule::Get()->GetFontMgr()->GetFTLibrary(),
-                   variation_desc);
-  } else {
-    FXFT_Free(rec, variation_desc);
-  }
-}
-
 FX_RECT FXRectFromFTPos(FT_Pos left, FT_Pos top, FT_Pos right, FT_Pos bottom) {
   return FX_RECT(pdfium::base::checked_cast<int32_t>(left),
                  pdfium::base::checked_cast<int32_t>(top),
@@ -682,7 +658,8 @@
     FT_Pos max_width = FXFT_Get_Glyph_HoriAdvance(m_Face->GetRec()) * 1000 /
                        FXFT_Get_Face_UnitsPerEM(m_Face->GetRec());
     if (max_width == min_width) {
-      FreeMMVar(m_Face->GetRec(), pMasters);
+      FT_Done_MM_Var(CFX_GEModule::Get()->GetFontMgr()->GetFTLibrary(),
+                     pMasters);
       return;
     }
     FT_Pos param = min_param + (max_param - min_param) *
@@ -690,7 +667,7 @@
                                    (max_width - min_width);
     coords[1] = param;
   }
-  FreeMMVar(m_Face->GetRec(), pMasters);
+  FT_Done_MM_Var(CFX_GEModule::Get()->GetFontMgr()->GetFTLibrary(), pMasters);
   FT_Set_MM_Design_Coordinates(m_Face->GetRec(), 2, coords);
 }
 
diff --git a/core/fxge/freetype/fx_freetype.h b/core/fxge/freetype/fx_freetype.h
index 3da0372..e09ca61 100644
--- a/core/fxge/freetype/fx_freetype.h
+++ b/core/fxge/freetype/fx_freetype.h
@@ -76,7 +76,6 @@
 #define FXFT_Get_MM_Axis_Min(axis) (axis).minimum
 #define FXFT_Get_MM_Axis_Max(axis) (axis).maximum
 #define FXFT_Get_MM_Axis_Def(axis) (axis).def
-#define FXFT_Free(face, p) (face)->memory->free((face)->memory, p)
 #define FXFT_Get_Glyph_Outline(face) &((face)->glyph->outline)
 #define FXFT_Get_Glyph_Bitmap(face) (face)->glyph->bitmap
 #define FXFT_Get_Bitmap_Width(bitmap) (bitmap).width