[latex3-commits] [git/LaTeX3-latex3-pdfresources] test-new-hooks: starting pdfstringdef replacement (cc100e3)
Ulrike Fischer
fischer at troubleshooting-tex.de
Thu May 14 19:09:06 CEST 2020
Repository : https://github.com/latex3/pdfresources
On branch : test-new-hooks
Link : https://github.com/latex3/pdfresources/commit/cc100e3a8d9436ed217f72d6b3d510ae1c6338aa
>---------------------------------------------------------------
commit cc100e3a8d9436ed217f72d6b3d510ae1c6338aa
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Thu May 14 19:09:06 2020 +0200
starting pdfstringdef replacement
>---------------------------------------------------------------
cc100e3a8d9436ed217f72d6b3d510ae1c6338aa
hgeneric-experimental.def | 33 +++++++++++++++++++++++++++++++++
newpackages/new-pdfescape.sty | 24 ++++++++++++++++++++++++
2 files changed, 57 insertions(+)
diff --git a/hgeneric-experimental.def b/hgeneric-experimental.def
index 2a4daa7..bbb142d 100644
--- a/hgeneric-experimental.def
+++ b/hgeneric-experimental.def
@@ -14,6 +14,8 @@
%% \__hyp_PageLabels_gpush: : puts pagelabels in the catalog, used on every storing
%% \__hyp_pstringdef:Nn : replaces Hy at pstringdef, converts n to pdfstring and stores in N
%% naming??
+%% \__hyp_text_purify:Nn : replaces the first step of \pdfstringdef/\Hy at pdfstringdef
+%% currently simply \text_purify:n
%% \__hyp_info_generate_addons: what did this do??
%% list of new variables
%% \l__hyp_pdfa_bool : for pdfa option (unclear if it will stay)
@@ -245,6 +247,37 @@
}
}
+%% conversion macro, replacement for \pdfstringdef
+% first the purify step
+% a hook, but there will need for a wrapper interface ...
+
+\hook_new:n {hyp/text/purify}
+
+\cs_new_protected:Npn \__hyp_text_purify:nN #1 #2
+ {
+ \hook_use:n {hyp/text/purify}
+ \tl_set:Nx #2 {\text_purify:n { #1 }
+ }
+
+% this takes the output of \__hyp_text_purify and applies a converter
+% #1 = text, #2 = converter #3 output
+% #2 should be hex_print for \pdftool_textstringhex_print:nN
+% hex for \pdftool_textstringhex:nN
+% or lit_print for \pdftool_textstringlit_print:nN
+% or lit for \pdftool_textstringlit:nN
+\cs_new_protected:Npn \__hyp_text_convert:NnN #1 #2 #3
+ {
+ \use:c { pdftool_textstring#2:VN} #1 #3
+ }
+
+%% combining both:
+% #1=input, #2= handler shortcut #3 output command
+\cs_new_protected:Npn \__hyp_text_pdfdef:Nnn
+ {
+ \__hyp_text_purify:nN {#1}\l__hyp_tmpa_tl
+ \__hyp_text_convert:NnN \l__hyp_tmpa_tl { #2} #3
+ }
+
% variants of hyperref commands to get attributes in the prop
% these are (temporary) commands to fill various attributes (color, border style) in
% the hooks for links from the hyperref keys.
diff --git a/newpackages/new-pdfescape.sty b/newpackages/new-pdfescape.sty
index 4a8ac89..b6d1aa6 100644
--- a/newpackages/new-pdfescape.sty
+++ b/newpackages/new-pdfescape.sty
@@ -104,6 +104,11 @@
% check if one can use HEX too when directly writing the object
\sys_if_engine_pdftex:TF
{
+ \cs_new:Npn \pdftool_textstringlit:nN #1 #2
+ {
+ \str_set_convert:Nnnn #2 { #1 }{ utf8 } {utf16/string}
+ }
+
\cs_new:Npn \pdftool_textstringlit_print:nN #1 #2
{
\str_set_convert:Nnnn #2 { #1 }{ utf8 } {utf16/string}
@@ -112,6 +117,11 @@
}
}
{
+ \cs_new:Npn \pdftool_textstringlit:nN #1 #2
+ {
+ \str_set_convert:Nnnn #2 { #1 }{ } {utf16/string}
+ }
+
\cs_new:Npn \pdftool_textstringlit_print:nN #1 #2
{
\str_set_convert:Nnnn #2 { #1 }{ } {utf16/string}
@@ -122,6 +132,10 @@
\sys_if_engine_pdftex:TF
{
+ \cs_new:Npn \pdftool_textstringhex:nN #1 #2
+ {
+ \str_set_convert:Nnnn #2 { #1 }{ utf8 } {utf16/hex}
+ }
\cs_new:Npn \pdftool_textstringhex_print:nN #1 #2
{
\str_set_convert:Nnnn #2 { #1 }{ utf8 } {utf16/hex}
@@ -130,6 +144,11 @@
}
}
{
+ \cs_new:Npn \pdftool_textstringhex:nN #1 #2
+ {
+ \str_set_convert:Nnnn #2 { #1 }{ } {utf16/hex}
+ }
+
\cs_new:Npn \pdftool_textstringhex_print:nN #1 #2
{
\str_set_convert:Nnnn #2 { #1 }{ } {utf16/hex}
@@ -137,3 +156,8 @@
\str_put_right:Nn #2 {>}
}
}
+
+\cs_generate_variant:Nn \pdftool_textstringhex_print:nN {VN}
+\cs_generate_variant:Nn \pdftool_textstringhex:nN {VN}
+\cs_generate_variant:Nn \pdftool_textstringlit_print:nN {VN}
+\cs_generate_variant:Nn \pdftool_textstringlit:nN {VN}
More information about the latex3-commits
mailing list.