Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

use "Draft 10cpi" font in printing?

843806Aug 20 2008 — edited Sep 8 2008
hi everyone,

i want to know how to change the font to "Draft 10cpi" to print to a printer. i am using Epson LX - 1050 a dot matrix printer. and font draft 10cpi is used because of its speed in printing.

i have done this.
public int print(Graphics g, PageFormat pf, int page) throws
                                                        PrinterException {

        if (page > 0) { /* We have only one page, and 'page' is zero-based */
            return NO_SUCH_PAGE;
        }

        /* User (0,0) is typically outside the imageable area, so we must
         * translate by the X and Y values in the PageFormat to avoid clipping
         */
        Graphics2D g2d = (Graphics2D)g;
        g2d.translate(pf.getImageableX(), pf.getImageableY());

        /* Now we perform our rendering */
        g.setFont(new Font("Draft 10cpi",Font.PLAIN,12));
        g.drawString("Hello world!", 100, 100);

        /* tell the caller that this page is part of the printed document */
        return PAGE_EXISTS;
    }
but it seems the result is not what i expected.
the font printed is not in Draft 10cpi.

please help...
thank you.

killuasoft
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 6 2008
Added on Aug 20 2008
11 comments
2,002 views