🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.api
6 messages
6 total messages Started by Alex Waller Fri, 07 Mar 2003 21:32
Trouble scaling rotated SansSerif Font in JDK 1.4.1
#720
Author: Alex Waller
Date: Fri, 07 Mar 2003 21:32
197 lines
7394 bytes
Hello,

    Earlier I've had problems posting to the comp.lang.java
newsgroup. I still haven't found an answer to my problem so I'm
reposting to comp.lang.java and borland.public.jbuilder in hopes that
someone can offer a solution to (or at least verify I'm not the only
one with) this problem. In frustration, I tried submitting this
as a bug report to Sun but after 3 tries using 2 different
browsers getting some kind of bad URL link after I pressed the
"submit" button, I return here in hopes that someone can help.
    Up until recently I've been using the JBuilder 7 1.3.1 JDK. I
downloaded Sun's JDK 1.4.1 and configured the JDK via the Tool menu
since we will have to use 1.4.1 at work. 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. I've also checked the Sun site and have
not seen any mention of this particular problem.
    All the 1.3.1 JDKs I tried 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.
    To summarize; I've verified that Borland 1.3.1 JDK on Windows,
Sun 1.3.1_07 on Windows, and Apple 1.3.1 JDK on the Mac all seem to work

the same and produce "acceptable" results when a window having rotated
text is resized to a long, narrow window. However the Sun version JDK
1.4.1_01 produces unacceptable results. So something "broke" with
version 1.4.1_01. Is this a known problem? Is there a workaround? Or
should I be now doing things differently?
    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.

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

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

