Solved

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

Posted on 2006-06-25
7
1,099 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
  • 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

If you use a Brother DCP 130C or similar Brother printer, at some point you might encounter the following problem: after you change the ink cartridge, the printer displays an "ink empty" message. Sometimes you just need to follow the instructions…
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 …
This video discusses moving either the default database or any database to a new volume.
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now