summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/latex/bxnewfont/README.md4
-rw-r--r--Master/texmf-dist/tex/latex/bxnewfont/bxnewfont.sty294
2 files changed, 261 insertions, 37 deletions
diff --git a/Master/texmf-dist/doc/latex/bxnewfont/README.md b/Master/texmf-dist/doc/latex/bxnewfont/README.md
index 6ac295babd5..3f7248931ef 100644
--- a/Master/texmf-dist/doc/latex/bxnewfont/README.md
+++ b/Master/texmf-dist/doc/latex/bxnewfont/README.md
@@ -70,6 +70,10 @@ Available options:
Revision History
----------------
+ * Version 0.2a ‹2016/08/08›
+ - Now “TFM” names can contain spaces with suitable quoting.
+ This enables one to specify OpenType fonts on Unicode engines.
+ - An experimental command `\newfontjascale` is added.
* Version 0.2 ‹2016/03/27›
- The first public version.
diff --git a/Master/texmf-dist/tex/latex/bxnewfont/bxnewfont.sty b/Master/texmf-dist/tex/latex/bxnewfont/bxnewfont.sty
index e3127c9f5a1..e2d04f7ad53 100644
--- a/Master/texmf-dist/tex/latex/bxnewfont/bxnewfont.sty
+++ b/Master/texmf-dist/tex/latex/bxnewfont/bxnewfont.sty
@@ -2,7 +2,7 @@
%% package declaration
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{bxnewfont}[2016/03/27 v0.2]
+\ProvidesPackage{bxnewfont}[2016/08/08 v0.2a]
%% preparation
\def\bxnf@pkgname{bxnewfont}
@@ -34,6 +34,9 @@
%% variables
\newbool{bxnf@ok}
+%% constants
+\def\bxnf@@star{*}
+
%% \bxnf@cond\if...\fi{<true>}{<false>}
\@gobbletwo\if\if \def\bxnf@cond#1\fi{%
#1\expandafter\@firstoftwo
@@ -77,6 +80,7 @@
}%]
}
\def\bxnf@newfontx@b#1[#2]#3{%
+ \bxnf@annihilate@setjascale
\edef\bxnf@enc{#2}%
\edef\bxnf@font{#3}%
\bxnf@split@name
@@ -85,26 +89,6 @@
\ifbxnf@ok \bxnf@make@cmd#1\fi
}
-%% \bxnf@split@name
-% Parses \bxnf@font and sets \bxnf@tfm and \bxnf@atcl.
-\def\bxnf@next#1{%
- \def\bxnf@split@name{%
- \expandafter\bxnf@split@name@a\bxnf@font\bxnf@mk#1\bxnf@end
- }%
- \def\bxnf@split@name@a##1#1##2\bxnf@end{%
- \ifstrempty{##2}{%
- \let\bxnf@tfm\bxnf@font \let\bxnf@atcl\relax
- }{%else
- \def\bxnf@tfm{##1}%
- \bxnf@split@name@b##2\bxnf@end
- }%
- }%
- \def\bxnf@split@name@b##1\bxnf@mk##2\bxnf@end{%
- \def\bxnf@atcl{##1}%
- }%
-}
-\bxnf@next{ }
-
%% \bxnf@check@param
% Sets bxnf@ok.
\def\bxnf@check@param{%
@@ -138,7 +122,7 @@
\unless\ifbxnf@fixed \unless\ifx\bxnf@atcl\relax
\bxnf@error{You cannot use size spec here}{%
The invalid size spec (\bxnf@atcl) is ignored.%
- \MeesageBreak\@ehc}%
+ \MessageBreak\@ehc}%
\fi\fi
}
@@ -176,45 +160,170 @@ __\newrobustcmd*#2{\select font#1 }}%
__\bxnf@select@family{#1}}%
\endgroup
+%--------------------------------------- parse
+
+%% variables
+\let\bxnf@pre\relax
+\let\bxnf@post\relax
+\let\bxnf@quoted@part\relax
+
+%% \bxnf@split@at{<sep>}{<text>}
+% Splits the text by the given separator.
+% In success, it will set \bxnf@pre and \bxnf@post.
+\def\bxnf@split@at#1#2{%
+ \def\bxnf@next##1#1##2\bxnf@end{%
+ \bxnf@split@at@a{##1}{##2}}%
+ \bxnf@next#2\bxnf@mk#1\bxnf@end
+}
+\def\bxnf@split@at@a#1#2{%
+ \ifstrempty{#2}{%
+ \let\bxnf@pre\relax \let\bxnf@post\relax
+ }{%else
+ \def\bxnf@pre{#1}%
+ \bxnf@split@at@b#2\bxnf@end
+ }%
+}%
+\def\bxnf@split@at@b#1\bxnf@mk#2\bxnf@end{%
+ \def\bxnf@post{#1}%
+}%
+
+%% \bxnf@guard@quote\CS
+% Extract from the string a part enclosed by a pair of quotes,
+% and replaces the part with the cs '\bxnf@quoted@part'.
+% Then the cs is assigned to the content of the part.
+\def\bxnf@guard@quote#1{%
+ \let\bxnf@quoted@part\relax
+ \edef\bxnf@tmpb{{"}{#1}}%
+ \expandafter\bxnf@split@at\bxnf@tmpb
+ \unless\ifx\bxnf@pre\relax
+ \let\bxnf@tmpa\bxnf@pre \edef\bxnf@tmpb{{"}{\bxnf@post}}%
+ \expandafter\bxnf@split@at\bxnf@tmpb
+ \unless\ifx\bxnf@pre\relax
+ \let\bxnf@quoted@part\bxnf@pre
+ \edef#1{\bxnf@tmpa"\noexpand\bxnf@quoted@part"\bxnf@post}%
+ \fi
+ \fi
+}
+
+%% \bxnf@enclose@quote\CS
+% If the string does not contain a quote but does contain
+% a space, then the string will get enclosed by quotes.
+\def\bxnf@enclose@quote#1{%
+ \edef\bxnf@tmpa{#1}%
+ \edef\bxnf@tmpb{{"}{\bxnf@tmpa}}%
+ \expandafter\bxnf@split@at\bxnf@tmpb
+ \ifx\bxnf@pre\relax
+ \edef\bxnf@tmpb{{ }{\bxnf@tmpa}}%
+ \expandafter\bxnf@split@at\bxnf@tmpb
+ \unless\ifx\bxnf@pre\relax
+ \edef\bxnf@tmpa{"\bxnf@tmpa"}%
+ \fi
+ \fi
+ \let#1\bxnf@tmpa
+}
+
+%% \bxnf@split@name
+% Parses \bxnf@font and sets \bxnf@tfm and \bxnf@atcl.
+\def\bxnf@split@name{%
+ \let\bxnf@tfm\bxnf@font \let\bxnf@atcl\relax
+ \bxnf@guard@quote\bxnf@tfm
+ \expandafter\bxnf@split@name@a\bxnf@tfm\bxnf@end
+ \bxnf@enclose@quote\bxnf@tfm
+}
+\def\bxnf@split@name@a#1\bxnf@end{%
+ \let\bxnf@pre\relax
+ \def\do##1{%
+ \bxnf@split@name@b{##1}{#1}%
+ }%
+ \bxnf@split@sep@list
+}
+\def\bxnf@split@name@b#1#2{%
+ \ifx\bxnf@pre\relax
+ \bxnf@split@at{ #1}{#2}%
+ \unless\ifx\bxnf@pre\relax
+ \let\bxnf@tfm\bxnf@pre
+ \edef\bxnf@atcl{#1\bxnf@post}%
+ \fi
+ \fi
+}
+\let\do\relax
+\edef\bxnf@split@sep@list{%
+ \do{at}\do{scaled}%
+ \do{\detokenize{at}}%
+ \do{\detokenize{scaled}}%
+}
+
%--------------------------------------- Family name
%% variables
-%\[bxnf@varid/<tfm>] % maximum used id number
-%\[bxnf@prm/<family>] % font parameter ({<enc>}{<size>})
-%\[bxnf@pc/<spec>] % cache
+%\[bxnf@g@varid/<tfm>] % maximum used id number
+%\[bxnf@g@prm/<family>] % font parameter ({<enc>}{<size>})
+%\[bxnf@g@pc/<spec>] % cache
+\let\bxnf@stfm\relax
%% \bxnf@get@family@name
% Generates a family name and returns to \bxnf@fam.
% The name is of the form "<tfm-name>(<id>)".
\def\bxnf@get@family@name{%
- \def\bxnf@tmpa{bxnf@pc/\bxnf@enc:\bxnf@tfm:%
+ \def\bxnf@tmpa{bxnf@g@pc/\bxnf@enc:\bxnf@tfm:%
\ifbxnf@fixed \the\dimexpr\bxnf@size\relax \fi}%
\letcs\bxnf@fam{\bxnf@tmpa}%
\ifdef\bxnf@fam{%
\bxDebug{\bxnf@tmpa==\bxnf@fam}%
\bxnf@oktrue
}{%else
- \csnumdef{bxnf@varid/\bxnf@tfm}{\csuse{bxnf@varid/\bxnf@tfm}+1}%
- \edef\bxnf@fam{\bxnf@tfm(\csuse{bxnf@varid/\bxnf@tfm})}%
- \cslet{\bxnf@tmpa}\bxnf@fam
+ \bxnf@sanitize@tfmname\bxnf@stfm
+ \csnumgdef{bxnf@g@varid/\bxnf@stfm}{\csuse{bxnf@g@varid/\bxnf@stfm}+1}%
+ \edef\bxnf@fam{\bxnf@stfm*\csuse{bxnf@g@varid/\bxnf@stfm}*}%
+ \global\cslet{\bxnf@tmpa}\bxnf@fam
\bxDebug{\bxnf@tmpa:=\bxnf@fam}%
\bxnf@okfalse
}%
}
+%% \bxnf@sanitize@tfmname\CS
+\def\bxnf@sanitize@tfmname#1{%
+ \begingroup
+ \let\bxnf@pre\relax
+ \let\do\bxnf@sanitize@tfmname@a
+ \bxnf@sanitize@list
+ \ifx\bxnf@pre\relax
+ \global\let\bxnf@g@tmpa\bxnf@tfm
+ \else
+ \global\let\bxnf@g@tmpa\bxnf@@sanitized
+ \fi
+ \endgroup
+ \let#1\bxnf@g@tmpa
+}
+\def\bxnf@sanitize@tfmname@a#1{%
+ \ifx\bxnf@pre\relax
+ \edef\bxnf@tmpa{{#1}{\bxnf@tfm}}%
+ \expandafter\bxnf@split@at\bxnf@tmpa
+ \fi
+}
+\def\bxnf@@sanitized{(OpenType)}
+\def\bxnf@sanitize@list{%
+ \do{ }\do{:}\do{,}\do{;}\do{=}\do{/}%
+}
+
%% \def\bxnf@set@family@param
-% Sets \[bxnf@prm/*].
+% Sets \[bxnf@g@prm/*].
\def\bxnf@set@family@param{%
- \csedef{bxnf@prm/\bxnf@fam}{{\bxnf@enc}%
+ \csxdef{bxnf@g@prm/\bxnf@fam}{{\bxnf@enc}%
{\ifbxnf@fixed \expandafter\rem@pt\bxnf@size \fi}}%
- \bxDebug{bxnf@prm/\bxnf@fam:=\csuse{bxnf@prm/\bxnf@fam}}%
+ \bxDebug{bxnf@g@prm/\bxnf@fam:=\csuse{bxnf@g@prm/\bxnf@fam}}%
}
%% \bxnf@declare@family
\def\bxnf@declare@family{%
\DeclareFontFamily{\bxnf@enc}{\bxnf@fam}{}%
+ \let\bxnf@tmpb\@empty
+ \ifcase\bxnf@type\or
+ \or \let\bxnf@tmpb\bxnf@jfscale@spec
+ \or \let\bxnf@tmpb\bxnf@jfscale@spec
+ \fi
\DeclareFontShape{\bxnf@enc}{\bxnf@fam}{m}{n}%
- {<->\bxnf@tfm}{}%
+ {<->\bxnf@tmpb\bxnf@tfm}{}%
% In pTeX, a dummy entry must be declared for the
% encoding counterpart.
\let\bxnf@tmpb\relax
@@ -232,7 +341,7 @@ __\bxnf@select@family{#1}}%
%% \bxnf@select@family{<family>}
\def\bxnf@select@family#1{%
\edef\bxnf@next{\noexpand\bxnf@select@family@a
- {#1}\csuse{bxnf@prm/#1}}%
+ {#1}\csuse{bxnf@g@prm/#1}}%
\bxnf@next
}
\def\bxnf@select@family@a#1#2#3{%
@@ -306,7 +415,7 @@ __\bxnf@select@family{#1}}%
%% \bxnf@curr@font\CS\Xfont
\def\bxnf@curr@font#1#2{%
- \xdef#1{\expandafter\meaning\the#2}%
+ \xdef#1{\fontname#2}%
}
\ifbxnf@ptex %----<*pTeX>
@@ -349,6 +458,117 @@ __\bxnf@select@family{#1}}%
\fi %----</pTeX>
+%--------------------------------------- Ja-font scaling
+
+%% variables
+\def\bxnf@jfscale{1}
+
+%% error message
+\def\bxnf@err@ivjsc{%
+ \PackageError\bxnf@pkgname
+ {Invalid argument given to \string\newfontjascale
+ \MessageBreak(\bxnf@tmpa)}%
+ {\@eha}%
+}
+\def\bxnf@err@najsc{%
+ \PackageError\bxnf@pkgname
+ {The command is already invalidated}%
+ {\@eha}%
+}
+
+%% \bxnf@jfscale@spec
+\def\bxnf@jfscale@spec{%
+ \unless\ifdim\p@=\bxnf@jfscale\p@
+ s*[\bxnf@jfscale]%
+ \fi
+}
+
+%%<*>\newfontjascale
+\newrobustcmd*\newfontjascale[1]{%
+ \edef\bxnf@tmpa{#1}%
+ \ifx\bxnf@tmpa\bxnf@@star
+ \edef\bxnf@tmpa{\csuse{mcdefault}}%
+ \fi
+ \expandafter\bxnf@setjascale@a\bxnf@tmpa\bxnf@end
+}
+\def\bxnf@setjascale@a#1\bxnf@end{%
+ \ifblank{#1}{%
+ \bxnf@setjascale@real{1}%
+ }{%else
+ \bxnf@setjascale@b#1\bxnf@end%
+ }%
+}
+\def\bxnf@setjascale@b#1#2\bxnf@end{%
+ \ifcat\noexpand#10%
+ \afterassignment\bxnf@setjascale@c\dimen@ii=#1#2\p@\bxnf@stop
+ \else
+ \bxnf@setjascale@fam\bxnf@tmpa
+ \fi
+}
+\def\bxnf@setjascale@c#1\bxnf@stop{%
+ \ifstrempty{#1}{%
+ \edef\bxnf@tmpa{\strip@pt\dimen@ii}%
+ \bxnf@setjascale@real\bxnf@tmpa
+ }{%else
+ \bxnf@err@ivjsc
+ }%
+}
+
+%% \bxnf@setjascale@real
+\let\bxnf@setjascale@real\@gobble
+%% \bxnf@setjascale@fam
+\let\bxnf@setjascale@fam\@gobble
+
+%% \bxnf@annihilate@setjascale
+\def\bxnf@annihilate@setjascale{%
+ \global\let\bxnf@annihilate@setjascale\relax
+ \gdef\newfontjascale##1{%
+ \bxnf@err@najsc
+ }%
+ \global\let\bxnf@setjascale@a\@undefined
+ \global\let\bxnf@setjascale@b\@undefined
+ \global\let\bxnf@setjascale@c\@undefined
+ \global\let\bxnf@setjascale@real\@undefined
+ \global\let\bxnf@setjascale@fam\@undefined
+}
+
+\ifbxnf@ptex %----<*pTeX>
+
+%% \bxnf@setjascale@real
+\def\bxnf@setjascale@real#1{%
+ \edef\bxnf@jfscale{#1}%
+ \bxDebug{jfscale:=\bxnf@jfscale}%
+}
+%% \bxnf@setjascale@fam
+\def\bxnf@setjascale@fam#1{%
+ \letcs\bxnf@tmpb{\cy@encoding/#1/m/n}%
+ \ifdef\bxnf@tmpb{%
+ \expandafter\bxnf@setjascale@fam@a\meaning\bxnf@tmpb\bxnf@end
+ }{%else
+ \bxnf@err@ivjsc
+ }%
+}
+\begingroup
+ \catcode`\S=12
+ \lowercase{%
+ \gdef\bxnf@setjascale@fam@a#1\bxnf@end{%
+ \def\bxnf@tmpb{1}%
+ \bxnf@split@at{<->S*[}{#1}%
+ \ifx\bxnf@pre\relax \bxnf@split@at{<->*[}{#1}\fi
+ \unless\ifx\bxnf@pre\relax
+ \edef\bxnf@tmpb{{]}{\bxnf@post}}%
+ \expandafter\bxnf@split@at\bxnf@tmpb
+ \unless\ifx\bxnf@pre\relax
+ \let\bxnf@tmpb\bxnf@pre
+ \fi
+ \fi
+ \bxnf@setjascale@real\bxnf@tmpb
+ }%
+ }%
+\endgroup
+
+\fi %----</pTeX>
+
%--------------------------------------- Switching of \newfont
%% \bxnf@ltx@newfont
@@ -356,11 +576,11 @@ __\bxnf@select@family{#1}}%
\let\bxnf@ltx@newfont\newfont
%%<*>\enhancenewfont
-\newcommand*\enhancenewfont{%
+\newrobustcmd*\enhancenewfont{%
\let\newfont\newfontx}
%%<*>\noenhancenewfont
-\newcommand*\noenhancenewfont{%
+\newrobustcmd*\noenhancenewfont{%
\let\newfont\bxnf@ltx@newfont}
%% initial