Init package

This commit is contained in:
misaka00251 2022-07-20 18:58:49 +08:00
parent e922328744
commit 4411696d74
No known key found for this signature in database
GPG Key ID: 4AA100DC964EDE26
3 changed files with 124 additions and 0 deletions

View File

@ -0,0 +1,46 @@
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

78
R-showtextdb.spec Normal file
View File

@ -0,0 +1,78 @@
%global packname showtextdb
%global packver 3.0
%global rlibdir %{_datadir}/R/library
# No network for OBS.
%bcond_with network
Name: R-%{packname}
Version: 3.0
Release: 1
Summary: Font Files for the 'showtext' Package
License: ASL 2.0
URL: https://CRAN.R-project.org/package=%{packname}
Source0: https://cran.r-project.org/src/contrib/%{packname}_%{packver}.tar.gz
Patch0001: 0001-Load-existing-font-file.patch
BuildArch: noarch
Requires: wqy-microhei-fonts
BuildRequires: R-devel
BuildRequires: tex(latex)
BuildRequires: wqy-microhei-fonts
BuildRequires: R-sysfonts >= 0.7
BuildRequires: R-utils
BuildRequires: R-curl
%description
Providing font files that can be used by the 'showtext' package.
%prep
%setup -q -c -n %{packname}
pushd %{packname}
rm inst/AUTHORS inst/COPYRIGHTS
%patch0001 -p1
popd
%build
%install
mkdir -p %{buildroot}%{rlibdir}
%{_bindir}/R CMD INSTALL -l %{buildroot}%{rlibdir} %{packname}
test -d %{packname}/src && (cd %{packname}/src; rm -f *.o *.so)
rm -f %{buildroot}%{rlibdir}/R.css
pushd %{buildroot}%{rlibdir}/%{packname}
rm fonts/*
ln -s /usr/share/fonts/wqy-microhei/wqy-microhei.ttc fonts/wqy-microhei.ttc
popd
%check
%if %{with network}
%{_bindir}/R CMD check %{packname}
%else
%{_bindir}/R CMD check %{packname} --no-examples
%endif
%files
%dir %{rlibdir}/%{packname}
%doc %{rlibdir}/%{packname}/html
%{rlibdir}/%{packname}/DESCRIPTION
%doc %{rlibdir}/%{packname}/NEWS.Rd
%{rlibdir}/%{packname}/INDEX
%{rlibdir}/%{packname}/NAMESPACE
%{rlibdir}/%{packname}/Meta
%{rlibdir}/%{packname}/R
%{rlibdir}/%{packname}/help
%{rlibdir}/%{packname}/fonts
%changelog
* Fri Jun 24 2022 misaka00251 <misaka00251@misakanet.cn> - 3.0-1
- Init package (Thanks to fedora team)

BIN
showtextdb_3.0.tar.gz Normal file

Binary file not shown.