summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/blopentype/luatex/blot.tex
blob: c4a0a79c99e5a04e1982cb6f5e31807062f54916 (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
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
%
% blopentype: a basic luatex open type loader
%
% some (most) pitex macros still in place.- 30.12.2022
% check history after `\endinput`
% 
% User interface
%
\message{This is blopentype, v0.0.4 December 2023}

\input luatex85.sty % deprecated 30.12.2022
\input yax % which itself \input's texapi
\input gates

\setcatcodes{\@\_=11}
\suppressoutererror=1

% MESSAGES
\def\ptx@error{\senderror{PiTeX}}
\def\ptx@log#1{%
  \immediate\write17{^^J#1^^J}%
  }
\def\ptx@warn#1{%
  \ptx@log{PiTeX warning: #1}%
  }

% ATTRIBUTES
\newcount\ptx@attribute_count
\ptx@attribute_count=100 % The first 100 attributes are scratch.
\def\newattribute#1{%
  \advance\ptx@attribute_count1
  \attributedef#1=\ptx@attribute_count
  \xdefcs{ptx@attribute:\commandtoname#1}{\the\ptx@attribute_count}%
  }
\def\unsetattribute#1{#1=-"7FFFFFFF\relax}
\def\attributenumber#1{\usecs{ptx@attribute:\commandtoname#1}}

% FREEDEF
\def\freedef#1{%
  \def#1{%
    \ifnextnospace"
           {\ptx@freedef_quote#1}
           {\ifnextnospace/
             {\ptx@freedef_slash#1}
             {\usecs{ptx@freedef_user:\commandtoname#1}}}%
    }%
  \defcs{ptx@freedef_user:\commandtoname#1}##1%
  }
\def\ptx@freedef_quote#1"#2"{%
  \usecs{ptx@freedef_user:\commandtoname#1}{#2}%
  }
\def\ptx@freedef_slash#1/#2/{%
  \usecs{ptx@freedef_user:\commandtoname#1}{#2}%
  }


\newbox\ptx@box_temp

\newif\ifmaintext
\maintexttrue

% CATCODE TABLES
\newcount\ptx@catcodetable_count
\ptx@catcodetable_count=100 % First 100 are scratch.
\def\newcatcodetable#1#2{%
  \global\advance\ptx@catcodetable_count1
  \chardef#1=\ptx@catcodetable_count
  \begingroup
    \setcatcodes{#2}%
    \savecatcodetable#1%
  \endgroup
  }

\newcatcodetable\texcatcodes{\@\_=12}

\def\inputltmfile#1 {\input #1.tex }

\inputltmfile blot-lua
\inputltmfile blot-files
\inputltmfile blot-fonts
\restorecatcodes
\endinput
%
% the remaining macros are leftovers from PiTeX, awaiting removal.- 30.12.2022
%
%
\inputltmfile sections
\inputltmfile blocks
\inputltmfile references
\inputltmfile verbatim
\inputltmfile inserts
\inputltmfile output
\input navigator.tex

% AUXILIARY FILE
\iffile{\jobname.aux}{%
  \ptx@lua{%
    remove_conversion()
    tex.print("\luaescapestring{\noexpand\input\noexpand\jobname.aux}")
    }%
  \directlua{restore_conversion()}}
\immediate\openout\ptx@auxfile=\jobname.aux

% PDF SETTINGS
\restrictparameter document : author title pdftitle date pdfdate subject keywords mode layout version\par
\restrictattribute document : mode   outlines bookmarks thumbs thumbnails attachments files oc\par
\restrictattribute document : layout onepage onecolumn twopage twocolumn twopage* twocolumn*\par

\suppressoutererror=1
\let\ptx@bye\bye
\def\bye{%
  \passvalueand{\setattribute navigator : title = } document : pdftitle { }{}
  % The "date" attribute in the "document" parameter isn't supposed to hold a
  % PDF-date, as navigator expects.
  \deleteattribute document : date
  \passvalueand{\setattribute navigator : date  = } document : pdfdate { }{}
  \finishpdffile\ptx@bye
  }

\setattribute navigator : meta = document

% Turns a dimen into PostScript points, without the unit (as wanted by PDF).
\def\pdfpoint#1{%
  \directlua{%
    local d = "\the\dimexpr#1"
    d = string.gsub(d, "pt", "")
    tex.print(tostring(d * (72/72.27)))
    }}




% TEX SETTINGS
\long\def\ptx@tex_set#1#2#3{%
  \ifcs{#2}
    {\usecs{#2}=#3\relax}
    {\ptx@error{No TeX parameter `#2'}}
  }

\defactiveparameter tex {%
  \parameterloop #1 : \ptx@tex_set
  }

\frenchspacing
\maxdepth=\maxdimen

\def\antigobblespace{%
  \ifcatnext a{ }{\iffnext({ }}%
  }

\def\strut#1#2{%
  \vrule height#1 depth#2 width0pt
  }

\newdimen\extraboxspace
\newdimen\ptx@extraboxspace_top
\newdimen\ptx@extraboxspace_right
\newdimen\ptx@extraboxspace_bottom
\newdimen\ptx@extraboxspace_left

\newfornoempty\ptx@colorbox_loop{1}#2,{%
  \ifcase#1
    \ptx@extraboxspace_top    =#2
    \ptx@extraboxspace_right  =#2
    \ptx@extraboxspace_bottom =#2
    \ptx@extraboxspace_left   =#2
  \or
    \ptx@extraboxspace_right  =#2
    \ptx@extraboxspace_left   =#2
  \or
    \ptx@extraboxspace_bottom =#2
  \or
    \ptx@extraboxspace_left   =#2
  \fi
  \passarguments{\numexpr(#1+1)}%
  }
\def\colorbox{%
  \ifnextnospace[\ptx@colorbox_setborders
          {\ptx@extraboxspace_top    =\extraboxspace
           \ptx@extraboxspace_right  =\extraboxspace
           \ptx@extraboxspace_bottom =\extraboxspace
           \ptx@extraboxspace_left   =\extraboxspace
           \ptx@colorbox_do}%
  }
\def\ptx@colorbox_setborders[#1]{%
  \ptx@colorbox_loop{0}{#1,}%
  \ptx@colorbox_do
  }
{\setcatcodes{pt=12}
\gdef\noPT#1pt{#1 }}
\def\ptx@colorbox_do#1#2{%
  \bgroup
  \setbox\ptx@box_temp=\hbox{#2}%
  \hbox{%
    \pdfliteral{
      q #1 rg #1 RG
      -\expandafter\noPT\the\ptx@extraboxspace_left
       \expandafter\noPT\the\dimexpr(\ht\ptx@box_temp+\ptx@extraboxspace_top)\relax
       \expandafter\noPT\the\dimexpr(\wd\ptx@box_temp+\ptx@extraboxspace_left+\ptx@extraboxspace_right)\relax
      -\expandafter\noPT\the\dimexpr(\ht\ptx@box_temp+\ptx@extraboxspace_top+\dp\ptx@box_temp+\ptx@extraboxspace_bottom)\relax
      re f Q}%
    #2}%
  \egroup
  }

\def\og{\char"00AB~} \def\fg{~\char"00BB\antigobblespace}

\def\trace{\tracingcommands3 \tracingmacros2 }
\def\untrace{\tracingcommands0 \tracingmacros0 }

\restorecatcodes

\endinput

These notes are leftovers from Isambert's code: they'll be removed as 
documentation improves.- 30.12.2022

This is piTeX, a set of macros I (Paul Isambert) use to
typeset documentations for my packages (that's why it is
archived on CTAN).

Perhaps in the future, when this achieves some kind of
format-like completude, it'll be publicly announced. In the
meanwhile, a documentation exists (pitex-doc.pdf, also readable
in a text editor as pitex-doc.txt).


You can of course use those macros, but you are on your
own, and the files will probably be modified without announcement.
The file is supposed to be \input on plain TeX with LuaTeX, at least v.0.6.


The files needed are:

texapi.tex              (an independent package for programming)
yax.tex                 (an independent package for key=value interface)
gates.tex and gates.lua (an independant package for overall architecture)
navigator.tex           (an independant package for PDF features)
lua.ptx and base.ptxlua (Lua side)
files.ptx               (file management)
fonts.ptx, fonts.ptxlua and foundry-settings.lua
                        (fonts, should be independant some day; actually
                        fonts.ptxlua can be used independantly, but there is
                        no doc)
sections.ptx            (sectionning commands)
blocks.ptx              (text blocks)
references.ptx          (labels and references)
verbatim.ptx            (typesetting verbatim)
inserts.ptx             (footnotes and figures, a mess)
output.ptx              (output routine)

The file i-pitex.lua is needed only to typeset the documentation with the
Interpreter package.


Date: November 2011.

--- blopentype history

28-06-2023 fixed bug in blot-fonts.lua which affected nix systems. 
           thanks to david.carlisle for useful patch.
02-08-2023 fixed bug in blot-fonts.lua: 
           failure on files with empty extensions in font directories. 
           thanks to david.carlisle for useful patch.
07-09-2023 fixed bugs in blot-fonts.lua: 
           - quick kludge to avoid empty ligature tables
           - quick kludge to avoid missing font families/series: fallback to default font