summaryrefslogtreecommitdiff
path: root/build/templates/header.ko.tex
blob: b0820722cf75d227f5badd395231d088f6ad8426 (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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% hangul typesetting along with jadetex
%%%
%%% (C) 2005  Dohyun Kim <nomosnomos@gmail.com>
%%%
%%% This program is free software; you can redistribute it and/or modify
%%% it under the terms of version 2 of the GNU General Public License as
%%% published by the Free Software Foundation.
%%%
%%% This program is distributed in the hope that it will be useful, but
%%% WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
%%% General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License
%%% along with this program; if not, write to the Free Software
%%% Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
%%% USA 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\hangulfontnormal{unwmj}
\def\hangulfontbold{unwmjb}
\def\hangulfonttitlenormal{unwgt}
\def\hangulfonttitlebold{unwgtb}
\def\chaptername{Chapter}
\let\ucshanguljadetex@character@orig\Character
\def\Character#1{%
  \expandafter\ifx\csname!#1\endcsname\relax
    \hangulunichar{#1}%
  \else
    \ucshanguljadetex@character@orig{#1}%
  \fi}
\edef\ucshanguljadetex@f@series{\f@series}%
\def\hangulunichar#1{%
  \begingroup
  \edef\temp@f@series{\f@series}%
  \ifx\temp@f@series\ucshanguljadetex@f@series
    \ifx\ProcessingMode{book-title-verso-mode}
      \let\myhangulfont\hangulfonttitlenormal
    \else    
      \let\myhangulfont\hangulfontnormal
    \fi
  \else
    \ifx\ProcessingMode{book-title-verso-mode}
      \let\myhangulfont\hangulfonttitlebold
    \else
      \let\myhangulfont\hangulfontbold
    \fi
  \fi
  \count2=#1                  % \count2   = "AC01
  \divide\count2 256          % \count2   = "AC
  \count4\count2              % \count4   = "AC
  \divide\count2 16           % \count2   = "A    ; determined
  \count255\count2            % \count255 = "A
  \multiply\count255 16       % \count255 = "A0
  \advance\count4 -\count255  % \count4   = "C    ; determined
  \edef\mymyfont{\myhangulfont
    \ifcase\count2  0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or
                    8\or 9\or a\or b\or c\or d\or e\or f\fi
    \ifcase\count4  0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or
                    8\or 9\or a\or b\or c\or d\or e\or f\fi}%
  \font\myfont\mymyfont\space at \f@size pt\relax
  % calculate hangul char number
  \count2=#1                  % \count2   = "AC01
  \count255\count2            % \count255 = "AC01
  \divide\count255 256        % \count255 = "AC
  \multiply\count255 256      % \count255 = "AC00
  \advance\count2 -\count255  % \count2   = "1    ; determined
  \breakbeforehangulchar{#1}% allow linebreak before hangul chars
  \myfont\char\count2 % print character
  \hangulspacefactor{#1}% insert hangul spacefactor
  \endgroup
  \futurelet\nextglyph\breakbeforeasciioparen% allowbreak before ascii OP (
}
% disallow linebreak after OP
\sfcode`\(=998
\sfcode`\`=998
\sfcode`\[=998
\def\breakbeforehangulchar#1{%
  \ifnum#1> 13311 
  \ifnum#1< 64255 
  \ifhmode
  \ifdim\lastskip=0pt
  \ifnum\spacefactor>998
  \ifnum\spacefactor=1001
    \discretionary{}{}{\kern-.085em}%
  \else
    \allowbreak
  \fi\fi\fi\fi\fi\fi
}
\def\hangulspacefactor#1{%
  \ifnum#1>13311
    \ifnum#1<64255 \spacefactor=1001 \else% hangul, hanja
    \ifnum#1=65288 \spacefactor=998  \else% (
    \ifnum#1=65308 \spacefactor=998  \else% <
    \ifnum#1=65339 \spacefactor=998  \else% [
    \ifnum#1=65371 \spacefactor=998       % {
    \fi\fi\fi\fi\fi\else
  \ifnum#1>12295
  \ifnum#1<12316                       % 〈〉《》「」 etc
    \ifodd#1 \else \spacefactor=998 \fi% 〈《「『【 etc
  \fi\fi\fi
}
\def\breakbeforeasciioparen{\ifx (\nextglyph\allowbreak\fi}
\linespread{1.3}