Solved

How do I print with a specific printer device font, not a truetype font?

Posted on 2006-06-25
7
1,108 Views
Last Modified: 2013-12-03
My app (in Visual C#) prints using various fonts as follows:

                  Font font = new Font("Arial", 7);
                  e.Graphics.DrawString("Hello World", font, Brushes.Black, x, y);

But how do I print with a specific device font that is installed on the printer itself? The code above just picks a TrueType font installed on the computer.

0
Comment
Question by:groovyjon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 21

Expert Comment

by:wyliecoyoteuk
ID: 16980003
depends on the printer.
If it is a PCL printer, truetype fonts are often mapped to printer fonts. Otherwise, you would need to embed a PCL font command into the I/O stream.
Other print languages have different ways of doing things.

If you are using a GDI printer, the file is rendered within windows, so the font is renderd as an image by the GDI API, and "printer" fonts do not exist.
0
 

Author Comment

by:groovyjon
ID: 16980055
It's a thermal receipt printer (Star TSP100) and does have its own device fonts. One of them is called "control" and when certain characters in that font are printed, it performs certain actions (e.g. printing letter A in Control font triggers the attached cash drawer to open). I need to perform these actions hence the need to use its own fonts rather than the truetype fonts I've used up to now.
0
 
LVL 21

Expert Comment

by:wyliecoyoteuk
ID: 16986752
Ah, embedded command font. I have used some fax applications which use these.

Usually, you need to install the font into windows.
It may install with the printer driver, or it may be on the driver disk.
You may need to use square brackets [ ] or another symbol to embed it into the I/O stream.
0
Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

 
LVL 21

Expert Comment

by:wyliecoyoteuk
ID: 16986890
the programming manual does not mention a command font, it seems to use escape codes to control the printer:

http://www.starmicronics.com/printers/printers_pages/support/manuals/linemodepm.pdf

The escape character shown as "ESC" is a non printing character, and how you produce it depends on which editor you are using.(for example Vim uses ctrl+esc, if I remember correctly, but other editors use different combinations, or you can use an ASCII code)
0
 

Author Comment

by:groovyjon
ID: 16987380
Hmmm, I hadn't seen that manual, I was looking at a user's manual which kept referring to "control fonts". I'll have to have to try to get my head round all this as it's quite new to me - I'm not even sure what it means by "line mode". At the moment, I'm printing TrueType fonts which I guess just get sent to the printer as graphics so escape codes aren't going to be applicable in that context.
0
 
LVL 21

Accepted Solution

by:
wyliecoyoteuk earned 125 total points
ID: 16988360
The control fonts may well be new, and limited to that model, as there seems to be no up to date version of the manual.
Escape codes are often embedded in PCL or Esc/2p pages, the ESC symbol is interpreted by the printer as a prefix to a command.
0
 

Author Comment

by:groovyjon
ID: 16995519
I have it sorted now - the solution was to spool raw text including the escape sequences rather than using TrueType fonts. Thanks wyliecoyoteuk, I owe you one!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to solve seemingly unsolvable printer issues. Users sometimes run into printing issues where all the normal steps do not seem to work. Well the steps below can show users how to take one extra step beyond the normal steps needed to remove old…
When I recently replaced my image transfer kit on my office HP color laserjet 5550dn printer, I had a slight problem.  The left bracket that holds the transfer kit got stuck in the upright locked position instead of being at a 45 degree angle facing…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question