-
Notifications
You must be signed in to change notification settings - Fork 0
/
yiddish.tex
195 lines (158 loc) · 4.25 KB
/
yiddish.tex
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
% Author: Marc Trius
% Email: [email protected]
% Licensed under GNU General Public License
\startenvironment yiddish
% Strings replacement
\setupheadtext[content=אינהאַלט]
% breaks the head text
% \installlanguage
% [yiddish]
% [righthyphenchar="05BE,
% default=en]
\mainlanguage[yiddish]
\setupdirections[bidi=global,method=one]
\setupalign[r2l, hz, hanging]
\setuplayout[direction=reverse]
\setupinteractionscreen[option=righttoleft]
% Numbers
\dontcomplain
\startluacode
local concat, insert, reverse = table.concat, table.insert, table.reverse
local rep = string.rep
local floor = math.floor
local trace_hebrew trackers.register("converters.hebrew", function(v)
trace_hebrew = v
end)
local list = {
{ 400, "ת" },
{ 300, "ש" },
{ 200, "ר" },
{ 100, "ק" },
{ 90, "צ" },
{ 80, "פ" },
{ 70, "ע" },
{ 60, "ס "},
{ 50, "נ" },
{ 40, "מ" },
{ 30, "ל" },
{ 20, "כ" },
{ 10, "י" ,},
{ 9, "ט" },
{ 8, "ח" },
{ 7, "ז", },
{ 6, "ו", },
{ 5, "ה" },
{ 4, "ד" },
{ 3, "ג" },
{ 2, "ב" },
{ 1, "א" },
}
local special = {
[15] = "ט״ו", -- exception: avoid mixup with God יה
[16] = "ט״ז", -- exception: avoid mixup with God יו
}
local function tohebrew(n,gershayim,geresh)
local split = { }
local size = 0
while n > 1000 do
size = size + 1
split[size] = n % 1000
n = floor(n/1000)
end
size = size + 1
split[size] = n
for i=1,size do
local t = { }
local n = 0
local s = split[i]
while s > 0 do
for i=1,#list do
::again::
local li = list[i]
local l1 = li[1]
local s1 = special[l1]
if s1 then
s = s - l1
n = n + 1
t[n] = s1
goto again
elseif s >= l1 then
s = s - l1
n = n + 1
t[n] = li[2]
goto again
end
end
end
::done::
split[i] = t
end
if gershayim then
for i=1,size do
local si = split[i]
local ni = #si
if ni >= 2 then
local s = "״"
insert(split[i],ni,trace_hebrew and ("{\\red "..s.."}") or s)
end
end
end
if geresh then
for i=2,#split do
local s = rep("׳",i-1)
insert(split[i],trace_hebrew and ("{\\blue "..s.."}") or s)
end
end
for i=1,size do
split[i] = concat(split[i])
end
result = string.format("{\\righttoleft %s}",concat(reverse(split)))
return result
end
converters.tohebrew = hebrewnumber
converters.hebrewnumerals = converters.hebrew
-- converters['alphabetic:hb'] = converters.hebrewnumerals
interfaces.implement {
name = "hebrewnumerals",
actions = { tohebrew, context },
arguments = { "integer", true, true }
}
\stopluacode
\unprotect
\def\hebrewnumerals#1{\clf_hebrewnumerals\numexpr#1\relax}
\protect
\defineconversion [hebrewnumerals] [\hebrewnumerals]
\enabletrackers[converters.hebrew]
% Fonts
\definefontfeature [yiddish] [hebrew] [
protrusion=punctuation,
expansion=quality,
% hlig=no,
% liga=no,
dlig=no,
% clig=no
]
\starttypescript [serif] [Frank Ruehl]
\definefontsynonym [Serif] [file:fonts/FrankRuehlCLM-Medium.ttf] [features=yiddish]
\definefontsynonym [SerifBold] [file:fonts/FrankRuehlCLM-Bold.ttf] [features=yiddish]
\stoptypescript
\starttypescript [sans] [Secular]
\definefontsynonym [Sans] [file:fonts/SecularOne-Regular.ttf] [features=yiddish]
\definefontsynonym [SansBold] [file:fonts/SuezOne-Regular.ttf] [features=yiddish]
\stoptypescript
\definetypeface [yiddish] [rm] [serif] [Frank Ruehl]
\definetypeface [yiddish] [ss] [sans] [Secular]
\setupbodyfont[yiddish,rm,12pt]
\setupbodyfont [yiddish]
% Emphasis
\definehighlight[em]
\setuphighlight[em][style={\setcharacterkerning[extrakerning]}]
\usemodule [translate]
\enableinputtranslation
% Correct horizontal bar spacing
\translateinput
[―]
[\sixperemspace―\sixperemspace]
% Hyphenation
\input{hyphenation_list}
\stopenvironment