summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/hyperxmp
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-10-09 03:02:16 +0000
committerNorbert Preining <norbert@preining.info>2020-10-09 03:02:16 +0000
commit1f42d0c83e745c8ee0454060ea03fbb886e77ce5 (patch)
tree4a556cfc662424e929c903ee8f70b8051e2fa9ab /macros/latex/contrib/hyperxmp
parentd7d6de5b9de5d5d8a6d6b740ae5f7d4101e5e40d (diff)
CTAN sync 202010090302
Diffstat (limited to 'macros/latex/contrib/hyperxmp')
-rw-r--r--macros/latex/contrib/hyperxmp/hyperxmp.dtx98
-rw-r--r--macros/latex/contrib/hyperxmp/hyperxmp.pdfbin1520844 -> 1525551 bytes
2 files changed, 82 insertions, 16 deletions
diff --git a/macros/latex/contrib/hyperxmp/hyperxmp.dtx b/macros/latex/contrib/hyperxmp/hyperxmp.dtx
index 08e6d2fab8..eab2cc3940 100644
--- a/macros/latex/contrib/hyperxmp/hyperxmp.dtx
+++ b/macros/latex/contrib/hyperxmp/hyperxmp.dtx
@@ -22,7 +22,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{hyperxmp}
%<*package>
- [2020/09/24 v5.5 Store hyperref metadata in XMP format]
+ [2020/10/05 v5.6 Store hyperref metadata in XMP format]
%</package>
%
%<*driver>
@@ -116,7 +116,7 @@
%</driver>
% \fi
%
-% \CheckSum{2804}
+% \CheckSum{2826}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -191,6 +191,10 @@
% \protect\cs{AtEndPreamble}, as is done by
% \protect\pkgname{doclicense}~v2.2.0. Thanks to Tommaso Pecorella
% for the bug report and help testing}
+% \changes{v5.6}{2020/10/05}{Make conditional the loading of the
+% \protect\pkgname{ifdraft} package. Thanks to Tobias Pape for
+% reporting the incompatibility between \protect\pkgname{hyperxmp} and
+% \protect\pkgname{ifdraft}}
%
% ^^A \GetFileInfo{hyperxmp.dtx}
%
@@ -1612,6 +1616,28 @@
% \pkgname{hyperxmp}. Read this section only if you want to learn how
% \pkgname{hyperxmp} is implemented.
%
+% \bigskip
+%
+% One thing to bear in mind when reading the \pkgname{hyperxmp} source
+% code is that different actions occur at different times throughout
+% document processing:
+%
+% \begin{enumerate}
+% \item |\usepackage{hyperxmp}|: \pkgname{hyperxmp} parses package
+% options, defines a number of commands, loads various helper
+% packages, and assigns default values to most \acro{XMP} fields.
+%
+% \item |\begin{document}|: \pkgname{hyperxmp} loads certain packages
+% such as \pkgname{hyperref} and \pkgname{ifdraft} and queries
+% natural-language information from \pkgname{babel} and
+% \pkgname{polyglossia} that becomes available only at the end of
+% the preamble.
+%
+% \item |\end{document}|: \pkgname{hyperxmp} finalizes certain data
+% that are known only at the end of the document, such as the page
+% count, and writes the \acro{XMP} packet to the \acro{PDF} file.
+% \end{enumerate}
+%
% \iffalse
%<*package>
% \fi
@@ -2101,16 +2127,32 @@
% \end{macro}
%
% \begin{macro}{\ifdraft}
+% \begin{macro}{\next}
% Use the \pkgname{ifdraft} package to determine if this is a draft or
-% final document.
+% final document. The challenge here is that we want to use
+% \pkgname{ifdraft} if it's already loaded, load it if not, and not
+% break any incompatible, author-defined \cs{ifdraft} macros that may
+% occur either before or after the |\usepackage{hyperxmp}|. Our
+% solution begins by defining a new group. Then, if \pkgname{ifdraft}
+% is not yet loaded, we locally undefine \cs{ifdraft} and load the
+% package. In this case, we later ``unload'' the package by setting
+% \cs{ver@ifdraft.sty} to \cs{relax}.
% \changes{v5.2}{2020/04/18}{Define \protect\cs{ifdraft} only locally, at
% Niklas Beisert's request}
% \begin{macrocode}
\begingroup
-\let\ifdraft=\relax
-\RequirePackage{ifdraft}
+ \@ifpackageloaded{ifdraft}{%
+ \let\next=\relax
+ }{%
+ \let\ifdraft=\relax
+ \RequirePackage{ifdraft}%
+ \def\next{%
+ \expandafter\global\expandafter\let\csname ver@ifdraft.sty\endcsname=\relax
+ }%
+ }%
% \end{macrocode}
% \end{macro}
+% \end{macro}
%
% \begin{macro}{\@pdfrendition}
% \changes{v5.0}{2020/02/27}{Added the \protect\optname{pdfrendition}
@@ -2121,11 +2163,12 @@
% |\documentclass[draft]|, for which |\@pdfrendition| defaults to
% |draft|.
% \begin{macrocode}
-\ifdraft{%
- \gdef\@pdfrendition{draft}%
-}{%
- \gdef\@pdfrendition{default}%
-}
+ \ifdraft{%
+ \gdef\@pdfrendition{draft}%
+ }{%
+ \gdef\@pdfrendition{default}%
+ }
+ \next
\endgroup
\define@key{Hyp}{pdfrendition}{\hyxmp@pdfstringdef\@pdfrendition{#1}}
% \end{macrocode}
@@ -5988,8 +6031,27 @@ ______</Iptc4xmpCore:CreatorContactInfo>^^J%
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\hyxmp@prot@us}
+% Define an underscore character that's protected from being converted
+% into a space when passed to \cs{hyxmp@add@to@xml}. \cs{hyxmp@prot@us}
+% is used within |write_xmp_font_list| (below) in particular to typeset
+% filenames that may contain underscores.
+% \begin{macrocode}
+\bgroup
+ \catcode`\_=11
+ \gdef\hyxmp@prot@us{_}%
+\egroup
+% \end{macrocode}
+% \end{macro}
+%
% Here we define a Lua\index{Lua} function, |write_xmp_font_list|, that
% writes font information to the \acro{XMP} packet.
+% \changes{v5.6}{2020/10/02}{Make \protect\texttt{write\_xmp\_font\_list}
+% robust to fonts loaded using
+% \protect\href{https://en.wikipedia.org/wiki/HarfBuzz}{HarfBuzz}.
+% Thanks to John Lienhard for the bug report}
+% \changes{v5.6}{2020/10/02}{Don't inadvertently replace underscores in
+% filenames when writing font-related metadata}
% \begin{macrocode}
\ifLuaTeX
\begin{luacode*}
@@ -6001,8 +6063,9 @@ function write_xmp_font_list (cct)
local xml = string.gsub(val, "&", "&amp;")
xml = string.gsub(xml, "<", "&lt;")
xml = string.gsub(xml, ">", "&gt;")
+ xml = string.gsub(xml, "_", "\\hyxmp@prot@us ")
tex.print(cct, "____________<stFnt:" .. name .. ">" ..
- val .. "</stFnt:" .. name .. ">^^J%")
+ xml .. "</stFnt:" .. name .. ">^^J%")
return
end
end
@@ -6013,11 +6076,14 @@ function write_xmp_font_list (cct)
for i, f in font.each() do
tex.print(cct, "__________<rdf:li rdf:parseType=\"Resource\">^^J%")
if f.filename then
- local info = fontloader.info(f.filename)
- show_field("fontFace", info.fullname)
- show_field("fontFamily", info.familyname)
- show_field("fontName", info.fontname)
- show_field("versionString", info.version)
+ local fname = string.gsub(f.filename, "^harfloaded:(.*)", "%1")
+ local info = fontloader.info(fname)
+ if info then
+ show_field("fontFace", info.fullname)
+ show_field("fontFamily", info.familyname)
+ show_field("fontName", info.fontname)
+ show_field("versionString", info.version)
+ end
local baseName = string.gsub(f.filename, ".*[/\\](.*)", "%1")
show_field("fontFileName", baseName)
else
diff --git a/macros/latex/contrib/hyperxmp/hyperxmp.pdf b/macros/latex/contrib/hyperxmp/hyperxmp.pdf
index 713d57a2b6..23e5ed9f76 100644
--- a/macros/latex/contrib/hyperxmp/hyperxmp.pdf
+++ b/macros/latex/contrib/hyperxmp/hyperxmp.pdf
Binary files differ