Re: LOGFONT and Courier font to a printer
- From: "Paul Baker [MVP, Windows - SDK]" <paulrichardbaker@xxxxxxxxxxxxxxxx>
- Date: Fri, 6 Apr 2007 09:41:31 -0400
GMG,
Sorry, I am not sure how we ended up assuming it was using the "Courier New"
font. If GetTextFace returns "Arial", that assumption was a mistake, so we
will have to first backtrack a little bit. Arial, of course, looks nothing
like Courier as it is a variable width (aka. proportional) font whereas
Courier is a fixed width font. So on a report, if you used spaces to line
things up into columns, it just won't work. No wonder your customer is
complaining!
If it is important to you which font it uses, you must pay close attention
to your LOGFONT structure as this is what the font mapper is using. It
compares the attributes of the LOGFONT to the attributes of each available
font and does a weighted score. Your LOGFONT.lfPitchAndFamily is
DEFAULT_PITCH Or FF_DONTCARE. I should have noticed this earlier, but did
not. By using this, you are saying that you don't care if it's a fixed width
or variable width font and that you don't care what font family it is. But
you do care! You want a fixed width, preferably "modern" font and, given our
discussion, you would prefer "Courier New".
So, set LOGFONT.lfFaceName to "Courier New" and set LOGFONT.lfPitchAndFamily
to FIXED_PITCH Or FF_MODERN. I am confident this will solve your problem.
Your assertion that you would expect it to choose "Courier New" given your
parameters is faulty in that when you elect not to specify the pitch and
family that it is using to compare against, it does not look at the
attributes of your preferred font face "Courier" and see what pitch and
family that is and use that for future comparisons. It's just a straight
comparison of LOGFONT.
Here is the LOGFONT documentation:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/fontext_1wmq.asp
Paul
"GMG" <GMG@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:D5B570FB-3E86-43C4-904A-29E6E54C309F@xxxxxxxxxxxxxxxx
Paul,
Thanks for the help. I double the font via gettextface and it returns
Arial
for Courier when sending to the printer. I tried printing a web page the
had
Courier and it printed Arial as well. The Desktop shows it as Courier,
but
the printer seems to print it as Arial. I can see why there's come
confusion, you would think the Windows GDI would have choosen Courier New
over Arial.
Thanks
Gary
"Paul Baker [MVP, Windows - SDK]" wrote:
GMG,
There is a misunderstanding here somewhere.
Courier and Courier New are internal font names used by Windows GDI.
Courier
is also an internal font name used by Adobe which is unrelated to GDI. No
matter what you call them internally, there's all the same. Their the
"Courier" typeface you might find in a typeface book. But you have to use
the Courier New internal name with the Windows GDI to get a good quality
representation. And if you don't, it does it for you. That's a good
thing.
If I renamed my Courier font "Cool Fixed Width Font" and used that on
your
customer's report, would he complain that it used "Cool Fixed Width Font"
and not Courier? No, because it is the same. Just as "Courier New" is the
same.
Paul
"GMG" <GMG@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A473E6C1-20D7-4B69-B1DD-03AD8C60EDEB@xxxxxxxxxxxxxxxx
Alex/Paul,
Thanks for all your input regarding the Courier font issue. I didn't
think
it would be so difficult to select a raster font like Courier, but it
seems
to be.
I could go with Courier New and I know this works. But my customer
question/issue was trying to get Courier to work with thier their
printer.
I market a report engine and the customer was asking why they can't
send a
report that uses courier font to the printer. They can generate the a
report from the report engine and courier works fine when sending to
the
printer.
GMG
"Paul Baker [MVP, Windows - SDK]" wrote:
If you MUST use Courier, the only solution I can think of is to output
the
text to a screen-compatible bitmap at the appropriate size in pixels
according to the printer DPI and then output that to the printer.
Someone else might have a better solution. However, noone has stepped
forward with one so far. You're going against the grain.
Paul
"Alex Cohn" <AlexCohn@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9C0F5309-CFEA-4203-8288-AD56692C36A2@xxxxxxxxxxxxxxxx
OUT_RASTER_PRECIS will not resolve your problem; it will prefer a
raster
font
over TrueType scalable font _if_ one is available for the given
typeface.
If
the system could not match the Courier font for the specific device
context,
it will not become better. As Paul indicated, you may use the
EnumFontFamiliesEx API to find the font type for a given typeface.
The
EnumFontFamExProc will receive FontType argument that will indicate
RASTER_FONTTYPE or TRUETYPE_FONTTYPE. See an example for VB at
http://www.math.msu.su/~vfnik/WinApi/e/enumfontfamiliesex.html.
Alex
"GMG" wrote:
I'm wondering if I use OUT_RASTER_PRECIS if this would force the
font
mapper
to choose courier?
Is there a method to know if a font is a Raster Font verses a true
type
font.
Thanks
GMG
"Paul Baker [MVP, Windows - SDK]" wrote:
You should use Courier New. For all intents and purposes, it *is*
Courier,
but it's scalable. The customer doesn't care what Windows calls
the
font, he
only cares what it looks like.
Paul
"GMG" <GMG@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1FD4545C-BF04-4889-9071-7D4E2E7D3AF8@xxxxxxxxxxxxxxxx
Paul.
I'm setting every field that the LOGFONT structure has
available,
unless
I'm
missing something.
The reason for why I'm pushing courier and my customer, of
course,
requires
it for their reports. I'm stump by this issue because Courier,
I
would
expect to work because it's the oldest font out there.
Thanks
GMG
"Paul Baker [MVP, Windows - SDK]" wrote:
HI,
You are not zero-filling your LOGFONT structure, although it
looks
like
you
are initializing each of its members separately.
I am not saying that your printer driver does not support
Courier.
In
fact
it ought to be able to support it using graphics. I am simply
saying
that
the font mapper, based on your LOGFONT, driver and printer
settings,
decided
not to use Courier. Actually, I am assuming that from your
observations.
You
would have to call GetTextFace to see what physical font face
it
actually
used. The reason it did that is unclear to me, as the decision
is
complex
and not well documented. However, it would seem to be a rather
large
strike
against choosing Courier that is a raster font. It comes only
in
sizes of
10, 12 and 15. The quality is going to look awful on a
printer,
which
probably has a much higher DPI than your screen.
Can I ask, why are you so determined that it use the Courier
font?
As
previously mentioned, you probably want to be using Courier
New.
Paul
"GMG" <GMG@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:77EFCFA4-FE6A-41AB-93B7-E2AE14FFF1ED@xxxxxxxxxxxxxxxx
Below is what I'm doing to select the logical font. This
routine
works
when
displaying the font on the desktop monitor but doesn't work
when
sending
to
the printer. I'm going the SelectObject to select the new
font
and
everything. It does seem work ok with True Type Font but
not
with
Raster.
Are you saying HP T45 OfficeJet doesn't support Courier that
way
I'm
not
able to select it and Adobe PDF is doing some type of
preprocessing
before
sending to the print to handle Courier.
With tLF
sFont = fld.Font & vbNullChar
b = StrConv(sFont, vbFromUnicode)
For iChar = 1 To Len(sFont)
.lfFaceName(iChar - 1) = b(iChar - 1)
Next iChar
.lfHeight = -(fld.FontSize * 20) 'using MM_ANISOTROPIC
.lfWidth = 0
If fld.Italic Then
.lfItalic = 1
Else
.lfItalic = 0
End If
If (fld.Bold) Then
.lfWeight = FW_BOLD
Else
.lfWeight = FW_NORMAL
End If
If fld.Underline Then
.lfUnderline = 1
Else
.lfUnderline = 0
End If
.lfStrikeOut = 0
.lfCharSet = DEFAULT_CHARSET
.lfEscapement = 0
.lfOrientation = 0
.lfOutPrecision = OUT_DEFAULT_PRECIS
.lfClipPrecision = CLIP_DEFAULT_PRECIS
.lfQuality = DEFAULT_QUALITY
.lfPitchAndFamily = DEFAULT_PITCH Or FF_DONTCARE
End With
"Paul Baker [MVP, Windows - SDK]" wrote:
Alex,
I think that the reason you are confused is that you are
unaware
of
the
font
mapping behaviour of Windows.
A LOGFONT structure represents a logical font. It describes
the
attributes
of the font you would like to have.
When you output using the font, you must first use the
SelectObject()
API.
This selects the font. In doing so, it creates a physical
font. A
physical
font is the font it will actually use and it is determined
by
the
font
mapper. It looks at your logical font and finds what it
believes
to be
the
best match for the device. This depends on the capabilities
of
the
device.
For a screen, this essentially means installed fonts. For a
printer,
this
depends on the driver.
The face name is one of the most important things, but each
value
has
a
weighting and you must be careful to fill out as much of
the
LOGFONT
structure as you can as accurately as you can to help
ensure
that
you
get
the physical font you want/expect.
A raster font like Courier comes in fixed sizes, it's like
a
bitmap.
It
can
be scaled if necessary, but it does not scale well.
Also, PDF documents generally print text using graphics and
not
fonts.
At
least, not GDI fonts. It uses its own font mechanism
designed
by
Adobe.
So
what Adobe calls "Courier" by no means corresponds to your
GDI
Courier
font.
Paul
"GMG" <GMG@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F51A83A1-4E76-4979-AF12-886B74790CD1@xxxxxxxxxxxxxxxx
Alex,
Only reason I'm confused by this answer, is when I send a
document
to
the printer that uses a Courier font it print correctly.
I'm
only
finding
the issue when I'm trying to send to the printer via
LOGFONT/CreateFontIndirect.
Do I need to specify in the LOGFONT structure it's a
raster
font.
If
so,
how to I determine if a font is a raster font when all I
.
- Follow-Ups:
- References:
- Re: LOGFONT and Courier font to a printer
- From: Paul Baker [MVP, Windows - SDK]
- Re: LOGFONT and Courier font to a printer
- From: GMG
- Re: LOGFONT and Courier font to a printer
- From: Paul Baker [MVP, Windows - SDK]
- Re: LOGFONT and Courier font to a printer
- From: GMG
- Re: LOGFONT and Courier font to a printer
- From: Paul Baker [MVP, Windows - SDK]
- Re: LOGFONT and Courier font to a printer
- From: GMG
- Re: LOGFONT and Courier font to a printer
- From: Alex Cohn
- Re: LOGFONT and Courier font to a printer
- From: Paul Baker [MVP, Windows - SDK]
- Re: LOGFONT and Courier font to a printer
- From: GMG
- Re: LOGFONT and Courier font to a printer
- From: Paul Baker [MVP, Windows - SDK]
- Re: LOGFONT and Courier font to a printer
- From: GMG
- Re: LOGFONT and Courier font to a printer
- Prev by Date: Re: LOGFONT and Courier font to a printer
- Next by Date: Re: Bitmap handle for pre-existing bitmap
- Previous by thread: Re: LOGFONT and Courier font to a printer
- Next by thread: Re: LOGFONT and Courier font to a printer
- Index(es):
Relevant Pages
|