Class Type1CFont
java.lang.Object
org.openpdf.renderer.font.PDFFont
org.openpdf.renderer.font.OutlineFont
org.openpdf.renderer.font.Type1CFont
A representation, with parser, of an Adobe Type 1C font.
You can find information about CFF and Type 1C font encoding
in
http://partners.adobe.com/public/developer/en/font/5176.CFF.pdf
and
http://partners.adobe.com/public/developer/en/font/5177.Type2.pdf
-
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) 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 voidbuildAccentChar(float x, float y, char b, char a, 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(String name) get the index of a particular name.protected GeneralPathgetOutline(char src, float width) Get a glyph outline by character code Note this method must always return an outlineprotected GeneralPathgetOutline(String name, float width) Get a glyph outline by namegetSID(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, GeneralPath gp, FlPoint pt) parse a glyph defined in a particular rangeprivate voida debug method for printing the dataprivate intreadByte()read the next byte from the streamprivate intreadCommand(boolean charstring) read a complete command.private voidread 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 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 Stringconvert 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 OutlineFont
getCharCount, getDefaultWidth, getFirstChar, getGlyph, getLastChar, getWidthMethods inherited from class 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 -
stemhints
int stemhints -
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
-
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:
getOutlinein 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:
getOutlinein classOutlineFont- Parameters:
src- the character code of the desired glyph- Returns:
- the glyph outline
-