On the GhostScript installed on ps2pdf.com (which the webmaster says is 8.61 on Linux) the following code fails to run properly. But it works well on Distiller 8 (and indeed 7), and on Mac Preview. www.jdawiseman.com/papers/bugs/Broken_FontMatrix.ps (PostScript code, copied below) www.jdawiseman.com/papers/bugs/Broken_FontMatrix-distiller.pdf (output from Distiller: good) www.jdawiseman.com/papers/bugs/Broken_FontMatrix-distiller.log (log file from Distiller: good) www.jdawiseman.com/papers/bugs/Broken_FontMatrix-preview.pdf (output from Mac Preview: good) www.jdawiseman.com/papers/bugs/Broken_FontMatrix-ps2pdf.pdf (output from ps2pdf.com: some parts seemingly missing) www.jdawiseman.com/papers/bugs/Broken_FontMatrix-ps2pdf.log (log from ps2pdf.com: dropping factors of 1000) %! /FontName /Times-Roman def /FontSize 51 def FontName FontSize selectfont /CurrentFontSize {currentfont /FontMatrix get 3 get dup =} bind def /SuperscriptOn {0 CurrentFontSize 0.375 mul rmoveto FontName CurrentFontSize 1.7 div selectfont} def /SuperscriptOff {FontName CurrentFontSize 1.7 mul selectfont 0 CurrentFontSize -0.375 mul rmoveto} def 72 72 moveto (1) show SuperscriptOn (st) show SuperscriptOff (, 2) show SuperscriptOn (nd) show SuperscriptOff (, and 3) show SuperscriptOn (rd) show SuperscriptOff (.) show showpage For what little it's worth, this bug is a cut-down version of one that was discovered in the wild whilst using the PostScript at www.jdawiseman.com/papers/placemat/placemat.html This was also posted on groups.google.com/group/ gnu.ghostscript.bug/browse_thread/thread/60c0e4315a18dbbc (remove space to make URL work).
Created attachment 3717 [details] PS code that shows problem with FontMatrix
Created attachment 3718 [details] Output from Distiller: good
Created attachment 3719 [details] Log file from Distiller: good
Created attachment 3720 [details] Output from Preview 4.0 (469) on Mac OS 10.5.1
Created attachment 3721 [details] Output from GhostScript: parts shrunk to near-zero size
Created attachment 3722 [details] Log file from ps2pdf: ever-shrinking numbers
Since I was looking at a FontMatrix issue I just checked this one (you never know..). Its not, as far as I can tell, a FontMatrix problem, the job uses a 'base 14' font, and as such it isn't embedded, hence no FontMatrix. The resulting PDF however does have a tiny text matrix applied to the text after the superscript: 0.00005100 0 0 0.00005100 97.5199 72.0191 Tm Scaling down by a factor of 20,000! Followed (without restoring the text matrix) by: 0.00000003 0 0 0.00000003 97.5199 72.0191 Tm and eventually: 0.00000000 0 0 0.00000000 97.5199 72.0191 Tm The PDF also sets the font size for the initial superscript too small. I'd be grateful if Mr Wiseman could confirm this is the issue, just to be certain. My thanks for reducing the PostScript to a nice small job.
Adding a new even simpler PS file, and its output from Distiller, Preview and Ghostscript.
Created attachment 3730 [details] PS file more clearly demonstrating problem
Created attachment 3731 [details] Distiller output from second PS file
Created attachment 3732 [details] Preview output from second PS file
Created attachment 3733 [details] Ghostscript output from second PS file
Actually, this might be a bug in the Adobe Distiller! PLRM3 (1999), section 5.2.1, page 324, says: FontMatrix array (Required) An array that transforms the glyph coordinate system into the user coordinate system (see Section 5.4, “Glyph Metric Information”). For example, Type 1 font programs from Adobe are usually defined in terms of a 1000-unit glyph coordinate system, and their initial font matrix is [0.001 0 0 0.001 0 0]. When a font is derived by the scalefont or makefont operator, the new matrix is concatenated with the existing font matrix to yield a new copy of the font with a different font matrix. If it is that's rather embarrassing for Adobe.
Julian, I'm not sure why you think the FontMatrix is at fault here. The PDF files you've sent produced by Distiller actually contain an embedded version of Times-Roman (which is unusual, this font doesn't normally get embedded). The Ghostscript pdfwrite output doesn't embed this font by default either, and indeed the files you've supplied produced by GS don't have the font embedded. That's why they are 10% of the size. Obviously since they don't have the font, they also don't have a FontMatrix... The FontMatrix is part of the font program, but in this (Distiller) case the embedded font is a TrueType font, so it doesn't have a FontMatrix in the normal sense. Also the design space for a TrueType font is usually (if I remember correctly) 2048x2048 not 1000x1000 as recommended for type 1 fonts. I do see the differing result from your PostScript test, but I wouldn't worry about that. The FontMatrix isn't meant to be manipulated by PostScript jobs. It looks to me like the results you have are for the particular scaled instance of the font, and probably include the page default scaling. Or something. Now, having said that, I *do* see a problem with the pdfwrite output, but its the text matrix which I see as incorrect. Distiller output: (1)Tj 30 0 0 30 97.5 91.125 Tm (st)Tj 51 0 0 51 117.5098 72 Tm (, 2)Tj 30 0 0 30 168.5098 91.125 Tm (nd)Tj etc. pdfwrite output (1)Tj /R8 0.03 Tf 25.5 0.0191406 Td (st)Tj /R8 1 Tf 0.00005100 0 0 0.00005100 97.5199 72.0191 Tm (, 2)Tj 0.00000003 0 0 0.00000003 97.5199 72.0191 Tm (nd)Tj 0.00000000 0 0 0.00000000 97.5199 72.0191 Tm Tm sets the text matrix, the first and fourth numbers being the horizontal and vertical scaling. As you can see, these are tiny, and in the last case are 0. Scaling by 0 is not a good thing. :-) I believe this is the problem, not the FontMatrix, does this seem right to you ? In fact, modifying the content stream like this: (1)Tj /R8 30 Tf 25.5 0.0191406 Td (st)Tj /R8 1 Tf 20 0 0 20 97.5199 72.0191 Tm (, 2)Tj 20 0 0 20 97.5199 72.0191 Tm (nd)Tj 20 0 0 20 97.5199 72.0191 Tm (, and 3)Tj 20 0 0 20 97.5199 72.0191 Tm (rd)Tj 20 0 0 20 97.5199 72.0191 Tm (.)Tj You can see the text. Its not correct of course, these are silly numbers, but I think it shows where the problem is. There seems to be some kind of scale inversion going on for the smaller font size (0.03 Tf should be ~30 I think), which seems to be seriously confusing the later text matrix calculations.
My understanding, perhaps erroneous, is that FontMatrix contains the size information for the font. Let's rephrase. Fixed 'identity' scaling matrix. Earlier in the code /SomeFontName /SomeSize selectont. What routine can extract the name of the current font, its size, and then do the equivalent of Name Size 2 div selectfont? My understanding was that such a half-the-current-font-size code would look into FontMatrix. It is the logical place. But that can only work if FontMatrix is well defined*. PLRM3 seems to define it well enough, but Distiller and GhostScript have different behaviour. Whether or not the font is embedded doesn't seem, to me, to be relevant to the numbers stored in FontMatrix. * I suppose I could abandon the attempt to know the CurrentFontSize, and just multiply elements of the matrix by some factor. But, ignoring this, can I know the current font size?
Aha, I see where you are coming form now. The fact that you were using ps2pdf had me confused over your problem, I thought you were complaining about the PDF output. You are quite correct that the FontMatrix scales the font, the only question being by how much. Usually the matrix defines a scaling from a 1000x1000 design space into PostScript user space, but this is not a guarantee. I am intrigued by the results you get with your second file from Distiller 8, when I run Distiller 7 & 8 here (on Windows admittedly) I get the same set of numbers as for Ghostscript. To be honest these are pretty much the numbers I would expect. When I run your original PostScript file through Distiller here it also results in a PDF file identical with the Ghostscript output. Since the PostScript job doesn't contain a font, Distiller must be using local fonts, which suggests that the font on your Mac is quite different to the font on my PC... Anyway. The basic problem with your PostScript is that you don't account for the mapping from font space to user space, you're just assuming an identity. For some strange reason the font you were using has a mapping which *is* the identity. The Ghostscript font doesn't have an identity font matrix, and that's where your problem comes up. You can fix this issue readily enough, here's a modified version of your original file which works here for me on both Ghostscript and 2 versions of Distiller. %! /FontName /Times-Roman def /FontSize 51 def FontName FontSize selectfont /CurrentFontSize { currentfont dup %% copy current font dictionary /FontName get %% extract the font name findfont %% Get the original font dictionary /FontMatrix get 3 get %% Get the y user space scale from it. dup (initial y scale ) print == exch %% bring back the current font dict /FontMatrix get 3 get %% Get the current y user space scale dup (current y scale ) print = exch %% Swap the original and current y scale div %% Divide together to get current font scale dup (final size ) print == } bind def /SuperscriptOn {0 CurrentFontSize 0.375 mul rmoveto FontName CurrentFontSize 1.7 div selectfont} def /SuperscriptOff {FontName CurrentFontSize 1.7 mul selectfont 0 CurrentFontSize -0.375 mul rmoveto} def 72 72 moveto (1) show SuperscriptOn (st) show SuperscriptOff (, 2) show SuperscriptOn (nd) show SuperscriptOff (, and 3) show SuperscriptOn (rd) show SuperscriptOff (.) show showpage I expect this will work for your Distiller on the Mac, which seems to have an identity FontMatrix. Division by 1 will just give back the size. If this doesn't work for some reason, please re-open the issue.
OK, thank you. I still think that there's a bug in at least of Distiller and Ghostscript, though it's probably Mac Distiller. www.jdawiseman.com/papers/placemat/placemat.ps updated to include a version of your routine, shortened by one exch: % http://bugs.ghostscript.com/show_bug.cgi?id=689664 /CurrentFontSize { currentfont dup /FontMatrix get 3 get % current y scale exch /FontName get findfont /FontMatrix get 3 get % original y scale div } bind def % /CurrentFontSize See www.jdawiseman.com/papers/placemat/placemat.html for the manual.