2 * Copyright (c) 2014 - 2015 Steffen (Daode) Nurpmeso <sdaoden@users.sf.net>.
4 * Copyright (C) 1989 - 1992, 2007 Free Software Foundation, Inc.
5 * Written by James Clark (jjc@jclark.com)
7 * This is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2, or (at your option) any later
12 * This is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * You should have received a copy of the GNU General Public License along
18 * with groff; see the file COPYING. If not, write to the Free Software
19 * Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
23 #include "eqn-config.h"
28 #define STRING_FORMAT PREFIX "str%d"
30 #define SPECIAL_STRING "0s"
31 #define SPECIAL_WIDTH_REG "0w"
32 #define SPECIAL_HEIGHT_REG "0h"
33 #define SPECIAL_DEPTH_REG "0d"
34 #define SPECIAL_SUB_KERN_REG "0skern"
35 #define SPECIAL_SKEW_REG "0skew"
41 .ds 0s \Z'\\*[0s]'\v'\\n(0du'\D'l \\n(0wu -\\n(0hu-\\n(0du'\v'\\n(0hu'
44 define cancel 'special Cl'
54 special_box(char *, box
*);
56 int compute_metrics(int);
57 void compute_subscript_kern();
63 box
*make_special_box(char *s
, box
*p
)
65 return new special_box(s
, p
);
68 special_box::special_box(char *s
, box
*pp
) : pointer_box(pp
), macro_name(s
)
72 special_box::~special_box()
77 int special_box::compute_metrics(int style
)
79 int r
= p
->compute_metrics(style
);
80 p
->compute_subscript_kern();
82 printf(".ds " SPECIAL_STRING
" \"");
85 printf(".nr " SPECIAL_WIDTH_REG
" 0\\n[" WIDTH_FORMAT
"]\n", p
->uid
);
86 printf(".nr " SPECIAL_HEIGHT_REG
" \\n[" HEIGHT_FORMAT
"]\n", p
->uid
);
87 printf(".nr " SPECIAL_DEPTH_REG
" \\n[" DEPTH_FORMAT
"]\n", p
->uid
);
88 printf(".nr " SPECIAL_SUB_KERN_REG
" \\n[" SUB_KERN_FORMAT
"]\n", p
->uid
);
89 printf(".nr " SPECIAL_SKEW_REG
" 0\\n[" SKEW_FORMAT
"]\n", p
->uid
);
90 printf(".%s\n", macro_name
);
91 printf(".rn " SPECIAL_STRING
" " STRING_FORMAT
"\n", uid
);
92 printf(".nr " WIDTH_FORMAT
" 0\\n[" SPECIAL_WIDTH_REG
"]\n", uid
);
93 printf(".nr " HEIGHT_FORMAT
" 0>?\\n[" SPECIAL_HEIGHT_REG
"]\n", uid
);
94 printf(".nr " DEPTH_FORMAT
" 0>?\\n[" SPECIAL_DEPTH_REG
"]\n", uid
);
95 printf(".nr " SUB_KERN_FORMAT
" 0>?\\n[" SPECIAL_SUB_KERN_REG
"]\n", uid
);
96 printf(".nr " SKEW_FORMAT
" 0\\n[" SPECIAL_SKEW_REG
"]\n", uid
);
97 // User will have to change MARK_REG if appropriate.
101 void special_box::compute_subscript_kern()
103 // Already computed in compute_metrics(), so do nothing.
106 void special_box::compute_skew()
108 // Already computed in compute_metrics(), so do nothing.
111 void special_box::output()
113 if (output_format
== troff
)
114 printf("\\*[" STRING_FORMAT
"]", uid
);
115 else if (output_format
== mathml
)
116 printf("<merror>eqn specials cannot be expressed in MathML</merror>");
119 void special_box::debug_print()
121 fprintf(stderr
, "special %s { ", macro_name
);
123 fprintf(stderr
, " }");