texlive[56599] Master/texmf-dist: hyperxmp (8oct20)

commits+karl at tug.org commits+karl at tug.org
Thu Oct 8 23:21:24 CEST 2020


Revision: 56599
          http://tug.org/svn/texlive?view=revision&revision=56599
Author:   karl
Date:     2020-10-08 23:21:24 +0200 (Thu, 08 Oct 2020)
Log Message:
-----------
hyperxmp (8oct20)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/hyperxmp/hyperxmp.pdf
    trunk/Master/texmf-dist/source/latex/hyperxmp/hyperxmp.dtx
    trunk/Master/texmf-dist/tex/latex/hyperxmp/hyperxmp.sty

Modified: trunk/Master/texmf-dist/doc/latex/hyperxmp/hyperxmp.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/hyperxmp/hyperxmp.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/hyperxmp/hyperxmp.dtx	2020-10-08 21:20:56 UTC (rev 56598)
+++ trunk/Master/texmf-dist/source/latex/hyperxmp/hyperxmp.dtx	2020-10-08 21:21:24 UTC (rev 56599)
@@ -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 at 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 at 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 at key{Hyp}{pdfrendition}{\hyxmp at pdfstringdef\@pdfrendition{#1}}
 %    \end{macrocode}
@@ -5988,8 +6031,27 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\hyxmp at prot@us}
+% Define an underscore character that's protected from being converted
+% into a space when passed to \cs{hyxmp at add@to at xml}.  \cs{hyxmp at 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 at 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 @@
         local xml = string.gsub(val, "&", "&")
         xml = string.gsub(xml, "<", "<")
         xml = string.gsub(xml, ">", ">")
+        xml = string.gsub(xml, "_", "\\hyxmp at prot@us ")
         tex.print(cct, "____________<stFnt:" .. name .. ">" ..
-                  val .. "</stFnt:" .. name .. ">^^J%")
+                  xml .. "</stFnt:" .. name .. ">^^J%")
         return
       end
     end
@@ -6013,11 +6076,14 @@
   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

Modified: trunk/Master/texmf-dist/tex/latex/hyperxmp/hyperxmp.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/hyperxmp/hyperxmp.sty	2020-10-08 21:20:56 UTC (rev 56598)
+++ trunk/Master/texmf-dist/tex/latex/hyperxmp/hyperxmp.sty	2020-10-08 21:21:24 UTC (rev 56599)
@@ -22,7 +22,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{hyperxmp}
-    [2020/09/24 v5.5 Store hyperref metadata in XMP format]
+    [2020/10/05 v5.6 Store hyperref metadata in XMP format]
 \edef\hyxmp at dq@code{\the\catcode`\"}
 \catcode`\"=12
 \@ifundefined{AtEndDocument}{%
@@ -156,13 +156,21 @@
 \def\@pdfversionid{1}
 \define at key{Hyp}{pdfversionid}{\hyxmp at pdfstringdef\@pdfversionid{#1}}
 \begingroup
-\let\ifdraft=\relax
-\RequirePackage{ifdraft}
-\ifdraft{%
-  \gdef\@pdfrendition{draft}%
-}{%
-  \gdef\@pdfrendition{default}%
-}
+  \@ifpackageloaded{ifdraft}{%
+    \let\next=\relax
+  }{%
+    \let\ifdraft=\relax
+    \RequirePackage{ifdraft}%
+    \def\next{%
+      \expandafter\global\expandafter\let\csname ver at ifdraft.sty\endcsname=\relax
+    }%
+  }%
+  \ifdraft{%
+    \gdef\@pdfrendition{draft}%
+  }{%
+    \gdef\@pdfrendition{default}%
+  }
+  \next
 \endgroup
 \define at key{Hyp}{pdfrendition}{\hyxmp at pdfstringdef\@pdfrendition{#1}}
 \def\@pdfpublication{}
@@ -1593,6 +1601,10 @@
   \newcatcodetable\hyxmp at cct
   \savecatcodetable\hyxmp at cct
 \fi
+\bgroup
+  \catcode`\_=11
+  \gdef\hyxmp at prot@us{_}%
+\egroup
 \ifLuaTeX
   \begin{luacode*}
 function write_xmp_font_list (cct)
@@ -1603,8 +1615,9 @@
         local xml = string.gsub(val, "&", "&")
         xml = string.gsub(xml, "<", "<")
         xml = string.gsub(xml, ">", ">")
+        xml = string.gsub(xml, "_", "\\hyxmp at prot@us ")
         tex.print(cct, "____________<stFnt:" .. name .. ">" ..
-                  val .. "</stFnt:" .. name .. ">^^J%")
+                  xml .. "</stFnt:" .. name .. ">^^J%")
         return
       end
     end
@@ -1615,11 +1628,14 @@
   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



More information about the tex-live-commits mailing list.