Solved

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

Posted on 2006-06-25
7
1,113 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
Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

 
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Causes of paper jams:The following are the main causes of paper jams. Guides:If the guides for the paper are not set correctly they may cause the paper to enter at an angle. You should ensure that the guides are set correctly for the paper type a…
Printers have changed substantially in the last 30 or so years, not just in technical capabilities but in cost and usage as well.  Printers were originally used for interfacing with the operator, not necessarily for printing copy or pictures. In …
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

690 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