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
-
public class Type1CFont extends OutlineFont
A representation, with parser, of an Adobe Type 1C font.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classType1CFont.RangeA range.
-
Field Summary
Fields Modifier and Type Field Description (package private) java.awt.geom.AffineTransformat(package private) intcharsetbase(package private) intcharstringbase(package private) intcharstringtype(package private) java.lang.String[]chr2name(package private) static intCMD(package private) byte[]data(package private) int[]encoding(package private) intencodingbase(package private) static intFLT(package private) floatfnum(package private) java.lang.Stringfontname(package private) int[]glyphnames(package private) intgsubrbase(package private) intgsubrsoffset(package private) intlsubrbase(package private) intlsubrsoffset(package private) java.lang.String[]names(package private) intnglyphs(package private) intnum(package private) static intNUM(package private) intpos(package private) intprivatebase(package private) intprivatesize(package private) float[]stack(package private) intstackptr(package private) byte[]subrs(package private) float[]temps(package private) inttype
-
Constructor Summary
Constructors Constructor Description Type1CFont(java.lang.String baseFont, PDFObject src, PDFFontDescriptor descriptor)create a new Type1CFont based on a font data stream and a descriptor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidbuildAccentChar(float x, float y, char b, char a, java.awt.geom.GeneralPath gp)build an accented character out of two pre-defined glyphs.intcalcoffset(int base)calculate an offset code for a dictionary.(package private) Type1CFont.RangegetIndexEntry(int index, int id)Get the range of a particular index in a dictionary.intgetIndexSize(int loc)get the size of the dictionary located within the stream at some offset.private intgetNameIndex(java.lang.String name)get the index of a particular name.protected java.awt.geom.GeneralPathgetOutline(char src, float width)Get a glyph outline by character code Note this method must always return an outlineprotected java.awt.geom.GeneralPathgetOutline(java.lang.String name, float width)Get a glyph outline by namejava.lang.StringgetSID(int id)get the name associated with an ID.intgetTableLength(int loc)return the number of entries in an Index table.private voidparse()parse the font data.(package private) voidparseGlyph(Type1CFont.Range r, java.awt.geom.GeneralPath gp, FlPoint pt)parse a glyph defined in a particular rangeprivate voidprintData()a debug method for printing the dataprivate intreadByte()read the next byte from the streamprivate intreadCommand(boolean charstring)read a complete command.private voidreadDict(Type1CFont.Range r)read a dictionary that exists within some range, parsing the entries within the dictionary.private voidreadEncodingData(int base)parse information about the encoding of this file.voidreadFNum()read the next funky floating point number from the input stream.private java.awt.geom.GeneralPathreadGlyph(int base, int offset)Read the data for a glyph from the glyph table, and transform it based on the current transform.private voidreadGlyphNames(int base)read the names of the glyphs.private intreadInt(int len)read an integer from the input streamprivate voidreadNames(int base)read a list of namesprivate intreadNext(boolean charstring)read the next decoded value from the streamprivate java.lang.Stringsafe(java.lang.String src)convert a string to one in which any non-printable bytes are replaced by "<###>" 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 Detail
-
chr2name
java.lang.String[] chr2name
-
data
byte[] data
-
pos
int pos
-
subrs
byte[] subrs
-
stack
float[] stack
-
stackptr
int stackptr
-
names
java.lang.String[] names
-
glyphnames
int[] glyphnames
-
encoding
int[] encoding
-
fontname
java.lang.String fontname
-
at
java.awt.geom.AffineTransform 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 Detail
-
Type1CFont
public Type1CFont(java.lang.String baseFont, PDFObject src, PDFFontDescriptor descriptor) throws java.io.IOExceptioncreate 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:
java.io.IOException
-
-
Method Detail
-
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
Type1CFont.Range getIndexEntry(int index, int id)
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
private void readDict(Type1CFont.Range r)
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
private void parse() throws java.io.IOExceptionparse the font data.- Parameters:
encdif- a dictionary describing the encoding.- Throws:
java.io.IOException
-
getNameIndex
private int getNameIndex(java.lang.String name)
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
private java.lang.String safe(java.lang.String src)
convert a string to one in which any non-printable bytes are replaced by "<###>" where ## is the value of the byte.
-
readGlyph
private java.awt.geom.GeneralPath readGlyph(int base, int offset)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
public java.lang.String getSID(int id)
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
private void buildAccentChar(float x, float y, char b, char a, java.awt.geom.GeneralPath gp)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
void parseGlyph(Type1CFont.Range r, java.awt.geom.GeneralPath gp, FlPoint pt)
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
protected java.awt.geom.GeneralPath getOutline(java.lang.String name, float width)Get a glyph outline by name- Specified by:
getOutlinein classOutlineFont- Parameters:
name- the name of the desired glyph- Returns:
- the glyph outline, or null if unavailable
-
getOutline
protected java.awt.geom.GeneralPath getOutline(char src, float width)Get a glyph outline by character code Note this method must always return an outline- Specified by:
getOutlinein classOutlineFont- Parameters:
src- the character code of the desired glyph- Returns:
- the glyph outline
-
-