Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6985549

2d - printing - Font pagination

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 6-pool
    • docs
    • generic
    • generic

      In the sample printing example "PaginationExample.java" referenced here:

      http://download.oracle.com/javase/tutorial/2d/printing/set.html

      with source code here:

      http://download.oracle.com/javase/tutorial/2d/printing/examples/PaginationExample.java

      You are creating a Font, and obtaining metrics on that Font, which affects the pagination of the printed output, but you do not actually *set* the Font on the Graphics context.

      You may have been making an assumption on the default Font, but that assumption will not always be correct; it's certainly not when running this example on Mac OS.

      The fix is simple. In the print() method, simply add

      g.setFont(font);

      before you call drawString().

      Perhaps right after you create the font:

              Font font = new Font("Serif", Font.PLAIN, 10);
              g.setFont(font);

            Unassigned Unassigned
            skannan Sowmya Kannan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: