4 /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
5 Written by James Clark (jjc@jclark.com)
7 This file is part of groff.
9 groff is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 2, or (at your option) any later
14 groff is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 You should have received a copy of the GNU General Public License along
20 with groff; see the file COPYING. If not, write to the Free Software
21 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
26 #define STRING_FORMAT PREFIX "str%d"
28 #define SPECIAL_STRING "0s"
29 #define SPECIAL_WIDTH_REG "0w"
30 #define SPECIAL_HEIGHT_REG "0h"
31 #define SPECIAL_DEPTH_REG "0d"
32 #define SPECIAL_SUB_KERN_REG "0skern"
33 #define SPECIAL_SKEW_REG "0skew"
39 .ds 0s \Z'\\*[0s]'\v'\\n(0du'\D'l \\n(0wu -\\n(0hu-\\n(0du'\v'\\n(0hu'
42 define cancel 'special Cl'
47 class special_box
: public pointer_box
{
50 special_box(char *, box
*);
52 int compute_metrics(int);
53 void compute_subscript_kern();
59 box
*make_special_box(char *s
, box
*p
)
61 return new special_box(s
, p
);
64 special_box::special_box(char *s
, box
*pp
) : pointer_box(pp
), macro_name(s
)
68 special_box::~special_box()
73 int special_box::compute_metrics(int style
)
75 int r
= p
->compute_metrics(style
);
76 p
->compute_subscript_kern();
78 printf(".ds " SPECIAL_STRING
" \"");
81 printf(".nr " SPECIAL_WIDTH_REG
" 0\\n[" WIDTH_FORMAT
"]\n", p
->uid
);
82 printf(".nr " SPECIAL_HEIGHT_REG
" \\n[" HEIGHT_FORMAT
"]\n", p
->uid
);
83 printf(".nr " SPECIAL_DEPTH_REG
" \\n[" DEPTH_FORMAT
"]\n", p
->uid
);
84 printf(".nr " SPECIAL_SUB_KERN_REG
" \\n[" SUB_KERN_FORMAT
"]\n", p
->uid
);
85 printf(".nr " SPECIAL_SKEW_REG
" 0\\n[" SKEW_FORMAT
"]\n", p
->uid
);
86 printf(".%s\n", macro_name
);
87 printf(".rn " SPECIAL_STRING
" " STRING_FORMAT
"\n", uid
);
88 printf(".nr " WIDTH_FORMAT
" 0\\n[" SPECIAL_WIDTH_REG
"]\n", uid
);
89 printf(".nr " HEIGHT_FORMAT
" 0>?\\n[" SPECIAL_HEIGHT_REG
"]\n", uid
);
90 printf(".nr " DEPTH_FORMAT
" 0>?\\n[" SPECIAL_DEPTH_REG
"]\n", uid
);
91 printf(".nr " SUB_KERN_FORMAT
" 0>?\\n[" SPECIAL_SUB_KERN_REG
"]\n", uid
);
92 printf(".nr " SKEW_FORMAT
" 0\\n[" SPECIAL_SKEW_REG
"]\n", uid
);
93 // User will have to change MARK_REG if appropriate.
97 void special_box::compute_subscript_kern()
99 // Already computed in compute_metrics(), so do nothing.
102 void special_box::compute_skew()
104 // Already computed in compute_metrics(), so do nothing.
107 void special_box::output()
109 printf("\\*[" STRING_FORMAT
"]", uid
);
112 void special_box::debug_print()
114 fprintf(stderr
, "special %s { ", macro_name
);
116 fprintf(stderr
, " }");