Hi,

I worked around this problem by writing a short function that returns something 
usable.  It is better than returning an empty array, but not a solution to the 
problem.  Essentially, the java spec states that some basic font objects should 
be built into Java independently of the host operating system, and this can be 
taken advantage of:

    /*
    buildFontList constructs a list of fonts that is available indepenently
    of the host operating system per the Java specification.  
    This is needed for GCJ 4.1, which does not implement getAllFonts().

    Usage description of the relevant Font members follows:

    Font f;
    f = new Font(String name, int style, int size);
    Where:
      o name is "Serif", "SansSerif", "Monospaced", or a font on the system.
      o style is Font.PLAIN. Font.BOLD, Font.ITALIC, or Font.BOLD+Font.ITALIC.
      o size is the point size, typically in the range 8-48.
    */
    private Font[] buildFontList(int pointSize) {
        Font[] list = new Font[12];

        list[0] = new Font("Serif", Font.PLAIN, pointSize);
        list[1] = new Font("Serif", Font.BOLD, pointSize);
        list[2] = new Font("Serif", Font.ITALIC, pointSize);
        list[3] = new Font("Serif", Font.BOLD+Font.ITALIC, pointSize);
        list[4] = new Font("SansSerif", Font.PLAIN, pointSize);
        list[5] = new Font("SansSerif", Font.BOLD, pointSize);
        list[6] = new Font("SansSerif", Font.ITALIC, pointSize);
        list[7] = new Font("SansSerif", Font.BOLD+Font.ITALIC, pointSize);
        list[8] = new Font("Monospaced", Font.PLAIN, pointSize);
        list[9] = new Font("Monospaced", Font.BOLD, pointSize);
        list[10] = new Font("Monospaced", Font.ITALIC, pointSize);
        list[11] = new Font("Monospaced", Font.BOLD+Font.ITALIC, pointSize);
        return list;
    }

While this is really a hack to get my program running, it could replace 
getAllFonts() until something better is written.  At least then people will 
have a small selection of Font objects available that they can work with.

-Mike

On Mon, 29 May 2006 12:25:02 +0200
Mark Wielaard <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> On Wed, 2006-05-24 at 16:05 -0700, David Daney wrote:
> > Michael Mohr wrote:
> > > On Wed, 24 May 2006 10:26:05 -0700
> > > David Daney <[EMAIL PROTECTED]> wrote:
> > >>Michael Mohr wrote:
> > >>>I'm currently attempting to use GCC 4.1's gcj to compile a medium-sized 
> > >>>(6000-line) java application.  Unfortunately, it requires raw access to 
> > >>>serial ports, as implemented by RXTX.  It appears that RXTX has already 
> > >>>been modified to compile using CNI; however, the port appears to be in 
> > >>>early alpha stage.
> > >>>
> > >>>I am able to compile RXTX (mostly) without complaint.  I am also able to 
> > >>>compile my application -- GPSExplorer -- with no warnings or errors 
> > >>>using GCC 4.1.  However, it exits when run with the following exception:
> > >>>
> > >>>Exception in thread "main" java.lang.UnsupportedOperationException
> > >>>   at gnu.java.awt.peer.gtk.GdkGraphicsEnvironment.getAllFonts 
> > >>> (lib-gnu-java-awt-peer-gtk.so)
> > >>>   at GPSExplorer.<init> (GPSExplorer)
> > >>>   at GPSExplorer.main (GPSExplorer)
> > >>
> > >>Looks like GraphicsEnvironment.getAllFonts() is not supported by your 
> > >>libgcj.
> > > 
> > > Okay.  Is there a person who I could contact that is working on related 
> > > classes?  I'd be happy to lend a hand, at least in regards to 
> > > implementing functions missing from my own application.
> >
> > The classpath project is the source of the culpable code.  See 
> > http://www.gnu.org/software/classpath/
> 
> I added a bug report for this:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27792
> 
> Meanwhile could you try if just returning an empty array from that
> method helps you for now? It is probably more friendly to just claim we
> don't support any fonts then throwing an exception.
> 
> Cheers,
> 
> Mark
> 

Reply via email to