summaryrefslogtreecommitdiff
path: root/tex/context
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2011-05-10 22:22:38 +0200
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2011-05-10 22:22:38 +0200
commitc3fcd6a29999502c8c0e080c780c24284a754207 (patch)
tree437c7d655ebb7744536524b26138145a0ebadaa1 /tex/context
parentf3a4c4e7b2cfa0a12bf465a7753681aff2de39bc (diff)
downloadtransliterator-c3fcd6a29999502c8c0e080c780c24284a754207.tar.gz
hinting (character: “*”)
Diffstat (limited to 'tex/context')
-rw-r--r--tex/context/third/transliterator/t-transliterator.mkiv25
-rw-r--r--tex/context/third/transliterator/trans_tables_sr.lua30
2 files changed, 47 insertions, 8 deletions
diff --git a/tex/context/third/transliterator/t-transliterator.mkiv b/tex/context/third/transliterator/t-transliterator.mkiv
index e918b7b..b6b841c 100644
--- a/tex/context/third/transliterator/t-transliterator.mkiv
+++ b/tex/context/third/transliterator/t-transliterator.mkiv
@@ -34,8 +34,31 @@
%D key-value options; at present you may configure \type{mode} and
%D \type{hyphenate}.
+\def\set_serbian_exceptions{%
+ \doifelse{\transliterateparameter{sr_exceptions}}\v!yes
+ {\ctxlua{translit.sr_except = true}}
+ {\ctxlua{translit.sr_except = false}}%
+}
+
+\def\set_hinting{%
+ \doifelse{\transliterateparameter{hinting}}\v!yes
+ {\ctxlua{translit.hinting = true}}
+ {\ctxlua{translit.hinting = false}}%
+}
+
+\appendtoks \set_serbian_exceptions \to \everysetuptransliterate
+\appendtoks \set_hinting \to \everysetuptransliterate
+
%D At first we'll set some defaults:
-\setuptransliterate[mode=ru_old,hyphenate=cz,debug=false]
+
+\setuptransliterate[%
+ debug=\v!false,
+ hinting=\v!yes,
+ hyphenate=cz,
+ mode=ru_old,
+ sr_exceptions=\v!yes,
+]
+
%D Possible values for \type{mode} are by the time of this writing:
%D \type{ru}, \type{ru_transcript_de}, \type{ru_transcript_en}, \type{ru_old},
%D \type{all}, \type{iso9_ocs}, \type{ocs}, \type{ocs_gla}, \type{ru_cz},
diff --git a/tex/context/third/transliterator/trans_tables_sr.lua b/tex/context/third/transliterator/trans_tables_sr.lua
index 953d934..0fab540 100644
--- a/tex/context/third/transliterator/trans_tables_sr.lua
+++ b/tex/context/third/transliterator/trans_tables_sr.lua
@@ -128,18 +128,30 @@ if not translit.done_serbian then
end
end
- translit.serbian_exceptions = { }
+ --local _p_hintchar = P"*" / ""
+ local _p_hintchar = P"*" / ""
+ local hintme = "dln"
+ local _p_tocy_hint, _p_tolt_hint
- local _p_hintchar = P"|" / ""
- local hintme = P"dln"
for left in hintme:utfcharacters() do
local right = translit.sr_tocy_lower[left]
local LEFT, RIGHT = upper(left), upper(right)
+ if not _p_tocy_hint then
+ _p_tocy_hint = P(left) / right + P(LEFT) / RIGHT
+ _p_tolt_hint = P(right) / left + P(RIGHT) / LEFT
+ else
+ _p_tocy_hint = _p_tocy_hint + P(left) / right + P(LEFT) / RIGHT
+ _p_tolt_hint = _p_tolt_hint + P(right) / left + P(RIGHT) / LEFT
+ end
end
+
+ translit.serbian_exceptions = { }
translit.serbian_exceptions.p_tocy = p_tocy
translit.serbian_exceptions.p_tolt = p_tolt
translit.serbian_exceptions.p_tocy_init = p_i_tocy
translit.serbian_exceptions.p_tolt_init = p_i_tolt
+ translit.serbian_exceptions.p_tocy_hint = _p_tocy_hint * _p_hintchar
+ translit.serbian_exceptions.p_tolt_hint = _p_tolt_hint * _p_hintchar
translit.done_serbian = true
end
@@ -153,17 +165,21 @@ local t = translit
local function sr (mode, text)
local P, R, Cs = lpeg.P, lpeg.R, lpeg.Cs
local utfchar = translit.utfchar
- local _p_sre = t.serbian_exceptions["p_" .. mode:match("to..$")]
- local _p_sre_i = t.serbian_exceptions["p_" .. mode:match("to..$") .. "_init"]
+ local modestr = "p_" .. mode:match("to..$")
+ local _p_sre = t.serbian_exceptions[modestr]
+ local _p_sre_i = t.serbian_exceptions[modestr .. "_init"]
local trl_sr = translit.make_add_dict{}
trl_sr = t[mode.."_upper"] + t[mode.."_lower"]
-- transliteration from latin script requires macro handling …
local _p_macro = P[[\]] * R("az", "AZ")^1
- local _p_sr = translit.addrules (trl_sr)
+ local _p_sr = translit.addrules (trl_sr, _p_sr) / trl_sr
+ if translit.hinting then
+ _p_sr = t.serbian_exceptions[modestr .. "_hint"] + _p_sr
+ end
- local p_sr = Cs(_p_sre_i^-1 * (_p_macro + _p_sre + (_p_sr / trl_sr) + utfchar)^0)
+ local p_sr = Cs(_p_sre_i^-1 * (_p_macro + _p_sre + _p_sr + utfchar)^0)
return p_sr:match(text)
end