Bug 703187 - `makefont` problem with mirrored font
Summary: `makefont` problem with mirrored font
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Font API (show other bugs)
Version: 9.52
Hardware: PC Linux
: P4 normal
Assignee: Chris Liddell (chrisl)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-26 12:22 UTC by Werner Lemberg
Modified: 2020-12-04 09:49 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
grdemo.eps (33.50 KB, image/x-eps)
2020-11-26 12:22 UTC, Werner Lemberg
Details
gs-8.56.png (3.80 KB, image/png)
2020-11-26 12:26 UTC, Werner Lemberg
Details
gs-9.52.png (4.12 KB, image/png)
2020-11-26 12:27 UTC, Werner Lemberg
Details
Simplified sample file (4.26 KB, application/postscript)
2020-11-26 18:17 UTC, Peter Cherepanov
Details
A patch for the sample file. (1.28 KB, patch)
2020-11-27 19:58 UTC, Peter Cherepanov
Details | Diff
grdemo4.ps -- Fully simplified sample file. (241 bytes, application/postscript)
2020-11-29 08:40 UTC, Peter Cherepanov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Werner Lemberg 2020-11-26 12:22:14 UTC
Created attachment 20240 [details]
grdemo.eps

The attached file is no longer correctly rendered with gs 9.52: the left handed glyph from `ZapfDingbats-Reverse` has an incorrect horizontal offset.

For testing purposes I locally installed

  gnu-ghostscript-8.56.0.tar.bz2
  ghostscript-fonts-std-5.10.tar.gz

which gives correct results, see attached images.

Is this a bug?  Is this an incompatibility?
Comment 1 Werner Lemberg 2020-11-26 12:26:40 UTC
Created attachment 20241 [details]
gs-8.56.png
Comment 2 Werner Lemberg 2020-11-26 12:27:13 UTC
Created attachment 20242 [details]
gs-9.52.png
Comment 3 Peter Cherepanov 2020-11-26 18:17:23 UTC
Created attachment 20243 [details]
Simplified sample file

Thank you for using and testing Ghostscript. This is a bug which was introduced in v. 9.00. Two other interpreters agree with the old interpretation of the sample file.
Comment 4 Ray Johnston 2020-11-26 18:26:49 UTC
Thanks for testing, Peter.

Marking the  bug bountiable, and assigning it to Chris as most likely to have
knowledge of font issues.
Comment 5 Werner Lemberg 2020-11-26 18:33:55 UTC
Thank you for the quick confirmation.

Would it be possible to modify the PS code for `ZapfDingbats-Reverse` to detect the problem and apply a work-around so that the font works with the buggy gs versions, too?
Comment 6 Peter Cherepanov 2020-11-26 19:37:57 UTC
The easiest way to fix the sample file is to reprocess it with Ghostscript. This works fine even with new versions of Ghostscript.
~/bug/703187 $ ~/ghostpdl/debugbin/gs -sDEVICE=eps2write -o grdemo-new.eps -dEPSCrop grdemo.eps 

It is also possible to fix the sample file by hand by hacking /fshow procedure.

Porting this hack to groff is harder, because acceptance of this hack is not guaranteed.

Implementing reverse fonts as Type 3 fonts is not desirable, because Type 3 fonts make Ghostscript produce poor quality PDF files.
Comment 7 Werner Lemberg 2020-11-27 07:19:31 UTC
The very idea of creating a Type 3 font is that for historical reasons (and backward compatibility) GNU troff uses the 35 Adobe standard fonts by default, which can't be distributed together with GNU software.  In other words, groff is bound to use the Type 3 hack since those fonts lack some glyphs necessary to cover the original AT&T troff glyph set.  Having a solution that works with all gs versions would thus be really great.

For new documents the user can switch to a font that offers a proper glyph for the left-pointing hand symbol, for example.
Comment 8 Chris Liddell (chrisl) 2020-11-27 14:30:15 UTC
The problem is the values from the Metrics dictionary are going awol somewhere through the FAPI code... It's not immediately obvious to me how to solve this, since the naive solutions all seem to result in regression elsewhere. :-(


Ironically Werner, this has more than a little overlap with the Freetype issue you asked me to look at!
Comment 9 Werner Lemberg 2020-11-27 14:53:11 UTC
:-)

Is this good or bad?
Comment 10 Chris Liddell (chrisl) 2020-11-27 14:57:08 UTC
(In reply to Werner Lemberg from comment #9)
> :-)
> 
> Is this good or bad?

Too early to tell!
Comment 11 Peter Cherepanov 2020-11-27 19:58:40 UTC
Created attachment 20260 [details]
A patch for the sample file.

This is a work-around for the attached sample file that can be adapted for use in groff PostScript prologue.

For the affected revision and output device, check for -Reverse font at run time and move the current point forward by the length of the first character.
Comment 12 Peter Cherepanov 2020-11-29 08:40:22 UTC
Created attachment 20262 [details]
grdemo4.ps -- Fully simplified sample file.

The problem is caused by Ghostscript ignoring left sidebearings. This conclusion can be checked by changing the number -1000 in the sample file to any other number and observing that it does not affect the output file.
Comment 13 Ken Sharp 2020-11-29 09:11:32 UTC
Sounds like a duplicate of #694692 then.
Comment 14 Chris Liddell (chrisl) 2020-12-01 19:19:54 UTC
Here's what I have, so far:
https://git.ghostscript.com/?p=user/chrisl/ghostpdl.git;a=commitdiff;h=f0dedd007b5e


This deals with the lsb in the "glue" code between gs and freetype.

There are still a couple of PCL/PXL issues that I need to look into, but I think this is illustrative of the overall approach.

As a "happy" coincidence, this also stops the pending, promised changes I owe on Freetype from affecting us as badly as they otherwise would - again, there are one or two PCL anomalies to deal with there.
Comment 15 Chris Liddell (chrisl) 2020-12-01 19:20:35 UTC
Oh, and I forgot to say: thanks Peter for the initial checks and the cut down file, very much appreciated.
Comment 16 Werner Lemberg 2020-12-01 21:49:06 UTC
Having no idea about the gs code I can only applaud your efforts – I don't dare to say 'looks good' :-)
Comment 17 Werner Lemberg 2020-12-01 21:50:40 UTC
And thanks, Peter, for your PS sample code!  Will have to think now how to integrate this into groff – and MetaPost, which has a groff interface, too.
Comment 18 Chris Liddell (chrisl) 2020-12-04 09:49:50 UTC
Here's the fix I settled on:

https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=fb1a336ac4d2

It's (almost?) the same as the patch I posted above.

It solves this problem, and a few others in our test suite. Plus it improves a few PCL test files.