Class Font.GlyphRegion

java.lang.Object
com.badlogic.gdx.graphics.g2d.TextureRegion
com.github.tommyettinger.textra.Font.GlyphRegion
Enclosing class:
Font

public static class Font.GlyphRegion extends com.badlogic.gdx.graphics.g2d.TextureRegion
Describes the region of a glyph in a larger TextureRegion, carrying a little more info about the offsets that apply to where the glyph is rendered.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    float
    The offset from the left of the original image to the left of the packed image, after whitespace was removed for packing.
    float
    The offset from the bottom of the original image to the bottom of the packed image, after whitespace was removed for packing.
    float
    How far to move the "cursor" to the right after drawing this GlyphRegion.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GlyphRegion(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion atlasRegion)
    Creates a GlyphRegion from a parent TextureAtlas.AtlasRegion (almost always from an atlas).
    GlyphRegion(com.badlogic.gdx.graphics.g2d.TextureRegion textureRegion)
    Creates a GlyphRegion from a parent TextureRegion (typically from an atlas).
    GlyphRegion(com.badlogic.gdx.graphics.g2d.TextureRegion textureRegion, float offsetX, float offsetY, float xAdvance)
    Creates a GlyphRegion from a parent TextureRegion (typically from an atlas), along with any offsets to use for its x and y coordinates, and the amount of horizontal space to move over when this is drawn.
    GlyphRegion(com.badlogic.gdx.graphics.g2d.TextureRegion textureRegion, float x, float y, float width, float height)
    Creates a GlyphRegion from a parent TextureRegion (typically from an atlas), along with the lower-left x and y coordinates, the width, and the height of the GlyphRegion.
    Copies another GlyphRegion.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    flip(boolean x, boolean y)
    Flips the region, adjusting the offset so the image appears to be flipped as if no whitespace has been removed for packing.

    Methods inherited from class com.badlogic.gdx.graphics.g2d.TextureRegion

    getRegionHeight, getRegionWidth, getRegionX, getRegionY, getTexture, getU, getU2, getV, getV2, isFlipX, isFlipY, scroll, setRegion, setRegion, setRegion, setRegion, setRegion, setRegionHeight, setRegionWidth, setRegionX, setRegionY, setTexture, setU, setU2, setV, setV2, split, split

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • offsetX

      public float offsetX
      The offset from the left of the original image to the left of the packed image, after whitespace was removed for packing.
    • offsetY

      public float offsetY
      The offset from the bottom of the original image to the bottom of the packed image, after whitespace was removed for packing.
    • xAdvance

      public float xAdvance
      How far to move the "cursor" to the right after drawing this GlyphRegion. Uses the same unit as offsetX.
  • Constructor Details

    • GlyphRegion

      public GlyphRegion(com.badlogic.gdx.graphics.g2d.TextureRegion textureRegion)
      Creates a GlyphRegion from a parent TextureRegion (typically from an atlas). The resulting GlyphRegion will have 0 offsetX, 0 offsetY, and xAdvance equal to TextureRegion.getRegionWidth().
      Parameters:
      textureRegion - a TextureRegion to draw for this GlyphRegion, typically from a TextureAtlas
    • GlyphRegion

      public GlyphRegion(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion atlasRegion)
      Creates a GlyphRegion from a parent TextureAtlas.AtlasRegion (almost always from an atlas). The resulting GlyphRegion will have the same offsetX and offsetY as atlasRegion, and xAdvance equal to TextureAtlas.AtlasRegion.originalWidth.
      Parameters:
      atlasRegion - a TextureAtlas.AtlasRegion to draw for this GlyphRegion, typically from a TextureAtlas
    • GlyphRegion

      public GlyphRegion(com.badlogic.gdx.graphics.g2d.TextureRegion textureRegion, float offsetX, float offsetY, float xAdvance)
      Creates a GlyphRegion from a parent TextureRegion (typically from an atlas), along with any offsets to use for its x and y coordinates, and the amount of horizontal space to move over when this is drawn.
      Parameters:
      textureRegion - a TextureRegion to draw for this GlyphRegion, typically from a TextureAtlas
      offsetX - how many pixels to shift over the TextureRegion when drawn; positive is to the right
      offsetY - how many pixels to shift over the TextureRegion when drawn; positive is upwards
      xAdvance - how much horizontal space the GlyphRegion should use up when drawn
    • GlyphRegion

      public GlyphRegion(com.badlogic.gdx.graphics.g2d.TextureRegion textureRegion, float x, float y, float width, float height)
      Creates a GlyphRegion from a parent TextureRegion (typically from an atlas), along with the lower-left x and y coordinates, the width, and the height of the GlyphRegion.
      Parameters:
      textureRegion - a TextureRegion, typically from a TextureAtlas
      x - the x-coordinate of the left side of the texture, in pixels
      y - the y-coordinate of the lower side of the texture, in pixels
      width - the width of the GlyphRegion, in pixels
      height - the height of the GlyphRegion, in pixels
    • GlyphRegion

      public GlyphRegion(Font.GlyphRegion other)
      Copies another GlyphRegion.
      Parameters:
      other - the other GlyphRegion to copy
  • Method Details

    • flip

      public void flip(boolean x, boolean y)
      Flips the region, adjusting the offset so the image appears to be flipped as if no whitespace has been removed for packing.
      Overrides:
      flip in class com.badlogic.gdx.graphics.g2d.TextureRegion
      Parameters:
      x - true if this should flip x to be -x
      y - true if this should flip y to be -y