/**
 * <p>Title: FontScalingProblem</p>
 * <p>Description: Minimal Demo of 1.4.1 Font Scaling Problem</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 Demo of 1.4.1 Font Scaling Problem</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
 {
  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: Trouble scaling rotated SansSerif Font in JDK 1.4.1
#721
Author: Lori M Olson (TeamB)
Date: Sat, 08 Mar 2003 20:32
43 lines
2875 bytes
Alex Waller wrote:
>     To summarize; I've verified that Borland 1.3.1 JDK on Windows,
> Sun 1.3.1_07 on Windows, and Apple 1.3.1 JDK on the Mac all seem to work
> 
> the same and produce "acceptable" results when a window having rotated
> text is resized to a long, narrow window. However the Sun version JDK
> 1.4.1_01 produces unacceptable results. So something "broke" with
> version 1.4.1_01. Is this a known problem? Is there a workaround? Or
> should I be now doing things differently?
>     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.
> 

Interesting.  The difference appears to be subtle, but makes a 
significant difference in readability when you really squish it.

I haven't seen this anywhere else.  I think you will have to try and 
submit it as a JDK bug.

-- 

Regards,

Lori Olson (TeamB)

------------

Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.

Google Advanced Newsgroup Search
	http://www.google.com/advanced_group_search
Other Newsgroup Searches:
	http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
	http://www.visi.com/~gyles19/fom-serve/cache/1.html
Re: Trouble scaling rotated SansSerif Font in JDK 1.4.1
#722
Author: John McGrath TeamB
Date: Sat, 08 Mar 2003 20:43
53 lines
3369 bytes
On Fri, 07 Mar 2003 15:32:15 -0600, Alex Waller wrote:

> Earlier I've had problems posting to the comp.lang.java
> newsgroup. I still haven't found an answer to my problem so
> I'm reposting to comp.lang.java and borland.public.jbuilder
> in hopes that someone can offer a solution to (or at least
> verify I'm not the only one with) this problem. 

Yes, I see the same thing.  Sorry, but I do not have a solution.

> In frustration, I tried submitting this as a bug report to
> Sun but after 3 tries using 2 different browsers getting some
> kind of bad URL link after I pressed the "submit" button, I
> return here in hopes that someone can help.

Are you referring to the Sun Bug Parade?  If so, there may have been 
some temporary problem.  I have submitted quite a few bugs and RFEs 
there over the years and it has always worked for me.

One comment on the problem statement / program:  I think you will have 
much better luck if you do not ask the person checking it out to "make 
the window long and narrow and watch what happens".  The problem is 
that it renders the font badly in some particular cases, so your 
program should show one (or more) of those cases.  

You should not ask the bug reviewer to find the problem case.  That is 
very likely to lead to a "cannot reproduce" response.  Remember that 
the vast majority of bugs reported are not bugs, so he will be looking 
at it with the preconception that there is no bug.  You have to hit the 
guy in the face with the problem so he cannot miss it.

Just find some scaling factors that cause the problem and hard-code 
them.  Don't make it dependent on the window size.  That way when 
someone runs the program, the first thing they see will be the problem.

It would also be a good idea to merge the code into a single file and 
make it as short as possible.  Things like @version tags and unused 
code to pack() the frame just get in the way.  The idea is to make it 
as simple as possible to build the program and see the problem.

> To summarize; I've verified that Borland 1.3.1 JDK on Windows,

Just to be clear, there is no such thing as the "Borland JDK".  That is 
the Sun JDK 1.3.1.

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Re: Trouble scaling rotated SansSerif Font in JDK 1.4.1
#723
Author: Alex Waller
Date: Mon, 10 Mar 2003 17:37
64 lines
4061 bytes
Hi,

    Thanks for the quick reply. Even though you didn't offer an anwser it is
good to know that I'm not the only one seeing this problem. After all one of
the many variables may have been how I have my environment set up!
    Unfortunately I've tried several times to submit this as a bug report ala
the "submit bug!" link near the bottom of the Sun "Bug Parade" page but with
no luck. I'm able to navigate to the bug form, fill it out, and then hit
"submit" on the bottom of the forms page. After I hit submit it returns
*immediately* with a "Sorry! We couldn't find your document. The URL you
requested could not be found on this server. If you got this URL from a book
or a reffering link, it may be outdated and has been replaced. If you provided
the URL ....". I don't know what that might mean since I didn't provide *any*
URL ... all I did was press the "submit" button. BTW, I've informed the Sun
webmaster each time this occurred. Once I got a reply with a link to try. I
tried it ... same results. I've tried submitting the bug report via Netscape
4.77 browser and the IE 6.0.2600 browser. But I diverge from the content of
this newsgroup. Thanks!

"Lori M Olson (TeamB)" wrote:

> Alex Waller wrote:
> >     To summarize; I've verified that Borland 1.3.1 JDK on Windows,
> > Sun 1.3.1_07 on Windows, and Apple 1.3.1 JDK on the Mac all seem to work
> >
> > the same and produce "acceptable" results when a window having rotated
> > text is resized to a long, narrow window. However the Sun version JDK
> > 1.4.1_01 produces unacceptable results. So something "broke" with
> > version 1.4.1_01. Is this a known problem? Is there a workaround? Or
> > should I be now doing things differently?
> >     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.
> >
>
> Interesting.  The difference appears to be subtle, but makes a
> significant difference in readability when you really squish it.
>
> I haven't seen this anywhere else.  I think you will have to try and
> submit it as a JDK bug.
>
> --
>
> Regards,
>
> Lori Olson (TeamB)
>
> ------------
>
> Save yourself, and everyone else, some time and search the
> newsgroups and the FAQ-O-Matic before posting your next
> question.
>
> Google Advanced Newsgroup Search
>         http://www.google.com/advanced_group_search
> Other Newsgroup Searches:
>         http://www.borland.com/newsgroups/ngsearch.html
> Joi Ellis's FAQ-O-Matic:
>         http://www.visi.com/~gyles19/fom-serve/cache/1.html
Re: Trouble scaling rotated SansSerif Font in JDK 1.4.1
#724
Author: Alex Waller
Date: Mon, 10 Mar 2003 17:46
40 lines
2900 bytes

"John McGrath [TeamB]" wrote:

> On Fri, 07 Mar 2003 15:32:15 -0600, Alex Waller wrote:
>
> > Earlier I've had problems posting to the comp.lang.java
> > newsgroup. I still haven't found an answer to my problem so
> > I'm reposting to comp.lang.java and borland.public.jbuilder
> > in hopes that someone can offer a solution to (or at least
> > verify I'm not the only one with) this problem.
>
> Yes, I see the same thing.  Sorry, but I do not have a solution.
>

    Thanks John, just having others able to reproduce it without difficulty
goes a long way.

> > In frustration, I tried submitting this as a bug report to
> > Sun but after 3 tries using 2 different browsers getting some
> > kind of bad URL link after I pressed the "submit" button, I
> > return here in hopes that someone can help.
>
> Are you referring to the Sun Bug Parade?  If so, there may have been
> some temporary problem.  I have submitted quite a few bugs and RFEs
> there over the years and it has always worked for me.
>
> One comment on the problem statement / program:  I think you will have
> much better luck if you do not ask the person checking it out to "make
> the window long and narrow and watch what happens".  The problem is
> that it renders the font badly in some particular cases, so your
> program should show one (or more) of those cases.

    Thanks for the advice. I've no experience with submitting "demo code"
so this is a good thing to keep in mind. I just quickly tapped out the
problem via JBuilder and just basically "cut and pasted" my code (with a
couple of edits ... like the copyright statement). As for submitting as a
bug report. I replied to a previous post about that but yeah I used the
link near the bottom of the Bug Parade page that says "submit a bug!". No
luck on three tries. But I digress. Thanks.
Re: Trouble scaling rotated SansSerif Font in JDK 1.4.1
#725
Author: John McGrath TeamB
Date: Tue, 11 Mar 2003 04:06
43 lines
2877 bytes
On Mon, 10 Mar 2003 11:46:12 -0600, Alex Waller wrote:

> Thanks for the advice. I've no experience with submitting 
> "demo code" so this is a good thing to keep in mind. I just
> quickly tapped out the problem via JBuilder and just basically
> "cut and pasted" my code (with a couple of edits ... like the
> copyright statement). 

I'm afraid my comments do not always come across the way I want them 
to.  Just to be clear, you posted a runnable example of the problem, 
which in itself makes it better than the vast majority of the problem 
reports that I see.  I guess it is my nature: whenever I see very good, 
I look toward making it perfect.  :o)

> As for submitting as a bug report. I replied to a previous post
> about that but yeah I used the link near the bottom of the Bug
> Parade page that says "submit a bug!". No luck on three tries.

At times, Sun has been very quick processing bug reports and at other 
times they have been awful.  

In the worst case I ever saw, I submitted a report and forgot about it.  
Over two years later I got an email message saying that some reports 
had gotten waylaid and they wanted to know if I thought it was still 
relevant.

The best time I ever saw was once when I submitted a bug against an RC 
version of the JDK just before the FCS release, and it was processed in 
just a few days.  I imagine they review all bugs submitted against 
release candidates before they give the go-ahead for the release.

If the bug report does not show up on the Bug Parade, you probably 
should just give it time.  Submitting a duplicate will not help, and it 
will just slow Sun down.

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
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