Package org.apache.fontbox.ttf
Class TTFDataStream
java.lang.Object
org.apache.fontbox.ttf.TTFDataStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
MemoryTTFDataStream
,RAFDataStream
,TTCDataStream
An interface into a data stream.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract long
Get the current position in the stream.abstract InputStream
This will get the original data file that was used for this stream.abstract long
This will get the original data size that was used for this stream.abstract int
read()
Read an unsigned byte.abstract int
read
(byte[] b, int off, int len) byte[]
read
(int numberOfBytes) Read a specific number of bytes from the stream.float
Read a 16.16 fixed value, where the first 16 bits are the decimal and the last 16 bits are the fraction.Read an eight byte international date.abstract long
readLong()
Read an unsigned byte.int
Read a signed byte.abstract short
Read an signed short.readString
(int length) Read a fixed length ascii string.readString
(int length, String charset) Read a fixed length string.readString
(int length, Charset charset) Read a fixed length string.readTag()
Reads a tag, an arrau of four uint8s used to identify a script, language system, feature, or baseline.int
Read a unsigned byte.int[]
readUnsignedByteArray
(int length) Read an unsigned byte array.long
Read an unsigned integer.abstract int
Read an unsigned short.int[]
readUnsignedShortArray
(int length) Read an unsigned short array.abstract void
seek
(long pos) Seek into the datasource.
-
Constructor Details
-
TTFDataStream
TTFDataStream()
-
-
Method Details
-
read32Fixed
Read a 16.16 fixed value, where the first 16 bits are the decimal and the last 16 bits are the fraction.- Returns:
- A 32 bit value.
- Throws:
IOException
- If there is an error reading the data.
-
readString
Read a fixed length ascii string.- Parameters:
length
- The length of the string to read.- Returns:
- A string of the desired length.
- Throws:
IOException
- If there is an error reading the data.
-
readString
Read a fixed length string.- Parameters:
length
- The length of the string to read in bytes.charset
- The expected character set of the string.- Returns:
- A string of the desired length.
- Throws:
IOException
- If there is an error reading the data.
-
readString
Read a fixed length string.- Parameters:
length
- The length of the string to read in bytes.charset
- The expected character set of the string.- Returns:
- A string of the desired length.
- Throws:
IOException
- If there is an error reading the data.
-
read
Read an unsigned byte.- Returns:
- An unsigned byte.
- Throws:
IOException
- If there is an error reading the data.
-
readLong
Read an unsigned byte.- Returns:
- An unsigned byte.
- Throws:
IOException
- If there is an error reading the data.
-
readSignedByte
Read a signed byte.- Returns:
- A signed byte.
- Throws:
IOException
- If there is an error reading the data.
-
readUnsignedByte
Read a unsigned byte. Similar toread()
, but throws an exception if EOF is unexpectedly reached.- Returns:
- A unsigned byte.
- Throws:
IOException
- If there is an error reading the data.
-
readUnsignedInt
Read an unsigned integer.- Returns:
- An unsigned integer.
- Throws:
IOException
- If there is an error reading the data.
-
readUnsignedShort
Read an unsigned short.- Returns:
- An unsigned short.
- Throws:
IOException
- If there is an error reading the data.
-
readUnsignedByteArray
Read an unsigned byte array.- Parameters:
length
- the length of the array to be read- Returns:
- An unsigned byte array.
- Throws:
IOException
- If there is an error reading the data.
-
readUnsignedShortArray
Read an unsigned short array.- Parameters:
length
- The length of the array to read.- Returns:
- An unsigned short array.
- Throws:
IOException
- If there is an error reading the data.
-
readSignedShort
Read an signed short.- Returns:
- An signed short.
- Throws:
IOException
- If there is an error reading the data.
-
readInternationalDate
Read an eight byte international date.- Returns:
- An signed short.
- Throws:
IOException
- If there is an error reading the data.
-
readTag
Reads a tag, an arrau of four uint8s used to identify a script, language system, feature, or baseline.- Throws:
IOException
-
seek
Seek into the datasource.- Parameters:
pos
- The position to seek to.- Throws:
IOException
- If there is an error seeking to that position.
-
read
Read a specific number of bytes from the stream.- Parameters:
numberOfBytes
- The number of bytes to read.- Returns:
- The byte buffer.
- Throws:
IOException
- If there is an error while reading.
-
read
- Parameters:
b
- The buffer to write to.off
- The offset into the buffer.len
- The length into the buffer.- Returns:
- The number of bytes read, or -1 at the end of the stream
- Throws:
IOException
- If there is an error reading from the stream.- See Also:
-
getCurrentPosition
Get the current position in the stream.- Returns:
- The current position in the stream.
- Throws:
IOException
- If an error occurs while reading the stream.
-
getOriginalData
This will get the original data file that was used for this stream.- Returns:
- The data that was read from.
- Throws:
IOException
- If there is an issue reading the data.
-
getOriginalDataSize
public abstract long getOriginalDataSize()This will get the original data size that was used for this stream.- Returns:
- The size of the original data.
-