Class Glyph

java.lang.Object
icyllis.arc3d.sketch.Glyph

public final class Glyph extends Object
Represents a CPU glyph + digest information for GPU drawing, managed by Strike.

GlyphID is represented as an int value. For TrueType/OpenType fonts, glyph ID (or glyph index) is a 16-bit unsigned int. For composite fonts (mapping a logical font to a set of physical fonts) in JDK, the slot index is stored in the higher 8 bits, then the 16-24 bits is reserved.

Another form of GlyphID is PackedGlyphID, which is also represented by an int value. It stores sub-pixel information based on the GlyphID. We use bit 22 and bit 23 to represent the sub-pixel X positions of glyph rendering at 0.0, 0.25, 0.5, and 0.75 in the horizontal direction.

If sub-pixel positioning is not required, then GlyphID and PackedGlyphID are interchangeable.

  • 0-16 bits: glyph index
  • 16-22 bits: reserved
  • 22-24 bits: sub-pixel X position
  • 24-32 bits: slot index
  • Field Details

  • Constructor Details

    • Glyph

      public Glyph(int id)
  • Method Details

    • packGlyphID

      public static int packGlyphID(int glyphID, float xPos, int mask)
    • getGlyphID

      public static int getGlyphID(int packedID)
    • getSubX

      public static float getSubX(int packedID)
    • getGlyphID

      public int getGlyphID()
    • getPackedID

      public int getPackedID()
    • getSubX

      public float getSubX()
    • getLeft

      public int getLeft()
      The bearing X.
    • getTop

      public int getTop()
      The bearing Y.
    • getWidth

      public int getWidth()
    • getHeight

      public int getHeight()
    • getMaxDimension

      public int getMaxDimension()
      Returns the largest dimension ( max(width, height) ).
    • getBounds

      public void getBounds(@NonNull Rect2i dst)
      Returns the bounding box for this glyph.

      This may an exact bounding box or just a bounds of all control points, also known as pixel bounds.

    • getBounds

      public void getBounds(@NonNull Rect2f dst)
      Returns the bounding box for this glyph, it holds rounded integer values.

      This may an exact bounding box or just a bounds of all control points, also known as pixel bounds.

    • isEmpty

      public boolean isEmpty()
    • getMaskFormat

      public byte getMaskFormat()
    • isColor

      public boolean isColor()
    • imageIsTooLarge

      public boolean imageIsTooLarge()
    • setImage

      public boolean setImage(ScalerContext scalerContext)
    • setImageHasBeenCalled

      public boolean setImageHasBeenCalled()
    • getImageBase

      public Object getImageBase()
    • getImageAddress

      public long getImageAddress()
    • getRowBytes

      public int getRowBytes()
    • getImageSize

      public int getImageSize()
    • setPath

      public boolean setPath(ScalerContext scalerContext)
    • setPath

      public boolean setPath(Path path)
    • setPathHasBeenCalled

      public boolean setPathHasBeenCalled()
    • getPath

      public Path getPath()
    • actionFor

      public int actionFor(int actionType)
      Returns the action result for the given text rendering method.
      Parameters:
      actionType - e.g. kDirectMask