summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/typo-par.mkiv
blob: 7153d1f8adc30d798bf4b7fb9a15900ec760a3c3 (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
%D \module
%D   [       file=typo-par,
%D        version=2011.10.27,
%D          title=\CONTEXT\ Typesetting Macros,
%D       subtitle=Paragraphs,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\writestatus{loading}{ConTeXt Typesetting Macros / Paragraphs}

%D This will change ... par specific attribute set and such.

\unprotect

\registerctxluafile{typo-par}{1.001}

\definesystemattribute[paragraphspecial][public]

\unexpanded\def\setparagraphspecial[#1]%
  {\ctxlua{typesetters.paragraphs.set("#1")}}

\appendtoks
    \attribute\paragraphspecialattribute\attributeunsetvalue
\to \everyforgetall

%D For the moment here: dropped caps redone. In addition to the
%D parameters shown in the example you can use the \type {style} and
%D more low level \type {font} keys to set up the font where
%D the first one wins. If you don't like the behaviour you can always
%D roll out your own command.
%D
%D \starttyping
%D \placeinitial \input ward \par \input ward \par \placeinitial \input tufte
%D
%D \setupinitial
%D   [location=text,
%D    n=2,
%D    color=darkred,
%D    distance=-1em,
%D    hoffset=1em,
%D    voffset=-3ex,
%D    before=\blank]
%D
%D \placeinitial \input ward \par \input ward \placeinitial \input tufte
%D \stoptyping

\installcorenamespace{initial}

\installsimplecommandhandler \??initial {initial} \??initial

\appendtoks
    \checkinitialparent % this might become automatic
\to \everysetupinitial

\def\v_typo_initials_auto_scale % magic
  {\the\dimexpr\lineheight*\initialparameter\c!n-\initialparameter\c!voffset\relax}

\setupinitial
  [\c!location=\v!text,
   \c!n=3,
 % \s!font=Bold sa 4,
   \s!font=Bold at \v_typo_initials_auto_scale,
   \c!distance=.125em,
   \c!hoffset=\zeropoint,
   \c!voffset=-1ex,
   \c!style=,
   \c!color=,
   \c!before=\blank]

\unexpanded\def\placeinitial
  {\dosingleempty\typo_initials_place}

\def\typo_initials_place[#1]% todo: optional text
  {\par
   \begingroup
   \edef\currentinitial{#1}%
   \begingroup
   \useinitialcolorparameter\c!color
   \ctxlua{typesetters.paragraphs.droppers.set {
     location = "\initialparameter\c!location",
     enabled  = true,
     n        = \number\initialparameter\c!n,
     distance = \number\dimexpr\initialparameter\c!distance,
     hoffset  = \number\dimexpr\initialparameter\c!hoffset,
     voffset  = \number\dimexpr\initialparameter\c!voffset,
     ma       = \the\attribute\colormodelattribute  ,
     ca       = \the\attribute\colorattribute       ,
     ta       = \the\attribute\transparencyattribute
   }}%
   \stopluacode
   \endgroup
   \begingroup
   \doifelsenothing{\initialparameter\c!style}
     {\definedfont[\initialparameter\s!font]}
     {\useinitialstyleparameter\c!style}%
   \ctxlua{typesetters.paragraphs.droppers.freeze()}%
   \endgroup
   \endgroup
   \setparagraphspecial[1]%
   \namedinitialparameter{#1}\c!before}

\protect \endinput