summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/polyglossia/gloss-tibetan.ldf
blob: bf1647cca763bab4c33687a520c3664652866688 (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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
% Language definition file (part of polyglossia v1.58 -- 2022/10/26)
%
\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}{
  bcp47=bo,
  script=Tibetan,
  scripttag=tibt,
  langtag=TIB,
  hyphennames={nohyphenation},
  fontsetup=true,
  localnumeral=tibetannumerals
  %TODO localalph={xxx@alph,xxx@Alph}
}

% BCP-47 compliant aliases
\setlanguagealias*{tibetan}{bo}

\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%
}

\ifluatex
  \newluatexattribute\xpg@tibteol %
  \directlua{polyglossia.load_tibt_eol()}%
\fi

\def\tibetan@eol{%
  \ifluatex%
    \xpg@tibteol=1\relax%
    \directlua{polyglossia.activate_tibt_eol()}%
  \else%
    \XeTeXlinebreaklocale "bo"%
    \XeTeXlinebreakskip=0pt plus 0.1em% doesn't do much, but doesn't harm I guess...
  \fi%
}

\def\notibetan@eol{%
  \ifluatex%
    \xpg@tibteol=0\relax%
    %\directlua{polyglossia.activate_tibt_eol()}%
  \else%
    \XeTeXlinebreaklocale "en"% en? really?
    \XeTeXlinebreakskip=0pt plus 0pt%
  \fi%
}

% Register default options
\xpg@initialize@gloss@options{tibetan}{numerals=tibetan}

% 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%
}

\newcommand{\tibetanumerals}[2]{\tibetannumber{#2}}

\def\tibetan@numbers{%
   \if@tibetan@numerals
     \let\@alph\@tibetanalph%
     \let\@Alph\@tibetanAlph%
   \fi
}

\def\notibetan@numbers{%
  \let\@alph\latin@alph%
  \let\@Alph\latin@Alph%
}

% Store original definition
\let\xpg@orig@arabic\@arabic

\def\tibetan@globalnumbers{%
   \let\@arabic\tibetannumber%
   \renewcommand{\thefootnote}{\localnumeral*{footnote}}%
}

\def\notibetan@globalnumbers{%
   \let\@arabic\xpg@orig@arabic%
}

\def\noextras@tibetan{%
   \notibetan@eol%
   \ifcsname xpg@orig@baselinestretch\endcsname%
       \renewcommand{\baselinestretch}{\xpg@orig@baselinestretch}%
   \fi%
}

\def\inlineextras@tibetan{%
   \xdef\xpg@orig@baselinestretch{%
       \ifcsname baselinestretch\endcsname
           \baselinestretch
        \else
           1%
        \fi%
   }%
   \renewcommand{\baselinestretch}{1.2}%
   \tibetan@eol%
}

\def\blockextras@tibetan{%
   \xdef\xpg@orig@baselinestretch{%
        \ifcsname baselinestretch\endcsname
            \baselinestretch
        \else
           1%
        \fi%
   }%
   \renewcommand{\baselinestretch}{1.2}%
   \tibetan@eol%
}

\endinput