Package org.apache.fop.fonts.truetype
Class FontFileReader
java.lang.Object
org.apache.fop.fonts.truetype.FontFileReader
Reads a TrueType font file into a byte array and
provides file like functions for array access.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
Returns the full byte array representation of the file.byte[]
getBytes
(int offset, int length) Return a copy of the internal arrayint
Returns current file position.int
Returns the size of the file.final byte
Read 1 signed byte.final int
Read 4 bytes.final short
Read 2 bytes signed.final short
readTTFShort
(long pos) Read 2 bytes signed at position pos without changing current position.final String
Read a NUL terminated ISO-8859-1 string.final String
readTTFString
(int len) Read an ISO-8859-1 string of len bytes.final String
readTTFString
(int len, int encodingID) Read an ISO-8859-1 string of len bytes.final int
Read 1 unsigned byte.final long
Read 4 bytes.final int
Read 2 bytes unsigned.final int
readTTFUShort
(long pos) Read 2 bytes unsigned at position pos without changing current position.void
seekSet
(long offset) Set current file position to offsetvoid
skip
(long add) Skip a given number of bytes.final void
writeTTFUShort
(long pos, int val) Write a USHort at a given position.
-
Constructor Details
-
FontFileReader
Constructor- Parameters:
in
- InputStream to read from- Throws:
IOException
- In case of an I/O problem
-
-
Method Details
-
seekSet
Set current file position to offset- Parameters:
offset
- The new offset to set- Throws:
IOException
- In case of an I/O problem
-
skip
Skip a given number of bytes.- Parameters:
add
- The number of bytes to advance- Throws:
IOException
- In case of an I/O problem
-
getCurrentPos
public int getCurrentPos()Returns current file position.- Returns:
- int The current position.
-
getFileSize
public int getFileSize()Returns the size of the file.- Returns:
- int The filesize
-
readTTFByte
Read 1 signed byte.- Returns:
- One byte
- Throws:
IOException
- If EOF is reached
-
readTTFUByte
Read 1 unsigned byte.- Returns:
- One unsigned byte
- Throws:
IOException
- If EOF is reached
-
readTTFShort
Read 2 bytes signed.- Returns:
- One signed short
- Throws:
IOException
- If EOF is reached
-
readTTFUShort
Read 2 bytes unsigned.- Returns:
- One unsigned short
- Throws:
IOException
- If EOF is reached
-
writeTTFUShort
Write a USHort at a given position.- Parameters:
pos
- The absolute position to write toval
- The value to write- Throws:
IOException
- If EOF is reached
-
readTTFShort
Read 2 bytes signed at position pos without changing current position.- Parameters:
pos
- The absolute position to read from- Returns:
- One signed short
- Throws:
IOException
- If EOF is reached
-
readTTFUShort
Read 2 bytes unsigned at position pos without changing current position.- Parameters:
pos
- The absolute position to read from- Returns:
- One unsigned short
- Throws:
IOException
- If EOF is reached
-
readTTFLong
Read 4 bytes.- Returns:
- One signed integer
- Throws:
IOException
- If EOF is reached
-
readTTFULong
Read 4 bytes.- Returns:
- One unsigned integer
- Throws:
IOException
- If EOF is reached
-
readTTFString
Read a NUL terminated ISO-8859-1 string.- Returns:
- A String
- Throws:
IOException
- If EOF is reached
-
readTTFString
Read an ISO-8859-1 string of len bytes.- Parameters:
len
- The length of the string to read- Returns:
- A String
- Throws:
IOException
- If EOF is reached
-
readTTFString
Read an ISO-8859-1 string of len bytes.- Parameters:
len
- The length of the string to readencodingID
- the string encoding id (presently ignored; always uses UTF-16BE)- Returns:
- A String
- Throws:
IOException
- If EOF is reached
-
getBytes
Return a copy of the internal array- Parameters:
offset
- The absolute offset to start reading fromlength
- The number of bytes to read- Returns:
- An array of bytes
- Throws:
IOException
- if out of bounds
-
getAllBytes
public byte[] getAllBytes()Returns the full byte array representation of the file.- Returns:
- byte array.
-