Closed Bug 432071 Opened 12 years ago Closed 12 years ago

Type 1 fonts don't print correctly.

Categories

(Core :: Graphics, defect, major)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED FIXED
mozilla1.9

People

(Reporter: tkloos, Assigned: pavlov)

References

Details

(Keywords: fonts)

Attachments

(4 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9pre) Gecko/2008050312 SeaMonkey/2.0a1pre
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9pre) Gecko/2008050311 Minefield/3.0pre

Type 1 Fonts may not print print correctly.  Judging from my test case it appears that the fonts the printer "knows about" are usually the ones that fail since "CMR10" appears OK.  The incorrectly printed pattern matches that displayed from bug 396315.

Sending the printer PCL generates the output shown in the attachments where both Helvetica and Courier are broken.  Sending the printer Postscript results in only Courier being broken.

There are other Mozilla printing problems with PCL.  See bug 427229.

Reproducible: Always

Steps to Reproduce:
1.  Display and print the test case.  Note that you MUST have the appropriate Type 1 fonts installed.

Actual Results:  
See scan of print from Firefox -- attachment ff3_print_bug.png -- Helvetica and Courier fonts are trashed.

Expected Results:  
See scan of print from Opera -- attachment opera927_print.png

These are commonly used fonts so their proper rendering with both PCL and Postscript is critical.
Flags: blocking1.9?
Keywords: fonts
Hmm, I thought bug 431391 was supposed to fix this?  I too had similar printing problems with the nightlies, though I hadn't tried printing recently.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Yea, I am indeed getting garbled text for Type 1 fonts on a LaserJet 5M with the 20080503 nightly using your testcase, and I'm still getting garbled text when trying to print from support.mozilla.org (which was where I first noticed the problem a few weeks ago; I thought at the time that it was a fault with my printer, so I didn't think to file a bug report).  So I guess bug 431391 didn't fix the problem after all.

I also wonder if bug 426438 is related, though the problem sites mentioned in that bug print out fine for me.
Version: unspecified → Trunk
Using your testcase I get garbled text for Line 7 "Courier (Type 1)". The rest displays correctly. In may case the reason for the garbled text is the only font named "Courier" on my system is the Windows bitmap courier font.

It looks like bitmap fonts have the same issues as Type 1 fonts (bug 431391 fixed the problem for Type 1 fonts). 

I've committed several patches to cairo that fix this as well as various other problems with bitmap fonts.

The minimum patches required to fix this bug (assuming the bug is with printing bitmap fonts) are:

547e2f552cff2
158d24412bba9
d35d6eec24c1b

I don't think that the problem is just with bitmap fonts, though.  I ran into the same problem when printing from support.mozilla.org, e.g.,
<http://support.mozilla.com/tiki-print.php?page=Keyboard+shortcuts>

Although Courier is a bitmap font in Windows, Courier has always printed out smoothly (i.e., without the jaggedness of a bitmap font) on the printer when using other apps because it is one of the fonts that the printer "knows" and has stored internally.
(In reply to comment #7)
> Although Courier is a bitmap font in Windows, Courier has always printed out
> smoothly (i.e., without the jaggedness of a bitmap font) on the printer when
> using other apps because it is one of the fonts that the printer "knows" and
> has stored internally.
> 

This would be what Windows calls "device fonts". Some good information in device fonts is at:

http://support.microsoft.com/kb/201978

I see now that the garbled Courier text on line 7 in attachment 2 [details] [diff] [review] is in the Courier font. When I printed this on my HP LaserJet the garbled text was in a Arial or Helvetica font. My printer has all the PostScript fonts built in so this is probably up to the printer driver and whatever settings the driver makes available to control the font substitution. This is a good reason for avoiding device fonts as we can not guarantee WYSIWYG.

The problem is cairo uses glyph indices for drawing text, not the unicode characters. As glyph indices are font specific, substituting fonts is going to cause all sorts of problems.

It may also be that case that device fonts, like bitmap and Type 1 fonts, seem to require the unicode characters to be used on a printer context but work fine with glyph indices on a display context.

I'm not really sure what can be done here. It would be best if Firefox avoided these fonts and if possible substituted TrueType/OpenType/Type 1 fonts for the well known PostScript fonts. eg when "Courier" is requested, use "Courier New".

Look for the presence of one or more of these files, usually in a "PSFONTS" directory:
COBO____.PFB
COB_____.PFB
COM_____.PFB
COO_____.PFB
These are scalable "Type 1" Courier fonts and appear to be what FF has problems with, both in printing and some display sizes (see bug 432065).

Helvetica Type 1 is HV*.PFB in the same place.

The Courier (besides Courier New) font that comes with Windows is COURE.FON. I believe this is rendered correctly by FF and appears to be used interchangeably with the Type 1 version (if present) for certain font sizes (10, 12, 15?).  Most confusing, but the "g" gives it away -- more of a hook on the descender than either "Courier New" or the Type 1 version.
(In reply to comment #9)
> Look for the presence of one or more of these files, usually in a "PSFONTS"
> directory:
> COBO____.PFB
> COB_____.PFB
> COM_____.PFB
> COO_____.PFB

I don't have these fonts available which would explain why I can't reproduce the same results.

> The Courier (besides Courier New) font that comes with Windows is COURE.FON. I
> believe this is rendered correctly by FF and appears to be used interchangeably
> with the Type 1 version (if present) for certain font sizes (10, 12, 15?). 
> Most confusing, but the "g" gives it away -- more of a hook on the descender
> than either "Courier New" or the Type 1 version.

So there appears to be multiple issues here:

- Firefox switches between a Type 1 Courier and a bitmap Courier font at different scales (432065).

- Firefox is using the wrong glyphs for displaying some Type 1 fonts (432065). Are your sure it is a Type 1 font and not a bitmap font? Try removing all Courier fonts except for one Type 1 Courier font and check if it works.

- Cairo prints the wrong glyphs when printing a bitmap font. I've patched cairo to fix this but the patches are not yet in Firefox.

- The printer driver may substitute a bitmap font with a printer font. This may cause the wrong glyphs to be printed. My patches to cairo to fix bitmap font printing should prevent device font substitution so we know the correct glyphs will be printed.

We need to get the text right on the display first. Once that is working, if there are still printing problems it is likely a cairo problem.
Assignee: nobody → pavlov
Flags: blocking1.9? → blocking1.9+
Decided not to block on this at the triage during the Firefox meeting.
Flags: wanted1.9.0.x+
Flags: blocking1.9-
Flags: blocking1.9+
Attached patch patch for stuartSplinter Review
Attaching patch for stuart, not sure what he wants to do with it!
Comment on attachment 319923 [details] [diff] [review]
patch for stuart

I'd like to take this for rc1.
Attachment #319923 - Flags: review+
Attachment #319923 - Flags: approval1.9?
Attachment #319923 - Flags: approval1.9? → approval1.9+
mozilla/gfx/cairo/README 	1.96
mozilla/gfx/cairo/cairo/src/cairo-win32-font.c 	1.49
mozilla/gfx/cairo/cairo/src/cairo-win32-printing-surface.c 	1.12
mozilla/gfx/cairo/cairo/src/cairo-win32-private.h 	1.38 
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9
How does one apply this patch? or is it included in the latest version of FF3 already?  I'm running Windows XP SP3 with FF3 3.0.1 
(In reply to comment #15)
> or is it included in the latest version of FF3
> already?
> 

It already is.  This patch was checked in on 8 May 2008, per comment 14.  If you are still having printing problems with Type 1 fonts, you should file a new bug.  Note that there are other printing bugs, not specific to Type 1 fonts, so unless you are sure that your problem is with a Type 1 font, you may want look around at other bugs that have been filed.
Blocks: 454532
Flags: wanted1.9.0.x+
You need to log in before you can comment on or make changes to this bug.