Class Typeface

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class Typeface
    extends RefCnt
    • Constructor Detail

      • Typeface

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

      • getFontStyle

        public FontStyle getFontStyle()
        Returns:
        the typeface’s intrinsic style attributes
      • isBold

        public boolean isBold()
        Returns:
        true if getFontStyle() has the bold bit set
      • isItalic

        public boolean isItalic()
        Returns:
        true if getFontStyle() has the italic bit set
      • isFixedPitch

        public boolean isFixedPitch()
        This is a style bit, advance widths may vary even if this returns true.
        Returns:
        true if the typeface claims to be fixed-pitch
      • getVariations

        @Nullable
        public @Nullable FontVariation[] getVariations()
        It is possible the number of axes can be retrieved but actual position cannot.
        Returns:
        the variation coordinates describing the position of this typeface in design variation space, null if there’s no variations
      • getVariationAxes

        @Nullable
        public @Nullable FontVariationAxis[] getVariationAxes()
        It is possible the number of axes can be retrieved but actual position cannot.
        Returns:
        the variation coordinates describing the position of this typeface in design variation space, null if there’s no variations
      • getUniqueId

        public int getUniqueId()
        Returns:
        a 32bit value for this typeface, unique for the underlying font data. Never 0
      • _nativeEquals

        @Internal
        public boolean _nativeEquals​(Native other)
        Overrides:
        _nativeEquals in class Native
        Returns:
        true if the two typefaces reference the same underlying font, treating null as the default font
      • makeDefault

        @NotNull
        public static @NotNull Typeface makeDefault()
        Returns:
        the default normal typeface, which is never null
      • makeFromName

        @NotNull
        public static @NotNull Typeface makeFromName​(java.lang.String name,
                                                     FontStyle style)
        Creates a new reference to the typeface that most closely matches the requested name and style. This method allows extended font face specifiers as in the FontStyle type. Will never return null.
        Parameters:
        name - May be null. The name of the font family
        style - The style of the typeface
        Returns:
        reference to the closest-matching typeface
      • makeFromFile

        @NotNull
        public static @NotNull Typeface makeFromFile​(java.lang.String path)
        Returns:
        a new typeface given a file
        Throws:
        java.lang.IllegalArgumentException - If the file does not exist, or is not a valid font file
      • makeFromFile

        @NotNull
        public static @NotNull Typeface makeFromFile​(java.lang.String path,
                                                     int index)
        Returns:
        a new typeface given a file
        Throws:
        java.lang.IllegalArgumentException - If the file does not exist, or is not a valid font file
      • makeFromData

        @NotNull
        public static @NotNull Typeface makeFromData​(Data data)
        Returns:
        a new typeface given a Data
        Throws:
        java.lang.IllegalArgumentException - If the data is null, or is not a valid font file
      • makeFromData

        @NotNull
        public static @NotNull Typeface makeFromData​(Data data,
                                                     int index)
        Returns:
        a new typeface given a Data
        Throws:
        java.lang.IllegalArgumentException - If the data is null, or is not a valid font file
      • makeClone

        public Typeface makeClone​(FontVariation variation)
        Return a new typeface based on this typeface but parameterized as specified in the variation. If the variation does not supply an argument for a parameter in the font then the value from this typeface will be used as the value for that argument.
        Returns:
        same typeface if variation already matches, new typeface otherwise
        Throws:
        java.lang.IllegalArgumentException - on failure
      • makeClone

        public Typeface makeClone​(FontVariation[] variations)
        Return a new typeface based on this typeface but parameterized as specified in the variations. If the variations does not supply an argument for a parameter in the font then the value from this typeface will be used as the value for that argument.
        Returns:
        same typeface if all variation already match, new typeface otherwise
        Throws:
        java.lang.IllegalArgumentException - on failure
      • makeClone

        public Typeface makeClone​(FontVariation[] variations,
                                  int collectionIndex)
        Return a new typeface based on this typeface but parameterized as specified in the variations. If the variations does not supply an argument for a parameter in the font then the value from this typeface will be used as the value for that argument.
        Returns:
        same typeface if all variation already match, new typeface otherwise
        Throws:
        java.lang.IllegalArgumentException - on failure
      • getStringGlyphs

        public short[] getStringGlyphs​(java.lang.String s)
        Given a string, returns corresponding glyph ids.
        Returns:
        the corresponding glyph ids for each character.
      • getUTF32Glyphs

        public short[] getUTF32Glyphs​(int[] uni)
        Given an array of UTF32 character codes, return their corresponding glyph IDs.
        Returns:
        the corresponding glyph IDs for each character.
      • getUTF32Glyph

        public short getUTF32Glyph​(int unichar)
        This is a short-cut for calling getUTF32Glyphs(int[]).
        Returns:
        the glyph that corresponds to the specified unicode code-point (in UTF32 encoding). If the unichar is not supported, returns 0
      • getGlyphsCount

        public int getGlyphsCount()
        Returns:
        the number of glyphs in the typeface
      • getTablesCount

        public int getTablesCount()
        Returns:
        the number of tables in the font
      • getTableTags

        public java.lang.String[] getTableTags()
        Returns:
        the list of table tags in the font
      • getTableSize

        public long getTableSize​(java.lang.String tag)
        Given a table tag, return the size of its contents, or 0 if not present
      • getTableData

        @Nullable
        public @Nullable Data getTableData​(java.lang.String tag)
        Return an immutable copy of the requested font table, or null if that table was not found.
        Parameters:
        tag - The table tag whose contents are to be copied
        Returns:
        an immutable copy of the table's data, or null
      • getUnitsPerEm

        public int getUnitsPerEm()
        Returns:
        the units-per-em value for this typeface, or zero if there is an error
      • getKerningPairAdjustments

        @Nullable
        public @org.jetbrains.annotations.Nullable int[] getKerningPairAdjustments​(short[] glyphs)
        Given a run of glyphs, return the associated horizontal adjustments. Adjustments are in "design units", which are integers relative to the typeface's units per em (see getUnitsPerEm()). Some typefaces are known to never support kerning. Calling this with null, if it returns null then it will always return null (no kerning) for all possible glyph runs. If it returns int[0], then it *may* return non-null adjustments for some glyph runs.
        Returns:
        adjustment array (one less than glyphs), or null if no kerning should be applied
      • getFamilyNames

        public FontFamilyName[] getFamilyNames()
        Returns:
        all of the family names specified by the font
      • getFamilyName

        public java.lang.String getFamilyName()
        Returns:
        the family name for this typeface. The language of the name is whatever the host platform chooses
      • getBounds

        public io.github.humbleui.types.Rect getBounds()
        Return a rectangle (scaled to 1-pt) that represents the union of the bounds of all of the glyphs, but each one positioned at (0,). This may be conservatively large, and will not take into account any hinting or other size-specific adjustments.
      • _nGetFontStyle

        @Internal
        public static int _nGetFontStyle​(long ptr)
      • _nIsFixedPitch

        @Internal
        public static boolean _nIsFixedPitch​(long ptr)
      • _nGetVariations

        @Internal
        public static FontVariation[] _nGetVariations​(long ptr)
      • _nGetVariationAxes

        @Internal
        public static FontVariationAxis[] _nGetVariationAxes​(long ptr)
      • _nGetUniqueId

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

        @Internal
        public static boolean _nEquals​(long ptr,
                                       long otherPtr)
      • _nMakeDefault

        @Internal
        public static long _nMakeDefault()
      • _nMakeFromName

        @Internal
        public static long _nMakeFromName​(java.lang.String name,
                                          int fontStyle)
      • _nMakeFromFile

        @Internal
        public static long _nMakeFromFile​(java.lang.String path,
                                          int index)
      • _nMakeFromData

        @Internal
        public static long _nMakeFromData​(long dataPtr,
                                          int index)
      • _nMakeClone

        @Internal
        public static long _nMakeClone​(long ptr,
                                       FontVariation[] variations,
                                       int collectionIndex)
      • _nGetUTF32Glyphs

        @Internal
        public static short[] _nGetUTF32Glyphs​(long ptr,
                                               int[] uni)
      • _nGetUTF32Glyph

        @Internal
        public static short _nGetUTF32Glyph​(long ptr,
                                            int unichar)
      • _nGetGlyphsCount

        @Internal
        public static int _nGetGlyphsCount​(long ptr)
      • _nGetTablesCount

        @Internal
        public static int _nGetTablesCount​(long ptr)
      • _nGetTableTags

        @Internal
        public static int[] _nGetTableTags​(long ptr)
      • _nGetTableSize

        @Internal
        public static long _nGetTableSize​(long ptr,
                                          int tag)
      • _nGetTableData

        @Internal
        public static long _nGetTableData​(long ptr,
                                          int tag)
      • _nGetUnitsPerEm

        @Internal
        public static int _nGetUnitsPerEm​(long ptr)
      • _nGetKerningPairAdjustments

        @Internal
        public static int[] _nGetKerningPairAdjustments​(long ptr,
                                                        short[] glyphs)
      • _nGetFamilyNames

        @Internal
        public static FontFamilyName[] _nGetFamilyNames​(long ptr)
      • _nGetFamilyName

        @Internal
        public static java.lang.String _nGetFamilyName​(long ptr)
      • _nGetBounds

        @Internal
        public static io.github.humbleui.types.Rect _nGetBounds​(long ptr)