类 ReadableFontData
java.lang.Object
com.google.typography.font.sfntly.data.FontData
com.google.typography.font.sfntly.data.ReadableFontData
- 直接已知子类:
WritableFontData
Writable font data wrapper. Supports reading of data primitives in the
TrueType / OpenType spec.
The data types used are as listed:
BYTE | 8-bit unsigned integer. |
CHAR | 8-bit signed integer. |
USHORT | 16-bit unsigned integer. |
SHORT | 16-bit signed integer. |
UINT24 | 24-bit unsigned integer. |
ULONG | 32-bit unsigned integer. |
LONG | 32-bit signed integer. |
Fixed | 32-bit signed fixed-point number (16.16) |
FUNIT | Smallest measurable distance in the em space. |
FWORD | 16-bit signed integer (SHORT) that describes a quantity in FUnits. |
UFWORD | 16-bit unsigned integer (USHORT) that describes a quantity in FUnits. |
F2DOT14 | 16-bit signed fixed number with the low 14 bits of fraction (2.14). |
LONGDATETIME | Date represented in number of seconds since 12:00 midnight, January 1, 1904. The value is represented as a signed 64-bit integer. |
- 作者:
- Stuart Gill
- 另请参阅:
-
嵌套类概要
从类继承的嵌套类/接口 com.google.typography.font.sfntly.data.FontData
FontData.DataSize
-
字段概要
字段修饰符和类型字段说明private long
private final Object
Lock on all operations that will affect the value of the checksum.private int[]
private boolean
Flag on whether the checksum has been set.从类继承的字段 com.google.typography.font.sfntly.data.FontData
array, GROWABLE_SIZE
-
构造器概要
构造器限定符构造器说明protected
ReadableFontData
(ByteArray<? extends ByteArray<?>> array) Constructor.protected
ReadableFontData
(ReadableFontData data, int offset) Constructor.protected
ReadableFontData
(ReadableFontData data, int offset, int length) Constructor. -
方法概要
修饰符和类型方法说明long
checksum()
Gets a computed checksum for the data.int[]
Gets the ranges that are used for computing the checksum.private void
Computes the checksum for the font data using any ranges set for the calculation.private long
computeCheckSum
(int lowBound, int highBound) Do the actual computation of the checksum for a range using the TrueType/OpenType checksum algorithm.int
copyTo
(WritableFontData wfd) Copies the FontData to a WritableFontData.int
copyTo
(OutputStream os) Copy the FontData to an OutputStream.static ReadableFontData
createReadableFontData
(byte[] b) int
readByte
(int index) Reads the BYTE at the given index.int
readBytes
(int index, byte[] b, int offset, int length) Reads the bytes at the given index into the array.int
readChar
(int index) Reads the CHAR at the given index.long
readDateTimeAsLong
(int index) Reads the LONGDATETIME at the given index.readF2Dot14
(int index) Reads the F2DOT14 at the given index.int
readFixed
(int index) Reads the Fixed at the given index.int
readFUnit
(int index) Reads the FUNIT at the given index.int
readFWord
(int index) Reads the FWORD at the given index.int
readLong
(int index) Reads the LONG at the given index.readLongDateTime
(int index) Reads the LONGDATETIME at the given index.int
readShort
(int index) Reads the SHORT at the given index.int
readUByte
(int index) Reads the UBYTE at the given index.int
readUFWord
(int index) Reads the UFWORD at the given index.int
readUInt24
(int index) Reads the UINT24 at the given index.long
readULong
(int index) Reads the ULONG at the given index.int
readULongAsInt
(int index) Reads the ULONG at the given index as an int.long
readULongLE
(int index) Reads the ULONG at the given index, little-endian variant.int
readUShort
(int index) Reads the USHORT at the given index.int
searchULong
(int startIndex, int startOffset, int endIndex, int endOffset, int length, int key) Search for the key value in the range tables provided.int
searchUShort
(int startIndex, int startOffset, int length, int key) Search for the key value in the table provided.int
searchUShort
(int startIndex, int startOffset, int endIndex, int endOffset, int length, int key) Search for the key value in the range tables provided.void
setCheckSumRanges
(int... ranges) Sets the ranges to use for computing the checksum.slice
(int offset) Makes a bottom bound only slice of this array.slice
(int offset, int length) Makes a slice of this FontData.toString()
toString
(int length) Generates a String representation of the object with a certain number of data bytes.从类继承的方法 com.google.typography.font.sfntly.data.FontData
bound, bound, boundLength, boundOffset, boundsCheck, dataOffset, length, size
-
字段详细资料
-
checksumSet
private volatile boolean checksumSetFlag on whether the checksum has been set. -
checksumLock
Lock on all operations that will affect the value of the checksum. -
checksum
private volatile long checksum -
checksumRange
private volatile int[] checksumRange
-
-
构造器详细资料
-
ReadableFontData
Constructor.- 参数:
array
- byte array to wrap
-
ReadableFontData
Constructor. Creates a bounded wrapper of another ReadableFontData from the given offset until the end of the original ReadableFontData.- 参数:
data
- data to wrapoffset
- the start of this data's view of the original data
-
ReadableFontData
Constructor. Creates a bounded wrapper of another ReadableFontData from the given offset until the end of the original ReadableFontData.- 参数:
data
- data to wrapoffset
- the start of this data's view of the original datalength
- the length of the other FontData to use
-
-
方法详细资料
-
createReadableFontData
-
slice
Makes a slice of this FontData. The returned slice will share the data with the originalFontData
. -
slice
Makes a bottom bound only slice of this array. The returned slice will share the data with the originalFontData
. -
toString
Generates a String representation of the object with a certain number of data bytes.- 参数:
length
- number of bytes of the data to include in the String- 返回:
- String representation of the object
-
toString
-
checksum
public long checksum()Gets a computed checksum for the data. This checksum uses the OpenType spec calculation. Every ULong value (32 bit unsigned) in the data is summed and the resulting value is truncated to 32 bits. If the data length in bytes is not an integral multiple of 4 then any remaining bytes are treated as the start of a 4 byte sequence whose remaining bytes are zero.- 返回:
- the checksum
-
computeChecksum
private void computeChecksum()Computes the checksum for the font data using any ranges set for the calculation. Updates the internal state of this object in a threadsafe way. -
computeCheckSum
private long computeCheckSum(int lowBound, int highBound) Do the actual computation of the checksum for a range using the TrueType/OpenType checksum algorithm. The range used is from the low bound to the high bound in steps of four bytes. If any of the bytes within that 4 byte segment are not readable then it will considered a zero for calculation.Only called from within a synchronized method so it does not need to be synchronized itself.
- 参数:
lowBound
- first position to start a 4 byte segment onhighBound
- last possible position to start a 4 byte segment on- 返回:
- the checksum for the total range
-
setCheckSumRanges
public void setCheckSumRanges(int... ranges) Sets the ranges to use for computing the checksum. These ranges are in begin and end pairs. If an odd number is given then the final range is assumed to extend to the end of the data. The lengths of each range must be a multiple of 4.- 参数:
ranges
- the range bounds to use for the checksum
-
checkSumRange
public int[] checkSumRange()Gets the ranges that are used for computing the checksum. These ranges are in begin and end pairs. If an odd number is given then the final range is assumed to extend to the end of the data. The lengths of each range must be a multiple of 4.- 返回:
- the range bounds used for the checksum
-
readUByte
public int readUByte(int index) Reads the UBYTE at the given index.- 参数:
index
- index into the font data- 返回:
- the UBYTE; -1 if outside the bounds of the font data
- 抛出:
IndexOutOfBoundsException
- if index is outside the FontData's range
-
readByte
public int readByte(int index) Reads the BYTE at the given index.- 参数:
index
- index into the font data- 返回:
- the BYTE
- 抛出:
IndexOutOfBoundsException
- if index is outside the FontData's range
-
readBytes
public int readBytes(int index, byte[] b, int offset, int length) Reads the bytes at the given index into the array.- 参数:
index
- index into the font datab
- the destination for the bytes readoffset
- offset in the byte array to place the byteslength
- the length of bytes to read- 返回:
- the number of bytes actually read; -1 if the index is outside the bounds of the font data
-
readChar
public int readChar(int index) Reads the CHAR at the given index.- 参数:
index
- index into the font data- 返回:
- the CHAR
- 抛出:
IndexOutOfBoundsException
- if index is outside the FontData's range
-
readUShort
public int readUShort(int index) Reads the USHORT at the given index.- 参数:
index
- index into the font data- 返回:
- the USHORT
- 抛出:
IndexOutOfBoundsException
- if index is outside the FontData's range
-
readShort
public int readShort(int index) Reads the SHORT at the given index.- 参数:
index
- index into the font data- 返回:
- the SHORT
- 抛出:
IndexOutOfBoundsException
- if index is outside the FontData's range
-
readUInt24
public int readUInt24(int index) Reads the UINT24 at the given index.- 参数:
index
- index into the font data- 返回:
- the UINT24
- 抛出:
IndexOutOfBoundsException
- if index is outside the FontData's range
-
readULong
public long readULong(int index) Reads the ULONG at the given index.- 参数:
index
- index into the font data- 返回:
- the ULONG
- 抛出:
IndexOutOfBoundsException
- if index is outside the FontData's range
-
readULongAsInt
public int readULongAsInt(int index) Reads the ULONG at the given index as an int.- 参数:
index
- index into the font data- 返回:
- the ULONG
- 抛出:
IndexOutOfBoundsException
- if index is outside the FontData's rangeArithmeticException
- if the value will not fit into an integer
-
readULongLE
public long readULongLE(int index) Reads the ULONG at the given index, little-endian variant.- 参数:
index
- index into the font data- 返回:
- the ULONG
- 抛出:
IndexOutOfBoundsException
- if index is outside the FontData's range
-
readLong
public int readLong(int index) Reads the LONG at the given index.- 参数:
index
- index into the font data- 返回:
- the LONG
- 抛出:
IndexOutOfBoundsException
- if index is outside the FontData's range
-
readFixed
public int readFixed(int index) Reads the Fixed at the given index.- 参数:
index
- index into the font data- 返回:
- the Fixed
- 抛出:
IndexOutOfBoundsException
- if index is outside the FontData's range
-
readF2Dot14
Reads the F2DOT14 at the given index.- 参数:
index
- index into the font data- 返回:
- the F2DOT14
- 抛出:
IndexOutOfBoundsException
- if index is outside the FontData's range
-
readDateTimeAsLong
public long readDateTimeAsLong(int index) Reads the LONGDATETIME at the given index.- 参数:
index
- index into the font data- 返回:
- the LONGDATETIME
- 抛出:
IndexOutOfBoundsException
- if index is outside the FontData's range
-
readLongDateTime
Reads the LONGDATETIME at the given index.- 参数:
index
- index into the font data- 返回:
- the F2DOT14
- 抛出:
IndexOutOfBoundsException
- if index is outside the FontData's range
-
readFUnit
public int readFUnit(int index) Reads the FUNIT at the given index.- 参数:
index
- index into the font data- 返回:
- the FUNIT
- 抛出:
IndexOutOfBoundsException
- if index is outside the FontData's range
-
readFWord
public int readFWord(int index) Reads the FWORD at the given index.- 参数:
index
- index into the font data- 返回:
- the FWORD
- 抛出:
IndexOutOfBoundsException
- if index is outside the FontData's range
-
readUFWord
public int readUFWord(int index) Reads the UFWORD at the given index.- 参数:
index
- index into the font data- 返回:
- the UFWORD
- 抛出:
IndexOutOfBoundsException
- if index is outside the FontData's range
-
copyTo
Copy the FontData to an OutputStream.- 参数:
os
- the destination- 返回:
- number of bytes copied
- 抛出:
IOException
-
copyTo
Copies the FontData to a WritableFontData.- 参数:
wfd
- the destination- 返回:
- number of bytes copied
-
searchUShort
public int searchUShort(int startIndex, int startOffset, int endIndex, int endOffset, int length, int key) Search for the key value in the range tables provided. The search looks through the start-end pairs looking for the key value. It is assumed that the start-end pairs are both represented by UShort values, ranges do not overlap, and are monotonically increasing.- 参数:
startIndex
- the position to read the first start value fromstartOffset
- the offset between subsequent start valuesendIndex
- the position to read the first end value fromendOffset
- the offset between subsequent end valueslength
- the number of start-end pairskey
- the value to search for- 返回:
- the index of the start-end pairs in which the key was found; -1 otherwise
-
searchULong
public int searchULong(int startIndex, int startOffset, int endIndex, int endOffset, int length, int key) Search for the key value in the range tables provided. The search looks through the start-end pairs looking for the key value. It is assumed that the start-end pairs are both represented by ULong values that can be represented within 31 bits, ranges do not overlap, and are monotonically increasing.- 参数:
startIndex
- the position to read the first start value fromstartOffset
- the offset between subsequent start valuesendIndex
- the position to read the first end value fromendOffset
- the offset between subsequent end valueslength
- the number of start-end pairskey
- the value to search for- 返回:
- the index of the start-end pairs in which the key was found; -1 otherwise
-
searchUShort
public int searchUShort(int startIndex, int startOffset, int length, int key) Search for the key value in the table provided. The search looks through the values looking for the key value. It is assumed that the are represented by UShort values and are monotonically increasing.- 参数:
startIndex
- the position to read the first start value fromstartOffset
- the offset between subsequent start valueslength
- the number of start-end pairskey
- the value to search for- 返回:
- the index of the start-end pairs in which the key was found; -1 otherwise
-