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 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472
|
##
## wml::des::typography - Typography
## Copyright (c) 1997-2001 Ralf S. Engelschall, All Rights Reserved.
##
# The <preserve>/<restore> tags with multiple arguments require WML 2.0.3
#use wml::mod::version
<require 2.0.3 />
#use wml::std::tags
#use wml::des::imgdot
#use wml::des::gfont
#use wml::des::space
#use wml::fmt::verbatim
#
# typographical paragraph skip (ps)
# [german variant: *D*urch*S*chu (ds)]
#
<define-tag ps>
<br />
<imgdot height=<or %0 4 /> /><br />
</define-tag>
<let ds=ps />
#
# typographical paragraph indention (pi)
# [german variant: *Ein*rckung (ein)]
#
<define-tag pi>
<br />
<imgdot height=16 width=<or %0 40 /> />
</define-tag>
<let ein=pi />
#
# big letter
#
<define-tag big>
<gfont face="ps:ptmb8r" size=+4 align=left crop>%0</gfont>
</define-tag>
#
# Spaced Paragraph
# [german variant: Gesperrt]
#
<define-tag spaced endtag=required>
<preserve interchar interline />
<set-var %attributes />
<perl>
{
my $n_char = qq|<get-var interchar />|;
my $n_line = qq|<get-var interline />|;
my $base = qq|<or <get-var IMGDOT_BASE /> <get-var IMAGE_BASE /> />|;
my $format = qq|<or <get-var IMAGE_FORMAT /> gif />|;
<perl:assign:sq $body>%body</perl:assign:sq>
$n_char = 0 if ($n_char eq '' or $n_char < 0);
$n_line = 0 if ($n_line eq '' or $n_line < 0);
my $pad_char = '';
if ($n_char > 0) {
$pad_char = ' ' x $n_char;
}
my $pad_line = '';
if ($n_line > 0) {
$n_line += 14; # 14 pt is the average text width
my $file = &imgdot($base, 1, 1, 'transp-ffffff', 255, 255, 255, 1, $format);
$pad_line = '<*img src="'.$file.'" width=1 height='.$n_line.' alt="">';
}
my $cnt = 0;
my $every = int(5 / ($n_char+1));
$every = 1 if ($every < 1);
while ($body) {
if ($body =~ s|^(</?[a-zA-Z]+[^>]*>)||s) {
<perl:print: $1 />
}
elsif ($body =~ s|^([^<\s]+)||s) {
$word = $1;
$word =~ s|\G(.)|$1$pad_char|sg;
<perl:print: $word />
if (($cnt++ % $every) == 0) {
<perl:print: $pad_line />
}
}
elsif ($body =~ s|^(\S+)||s) {
$word = $1;
$word =~ s|\G(.)|$1$pad_char|sg;
<perl:print: $word />
if (($cnt++ % $every) == 0) {
<perl:print: $pad_line />
}
}
elsif ($body =~ s|^(\s+)||s) {
$space = $1;
$space =~ s|\G([^\n])|$pad_char$1|sg;
<perl:print: $space />
}
}
}
</perl>
<restore interchar interline />
</define-tag>
<let gesperrt=spaced />
#
# Small Caps (sc)
# i.e. change all lower case letters to upper case but lower
# them a little bit by font size. Optionally all words can
# begin with an upper case letter
# [german variant: "Kapitlchen"]
#
<define-tag sc endtag=required>\
<preserve complete />\
<set-var complete=* />\
<set-var %attributes />\
<perl>
{
my $complete = (qq|<get-var complete />| eq '' ? 1 : 0);
<perl:assign:sq $body>%body</perl:assign:sq>
$body =~ s|\n$||s;
use locale;
sub convword {
my ($w) = @_;
# optionally make all words start with an upper case letter
$w = uc(substr($w, 0, 1)).substr($w, 1) if ($complete);
# convert lower case chars to upper case
my $c;
my @C = split('', $w);
my $makeupper = 0;
$w = '';
foreach $c (@C) {
if (not $makeupper and $c eq lc($c)) {
$w .= '<*font size="-1">'.uc($c);
$makeupper = 1;
}
elsif ($makeupper and $c ne lc($c)) {
$w .= '<*/font>'.$c;
$makeupper = 0;
}
elsif ($makeupper and $c eq lc($c)) {
$w .= uc($c);
}
else {
$w .= $c;
}
}
$w .= '<*/font>' if ($makeupper);
return $w;
}
my $text = '';
while ($body ne '') {
if ($body =~ m|^([^<]+)(<[/a-zA-Z].*?>)(.*)$|) {
my $words = $1;
my $rest = $2;
$body = $3;
$words =~ s|(\w+)|&convword($1)|sge;
$text .= $words . $rest;
}
elsif ($body =~ m|^(<[/a-zA-Z].*?>)(.*)$|) {
$text .= $1;
$body = $2;
}
else {
$body =~ s|(\w+)|&convword($1)|sge;
$text .= $body;
$body = '';
}
}
<perl:print: $text />
}
</perl>\
<restore complete />\
</define-tag>
<let csc=sc />
#
# Verbatim Code Text
#
<define-tag verbcode endtag=required>
<p*>
<over 30>
<b><verbatim>%body</verbatim></b>
</over>
</define-tag>
#
# Headline
# [german variant: "berschrift"]
#
<define-tag headline endtag=required>
<if %0 "<a* name="%0">" />\
<font face="Arial,Helvetica" size=+4><b>%body</b></font>\
<if %0 "</a*>" />
<ds 5 />\
</define-tag>
<let ue=headline />
#
# Sub Headline
# [german variant: "Zwischenberschrift"]
#
<define-tag subheadline endtag=required>
<if %0 "<a* name="%0">" />\
<font face="Arial,Helvetica" size=+2><b>%body</b></font>
<if %0 "</a*>" />
<ds 2 />\
</define-tag>
<let zwue=subheadline />
#
# Emulation of the <ul>...</ul> environment in
# a more typographically strong layout.
#
<define-tag tul endtag=required>
<preserve ps pi />
<set-var %attributes />
<defvar pi 30 />
<ps <get-var ps /> />
<table cellspacing=0 cellpadding=0 border=$(DEBUG:-0) summary="">
<tr>
<td valign=top><imgdot height=1 width=<get-var pi /> /></td><suck/>
<td valign=top><imgdot height=1 width=<get-var pi /> /><suck/>
%body<suck/>
</td>
</tr>
</table>
<restore ps pi />
</define-tag>
<define-tag tli endtag=required>
<preserve pshape pcolor />
<set-var %attributes />
<defvar pshape box />
<defvar pcolor "#cccccc" />
<ps <get-var ps /> />
</td*>\
</tr*>
<tr*>\
<td valign=top align=right>\
<ifeq "<get-var pshape />" "box"
<imgdot color="<get-var pcolor />" height=10 width=10 />
"<font color="<get-var pcolor />">-</font>" />\
\
</td>\
<td*>
%body
<restore pshape pcolor />
</define-tag>
#
# the ``#use ... face_shortcuts'' support
#
<if "$(face_shortcuts)" <group
{: [[s/(face=)"?helvetica"?/face="Arial,Helvetica"/ig]]
{#TYPOGRAPHY_FACE_SHORTCUTS#}
:}
{#TYPOGRAPHY_FACE_SHORTCUTS#:
/>/>
##EOF##
__END__
=encoding latin1
=head1 NAME
wml::des::typography - Typography
=head1 SYNOPSIS
#use wml::des::typography [face_shortcuts]
# paragraph whitespace
<ps [height]>
(<ds [height]>)
<pi [width]>
(<ein [width]>)
# paragraph text rendering
<big X>
<sc [complete]>...</sc>
<csc>...</csc>
<spaced [interchar=N] [interline=N]>...</spaced>
<verbcode>...</verbcode>
# headlines
<headline [name]>...</headline>
(<ue [name]>...</ue>)
<subheadline [name]>...</subheadline>
(<zwue [name]>...</zwue>)
# unsorted lists
<tul [ps=N] [pi=N]>
<tli [pshape=dash|box] [pcolor=#rrggbb]>...</tli>
...
</tul>
=head1 DESCRIPTION
This include file provides tags for more typographically strong layouting then
HTML per default provides. The following tags are provided:
=over 4
=item B<Typographical Paragraph Skip>
B<C<E<lt>ps >>[I<height>]B<C<E<gt>>>
This is the typographical way to insert a
blank line between two paragraphs. It is not as high as the one generated by
HTML's C<E<lt>pE<gt>> tag. Default is 4 pixels for I<height>. Optically and
functionally C<E<lt>psE<gt>> is between C<E<lt>brE<gt>> and C<E<lt>pE<gt>>.
In german this is called "Durchschuss", so you can also use the alterntive name
C<E<lt>dsE<gt>> for this tag.
...The last line of the previous paragraph.
<ps>
The new line of the following paragraph...
=item B<Typographical Paragraph Indention>
B<C<E<lt>pi >>[I<width>]B<C<E<gt>>>
This is the typographical way to glue
paragraphs which should become one optical block. A complete blank line
between them would be ugly and without any inserts the reader cannot
distinguish between the two paragraphs. The typographical solution here is to
indent the second paragraph by I<width> pixels. The default is 40 pixels.
Optically C<E<lt>piE<gt>> also includes the effect of C<E<lt>psE<gt>>. In
german this is called `Einrckung', so you can also use the alterntive name
C<E<lt>einE<gt>> for this tag.
Example:
...The last line of the previous paragraph.
<pi>The new line of the following paragraph...
=item B<Big Paragraph Starting Letter>
B<C<E<lt>big >>I<X>B<C<E<gt>>>
This is the typographical way to mark the
beginning of a more important paragraph by rendering the first letter of the
first word of this paragraph in huge font. Optically this letter then is
approximately three times bigger then the normal text font. Additionally the
B<alt> attribute of the used C<E<lt>imgE<gt>> tag is set to the letter, so
text-based browsers correctly show the first word. Because
such a paragraph should also be introduced by more whitespace, one
usually uses the standard C<E<lt>pE<gt>> tag in front of C<E<lt>bigE<gt>> to
achieve the correct optical effect.
Example:
...The last line of the previous paragraph.
<p>
<big T>he new line of the following paragraph...
=item B<Small Caps Text>
B<C<E<lt>sc >>[B<complete>]B<C<E<gt>>>...B<C<E<lt>/scE<gt>>>
This container tag renders its body with small caps, i.e.
all lower case letters are changed to upper case while lowered optically via
font size. In german typography this is also known as `Kapitlchen'.
Optionally when adding the attribute B<complete>, all words are forced to
begin with an upper case letter, too.
If you have support for i18n (internationalization) you may also convert case
of non-ASCII characters. See your local documentation locale(7) for details
or ask your system administrator.
=item B<Spaced Text>
B<C<E<lt>spaced >>[B<interchar=>I<N>] [B<interline=>I<N>]B<C<E<gt>>>...B<C<E<lt>/spacedE<gt>>>
This container tag renders its body as spaced text, i.e. text with spaces
between the lines and characters. In typpgraphy this is usually used to
emphasize the text by the use of whitespace. Per default B<interchar> and
B<interline> are 0, i.e. no spacing. The spacing is achieved by inserting as
much C< > entities as I<interchar> specifies and 1pt-images of height
14+I<interline> every fifth word. In german typography this is also known as
`Gesperrt'.
=item B<Headline>
B<C<E<lt>headline >>[I<name>]B<C<E<gt>>>...B<C<E<lt>/headlineE<gt>>>
This container tag creates a typographically better headline as
the standard HTML C<E<lt>h1E<gt>> does, i.e. it renders the text in Helvetica
and used better whitespaces around it. Actually it does not create any
whitespace above it, but the correct one below it. This way you can create the
leading whitespace your own (which is usually different according to the
context) but get nice trailing whitespace (which has to be chosen carefully
to make the headline and the following paragraph one unit). In german this is
called `berschrift' hence the alias C<E<lt>ueE<gt>>.
Example:
...The last line of the previous paragraph.
<p>
<ue>The headline</ue>
The new line of the following paragraph...
=item B<Sub-Headline>
B<C<E<lt>subheadline >>[I<name>]B<C<E<gt>>>...B<C<E<lt>/subheadlineE<gt>>>
This container tag creates a typographically better
sub-headline as the standard HTML C<E<lt>h2E<gt>> does, i.e. it renders the
text in Helvetica and used better whitespaces around it. Actually it does not
create any whitespace above it, but the correct one below it. This way you can
create the leading whitespace your own (which is usually different according
to the context) but get nice trailing whitespace (which has to be chosen
carefully to make the headline and the following paragraph one unit). In
german this is called `Zwischenberschrift' hence the alias C<E<lt>zwueE<gt>>.
Example:
...The last line of the previous paragraph.
<p>
<zwue>The headline</zwue>
The new line of the following paragraph...
=item B<Verbatim Code>
B<C<E<lt>verbcodeE<gt>>>...B<C<E<lt>/verbcodeE<gt>>>
This container tag renders its body mostly verbatim, i.e.
treats it like plain (source) code. Internally this just is an indented
C<E<lt>verbatimE<gt>> container from wml::fmt::verbatim(3) which itself is an
enhanced C<E<lt>preE<gt>> container.
=item B<Unnumbered Lists>
B<C<E<lt>tul >>[B<ps=>I<N>] [B<pi=>I<N>]B<C<E<gt>>>...B<C<E<lt>/tulE<gt>>>
This container tag displays unnumbered lists in a more typographically
strong layout, rendered via HTML tables for indentation.
B<C<E<lt>tli >>[B<pshape=>I<box>|I<dash>] [B<pcolor=>I<#rrggbb>]B<C<E<gt>>>...B<C<E<lt>/tliE<gt>>>
Items are prefixed by a box or a dash, depending on the B<pshape> attribute,
and its color may be defined.
=back
=head1 AUTHOR
Ralf S. Engelschall
rse@engelschall.com
www.engelschall.com
=head1 REQUIRES
Internal: P1, P2, P3, P8
=head1 SEE ALSO
HTML C<E<lt>fontE<gt>> and C<E<lt>brE<gt>> tags.
=cut
|