Re: grohtml: confused about constant-width font handling

"G. Branden Robinson" <[email protected]>
Newsgroups gmane.comp.printing.groff.general
Message-ID <20260120172706.sx37op4wycpainay@illithid>
Hi Colin,

At 2026-01-20T15:20:55+0000, Colin Watson wrote:
> I'm working through some Debian packages whose tests fail with groff
> 1.24.0.rc1.  One of those is xlbiff, where there was a previous
> attempt to improve the handling of constant-width font selection in
> https://github.com/edsantiago/xlbiff/commit/e0987fbbcd2304b389f70bbedb9ab9201c8bd7f1.
> 
> My current plan is to add the following preamble to the affected
> pages:
> 
>   .ie n .ds CR R
>   .el .ds CR CR

The name "CR" is a groffism, but you probably knew that.  (There are no
portable font names in AT&T troff.)  Just making full disclosure.
> 
> ... and then just use `.ft \*(CR` in each of the places where it
> currently has a conditional.  This seems to work fine for utf8, ps,
> and pdf output.

Yup.  Go for it!

> However, when I tested with -Thtml I found that the expected <pre> or <tt>
> tag was missing.  I don't exactly remember how this works, so I poked around
> in src/devices/grohtml/post-html.cpp and found this:
> 
>   void html_printer::start_font (const char *fontname)
>   {
>     assert(fontname != 0 /* nullptr */);
>     [...]
>     } else if (strcmp(fontname, "CR") == 0) {
>       if ((! fill_on)
>           && is_courier_until_eol()
>           && is_line_start(! fill_on)) {
>         current_paragraph->do_pre();
>       }
>       current_paragraph->do_tt();
>     [...]
>     }
>   }
> 
> So that should work, right?  CR is meant to turn into a <pre> or <tt>
> tag depending on the context.  But even with current git master, it
> doesn't seem to:
> 
>   $ cat t.1
>   .TH T 1
>   .SH NAME
>   t \- a test
>   .SH DESCRIPTION
>   .ft CR
>   constant-width text
>   $ ./test-groff -ww -man -Thtml t.1
>   [...]
>   <p style="margin-left:6%; margin-top: 1em">constant-width
>   text</p>
> 
> So there's no warning, but also no actual constant-width output.  Am I
> holding it wrong somehow, or is this broken?

Nope.  It's broken.

I don't see a Savannah ticket for this, but I recall complaining
exasperatedly to this list[1] (or maybe to some Savannah ticket that
_does_ exist) about grohtml's crude technique of employing <pre>
sometimes, when that implies too much (more than a change of typeface),
and failing to switch the typeface at all at other times.

Regards,
Branden

[1] I'd search, but Web connections to lists.gnu.org/archive are once
    again timing out for me.
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEh3PWHWjjDgcrENwa0Z6cfXEmbc4FAmlvuuMACgkQ0Z6cfXEm
bc5fdw/8DYtk2hF5zkNZ7l755wTqIoG5FrvsQojk4pyEH8U9FSPlCTXaTSW/pWjv
VW6kHr1we1yUWMS/9be7qNuQ11YDrKE7iofd/XzCFR7/43QARFH2dKt6c+P3US0N
d+xxOsX/AxzzRZkjFsrFpzUD/EY5vWysJ2fDUQQ20fIWNSkCb3Ovy6oKNiWO7M/C
2+lOgdbgxE5wRtdiKq0wYd05VU9JMHSKOX2jNyP3alWFEWgr9Y/QLo8GzjbYxhH3
95YHQSk+W6heqW/OEBweMNJkXIUG2nwnq4AP6CVtqJvWwEohMKhEfcKsSwATwjsE
t/3EyeVdGdG25/iqqUg/uvLAhCSCiplbl0TJn+AtkcFKLmeZip5IAH+5v0iwjRax
rVbvQkCF3NGoxrwUR2fR3pPV56A3jYOjstBOJ/hhVZrRq3pak+cyIlqsbhrW0Nml
T46MpKcnLBZe9ybAhkrCWXbLN6dnVJoebiwjZ82HiSHLTMjAXOLPUP3+VI3D+7bk
q1T2hCIfVy2POtUIQCVfYYiR/9aPAZkP/bJzin4mvlPwnMR5ivw2E0VeUXxjo0ff
yzZ0SQbbBQGAYsyrJZCQsKWSFpn8lcNnpRg5jdeYGui3RrAkN+djXBPIQmXjQrmZ
hk8KQ5d2u3I8olDj12HvSpEMvECLzW6+0ZsBSeATMx3ikGLjmXs=
=T8HQ
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.