texlive[41818] Master/texmf-dist: bxnewfont (6aug16)
commits+karl at tug.org
commits+karl at tug.org
Sun Aug 7 23:26:42 CEST 2016
Revision: 41818
http://tug.org/svn/texlive?view=revision&revision=41818
Author: karl
Date: 2016-08-07 23:26:42 +0200 (Sun, 07 Aug 2016)
Log Message:
-----------
bxnewfont (6aug16)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/bxnewfont/README.md
trunk/Master/texmf-dist/tex/latex/bxnewfont/bxnewfont.sty
Modified: trunk/Master/texmf-dist/doc/latex/bxnewfont/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/bxnewfont/README.md 2016-08-07 21:26:32 UTC (rev 41817)
+++ trunk/Master/texmf-dist/doc/latex/bxnewfont/README.md 2016-08-07 21:26:42 UTC (rev 41818)
@@ -70,6 +70,10 @@
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.
Modified: trunk/Master/texmf-dist/tex/latex/bxnewfont/bxnewfont.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/bxnewfont/bxnewfont.sty 2016-08-07 21:26:32 UTC (rev 41817)
+++ trunk/Master/texmf-dist/tex/latex/bxnewfont/bxnewfont.sty 2016-08-07 21:26:42 UTC (rev 41818)
@@ -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 at pkgname{bxnewfont}
@@ -34,6 +34,9 @@
%% variables
\newbool{bxnf at ok}
+%% constants
+\def\bxnf@@star{*}
+
%% \bxnf at cond\if...\fi{<true>}{<false>}
\@gobbletwo\if\if \def\bxnf at cond#1\fi{%
#1\expandafter\@firstoftwo
@@ -77,6 +80,7 @@
}%]
}
\def\bxnf at newfontx@b#1[#2]#3{%
+ \bxnf at annihilate@setjascale
\edef\bxnf at enc{#2}%
\edef\bxnf at font{#3}%
\bxnf at split@name
@@ -85,26 +89,6 @@
\ifbxnf at ok \bxnf at make@cmd#1\fi
}
-%% \bxnf at split@name
-% Parses \bxnf at font and sets \bxnf at tfm and \bxnf at atcl.
-\def\bxnf at next#1{%
- \def\bxnf at split@name{%
- \expandafter\bxnf at split@name at a\bxnf at font\bxnf at mk#1\bxnf at end
- }%
- \def\bxnf at split@name at a##1#1##2\bxnf at end{%
- \ifstrempty{##2}{%
- \let\bxnf at tfm\bxnf at font \let\bxnf at atcl\relax
- }{%else
- \def\bxnf at tfm{##1}%
- \bxnf at split@name at b##2\bxnf at end
- }%
- }%
- \def\bxnf at split@name at b##1\bxnf at mk##2\bxnf at end{%
- \def\bxnf at atcl{##1}%
- }%
-}
-\bxnf at next{ }
-
%% \bxnf at check@param
% Sets bxnf at ok.
\def\bxnf at check@param{%
@@ -138,7 +122,7 @@
\unless\ifbxnf at fixed \unless\ifx\bxnf at atcl\relax
\bxnf at error{You cannot use size spec here}{%
The invalid size spec (\bxnf at atcl) is ignored.%
- \MeesageBreak\@ehc}%
+ \MessageBreak\@ehc}%
\fi\fi
}
@@ -176,18 +160,112 @@
__\bxnf at select@family{#1}}%
\endgroup
+%--------------------------------------- parse
+
+%% variables
+\let\bxnf at pre\relax
+\let\bxnf at post\relax
+\let\bxnf at quoted@part\relax
+
+%% \bxnf at split@at{<sep>}{<text>}
+% Splits the text by the given separator.
+% In success, it will set \bxnf at pre and \bxnf at post.
+\def\bxnf at split@at#1#2{%
+ \def\bxnf at next##1#1##2\bxnf at end{%
+ \bxnf at split@at at a{##1}{##2}}%
+ \bxnf at next#2\bxnf at mk#1\bxnf at end
+}
+\def\bxnf at split@at at a#1#2{%
+ \ifstrempty{#2}{%
+ \let\bxnf at pre\relax \let\bxnf at post\relax
+ }{%else
+ \def\bxnf at pre{#1}%
+ \bxnf at split@at at b#2\bxnf at end
+ }%
+}%
+\def\bxnf at split@at at b#1\bxnf at mk#2\bxnf at end{%
+ \def\bxnf at post{#1}%
+}%
+
+%% \bxnf at guard@quote\CS
+% Extract from the string a part enclosed by a pair of quotes,
+% and replaces the part with the cs '\bxnf at quoted@part'.
+% Then the cs is assigned to the content of the part.
+\def\bxnf at guard@quote#1{%
+ \let\bxnf at quoted@part\relax
+ \edef\bxnf at tmpb{{"}{#1}}%
+ \expandafter\bxnf at split@at\bxnf at tmpb
+ \unless\ifx\bxnf at pre\relax
+ \let\bxnf at tmpa\bxnf at pre \edef\bxnf at tmpb{{"}{\bxnf at post}}%
+ \expandafter\bxnf at split@at\bxnf at tmpb
+ \unless\ifx\bxnf at pre\relax
+ \let\bxnf at quoted@part\bxnf at pre
+ \edef#1{\bxnf at tmpa"\noexpand\bxnf at quoted@part"\bxnf at post}%
+ \fi
+ \fi
+}
+
+%% \bxnf at 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 at enclose@quote#1{%
+ \edef\bxnf at tmpa{#1}%
+ \edef\bxnf at tmpb{{"}{\bxnf at tmpa}}%
+ \expandafter\bxnf at split@at\bxnf at tmpb
+ \ifx\bxnf at pre\relax
+ \edef\bxnf at tmpb{{ }{\bxnf at tmpa}}%
+ \expandafter\bxnf at split@at\bxnf at tmpb
+ \unless\ifx\bxnf at pre\relax
+ \edef\bxnf at tmpa{"\bxnf at tmpa"}%
+ \fi
+ \fi
+ \let#1\bxnf at tmpa
+}
+
+%% \bxnf at split@name
+% Parses \bxnf at font and sets \bxnf at tfm and \bxnf at atcl.
+\def\bxnf at split@name{%
+ \let\bxnf at tfm\bxnf at font \let\bxnf at atcl\relax
+ \bxnf at guard@quote\bxnf at tfm
+ \expandafter\bxnf at split@name at a\bxnf at tfm\bxnf at end
+ \bxnf at enclose@quote\bxnf at tfm
+}
+\def\bxnf at split@name at a#1\bxnf at end{%
+ \let\bxnf at pre\relax
+ \def\do##1{%
+ \bxnf at split@name at b{##1}{#1}%
+ }%
+ \bxnf at split@sep at list
+}
+\def\bxnf at split@name at b#1#2{%
+ \ifx\bxnf at pre\relax
+ \bxnf at split@at{ #1}{#2}%
+ \unless\ifx\bxnf at pre\relax
+ \let\bxnf at tfm\bxnf at pre
+ \edef\bxnf at atcl{#1\bxnf at post}%
+ \fi
+ \fi
+}
+\let\do\relax
+\edef\bxnf at split@sep at list{%
+ \do{at}\do{scaled}%
+ \do{\detokenize{at}}%
+ \do{\detokenize{scaled}}%
+}
+
%--------------------------------------- Family name
%% variables
-%\[bxnf at varid/<tfm>] % maximum used id number
-%\[bxnf at prm/<family>] % font parameter ({<enc>}{<size>})
-%\[bxnf at pc/<spec>] % cache
+%\[bxnf at g@varid/<tfm>] % maximum used id number
+%\[bxnf at g@prm/<family>] % font parameter ({<enc>}{<size>})
+%\[bxnf at g@pc/<spec>] % cache
+\let\bxnf at stfm\relax
%% \bxnf at get@family at name
% Generates a family name and returns to \bxnf at fam.
% The name is of the form "<tfm-name>(<id>)".
\def\bxnf at get@family at name{%
- \def\bxnf at tmpa{bxnf at pc/\bxnf at enc:\bxnf at tfm:%
+ \def\bxnf at tmpa{bxnf at g@pc/\bxnf at enc:\bxnf at tfm:%
\ifbxnf at fixed \the\dimexpr\bxnf at size\relax \fi}%
\letcs\bxnf at fam{\bxnf at tmpa}%
\ifdef\bxnf at fam{%
@@ -194,27 +272,58 @@
\bxDebug{\bxnf at tmpa==\bxnf at fam}%
\bxnf at oktrue
}{%else
- \csnumdef{bxnf at varid/\bxnf at tfm}{\csuse{bxnf at varid/\bxnf at tfm}+1}%
- \edef\bxnf at fam{\bxnf at tfm(\csuse{bxnf at varid/\bxnf at tfm})}%
- \cslet{\bxnf at tmpa}\bxnf at fam
+ \bxnf at sanitize@tfmname\bxnf at stfm
+ \csnumgdef{bxnf at g@varid/\bxnf at stfm}{\csuse{bxnf at g@varid/\bxnf at stfm}+1}%
+ \edef\bxnf at fam{\bxnf at stfm*\csuse{bxnf at g@varid/\bxnf at stfm}*}%
+ \global\cslet{\bxnf at tmpa}\bxnf at fam
\bxDebug{\bxnf at tmpa:=\bxnf at fam}%
\bxnf at okfalse
}%
}
+%% \bxnf at sanitize@tfmname\CS
+\def\bxnf at sanitize@tfmname#1{%
+ \begingroup
+ \let\bxnf at pre\relax
+ \let\do\bxnf at sanitize@tfmname at a
+ \bxnf at sanitize@list
+ \ifx\bxnf at pre\relax
+ \global\let\bxnf at g@tmpa\bxnf at tfm
+ \else
+ \global\let\bxnf at g@tmpa\bxnf@@sanitized
+ \fi
+ \endgroup
+ \let#1\bxnf at g@tmpa
+}
+\def\bxnf at sanitize@tfmname at a#1{%
+ \ifx\bxnf at pre\relax
+ \edef\bxnf at tmpa{{#1}{\bxnf at tfm}}%
+ \expandafter\bxnf at split@at\bxnf at tmpa
+ \fi
+}
+\def\bxnf@@sanitized{(OpenType)}
+\def\bxnf at sanitize@list{%
+ \do{ }\do{:}\do{,}\do{;}\do{=}\do{/}%
+}
+
%% \def\bxnf at set@family at param
-% Sets \[bxnf at prm/*].
+% Sets \[bxnf at g@prm/*].
\def\bxnf at set@family at param{%
- \csedef{bxnf at prm/\bxnf at fam}{{\bxnf at enc}%
+ \csxdef{bxnf at g@prm/\bxnf at fam}{{\bxnf at enc}%
{\ifbxnf at fixed \expandafter\rem at pt\bxnf at size \fi}}%
- \bxDebug{bxnf at prm/\bxnf at fam:=\csuse{bxnf at prm/\bxnf at fam}}%
+ \bxDebug{bxnf at g@prm/\bxnf at fam:=\csuse{bxnf at g@prm/\bxnf at fam}}%
}
%% \bxnf at declare@family
\def\bxnf at declare@family{%
\DeclareFontFamily{\bxnf at enc}{\bxnf at fam}{}%
+ \let\bxnf at tmpb\@empty
+ \ifcase\bxnf at type\or
+ \or \let\bxnf at tmpb\bxnf at jfscale@spec
+ \or \let\bxnf at tmpb\bxnf at jfscale@spec
+ \fi
\DeclareFontShape{\bxnf at enc}{\bxnf at fam}{m}{n}%
- {<->\bxnf at tfm}{}%
+ {<->\bxnf at tmpb\bxnf at tfm}{}%
% In pTeX, a dummy entry must be declared for the
% encoding counterpart.
\let\bxnf at tmpb\relax
@@ -232,7 +341,7 @@
%% \bxnf at select@family{<family>}
\def\bxnf at select@family#1{%
\edef\bxnf at next{\noexpand\bxnf at select@family at a
- {#1}\csuse{bxnf at prm/#1}}%
+ {#1}\csuse{bxnf at g@prm/#1}}%
\bxnf at next
}
\def\bxnf at select@family at a#1#2#3{%
@@ -306,7 +415,7 @@
%% \bxnf at curr@font\CS\Xfont
\def\bxnf at curr@font#1#2{%
- \xdef#1{\expandafter\meaning\the#2}%
+ \xdef#1{\fontname#2}%
}
\ifbxnf at ptex %----<*pTeX>
@@ -349,6 +458,117 @@
\fi %----</pTeX>
+%--------------------------------------- Ja-font scaling
+
+%% variables
+\def\bxnf at jfscale{1}
+
+%% error message
+\def\bxnf at err@ivjsc{%
+ \PackageError\bxnf at pkgname
+ {Invalid argument given to \string\newfontjascale
+ \MessageBreak(\bxnf at tmpa)}%
+ {\@eha}%
+}
+\def\bxnf at err@najsc{%
+ \PackageError\bxnf at pkgname
+ {The command is already invalidated}%
+ {\@eha}%
+}
+
+%% \bxnf at jfscale@spec
+\def\bxnf at jfscale@spec{%
+ \unless\ifdim\p@=\bxnf at jfscale\p@
+ s*[\bxnf at jfscale]%
+ \fi
+}
+
+%%<*>\newfontjascale
+\newrobustcmd*\newfontjascale[1]{%
+ \edef\bxnf at tmpa{#1}%
+ \ifx\bxnf at tmpa\bxnf@@star
+ \edef\bxnf at tmpa{\csuse{mcdefault}}%
+ \fi
+ \expandafter\bxnf at setjascale@a\bxnf at tmpa\bxnf at end
+}
+\def\bxnf at setjascale@a#1\bxnf at end{%
+ \ifblank{#1}{%
+ \bxnf at setjascale@real{1}%
+ }{%else
+ \bxnf at setjascale@b#1\bxnf at end%
+ }%
+}
+\def\bxnf at setjascale@b#1#2\bxnf at end{%
+ \ifcat\noexpand#10%
+ \afterassignment\bxnf at setjascale@c\dimen at ii=#1#2\p@\bxnf at stop
+ \else
+ \bxnf at setjascale@fam\bxnf at tmpa
+ \fi
+}
+\def\bxnf at setjascale@c#1\bxnf at stop{%
+ \ifstrempty{#1}{%
+ \edef\bxnf at tmpa{\strip at pt\dimen at ii}%
+ \bxnf at setjascale@real\bxnf at tmpa
+ }{%else
+ \bxnf at err@ivjsc
+ }%
+}
+
+%% \bxnf at setjascale@real
+\let\bxnf at setjascale@real\@gobble
+%% \bxnf at setjascale@fam
+\let\bxnf at setjascale@fam\@gobble
+
+%% \bxnf at annihilate@setjascale
+\def\bxnf at annihilate@setjascale{%
+ \global\let\bxnf at annihilate@setjascale\relax
+ \gdef\newfontjascale##1{%
+ \bxnf at err@najsc
+ }%
+ \global\let\bxnf at setjascale@a\@undefined
+ \global\let\bxnf at setjascale@b\@undefined
+ \global\let\bxnf at setjascale@c\@undefined
+ \global\let\bxnf at setjascale@real\@undefined
+ \global\let\bxnf at setjascale@fam\@undefined
+}
+
+\ifbxnf at ptex %----<*pTeX>
+
+%% \bxnf at setjascale@real
+\def\bxnf at setjascale@real#1{%
+ \edef\bxnf at jfscale{#1}%
+ \bxDebug{jfscale:=\bxnf at jfscale}%
+}
+%% \bxnf at setjascale@fam
+\def\bxnf at setjascale@fam#1{%
+ \letcs\bxnf at tmpb{\cy at encoding/#1/m/n}%
+ \ifdef\bxnf at tmpb{%
+ \expandafter\bxnf at setjascale@fam at a\meaning\bxnf at tmpb\bxnf at end
+ }{%else
+ \bxnf at err@ivjsc
+ }%
+}
+\begingroup
+ \catcode`\S=12
+ \lowercase{%
+ \gdef\bxnf at setjascale@fam at a#1\bxnf at end{%
+ \def\bxnf at tmpb{1}%
+ \bxnf at split@at{<->S*[}{#1}%
+ \ifx\bxnf at pre\relax \bxnf at split@at{<->*[}{#1}\fi
+ \unless\ifx\bxnf at pre\relax
+ \edef\bxnf at tmpb{{]}{\bxnf at post}}%
+ \expandafter\bxnf at split@at\bxnf at tmpb
+ \unless\ifx\bxnf at pre\relax
+ \let\bxnf at tmpb\bxnf at pre
+ \fi
+ \fi
+ \bxnf at setjascale@real\bxnf at tmpb
+ }%
+ }%
+\endgroup
+
+\fi %----</pTeX>
+
%--------------------------------------- Switching of \newfont
%% \bxnf at ltx@newfont
@@ -356,11 +576,11 @@
\let\bxnf at ltx@newfont\newfont
%%<*>\enhancenewfont
-\newcommand*\enhancenewfont{%
+\newrobustcmd*\enhancenewfont{%
\let\newfont\newfontx}
%%<*>\noenhancenewfont
-\newcommand*\noenhancenewfont{%
+\newrobustcmd*\noenhancenewfont{%
\let\newfont\bxnf at ltx@newfont}
%% initial
More information about the tex-live-commits
mailing list