summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/zxjafont
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-05-04 22:10:36 +0000
committerKarl Berry <karl@freefriends.org>2018-05-04 22:10:36 +0000
commit9f5f371b6edfed9acecb0137104ce2e1bc796e60 (patch)
tree5f900663431d7afd34247ea122ee85aecd663f52 /Master/texmf-dist/tex/latex/zxjafont
parent7a7ea7aa5948c4be61b65cd43bd4d3a899ba2b75 (diff)
zxjafont (4may18)
git-svn-id: svn://tug.org/texlive/trunk@47613 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/zxjafont')
-rw-r--r--Master/texmf-dist/tex/latex/zxjafont/zxjafont.sty214
1 files changed, 154 insertions, 60 deletions
diff --git a/Master/texmf-dist/tex/latex/zxjafont/zxjafont.sty b/Master/texmf-dist/tex/latex/zxjafont/zxjafont.sty
index 271a3f2e043..d935bc8309c 100644
--- a/Master/texmf-dist/tex/latex/zxjafont/zxjafont.sty
+++ b/Master/texmf-dist/tex/latex/zxjafont/zxjafont.sty
@@ -1,82 +1,121 @@
-%
-% zxjafont.sty
-%
-%%%% package declaration
-\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{zxjafont}[2015/05/08 v0.3]
-\RequirePackage{ifxetex}
-\RequireXeTeX
+%%
+%% This is file 'zxjafont.sty'.
+%%
+%% Copyright (c) 2018 Takayuki YATO (aka. "ZR")
+%% GitHub: https://github.com/zr-tex8r
+%% Twitter: @zr_tex8r
+%%
+%% This package is distributed under the MIT License.
+%%
-%%%% preparation
+%% package declaration
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zxjafont}[2018/05/03 v0.4-pre]
\def\zxjf@pkgname{zxjafont}
-\def\zxjf@error{\PackageError\zxjf@pkgname}
-\def\zxjf@warn{\PackageInfo\zxjf@pkgname}
+
+%% preparation
+\RequirePackage{ifxetex}\RequireXeTeX
+\providecommand{\bxDebug}[1]{}
+
+%--------------------------------------- general
+
+%% packages
\RequirePackage{fontspec}
\RequirePackage{keyval}
-\ifx\bxUseDebug\relax \let\zxjf@debug\@gobble
-\else \def\zxjf@debug#1{\typeout{\zxjf@pkgname: #1}}
-\fi
+\RequirePackage{etoolbox}
+
+%% errors
+\def\zxjf@err@ivval#1#2{%
+ \PackageError\zxjf@pkgname
+ {Invalid value '#2' for option #1}\@ehc}
+
+%--------------------------------------- handle options
+
+%% constants
+\chardef\zxjf@cjkshape@@none=0
+\chardef\zxjf@cjkshape@@xc=1 % 90jis
+\chardef\zxjf@cjkshape@@mmiv=2 % jis2004
+
+%% variables
+\let\zxjf@main@preset\relax
+\let\zxjf@sub@preset\@empty
+\newif\ifzxjf@prop
+\newif\ifzxjf@oneweight
+\let\zxjf@cjkshape\zxjf@cjkshape@@none
+\let\zxjf@scale\relax
+\let\zxjf@feat\@empty
+\newif\ifzxjf@zxjatype
-%%%% options handling
%% \zxjf@main@preset
\def\zxjf@all@main@preset{%
ms,ipa,ipaex,%
- ms-hg,ipa-hg,ipaex-hg,moga,moga-90,%
+ ms-hg,ipa-hg,ipaex-hg,moga,moga-90,ume,%
kozuka-pro,kozuka-pr6,kozuka-pr6n,hiragino-pro,hiragino-pron,%
- morisawa-pro,morisawa-pr6n,yu-win,yu-osx,%
+ morisawa-pro,morisawa-pr6n,yu-win,yu-win10,yu-osx,%
+ sourcehan,sourcehan-jp,noto,noto-jp,%
kozuka4,kozuka6,kozuka6n,hiragino,%
ms-dx,ipa-dx,hiragino-dx,moga-mobo}
+
+%% \zxjf@main@sub@preset
\def\zxjf@all@sub@preset{%
hg,hiraginomg-pro,hiraginomg-pron,mobo,mobo-90,maruberi,%
hiraginomg}
-\let\zxjf@main@preset\relax
+
+% preset options
\def\zxjf@do#1{\DeclareOption{#1}{\def\zxjf@main@preset{#1}}}
\@for\zxjf@x:=\zxjf@all@main@preset\do{%
\expandafter\zxjf@do\expandafter{\zxjf@x}}
-\let\zxjf@sub@preset\@empty
\def\zxjf@do#1{\DeclareOption{#1}{\zxjf@add@sub@preset{#1}}}
\@for\zxjf@x:=\zxjf@all@sub@preset\do{%
\expandafter\zxjf@do\expandafter{\zxjf@x}}
\def\zxjf@add@sub@preset#1{%
\edef\zxjf@sub@preset{\zxjf@sub@preset#1,}}
-%
-\newif\ifzxjf@prop
+% 'prop'
\DeclareOption{prop}{\zxjf@proptrue}
-\newif\ifzxjf@oneweight
+% 'oneweight'
\DeclareOption{oneweight}{\zxjf@oneweighttrue}
-\define@key{zxjf}{scale}{\def\zxjf@scale{#1}}
-% options using keyval
-\let\zxjf@scale\relax
-\define@key{zxjf}{scale}{\def\zxjf@scale{#1}}
-\let\zxjf@feat\@empty
-\define@key{zxjf}{feature}{\def\zxjf@feat{#1}}
+% '90jis'/'jis2004'
+\DeclareOption{90jis}{\let\zxjf@cjkshape\zxjf@cjkshape@@xc}
+\DeclareOption{jis2004}{\let\zxjf@cjkshape\zxjf@cjkshape@@mmiv}
+
+%% options using keyval
\DeclareOption*{\def\zxjf@nxt{\setkeys{zxjf}}%
\expandafter\zxjf@nxt\expandafter{\CurrentOption}}
-% dispatch
+% 'scale=<real>'
+\define@key{zxjf}{scale}{\def\zxjf@scale{#1}}
+% 'feature=<text>'
+\define@key{zxjf}{feature}{\def\zxjf@feat{#1}}
+
+%% dispatch
\let\@org@use@ption\@use@ption
\def\@use@ption{\csname ds@\CurrentOption \endcsname}
\ProcessOptions*
\let\@use@ption\@org@use@ption
-% preset must be given
+
+%% preset must be given
\ifx\zxjf@main@preset\relax
- \zxjf@error{Preset name not specified}
- {You must give one of the following names as option.\MessageBreak
- \space\space\zxjf@all@main@preset}
- \endinput\fi
+ \PackageError\zxjf@pkgname
+ {Preset name not specified}
+ {You must give one of the following names as option.\MessageBreak
+ \space\space\zxjf@all@main@preset}
+\expandafter\endinput\fi\relax
-%%%% detect bxjatype
-\newif\ifzxjf@zxjatype
+%% detect bxjatype
\@ifpackageloaded{zxjatype}{\zxjf@zxjatypetrue}{}
\AtBeginDocument{%
- \ifzxjf@zxjatype\else\@ifpackageloaded{zxjatype}{%
- \zxjf@error{zxjatype must be loaded before me}\@ehc
- }\fi}
+ \unless\ifzxjf@zxjatype
+ \@ifpackageloaded{zxjatype}{%
+ \PackageError\zxjf@pkgname
+ {zxjatype must be loaded before me}\@ehc
+ }{}%
+ \fi}
\ifzxjf@zxjatype\ifzxjf@prop
- \zxjf@error{Option 'prop' cannot be used with zxjatype}\@ehc
+ \PackageError\zxjf@pkgname
+ {Option 'prop' cannot be used with zxjatype}\@ehc
\zxjf@propfalse
\fi\fi
-%%%% decide scale factor
+%% decide scale factor
\ifx\zxjf@scale\relax
% If zxjatype is used, try \JaFontScale, \zxjt@scale,
% and \__zxjt_scale_tl.
@@ -84,8 +123,7 @@
\ifdefined\JaFontScale \let\zxjf@scale\JaFontScale
\else\ifdefined\zxjt@scale \let\zxjf@scale\zxjt@scale
\else\ifcsname __zxjt_scale_tl\endcsname
- \expandafter\let\expandafter\zxjf@scale
- \csname __zxjt_scale_tl\endcsname
+ \letcs\zxjf@scale{__zxjt_scale_tl}
\fi\fi\fi
\fi
\ifx\zxjf@scale\relax % still unknown
@@ -98,11 +136,22 @@
\def\zxjf@scale{1}%
\fi
\fi
+
+%% resolve CJKshape
+\edef\zxjf@feat{%
+ \ifcase\zxjf@cjkshape % none
+ \or CJKShape=JIS1990,% 90jis
+ \or CJKShape=JIS2004,% jis2004
+ \fi
+ \zxjf@feat}
+
+%% \zxjf@xfeat
+% All fontspec options including scale.
\edef\zxjf@xfeat{Scale=\zxjf@scale,\zxjf@feat}
-\zxjf@debug{scale=\zxjf@scale/feat={\zxjf@feat}/%
+\bxDebug{zxjafont>>scale=\zxjf@scale/feat={\zxjf@feat}/%
preset=\zxjf@main@preset/\zxjf@sub@preset}
-%%-------- preset japanese font mappings
+%--------------------------------------- font setup helpers
%% \zxjf@setmainfont{<attributes>}{<fam_name>}, etc.
\ifzxjf@zxjatype
@@ -110,8 +159,8 @@
\def\zxjf@setsansfont#1{\setjasansfont[\zxjf@xfeat,#1]}
\def\zxjf@setmonofont#1{\setjamonofont[\zxjf@xfeat,#1]}
\def\zxjf@newfamily#1#2#3{%
- \expandafter\def\csname #1family\expandafter\endcsname\expandafter
- {\csname a#1family\endcsname\CJKfamily{#1}}%
+ \csedef{#1family}{%
+ \expandonce{\csname a#1family\endcsname}\noexpand\CJKfamily{#1}}%
\expandafter\newfontfamily\csname a#1family\endcsname[\zxjf@feat,#2]{#3}%
\setjafamilyfont{#1}[\zxjf@xfeat,#2]{#3}}
\else
@@ -122,10 +171,13 @@
\expandafter\newfontfamily\csname #1family\endcsname[\zxjf@xfeat,#2]}
\fi
+%--------------------------------------- preset japanese font mappings
+
%% \zxjf@declare@preset{<name>}{<text>}, etc.
\def\zxjf@declare@preset#1{%
\expandafter\zxjf@decl@preset@a\csname zxjf@the@preset@#1\endcsname}
\def\zxjf@decl@preset@a#1{\@onlypreamble#1\def#1}
+\zxjf@declare@preset{}{}
\@onlypreamble\zxjf@uniweight
\def\zxjf@uniweight#1#2{%
\zxjf@uniweight@opt{#1}{#2}{}}
@@ -148,21 +200,25 @@
\zxjf@setsansfont{#6,BoldFont=#4}{#3}%
\zxjf@setmonofont{#6,BoldFont=#4}{#3}%
\fi}
+%% \zxjf@declare@preset@with@prop{<name>}{<text>}
+\def\zxjf@declare@preset@with@prop#1#2{%
+ \zxjf@declare@preset{#1}{#2{RawFeature=-palt;-kern}}%
+ \zxjf@declare@preset{#1/prop}{#2{RawFeature=+palt;+Wkern}}}
%% \zxjf@declare@preset@alias{<name1>}{<name2>}
\def\zxjf@declare@preset@alias#1#2{%
- \expandafter\let\csname zxjf@the@preset@#1\expandafter\endcsname
- \csname zxjf@the@preset@#2\endcsname}
+ \csletcs{zxjf@the@preset@#1}{zxjf@the@preset@#2}}
+%% \zxjf@declare@preset@alias@with@prop{<name1>}{<name2>}
+\def\zxjf@declare@preset@alias@with@prop#1#2{%
+ \zxjf@declare@preset@alias{#1}{#2}%
+ \zxjf@declare@preset@alias{#1/prop}{#2/prop}}
%% \zxjf@use@preset{<name>}
\def\zxjf@use@preset#1{%
- \ifzxjf@prop \zxjf@use@preset@a{#1/prop}%
- \else \let\zxjf@nxt\relax \fi
- \ifx\zxjf@nxt\relax \zxjf@use@preset@a{#1}\fi
+ \undef\zxjf@nxt
+ \ifzxjf@prop \letcs\zxjf@nxt{zxjf@the@preset@#1/prop}\fi
+ \unless\ifdefined\zxjf@nxt \letcs\zxjf@nxt{zxjf@the@preset@#1}\fi
\zxjf@nxt}
-\def\zxjf@use@preset@a#1{%
- \expandafter\let\expandafter\zxjf@nxt
- \csname zxjf@the@preset@#1\endcsname}
%% definitions of main preset mappings
\zxjf@declare@preset{ms}{%
@@ -196,6 +252,9 @@
\zxjf@declare@preset{moga-90}{%
\zxjf@multiweight{MogaEx90Mincho}{MogaEx90Mincho Bold}%
{MogaEx90Gothic}{MogaEx90Gothic Bold}{MogaEx90Gothic}}
+\zxjf@declare@preset{ume}{%
+ \zxjf@multiweight{Ume Mincho}{Ume Mincho}%
+ {Ume Gothic}{Ume Gothic O5}{Ume Gothic O5}}
\zxjf@declare@preset{kozuka-pro}{%
\zxjf@multiweight@opt{KozMinPro-Regular}{KozMinPro-Bold}%
{KozGoPro-Regular}{KozGoPro-Bold}%
@@ -260,6 +319,10 @@
\zxjf@multiweight@opt{YuMincho-Regular}{YuMincho-Demibold}%
{YuGothic-Regular}{YuGothic-Bold}%
{YuGothic-Regular}{RawFeature=+palt;+kern}}
+\zxjf@declare@preset@with@prop{yu-win10}{%
+ \zxjf@multiweight@opt{YuMincho-Regular}{YuMincho-Demibold}%
+ {YuGothic-Regular}{YuGothic-Bold}%
+ {YuGothic-Medium}}
\zxjf@declare@preset{yu-osx}{%
\zxjf@multiweight@opt{YuMincho-Medium}{YuMincho-Demibold}%
{YuGothic-Medium}{YuGothic-Bold}%
@@ -268,6 +331,22 @@
\zxjf@multiweight@opt{YuMincho-Medium}{YuMincho-Demibold}%
{YuGothic-Medium}{YuGothic-Bold}%
{YuGothic-Medium}{RawFeature=+palt;+kern}}
+\zxjf@declare@preset@with@prop{sourcehan}{%
+ \zxjf@multiweight@opt{SourceHanSerif-Regular}{SourceHanSerif-Bold}%
+ {SourceHanSans-Regular}{SourceHanSans-Bold}%
+ {SourceHanSans-Medium}}
+\zxjf@declare@preset@with@prop{sourcehan-jp}{%
+ \zxjf@multiweight@opt{SourceHanSerifJP-Regular}{SourceHanSerifJP-Bold}%
+ {SourceHanSansJP-Regular}{SourceHanSansJP-Bold}%
+ {SourceHanSansJP-Medium}}
+\zxjf@declare@preset@with@prop{noto}{%
+ \zxjf@multiweight@opt{NotoSerifCJKjp-Regular}{NotoSerifCJKjp-Bold}%
+ {NotoSansCJKjp-Regular}{NotoSansCJKjp-Bold}%
+ {NotoSansCJKjp-Medium}}
+\zxjf@declare@preset@with@prop{noto-jp}{%
+ \zxjf@multiweight@opt{NotoSerifJP-Regular}{NotoSerifJP-Bold}%
+ {NotoSansJP-Regular}{NotoSansJP-Bold}%
+ {NotoSansJP-Medium}}
%(obsolete)
\zxjf@declare@preset{kozuka4}{%
\zxjf@uniweight@opt{Kozuka Mincho Pro}{Kozuka Gothic Pro}%
@@ -294,14 +373,18 @@
\zxjf@uniweight@opt{Hiragino Mincho Pro W3}{Hiragino Kaku Gothic Pro W6}%
{RawFeature=+palt;+kern}}
%(alias)
+\zxjf@declare@preset@alias@with@prop{kozuka}{kozuka-pro}
+\zxjf@declare@preset@alias@with@prop{morisawa}{morisawa-pro}
+\zxjf@declare@preset@alias{moga-mobo}{moga}
+%(alias-obsolete)
\zxjf@declare@preset@alias{ms-dx}{ms-hg}
\zxjf@declare@preset@alias{ms-dx/prop}{ms-hg/prop}
\zxjf@declare@preset@alias{ipa-dx}{ipa-hg}
\zxjf@declare@preset@alias{ipa-dx/prop}{ipa-hg/prop}
\zxjf@declare@preset@alias{hiragino-dx}{hiragino-pro}
\zxjf@declare@preset@alias{hiragino-dx/prop}{hiragino-pro/prop}
-\zxjf@declare@preset@alias{moga-mobo}{moga}
+%% definitions of sub preset mappings
\zxjf@declare@preset{hg}{%
\zxjf@newfamily{hgmc}{BoldFont=HGSMinchoE}{HGSMinchoB}%
\zxjf@newfamily{hgpr}{}{HGSSoeiPresenceEB}%
@@ -342,18 +425,29 @@
\zxjf@declare@preset{maruberi}{%
\zxjf@newfamily{mmg}{}{MotoyaLMaru}}
-%%%% ... and invokes the specified one!
+%% warn for deprecated presets
+\@for\zxjf@x:={%
+ kozuka4,kozuka6,kozuka6n,hiragino,ms-dx,ipa-dx,hiragino-dx%
+}\do{%
+ \ifx\zxjf@x\zxjf@main@preset
+ \PackageWarningNoLine\zxjf@pkgname
+ {Old preset '\zxjf@x' is deprecated\MessageBreak
+ (see the manual for detail)}%
+ \fi}
+
+%% ... and invokes the specified one!
\zxjf@use@preset{\zxjf@main@preset}
\@for\zxjf@x:=\zxjf@sub@preset\do{\zxjf@use@preset\zxjf@x}
-%%------ and some extras
+%--------------------------------------- and some extras
-\def\useeasyjapanesesettings{%
+%%<*> \useeasyjapanesesettings
+\newcommand*\useeasyjapanesesettings{%
\XeTeXlinebreaklocale "ja"\relax
\XeTeXlinebreakskip=0pt plus 1pt minus 0.1pt\relax
\XeTeXlinebreakpenalty=0\relax
}
-%%------ all done
+%--------------------------------------- all done
\endinput
%% EOF