Font not printing right on SOME printers

A

Al Meadows

Have a weird one. The application works fine on some printers, doesn't on
others. The problem is that I have a one page report which uses several
fonts and fonts of varying size. The only one I am having trouble with is
the OCR font (see code below). On some machines, when they print to their
local printer. it comes out looking like Arial or something similar. These
are a combination of local attached printers (mostly) and some network ones.
For example. one model of HP works, another doesn't.



I can't duplicate it locally.



The print routines are performed with VS2005 using C#. The specific line
where the problem occurs is as follows:



private void printLine(PrintPageEventArgs e, Font printFont, Brush brush,
float left, float top, string text, bool adjustFrom)
{

......

e.Graphics.DrawString(text, printFont, brush, left, top,
StringFormat.GenericTypographic);

......

}



Where all the variables are supplied. All printing, regardless of font,
size, location, or text being printed passes through this one single
statement. The only line that appears to have a problem is when the
variable printFont is as follows:



Font printFontOCR = StatInfo.createFont("OCR A Extended", 12);



where StatInfo.createFont is as follows:



public static Font createFont(string fontName, Int32 size)
{
Font printFont = new Font("Arial", 10);
try
{
printFont = new Font(fontName, size, style);
}
catch (Exception e)
{
MessageBox.Show("A font substition was necessary. Please
ensure you have the latest fonts installed. The Bad Font is:" + fontName);
ErrorTracker et = new ErrorTracker();
et.ExtraInfo = "createFont:" + fontName + " - " +
printFont.ToString();
et.postManagedError(e.Message, "A font substition was
necessary. From " + fontName);
printFont = new Font("Arial", size, style);
}
return printFont;

}



As you can see... I included this Font Instantiation procedure in order to
handle a situation where a desired font cannot be created within the
application. Note that when we have the problem, we are NOT triggering an
exception.



Additionally...



I added these lines of code around the DrawString line.



Application.DoEvents();
if (printFontOCR.Equals(printFont))
{
text = "OCR Font: " + text;
}
e.Graphics.DrawString(text, printFont, brush, left, top,
StringFormat.GenericTypographic);
Application.DoEvents();



in order to perhaps catch timing problems with the DoEvents method and also
having it check the value of the variable printFont to insure that it was
EQUAL to what I defined as printFontOCR. In all cases, both good printers
and problem printers, it correct equates printFont to printFontOCR.



This program is a replacement of an older VB6 program that creates the same
report however in the case of the VB6 app, we are using the printer object
that is part of VB. When these desktops with attached printers who are
having problems now print form the older VB6 app... it works PERFECT.



In addition, creation of a word document that includes a number of font
samples that also include the problematic font "OCR A Extended" also works
perfectly when printed.



As a final test to see what might be happening, I added a PrintPreviewDialog
to the project in order to get a preview of what the printed result should
look like. What was seen is that even in the PrintPreviewDialog display...
the OCR Font is 'wrong'.



One final, less importantr question relating to the PrintPreviewDialog .
When I use this, it is displaying correctly on the screen however the
document is ALSO being printed regardless which sort of makes using the
print preview kind of worthless. Any ideas why this is happening?
 
L

Linda Liu[MSFT]

Hi Al,

Based on my understanding, you have an application which prints something
to printers. The problem is that the font of "OCR A Extended" cannot be
printed properly on some of printers. If I'm off base, please feel free to
let me know.

I performed a test printing the font of "OCR A Extended" to a printer in my
office but didn't reproduce the problem on my side. The font was printed
properly in my test. The model of the printer I used is "HP LaserJet 8150
Series PCL6".

You can find all fonts installed on the machine under the folder
"C:\Windows\Fonts".

You may have a try printing the "OCR A Extended" font directly to see if it
can be printed properly on the problematic printers. To do this, in the
above folder, right-click the font of "OCR A Extended" and choose "Print"
command.

What are the model of the problematic printer? If they're PostScript
printers, you may need to avoid font substitution. Please visit the
following link for information on how to do it:
"Avoiding Font Substitution - Configuring Windows XP PostScript Printer "
http://www.sketchpad.net/config-ps-printer-winxp.htm

Hope this helps.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top