Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
LaTeX: (u)pLaTeX/LuaTeX-jaの総称シリーズ設定について和文を別にするやつ
%%
%% This is file 'bxjaseries.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.
%%
%% package declaration
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{bxjaseries}[2018/06/08 v0.2]
\def\bxjb@pkgname{bxjaseries}
\providecommand\bxDebug[1]{}
%--------------------------------------- main
%% \bxjb@fix@one@series{<label>}{<series>}
\@onlypreamble\bxjb@fix@one@series
\def\bxjb@fix@one@series#1#2{%
\begingroup
\expandafter\bxjb@fix@one@series@a\csname
\expandafter\ifx\csname #1series \endcsname\relax
#1series\else #1series \fi
\expandafter\endcsname\csname
#1series%
\expandafter\endcsname\csname
\expandafter\ifx\csname math#1\endcsname\relax
relax\else math#1\fi
\expandafter\endcsname\csname
#1default%
\expandafter\endcsname\csname
kanji#1default%
\endcsname{#1}{#2}%
\endgroup}
\@onlypreamble\bxjb@fix@one@series@a
\def\bxjb@fix@one@series@a#1#2#3#4#5#6#7{%
%\[XXseries ]\mathXX\XXseries\XXdefault\kanjiXXdefault{XX}{<ser>}
% patch to \XXseries
\ifx#1\relax
\bxDebug{'\string#1' is undefined.}%
\else
\long\def\bxjb@tmpa{% standard one
\not@math@alphabet#2#3\fontseries#4\selectfont}%
\ifx#1\bxjb@tmpa
\bxDebug{'\string#1' is standard.}%
\long\gdef#1{%
\not@math@alphabet#2#3\romanseries#4\kanjiseries#5\selectfont}%
\else
\bxDebug{'\string#1' is non-standard.}%
\g@addto@macro#1{\kanjiseries#5\selectfont}
\fi
\fi
% change \kanjiseriesdefault
\long\def\bxjb@tmpa{#4}%
\ifx\kanjiseriesdefault\bxjb@tmpa
\long\gdef\kanjiseriesdefault{#5}%
\bxDebug{\string\kanjiseriesdefault: \string#4 -> \string#5.}
\fi
% resolve \kanjiXXdefault
\long\def\bxjb@tmpa{#4\@empty}%
\ifx#5\bxjb@tmpa % is untouched
\ifx#1\relax
\global\let#5\@undefined % annihilate
\else
\expandafter\ifx\csname % ja-family is lack of XXdefault series
\kanjiencodingdefault/\kanjifamilydefault/#4/n%
\endcsname\relax
\gdef#5{#7}% change to the safe series
\else
\xdef#5{#4}% settle the series
\fi
\bxDebug{\string#5 = #5}%
\fi
\fi}
%% \bxjb@prepare@one@series{<series>}
\@onlypreamble\bxjb@prepare@one@series
\def\bxjb@prepare@one@series#1{%
\edef\bxjb@tmpa{%
\noexpand\newcommand
\expandafter\noexpand\csname kanji#1default\endcsname{%
\expandafter\noexpand\csname#1default\endcsname
\noexpand\@empty}%
}\bxjb@tmpa}
%%<+> \bxjaseriesApplyPatch
\@onlypreamble\bxjaseriesApplyPatch
\newcommand*\bxjaseriesApplyPatch{%
\global\let\bxjaseriesApplyPatch\relax}
\AtBeginDocument{%
\bxjaseriesApplyPatch}
%% target series
\def\do#1#2{%
\g@addto@macro\bxjaseriesApplyPatch{%
\bxjb@fix@one@series{#1}{#2}}%
\bxjb@prepare@one@series{#1}}
\do{md}{m}
\do{bf}{bx}
\do{lt}{l}
\do{eb}{eb}
%--------------------------------------- done
\endinput
%% EOF
@zr-tex8r

This comment has been minimized.

Copy link
Owner Author

zr-tex8r commented Jun 14, 2018

文書開始時点(または\bxjaseriesApplyPatch実行時)に以下の処理を行う。

  • \bfseriesについて、和文は\bfdefaultではなく\kanjibfdefaultを使うようにする。
  • \kanjibfdefaultの初期値は\bfdefaultと同じにする。ただし、既定和文ファミリ(\kanjifamilydefault)にそのシリーズ(のnシェープ)が存在しない場合は、代わりにbxとする。
  • \kanjiseriesdefaultの値が\bfdefaultと同じであったなら\kanjibfdefaultと同じ値に変更する。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.