Package com.sun.pdfview.font
Class PDFFontEncoding
- java.lang.Object
-
- com.sun.pdfview.font.PDFFontEncoding
-
public class PDFFontEncoding extends java.lang.ObjectThe PDFFont encoding encapsulates the mapping from character codes in the PDF document to glyphs of the font. Encodings take two basic forms. For Type1, TrueType, and Type3 fonts, the encoding maps from character codes to Strings, which represent the glyphs of the font. For Type0 fonts, the mapping is a CMap which maps character codes to characters in one of many descendant fonts. Note that the data in the PDF might be ASCII characters (bytes) or it might be a multi-byte format such as unicode. For now we will assume all glyph ids fit into at most the two bytes of a character.
-
-
Field Summary
Fields Modifier and Type Field Description private int[]baseEncodingthe base encoding (an array of integers which can be mapped to names using the methods on FontSupportprivate PDFCMapcmapa CMap for fonts encoded by CMapprivate java.util.Map<java.lang.Character,java.lang.String>differencesany differences from the base encodingprivate inttypethe type of this encoding (encoding or CMap)private static intTYPE_CMAPprivate static intTYPE_ENCODINGEncoding types
-
Constructor Summary
Constructors Constructor Description PDFFontEncoding(java.lang.String fontType, PDFObject encoding)Creates a new instance of PDFFontEncoding
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private int[]getBaseEncoding(java.lang.String encodingName)Get the base encoding for a given nameprivate PDFGlyphgetGlyphFromCMap(PDFFont font, char src)Get a glyph from a CMap, given a Type0 font and a characterprivate PDFGlyphgetGlyphFromEncoding(PDFFont font, char src)Get a glyph from an encoding, given a font and characterjava.util.List<PDFGlyph>getGlyphs(PDFFont font, java.lang.String text)Get the glyphs associated with a given StringvoidparseEncoding(PDFObject encoding)Parse a PDF encoding object for the actual encoding
-
-
-
Field Detail
-
TYPE_ENCODING
private static final int TYPE_ENCODING
Encoding types- See Also:
- Constant Field Values
-
TYPE_CMAP
private static final int TYPE_CMAP
- See Also:
- Constant Field Values
-
baseEncoding
private int[] baseEncoding
the base encoding (an array of integers which can be mapped to names using the methods on FontSupport
-
differences
private java.util.Map<java.lang.Character,java.lang.String> differences
any differences from the base encoding
-
cmap
private PDFCMap cmap
a CMap for fonts encoded by CMap
-
type
private int type
the type of this encoding (encoding or CMap)
-
-
Constructor Detail
-
PDFFontEncoding
public PDFFontEncoding(java.lang.String fontType, PDFObject encoding) throws java.io.IOExceptionCreates a new instance of PDFFontEncoding- Throws:
java.io.IOException
-
-
Method Detail
-
getGlyphs
public java.util.List<PDFGlyph> getGlyphs(PDFFont font, java.lang.String text)
Get the glyphs associated with a given String
-
getGlyphFromEncoding
private PDFGlyph getGlyphFromEncoding(PDFFont font, char src)
Get a glyph from an encoding, given a font and character
-
getGlyphFromCMap
private PDFGlyph getGlyphFromCMap(PDFFont font, char src)
Get a glyph from a CMap, given a Type0 font and a character
-
parseEncoding
public void parseEncoding(PDFObject encoding) throws java.io.IOException
Parse a PDF encoding object for the actual encoding- Throws:
java.io.IOException
-
getBaseEncoding
private int[] getBaseEncoding(java.lang.String encodingName)
Get the base encoding for a given name
-
-