diff options
author | Karl Berry <karl@freefriends.org> | 2016-10-17 21:23:41 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-10-17 21:23:41 +0000 |
commit | ed5e43ddff288abda4c9a13ab8727e0783260667 (patch) | |
tree | 4e4411258818b574f905a8d0ba9801b42a767b97 /Master/texmf-dist/tex | |
parent | 1b7ca392b2a28913edba35b74cd696be7ac5f816 (diff) |
bxcjkjatype (17oct16)
git-svn-id: svn://tug.org/texlive/trunk@42292 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/bxcjkjatype/bxcjkjatype.sty | 406 |
1 files changed, 378 insertions, 28 deletions
diff --git a/Master/texmf-dist/tex/latex/bxcjkjatype/bxcjkjatype.sty b/Master/texmf-dist/tex/latex/bxcjkjatype/bxcjkjatype.sty index 0ab4cb73851..f530e030e98 100644 --- a/Master/texmf-dist/tex/latex/bxcjkjatype/bxcjkjatype.sty +++ b/Master/texmf-dist/tex/latex/bxcjkjatype/bxcjkjatype.sty @@ -1,10 +1,16 @@ -% -% bxcjkjatype.sty -% +%% +%% This is file 'bxcjkjatype.sty'. +%% +%% Copyright (c) 2016 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{bxcjkjatype}[2013/10/18 v0.2c] +\ProvidesPackage{bxcjkjatype}[2016/10/15 v0.3] \def\bxjy@pkgname{bxcjkjatype} %% definitions @@ -14,8 +20,10 @@ %--------------------------------------- helpers -%% variables +%% switches \newif\ifbxjy@ok +\newif\ifbxjy@default@set +\newif\ifbxjy@byembolden %% unique tokens \def\bxjy@mark{\bxjy@mark@} @@ -71,8 +79,9 @@ \newif\ifbxjy@everypage \DeclareOption{everypage}{\bxjy@everypagetrue} \DeclareOption{noeverypage}{\bxjy@everypagefalse} +\newif\ifbxjy@ipaex \let\bxjy@oneweight=f -\DeclareOption{ipaex-type1}{\let\bxjy@oneweight=i} +\DeclareOption{ipaex-type1}{\bxjy@ipaextrue} \DeclareOption{oneweight}{\let\bxjy@oneweight=t} \DeclareOption{nooneweight}{\let\bxjy@oneweight=f} \newif\ifbxjy@autotilde @@ -84,6 +93,12 @@ \newif\ifbxjy@CJKspace \bxjy@CJKspacetrue \DeclareOption{CJKspace}{\bxjy@CJKspacetrue} \DeclareOption{noCJKspace}{\bxjy@CJKspacefalse} +\newif\ifbxjy@boldbyembolden \bxjy@boldbyemboldentrue +\DeclareOption{boldbyembolden}{\bxjy@boldbyemboldentrue} +\DeclareOption{noboldbyembolden}{\bxjy@boldbyemboldenfalse} +\newif\ifbxjy@substmin +\DeclareOption{substmingoth}{\bxjy@substmintrue} +\DeclareOption{nosubstmingoth}{\bxjy@substminfalse} % preset spec options \def\bxjy@all@main@preset{% %(uniweight) @@ -100,9 +115,18 @@ \DeclareOption*{% \expandafter\bxjy@setkey@a\expandafter{\CurrentOption}} \def\bxjy@setkey@a{\setkeys{bxjy}} +% 'scale=<real>' \let\bxjy@scale\relax \define@key{bxjy}{scale}{% \def\bxjy@scale{#1}} +% 'verrtical=<val>' +\let\bxjy@vertical\@empty +\define@key{bxjy}{vertical}[true]{% + \def\bxjy@vertical{#1}} +% 'ttfname=<val>' +\let\bxjy@ttfname\@empty +\define@key{bxjy}{ttfname}{% + \def\bxjy@ttfname{#1}} %% Dispatch options \ProcessOptions* @@ -130,7 +154,7 @@ \fi %% Consistency check -\ifx i\bxjy@oneweight \unless\ifx\bxjy@main@preset\relax +\ifbxjy@ipaex \unless\ifx\bxjy@main@preset\relax \bxjy@error{Preset options cannot go with 'ipaex-type1'}\@ehc \let\bxjy@main@preset\relax \fi\fi @@ -138,10 +162,9 @@ \bxjy@error{Preset options require a valid driver}\@ehc \let\bxjy@main@preset\relax \fi\fi -\ifx i\bxjy@oneweight \unless\ifx\bxjy@scale\relax - \bxjy@error{Scaling cannot go with 'ipaex-type1'}\@ehc - \let\bxjy@main@preset\relax -\fi\fi +\ifx \bxjy@driver\bxjy@none + \bxjy@boldbyemboldenfalse +\fi %% default scale value \ifx\bxjy@scale\relax @@ -153,9 +176,6 @@ \else \let\bxjy@scale\Cjascale \fi \fi -\ifx i\bxjy@oneweight - \def\bxjy@scale{1}% -\fi %--------------------------------------- preparations @@ -193,6 +213,39 @@ \newcommand*\EveryCJKUse{% \gappto\bxjy@every@cjk@use@hook} +%--------------------------------------- vertical + +%% constants +\chardef\bxjy@vert@none=0 +\chardef\bxjy@vert@false=0 +\chardef\bxjy@vert@=0 +\chardef\bxjy@vert@sub=1 +\chardef\bxjy@vert@main=2 +\chardef\bxjy@vert@true=2 + +%% \bxjy@vert +\let\bxjy@vert\bxjy@vert@none +\ifcsdef{bxjy@vert@\bxjy@vertical}{% + \letcs\bxjy@vert{bxjy@vert@\bxjy@vertical} +}{%else + \bxjy@error{Invalid value of 'vertical': \bxjy@vertical}\@ehc +} +\ifcase\bxjy@vert %none + \AfterEndPreamble{\csuse{CJKhorz}} +\or %sub + \RequirePackage{CJKvert}[]% + \AfterEndPreamble{\CJKhorz} +\or %main + \RequirePackage{CJKvert}[]% + \AfterEndPreamble{\CJKvert} +\fi +\AtBeginDocument{% + \@ifpackageloaded{CJKvert}{% + \bxjy@patch@CJKsymbol@CJKvert + \patchcmd{\CJKvert}{\normalfont}{\bxjy@normalafont}{}{}% + \patchcmd{\CJKhorz}{\normalfont}{\bxjy@normalafont}{}{}% + }{}} + %--------------------------------------- user interface %%%%<*> \setminchofont/\setgothicfont/etc. @@ -214,11 +267,8 @@ \else \@for\bxjy@x:={#1}\do{% \ifx @#2@\@namedef{bxjy@FS/\bxjy@x}{#3}% - \else\ifx\bxjy@driver\bxjy@dvipdfmx - \@namedef{bxjy@FS/\bxjy@x}{:#2:#3}% - \else % ttc is unavailable in pdfTeX - \bxjy@error{pdfTeX does not support TTC}\@eha - \fi\fi}% + \else \@namedef{bxjy@FS/\bxjy@x}{:#2:#3}% + \fi}% \fi} \@for\bxjy@x:={% mnr,mnb,gtr,gtb,gtx,gtu,mgr% @@ -240,7 +290,7 @@ } %%<*> \setCJKfamilydefault{<fam>} -\newbool{bxjy@default@set} +%\newif\ifbxjy@default@set \newrobustcmd*\setCJKfamilydefault[1]{% \bxjy@default@settrue \CJKencfamily{UTF8}{#1}} @@ -388,6 +438,113 @@ }#1% } +%--------------------------------------- ttfname + +%% variables +\let\bxjy@ttfname@ptn\relax +\let\bxjy@ttc@info + +%% constants +\begingroup \let\\\@backslashchar +% The set of allowed characters, all ASCII but the followings: +% [special in Windwos path name] \ / ? : * " > < | +% [special in LaTeX] # % ^ { } ~ +\edef\x{[]!$&'()+,.0-9;=@A-Z_`a-z-]} +\xdef\bxjy@Rx@tp@a{^(\x*)\\*(\x*)$} +\xdef\bxjy@Rx@tp@b{^.*\\.[Tt][Tt][Ff]$} +\xdef\bxjy@Rx@tp@c{^(|.*[^0-9])([0-9]{1,5})([^0-9]*)$} +\xdef\bxjy@Rx@fn@a{^(.*)\\.\\w+$} +\xdef\bxjy@Rx@fn@b{^.*\\.[Tt][Tt][Cc]$} +\endgroup + +%% \bxjy@set@match\CS{<number>} +\@onlypreamble\bxjy@set@match +\def\bxjy@set@match#1#2{% + \expandafter\bxjy@set@match@a\pdflastmatch#2\relax#1} +\@onlypreamble\bxjy@set@match@a +\def\bxjy@set@match@a#1>#2\relax#3{\def#3{#2}} + +%% \bxjy@set@ttfname@ptn +% Sets \bxjy@ttfname@ptn. +\@onlypreamble\bxjy@set@ttfname@ptn +\def\bxjy@set@ttfname@ptn{% + \begingroup + \let\bxjy@ttfname@ptn\relax + \ifnum\pdfmatch{\bxjy@Rx@tp@a}{\bxjy@ttfname}>\z@ + \bxjy@set@match\bxjy@ptnA{1}\bxjy@set@match\bxjy@ptnBC{2}% + \ifnum\pdfmatch{\bxjy@Rx@tp@b}{\bxjy@ptnBC}=\z@ + \edef\bxjy@ptnBC{\bxjy@ptnBC.ttf}% + \fi + \ifnum\pdfmatch{\bxjy@Rx@tp@c}{\bxjy@ptnBC}>\z@ + \bxjy@set@match\bxjy@ptnB{1}\bxjy@set@match\bxjy@ptnC{3}% + \bxjy@set@match\bxjy@ptnN{2}% + \xdef\bxjy@ttfname@ptn{% + {\bxjy@ptnA}{\bxjy@ptnB}{\bxjy@ptnC}{\bxjy@ptnN}}% + \fi + \fi + \ifx\bxjy@ttfname@ptn\relax + \@latex@warning@no@line + {Option 'ttfname' has an invalid value:\MessageBreak + "\bxjy@ttfname"}% + \fi + \endgroup} + +%% \bxjy@make@ttfname\CS{<ttc-name>}{<number>} +\@onlypreamble\bxjy@make@ttfname +\def\bxjy@make@ttfname{% + \expandafter\bxjy@make@ttfname@a\bxjy@ttfname@ptn} +\@onlypreamble\bxjy@make@ttfname@a +\def\bxjy@make@ttfname@a#1#2#3#4#5#6#7{% + \numdef\bxjy@tmpa{#4+#7}\numdef\bxjy@tmpb{1#4-#4}% + \ifnum\bxjy@tmpa<\bxjy@tmpb + \numdef\bxjy@tmpa{\bxjy@tmpa+\bxjy@tmpb}% + \edef\bxjy@tmpa{\expandafter\@gobble\bxjy@tmpa}% + \fi + \edef\bxjy@tmpb{\detokenize{#6}}% + \ifnum\pdfmatch{\bxjy@Rx@fn@a}{\bxjy@tmpb}>\z@ + \bxjy@set@match\bxjy@tmpb{1}% + \fi + \edef#5{#1\bxjy@tmpb#2\bxjy@tmpa#3}} + +%% set the pattern +\unless\ifx\bxjy@ttfname\@empty + \ifdefined\pdfmatch + \bxjy@set@ttfname@ptn + \else + \bxjy@error + {Option 'ttfname' cannot be used because your\MessageBreak + pdfTeX engine is too old}\@ehc + \fi +\fi + +%% \bxjy@modify@fontname +\@onlypreamble\bxjy@modify@fontname +\def\bxjy@modify@fontname{% + \bxly@check@ttc\FONT + \unless\ifx\bxjy@ttc@info\relax + \ifx\bxjy@ttfname@ptn\relax + \bxjy@error{pdfTeX does not support TTC}\@eha + \else + \edef\bxjy@tmpa{\noexpand\FONT\bxjy@ttc@info}% + \expandafter\bxjy@make@ttfname\bxjy@tmpa + \fi + \fi} + +%% \bxly@check@ttc{<name>} +\@onlypreamble\bxly@check@ttc +\ifdefined\pdfmatch +\def\bxly@check@ttc#1{% + \ifnum\pdfmatch{^:([0-9]+):(.*)}{#1}>\z@ + \bxjy@set@match\bxjy@tmpa{1}\bxjy@set@match\bxjy@tmpb{2}% + \edef\bxjy@ttc@info{{\bxjy@tmpb}{\bxjy@tmpa}}% + \else\ifnum\pdfmatch{\bxjy@Rx@fn@b}{#1}>\z@ + \edef\bxjy@ttc@info{{#1}{0}}% + \else\let\bxjy@ttc@info\relax + \fi\fi} +\else +\def\bxjy@check@ttc#1{\let\bxjy@ttc@info\relax} +\fi + %--------------------------------------- fontmap internals %% \bxjy@noembed @@ -430,7 +587,8 @@ \let\bxjy@spec\@empty \else\ifx\bxjy@driver\bxjy@pdftex \def\bxjy@entry@sub#1{%<tfm-spec> - \pdfmapline{=#1 <\FONT}} + \bxjy@modify@fontname + \unless\ifx\FONT\relax \pdfmapline{=#1 <\FONT}\fi} \else % invalid in dvips \fi\fi @@ -474,6 +632,9 @@ \not@math@alphabet\mcfamily\relax \CJKfamily{\mgdefault}} +%% \bxjy@normalafont +\letcs\bxjy@normalafont{normalfont } + %% Add patches to \rmfamily, etc. \csappto{rmfamily }{% \CJKfamily{\mcdefault}} @@ -491,8 +652,8 @@ \fontseries\ebdefault\selectfont} \providecommand{\ebdefault}{eb} \fi -\let\bxjy@CJKnormal\CJKnormal -\protected\def\CJKnormal{\bxjy@CJKnormal} +\protected\def\CJKbold{\CJK@bold@true} +\protected\def\CJKnormal{\CJK@bold@false} %% \bxjy@decl@series \@onlypreamble\bxjy@decl@series @@ -520,11 +681,7 @@ \bxjy@decl@family{mc}{\bxjy@sc unisong}{CJKssub*gt/m/n}{CJKssub*gt/m/n} \bxjy@decl@family{gt}{\bxjy@sc unihei}{CJKssub*gt/m/n}{CJKssub*gt/m/n} \bxjy@decl@family{mg}{\bxjy@sc unikai}{CJKssub*mg/m/n}{CJKssub*mg/m/n} -\else\ifx i\bxjy@oneweight -\renewcommand{\mcdefault}{ipxm} -\renewcommand{\gtdefault}{ipxg} -\renewcommand{\mgdefault}{ipxg} -\fi\fi\fi +\fi\fi %% Set default CJK family \setCJKfamilydefault{\mcdefault} @@ -553,6 +710,171 @@ \fi } +%% \bxjy@force@load@font@fam +\@onlypreamble\bxjy@force@load@font@fam +\def\bxjy@force@load@font@fam#1{% + \begingroup + \def\f@encoding{C70}\let\CJK@enc\f@encoding + \edef\f@family{#1}\let\CJK@family\f@family + \def\f@series{m}\def\f@shape{n}% + \xdef\font@name{\csname\curr@fontshape/\f@size\endcsname}% + \let\extract@font\relax \pickup@font + \endgroup} + +%--------------------------------------- ipaex-type1 +\ifbxjy@ipaex + +%% default changed +\renewcommand{\mcdefault}{ipxm} +\renewcommand{\gtdefault}{ipxg} +\renewcommand{\mgdefault}{ipxg} + +%% scale applied +\unless\ifdim\bxjy@scale\p@=\p@ + \def\bxjy@tmpa#1#2#3{% + \bxjy@force@load@font@fam{#1}% + \expandafter\ifx\csname C70+#1\endcsname\@empty\else + \def\bxjy@tmpb{\DeclareFontShape{C70}{#1}}% + \bxjy@tmpb{m}{n}{<->sCJK*[\bxjy@scale]#3-r-u}{}% + \ifx t#2% + \bxjy@tmpb{m}{sl}{<->sCJK*[\bxjy@scale]#3-ro-u}{}% + \bxjy@tmpb{bx}{n}{<->sCJKb*[\bxjy@scale]#3-r-u}{\CJKbold}% + \bxjy@tmpb{bx}{sl}{<->sCJKb*[\bxjy@scale]#3-ro-u}{\CJKbold}% + \fi + \fi} + \bxjy@tmpa{ipxm}f{ipxm}% + \bxjy@tmpa{ipxg}f{ipxg}% + \bxjy@tmpa{ipxma}t{ipxm}% + \bxjy@tmpa{ipxga}t{ipxg}% +\fi + +\fi +%--------------------------------------- subst-mingoth +\ifbxjy@substmin + +%% apply +\def\bxjy@tmpa#1#2{% + \bxjy@force@load@font@fam{#1}% + \expandafter\ifx\csname C70+#1\endcsname\@empty\else + \def\bxjy@tmpb{\DeclareFontShape{C70}{#1}}% + \bxjy@tmpb{l}{n}{<->CJKssub*#2/m/n}{}% + \bxjy@tmpb{m}{n}{<->CJKssub*#2/m/n}{}% + \bxjy@tmpb{bx}{n}{<->CJKssub*#2/bx/n}{\CJKbold}% + \fi} +\bxjy@tmpa{min}{mc}% +\bxjy@tmpa{goth}{gt}% +\bxjy@tmpa{maru}{mg}% + +\fi +%--------------------------------------- bold-by-embolden +\ifbxjy@boldbyembolden %<*boldbyembolden> + +%<*>\CJKboldbyembolden/\CJKnoboldbyembolden +%\newif\ifbxjy@byembolden +\newcommand*{\CJKboldbyembolden}{\bxjy@byemboldentrue} +\newcommand*{\CJKnoboldbyembolden}{\bxjy@byemboldenfalse} +\CJKboldbyembolden % initial value + +%% \bxjy@pdfliteraldirect{<pdf-text>} +\ifx\bxjy@driver\bxjy@pdftex + \def\bxjy@pdfliteraldirect#1{\pdfliteral page {#1}} +\else\ifx\bxjy@driver\bxjy@dvipdfmx + \def\bxjy@pdfliteraldirect#1{\special{pdf:literal direct #1}} +\else + \bxjy@error{INTERNAL_ERROR(1)} +\fi\fi + +%% \bxjy@embolden +\def\bxjy@bsfactor{1.68} +\def\bxjy@bswd;{\strip@pt\dimexpr\bxjy@bsfactor + \dimexpr\CJKboldshift\relax\relax} +\def\bxjy@embolden{% + \bxjy@pdfliteraldirect{q 2 Tr \bxjy@bswd; w}} +\def\bxjy@embolden@alt{% + \bxjy@pdfliteraldirect{2 Tr \bxjy@bswd; w}} +%% \bxjy@noembolden +\def\bxjy@noembolden{% + \bxjy@pdfliteraldirect{Q}} +\def\bxjy@noembolden@alt{% + \bxjy@pdfliteraldirect{0 Tr}} + +%% \bxjy@patch@CJKsymbol@CJKvert +% Patches to CJKvert version of \CJKsymbol. +\@onlypreamble\bxjy@patch@CJKsymbol@CJKvert +\def\bxjy@patch@CJKsymbol@CJKvert{% + \global\let\bxjy@patch@CJKsymbol@CJKvert\relax + \bxjy@oktrue + \expandafter\patchcmd\csname CJKsymbol \endcsname{%from + \ifCJK@bold@ \CJK@temp + \hbox to \z@{\hss \raise\CJKboldshift\hbox{\CJK@temp}}% + \hbox to \z@{\hss \raise-\CJKboldshift\hbox{\CJK@temp}}% + \else \CJK@temp + \fi + }{%to + \ifCJK@bold@\ifbxjy@byembolden + \bxjy@embolden@alt + \fi\fi + \CJK@temp + \ifCJK@bold@ + \ifbxjy@byembolden + \bxjy@noembolden@alt + \else + \hbox to \z@{\hss \raise\CJKboldshift\hbox{\CJK@temp}}% + \hbox to \z@{\hss \raise-\CJKboldshift\hbox{\CJK@temp}}% + \fi + \fi + }{}{\bxjy@okfalse}% + \expandafter\patchcmd\csname CJKsymbol \endcsname{%from + \ifCJK@bold@ \CJK@temp + \hbox to \CJKboldshift{\hss\CJK@temp}% + \hbox to \CJKboldshift{\hss\CJK@temp}% + \else \CJK@temp + \fi + }{%to + \ifCJK@bold@\ifbxjy@byembolden + \bxjy@embolden@alt + \fi\fi + \CJK@temp + \ifCJK@bold@ + \ifbxjy@byembolden + \bxjy@noembolden@alt + \else + \kern-\CJKboldshift\hb@xt@\z@{\hss\CJK@temp}% + \kern2\dimexpr\CJKboldshift\relax + \hb@xt@\z@{\hss\CJK@temp}\kern-\CJKboldshift\relax + \fi + \fi + }{}{\bxjy@okfalse}% + \unless\ifbxjy@ok + \bxjy@error{Failure in patching to CJKvert}\@ehc + \fi +} +%% redefine \CJKsymbol +\@ifpackageloaded{CJKvert}{% + % CJKvert version + \bxjy@patch@CJKsymbol@CJKvert +}{% non-CJKvert version + \@namedef{CJKsymbol }#1{% + \ifCJK@bold@\ifbxjy@byembolden + \bxjy@embolden + \fi\fi + \symbol{#1}% + \ifCJK@bold@ + \ifbxjy@byembolden + \bxjy@noembolden + \else + \kern-\CJKboldshift\hb@xt@\z@{\hss\symbol{#1}}% + \kern2\dimexpr\CJKboldshift\relax + \hb@xt@\z@{\hss\symbol{#1}}\kern-\CJKboldshift\relax + \fi + \fi}% +} + +\else %<*!boldbyembolden> +% makes \CJK[no]boldbyembolden no-op +\newcommand*{\CJKboldbyembolden}{} +\newcommand*{\CJKnoboldbyembolden}{} +\fi %</boldbyembolden> %--------------------------------------- begin-document hook \ifx\bxjy@driver\bxjy@dvipdfmx %<*dvipdfmx> @@ -596,6 +918,34 @@ %% Invokes first-CJK hook at begin-document \AtBeginDocument{\bxjy@first@cjk@use@hook} +%--------------------------------------- PDF-string hack + +%%<+> \bxcjkjatypeHyperrefPatchDone +%% Informs that the patch is applied. +\let\bxcjkjatypeHyperrefPatchDone=t + +%% prepare +\begingroup + \CJK@input{UTF8.bdg}% emerge CJK@UTF8Binding +\endgroup +%% register to \pdfstringdefPreHook +\g@addto@macro\pdfstringdefPreHook{% + \@nameuse{CJK@UTF8Binding}% enable UTF8 decoder + \ifx~\bxjy@@CJKtilde % \CJKtilde is effective + \let\bxjy@org@LetUnexpandableSpace\HyPsd@LetUnexpandableSpace + \let\HyPsd@LetUnexpandableSpace\bxjy@LetUnexpandableSpace + \let~\@empty + \fi +} +\def\bxjy@@CJKtilde{\CJKecglue\ignorespaces} +%% patch to \HyPsd@LetUnexpandableSpace +\def\bxjy@@tildecmd{~} +\def\bxjy@LetUnexpandableSpace#1{% + \def\bxjy@tmpa{#1}\ifx\bxjy@tmpa\bxjy@@tildecmd\else + \bxjy@org@LetUnexpandableSpace#1% + \fi +} + %--------------------------------------- preset font mappings %% \bxjy@declare@preset{<name>}{<text>} |