Accessing default printer font

Posted on 1998-09-28
Last Modified: 2013-12-02
This seems a bit silly, but I can't get it to work.

How do I print using the default printer font? Whenever I print using Delphi, it switches to the default windows printer font, or the font I set it to in the printer.canvas.font method, etc. Even when I use the assignprn(textfile) method, it switches the font... All I want is a dump in the default printer font.

The reason? The default font uses the old PC-8 character set. I'm trying to use an old piece of code that has boxes around the text for a report. Setting the printer.font and printer.charset doesn't seem to work. I can set the charset to ansi, but not to the old IBM PC-8 characterset, even though the printer has that set.
Question by:oneeye
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

Accepted Solution

ronit051397 earned 50 total points
ID: 1340997
This is from Borland documents


Instead of printing graphics, how can I get TPrinter to use the default resident font in the printer?


            Use the Windows API function GetStockObject() to retrieve the
            device default font handle, and assign it to Printer.Font.Handle.


            uses Printers;

            procedure TForm1.Button1Click(Sender: TObject);
              tm : TTextMetric;
              i : integer;
              if PrintDialog1.Execute then begin
                Printer.Canvas.Font.Handle := GetStockObject(DEVICE_DEFAULT_FONT);
                GetTextMetrics(Printer.Canvas.Handle, tm);
                for i := 1 to 10 do begin
                                         i * tm.tmHeight +


Author Comment

ID: 1340998
Ah, very good. One place I forgot to check.

I am much obliged.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

738 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