%% %% This is file 'zxjafont.sty'. %% %% Copyright (c) 2009-2020 Takayuki YATO (aka. "ZR") %% GitHub: https://github.com/zr-tex8r %% Twitter: @zr_tex8r %% %% This package is distributed under the MIT License. %% %% package declaration \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{zxjafont}[2020/01/12 v0.6] \def\zxjf@pkgname{zxjafont} %% preparation \RequirePackage{ifxetex}\RequireXeTeX \providecommand{\bxDebug}[1]{} %--------------------------------------- general %% packages \RequirePackage{fontspec} \RequirePackage{keyval} \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 %% \zxjf@main@preset \def\zxjf@all@main@preset{% %(uniweight) ms,ipa,ipaex,% %(multiweight) 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-win10,yu-osx,% sourcehan,sourcehan-jp,noto,noto-jp,haranoaji,% %(alias) kozuka,morisawa,moga-mobo-ex,noto-otf,hiragino} %% \zxjf@main@sub@preset \def\zxjf@all@sub@preset{% hg,hiraginomg-pro,hiraginomg-pron,mobo,mobo-90,maruberi,% hiraginomg} % 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}} \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,}} % 'prop' \DeclareOption{prop}{\zxjf@proptrue} \DeclareOption{noprop}{\zxjf@propfalse} % 'oneweight' \DeclareOption{oneweight}{\zxjf@oneweighttrue} \DeclareOption{nooneweight}{\zxjf@oneweightfalse} % '90jis'/'jis2004' \DeclareOption{jis90}{\let\zxjf@cjkshape\zxjf@cjkshape@@xc} \DeclareOption{90jis}{\let\zxjf@cjkshape\zxjf@cjkshape@@xc} \DeclareOption{jis2004}{\let\zxjf@cjkshape\zxjf@cjkshape@@mmiv} \DeclareOption{2004jis}{\let\zxjf@cjkshape\zxjf@cjkshape@@mmiv} % abolished presets \@onlypreamble\zxjf@err@abpre \def\zxjf@err@abpre#1{% \PackageError\zxjf@pkgname {The old preset '#1' is *abolished*}{\@ehc}} \@for\zxjf@x:={% kozuka4,kozuka6,kozuka6n,ms-dx,ipa-dx,hiragino-dx% }\do{\DeclareOption{\zxjf@x}{\zxjf@err@abpre{\CurrentOption}}} %% options using keyval \DeclareOption*{\def\zxjf@nxt{\setkeys{zxjf}}% \expandafter\zxjf@nxt\expandafter{\CurrentOption}} % 'scale=' \define@key{zxjf}{scale}{\def\zxjf@scale{#1}} % 'feature=' \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 \ifx\zxjf@main@preset\relax \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 \@ifpackageloaded{zxjatype}{\zxjf@zxjatypetrue}{} \AtBeginDocument{% \unless\ifzxjf@zxjatype \@ifpackageloaded{zxjatype}{% \PackageError\zxjf@pkgname {zxjatype must be loaded before me}\@ehc }{}% \fi} \ifzxjf@zxjatype\ifzxjf@prop \PackageError\zxjf@pkgname {Option 'prop' cannot be used with zxjatype}\@ehc \zxjf@propfalse \fi\fi %% decide scale factor \ifx\zxjf@scale\relax % If zxjatype is used, try \JaFontScale, \zxjt@scale, % and \__zxjt_scale_tl. \ifzxjf@zxjatype \ifdefined\JaFontScale \let\zxjf@scale\JaFontScale \else\ifdefined\zxjt@scale \let\zxjf@scale\zxjt@scale \else\ifcsname __zxjt_scale_tl\endcsname \letcs\zxjf@scale{__zxjt_scale_tl} \fi\fi\fi \fi \ifx\zxjf@scale\relax % still unknown % Try \Cjascale and \jsScale. \ifdefined\Cjascale \let\zxjf@scale\Cjascale \else\ifdefined\jsScale \let\zxjf@scale\jsScale \fi\fi \fi \ifx\zxjf@scale\relax % still unknown \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} \bxDebug{zxjafont>>scale=\zxjf@scale/feat={\zxjf@feat}/% preset=\zxjf@main@preset/\zxjf@sub@preset} %--------------------------------------- font setup helpers %% \zxjf@setmainfont{}{}, etc. \ifzxjf@zxjatype \def\zxjf@setmainfont#1{\setjamainfont[\zxjf@xfeat,#1]} \def\zxjf@setsansfont#1{\setjasansfont[\zxjf@xfeat,#1]} \def\zxjf@setmonofont#1{\setjamonofont[\zxjf@xfeat,#1]} \def\zxjf@newfamily#1#2#3{% \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 \def\zxjf@setmainfont#1{\setmainfont[\zxjf@xfeat,#1]} \def\zxjf@setsansfont#1{\setsansfont[\zxjf@xfeat,#1]} \def\zxjf@setmonofont#1{\setmonofont[\zxjf@xfeat,#1]} \def\zxjf@newfamily#1#2{% \expandafter\newfontfamily\csname #1family\endcsname[\zxjf@xfeat,#2]} \fi %--------------------------------------- preset japanese font mappings %% \zxjf@declare@preset{}{}, 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}{}} \@onlypreamble\zxjf@uniweight@opt \def\zxjf@uniweight@opt#1#2#3{% \zxjf@setmainfont{#3,BoldFont=#2}{#1}% \zxjf@setsansfont{#3}{#2}% \zxjf@setmonofont{#3}{#2}} \@onlypreamble\zxjf@multiweight \def\zxjf@multiweight#1#2#3#4#5{% \zxjf@multiweight@opt{#1}{#2}{#3}{#4}{#5}{}} \@onlypreamble\zxjf@multiweight@opt \def\zxjf@multiweight@opt#1#2#3#4#5#6{% \ifzxjf@oneweight \zxjf@setmainfont{#6,BoldFont=#5}{#1}% \zxjf@setsansfont{#6}{#5}% \zxjf@setmonofont{#6}{#5}% \else \zxjf@setmainfont{#6,BoldFont=#2}{#1}% \zxjf@setsansfont{#6,BoldFont=#4}{#3}% \zxjf@setmonofont{#6,BoldFont=#4}{#3}% \fi} %% \zxjf@declare@preset@with@prop{}{} \def\zxjf@declare@preset@with@prop#1#2{% \zxjf@declare@preset{#1}{#2{RawFeature=-palt;-kern}}% \zxjf@declare@preset{#1/prop}{#2{RawFeature=+palt;+kern}}} %% \zxjf@declare@preset@alias{}{} \def\zxjf@declare@preset@alias#1#2{% \csletcs{zxjf@the@preset@#1}{zxjf@the@preset@#2}} %% \zxjf@declare@preset@alias@with@prop{}{} \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{} \def\zxjf@use@preset#1{% \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} %% definitions of main preset mappings \zxjf@declare@preset{ms}{% \zxjf@uniweight{MS-Mincho}{MS-Gothic}} \zxjf@declare@preset{ms/prop}{% \zxjf@uniweight{MS-PMincho}{MS-PGothic}} \zxjf@declare@preset{ms-hg}{% \zxjf@multiweight{MS-Mincho}{HGMinchoE}% {HGGothicM}{HGGothicE}{MS-Gothic}} \zxjf@declare@preset{ms-hg/prop}{% \zxjf@multiweight{MS-PMincho}{HGPMinchoE}% {HGPGothicM}{HGGothicE}{MS-PGothic}} \zxjf@declare@preset{ipa}{% \zxjf@uniweight{IPAMincho}{IPAGothic}} \zxjf@declare@preset{ipa/prop}{% \zxjf@uniweight{IPAPMincho}{IPAPGothic}} \zxjf@declare@preset{ipa-hg}{% \zxjf@multiweight{IPAMincho}{HGMinchoE}% {HGGothicM}{HGGothicE}{IPAGothic}} \zxjf@declare@preset{ipa-hg/prop}{% \zxjf@multiweight{IPAPMincho}{HGPMinchoE}% {HGPGothicM}{HGGothicE}{IPAPGothic}} \zxjf@declare@preset{ipaex}{% \zxjf@uniweight{ipaexm.ttf}{ipaexg.ttf}} \zxjf@declare@preset{ipaex-hg}{% \zxjf@multiweight{ipaexm.ttf}{HGSMinchoE}% {HGSGothicM}{HGSGothicE}{ipaexg.ttf}} \zxjf@declare@preset{moga}{% \zxjf@multiweight{MogaExMincho}{MogaExMincho Bold}% {MogaExGothic}{MogaExGothic Bold}{MogaExGothic}} \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}% {KozGoPro-Medium}{RawFeature=-palt;-kern}} \zxjf@declare@preset{kozuka-pro/prop}{% \zxjf@multiweight@opt{KozMinPro-Regular}{KozMinPro-Bold}% {KozGoPro-Regular}{KozGoPro-Bold}% {KozGoPro-Medium}{RawFeature=+palt;+kern}} \zxjf@declare@preset{kozuka-pr6}{% \zxjf@multiweight@opt{KozMinProVI-Regular}{KozMinProVI-Bold}% {KozGoProVI-Regular}{KozGoProVI-Bold}% {KozGoProVI-Medium}{RawFeature=-palt;-kern}} \zxjf@declare@preset{kozuka-pr6/prop}{% \zxjf@multiweight@opt{KozMinProVI-Regular}{KozMinProVI-Bold}% {KozGoProVI-Regular}{KozGoProVI-Bold}% {KozGoProVI-Medium}{RawFeature=+palt;+kern}} \zxjf@declare@preset{kozuka-pr6n}{% \zxjf@multiweight@opt{KozMinPr6N-Regular}{KozMinPr6N-Bold}% {KozGoPr6N-Regular}{KozGoPr6N-Bold}% {KozGoPr6N-Medium}{RawFeature=-palt;-kern}} \zxjf@declare@preset{kozuka-pr6n/prop}{% \zxjf@multiweight@opt{KozMinPr6N-Regular}{KozMinPr6N-Bold}% {KozGoPr6N-Regular}{KozGoPr6N-Bold}% {KozGoPr6N-Medium}{RawFeature=+palt;+kern}} \zxjf@declare@preset{hiragino-pro}{% \zxjf@multiweight@opt{Hiragino Mincho Pro W3}{Hiragino Mincho Pro W6}% {Hiragino Kaku Gothic Pro W3}{Hiragino Kaku Gothic Pro W6}% {Hiragino Kaku Gothic Pro W6}{RawFeature=-palt;-kern}} \zxjf@declare@preset{hiragino-pro/prop}{% \zxjf@multiweight@opt{Hiragino Mincho Pro W3}{Hiragino Mincho Pro W6}% {Hiragino Kaku Gothic Pro W3}{Hiragino Kaku Gothic Pro W6}% {Hiragino Kaku Gothic Pro W6}{RawFeature=+palt;+kern}} \zxjf@declare@preset{hiragino-pron}{% \zxjf@multiweight@opt{Hiragino Mincho ProN W3}{Hiragino Mincho ProN W6}% {Hiragino Kaku Gothic ProN W3}{Hiragino Kaku Gothic ProN W6}% {Hiragino Kaku Gothic ProN W6}{RawFeature=-palt;-kern}} \zxjf@declare@preset{hiragino-pron/prop}{% \zxjf@multiweight@opt{Hiragino Mincho ProN W3}{Hiragino Mincho ProN W6}% {Hiragino Kaku Gothic ProN W3}{Hiragino Kaku Gothic ProN W6}% {Hiragino Kaku Gothic ProN W6}{RawFeature=+palt;+kern}} \zxjf@declare@preset{morisawa-pro}{% \zxjf@multiweight@opt{A-OTF-RyuminPro-Light.otf}{A-OTF-FutoMinA101Pro-Bold.otf}% {A-OTF-GothicBBBPro-Medium.otf}{A-OTF-FutoGoB101Pro-Bold.otf}% {A-OTF-GothicBBBPro-Medium.otf}{RawFeature=-palt;-kern}} \zxjf@declare@preset{morisawa-pro/prop}{% \zxjf@multiweight@opt{A-OTF-RyuminPro-Light.otf}{A-OTF-FutoMinA101Pro-Bold.otf}% {A-OTF-GothicBBBPro-Medium.otf}{A-OTF-FutoGoB101Pro-Bold.otf}% {A-OTF-GothicBBBPro-Medium.otf}{RawFeature=+palt;+kern}} \zxjf@declare@preset{morisawa-pr6n}{% \zxjf@multiweight@opt{A-OTF-RyuminPr6N-Light.otf}{A-OTF-FutoMinA101Pr6N-Bold.otf}% {A-OTF-GothicBBBPr6N-Medium.otf}{A-OTF-FutoGoB101Pr6N-Bold.otf}% {A-OTF-GothicBBBPr6N-Medium.otf}{RawFeature=-palt;-kern}} \zxjf@declare@preset{morisawa-pr6n/prop}{% \zxjf@multiweight@opt{A-OTF-RyuminPr6N-Light.otf}{A-OTF-FutoMinA101Pr6N-Bold.otf}% {A-OTF-GothicBBBPr6N-Medium.otf}{A-OTF-FutoGoB101Pr6N-Bold.otf}% {A-OTF-GothicBBBPr6N-Medium.otf}{RawFeature=+palt;+kern}} \zxjf@declare@preset{yu-win}{% \zxjf@multiweight@opt{YuMincho-Regular}{YuMincho-Demibold}% {YuGothic-Regular}{YuGothic-Bold}% {YuGothic-Regular}{RawFeature=-palt;-kern}} \zxjf@declare@preset{yu-win/prop}{% \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}% {YuGothic-Medium}{RawFeature=-palt;-kern}} \zxjf@declare@preset{yu-osx/prop}{% \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}} \zxjf@declare@preset@with@prop{haranoaji}{% \zxjf@multiweight@opt{HaranoAjiMincho-Regular}{HaranoAjiMincho-Bold}% {HaranoAjiGothic-Regular}{HaranoAjiGothic-Bold}% {HaranoAjiGothic-Medium}} %(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-ex}{moga} \zxjf@declare@preset@alias{noto-otf}{noto} \zxjf@declare@preset@alias{hiragino}{hiragino-pro} %% definitions of sub preset mappings \zxjf@declare@preset{hg}{% \zxjf@newfamily{hgmc}{BoldFont=HGSMinchoE}{HGSMinchoB}% \zxjf@newfamily{hgpr}{}{HGSSoeiPresenceEB}% \zxjf@newfamily{hggt}{BoldFont=HGSGothicE}{HGSGothicM}% \zxjf@newfamily{hggu}{}{HGSSoeiKakugothicUB}% \zxjf@newfamily{hgmg}{}{HGMaruGothicMPRO}% \zxjf@newfamily{hgkk}{}{HGSKyokashotai}% \zxjf@newfamily{hgks}{}{HGSeikaishotaiPRO}% \zxjf@newfamily{hggs}{}{HGSGyoshotai}% \zxjf@newfamily{hgpp}{}{HGSSoeiKakupoptai}% } \zxjf@declare@preset{hg/prop}{% \zxjf@newfamily{hgmc}{BoldFont=HGPMinchoE}{HGPMinchoB}% \zxjf@newfamily{hgpr}{}{HGPSoeiPresenceEB}% \zxjf@newfamily{hggt}{BoldFont=HGPGothicE}{HGPGothicM}% \zxjf@newfamily{hggu}{}{HGPSoeiKakugothicUB}% \zxjf@newfamily{hgmg}{}{HGMaruGothicMPRO}% \zxjf@newfamily{hgkk}{}{HGPKyokashotai}% \zxjf@newfamily{hgks}{}{HGSeikaishotaiPRO}% \zxjf@newfamily{hggs}{}{HGPGyoshotai}% \zxjf@newfamily{hgpp}{}{HGPSoeiKakupoptai}% } \zxjf@declare@preset{hiraginomg-pro}{% \zxjf@newfamily{hmg}{RawFeature=-palt;-kern}{Hiragino Maru Gothic Pro W4}} \zxjf@declare@preset{hiraginomg-pro/prop}{% \zxjf@newfamily{hmg}{RawFeature=+palt;+kern}{Hiragino Maru Gothic Pro W4}} \zxjf@declare@preset{hiraginomg-pron}{% \zxjf@newfamily{hmg}{RawFeature=-palt;-kern}{Hiragino Maru Gothic ProN W4}} \zxjf@declare@preset{hiraginomg-pron/prop}{% \zxjf@newfamily{hmg}{RawFeature=+palt;+kern}{Hiragino Maru Gothic ProN W4}} \zxjf@declare@preset@alias{hiraginomg}{hiraginomg-pro} \zxjf@declare@preset@alias{hiraginomg/prop}{hiraginomg-pro/prop} \zxjf@declare@preset{mobo}{% \zxjf@newfamily{mobo}{Bold=MoboExGothic Bold}{MoboExGothic}} \zxjf@declare@preset{mobo-90}{% \zxjf@newfamily{mobo}{Bold=MoboEx90Gothic Bold}{MoboEx90Gothic}} \zxjf@declare@preset{maruberi}{% \zxjf@newfamily{mmg}{}{MotoyaLMaru}} %% ... 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 %%<*> \useeasyjapanesesettings \newcommand*\useeasyjapanesesettings{% \XeTeXlinebreaklocale "ja"\relax \XeTeXlinebreakskip=0pt plus 1pt minus 0.1pt\relax \XeTeXlinebreakpenalty=0\relax } %--------------------------------------- all done \endinput %% EOF