Class TextBlob

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class TextBlob
    extends Managed
    • Field Summary

      • Fields inherited from class io.github.humbleui.skija.impl.Native

        _ptr
    • Constructor Summary

      Constructors 
      Constructor Description
      TextBlob​(long ptr)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static io.github.humbleui.types.Rect _nBounds​(long ptr)  
      static io.github.humbleui.types.Rect _nGetBlockBounds​(long ptr)  
      static int[] _nGetClusters​(long ptr)  
      static long _nGetFinalizer()  
      static java.lang.Float _nGetFirstBaseline​(long ptr)  
      static short[] _nGetGlyphs​(long ptr)  
      static float[] _nGetIntercepts​(long ptr, float lower, float upper, long paintPtr)  
      static java.lang.Float _nGetLastBaseline​(long ptr)  
      static float[] _nGetPositions​(long ptr)  
      static io.github.humbleui.types.Rect _nGetTightBounds​(long ptr)  
      static int _nGetUniqueId​(long ptr)  
      static long _nMakeFromData​(long dataPtr)  
      static long _nMakeFromPos​(short[] glyphs, float[] pos, long fontPtr)  
      static long _nMakeFromPosH​(short[] glyphs, float[] xpos, float ypos, long fontPtr)  
      static long _nMakeFromRSXform​(short[] glyphs, float[] xform, long fontPtr)  
      static long _nSerializeToData​(long ptr)  
      @NotNull io.github.humbleui.types.Rect getBlockBounds()
      Only works on TextBlobs that come from TextBlobBuilderRunHandler/Shaper default handler.
      io.github.humbleui.types.Rect getBounds()
      Returns conservative bounding box.
      @org.jetbrains.annotations.NotNull int[] getClusters()
      Only works on TextBlobs that come from TextBlobBuilderRunHandler/Shaper default handler.
      @NotNull java.lang.Float getFirstBaseline()
      Only works on TextBlobs that come from TextBlobBuilderRunHandler/Shaper default handler.
      @org.jetbrains.annotations.NotNull short[] getGlyphs()  
      @org.jetbrains.annotations.Nullable float[] getIntercepts​(float lowerBound, float upperBound)
      Returns the number of intervals that intersect bounds.
      @org.jetbrains.annotations.Nullable float[] getIntercepts​(float lowerBound, float upperBound, @Nullable Paint paint)
      Returns the number of intervals that intersect bounds.
      @NotNull java.lang.Float getLastBaseline()
      Only works on TextBlobs that come from TextBlobBuilderRunHandler/Shaper default handler.
      @org.jetbrains.annotations.NotNull float[] getPositions()
      Return result depends on how blob was constructed.
      @NotNull io.github.humbleui.types.Rect getTightBounds()
      Only works on TextBlobs that come from TextBlobBuilderRunHandler/Shaper default handler.
      int getUniqueId()
      Returns a non-zero value unique among all text blobs.
      static @Nullable TextBlob makeFromData​(Data data)  
      static TextBlob makeFromPos​(short[] glyphs, io.github.humbleui.types.Point[] pos, Font font)
      Returns a TextBlob built from a single run of text with positions.
      static TextBlob makeFromPosH​(short[] glyphs, float[] xpos, float ypos, Font font)
      Returns a TextBlob built from a single run of text with x-positions and a single y value.
      static TextBlob makeFromRSXform​(short[] glyphs, RSXform[] xform, Font font)  
      Data serializeToData()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • TextBlob

        @Internal
        public TextBlob​(long ptr)
    • Method Detail

      • getBounds

        public io.github.humbleui.types.Rect getBounds()
        Returns conservative bounding box. Uses Paint associated with each glyph to determine glyph bounds, and unions all bounds. Returned bounds may be larger than the bounds of all glyphs in runs.
        Returns:
        conservative bounding box
      • getUniqueId

        public int getUniqueId()
        Returns a non-zero value unique among all text blobs.
        Returns:
        identifier for TextBlob
      • getIntercepts

        @Nullable
        public @org.jetbrains.annotations.Nullable float[] getIntercepts​(float lowerBound,
                                                                         float upperBound)

        Returns the number of intervals that intersect bounds. bounds describes a pair of lines parallel to the text advance. The return array size is a multiple of two, and is at most twice the number of glyphs in the the blob.

        Runs within the blob that contain SkRSXform are ignored when computing intercepts.

        Parameters:
        lowerBound - lower line parallel to the advance
        upperBound - upper line parallel to the advance
        Returns:
        intersections; may be null
      • getIntercepts

        @Nullable
        public @org.jetbrains.annotations.Nullable float[] getIntercepts​(float lowerBound,
                                                                         float upperBound,
                                                                         @Nullable
                                                                         @Nullable Paint paint)

        Returns the number of intervals that intersect bounds. bounds describes a pair of lines parallel to the text advance. The return array size is a multiple of two, and is at most twice the number of glyphs in the the blob.

        Runs within the blob that contain SkRSXform are ignored when computing intercepts.

        Parameters:
        lowerBound - lower line parallel to the advance
        upperBound - upper line parallel to the advance
        paint - specifies stroking, PathEffect that affects the result; may be null
        Returns:
        intersections; may be null
      • makeFromPosH

        public static TextBlob makeFromPosH​(short[] glyphs,
                                            float[] xpos,
                                            float ypos,
                                            Font font)
        Returns a TextBlob built from a single run of text with x-positions and a single y value. Returns null if glyphs is empty.
        Parameters:
        glyphs - glyphs drawn
        xpos - array of x-positions, must contain values for all of the glyphs.
        ypos - shared y-position for each glyph, to be paired with each xpos.
        font - Font used for this run
        Returns:
        new TextBlob or null
      • makeFromPos

        public static TextBlob makeFromPos​(short[] glyphs,
                                           io.github.humbleui.types.Point[] pos,
                                           Font font)
        Returns a TextBlob built from a single run of text with positions. Returns null if glyphs is empty.
        Parameters:
        glyphs - glyphs drawn
        pos - array of positions, must contain values for all of the glyphs.
        font - Font used for this run
        Returns:
        new TextBlob or null
      • makeFromRSXform

        public static TextBlob makeFromRSXform​(short[] glyphs,
                                               RSXform[] xform,
                                               Font font)
      • serializeToData

        public Data serializeToData()
      • makeFromData

        @Nullable
        public static @Nullable TextBlob makeFromData​(Data data)
      • getGlyphs

        @NotNull
        public @org.jetbrains.annotations.NotNull short[] getGlyphs()
        Returns:
        glyph indices for the whole blob
      • getPositions

        @NotNull
        public @org.jetbrains.annotations.NotNull float[] getPositions()

        Return result depends on how blob was constructed.

        • makeFromPosH returns 1 float per glyph (x pos)
        • makeFromPos returns 2 floats per glyph (x, y pos)
        • makeFromRSXform returns 4 floats per glyph

        Blobs constructed by TextBlobBuilderRunHandler/Shaper default handler have 2 floats per glyph.

        Returns:
        glyph positions for the blob if it was made with makeFromPos, null otherwise
      • getClusters

        @NotNull
        public @org.jetbrains.annotations.NotNull int[] getClusters()
        Only works on TextBlobs that come from TextBlobBuilderRunHandler/Shaper default handler.
        Returns:
        utf-16 offsets of clusters that start the glyph
        Throws:
        java.lang.IllegalArgumentException - if TextBlob doesn’t have this information
      • getTightBounds

        @NotNull
        public @NotNull io.github.humbleui.types.Rect getTightBounds()
        Only works on TextBlobs that come from TextBlobBuilderRunHandler/Shaper default handler.
        Returns:
        tight bounds around all the glyphs in the TextBlob
        Throws:
        java.lang.IllegalArgumentException - if TextBlob doesn’t have this information
      • getBlockBounds

        @NotNull
        public @NotNull io.github.humbleui.types.Rect getBlockBounds()
        Only works on TextBlobs that come from TextBlobBuilderRunHandler/Shaper default handler.
        Returns:
        tight bounds around all the glyphs in the TextBlob
        Throws:
        java.lang.IllegalArgumentException - if TextBlob doesn’t have this information
      • getFirstBaseline

        @NotNull
        public @NotNull java.lang.Float getFirstBaseline()
        Only works on TextBlobs that come from TextBlobBuilderRunHandler/Shaper default handler.
        Returns:
        first baseline in TextBlob
        Throws:
        java.lang.IllegalArgumentException - if TextBlob doesn’t have this information
      • getLastBaseline

        @NotNull
        public @NotNull java.lang.Float getLastBaseline()
        Only works on TextBlobs that come from TextBlobBuilderRunHandler/Shaper default handler.
        Returns:
        last baseline in TextBlob
        Throws:
        java.lang.IllegalArgumentException - if TextBlob doesn’t have this information
      • _nGetFinalizer

        @Internal
        public static long _nGetFinalizer()
      • _nBounds

        @Internal
        public static io.github.humbleui.types.Rect _nBounds​(long ptr)
      • _nGetUniqueId

        @Internal
        public static int _nGetUniqueId​(long ptr)
      • _nGetIntercepts

        @Internal
        public static float[] _nGetIntercepts​(long ptr,
                                              float lower,
                                              float upper,
                                              long paintPtr)
      • _nMakeFromPosH

        @Internal
        public static long _nMakeFromPosH​(short[] glyphs,
                                          float[] xpos,
                                          float ypos,
                                          long fontPtr)
      • _nMakeFromPos

        @Internal
        public static long _nMakeFromPos​(short[] glyphs,
                                         float[] pos,
                                         long fontPtr)
      • _nMakeFromRSXform

        @Internal
        public static long _nMakeFromRSXform​(short[] glyphs,
                                             float[] xform,
                                             long fontPtr)
      • _nSerializeToData

        @Internal
        public static long _nSerializeToData​(long ptr)
      • _nMakeFromData

        @Internal
        public static long _nMakeFromData​(long dataPtr)
      • _nGetGlyphs

        @Internal
        public static short[] _nGetGlyphs​(long ptr)
      • _nGetPositions

        @Internal
        public static float[] _nGetPositions​(long ptr)
      • _nGetClusters

        @Internal
        public static int[] _nGetClusters​(long ptr)
      • _nGetTightBounds

        @Internal
        public static io.github.humbleui.types.Rect _nGetTightBounds​(long ptr)
      • _nGetBlockBounds

        @Internal
        public static io.github.humbleui.types.Rect _nGetBlockBounds​(long ptr)
      • _nGetFirstBaseline

        @Internal
        public static java.lang.Float _nGetFirstBaseline​(long ptr)
      • _nGetLastBaseline

        @Internal
        public static java.lang.Float _nGetLastBaseline​(long ptr)