From 5e63b9ef263d519ffe12d1471874d2442eb3a591 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Sat, 2 Jun 2018 23:13:06 -0400
Subject: [PATCH] Load existing font file.

Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
 R/load_showtext_fonts.R | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/R/load_showtext_fonts.R b/R/load_showtext_fonts.R
index 1d86255..23449b1 100644
--- a/R/load_showtext_fonts.R
+++ b/R/load_showtext_fonts.R
@@ -31,26 +31,9 @@ load_default_font = function()
     if(already_loaded("wqy-microhei"))
         return(invisible(NULL))
 
-    ## Extract font file
-    font_file = system.file("fonts", "wqy-microhei.ttc.zip", package = "showtextdb")
-    out_dir = tempdir()
-    out_file = file.path(out_dir, "wqy-microhei.ttc")
-    if(!file.exists(out_file))
-    {
-        ## Test for write permission
-        if(file.access(out_dir, mode = 2) < 0)
-        {
-            msg = paste("the temporary directory ", out_dir,
-                        " does not have write permission,\n",
-                        "failed to load the 'WenQuanYi Micro Hei' font", sep = "")
-            warning(msg)
-            return(invisible(NULL))
-        }
-        utils::unzip(font_file, exdir = out_dir, overwrite = FALSE)
-    }
-
     ## Add font to sysfonts
-    sysfonts::font_add("wqy-microhei", out_file)
+    font_file = system.file("fonts", "wqy-microhei.ttc", package = "showtextdb")
+    sysfonts::font_add("wqy-microhei", font_file)
 
     invisible(NULL)
 }
-- 
2.25.4

