2d - printing - Font pagination

XMLWordPrintable

    • Type: Bug
    • Resolution: Won't Fix
    • Priority: P4
    • None
    • Affects Version/s: 6-pool
    • Component/s: 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);

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: