summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/polyglossia/gloss-tibetan.ldf
blob: 759bc8c08e913d58a1bb51577a9f0eb420e03c82 (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
135
136
137
138
\ProvidesFile{gloss-tibetan.ldf}[polyglossia: module for tibetan]
%% Copyright 2013 Elie Roux
%% Under the CC0 license <http://creativecommons.org/publicdomain/zero/1.0/>
%%
%% A good font to make tests is \newfontfamily\tibetanfont{Tibetan Machine Uni}
%%

\PolyglossiaSetup{tibetan}{
  script=Tibetan,
  scripttag=tibt,
  hyphennames={nohyphenation},
  fontsetup=true
  %TODO localalph={xxx@alph,xxx@Alph}
  %TODO localdigits=tibetannumber
}

\newif\if@tibetan@numerals
\def\tmp@tibetan{tibetan}
\define@key{tibetan}{numerals}[tibetan]{%
	\def\@tmpa{#1}%
	\ifx\@tmpa\tmp@tibetan\@tibetan@numeralstrue\else
	  \@tibetan@numeralsfalse\fi
}

\setkeys{tibetan}{numerals}

% some are known, but very few
% a few come from "Standardizing Tibetan Terms of Information Technology"
% from the China Tibetology Research Center
\def\captionstibetan{%
   %\def\refname{}%
   \def\abstractname{གནད་བསྡུས།}%
   \def\bibname{དཔེ་ཆའི་ཐོ་གཞུང་།}% or dpe deb kyi re'u mig?
   \def\prefacename{དཔེ་དེབ་ཀྱི་གླེང་བརྗོད།}% or gleng brjod 'god pa or ngo sprod?
   \def\chaptername{ལེའུ་}%
   \def\appendixname{ཞར་བྱུང་།}%
   \def\contentsname{དཀར་ཆག།}%
   %\def\listfigurename{}%
   %\def\listtablename{}%
   \def\indexname{གསུལ་བྱང་།}%
   \def\figurename{པར་རིས་}% or dpe ris?
   \def\tablename{རེའུ་མིག་}%
   %\def\thepart{}%
   \def\partname{ཆ་ཤས་}%
   \def\pagename{ཤོག་}%
   %\def\seename{}%
   %\def\alsoname{}%
   %\def\enclname{}%
   \def\ccname{འདྲ་བཤུས་ལེན་མཁན་}%
   %\def\headtoname{}%
   \def\proofname{བདེན་དཔང་།}% not sure about this one...
   \def\glossaryname{མིང་ཚིག་རེའུ་མིག།}%
}
\def\datetibetan{%   
   \def\tibetan@month{%
     \ifcase\month\or
       ཟླ་དང་པོ\or ཟླ་གཉིས་པ\or ཟླ་གསུམ་པ%
      \or ཟླ་བཞི་པ\or ཟླ་ལྔ་པ\or ཟླ་དྲུག་པ\or ཟླ་བདུན་པ%
      \or ཟླ་བརྒྱད་པ\or ཟླ་དགུ་པ\or ཟླ་བཆུ་པ\or ཟླ་བཆུ་གཅིག་པ\or ཟླ་བཆུ་གཉིས་པ\fi}%      
   \def\tibetan@daynum{%
     \ifcase\day\or དང་པོ\or གཉིས་པ\or གསུམ་པ \or བཞི་པ\or ལྔ་པ\or དྲུག་པ\or བདུན་པ\or བརྒྱད་པ\or དགུ་པ\or བཆུ་པ%
 \or བཆུ་གཅིག་པ\or བཆུ་གཉིས་པ\or བཆུ་གསུམ་པ\or བཆུ་བཞི་པ\or བཆུ་ལྔ་པ\or བཆུ་དྲུག་པ\or བཆུ་བདུན་པ\or བཆུ་བརྒྱད་པ\or བཆུ་དགུ་པ\or ཉི་ཤུ་པ%
 
 \or ཉི་ཤུ་རྩ་གཅིག་པ\or ཉི་ཤུ་རྩ་གཉིས་པ\or ཉི་ཤུ་རྩ་གསུམ་པ\or ཉི་ཤུ་རྩ་བཞི་པ\or ཉི་ཤུ་རྩ་ལྔ་པ\or ཉི་ཤུ་རྩ་དྲུག་པ\or ཉི་ཤུ་རྩ་བདུན་པ\or ཉི་ཤུ་རྩ་བརྒྱད་པ\or ཉི་ཤུ་རྩ་དགུ་པ\or སུམ་ཆུ་པ%
 \or སུམ་ཆུ་སོ་གཅིག་པ\fi}%      
   % As we use gregorian calendar, it's better to stick with spyi lo
   %\newcount\tibetan@year%
   %\tibetan@year=\year%
   %\advance\tibetan@year by 127% this is bod rgyal lo, the most common, but there are others...
   % I'm not sure the / character is in most tibetan fonts
   %\def\today{\tibetannumber\day /\tibetannumber\day /\tibetannumber\year}%
   \def\today{\tibetannumber\day །\tibetannumber\month །\tibetannumber\year}%
   % this is more litterate, but longer
   %\def\today{སྤྱི་ལོ་\tibetannumber\year ་སྤྱི་\tibetan@month{}་ད་རེས་\tibetan@daynum{}།}%  
}

\def\tibetandigits#1{\expandafter\@tibetan@digits #1@}
\def\@tibetan@digits#1{%
  \ifx @#1% then terminate
  \else
    \ifx0#1༠\else\ifx1#1༡\else\ifx2#1༢\else\ifx3#1༣\else\ifx4#1༤\else\ifx5#1༥\else\ifx6#1༦\else\ifx7#1༧\else\ifx8#1༨\else\ifx9#1༩\else#1\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
    \expandafter\@tibetan@digits
  \fi
}

\def\tibetannumber#1{%
  \if@tibetan@numerals
    \tibetandigits{\number#1}%
    %%{\protect\addfontfeature{Mapping=tibetandigits}\protect\number#1}
  \else
    \number#1%
    %%{\protect\reset@font\number#1}
  \fi}

\def\@tibetanalph#1{%
  \ifcase#1\or ཀ\or ཁ\or ག\or ང\or ཅ\or ཆ\or ཇ\or ཉ\or ཏ\or ཐ\or ད\or ན\or པ\or 
  ཕ\or བ\or མ\or ཙ\or ཚ\or ཛ\or ཝ\or ཞ\or ཟ\or འ\or ཡ\or ར\or ལ\or ཤ\or ས\or ཧ\or ཨ
 \else\xpg@ill@value{#1}{@tibetanalph}\fi}
\def\tibetanAlph#1{\expandafter\@tibetanAlph\csname c@#1\endcsname}
\def\@tibetanAlph#1{%
  \ifcase#1\or ཀ\or ཁ\or ག\or ང\or ཅ\or ཆ\or ཇ\or ཉ\or ཏ\or ཐ\or ད\or ན\or པ\or 
  ཕ\or བ\or མ\or ཙ\or ཚ\or ཛ\or ཝ\or ཞ\or ཟ\or འ\or ཡ\or ར\or ལ\or ཤ\or ས\or ཧ\or ཨ
 \else\xpg@ill@value{#1}{@tibetanalph}\fi}
     
\def\tibetan@numbers{%
   \let\@latinalph\@alph%
   \let\@latinAlph\@Alph%
   \if@tibetan@numerals
     \let\@alph\@tibetanalph%
     \let\@Alph\@tibetanAlph%
   \fi
}
\def\notibetan@numbers{%
  \let\@alph\@latinalph%
  \let\@Alph\@latinAlph%
}

\def\tibetan@globalnumbers{%
   \let\orig@arabic\@arabic%
   \let\@arabic\tibetannumber%
   \renewcommand{\thefootnote}{\protect\tibetannumber{\c@footnote}}%
}
\def\notibetan@globalnumbers{%
   \let\@arabic\orig@arabic%
   \renewcommand\thefootnote{\protect\number{\c@footnote}}%
}

% copied from Thai, not tested

\def\blockextras@tibetan{%
   \let\orig@baselinestrech\baselinestretch%
   \renewcommand{\baselinestretch}{1.2}%
}
\def\noblockextras@tibetan{%
   \let\baselinestrech\orig@baselinestretch%
}

\endinput