Package com.sun.pdfview.font
Class Type1CFont
java.lang.Object
com.sun.pdfview.font.PDFFont
com.sun.pdfview.font.OutlineFont
com.sun.pdfview.font.Type1CFont
A representation, with parser, of an Adobe Type 1C font.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription(package private) AffineTransform
(package private) int
(package private) int
(package private) int
(package private) String[]
(package private) static int
(package private) byte[]
(package private) int[]
(package private) int
(package private) static int
(package private) float
(package private) String
(package private) int[]
(package private) int
(package private) int
(package private) int
(package private) int
(package private) String[]
(package private) int
(package private) int
(package private) static int
(package private) int
(package private) int
(package private) int
(package private) float[]
(package private) int
(package private) byte[]
(package private) float[]
(package private) int
-
Constructor Summary
ConstructorsConstructorDescriptionType1CFont
(String baseFont, PDFObject src, PDFFontDescriptor descriptor) create a new Type1CFont based on a font data stream and a descriptor -
Method Summary
Modifier and TypeMethodDescriptionprivate void
buildAccentChar
(float x, float y, char b, char a, GeneralPath gp) build an accented character out of two pre-defined glyphs.int
calcoffset
(int base) calculate an offset code for a dictionary.(package private) Type1CFont.Range
getIndexEntry
(int index, int id) Get the range of a particular index in a dictionary.int
getIndexSize
(int loc) get the size of the dictionary located within the stream at some offset.private int
getNameIndex
(String name) get the index of a particular name.protected GeneralPath
getOutline
(char src, float width) Get a glyph outline by character code Note this method must always return an outlineprotected GeneralPath
getOutline
(String name, float width) Get a glyph outline by namegetSID
(int id) get the name associated with an ID.int
getTableLength
(int loc) return the number of entries in an Index table.private void
parse()
parse the font data.(package private) void
parseGlyph
(Type1CFont.Range r, GeneralPath gp, FlPoint pt) parse a glyph defined in a particular rangeprivate void
a debug method for printing the dataprivate int
readByte()
read the next byte from the streamprivate int
readCommand
(boolean charstring) read a complete command.private void
read a dictionary that exists within some range, parsing the entries within the dictionary.private void
readEncodingData
(int base) parse information about the encoding of this file.void
readFNum()
read the next funky floating point number from the input stream.private GeneralPath
readGlyph
(int base, int offset) Read the data for a glyph from the glyph table, and transform it based on the current transform.private void
readGlyphNames
(int base) read the names of the glyphs.private int
readInt
(int len) read an integer from the input streamprivate void
readNames
(int base) read a list of namesprivate int
readNext
(boolean charstring) read the next decoded value from the streamprivate String
convert a string to one in which any non-printable bytes are replaced by "invalid input: '<'###>" where ## is the value of the byte.Methods inherited from class com.sun.pdfview.font.OutlineFont
getCharCount, getDefaultWidth, getFirstChar, getGlyph, getLastChar, getWidth
Methods inherited from class com.sun.pdfview.font.PDFFont
equals, getBaseFont, getCachedGlyph, getDescriptor, getEncoding, getFont, getGlyphs, getSubtype, getUnicodeMap, hashCode, setBaseFont, setDescriptor, setEncoding, setSubtype, setUnicodeMap, toString
-
Field Details
-
chr2name
String[] chr2name -
data
byte[] data -
pos
int pos -
subrs
byte[] subrs -
stack
float[] stack -
stackptr
int stackptr -
names
String[] names -
glyphnames
int[] glyphnames -
encoding
int[] encoding -
fontname
String fontname -
at
-
num
int num -
fnum
float fnum -
type
int type -
CMD
static int CMD -
NUM
static int NUM -
FLT
static int FLT -
charstringtype
int charstringtype -
temps
float[] temps -
charsetbase
int charsetbase -
encodingbase
int encodingbase -
charstringbase
int charstringbase -
privatebase
int privatebase -
privatesize
int privatesize -
gsubrbase
int gsubrbase -
lsubrbase
int lsubrbase -
gsubrsoffset
int gsubrsoffset -
lsubrsoffset
int lsubrsoffset -
nglyphs
int nglyphs
-
-
Constructor Details
-
Type1CFont
create a new Type1CFont based on a font data stream and a descriptor- Parameters:
baseFont
- the postscript name of this fontsrc
- a stream containing the fontdescriptor
- the descriptor for this font- Throws:
IOException
-
-
Method Details
-
printData
private void printData()a debug method for printing the data -
readNext
private int readNext(boolean charstring) read the next decoded value from the stream- Parameters:
charstring
- ????
-
readFNum
public void readFNum()read the next funky floating point number from the input stream. value gets put into the fnum field. -
readInt
private int readInt(int len) read an integer from the input stream- Parameters:
len
- the number of bytes in the integer- Returns:
- the integer
-
readByte
private int readByte()read the next byte from the stream- Returns:
- the byte
-
getIndexSize
public int getIndexSize(int loc) get the size of the dictionary located within the stream at some offset.- Parameters:
loc
- the index of the start of the dictionary- Returns:
- the size of the dictionary, in bytes.
-
getTableLength
public int getTableLength(int loc) return the number of entries in an Index table.- Parameters:
loc
-- Returns:
-
getIndexEntry
Get the range of a particular index in a dictionary.- Parameters:
index
- the start of the dictionary.id
- the index of the entry in the dictionary- Returns:
- a range describing the offsets of the start and end of the entry from the start of the file, not the dictionary
-
readDict
read a dictionary that exists within some range, parsing the entries within the dictionary. -
readCommand
private int readCommand(boolean charstring) read a complete command. this may involve several numbers which go onto a stack before an actual command is read.- Parameters:
charstring
- ????- Returns:
- the command. Some numbers may also be on the stack.
-
readEncodingData
private void readEncodingData(int base) parse information about the encoding of this file.- Parameters:
base
- the start of the encoding data
-
readGlyphNames
private void readGlyphNames(int base) read the names of the glyphs.- Parameters:
base
- the start of the glyph name table
-
readNames
private void readNames(int base) read a list of names- Parameters:
base
- the start of the name table
-
parse
parse the font data.- Parameters:
encdif
- a dictionary describing the encoding.- Throws:
IOException
-
getNameIndex
get the index of a particular name. The name table starts with the standard names in FontSupport.stdNames, and is appended by any names in the name table from this font's dictionary. -
safe
convert a string to one in which any non-printable bytes are replaced by "invalid input: '<'###>" where ## is the value of the byte. -
readGlyph
Read the data for a glyph from the glyph table, and transform it based on the current transform.- Parameters:
base
- the start of the glyph tableoffset
- the index of this glyph in the glyph table
-
calcoffset
public int calcoffset(int base) calculate an offset code for a dictionary. Uses the count of entries to determine what the offset should be.- Parameters:
base
- the index of the start of the dictionary
-
getSID
get the name associated with an ID.- Parameters:
id
- the index of the name- Returns:
- the name from the FontSupport.stdNames table augmented by the local name table
-
buildAccentChar
build an accented character out of two pre-defined glyphs.- Parameters:
x
- the x offset of the accenty
- the y offset of the accentb
- the index of the base glypha
- the index of the accent glyphgp
- the GeneralPath into which the combined glyph will be written.
-
parseGlyph
parse a glyph defined in a particular range- Parameters:
r
- the range of the glyph definitiongp
- a GeneralPath in which to store the glyph outlinept
- a FlPoint representing the end of the current path
-
getOutline
Get a glyph outline by name- Specified by:
getOutline
in classOutlineFont
- Parameters:
name
- the name of the desired glyph- Returns:
- the glyph outline, or null if unavailable
-
getOutline
Get a glyph outline by character code Note this method must always return an outline- Specified by:
getOutline
in classOutlineFont
- Parameters:
src
- the character code of the desired glyph- Returns:
- the glyph outline
-