# GlyphPage (Slick - The 2D Library)
Date: 2013-06-03

## org.newdawn.slick.font
Class GlyphPage

    java.lang.Object
      org.newdawn.slick.font.GlyphPage

    public class GlyphPage

extends java.lang.Object

Stores a number of glyphs on a single texture.

Author:
  Nathan Sweet <misc@n4te.com>

Field Summary
`static int` `MAX_GLYPH_SIZE` The maxium size of an individual glyph
`static java.awt.font.FontRenderContext` `renderContext` The render context in which the glyphs will be generated

Constructor Summary
`GlyphPage(UnicodeFont unicodeFont, int pageWidth, int pageHeight)` Create a new page of glyphs

Method Summary
`java.util.List` `getGlyphs()` Returns the glyphs stored on this page.
`Image` `getImage()` Returns the backing texture for this page.
`static java.awt.Graphics2D` `getScratchGraphics()` Get the scratch graphics used to generate the page of glyphs
`int` `loadGlyphs(java.util.List glyphs, int maxGlyphsToLoad)` Loads glyphs to the backing texture and sets the image on each loaded glyph.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### MAX_GLYPH_SIZE

    public static final int MAX_GLYPH_SIZE

  The maxium size of an individual glyph

  See Also:
    Constant Field Values

### renderContext

    public static java.awt.font.FontRenderContext renderContext

  The render context in which the glyphs will be generated

Constructor Detail

### GlyphPage

    public GlyphPage(UnicodeFont unicodeFont,
                     int pageWidth,
                     int pageHeight)
              throws SlickException

  Create a new page of glyphs

  Parameters:
    `unicodeFont` - The font this page forms part of
    `pageWidth` - The width of the backing texture.
    `pageHeight` - The height of the backing texture.
  Throws:
    `SlickException` - if the backing texture could not be created.

Method Detail

### getScratchGraphics

    public static java.awt.Graphics2D getScratchGraphics()

  Get the scratch graphics used to generate the page of glyphs

  Returns:
    The scratch graphics used to build the page

### loadGlyphs

    public int loadGlyphs(java.util.List glyphs,
                          int maxGlyphsToLoad)
                   throws SlickException

  Loads glyphs to the backing texture and sets the image on each loaded glyph. Loaded glyphs are removed from the list. If this page already has glyphs and maxGlyphsToLoad is -1, then this method will return 0 if all the new glyphs don't fit. This reduces texture binds when drawing since glyphs loaded at once are typically displayed together.

  Parameters:
    `glyphs` - The glyphs to load.
    `maxGlyphsToLoad` - This is the maximum number of glyphs to load from the list. Set to -1 to attempt to load all the glyphs.
  Returns:
    The number of glyphs that were actually loaded.
  Throws:
    `SlickException` - if the glyph could not be rendered.

### getGlyphs

    public java.util.List getGlyphs()

  Returns the glyphs stored on this page.

  Returns:
    A list of `Glyph` elements on this page

### getImage

    public Image getImage()

  Returns the backing texture for this page.

  Returns:
    The image of this page of glyphs

Copyright © 2006 New Dawn Software. All Rights Reserved.