typo-lan.mkiv /size: 1749 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=typo-lan,
3
%D version=2013.03.22,
4
%D title=\CONTEXT\ Typesetting Macros,
5
%D subtitle=Language Goodies,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
\writestatus
{
loading
}{
ConTeXt
Typography
Macros
/
Languages
}
15 16
\unprotect
17 18
\registerctxluafile
{
typo
-
lan
}{}
19 20
%D \macros
21
%D {averagecharwidth, charwidthlanguage}
22
%D
23
%D This is a more \MKIV-ish variant of lang-frq.mkiv. The methods are
24
%D gone as one doesn't need the tables for them. The main macro is
25
%D \type {\averagecharwidth} which behaves like a dimension register.
26
%D
27
%D I finally decided to reimplement this as I needed it for a manual
28
%D (which is often a reason for such a rewrite). With some inspiring
29
%D Porcupine Tree in the background it's not the worst thing to do.
30 31
\def
\charwidthlanguage
{
\currentmainlanguage
}
32 33
\def
\averagecharwidth
{
\dimexpr
\clf_averagecharwidth
{
\charwidthlanguage
}
\scaledpoint
\relax
}
34
\def
\languagecharwidth
#
1
{
\dimexpr
\clf_averagecharwidth
{
#
1
}
\scaledpoint
\relax
}
35 36
\protect
37 38
\continueifinputfile
{
typo
-
lan
.
mkiv
}
39 40
\setuplayout
[
backspace
=
4
cm
]
41 42
\showframe
43 44
\starttext
45 46
\startbuffer
47 48
\mainlanguage
[
en
]
\hsize
6
5
\averagecharwidth
\normalexpanded
{
\inleft
{
\the\hsize
}}
\input
ward
\par
49
\mainlanguage
[
de
]
\hsize
6
5
\averagecharwidth
\normalexpanded
{
\inleft
{
\the\hsize
}}
\input
ward
\par
50
\mainlanguage
[
nl
]
\hsize
6
5
\averagecharwidth
\normalexpanded
{
\inleft
{
\the\hsize
}}
\input
ward
\par
51 52
\stopbuffer
53 54
\getbuffer
\blank
55 56
\switchtobodyfont
[
pagella
]
57 58
\getbuffer
\blank
59 60
\switchtobodyfont
[
tt
,
8
pt
]
61 62
\getbuffer
63 64
\stoptext
65