/* Copyright (C) 1989, 1990 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.uucp)
This file is part of groff.
groff is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
groff is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
You should have received a copy of the GNU General Public License along
with groff; see the file LICENSE. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
class accent_box
: public pointer_box
{
accent_box(box
*, box
*);
int compute_metrics(int);
box
*make_accent_box(box
*p
, box
*q
)
return new accent_box(p
, q
);
accent_box::accent_box(box
*pp
, box
*qq
) : ab(qq
), pointer_box(pp
)
accent_box::~accent_box()
int accent_box::compute_metrics(int style
)
int r
= p
->compute_metrics(style
);
ab
->compute_metrics(style
);
printf(".nr " WIDTH_FORMAT
" 0\\n[" WIDTH_FORMAT
"]\n", uid
, p
->uid
);
printf(".nr " DEPTH_FORMAT
" \\n[" DEPTH_FORMAT
"]\n", uid
, p
->uid
);
printf(".nr " SUP_RAISE_FORMAT
" \\n[" HEIGHT_FORMAT
"]-%dM>?0\n",
printf(".nr " HEIGHT_FORMAT
" \\n[" HEIGHT_FORMAT
"]+\\n["
void accent_box::output()
printf("\\h'\\n[" WIDTH_FORMAT
"]u-\\n[" WIDTH_FORMAT
"]u/2u+\\n["
p
->uid
, ab
->uid
, p
->uid
);
printf("\\v'-\\n[" SUP_RAISE_FORMAT
"]u'", uid
);
printf("\\h'-\\n[" WIDTH_FORMAT
"]u'", ab
->uid
);
printf("\\v'\\n[" SUP_RAISE_FORMAT
"]u'", uid
);
printf("\\h'-(\\n[" WIDTH_FORMAT
"]u-\\n[" WIDTH_FORMAT
"]u/2u+\\n["
p
->uid
, ab
->uid
, p
->uid
);
/* This version copes with the possibility of an accent's being wider
than its accentee. LEFT_WIDTH_FORMAT gives the distance from the
left edge of the resulting box to the middle of the accentee's box.*/
int accent_box::compute_metrics(int style
)
int r
= p
->compute_metrics(style
);
ab
->compute_metrics(style
);
printf(".nr " LEFT_WIDTH_FORMAT
" 0\\n[" WIDTH_FORMAT
"]/2"
">?(\\n[" WIDTH_FORMAT
"]/2-\\n[" SKEW_FORMAT
"])\n",
uid
, p
->uid
, ab
->uid
, p
->uid
);
printf(".nr " WIDTH_FORMAT
" 0\\n[" WIDTH_FORMAT
"]/2"
">?(\\n[" WIDTH_FORMAT
"]/2+\\n[" SKEW_FORMAT
"])"
"+\\n[" LEFT_WIDTH_FORMAT
"]\n",
uid
, p
->uid
, ab
->uid
, p
->uid
, uid
);
printf(".nr " DEPTH_FORMAT
" \\n[" DEPTH_FORMAT
"]\n", uid
, p
->uid
);
printf(".nr " SUP_RAISE_FORMAT
" \\n[" HEIGHT_FORMAT
"]-%dM>?0\n",
printf(".nr " HEIGHT_FORMAT
" \\n[" HEIGHT_FORMAT
"]+\\n["
printf(".nr " MARK_REG
" +\\n[" LEFT_WIDTH_FORMAT
"]"
"-(\\n[" WIDTH_FORMAT
"]/2)'\n",
void accent_box::output()
printf("\\Z" DELIMITER_CHAR
);
printf("\\h'\\n[" LEFT_WIDTH_FORMAT
"]u+\\n[" SKEW_FORMAT
"]u"
"-(\\n[" WIDTH_FORMAT
"]u/2u)'",
printf("\\v'-\\n[" SUP_RAISE_FORMAT
"]u'", uid
);
printf("\\Z" DELIMITER_CHAR
);
printf("\\h'\\n[" LEFT_WIDTH_FORMAT
"]u-(\\n[" WIDTH_FORMAT
"]u/2u)'",
printf("\\h'\\n[" WIDTH_FORMAT
"]u'", uid
);
void accent_box::check_tabs(int level
)
ab
->check_tabs(level
+ 1);
p
->check_tabs(level
+ 1);
void accent_box::debug_print()
fprintf(stderr
, " } accent { ");
class overline_char_box
: public simple_box
{
overline_char_box::overline_char_box()
void overline_char_box::output()
printf("\\v'-%dM/2u-%dM'", 7*default_rule_thickness
, x_height
);
printf((draw_flag
? "\\D'l%dM 0'" : "\\l'%dM\\&\\(ru'"),
printf("\\v'%dM/2u+%dM'", 7*default_rule_thickness
, x_height
);
void overline_char_box::debug_print()
fprintf(stderr
, "<overline char>");
class overline_box
: public pointer_box
{
int compute_metrics(int);
box
*make_overline_box(box
*p
)
return new accent_box(p
, new overline_char_box
);
return new overline_box(p
);
overline_box::overline_box(box
*pp
) : pointer_box(pp
)
int overline_box::compute_metrics(int style
)
int r
= p
->compute_metrics(cramped_style(style
));
printf(".nr " HEIGHT_FORMAT
" \\n[" HEIGHT_FORMAT
"]+%dM\n",
uid
, p
->uid
, default_rule_thickness
*5);
printf(".nr " WIDTH_FORMAT
" 0\\n[" WIDTH_FORMAT
"]\n", uid
, p
->uid
);
printf(".nr " DEPTH_FORMAT
" \\n[" DEPTH_FORMAT
"]\n", uid
, p
->uid
);
void overline_box::output()
printf("\\Z" DELIMITER_CHAR
);
printf("\\v'-\\n[" HEIGHT_FORMAT
"]u-(%dM/2u)'",
p
->uid
, 7*default_rule_thickness
);
printf("\\D'l\\n[" WIDTH_FORMAT
"]u 0'", p
->uid
);
printf("\\l'\\n[" WIDTH_FORMAT
"]u\\&\\(ru'", p
->uid
);
void overline_box::debug_print()
fprintf(stderr
, " } bar");
class uaccent_box
: public pointer_box
{
uaccent_box(box
*, box
*);
int compute_metrics(int);
void compute_subscript_kern();
box
*make_uaccent_box(box
*p
, box
*q
)
return new uaccent_box(p
, q
);
uaccent_box::uaccent_box(box
*pp
, box
*qq
)
: pointer_box(pp
), ab(qq
)
uaccent_box::~uaccent_box()
int uaccent_box::compute_metrics(int style
)
int r
= p
->compute_metrics(style
);
ab
->compute_metrics(style
);
printf(".nr " LEFT_WIDTH_FORMAT
" 0\\n[" WIDTH_FORMAT
"]/2"
">?(\\n[" WIDTH_FORMAT
"]/2)\n",
printf(".nr " WIDTH_FORMAT
" 0\\n[" WIDTH_FORMAT
"]/2"
">?(\\n[" WIDTH_FORMAT
"]/2)"
"+\\n[" LEFT_WIDTH_FORMAT
"]\n",
uid
, p
->uid
, ab
->uid
, uid
);
printf(".nr " HEIGHT_FORMAT
" \\n[" HEIGHT_FORMAT
"]\n", uid
, p
->uid
);
printf(".nr " DEPTH_FORMAT
" \\n[" DEPTH_FORMAT
"]"
"+\\n[" DEPTH_FORMAT
"]\n",
printf(".nr " MARK_REG
" +\\n[" LEFT_WIDTH_FORMAT
"]"
"-(\\n[" WIDTH_FORMAT
"]/2)'\n",
void uaccent_box::output()
printf("\\Z" DELIMITER_CHAR
);
printf("\\h'\\n[" LEFT_WIDTH_FORMAT
"]u-(\\n[" WIDTH_FORMAT
"]u/2u)'",
printf("\\v'\\n[" DEPTH_FORMAT
"]u'", p
->uid
);
printf("\\Z" DELIMITER_CHAR
);
printf("\\h'\\n[" LEFT_WIDTH_FORMAT
"]u-(\\n[" WIDTH_FORMAT
"]u/2u)'",
printf("\\h'\\n[" WIDTH_FORMAT
"]u'", uid
);
void uaccent_box::check_tabs(int level
)
ab
->check_tabs(level
+ 1);
p
->check_tabs(level
+ 1);
void uaccent_box::compute_subscript_kern()
box::compute_subscript_kern(); // want 0 subscript kern
void uaccent_box::debug_print()
fprintf(stderr
, " } uaccent { ");
class underline_char_box
: public simple_box
{
underline_char_box::underline_char_box()
void underline_char_box::output()
printf("\\v'%dM/2u'", 7*default_rule_thickness
);
printf((draw_flag
? "\\D'l%dM 0'" : "\\l'%dM\\&\\(ru'"),
printf("\\v'-%dM/2u'", 7*default_rule_thickness
);
void underline_char_box::debug_print()
fprintf(stderr
, "<underline char>");
class underline_box
: public pointer_box
{
int compute_metrics(int);
void compute_subscript_kern();
box
*make_underline_box(box
*p
)
return new uaccent_box(p
, new underline_char_box
);
return new underline_box(p
);
underline_box::underline_box(box
*pp
) : pointer_box(pp
)
int underline_box::compute_metrics(int style
)
int r
= p
->compute_metrics(style
);
printf(".nr " DEPTH_FORMAT
" \\n[" DEPTH_FORMAT
"]+%dM\n",
uid
, p
->uid
, default_rule_thickness
*5);
printf(".nr " WIDTH_FORMAT
" 0\\n[" WIDTH_FORMAT
"]\n", uid
, p
->uid
);
printf(".nr " HEIGHT_FORMAT
" \\n[" HEIGHT_FORMAT
"]\n", uid
, p
->uid
);
void underline_box::output()
printf("\\Z" DELIMITER_CHAR
);
printf("\\v'\\n[" DEPTH_FORMAT
"]u+(%dM/2u)'",
p
->uid
, 7*default_rule_thickness
);
printf("\\D'l\\n[" WIDTH_FORMAT
"]u 0'", p
->uid
);
printf("\\l'\\n[" WIDTH_FORMAT
"]u\\&\\(ru'", p
->uid
);
// we want an underline box to have 0 subscript kern
void underline_box::compute_subscript_kern()
box::compute_subscript_kern();
void underline_box::debug_print()
fprintf(stderr
, " } under");
size_box::size_box(char *s
, box
*pp
) : size(s
), pointer_box(pp
)
int size_box::compute_metrics(int style
)
printf(".nr " SIZE_FORMAT
" \\n[.s]\n", uid
);
printf(".ps %s\n", size
);
printf(".nr " SMALL_SIZE_FORMAT
" \\n[.s]\n", uid
);
int r
= p
->compute_metrics(style
);
printf(".ps \\n[" SIZE_FORMAT
"]\n", uid
);
printf(".nr " WIDTH_FORMAT
" 0\\n[" WIDTH_FORMAT
"]\n", uid
, p
->uid
);
printf(".nr " HEIGHT_FORMAT
" \\n[" HEIGHT_FORMAT
"]\n", uid
, p
->uid
);
printf(".nr " DEPTH_FORMAT
" \\n[" DEPTH_FORMAT
"]\n", uid
, p
->uid
);
printf("\\s[\\n[" SMALL_SIZE_FORMAT
"]]", uid
);
printf("\\s[\\n[" SIZE_FORMAT
"]]", uid
);
void size_box::debug_print()
fprintf(stderr
, "size %s { ", size
);
font_box::font_box(char *s
, box
*pp
) : pointer_box(pp
), f(s
)
int font_box::compute_metrics(int style
)
const char *old_roman_font
= current_roman_font
;
printf(".nr " FONT_FORMAT
" \\n[.f]\n", uid
);
int r
= p
->compute_metrics(style
);
current_roman_font
= old_roman_font
;
printf(".ft \\n[" FONT_FORMAT
"]\n", uid
);
printf(".nr " WIDTH_FORMAT
" 0\\n[" WIDTH_FORMAT
"]\n", uid
, p
->uid
);
printf(".nr " HEIGHT_FORMAT
" \\n[" HEIGHT_FORMAT
"]\n", uid
, p
->uid
);
printf(".nr " DEPTH_FORMAT
" \\n[" DEPTH_FORMAT
"]\n", uid
, p
->uid
);
const char *old_roman_font
= current_roman_font
;
current_roman_font
= old_roman_font
;
printf("\\f[\\n[" FONT_FORMAT
"]]", uid
);
void font_box::debug_print()
fprintf(stderr
, "font %s { ", f
);
fat_box::fat_box(box
*pp
) : pointer_box(pp
)
int fat_box::compute_metrics(int style
)
int r
= p
->compute_metrics(style
);
printf(".nr " WIDTH_FORMAT
" 0\\n[" WIDTH_FORMAT
"]+%dM\n",
uid
, p
->uid
, fat_offset
);
printf(".nr " HEIGHT_FORMAT
" \\n[" HEIGHT_FORMAT
"]\n", uid
, p
->uid
);
printf(".nr " DEPTH_FORMAT
" \\n[" DEPTH_FORMAT
"]\n", uid
, p
->uid
);
printf("\\h'-\\n[" WIDTH_FORMAT
"]u'", p
->uid
);
printf("\\h'%dM'", fat_offset
);
void fat_box::debug_print()
fprintf(stderr
, "fat { ");
vmotion_box::vmotion_box(int i
, box
*pp
) : n(i
), pointer_box(pp
)
int vmotion_box::compute_metrics(int style
)
int r
= p
->compute_metrics(style
);
printf(".nr " WIDTH_FORMAT
" 0\\n[" WIDTH_FORMAT
"]\n", uid
, p
->uid
);
printf(".nr " HEIGHT_FORMAT
" %dM+\\n[" HEIGHT_FORMAT
"]\n",
printf(".nr " DEPTH_FORMAT
" \\n[" DEPTH_FORMAT
"]\n", uid
, p
->uid
);
printf(".nr " DEPTH_FORMAT
" %dM+\\n[" DEPTH_FORMAT
"]>?0\n",
printf(".nr " HEIGHT_FORMAT
" \\n[" HEIGHT_FORMAT
"]\n",
void vmotion_box::output()
void vmotion_box::debug_print()
fprintf(stderr
, "up %d { ", n
);
fprintf(stderr
, "down %d { ", -n
);
hmotion_box::hmotion_box(int i
, box
*pp
) : n(i
), pointer_box(pp
)
int hmotion_box::compute_metrics(int style
)
int r
= p
->compute_metrics(style
);
printf(".nr " WIDTH_FORMAT
" 0\\n[" WIDTH_FORMAT
"]+%dM\n",
printf(".nr " HEIGHT_FORMAT
" \\n[" HEIGHT_FORMAT
"]\n", uid
, p
->uid
);
printf(".nr " DEPTH_FORMAT
" \\n[" DEPTH_FORMAT
"]\n", uid
, p
->uid
);
printf(".nr " MARK_REG
" +%dM\n", n
);
void hmotion_box::output()
void hmotion_box::debug_print()
fprintf(stderr
, "fwd %d { ", n
);
fprintf(stderr
, "back %d { ", -n
);
vcenter_box::vcenter_box(box
*pp
) : pointer_box(pp
)
int vcenter_box::compute_metrics(int style
)
int r
= p
->compute_metrics(style
);
printf(".nr " WIDTH_FORMAT
" 0\\n[" WIDTH_FORMAT
"]\n", uid
, p
->uid
);
printf(".nr " SUP_RAISE_FORMAT
" \\n[" DEPTH_FORMAT
"]-\\n["
HEIGHT_FORMAT
"]/2+%dM\n",
uid
, p
->uid
, p
->uid
, axis_height
);
printf(".nr " HEIGHT_FORMAT
" \\n[" HEIGHT_FORMAT
"]+\\n["
SUP_RAISE_FORMAT
"]>?0\n", uid
, p
->uid
, uid
);
printf(".nr " DEPTH_FORMAT
" \\n[" DEPTH_FORMAT
"]-\\n["
SUP_RAISE_FORMAT
"]>?0\n", uid
, p
->uid
, uid
);
void vcenter_box::output()
printf("\\v'-\\n[" SUP_RAISE_FORMAT
"]u'", uid
);
printf("\\v'\\n[" SUP_RAISE_FORMAT
"]u'", uid
);
void vcenter_box::debug_print()
fprintf(stderr
, "vcenter { ");