Package org.apache.fop.fonts.type1
Class Type1SubsetFile
java.lang.Object
org.apache.fop.fonts.type1.Type1SubsetFile
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A class to encode and decode sections of a type 1 font file.static final class
A class used to store the last number operand and also it's size in bytes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
private byte[]
protected List<PostscriptParser.PSElement>
protected static final org.apache.commons.logging.Log
protected List<PostscriptParser.PSElement>
private static final int
private static final int
private static final int
private SingleByteFont
protected boolean
protected boolean
protected LinkedHashMap<Integer,
byte[]> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate byte[]
addSubroutine
(PostscriptParser.PSFixedArray subroutines, List<Type1SubsetFile.BytesNumber> operands, byte[] decoded, List<String> subsetEncodingEntries, byte[] data, int i, int opLength, int existingSubrRef, int subrID) private void
addToCharNames
(String encodingEntry) (package private) byte[]
concatArray
(byte[] a, byte[] b) Concatenate two byte arrays togetherprivate byte[]
constructNewRefData
(int curDataPos, byte[] currentData, List<Type1SubsetFile.BytesNumber> operands, int opNum, int curSubsetIndexSize, int operatorLength) private byte[]
createNewRef
(int newRef, int forceLength) byte[]
createSubset
(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, List<String> subsetEncodingEntries) protected String
findVariable
(byte[] decoded, List<PostscriptParser.PSElement> elements, String[] matches, 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
(String elementID, List<PostscriptParser.PSElement> elements) protected String
getEntryPart
(String entry, int part) (package private) int
getOperandsLength
(List<Type1SubsetFile.BytesNumber> operands) (package private) int
getOpPosition
(int opNum, List<Type1SubsetFile.BytesNumber> operands) private int
getSubrIndex
(int subID) readEncoding
(PostscriptParser.PSElement encoding) private boolean
readMainSection
(List<PostscriptParser.PSElement> mainSection, byte[] decoded, List<String> subsetEncodingEntries, PostscriptParser.PSElement charStrings) (package private) String
readVariableContents
(String variable) searchEntries
(HashMap<Integer, String> encodingEntries, int glyph) byte[]
stitchFont
(ByteArrayOutputStream boasHeader, ByteArrayOutputStream boasMain, ByteArrayOutputStream boasTrailer) (package private) ByteArrayOutputStream
updateSectionSize
(int size) protected ByteArrayOutputStream
writeHeader
(PFBData pfbData, PostscriptParser.PSElement encoding) protected ByteArrayOutputStream
writeMainSection
(byte[] decoded, List<PostscriptParser.PSElement> mainSection, PostscriptParser.PSElement charStrings) protected void
writeString
(String entry, ByteArrayOutputStream boas)
-
Field Details
-
LOG
protected static final org.apache.commons.logging.Log LOG -
subsetCharStrings
-
charNames
-
uniqueSubs
-
sbfont
-
eol
-
subsetSubroutines
protected boolean subsetSubroutines -
fullFont
private byte[] fullFont -
headerSection
-
mainSection
-
standardEncoding
protected boolean standardEncoding -
OP_SEAC
private static final int OP_SEAC- See Also:
-
OP_CALLSUBR
private static final int OP_CALLSUBR- See Also:
-
OP_CALLOTHERSUBR
private static final int OP_CALLOTHERSUBR- See Also:
-
-
Constructor Details
-
Type1SubsetFile
public Type1SubsetFile()
-
-
Method Details
-
createSubset
- Throws:
IOException
-
createSubset
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:
IOException
-
stitchFont
public byte[] stitchFont(ByteArrayOutputStream boasHeader, ByteArrayOutputStream boasMain, ByteArrayOutputStream boasTrailer) throws IOException - Throws:
IOException
-
readEncoding
-
searchEntries
-
writeHeader
protected ByteArrayOutputStream writeHeader(PFBData pfbData, PostscriptParser.PSElement encoding) throws IOException - Throws:
IOException
-
updateSectionSize
- Throws:
IOException
-
readMainSection
private boolean readMainSection(List<PostscriptParser.PSElement> mainSection, byte[] decoded, List<String> subsetEncodingEntries, PostscriptParser.PSElement charStrings) -
createSubsetCharStrings
private byte[] createSubsetCharStrings(byte[] decoded, byte[] data, PostscriptParser.PSFixedArray subroutines, List<String> subsetEncodingEntries) -
getSubrIndex
private int getSubrIndex(int subID) -
addSubroutine
private byte[] addSubroutine(PostscriptParser.PSFixedArray subroutines, List<Type1SubsetFile.BytesNumber> operands, byte[] decoded, List<String> subsetEncodingEntries, byte[] data, int i, int opLength, int existingSubrRef, int subrID) -
writeMainSection
protected ByteArrayOutputStream writeMainSection(byte[] decoded, List<PostscriptParser.PSElement> mainSection, PostscriptParser.PSElement charStrings) throws IOException - Throws:
IOException
-
findVariable
protected String findVariable(byte[] decoded, List<PostscriptParser.PSElement> elements, String[] matches, String fallback) throws UnsupportedEncodingException - Throws:
UnsupportedEncodingException
-
readVariableContents
-
addToCharNames
-
writeString
- Throws:
IOException
-
constructNewRefData
private byte[] constructNewRefData(int curDataPos, byte[] currentData, List<Type1SubsetFile.BytesNumber> operands, int opNum, int curSubsetIndexSize, int operatorLength) -
getOpPosition
-
getOperandsLength
-
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
-
getElement
protected PostscriptParser.PSElement getElement(String elementID, List<PostscriptParser.PSElement> elements)
-