🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.api
5 messages
5 total messages Started by Alex Waller Thu, 27 Feb 2003 23:07
Font Scaling problem on rotation with JDK 1.4.1
#707
Author: Alex Waller
Date: Thu, 27 Feb 2003 23:07
200 lines
7298 bytes
Hello,

    I realized that I posted this to the wrong newsgroup. It is better
suited for the  API newsgroup ... more specifally Graphics2D.

    I'm using JBuilder 7 Personal Edition on a Windows 2K system. Up
until recently I've been using the JBuilder 1.3.1 JDK. I down loaded
Sun's JDK 1.4.1 and configured the JDK via the Tool menu. I've
discovered a big difference in the way rotated text gets scaled. I've
tried searching the Borland archives but have not found anything
pertaining to this particular problem with fonts.
    The 1.3.1 JDK seems to do a much better job at rendering rotated
text when one makes a window (or panel) long and narrow (the text looks
stretched but not ugly). I have some plotting code which can create
several (plot) panels on a window and this long, narrow plot can be
exactly my situation. The rotated text is the Y-axis label. The 1.4.1
JDK from Sun does not seem to scale very nicely at all. There sometimes
are large gaps between characters in words. Sometimes single characters
within words are much larger than others. Sometimes (depending on how
the panel gets sized) the letters turn out all blotchy. Really ugly.
I've also checked the Sun site and have not seen any mention of this
problem.
    Last evening I tried this on my Macintosh at home. Here we have
another non Sun 1.3.1 JDK but on a different platform. It worked pretty
much like the Borland 1.3.1 JDK on the Windows platform at work. (A nit
picking difference has to do with improper clipping of the text on the
Mac platform with my test program but I'm not worried right now about
that problem on the Mac.)
    Some extra added info that might help. It seems to be associated
with the screen rendering of fonts. A plot procedure that I have can
print several (plot) panels (JPanel) that are in a window to a single
page. The rotated fonts seem to come out OK on the printer under JDK
1.4.1 (again they looked stretched out but not illegible).
    I include source code below which demonstrates this problem. After
the window is displayed make the window long and narrow and watch what
happens to the rotated (Y-axis) text.
    ... or this all work OK for others??

    -Thanks in advance, Alex Waller
/*
   FontScalingProblem.java
*/
package fontscalingproblem;

import javax.swing.UIManager;
import java.awt.*;

/**
 * <p>Title: FontScalingProblem</p>
 * <p>Description: Minimal Demonstration of JDK 1.4.1 Font Scaling
Problem</p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author A. M. Waller
 * @version 1.0
 */

public class FontScalingProblem
{
  private boolean packFrame = false;

