summary refs log tree commit diff
path: root/gnu/packages/tex.scm
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2022-04-09 13:07:33 -0400
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2022-05-12 12:45:48 -0400
commit1ee15c8d6821eab4452a57dae00c74178a32a058 (patch)
tree2eea2104277aba00364e5364ecf011fe6145a98b /gnu/packages/tex.scm
parentcea6ff3d805f86758f779dd7804d70ba077bbe84 (diff)
downloadguix-1ee15c8d6821eab4452a57dae00c74178a32a058.tar.gz
gnu: texlive-polyglossia: Rename and fix package.
Fixes <https://issues.guix.gnu.org/35780>.

* gnu/packages/tex.scm (texlive-latex-polyglossia): Rename to...
(texlive-polyglossia): ... this.  Inherit from a simple-texlive-package
package.
[version, source, build-system]: Remove field, now inherited.
[outputs]: New field.
[arguments]: Add the #:tex-format and #:phases arguments.
[native-inputs, propagated-inputs]: New fields.
[description]: Expound description.

Reported-by: Josh Holland
Diffstat (limited to 'gnu/packages/tex.scm')
-rw-r--r--gnu/packages/tex.scm147
1 files changed, 130 insertions, 17 deletions
diff --git a/gnu/packages/tex.scm b/gnu/packages/tex.scm
index 4bd65329c2..1840401ba1 100644
--- a/gnu/packages/tex.scm
+++ b/gnu/packages/tex.scm
@@ -58,6 +58,7 @@
   #:use-module (gnu packages bash)
   #:use-module (gnu packages boost)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages fonts)
   #:use-module (gnu packages fontutils)
   #:use-module (gnu packages gd)
   #:use-module (gnu packages ghostscript)
@@ -5716,25 +5717,137 @@ running text or as separate paragraphs with a preceding number or symbol.  It
 also provides compacted versions of enumerate and itemize.")
     (license license:lppl1.0+)))
 
-(define-public texlive-latex-polyglossia
+(define-public texlive-polyglossia
   (package
-    (name "texlive-latex-polyglossia")
-    (version (number->string %texlive-revision))
-    (source (origin
-              (method svn-fetch)
-              (uri (texlive-ref "latex" "polyglossia"))
-              (file-name (string-append name "-" version "-checkout"))
-              (sha256
-               (base32
-                "1ci6hr8hx4g2x359n6wqvw6w8fv42cjjpzxxxd3pn6av5nkaiav3"))))
-    (build-system texlive-build-system)
-    (arguments '(#:tex-directory "latex/polyglossia"))
+    (inherit (simple-texlive-package
+              "texlive-polyglossia"
+              (list "source/latex/polyglossia/"
+                    ;; These files are not part of polyglossia.dtx
+                    "tex/latex/polyglossia/arabicnumbers.sty"
+                    "tex/latex/polyglossia/xpg-cyrillicnumbers.sty")
+              (base32 "1p0hhclypv2zbs8h64c6sd689m9ym3vvpn966qpwpjxbymsrc49g")))
+    (outputs '("out" "doc"))
+    (arguments
+     (list
+      #:tex-directory "latex/polyglossia"
+      #:tex-format "xelatex"
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'build-and-install-xelatex.fmt
+            (lambda* (#:key tex-format #:allow-other-keys)
+              (invoke "fmtutil-sys" "--byfmt" tex-format "--fmtdir=web2c")
+              ;; Extend the current TEXMF environment variable to make
+              ;; available the newly built formats.
+              (setenv "GUIX_TEXMF" (string-append (getcwd) ":"
+                                                  (getenv "GUIX_TEXMF")))
+              ;; XXX: Extend the base (more limited) xelatex.fmt provided by
+              ;; texlive-latex-base, otherwise packages using Polyglossia
+              ;; would encounter the same lack of hyphenation support problem.
+              (install-file "web2c/xetex/xelatex.fmt"
+                            (string-append #$output
+                                           "/share/texmf-dist/web2c/xetex"))))
+          (add-before 'build 'chdir
+            (lambda _
+              ;; This is so the build can find the files not part of the .dtx.
+              (setenv "TEXINPUTS" (string-append (getcwd)
+                                                 "/tex/latex/polyglossia:"))
+              (chdir "source/latex/polyglossia")))
+          (add-after 'chdir 'substitute-nonfree-fonts
+            (lambda _
+              (substitute* "polyglossia.dtx"
+                (("\\{Serto Jerusalem}")
+                 "{FreeSans}"))))
+          (add-after 'substitute-nonfree-fonts 'extract-dtx
+            (lambda* (#:key tex-format #:allow-other-keys)
+              (invoke tex-format "polyglossia.dtx")))
+          (add-after 'install 'install-doc
+            (lambda* (#:key outputs tex-directory #:allow-other-keys)
+              (let ((doc (string-append (assoc-ref outputs "doc")
+                                        "/share/texmf-dist/doc" tex-directory)))
+                (install-file "README.md" doc)
+                (install-file "polyglossia.pdf" doc)))))))
+    (native-inputs (list fontconfig     ;for XDG_DATA_DIRS (to locate fonts)
+                         font-amiri
+                         font-dejavu
+                         font-gfs-ambrosia
+                         font-gnu-freefont
+                         font-linuxlibertine
+                         font-sil-ezra
+                         texlive-latex-base
+                         texlive-babel
+                         texlive-bin    ;for fmtutil.cnf
+                         texlive-bidi
+                         texlive-booktabs
+                         texlive-caption
+                         texlive-context
+                         texlive-latex-fancyvrb
+                         texlive-etoolbox
+                         texlive-fonts-latex
+                         texlive-fontspec
+                         texlive-hyperref
+                         ;; TODO: Remove texlive-stringenc and
+                         ;; texlive-zapfding after texlive-hyperref propagates
+                         ;; them.
+                         texlive-stringenc
+                         texlive-zapfding
+                         texlive-latex-graphics
+                         texlive-kpathsea ;for cp227.tcx & friends
+                         texlive-makecmds
+                         texlive-metalogo
+                         texlive-microtype
+                         texlive-paralist
+                         texlive-latex-tools
+                         texlive-tex-ini-files)) ;for pdftexconfig
+    ;; polyglossia.sty \RequirePackage or \\usepackage these other TexLive
+    ;; packages.
+    (propagated-inputs
+     (list texlive-bidi
+           texlive-etoolbox
+           texlive-fontspec
+           texlive-hyperref
+           ;; TODO: Remove texlive-stringenc and
+           ;; texlive-zapfding after texlive-hyperref propagates
+           ;; them.
+           texlive-stringenc
+           texlive-zapfding
+           texlive-makecmds
+           texlive-latex-l3packages     ;expl3, l3keys2e, xparse
+           texlive-latex-tools
+           texlive-latex-xkeyval))
     (home-page "https://www.ctan.org/pkg/polyglossia")
-    (synopsis "Alternative to babel for XeLaTeX and LuaLaTeX")
-    (description
-     "This package provides a complete Babel replacement for users of LuaLaTeX
-and XeLaTeX; it relies on the @code{fontspec} package, version 2.0 at least.")
-    (license license:lppl1.3+)))
+    (synopsis "Alternative to Babel for XeLaTeX and LuaLaTeX")
+    (description "This package provides a complete Babel replacement for users
+of LuaLaTeX and XeLaTeX.  It includes support for over 70 different languages,
+some of which in different regional or national varieties, or using a
+different writing system.  It enables:
+@itemize
+@item
+Loading the appropriate hyphenation patterns.
+@item
+Setting the script and language tags of the current font (if possible and
+available), using the package fontspec.
+@item
+Switching to a font assigned by the user to a particular script or language.
+@item
+Adjusting some typographical conventions in function of the current language
+(such as afterindent, frenchindent, spaces before or after punctuation marks,
+etc.)
+@item
+Redefining the document strings (like @samp{chapter}, @samp{figure},
+@samp{bibliography}).  Adapting the formatting of dates (for non-gregorian
+calendars via external packages bundled with polyglossia: currently the
+Hebrew, Islamic and Farsi calendars are supported).
+@item
+For languages that have their own numeration system, modifying the formatting
+of numbers appropriately.
+@item
+Ensuring the proper directionality if the document contains languages
+written from right to left (via the packages bidi and luabidi, available
+separately).
+@end itemize")
+    (license license:expat)))
+
+(define-deprecated-package texlive-latex-polyglossia texlive-polyglossia)
 
 (define-public texlive-latex-supertabular
   (package