Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / July 2008

Tip: Looking for answers? Try searching our database.

Cant use courier font with PrintDocument - need to print labels

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MichaelL - 07 Mar 2008 21:47 GMT
I'm trying to print labels and need to use the courier font(not
'courier new') so my horizontal and vertical spacing matches up with
the labels.  I've tried using other proportional/monospace fonts but
they don't have proper spacing for my labels and I know that 'courier'
would work.When you 'hover' over the printFont variable, it shows
'Microsoft Sans Serif" as the FontFamily even though I've set to
'Courier'.  Other fonts do not have this problem but, the labels are
no good with other fonts.  The 'for' loop below doesn't include
'courier' as a part of its output and I'm sure that is a clue but I
don't know what to do with that clue. I know that the courier font is
installed on my machine because it's available to outlook, word, and
even Visual Studio's text editor, however, its just not available to
be used by PrintDocument/Font namespace/class. Any help would be
greatly appreciated.

       Imports System.Drawing

       Dim printFont As System.Drawing.Font
       printFont = New System.Drawing.Font("Courier", 8)
       Dim oneFontFamily As System.Drawing.FontFamily
       For Each oneFontFamily In System.Drawing.FontFamily.Families
           Debug.WriteLine(oneFontFamily.Name)
       Next
Kerry Moorman - 07 Mar 2008 22:03 GMT
MichaelL,

The documentation says:

"Windows Forms applications support TrueType fonts and have limited support
for OpenType fonts. If you attempt to use a font that is not supported, or
the font is not installed on the machine running the application, Microsoft
Sans Serif will be substituted."

If you look at the list of fonts in Word, for example, TrueType fonts have a
TT symbol to the left of the font name. I wonder if the Courier font that is
available to Word on your system is a TrueType font?

Kerry Moorman

> I'm trying to print labels and need to use the courier font(not
> 'courier new') so my horizontal and vertical spacing matches up with
[quoted text clipped - 19 lines]
>             Debug.WriteLine(oneFontFamily.Name)
>         Next
Herfried K. Wagner [MVP] - 07 Mar 2008 22:05 GMT
"MichaelL" <mlafarlett@yahoo.com> schrieb:
>        Dim printFont As System.Drawing.Font
>        printFont = New System.Drawing.Font("Courier", 8)
>        Dim oneFontFamily As System.Drawing.FontFamily
>        For Each oneFontFamily In System.Drawing.FontFamily.Families
>            Debug.WriteLine(oneFontFamily.Name)
>        Next

The version of the "Courier" font included with Windows is a bitmap font.
'System.Drawing' only supports TrueType and OpenType fonts.  What you can do
is to use either plain old GDI via p/invoke or to get a version of "Courier"
in a vector font file format .NET supports.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>

Harald Hoyer - 27 Jul 2008 22:15 GMT
How can I get a version of "Courier"
in a vector font file format .NET supports?
Herfried K. Wagner [MVP] - 28 Jul 2008 01:07 GMT
"Harald Hoyer" <hahoyer@yahoo.de> schrieb:
> How can I get a version of "Courier"
> in a vector font file format .NET supports?

I assume that some font vendors license this or very similar fonts in vector
format.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>

Harald Hoyer - 28 Jul 2008 08:06 GMT
Actually I searched for things like this. Without success. Probably you
know any vendor that provides this?
What about the other option? (using old GDI) Are there examples
available? (I prefer C#) Is it probably possible to provide a "new" font
type, where the pixel fonds can be wrapped to?
Just_a_fan@home.net - 15 Mar 2008 00:31 GMT
Don't know why Courier New does not come up there.  This very code
(copied and pasted) lists Courier New here:

Comix
Commercial-Script
Congo
Congo Condensed
Congo Extended
Congo Thin
Congo Wide
Continuum Bold
Continuum Light
Continuum Medium
Cornered
Cornerstone
Cotillion
Courier New
Crate
Cuckoo
Cupid
Cupid Condensed
Cupid Wide
Curzon
D730-Deco
Danto

Does Courier New appear in other apps?  Word?

Mike

On Fri, 7 Mar 2008 13:47:34 -0800 (PST), in
microsoft.public.dotnet.languages.vb MichaelL <mlafarlett@yahoo.com>
wrote:

> Imports System.Drawing
>
[quoted text clipped - 4 lines]
>            Debug.WriteLine(oneFontFamily.Name)
>        Next
Herfried K. Wagner [MVP] - 15 Mar 2008 00:48 GMT
<Just_a_fan@home.net> schrieb:
> Don't know why Courier New does not come up there.  This very code
> (copied and pasted) lists Courier New here:
[quoted text clipped - 23 lines]
>
> Does Courier New appear in other apps?  Word?

Re-read the OP's post.  He attempts to use the Courier font, not Courier
New.  As Courier is a bitmap font it cannot be used together with
'System.Drawing'.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>

Just_a_fan@home.net - 15 Mar 2008 02:02 GMT
Actually, he did mention Courier New at one point.  Maybe it had the
"not" and I missed it.  Yes, trying to use Courier would fail and fails
here.  Sorry.

Why not use Courier New?

Mike

On Sat, 15 Mar 2008 00:48:38 +0100, in
microsoft.public.dotnet.languages.vb "Herfried K. Wagner [MVP]"
<hirf-spam-me-here@gmx.at> wrote:

><Just_a_fan@home.net> schrieb:
>> Don't know why Courier New does not come up there.  This very code
[quoted text clipped - 28 lines]
>New.  As Courier is a bitmap font it cannot be used together with
>'System.Drawing'.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.