summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex/hmtrump/hmtrump.sty
blob: 5fe1bfb49c5949e30674331f6dd5b1967f76ee08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
%
% This is `hmtrump.sty'
%
% Author: Hitomi-san (a.k.a. Carele Smith)
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{hmtrump}[2019/02/07 v1.0]
\RequirePackage{tikz,xcolor,fontspec}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 定義本体

%: 色の宣言
\definecolor{hartsuit}{cmyk}{.14,.94,.22,.27}
\definecolor{diasuit}{cmyk}{.11,.57,.97,.31}
\definecolor{clubsuit}{cmyk}{.70,.5,.99,.18}
\definecolor{spadesuit}{cmyk}{.98,.80,.5,.15}

\definecolor{cardback}{gray}{.95}
\definecolor{cardborder}{gray}{.2}
\definecolor{cardtext}{gray}{0}

% \hmtc@strut => 支柱\rule[-0.65em]{0pt}{1.85em}
% \newcommand{\hmtc@strut}{\rule[-0.65em]{0pt}{1.85em}}
\newcommand{\hmtc@strut}{\relax}

%: 日本語している時対策
\ifx\ltjdefcharrange\@undefined\relax\else
	\ltjdefcharrange{24}{
		"2660-"2667,%各スート
		"E000-"E005,%ブランク、(合成用ブランク→不使用)、数字10-13
		"EDDB-"EDE3,%ジョーカーマーク
		"2160-"216B,%ローマ数字1-12
		"E5BC-"E5BE,%ローマ数字12-21
		"1F0A0-"1F0FF%Unicodeトランプ
	}
	\ltjsetparameter{jacharrange={-24}}
\fi

%: \hmtcfont => フォント変更
\newcommand{\hmtc@trump@font}{NKD04_Playing_Cards_Index}
\newcommand{\hmtcfont}{\fontspec{\hmtc@trump@font}}

%%: \trump{ランク}{スート}
\tikzset{hmtcscale/.style={scale=0.9}} % 倍率
\tikzset{hmtrump/.style={hmtcscale,draw=cardborder,fill=cardback,outer sep=0pt,rounded corners}}
	% hmtrump スタイルを定義し直す(\tikzset を使って上書きする)ことで、カードのスタイルを変更可能。

\newcommand{\trump}[2]{\hmtc@strut\hmtc@trump@{\hmtc@rank@{#1}}{#2}}

\newcommand{\hmtc@rank@}[1]{\ifx#1T{\char"E002}\else#1\fi} % 10

\newcommand{\hmtc@trump@}[2]{%
	\ifx#2H{%
		\tikz[baseline=(T.base)]
		\node[hmtrump,text=hartsuit]
		(T)at(0,0){\hmtcfont{#1\char"2665}};%
	}%
	\else\ifx#2D{%
		\tikz[baseline=(T.base)]
		\node[hmtrump,text=diasuit]
		(T)at(0,0){\hmtcfont{#1\char"2666}};%
	}%
	\else\ifx#2C{%
		\tikz[baseline=(T.base)]
		\node[hmtrump,text=clubsuit]
		(T)at(0,0){\hmtcfont{#1\char"2663}};%
	}%
	\else\ifx#2S{%
		\tikz[baseline=(T.base)]
		\node[hmtrump,text=spadesuit]
		(T)at(0,0){\hmtcfont{#1\char"2660}};%
	}%
	\else{%
		\tikz[baseline=(T.base)]
		\node[hmtrump]
		(T)at(0,0){\hmtcfont{#1}};%
	}%
	\fi\fi\fi\fi%
}

%%: \trumpx{ランク}
\newcommand{\trumpx}[1]{\hmtc@strut\hmtc@trump@{\hmtc@rank@{#1}}{x}}


%: \hm[S,H,D,C] => それぞれのスートを出力
\newcommand{\hmH}{\textcolor{hartsuit}{\hmtcfont\char"2665}}
\newcommand{\hmD}{\textcolor{diasuit}{\hmtcfont\char"2666}}
\newcommand{\hmC}{\textcolor{clubsuit}{\hmtcfont\char"2663}}
\newcommand{\hmS}{\textcolor{spadesuit}{\hmtcfont\char"2660}}

%: \joker など=> ジョーカー
\newcommand{\BLACKJOKER}{\trumpx{\char"F5BC}}
\newcommand{\WHITEJOKER}{\trumpx{\char"F5BD}}
\newcommand{\REDJOKER}{\trumpx{\char"F5BE}}
\newcommand{\JOKER}{\BLACKJOKER}

\newcommand{\blackjoker}{\hmtc@joker@base{\char"F5BC}}
\newcommand{\whitejoker}{\hmtc@joker@base{\char"F5BD}}
\newcommand{\redjoker}{\hmtc@joker@base{\char"F5BE}}
\newcommand{\joker}{\blackjoker}

\newcommand{\hmtc@joker@base}[1]{\hmtc@strut{\hmtcfont%
	\tikz[baseline=(T.base)]\node[hmtrump](T)at(0,0){
		\parbox{1em}{
			\fontsize{0.3em}{0}\rule{0pt}{0pt}\hfil\selectfont JOKER\hfil\rule{0pt}{0pt}\\
			\fontsize{2.33em}{0}\selectfont\rule{0pt}{0pt}\hfil#1\hfil\rule{0pt}{0pt}%
		}
	};%
}}


%: \trumpblank => 枠
\newcommand{\trumpblank}[1]{%
	\rule[-0.65em]{0pt}{1.85em}\tikz[baseline=(T.base)]\node[hmtrump](T)at(0,0){#1};%
}

%: \romanindex => ローマ数字
\newcounter{hmtc@roman}
\newcommand{\romanindex}[1]{%
	\ifnum#1=0\relax%
		O%
	\else\ifnum#1<13\relax%
		\setcounter{hmtc@roman}{"215F}%
		\addtocounter{hmtc@roman}{#1}%
		{\hmtcfont\char\value{hmtc@roman}}%
	\else\ifnum#1>12\relax%
		\setcounter{hmtc@roman}{"EDCE}%
		\addtocounter{hmtc@roman}{#1}%
		{\hmtcfont\char\value{hmtc@roman}}%
	\fi\fi\fi%
}

%: \tarottrump => タロットの切札
\newcommand{\tarottrump}[1]{\trumpx{\romanindex{#1}}}