bugGNU roff - Bugs: bug #59522, .fam request can (wrongly?) bypass...

 
 

bug #59522: .fam request can (wrongly?) bypass .ftr font remapping

Submitter:  Bjarni Ingi Gislason <bjarniig>
Submitted:  Mon 23 Nov 2020 09:41:30 PM UTC
   
 
Category:  Core Severity:  3 - Normal
Item Group:  Warning/Suspicious behaviour Status:  Fixed
Privacy:  Public Assigned to:  gbranden
Open/Closed:  Closed Planned Release:  1.23.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 14 Feb 2022 01:23:25 PM UTC, comment #2: 

It turns out I fixed this last September.


commit d8cb8cf9d833b0a6afe525d11dc6a5ce242d1355
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Wed Sep 15 14:49:58 2021 +1000

    [troff]: Give font diagnostics more context.

    [troff]: Lift font mounting diagnostic messages to be closer to their
    user-controlled contexts to provide more information.  In many cases no
    diagnostic was being thrown at all when an unavailable font was
    requested by name, which is the method most users prefer, and which
    meant that failures resulting from typos in font names for many requests
    (`uf`, `fschar`, `rfschar`, `special`, `fspecial`, `fzoom`, `bd`, `tkf`,
    `cs`) were going unreported.  Also, these font warnings are promoted to
    errors because the request will utterly fail to do what was requested
    with no reasonable fallback.  Possibly, they were warnings in the first
    place because they could also be thrown regarding unavailable fonts
    encountered in device description files, and while that's bad news, it
    results in no formatting problems if it doesn't affect fonts that an
    input document actually uses; thus, a mere warning is appropriate.

    * src/roff/troff/node.cpp (struct font_lookup_info): New struct keeps
      the font name or position requested, and the position of successful
      font lookup.

      (font_lookup_info::font_lookup_info): Add constructor.

      (font_lookup_error): New function builds error message using a
      `font_lookup_info` struct and a message argument.

      (get_fontno): Rename to...

      (has_font): ...this.  Add argument to take a pointer to a
      `font_lookup_info` struct.  Return a `bool` indicating whether the
      lookup succeeded.  Place former `int` return value into the struct
      instead.  Populate the other struct members with the requested font
      name or position, as appropriate.

      (mount_font_no_translate): Stop throwing warning diagnostic here if a
      font cannot be loaded.  Instead, throw them...

      (font_position): ...here, and...

      (underline_font, define_font_special_character,
      remove_font_special_character, read_special_fonts,
      font_special_request, font_zoom_request, bold_font, track_kern,
      constant_space): ...here, using `font_lookup_info` structs and
      `has_font()`.

      (remove_font_special_character): Stop returning early if font lookup
      fails; it's gratuitously inconsistent with other similar functions
      (save one, which has a reason to be different).

      (define_font_special_character): Return early if font lookup fails and
      say why in a comment (we can't `skip_line()`).

    Input:

    .uf Z
    .uf 99
    .fschar Z \[co] COPYRIGHT
    .fschar 99 \[co] COPYRIGHT
    .rfschar Z \[co]
    .rfschar 99 \[co]
    .special Y
    .special 98
    .fspecial Z Y
    .fspecial 99 Y
    .fzoom Z
    .fzoom 99
    .bd Z 3
    .bd 99 3
    .bd S Z 3
    .bd S 99 3
    .bd 98 Z 3
    .bd 98 99 3
    .tkf Z
    .tkf 99
    .cs Z
    .cs 99

    groff 1.22.4 diagnostics:

    troff: ...:1: warning: can't find font 'Z'
    troff: ...:2: bad font number
    troff: ...:4: bad font number
    troff: ...:6: bad font number
    troff: ...:7: warning: can't find font 'Y'
    troff: ...:8: bad font number
    troff: ...:10: bad font number
    troff: ...:12: bad font number
    troff: ...:14: bad font number
    troff: ...:17: bad font number
    troff: ...:18: bad font number
    troff: ...:20: bad font number
    troff: ...:22: bad font number

    groff 1.23.0 diagnostics:

    troff: ...:1: error: cannot load font 'Z' to make it the underline font
    troff: ...:2: error: cannot load font at position 99 to make it the underline font
    troff: ...:3: error: cannot load font 'Z' to define font-specific fallback glyph
    troff: ...:4: error: cannot load font at position 99 to define font-specific fallback glyph
    troff: ...:5: error: cannot load font 'Z' to remove font-specific fallback glyph
    troff: ...:6: error: cannot load font at position 99 to remove font-specific fallback glyph
    troff: ...:7: error: cannot load font 'Y' to mark it as special
    troff: ...:8: error: cannot load font at position 98 to mark it as special
    troff: ...:9: error: cannot load font 'Z' to mark other fonts as special contingently upon it
    troff: ...:10: error: cannot load font at position 99 to mark other fonts as special contingently upon it
    troff: ...:11: error: cannot load font 'Z' to set a zoom factor for it
    troff: ...:12: error: cannot load font at position 99 to set a zoom factor for it
    troff: ...:13: error: cannot load font 'Z' for emboldening
    troff: ...:14: error: cannot load font at position 99 for emboldening
    troff: ...:15: error: cannot load font 'Z' for conditional emboldening
    troff: ...:16: error: cannot load font at position 99 for conditional emboldening
    troff: ...:17: error: cannot load font at position 98 for emboldening
    troff: ...:18: error: cannot load font at position 98 for emboldening
    troff: ...:19: error: cannot load font 'Z' for track kerning
    troff: ...:20: error: cannot load font at position 99 for track kerning
    troff: ...:21: error: cannot load font 'Z' for constant spacing
    troff: ...:22: error: cannot load font at position 99 for constant spacing


I believe the relevant portion to be this:


      (mount_font_no_translate): Stop throwing warning diagnostic here if a
      font cannot be loaded.  Instead, throw them...

      (font_position): ...here, and...

      (underline_font, define_font_special_character,
      remove_font_special_character, read_special_fonts,
      font_special_request, font_zoom_request, bold_font, track_kern,
      constant_space): ...here, using `font_lookup_info` structs and
      `has_font()`.


G. Branden Robinson <gbranden>
Group administrator
Thu 06 May 2021 03:10:19 AM UTC, comment #1: 

I later found this problem independently, and tracked it down to the troff core.  Here's my comment from bug #60530, which I'll be closing as a duplicate.

This doesn't make sense to me; it sure feels wrong.

I added a debugging statement to dvi.tmac to make sure the remapping code was getting run (there's no in-language way to query the font remapping table, apparently), and ran the following.


    $ grep 'ftr CR' tmac/dvi.tmac
    .ftr CR CW
    $ cat EXPERIMENTS/60530.trf
    .if !'\*[.T]'dvi' .ab process me with -Tdvi
    .fam C
    fixed-pitch text
    $ ./build/test-groff -b -ww -Tdvi -z EXPERIMENTS/60530.trf
    dvi.tmac: debug: remapping DVI fonts
    troff: backtrace: file 'EXPERIMENTS/60530.trf':2
    troff: EXPERIMENTS/60530.trf:2: warning: can't find font 'CR'


Can someone confirm that this smells like a bug, or justify this behavior sufficiently clearly that I can explain it in our documentation, and offer a workaround?

G. Branden Robinson <gbranden>
Group administrator
Mon 23 Nov 2020 09:41:30 PM UTC, original submission:  

tmac/an-ext.tmac: can't find font 'CR' for a dvi-device

  Found with "test-groff -Tdvi -man groff_char.7.man".

  A simpler test is "groff -Tdvi -fC /dev/null"

  A font file 'CR' is not in the "font/devdvi" directory,
but 'CW' is.

  The macro 'EX' has these lines:
.verbatim+
.\" Start example.
.de EX
.  do ds mF \\n[.fam]
.  nr mE \\n(.f
.  nr sP \\n(PD \" Save paragraph distance.
.  nr PD 1v
.  nf
.  nh
.  do fam C
.  ft CW
..
-verbatim-

  A simple work around fix is to create a link from 'CR' to 'CW' in the
directory "font/devdvi",
and add 'CR' to the ".gitignore" file.

  It looks like that the ".fam" request looks for an 'R' style font,
here 'CR', and does not find any.

  That does not affect the result of ".ft CW"; meaning "troff" outputs
for example:

x font 17 CW

Bjarni Ingi Gislason <bjarniig>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gbranden (Posted a comment)
  • -email is unavailable- added by bjarniig (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-02-14 gbranden StatusNeed Info Fixed
        Assigned toNone gbranden
        Open/ClosedOpen Closed
        Planned ReleaseNone 1.23.0
    2021-05-06 gbranden CategoryMacro man Core
        StatusNone Need Info
        Summaryan-ext.tmac: can't find font 'CR' for a dvi-device .fam request can (wrongly?) bypass .ftr font remapping

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code