类 WritableFontData


public final class WritableFontData extends ReadableFontData
Writable font data wrapper. Supports writing of data primitives in the TrueType / OpenType spec.
作者:
Stuart Gill
  • 构造器详细资料

    • WritableFontData

      private WritableFontData(ByteArray<? extends ByteArray<?>> array)
      Constructor.
      参数:
      array - byte array to wrap
    • WritableFontData

      private WritableFontData(WritableFontData data, int offset)
      Constructor with a lower bound.
      参数:
      data - other WritableFontData object to share data with
      offset - offset from the other WritableFontData's data
    • WritableFontData

      private WritableFontData(WritableFontData data, int offset, int length)
      Constructor with lower bound and a length bound.
      参数:
      data - other WritableFontData object to share data with
      offset - offset from the other WritableFontData's data
      length - length of other WritableFontData's data to use
  • 方法详细资料

    • createWritableFontData

      public static final WritableFontData createWritableFontData(int length)
      Constructs a writable font data object. If the length is specified as positive then a fixed size font data object will be created. If the length is zero or less then a growable font data object will be created and the size will be used as an estimate to help in allocating the original space.
      参数:
      length - if length > 0 create a fixed length font data; otherwise create a growable font data
      返回:
      a new writable font data
    • createWritableFontData

      public static final WritableFontData createWritableFontData(byte[] b)
      Constructs a writable font data object. The new font data object will wrap the bytes passed in to the factory and it will take ownership of those bytes. They should not be used again by the caller.
      参数:
      b - the byte array to wrap
      返回:
      a new writable font data
    • createWritableFontData

      public static final WritableFontData createWritableFontData(ReadableFontData original)
      Constructs a writable font data object. The new font data object will wrap a copy of the the data used by the original writable font data object passed in.
      参数:
      original - the source font data
      返回:
      a new writable font data
    • slice

      public WritableFontData slice(int offset, int length)
      Makes a slice of this FontData. The returned slice will share the data with the original FontData.
      覆盖:
      slice 在类中 ReadableFontData
      参数:
      offset - the start of the slice
      length - the number of bytes in the slice
      返回:
      a slice of the original FontData
    • slice

      public WritableFontData slice(int offset)
      Makes a bottom bound only slice of this array. The returned slice will share the data with the original FontData.
      覆盖:
      slice 在类中 ReadableFontData
      参数:
      offset - the start of the slice
      返回:
      a slice of the original FontData
    • writeByte

      public int writeByte(int index, byte b)
      Writes a byte at the given index.
      参数:
      index - index into the font data
      b - the byte to write
      返回:
      the number of bytes written
    • writeBytes

      public int writeBytes(int index, byte[] b, int offset, int length)
      Writes the bytes from the array.
      参数:
      index - index into the font data
      b - the source for the bytes to be written
      offset - offset in the byte array
      length - the length of the bytes to be written
      返回:
      the number of bytes actually written; -1 if the index is outside the FontData's range
    • writeBytesPad

      public int writeBytesPad(int index, byte[] b, int offset, int length, byte pad)
      Writes the bytes from the array and pad if necessary. Writes to the length given using the byte array provided and if there are not enough bytes in the array then pad to the requested length using the pad byte specified.
      参数:
      index - index into the font data
      b - the source for the bytes to be written
      offset - offset in the byte array
      length - the length of the bytes to be written
      pad - the padding byte to be used if necessary
      返回:
      the number of bytes actually written
    • writePadding

      public int writePadding(int index, int count)
      Writes padding to the FontData. The padding byte written is 0x00.
      参数:
      index - index into the font data
      count - the number of pad bytes to write
      返回:
      the number of pad bytes written
    • writePadding

      public int writePadding(int index, int count, byte pad)
      Writes padding to the FontData.
      参数:
      index - index into the font data
      count - the number of pad bytes to write
      pad - the byte value to use as padding
      返回:
      the number of pad bytes written
    • writeBytes

      public int writeBytes(int index, byte[] b)
      Writes the bytes from the array.
      参数:
      index - index into the font data
      b - the source for the bytes to be written
      返回:
      the number of bytes actually written; -1 if the index is outside the FontData's range
    • writeChar

      public int writeChar(int index, byte c)
      Writes the CHAR at the given index.
      参数:
      index - index into the font data
      c - the CHAR
      返回:
      the number of bytes actually written
      抛出:
      IndexOutOfBoundsException - if index is outside the FontData's range
    • writeUShort

      public int writeUShort(int index, int us)
      Writes the USHORT at the given index.
      参数:
      index - index into the font data
      us - the USHORT
      返回:
      the number of bytes actually written
      抛出:
      IndexOutOfBoundsException - if index is outside the FontData's range
    • writeUShortLE

      public int writeUShortLE(int index, int us)
      Writes the USHORT at the given index in little endian format.
      参数:
      index - index into the font data
      us - the USHORT
      返回:
      the number of bytes actually written
      抛出:
      IndexOutOfBoundsException - if index is outside the FontData's range
    • writeShort

      public int writeShort(int index, int s)
      Writes the SHORT at the given index.
      参数:
      index - index into the font data
      s - the SHORT
      返回:
      the number of bytes actually written
      抛出:
      IndexOutOfBoundsException - if index is outside the FontData's range
    • writeUInt24

      public int writeUInt24(int index, int ui)
      Writes the UINT24 at the given index.
      参数:
      index - index into the font data
      ui - the UINT24
      返回:
      the number of bytes actually written
      抛出:
      IndexOutOfBoundsException - if index is outside the FontData's range
    • writeULong

      public int writeULong(int index, long ul)
      Writes the ULONG at the given index.
      参数:
      index - index into the font data
      ul - the ULONG
      返回:
      the number of bytes actually written
      抛出:
      IndexOutOfBoundsException - if index is outside the FontData's range
    • writeULongLE

      public int writeULongLE(int index, long ul)
      Writes the ULONG at the given index in little endian format.
      参数:
      index - index into the font data
      ul - the ULONG
      返回:
      the number of bytes actually written
      抛出:
      IndexOutOfBoundsException - if index is outside the FontData's range
    • writeLong

      public int writeLong(int index, long l)
      Writes the LONG at the given index.
      参数:
      index - index into the font data
      l - the LONG
      返回:
      the number of bytes actually written
      抛出:
      IndexOutOfBoundsException - if index is outside the FontData's range
    • writeFixed

      public int writeFixed(int index, int f)
      Writes the Fixed at the given index.
      参数:
      index - index into the font data
      f - the Fixed
      返回:
      the number of bytes actually written
      抛出:
      IndexOutOfBoundsException - if index is outside the FontData's range
    • writeDateTime

      public int writeDateTime(int index, long date)
      Writes the LONGDATETIME at the given index.
      参数:
      index - index into the font data
      date - the LONGDATETIME
      返回:
      the number of bytes actually written
      抛出:
      IndexOutOfBoundsException - if index is outside the FontData's range
    • copyFrom

      public void copyFrom(InputStream is, int length) throws IOException
      Copy from the InputStream into this FontData.
      参数:
      is - the source
      length - the number of bytes to copy
      抛出:
      IOException
    • copyFrom

      public void copyFrom(InputStream is) throws IOException
      Copy everything from the InputStream into this FontData.
      参数:
      is - the source
      抛出:
      IOException