Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Print using Printer Fonts in c# app

359 views
Skip to first unread message

Alison via .NET 247

unread,
Oct 31, 2004, 6:59:11 AM10/31/04
to
Hi

How do I get a list all the printer fonts in c#?

I've written a c# app that prints out a receipt on a Citizen Thermal Printer. This works fine but I have to print out the character 'G' in the printer font "control" to automatically print out the bitmap logo saved in the printer's flash memory.

E.g.
e.Graphics.DrawString ("G", new Font("Control", 15), Brushes.Black, 0, 0, new StringFormat());

However, this doesn't work. And if I experiment with some of the MSDN examples on http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/_gdiplus_enumerating_installed_fonts_usecsharp.asp using the InstalledFontCollection the list it produces doesn't include any of the printer fonts available if I look at the drop down of fonts in, for example, Wordpad.

So my question is : how do I get the name of and use a printer font in my c# application? I thought maybe I'm not using the correct name or something which is how I came up with the idea of listing all the printer fonts which I can't do?

Thanks for your help.
--------------------------------
Regards: Alison

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>XFVYhwcPPUmrDJHOFOJbyQ==</Id>

Chris Marchal [MSFT]

unread,
Nov 1, 2004, 11:21:06 AM11/1/04
to
The GDI+ library used by the .NET framework will only use TrueType and
OpenType fonts. It does not allow you to access printer fonts. What
usually happends is that you specify the name of the printer font but the
GDI+ library will use a default TrueType font.

In order to access the printer font, you will need to bypass the .NET
framework drawing libraries (i.e. GDI+) and use GDI.

When you come to print, you can get use the Graphics.GetHdc method to get
handle you can use with GDI. You then use GDI routines to select the
printer font and draw the character for the symbol you need to print. You
then call Graphics.ReleaseHdc to continue with the rest of the printing in
.NET.

Chris Marchal
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.

0 new messages