public static GLFont fromFont(Font font){
  if (font == null)   throw new IllegalArgumentException("font may not be null");
  BufferedImage buffer=new BufferedImage(RASTER_DIM,RASTER_DIM,BufferedImage.TYPE_INT_ARGB);
  Graphics2D graphics=(Graphics2D)buffer.getGraphics();
  graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
  int off=0;
  int charsPerRow=12;
  for (char k=MIN_CH; k <= MAX_CH; k++, off++) {
    TextLayout layout=new TextLayout(String.valueOf(k),font,graphics.getFontRenderContext());
    Rectangle2D rect=layout.getBounds();
    int x=(off % charsPerRow) * (RASTER_DIM / charsPerRow);
    int y=(off / charsPerRow) * (RASTER_DIM / charsPerRow);
    float cy=(float)rect.getHeight();
    graphics.setColor(Color.WHITE);
    layout.draw(graphics,x,y - cy);
  }
  GLFontMetrics metric=GLFontMetrics.fromFontMetrics(font,graphics.getFontRenderContext(),RASTER_DIM,RASTER_DIM,charsPerRow,MIN_CH,MAX_CH);
  GLFont f0=fromBuffer(font.getFontName(),buffer,RASTER_DIM,RASTER_DIM,metric);
  return f0;
}

public static GLFont fromFont ( Font font ) { if ( font == null ) throw new IllegalArgumentException ( "font may not be null" ) ; BufferedImage buffer = new BufferedImage ( RASTER_DIM , RASTER_DIM , BufferedImage . TYPE_INT_ARGB ) ; Graphics2D graphics = ( Graphics2D ) buffer . getGraphics ( ) ; graphics . setRenderingHint ( RenderingHints . KEY_ANTIALIASING , RenderingHints . VALUE_ANTIALIAS_ON ) ; int off = 0 ; int charsPerRow = 12 ; for ( char k = MIN_CH ; k <= MAX_CH ; k ++ , off ++ ) { TextLayout layout = new TextLayout ( String . valueOf ( k ) , font , graphics . getFontRenderContext ( ) ) ; Rectangle2D rect = layout . getBounds ( ) ; int x = ( off % charsPerRow ) * ( RASTER_DIM / charsPerRow ) ; int y = ( off / charsPerRow ) * ( RASTER_DIM / charsPerRow ) ; float cy = ( float ) rect . getHeight ( ) ; graphics . setColor ( Color . WHITE ) ; layout . draw ( graphics , x , y - cy ) ; } GLFontMetrics metric = GLFontMetrics . fromFontMetrics ( font , graphics . getFontRenderContext ( ) , RASTER_DIM , RASTER_DIM , charsPerRow , MIN_CH , MAX_CH ) ; GLFont f0 = fromBuffer ( font . getFontName ( ) , buffer , RASTER_DIM , RASTER_DIM , metric ) ; return f0 ; }
create a glfont from a java font object
