harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ilya Okomin" <ilya.oko...@gmail.com>
Subject [classlib][awt] Fonts with negative size.
Date Fri, 22 Sep 2006 15:42:12 GMT
Hi, all!

I was playing with fonts and found that Font with negative size can be
created on RI.
 Unfortunately spec keep silence about fonts with negative sizes.
On Harmony if font size is negative then it is set to zero.

import java.awt.*;
import java.awt.font.FontRenderContext;

public class NegativeFontTest {

    public static void main(String[] args) {
        int fontsize=-5;
        Font localFont = new Font("Arial", 2, fontsize);
        System.out.println("Size = " + localFont.getSize2D());

        System.out.println("Height = " + localFont.getLineMetrics("", new
FontRenderContext(null, false, false)).getHeight());
        System.out.println("MaxCharBounds = " + localFont.getMaxCharBounds(new
FontRenderContext(null, false, false)));

If you run this test case on RI you can see that output looks quite strange:

Size = -5.0
Height = -5.7495117
MaxCharBounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=4.6081543,w=-5.46875

Actually, I dont see any sence in negative height and width metrics and
I think it is an RI bug.
If you try to draw text with such font on RI - nothing is happen, you can't
see any text on the component.
I've ran 'xfontsel' tool on Linux and there was suggested to choose only
positive sized fonts. Also I've looked on the GDI LOGFONT structure
description in MSDN and I've seen there again that we deal with absolute
height values.

Any thoughts on this issue, is it RI bug or not?


Ilya Okomin
Intel Middleware Products Division

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message