Package org.apache.fop.fonts.type1
Class Type1SubsetFile
- java.lang.Object
-
- org.apache.fop.fonts.type1.Type1SubsetFile
-
public class Type1SubsetFile extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Type1SubsetFile.BinaryCoder
A class to encode and decode sections of a type 1 font file.static class
Type1SubsetFile.BytesNumber
A class used to store the last number operand and also it's size in bytes
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.lang.String>
charNames
protected java.lang.String
eol
private byte[]
fullFont
protected java.util.List<PostscriptParser.PSElement>
headerSection
protected static org.apache.commons.logging.Log
LOG
protected java.util.List<PostscriptParser.PSElement>
mainSection
private static int
OP_CALLOTHERSUBR
private static int
OP_CALLSUBR
private static int
OP_SEAC
private SingleByteFont
sbfont
protected boolean
standardEncoding
protected java.util.HashMap<java.lang.String,byte[]>
subsetCharStrings
protected boolean
subsetSubroutines
protected java.util.LinkedHashMap<java.lang.Integer,byte[]>
uniqueSubs
-
Constructor Summary
Constructors Constructor Description Type1SubsetFile()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private byte[]
addSubroutine(PostscriptParser.PSFixedArray subroutines, java.util.List<Type1SubsetFile.BytesNumber> operands, byte[] decoded, java.util.List<java.lang.String> subsetEncodingEntries, byte[] data, int i, int opLength, int existingSubrRef, int subrID)
private void
addToCharNames(java.lang.String encodingEntry)
(package private) byte[]
concatArray(byte[] a, byte[] b)
Concatenate two byte arrays togetherprivate byte[]
constructNewRefData(int curDataPos, byte[] currentData, java.util.List<Type1SubsetFile.BytesNumber> operands, int opNum, int curSubsetIndexSize, int operatorLength)
private byte[]
createNewRef(int newRef, int forceLength)
byte[]
createSubset(java.io.InputStream in, SingleByteFont sbfont)
private byte[]
createSubset(SingleByteFont sbfont, boolean subsetSubroutines)
Creates a new subset from the given type 1 font input streamprivate byte[]
createSubsetCharStrings(byte[] decoded, byte[] data, PostscriptParser.PSFixedArray subroutines, java.util.List<java.lang.String> subsetEncodingEntries)
protected java.lang.String
findVariable(byte[] decoded, java.util.List<PostscriptParser.PSElement> elements, java.lang.String[] matches, java.lang.String fallback)
protected byte[]
getBinaryEntry(int[] position, byte[] decoded)
Returns a section of a byte array determined by it's start and end position.protected PostscriptParser.PSElement
getElement(java.lang.String elementID, java.util.List<PostscriptParser.PSElement> elements)
protected java.lang.String
getEntryPart(java.lang.String entry, int part)
(package private) int
getOperandsLength(java.util.List<Type1SubsetFile.BytesNumber> operands)
(package private) int
getOpPosition(int opNum, java.util.List<Type1SubsetFile.BytesNumber> operands)
private int
getSubrIndex(int subID)
private java.util.List<java.lang.String>
readEncoding(PostscriptParser.PSElement encoding)
private boolean
readMainSection(java.util.List<PostscriptParser.PSElement> mainSection, byte[] decoded, java.util.List<java.lang.String> subsetEncodingEntries, PostscriptParser.PSElement charStrings)
(package private) java.lang.String
readVariableContents(java.lang.String variable)
protected java.util.List<java.lang.String>
searchEntries(java.util.HashMap<java.lang.Integer,java.lang.String> encodingEntries, int glyph)
byte[]
stitchFont(java.io.ByteArrayOutputStream boasHeader, java.io.ByteArrayOutputStream boasMain, java.io.ByteArrayOutputStream boasTrailer)
(package private) java.io.ByteArrayOutputStream
updateSectionSize(int size)
protected java.io.ByteArrayOutputStream
writeHeader(PFBData pfbData, PostscriptParser.PSElement encoding)
protected java.io.ByteArrayOutputStream
writeMainSection(byte[] decoded, java.util.List<PostscriptParser.PSElement> mainSection, PostscriptParser.PSElement charStrings)
protected void
writeString(java.lang.String entry, java.io.ByteArrayOutputStream boas)
-
-
-
Field Detail
-
LOG
protected static final org.apache.commons.logging.Log LOG
-
subsetCharStrings
protected java.util.HashMap<java.lang.String,byte[]> subsetCharStrings
-
charNames
protected java.util.List<java.lang.String> charNames
-
uniqueSubs
protected java.util.LinkedHashMap<java.lang.Integer,byte[]> uniqueSubs
-
sbfont
private SingleByteFont sbfont
-
eol
protected java.lang.String eol
-
subsetSubroutines
protected boolean subsetSubroutines
-
fullFont
private byte[] fullFont
-
headerSection
protected java.util.List<PostscriptParser.PSElement> headerSection
-
mainSection
protected java.util.List<PostscriptParser.PSElement> mainSection
-
standardEncoding
protected boolean standardEncoding
-
OP_SEAC
private static final int OP_SEAC
- See Also:
- Constant Field Values
-
OP_CALLSUBR
private static final int OP_CALLSUBR
- See Also:
- Constant Field Values
-
OP_CALLOTHERSUBR
private static final int OP_CALLOTHERSUBR
- See Also:
- Constant Field Values
-
-
Method Detail
-
createSubset
public byte[] createSubset(java.io.InputStream in, SingleByteFont sbfont) throws java.io.IOException
- Throws:
java.io.IOException
-
createSubset
private byte[] createSubset(SingleByteFont sbfont, boolean subsetSubroutines) throws java.io.IOException
Creates a new subset from the given type 1 font input stream- Parameters:
sbfont
- The font object containing information such as the characters from which to create the subsetsubsetSubroutines
- This option will force the subset to include all subroutines.- Returns:
- Returns the subset as a byte array
- Throws:
java.io.IOException
-
stitchFont
public byte[] stitchFont(java.io.ByteArrayOutputStream boasHeader, java.io.ByteArrayOutputStream boasMain, java.io.ByteArrayOutputStream boasTrailer) throws java.io.IOException
- Throws:
java.io.IOException
-
readEncoding
private java.util.List<java.lang.String> readEncoding(PostscriptParser.PSElement encoding)
-
searchEntries
protected java.util.List<java.lang.String> searchEntries(java.util.HashMap<java.lang.Integer,java.lang.String> encodingEntries, int glyph)
-
writeHeader
protected java.io.ByteArrayOutputStream writeHeader(PFBData pfbData, PostscriptParser.PSElement encoding) throws java.io.IOException
- Throws:
java.io.IOException
-
updateSectionSize
java.io.ByteArrayOutputStream updateSectionSize(int size) throws java.io.IOException
- Throws:
java.io.IOException
-
readMainSection
private boolean readMainSection(java.util.List<PostscriptParser.PSElement> mainSection, byte[] decoded, java.util.List<java.lang.String> subsetEncodingEntries, PostscriptParser.PSElement charStrings)
-
createSubsetCharStrings
private byte[] createSubsetCharStrings(byte[] decoded, byte[] data, PostscriptParser.PSFixedArray subroutines, java.util.List<java.lang.String> subsetEncodingEntries)
-
getSubrIndex
private int getSubrIndex(int subID)
-
addSubroutine
private byte[] addSubroutine(PostscriptParser.PSFixedArray subroutines, java.util.List<Type1SubsetFile.BytesNumber> operands, byte[] decoded, java.util.List<java.lang.String> subsetEncodingEntries, byte[] data, int i, int opLength, int existingSubrRef, int subrID)
-
writeMainSection
protected java.io.ByteArrayOutputStream writeMainSection(byte[] decoded, java.util.List<PostscriptParser.PSElement> mainSection, PostscriptParser.PSElement charStrings) throws java.io.IOException
- Throws:
java.io.IOException
-
findVariable
protected java.lang.String findVariable(byte[] decoded, java.util.List<PostscriptParser.PSElement> elements, java.lang.String[] matches, java.lang.String fallback) throws java.io.UnsupportedEncodingException
- Throws:
java.io.UnsupportedEncodingException
-
readVariableContents
java.lang.String readVariableContents(java.lang.String variable)
-
addToCharNames
private void addToCharNames(java.lang.String encodingEntry)
-
writeString
protected void writeString(java.lang.String entry, java.io.ByteArrayOutputStream boas) throws java.io.IOException
- Throws:
java.io.IOException
-
constructNewRefData
private byte[] constructNewRefData(int curDataPos, byte[] currentData, java.util.List<Type1SubsetFile.BytesNumber> operands, int opNum, int curSubsetIndexSize, int operatorLength)
-
getOpPosition
int getOpPosition(int opNum, java.util.List<Type1SubsetFile.BytesNumber> operands)
-
getOperandsLength
int getOperandsLength(java.util.List<Type1SubsetFile.BytesNumber> operands)
-
createNewRef
private byte[] createNewRef(int newRef, int forceLength)
-
concatArray
byte[] concatArray(byte[] a, byte[] b)
Concatenate two byte arrays together- Parameters:
a
- The first arrayb
- The second array- Returns:
- The concatenated array
-
getBinaryEntry
protected byte[] getBinaryEntry(int[] position, byte[] decoded)
Returns a section of a byte array determined by it's start and end position.- Parameters:
position
- An array containing both the start and end position of the section to copy.decoded
- The array from which to copy a section of data- Returns:
- Returns the copy of the data section
-
getEntryPart
protected java.lang.String getEntryPart(java.lang.String entry, int part)
-
getElement
protected PostscriptParser.PSElement getElement(java.lang.String elementID, java.util.List<PostscriptParser.PSElement> elements)
-
-