summaryrefslogtreecommitdiff
path: root/tex/context
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context')
-rw-r--r--tex/context/third/cyrillicnumbers/cyrillicnumbers.lua99
-rw-r--r--tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv265
2 files changed, 364 insertions, 0 deletions
diff --git a/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua b/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua
new file mode 100644
index 0000000..d47c744
--- /dev/null
+++ b/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua
@@ -0,0 +1,99 @@
+#!/usr/bin/env texlua
+--------------------------------------------------------------------------------
+-- FILE: cyrillicnumbers.lua
+-- USAGE: called by t-cyrillicnumbers.mkiv
+-- DESCRIPTION: part of the Cyrillic Numbers module for ConTeXt
+-- REQUIREMENTS: recent ConTeXt MkIV and LuaTeX
+-- AUTHOR: Philipp Gesang (phg), <gesang at stud dot uni-heidelberg dot de>
+-- VERSION: hg tip
+-- CREATED: 2011-11-29 10:06:00+0100
+--------------------------------------------------------------------------------
+--
+
+--- read this first:
+---
+--- Жолобов, О. Ф.: *Числительные*. In: *Историческая грамматика древнерусского
+--- языка*, vol. 4, Moskva 2006, pp. 58--63
+---
+--- Trunte, Nikolaos H.: *Altkirchenslavisch*. In: *Словѣньскъи ѩꙁъікъ.
+--- Ein praktisches Lehrbuch des Kirchenslavischen in 30
+--- Lektionen. Zugleich eine Einführung in die slavische
+--- Philologie*, vol. 1, München ⁵2005, pp. 161ff.
+
+--- or have a glance at these:
+--- http://www.pravpiter.ru/zads/n018/ta013.htm
+--- http://www.uni-giessen.de/partosch/eurotex99/berdnikov2.pdf
+--- <http://ru.wikipedia.org/wiki/Кириллическая_система_счисления>
+
+local mathfloor = math.floor
+local tableconcat = table.concat
+local utf8char = unicode.utf8.char
+local utfupper = unicode.utf8.upper
+
+thirddata = thirddata or { }
+
+local cyrillic_placetitlo = true
+
+local cyrillic_numerals = {
+ { "а", "в", "г", "д", "е", "ѕ", "з", "и", "ѳ", },
+ { "і", "к", "л", "м", "н", "ѯ", "о", "п", "ч", },
+ { "р", "с", "т", "у", "ф", "х", "ѱ", "ѡ", "ц", },
+}
+local cyrillic_1k = "҂"
+local cyrillic_100k = utf8char(0x488) -- combining hundred thousands sign
+local cyrillic_1m = utf8char(0x489) -- combining million sign
+local cyrillic_titlo = utf8char(0x483) -- combining titlo
+
+local concat_cyrillic_nums = function (chars, upper)
+ local result = ""
+ for i=#chars, 1, -1 do
+ local this = chars[i]
+ if this then
+ if upper then this = utfupper(this) end
+ if i > 3 then
+ result = result .. cyrillic_1k .. this
+ else
+ result = result .. this
+ end
+ end
+ end
+ if cyrillic_placetitlo then -- not all fonts do this well
+ result = result .. cyrillic_titlo
+ end
+ return result
+end
+
+local do_tocyrillic do_tocyrillic = function (n, result)
+ if n < 1000 then
+ local mod100 = n % 100
+ if #result == 0 and mod100 > 10 and mod100 < 20 then
+ result[#result+1] = "і"
+ result[#result+1] = cyrillic_numerals[1][mod100%10] or false
+ else
+ result[#result+1] = cyrillic_numerals[1][mathfloor(n%10)] or false
+ result[#result+1] = cyrillic_numerals[2][mathfloor((n%100)/10)] or false
+ end
+ result[#result+1] = cyrillic_numerals[3][mathfloor((n%1000)/100)] or false
+ else
+ result = do_tocyrillic(n%1000, result)
+ result = do_tocyrillic(mathfloor(n/1000), result)
+ end
+ return result
+end
+
+local tocyrillic = function (n)
+ local chars = do_tocyrillic(n, { })
+ return concat_cyrillic_nums(chars)
+end
+
+local Tocyrillic = function (n)
+ local chars = do_tocyrillic(n, { })
+ return concat_cyrillic_nums(chars, true)
+end
+
+converters.tocyrillic = tocyrillic
+converters.cyrillicnumerals = tocyrillic
+converters.Cyrillicnumerals = Tocyrillic
+
+function commands.cyrillicnumerals (n) context(tocyrillic(n)) end
+function commands.Cyrillicnumerals (n) context(Tocyrillic(n)) end
diff --git a/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv b/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv
new file mode 100644
index 0000000..5ebaf29
--- /dev/null
+++ b/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv
@@ -0,0 +1,265 @@
+%D \module
+%D [ file=t-cyrillicnumbers,
+%D version=2011-11-29 09:58:48+0100,
+%D title=\CONTEXT\ User Module,
+%D subtitle=Cyrillic Number Module,
+%D author=Philipp Gesang,
+%D date=\currentdate,
+%D copyright=Philipp Gesang,
+%D license=2-clause BSD,
+%D email={gesang at stud dot uni-heidelberg dot de}]
+%D This module is licensed under the conditions of the BSD license with
+%D two clauses. There is a copy in a file named "COPYING" in the
+%D t-cyrillicnumbers source tree.
+
+\writestatus{loading}{Cyrillic Number Support for ConTeXt}
+
+\unprotect
+
+\definenamespace [cyrnum] [
+ name=cyrnum,
+ type=module,
+ setup=list,
+ parent=cyrnum,
+ style=no,
+ version=hg-tip,
+ comment=cyrillic numbers,
+]
+
+\registerctxluafile{cyrillicnumbers}
+
+\enablemode[cyrnum-titlo9]
+
+\def\cyrnum_penwidth{12}
+
+\startuniqueMPgraphic{cyrnum-titlo1}
+ path titlo ;
+ save High, Low ;
+ save Vfactor ; Vfactor = .15 ;
+ save Hfactor ; Hfactor = .90 ;
+ titlo := ( 0.00, -Vfactor) ..
+ ( 0.05, .4*Vfactor) ..
+ ( 0.95, -.4*Vfactor) ..
+ ( 1.00, Vfactor) ;
+ pickup pensquare yscaled \cyrnum_penwidth xscaled 1 rotated -30 ;
+ draw titlo
+ xysized (Hfactor*OverlayWidth,Vfactor*OverlayHeight)
+ shifted (.5*(OverlayWidth-Hfactor*OverlayWidth),OverlayHeight-Vfactor*OverlayHeight) ;
+ setbounds currentpicture to boundingbox OverlayBox ;
+\stopuniqueMPgraphic
+
+\startuniqueMPgraphic{cyrnum-titlo2}
+ path titlo ;
+ save penwidth ; penwidth = \cyrnum_penwidth ;
+ save High, Low ;
+ save Vfactor ; Vfactor = .15 ;
+ save Hfactor ; Hfactor = .80 ;
+ titlo := ( 0.05, -Vfactor) --
+ ( 0.07, .7*Vfactor) ..
+ ( 0.09, .8*Vfactor) ..
+ ( 0.91, -.8*Vfactor) ..
+ ( 0.93, -.7*Vfactor) --
+ ( 0.95, Vfactor) ;
+ pickup pensquare yscaled penwidth xscaled 1 rotated 70 ;
+ draw titlo
+ xysized (Hfactor*OverlayWidth,Vfactor*OverlayHeight)
+ shifted (.5*(OverlayWidth-Hfactor*OverlayWidth)-.5*penwidth,OverlayHeight-Vfactor*OverlayHeight) ;
+ setbounds currentpicture to boundingbox OverlayBox ;
+\stopuniqueMPgraphic
+
+\startuniqueMPgraphic{cyrnum-titlo3}
+ path titlo ;
+ save penwidth ; penwidth = \cyrnum_penwidth ;
+ save High, Low ;
+ save Vfactor ; Vfactor = .15 ;
+ save Hfactor ; Hfactor = .80 ;
+ titlo := ( 0.05, -Vfactor) --
+ ( 0.07, 0.70*Vfactor) ..
+ ( 0.09, 0.90*Vfactor) .. { dir 00 }
+ ( 0.49, -0.00*Vfactor) --
+ ( 0.49, -0.90*Vfactor) --
+ ( 0.51, 0.90*Vfactor) --
+ ( 0.51, 0.00*Vfactor) { dir 00 } ..
+ ( 0.91, -0.90*Vfactor) ..
+ ( 0.93, -0.70*Vfactor) --
+ ( 0.95, Vfactor) ;
+ pickup pensquare yscaled penwidth xscaled 1 rotated 70 ;
+ draw titlo
+ xysized (Hfactor*OverlayWidth,Vfactor*OverlayHeight)
+ shifted (.5*(OverlayWidth-Hfactor*OverlayWidth)-.5*penwidth,OverlayHeight-Vfactor*OverlayHeight) ;
+ setbounds currentpicture to boundingbox OverlayBox ;
+\stopuniqueMPgraphic
+
+%%% Same as 2 with inner vertical stroke
+\startuniqueMPgraphic{cyrnum-titlo4}
+ path titlo, stroke ;
+ save penwidth ; penwidth = \cyrnum_penwidth ;
+ save High, Low ;
+ save Vfactor ; Vfactor = .15 ;
+ save Hfactor ; Hfactor = .80 ;
+ titlo = ( 0.05, -1.00*Vfactor) --
+ ( 0.07, 0.70*Vfactor) ..
+ ( 0.09, 0.90*Vfactor) { dir 00 } .. { dir 00 }
+ ( 0.91, -0.90*Vfactor) ..
+ ( 0.93, -0.70*Vfactor) --
+ ( 0.95, 1.00*Vfactor) ;
+ stroke = ( 0.49*Hfactor*OverlayWidth+.5*penwidth, -0.30*Vfactor*OverlayHeight ) -- %% this is a mess
+ ( 0.51*Hfactor*OverlayWidth+.5*penwidth, 0.50*Vfactor*OverlayHeight ) ;
+ pickup pensquare yscaled penwidth xscaled 1 rotated 80 ;
+ draw titlo
+ xysized (Hfactor*OverlayWidth,Vfactor*OverlayHeight)
+ shifted (.5*(OverlayWidth-Hfactor*OverlayWidth)-.5*penwidth,OverlayHeight-Vfactor*OverlayHeight) ;
+ draw stroke
+ % xysized (Hfactor*OverlayWidth,Vfactor*OverlayHeight) %% doesn’t work as expected somehow
+ shifted (.5*(OverlayWidth-Hfactor*OverlayWidth)-.5*penwidth,OverlayHeight-Vfactor*OverlayHeight) ;
+ setbounds currentpicture to boundingbox OverlayBox ;
+\stopuniqueMPgraphic
+
+\startuniqueMPgraphic{cyrnum-titlo5}
+ path titlo ;
+ save penwidth ; penwidth = \cyrnum_penwidth ;
+ save High, Low ;
+ save Vfactor ; Vfactor = .20 ;
+ save Hfactor ; Hfactor = .85 ;
+ titlo := ( 0.00, -0.8*Vfactor) {dir 90} .. {dir 90}
+ ( 1.00, 1.2*Vfactor) ;
+ pickup pensquare yscaled penwidth xscaled 2 rotated 85 ;
+ draw titlo
+ xysized (Hfactor*OverlayWidth-.5*penwidth,Vfactor*OverlayHeight)
+ shifted (.5*(OverlayWidth-Hfactor*OverlayWidth),OverlayHeight-Vfactor*OverlayHeight) ;
+ setbounds currentpicture to boundingbox OverlayBox ;
+\stopuniqueMPgraphic
+
+\startuniqueMPgraphic{cyrnum-titlo6}
+ path titlo ;
+ save penwidth ; penwidth = \cyrnum_penwidth ;
+ save High, Low ;
+ save Vfactor ; Vfactor = .20 ;
+ save Hfactor ; Hfactor = .85 ;
+ titlo := ( 0.03, -0.80*Vfactor) --
+ ( 0.03, 0.15*Vfactor) --
+ ( 0.00, 0.20*Vfactor) {right} .. {right}
+ ( 1.00, -0.20*Vfactor) --
+ ( 0.97, -0.15*Vfactor) --
+ ( 0.97, 0.80*Vfactor) ;
+ pickup pensquare yscaled penwidth xscaled sqrt(2) rotated 90 ;
+ draw titlo
+ xysized (Hfactor*OverlayWidth-.5*penwidth,Vfactor*OverlayHeight)
+ shifted (.5*(OverlayWidth-Hfactor*OverlayWidth),OverlayHeight-(0.5*Vfactor*OverlayHeight)) ;
+ setbounds currentpicture to boundingbox OverlayBox ;
+\stopuniqueMPgraphic
+
+\startuniqueMPgraphic{cyrnum-titlo7}
+ path titlo ;
+ save penwidth ; penwidth = \cyrnum_penwidth ;
+ save High, Low ;
+ save Vfactor ; Vfactor = .20 ;
+ save Hfactor ; Hfactor = .85 ;
+ titlo := ( 0.05, -0.80*Vfactor) --
+ ( 0.05, -0.30*Vfactor) {up} .. {right}
+ ( 0.07, -0.00*Vfactor) --
+ ( 0.93, 0.00*Vfactor) {right} .. {up}
+ ( 0.95, 0.30*Vfactor) --
+ ( 0.95, 0.80*Vfactor) ;
+ pickup pensquare yscaled (0.66*penwidth) xscaled penwidth ;
+ draw titlo
+ xysized (Hfactor*OverlayWidth-2*penwidth,Vfactor*OverlayHeight)
+ shifted ((.5*penwidth+.5*(OverlayWidth-Hfactor*OverlayWidth)),
+ (OverlayHeight-(0.7*Vfactor*OverlayHeight))) ;
+ setbounds currentpicture to boundingbox OverlayBox ;
+\stopuniqueMPgraphic
+
+\startuniqueMPgraphic{cyrnum-titlo8}
+ path titlo, stroke ;
+ save penwidth ; penwidth = \cyrnum_penwidth ;
+ save High, Low ;
+ save Vfactor ; Vfactor = .20 ;
+ save Hfactor ; Hfactor = .85 ;
+ titlo := ( 0.15, -0.10*Vfactor) {dir 25} ..% tension 8 ..
+ controls (0.40, 0.50) and (0.00, 0.35) ..
+ ( 0.00, -0.00*Vfactor) {down} ..
+ controls (0.00, -0.30) and (0.10, -0.25) ..
+ % ( 0.10, -0.20*Vfactor) {right} .. tension 4 .. {dir -120}
+ ( 0.30, -0.90*Vfactor) ..
+ controls
+ ( 0.70, 0.20*Vfactor) and
+ ( 0.97, 0.08*Vfactor) ..
+ ( 0.97, -0.30*Vfactor) .. tension 6 .. {dir -140}
+ ( 0.95, -0.90*Vfactor) ;
+ stroke := ((0.45*Hfactor*OverlayWidth),-0.20*Vfactor*OverlayHeight) ..
+ ((0.54*Hfactor*OverlayWidth), 0.35*Vfactor*OverlayHeight) ---
+ ((0.65*Hfactor*OverlayWidth), 0.90*Vfactor*OverlayHeight) {dir -120} .. {dir 30}
+ % ((0.54*Hfactor*OverlayWidth), 0.35*Vfactor*OverlayHeight) ..
+ ((0.45*Hfactor*OverlayWidth), 0.90*Vfactor*OverlayHeight)
+ ;
+ pickup pensquare yscaled 2 xscaled (0.5*penwidth) rotated 10;
+ % pickup pensquare yscaled 1 xscaled 2 ;
+ draw titlo
+ xysized (Hfactor*OverlayWidth,Vfactor*OverlayHeight)
+ shifted ((.5*(OverlayWidth-Hfactor*OverlayWidth)),
+ (OverlayHeight-(0.7*Vfactor*OverlayHeight))) ;
+ pickup pensquare yscaled 2 xscaled (0.5*penwidth) rotated 70;
+ draw stroke
+ % xysized (Hfactor*OverlayWidth,Vfactor*OverlayHeight)
+ shifted ((.6*(OverlayWidth-Hfactor*OverlayWidth)),
+ (OverlayHeight-Vfactor*OverlayHeight))
+ ;
+ setbounds currentpicture to boundingbox OverlayBox ;
+\stopuniqueMPgraphic
+
+\startuniqueMPgraphic{cyrnum-titlo9}
+ path titlo ;
+ save penwidth ; penwidth = \cyrnum_penwidth ;
+ save High, Low ;
+ save Vfactor ; Vfactor = .10 ;
+ save Hfactor ; Hfactor = .85 ;
+ titlo := ( 0.05, -0.40*Vfactor) --
+ ( 0.05, 0.00*Vfactor) --
+ ( 0.95, 0.00*Vfactor) --
+ ( 0.95, -0.40*Vfactor) ;
+ pickup pensquare yscaled (2*penwidth/3) xscaled penwidth ;
+ draw titlo
+ xysized (Hfactor*OverlayWidth-2*penwidth,Vfactor*OverlayHeight)
+ shifted ((.5*penwidth+.5*(OverlayWidth-Hfactor*OverlayWidth)),
+ (OverlayHeight-(0.7*Vfactor*OverlayHeight))) ;
+ setbounds currentpicture to boundingbox OverlayBox ;
+\stopuniqueMPgraphic
+
+\startmode[cyrnum-titlo1]
+ \defineoverlay[cyrnum-titlo-overlay][\uniqueMPgraphic{cyrnum-titlo1}]
+\stopmode %%% titlo1
+\startmode[cyrnum-titlo2]
+ \defineoverlay[cyrnum-titlo-overlay][\uniqueMPgraphic{cyrnum-titlo2}]
+\stopmode
+\startmode[cyrnum-titlo3]
+ \defineoverlay[cyrnum-titlo-overlay][\uniqueMPgraphic{titlo3}]
+\stopmode
+\startmode[cyrnum-titlo4]
+ \defineoverlay[cyrnum-titlo-overlay][\uniqueMPgraphic{cyrnum-titlo4}]
+\stopmode
+\startmode[cyrnum-titlo5]
+ \defineoverlay[cyrnum-titlo-overlay][\uniqueMPgraphic{cyrnum-titlo5}]
+\stopmode
+\startmode[cyrnum-titlo6]
+ \defineoverlay[cyrnum-titlo-overlay][\uniqueMPgraphic{cyrnum-titlo6}]
+\stopmode
+\startmode[cyrnum-titlo7]
+ \defineoverlay[cyrnum-titlo-overlay][\uniqueMPgraphic{cyrnum-titlo7}]
+\stopmode
+\startmode[cyrnum-titlo8]
+ \defineoverlay[cyrnum-titlo-overlay][\uniqueMPgraphic{cyrnum-titlo8}]
+\stopmode
+\startmode[cyrnum-titlo9]
+ \defineoverlay[cyrnum-titlo-overlay][\uniqueMPgraphic{cyrnum-titlo9}]
+\stopmode
+
+\defineframed[cyrnum_titloframe][
+ location=low,
+ frame=off,
+ background=cyrnum-titlo-overlay,
+]
+
+\def\Titlo{\dontleavehmode\cyrnum_titloframe}
+
+\unprotect \endinput
+