Java Forum / GUI / September 2005
Render Fonts smoothly...
SPG - 30 Jun 2005 16:12 GMT Hi,
I am trying to draw a string onto an image as smoothly as possible. The problem is that I am streching the font a little to fit my area fully..
AffineTransform fontTransform = new AffineTransform(); fontTransform.scale( xScale , yScale); Font f = myFont.deriveFont(fontTransform);
g.setFont(f); Graphics2D g2d = (Graphics2D)g; g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2d.drawString(x,y,"Hello");
This works a little but the antialiasing seems to be a bit heavy and the rendered string looks a bit strange. Is there another/better way to do this?
Steve
SPG - 01 Jul 2005 11:53 GMT All,
I have made a copy of two screen shots.. One from a C++ app, and the other from my java applet. As you can see, the C++ app renders the font nicely, and ther eis not fading of colours, whereas the java applet seems to fade the colours where antialiasing is occuring..
http://www.thegster.pwp.blueyonder.co.uk/terminal/
I know that antialiasing does feather the edges of a line, but it seems to have really made the original green colour quite dim.
Any thoughts?
Steve
Boudewijn Dijkstra - 01 Jul 2005 23:32 GMT > All, > [quoted text clipped - 8 lines] > I know that antialiasing does feather the edges of a line, but it seems to > have really made the original green colour quite dim. Note that the C++ app does absolutely no anti-aliasing or smoothing. It looks just like a bitmapped font.
The dimming effect that you see, is because Java actually tried to smooth the graphics. But it doesn't look too good because green is a bright colour to the human eye. What you can do is increase the gamma adjust of your monitor or pull the image through a gamma-increasing filter.
SPG - 08 Jul 2005 16:30 GMT >> All, >> [quoted text clipped - 16 lines] > colour to the human eye. What you can do is increase the gamma adjust of > your monitor or pull the image through a gamma-increasing filter. Hi,
Interesting response. I will have a go with the Gamma Increasing filter (if I could find out what one is first ;) )
Thanks for the help, I'll post back with results..
Steve
Roedy Green - 29 Aug 2005 08:36 GMT >Interesting response. I will have a go with the Gamma Increasing filter (if >I could find out what one is first ;) ) it is not as terrifying as it sounds. See http://mindprod.com/jgloss/gamma.html
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Again taking new Java programming contracts.
Boudewijn Dijkstra - 29 Aug 2005 20:16 GMT >>Interesting response. I will have a go with the Gamma Increasing filter (if >>I could find out what one is first ;) ) > > it is not as terrifying as it sounds. See > http://mindprod.com/jgloss/gamma.html This only explains what happens to the image, not how the actual operation is performed in a computational sense. I don't see how it could possibly reduce any terrifiedness on Mr. Steve's side.
Roedy Green - 29 Aug 2005 23:03 GMT >> it is not as terrifying as it sounds. See >> http://mindprod.com/jgloss/gamma.html > >This only explains what happens to the image, not how the actual operation is >performed in a computational sense. I don't see how it could possibly reduce >any terrifiedness on Mr. Steve's side. Follow the main link once you get there, the one in green. It shows the computation.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Again taking new Java programming contracts.
Boudewijn Dijkstra - 30 Aug 2005 12:31 GMT >>> it is not as terrifying as it sounds. See >>> http://mindprod.com/jgloss/gamma.html [quoted text clipped - 5 lines] > Follow the main link once you get there, the one in green. It shows > the computation. Thanks. Although this 'main link' concept may be clear to regular visitors of your glossary, others might fail to grasp it directly, as I have.
Roedy Green - 02 Sep 2005 08:43 GMT >Thanks. Although this 'main link' concept may be clear to regular visitors of >your glossary, others might fail to grasp it directly, as I have. You are not the first person to miss it. It is underlined, green, bold. I can't think of anything else to do to make it clear it is the most important link. I figured perhaps I should duplicate that link at the bottom, perhaps with some special highlighting.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Again taking new Java programming contracts.
Boudewijn Dijkstra - 02 Sep 2005 22:18 GMT >>Thanks. Although this 'main link' concept may be clear to regular visitors >>of your glossary, others might fail to grasp it directly, as I have. [quoted text clipped - 3 lines] > most important link. I figured perhaps I should duplicate that link > at the bottom, perhaps with some special highlighting. The link doesn't appear where I would expect a link. It looks like a title; which is confirmed by the greenness and boldness in the line above the 'title'.
BTW, Wikipedia has an icon for external links.
BTBTW, have you noticed the word 'partos' in the glossary text?
Roedy Green - 07 Sep 2005 09:04 GMT >BTBTW, have you noticed the word 'partos' in the glossary text? I don't know what you are referring to.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Again taking new Java programming contracts.
Boudewijn Dijkstra - 07 Sep 2005 16:39 GMT >>BTBTW, have you noticed the word 'partos' in the glossary text? > > I don't know what you are referring to. Never mind, it's gone now.
Roedy Green - 07 Sep 2005 09:37 GMT >BTW, Wikipedia has an icon for external links I have added the wikiPedia offsite icon on all the external <DT> links, but I could not figure out how to add it to all external body links without using CSS3 which only Mozilla supports, or without manually finding and tagging them all.
That will clue in WikiPediaophiles there is a link. I hope the underline catches the rest.
The WikiPedia people seem to have a trick for doing it, but their style sheet is hidden behind a veil of PHP CDATA and other mumbo jumbo.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Again taking new Java programming contracts.
Roedy Green - 07 Sep 2005 10:23 GMT >The WikiPedia people seem to have a trick for doing it, but their >style sheet is hidden behind a veil of PHP CDATA and other mumbo >jumbo. I double checked. Wikipedia do it the long-winded way labelling every external link with class="external".
I suppose I could do the same thing, use a regex to find all such links in the bodies and add the class. I think though the only serious problem was the the DT links being ignored.
We will see how this goes with people discovering links that have been there for years.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Again taking new Java programming contracts.
Roland - 02 Jul 2005 00:04 GMT > All, > [quoted text clipped - 12 lines] > > Steve It might also be the result of the AffineTransform to derive the scaled font (shown in the code snippet of your original message). In particular when xScale and/or yScale aren't integral values (e.g. 2.1 rather than 2.0).
Q: what are the values of xScale/yScale when you run your applet?
You could try without the AffineTransform or applying an AffineTransform that scales the font using integral values. It would also be interesting if you could show a screenshot with anti-aliasing disabled.
 Signature Regards,
Roland de Ruiter ` ___ ___ `/__/ w_/ /__/ / \ /_/ / \
SPG - 08 Jul 2005 16:33 GMT >> All, >> [quoted text clipped - 23 lines] > that scales the font using integral values. It would also be interesting > if you could show a screenshot with anti-aliasing disabled. Hi Roland,
The x and y scale values differ based on the *new* size of the screen. I keep a ref tot he previous size and work out how much it has grown..
int xScale = bounds.width / prevBounds.width;
The values could be anything, but an average seems to be between 0.5 to 1.5.. The idea is to rescale the font so I can properly fill the screen.
Steve
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|