summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/xltxtra
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-01-21 22:21:37 +0000
committerKarl Berry <karl@freefriends.org>2016-01-21 22:21:37 +0000
commitc826689e35799045873cee4c33d95d7820317ec8 (patch)
treed177709a1ff804a12aab183e9902448b766f4e55 /Master/texmf-dist/tex/latex/xltxtra
parenta3530eabad2579db06eb6d331f67435d3150da8b (diff)
xltxtra (21jan16)
git-svn-id: svn://tug.org/texlive/trunk@39453 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/xltxtra')
-rw-r--r--Master/texmf-dist/tex/latex/xltxtra/xltxtra.sty109
1 files changed, 79 insertions, 30 deletions
diff --git a/Master/texmf-dist/tex/latex/xltxtra/xltxtra.sty b/Master/texmf-dist/tex/latex/xltxtra/xltxtra.sty
index 7c4ee541468..377ffbc6701 100644
--- a/Master/texmf-dist/tex/latex/xltxtra/xltxtra.sty
+++ b/Master/texmf-dist/tex/latex/xltxtra/xltxtra.sty
@@ -7,11 +7,11 @@
%% xltxtra.dtx (with options: `package')
%% ____________________________
%% The XLTXTRA package
-%% (C) 2006-2010 Will Robertson
+%% (C) 2006-2016 Will Robertson
%% License information appended
%%
\ProvidesPackage{xltxtra}
- [2010/09/20 v0.5e Improvements for the "XeLaTeX" format]
+ [2016/01/21 v0.6 Improvements for the "XeLaTeX" format]
\RequirePackage{ifluatex}
\ifluatex
\PackageWarningNoLine {xltxtra} {^^J
@@ -19,12 +19,12 @@
LOAD FONTSPEC DIRECTLY, INSTEAD.^^J
ABORTING LOADING%
}
- \RequirePackage{fontspec}[2010/05/14 v2.0]
+ \RequirePackage{fontspec}
\expandafter \endinput
\fi
\RequirePackage{ifxetex}
\RequireXeTeX
-\RequirePackage{fontspec}[2010/05/14 v2.0]
+\RequirePackage{fontspec}
\RequirePackage{realscripts}
\newif\if@xxt@nosscript@
\newif\if@xxt@nologos@
@@ -86,33 +86,82 @@
\xxt@namedglyph@fallback{#1}%
\fi}
\newcommand\xxt@namedglyph@fallback[1]{[#1]}
-\newbox\xxt@tempbox
-\def\showhyphens#1{%
- \typeout{^^J***********************
- \string\showhyphens:
- ***********************}%
- \@for\@ii:=#1\do{\xxt@showhyphens{\@ii}}%
- \typeout{^^J***********************%
- ***************%
- ***********************^^J}}
-\def\xxt@showhyphens#1{%
- \setbox\@tempboxa=\vbox{%
- \hsize1sp \hbadness10000 \hfuzz\maxdimen
- \everypar={} \leftskip\z@ \rightskip\leftskip
- \pretolerance\m@ne \noindent \hskip\z@ #1\par
- \global\setbox\xxt@tempbox=\hbox{}\xxt@sh@cat}%
- \setbox\@tempboxa=\hbox to \maxdimen{\unhbox\xxt@tempbox}}
-\def\xxt@sh@cat{\unskip\unpenalty
- \setbox\@tempboxa=\lastbox
- \unless\ifvoid\@tempboxa
- \global\setbox\xxt@tempbox=\hbox{%
- \unhbox\@tempboxa
- \unskip\unskip
- \unhbox\xxt@tempbox}%
- \expandafter\xxt@sh@cat
- \fi}
+\ExplSyntaxOn
+\seq_new:N \l__xetex_showhyphens_seq
+\box_new:N \l__xetex_show_hyphens_wrapping_box
+\box_new:N \l__xetex_show_hyphens_temp_box
+\box_new:N \l__xetex_show_hyphens_final_box
+\box_new:N \g__xetex_show_hyphens_word_box
+
+\cs_new_protected:Npn \xetex_show_hyphens:n #1
+ {
+ \box_clear:N \l__xetex_show_hyphens_final_box
+ % split the input into items
+ \seq_set_split:Nnn \l__xetex_showhyphens_seq { ~ } { #1 }
+ % hyphenate all items
+ \seq_map_function:NN \l__xetex_showhyphens_seq \xetex_hyphenate_word:n
+ % set a box to the maximum dimension to force a Underfull \hbox warning
+ \hbox_set_to_wd:Nnn \l__xetex_show_hyphens_final_box { \c_max_dim }
+ {
+ \hbox_unpack_clear:N \l__xetex_show_hyphens_final_box
+ }
+ }
+
+\cs_new_protected:Npn \xetex_hyphenate_word:n #1
+ {
+ \vbox_set:Nn \l__xetex_show_hyphens_wrapping_box
+ {% build a paragraph with the word with a very narrow line width
+ \dim_set:Nn \hsize { 1sp }
+ % disregard spurious messages
+ \hbadness = \c_ten_thousand
+ \dim_set:Nn \hfuzz { \c_max_dim }
+ % clear possible values of \everypar and other parameters
+ \everypar={}
+ \skip_set:Nn \leftskip { 0pt }
+ \skip_set_eq:NN \rightskip \leftskip
+ % skip the first step
+ \pretolerance = \c_minus_one
+ % avoid the indentation and add a skip to allow hyphenation
+ \noindent
+ \skip_horizontal:n { 0pt }
+ #1
+ \par
+ \hbox_gset:Nn \g__xetex_show_hyphens_word_box {}
+ % start a recursion to dismantle the paragraph just built
+ \xetex_show_hyphens_split:
+ % the result is put into \g__xetex_show_hyphens_word_box
+ }
+ % add the box to the final container
+ \hbox_set:Nn \l__xetex_show_hyphens_final_box
+ {
+ \hbox_unpack_clear:N \l__xetex_show_hyphens_final_box
+ \hbox_unpack_clear:N \g__xetex_show_hyphens_word_box
+ }
+ }
+
+\cs_new_protected:Npn \xetex_show_hyphens_split:
+ {
+ \unskip % remove the interline glue
+ \unpenalty % remove possible penalties
+ % get the last line
+ \box_set_to_last:N \l__xetex_show_hyphens_temp_box
+ \box_if_empty:NF \l__xetex_show_hyphens_temp_box
+ {% if there is a last line unpack it into a container
+ \hbox_gset:Nn \g__xetex_show_hyphens_word_box
+ {% the order is last to first
+ \hbox_unpack_clear:N \l__xetex_show_hyphens_temp_box
+ \unskip\unskip % remove spaces
+ \hbox_unpack_clear:N \g__xetex_show_hyphens_word_box
+ }
+ % restart the recursion
+ \xetex_show_hyphens_split:
+ }
+ }
+
+\cs_set_eq:NN \showhyphens \xetex_show_hyphens:n
+\ExplSyntaxOff
%%
-%% Copyright (C) 2006-2010 by Will Robertson <wspr81@gmail.com>
+%% Copyright (C) 2006-2016 by Will Robertson <wspr81@gmail.com>
%%
%% Distributable under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of