  //Construct the application
  public FontScalingProblem()
  {
    Frame1 frame = new Frame1();
    //Validate frames that have preset sizes
    //Pack frames that have useful preferred size info, e.g. from their
layout
    if (packFrame)
    {
      frame.pack();
    }
    else
    {
      frame.validate();
    }
    //Center the window
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = frame.getSize();
    if (frameSize.height > screenSize.height)
    {
      frameSize.height = screenSize.height;
    }
    if (frameSize.width > screenSize.width)
    {
      frameSize.width = screenSize.width;
    }
    frame.setLocation((screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
    frame.setVisible(true);
  }
  //Main method
  public static void main(String[] args)
  {
    try
    {

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
    new FontScalingProblem();
  }
}
/*
   Frame1.java
*/
package fontscalingproblem;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * <p>Title: FontScalingProblem</p>
 * <p>Description: Minimal Demonstration of JDK 1.4.1 Font Scaling
Problem</p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author A. M. Waller
 * @version 1.0
 */

public class Frame1 extends JFrame
{
  private JPanel contentPane;
  private BorderLayout borderLayout1 = new BorderLayout();

  private static final int LABEL_PT_BASE = 36;
  private static final int windowWidth = 850, windowHeight = 850;
  private static final Font labelFont = new Font( "SansSerif",
Font.PLAIN, LABEL_PT_BASE );
  private double baseWidth, baseHeight;

  //Construct the frame
  public Frame1()
  {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try
    {
      jbInit();
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
  //Component initialization
  private void jbInit() throws Exception
  {

//setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your

Icon]")));
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(borderLayout1);
    baseWidth = windowWidth; baseHeight = windowHeight;
    this.setSize(new Dimension(windowWidth, windowHeight));
    this.setTitle("Font Rotation and Scaling Problem");
  }
  //Overridden so we can exit when window is closed
  protected void processWindowEvent(WindowEvent e)
  {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING)
    {
      System.exit(0);
    }
  }

  public void paint( Graphics g )
  {
    double xScale, yScale;

    super.paint( g );

    Dimension windowSize = this.getSize();
    Graphics2D g2d = (Graphics2D)g;
// Antialias text. Is fractional metrics necessary?
    g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
// Set current scale from original base setting
    xScale = windowSize.width / baseWidth; yScale = windowSize.height /
baseHeight;
    g2d.scale( xScale, yScale );
// Set font
    g2d.setFont( labelFont );
    g2d.drawString( "A quick Brown Fox jumped over the lazy Dog.", 75,
800 );
// Rotate -90 degrees (Y axis label)
    g2d.rotate( Math.toRadians( 270 ) );
    g2d.drawString( "A quick Brown Fox jumped over the lazy Dog.", -800,

75 );
  }
}
Re: Font Scaling problem on rotation with JDK 1.4.1
#708
Author: Nieva
Date: Fri, 28 Feb 2003 14:14
51 lines
3719 bytes
Hi,
 yeaj seem to come from a FontRasterizer trouble...

Obviously the MRJ use Quartz, which have its own native rasterizer
(providing real and complete aliasing corection tnx to Quartz Extreme ).

By the way did you tried with agile2D (OpenGL Renderer for Java2D) plugged ?
http://www.cs.umd.edu/hcil/agile2d/

-SLK

"Alex Waller" <waller@fnal.gov> a �crit dans le message de news:
3E5E9A3D.579AEE93@fnal.gov...
> Hello,
>
>     I realized that I posted this to the wrong newsgroup. It is better
> suited for the  API newsgroup ... more specifally Graphics2D.
>
>     I'm using JBuilder 7 Personal Edition on a Windows 2K system. Up
> until recently I've been using the JBuilder 1.3.1 JDK. I down loaded
> Sun's JDK 1.4.1 and configured the JDK via the Tool menu. I've
> discovered a big difference in the way rotated text gets scaled. I've
> tried searching the Borland archives but have not found anything
> pertaining to this particular problem with fonts.
>     The 1.3.1 JDK seems to do a much better job at rendering rotated
> text when one makes a window (or panel) long and narrow (the text looks
> stretched but not ugly). I have some plotting code which can create
> several (plot) panels on a window and this long, narrow plot can be
> exactly my situation. The rotated text is the Y-axis label. The 1.4.1
> JDK from Sun does not seem to scale very nicely at all. There sometimes
> are large gaps between characters in words. Sometimes single characters
> within words are much larger than others. Sometimes (depending on how
> the panel gets sized) the letters turn out all blotchy. Really ugly.
> I've also checked the Sun site and have not seen any mention of this
> problem.
>     Last evening I tried this on my Macintosh at home. Here we have
> another non Sun 1.3.1 JDK but on a different platform. It worked pretty
> much like the Borland 1.3.1 JDK on the Windows platform at work. (A nit
> picking difference has to do with improper clipping of the text on the
> Mac platform with my test program but I'm not worried right now about
> that problem on the Mac.)
>     Some extra added info that might help. It seems to be associated
> with the screen rendering of fonts. A plot procedure that I have can
> print several (plot) panels (JPanel) that are in a window to a single
> page. The rotated fonts seem to come out OK on the printer under JDK
> 1.4.1 (again they looked stretched out but not illegible).
>     I include source code below which demonstrates this problem. After
> the window is displayed make the window long and narrow and watch what
> happens to the rotated (Y-axis) text.
>     ... or this all work OK for others??
>
Re: Font Scaling problem on rotation with JDK 1.4.1
#709
Author: Alex Waller
Date: Fri, 28 Feb 2003 16:27
64 lines
4502 bytes
Hello,
    Thanks for the Agile2D lead. I'll look into that but this doesn't really
help my situation. That situation being that where I am working all applications
produced will be using the "standard" Sun Java2D and 1.4.1_01 on a Windows
platform. This is why I moved over (or at least I'm trying to move over) to
1.4.1 from the Borland 1.3.1 JDK that I originally developed on. To me it looks
like the graphics "performance" improvements Sun has put into the Java2D with
1.4.1 have "broken" what use to work nicely for me in 1.3.1. I was looking for
some possible work around. I've tried sending this mail to comp.lang.java.help
but I cann't seem to get my message posted there.

Nieva wrote:

> Hi,
>  yeaj seem to come from a FontRasterizer trouble...
>
> Obviously the MRJ use Quartz, which have its own native rasterizer
> (providing real and complete aliasing corection tnx to Quartz Extreme ).
>
> By the way did you tried with agile2D (OpenGL Renderer for Java2D) plugged ?
> http://www.cs.umd.edu/hcil/agile2d/
>
> -SLK
>
> "Alex Waller" <waller@fnal.gov> a �crit dans le message de news:
> 3E5E9A3D.579AEE93@fnal.gov...
> > Hello,
> >
> >     I realized that I posted this to the wrong newsgroup. It is better
> > suited for the  API newsgroup ... more specifally Graphics2D.
> >
> >     I'm using JBuilder 7 Personal Edition on a Windows 2K system. Up
> > until recently I've been using the JBuilder 1.3.1 JDK. I down loaded
> > Sun's JDK 1.4.1 and configured the JDK via the Tool menu. I've
> > discovered a big difference in the way rotated text gets scaled. I've
> > tried searching the Borland archives but have not found anything
> > pertaining to this particular problem with fonts.
> >     The 1.3.1 JDK seems to do a much better job at rendering rotated
> > text when one makes a window (or panel) long and narrow (the text looks
> > stretched but not ugly). I have some plotting code which can create
> > several (plot) panels on a window and this long, narrow plot can be
> > exactly my situation. The rotated text is the Y-axis label. The 1.4.1
> > JDK from Sun does not seem to scale very nicely at all. There sometimes
> > are large gaps between characters in words. Sometimes single characters
> > within words are much larger than others. Sometimes (depending on how
> > the panel gets sized) the letters turn out all blotchy. Really ugly.
> > I've also checked the Sun site and have not seen any mention of this
> > problem.
> >     Last evening I tried this on my Macintosh at home. Here we have
> > another non Sun 1.3.1 JDK but on a different platform. It worked pretty
> > much like the Borland 1.3.1 JDK on the Windows platform at work. (A nit
> > picking difference has to do with improper clipping of the text on the
> > Mac platform with my test program but I'm not worried right now about
> > that problem on the Mac.)
> >     Some extra added info that might help. It seems to be associated
> > with the screen rendering of fonts. A plot procedure that I have can
> > print several (plot) panels (JPanel) that are in a window to a single
> > page. The rotated fonts seem to come out OK on the printer under JDK
> > 1.4.1 (again they looked stretched out but not illegible).
> >     I include source code below which demonstrates this problem. After
> > the window is displayed make the window long and narrow and watch what
> > happens to the rotated (Y-axis) text.
> >     ... or this all work OK for others??
> >
Re: Font Scaling problem on rotation with JDK 1.4.1
#710
Author: Shankar Unni
Date: Fri, 28 Feb 2003 18:46
11 lines
1615 bytes
Alex Waller wrote:

>     I realized that I posted this to the wrong newsgroup. It is better
> suited for the  API newsgroup ... more specifally Graphics2D.

There definitely seems to be a problem. Disabling 2D acceleration with 
-Dsun.java2d.noddraw=true makes no difference.

I encourage you to visit http://developer.java.sun.com and post a bug 
report with the test case.  (Better shorten all your lines to 72 chars 
or less if possible).
Re: Font Scaling problem on rotation with JDK 1.4.1
#711
Author: Alex Waller
Date: Fri, 28 Feb 2003 19:47
26 lines
2221 bytes
Hi,

    I re-installed the old JDK 1.3.1_07 today just to verify that the
Borland and Apple versions of JDK 1.3.1 were not the exceptions to the rule.
The old Sun JDK 1.3.1 works. Unless some one can explain why it doesn't work
with JDK 1.4.1 or what needs to be done with JDK 1.4.1 this looks like a
good candidate for a bug report. What surprises me most is that this was not
caught early on by Sun themselves and even more amazingly has not been
reported by any users (at least I didn't see anything or was able to find
anything pertaining to this problem when searching the Sun bug reports).

    Thanks, Alex

Shankar Unni wrote:

> Alex Waller wrote:
>
> >     I realized that I posted this to the wrong newsgroup. It is better
> > suited for the  API newsgroup ... more specifally Graphics2D.
>
> There definitely seems to be a problem. Disabling 2D acceleration with
> -Dsun.java2d.noddraw=true makes no difference.
>
> I encourage you to visit http://developer.java.sun.com and post a bug
> report with the test case.  (Better shorten all your lines to 72 chars
> or less if possible).
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads