Java Doc for BaseFont.java in  » PDF » pdf-itext » com » lowagie » text » pdf » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » PDF » pdf itext » com.lowagie.text.pdf 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.lowagie.text.pdf.BaseFont

All known Subclasses:   com.lowagie.text.pdf.Type3Font,  com.lowagie.text.pdf.CJKFont,  com.lowagie.text.pdf.TrueTypeFont,  com.lowagie.text.pdf.DocumentFont,  com.lowagie.text.pdf.Type1Font,
BaseFont
abstract public class BaseFont (Code)
Base class for the several font types supported
author:
   Paulo Soares (psoares@consiste.pt)

Inner Class :static class StreamFont extends PdfStream

Field Summary
final public static  intASCENT
     The maximum height above the baseline reached by glyphs in this font, excluding the height of glyphs for accented characters.
final public static  intAWT_ASCENT
    
final public static  intAWT_DESCENT
    
final public static  intAWT_LEADING
    
final public static  intAWT_MAXADVANCE
    
final public static  intBBOXLLX
     The lower left x glyph coordinate.
final public static  intBBOXLLY
     The lower left y glyph coordinate.
final public static  intBBOXURX
     The upper right x glyph coordinate.
final public static  intBBOXURY
     The upper right y glyph coordinate.
final protected static  HashMapBuiltinFonts14
     list of the 14 built in fonts.
final public static  booleanCACHED
    
final public static  intCAPHEIGHT
     The y coordinate of the top of flat capital letters, measured from the baseline.
final public static  int[]CHAR_RANGE_ARABIC
    
final public static  int[]CHAR_RANGE_CYRILLIC
    
final public static  int[]CHAR_RANGE_HEBREW
    
final public static  int[]CHAR_RANGE_LATIN
    
final public static  charCID_NEWLINE
     The fake CID code that represents a newline.
final public static  StringCOURIER
    
final public static  StringCOURIER_BOLD
    
final public static  StringCOURIER_BOLDOBLIQUE
    
final public static  StringCOURIER_OBLIQUE
    
final public static  StringCP1250
     A possible encoding.
final public static  StringCP1252
     A possible encoding.
final public static  StringCP1257
     A possible encoding.
final public static  intDESCENT
     The maximum depth below the baseline reached by glyphs in this font.
final public static  booleanEMBEDDED
    
final public static  intFONT_TYPE_CJK
     The font is CJK.
final public static  intFONT_TYPE_DOCUMENT
     A font already inside the document.
final public static  intFONT_TYPE_T1
     The font is Type 1.
final public static  intFONT_TYPE_T3
     A Type3 font.
final public static  intFONT_TYPE_TT
     The font is True Type with a standard encoding.
final public static  intFONT_TYPE_TTUNI
     The font is True Type with a Unicode encoding.
final public static  StringHELVETICA
    
final public static  StringHELVETICA_BOLD
    
final public static  StringHELVETICA_BOLDOBLIQUE
    
final public static  StringHELVETICA_OBLIQUE
    
final public static  StringIDENTITY_H
     The Unicode encoding with horizontal writing.
final public static  StringIDENTITY_V
     The Unicode encoding with vertical writing.
final public static  intITALICANGLE
     The angle, expressed in degrees counterclockwise from the vertical, of the dominant vertical strokes of the font.
final public static  StringMACROMAN
     A possible encoding.
final public static  booleanNOT_CACHED
    
final public static  booleanNOT_EMBEDDED
    
final public static  StringRESOURCE_PATH
     The path to the font resources.
final public static  StringSYMBOL
    
final public static  StringTIMES_BOLD
    
final public static  StringTIMES_BOLDITALIC
    
final public static  StringTIMES_ITALIC
    
final public static  StringTIMES_ROMAN
    
final public static  StringWINANSI
     A possible encoding.
final public static  StringZAPFDINGBATS
    
protected  intcharBBoxes
    
protected  Stringdifferences
    
protected  booleandirectTextToByte
     Converts char directly to byte by casting.
protected  booleanembedded
    
protected  Stringencoding
    
protected  booleanfastWinansi
    
protected static  HashMapfontCache
     cache for the fonts already used.
protected  booleanfontSpecific
     true if the font must use it's built in encoding.
 intfontType
     The font type.
protected  booleanforceWidthsOutput
     Forces the output of the width array.
final public static  Stringnotdef
    
protected  IntHashtablespecialMap
     Custom encodings use this map to key the Unicode character to the single byte code.
protected  booleansubset
     Indicates if all the glyphs and widths for that particular encoding should be included in the document.
protected  ArrayListsubsetRanges
    
protected  charunicodeDifferences
    
protected  intwidths
    

Constructor Summary
protected  BaseFont()
    

Method Summary
public  voidaddSubsetRange(int[] range)
     Adds a character range when subsetting.
public  booleancharExists(char c)
     Checks if a character exists in this font.
 byte[]convertToBytes(String text)
     Converts a String to a byte array according to the font's encoding.
 byte[]convertToBytes(char char1)
     Converts a char to a byte array according to the font's encoding.
public  voidcorrectArabicAdvance()
     iText expects Arabic Diactrics (tashkeel) to have zero advance but some fonts, most notably those that come with Windows, like times.ttf, have non-zero advance for those characters.
protected  voidcreateEncoding()
    
public static  BaseFontcreateFont(String name, String encoding, boolean embedded)
     Creates a new font.
public static  BaseFontcreateFont(String name, String encoding, boolean embedded, boolean cached, byte ttfAfm, byte pfb)
     Creates a new font.
public static  BaseFontcreateFont(String name, String encoding, boolean embedded, boolean cached, byte ttfAfm, byte pfb, boolean noThrow)
     Creates a new font.
public static  BaseFontcreateFont(PRIndirectReference fontRef)
     Creates a font based on an existing document font.
public static  StringcreateSubsetPrefix()
     Creates a unique subset prefix to be added to the font name when the font is embedded and subset.
public static  String[]enumerateTTCNames(String ttcFile)
     Enumerates the postscript font names present inside a True Type Collection.
public static  String[]enumerateTTCNames(byte ttcArray)
     Enumerates the postscript font names present inside a True Type Collection.
public static  Object[]getAllFontNames(String name, String encoding, byte ttfAfm)
     Gets all the names from the font.
public  intgetAscent(String text)
     Gets the ascent of a String in normalized 1000 units.
public  floatgetAscentPoint(String text, float fontSize)
     Gets the ascent of a String in points.
protected static  StringgetBaseName(String name)
     Gets the name without the modifiers Bold, Italic or BoldItalic.
public  int[]getCharBBox(char c)
     Gets the smallest box enclosing the character contours.
public  chargetCidCode(char c)
     Gets the CID code given an Unicode.
public  String[]getCodePagesSupported()
     Gets the code pages supported by the font.
public  intgetDescent(String text)
     Gets the descent of a String in normalized 1000 units.
public  floatgetDescentPoint(String text, float fontSize)
     Gets the descent of a String in points.
public  String[]getDifferences()
     Gets the array with the names of the characters.
public static  ArrayListgetDocumentFonts(PdfReader reader)
     Gets a list of all document fonts.
public static  ArrayListgetDocumentFonts(PdfReader reader, int page)
     Gets a list of the document fonts in a particular page.
public  StringgetEncoding()
     Gets the encoding used to convert String into byte[].
abstract public  String[][]getFamilyFontName()
     Gets the family name of the font.
abstract public  floatgetFontDescriptor(int key, float fontSize)
     Gets the font parameter identified by key.
public  intgetFontType()
     Gets the font type.
abstract public  String[][]getFullFontName()
     Gets the full name of the font.
public static  String[][]getFullFontName(String name, String encoding, byte ttfAfm)
     Gets the full name of the font.
abstract public  intgetKerning(char char1, char char2)
     Gets the kerning between two Unicode chars.
abstract public  StringgetPostscriptFontName()
     Gets the postscript font name.
abstract protected  int[]getRawCharBBox(int c, String name)
    
abstract  intgetRawWidth(int c, String name)
     Gets the width from the font according to the Unicode char c or the name.
public static  InputStreamgetResourceStream(String key)
     Gets the font resources.
public static  InputStreamgetResourceStream(String key, ClassLoader loader)
     Gets the font resources.
 chargetUnicodeDifferences(int index)
     Gets the Unicode character corresponding to the byte output to the pdf stream.
public  char[]getUnicodeDifferences()
     Gets the array with the unicode characters.
public  chargetUnicodeEquivalent(char c)
     Gets the Unicode equivalent to a CID. The (inexistent) CID is translated as '\n'.
public  intgetWidth(char char1)
     Gets the width of a char in normalized 1000 units.
public  intgetWidth(String text)
     Gets the width of a String in normalized 1000 units.
public  floatgetWidthPoint(String text, float fontSize)
     Gets the width of a String in points.
public  floatgetWidthPoint(char char1, float fontSize)
     Gets the width of a char in points.
public  floatgetWidthPointKerned(String text, float fontSize)
     Gets the width of a String in points taking kerning into account.
public  int[]getWidths()
     Gets the font width array.
abstract public  booleanhasKernPairs()
     Checks if the font has any kerning pairs.
public  booleanisDirectTextToByte()
     Gets the direct conversion of char to byte.
public  booleanisEmbedded()
     Gets the embedded flag.
public  booleanisFontSpecific()
     Gets the symbolic flag of the font.
public  booleanisForceWidthsOutput()
     Gets the state of the property.
public  booleanisSubset()
     Indicates if all the glyphs and widths for that particular encoding should be included in the document.
protected static  StringnormalizeEncoding(String enc)
     Normalize the encoding names.
public  booleansetCharAdvance(char c, int advance)
     Sets the character advance.
public  voidsetDirectTextToByte(boolean directTextToByte)
     Sets the conversion of char directly to byte by casting.
public  voidsetForceWidthsOutput(boolean forceWidthsOutput)
     Set to true to force the generation of the widths array.
abstract public  booleansetKerning(char char1, char char2, int kern)
     Sets the kerning between two Unicode chars.
abstract public  voidsetPostscriptFontName(String name)
     Sets the font name that will appear in the pdf font dictionary.
public  voidsetSubset(boolean subset)
     Indicates if all the glyphs and widths for that particular encoding should be included in the document.
abstract  voidwriteFont(PdfWriter writer, PdfIndirectReference ref, Object params)
     Outputs to the writer the font dictionaries and streams.

Field Detail
ASCENT
final public static int ASCENT(Code)
The maximum height above the baseline reached by glyphs in this font, excluding the height of glyphs for accented characters.



AWT_ASCENT
final public static int AWT_ASCENT(Code)
java.awt.Font property



AWT_DESCENT
final public static int AWT_DESCENT(Code)
java.awt.Font property



AWT_LEADING
final public static int AWT_LEADING(Code)
java.awt.Font property



AWT_MAXADVANCE
final public static int AWT_MAXADVANCE(Code)
java.awt.Font property



BBOXLLX
final public static int BBOXLLX(Code)
The lower left x glyph coordinate.



BBOXLLY
final public static int BBOXLLY(Code)
The lower left y glyph coordinate.



BBOXURX
final public static int BBOXURX(Code)
The upper right x glyph coordinate.



BBOXURY
final public static int BBOXURY(Code)
The upper right y glyph coordinate.



BuiltinFonts14
final protected static HashMap BuiltinFonts14(Code)
list of the 14 built in fonts.



CACHED
final public static boolean CACHED(Code)
if the font has to be cached



CAPHEIGHT
final public static int CAPHEIGHT(Code)
The y coordinate of the top of flat capital letters, measured from the baseline.



CHAR_RANGE_ARABIC
final public static int[] CHAR_RANGE_ARABIC(Code)



CHAR_RANGE_CYRILLIC
final public static int[] CHAR_RANGE_CYRILLIC(Code)



CHAR_RANGE_HEBREW
final public static int[] CHAR_RANGE_HEBREW(Code)



CHAR_RANGE_LATIN
final public static int[] CHAR_RANGE_LATIN(Code)



CID_NEWLINE
final public static char CID_NEWLINE(Code)
The fake CID code that represents a newline.



COURIER
final public static String COURIER(Code)
This is a possible value of a base 14 type 1 font



COURIER_BOLD
final public static String COURIER_BOLD(Code)
This is a possible value of a base 14 type 1 font



COURIER_BOLDOBLIQUE
final public static String COURIER_BOLDOBLIQUE(Code)
This is a possible value of a base 14 type 1 font



COURIER_OBLIQUE
final public static String COURIER_OBLIQUE(Code)
This is a possible value of a base 14 type 1 font



CP1250
final public static String CP1250(Code)
A possible encoding.



CP1252
final public static String CP1252(Code)
A possible encoding.



CP1257
final public static String CP1257(Code)
A possible encoding.



DESCENT
final public static int DESCENT(Code)
The maximum depth below the baseline reached by glyphs in this font. The value is a negative number.



EMBEDDED
final public static boolean EMBEDDED(Code)
if the font has to be embedded



FONT_TYPE_CJK
final public static int FONT_TYPE_CJK(Code)
The font is CJK.



FONT_TYPE_DOCUMENT
final public static int FONT_TYPE_DOCUMENT(Code)
A font already inside the document.



FONT_TYPE_T1
final public static int FONT_TYPE_T1(Code)
The font is Type 1.



FONT_TYPE_T3
final public static int FONT_TYPE_T3(Code)
A Type3 font.



FONT_TYPE_TT
final public static int FONT_TYPE_TT(Code)
The font is True Type with a standard encoding.



FONT_TYPE_TTUNI
final public static int FONT_TYPE_TTUNI(Code)
The font is True Type with a Unicode encoding.



HELVETICA
final public static String HELVETICA(Code)
This is a possible value of a base 14 type 1 font



HELVETICA_BOLD
final public static String HELVETICA_BOLD(Code)
This is a possible value of a base 14 type 1 font



HELVETICA_BOLDOBLIQUE
final public static String HELVETICA_BOLDOBLIQUE(Code)
This is a possible value of a base 14 type 1 font



HELVETICA_OBLIQUE
final public static String HELVETICA_OBLIQUE(Code)
This is a possible value of a base 14 type 1 font



IDENTITY_H
final public static String IDENTITY_H(Code)
The Unicode encoding with horizontal writing.



IDENTITY_V
final public static String IDENTITY_V(Code)
The Unicode encoding with vertical writing.



ITALICANGLE
final public static int ITALICANGLE(Code)
The angle, expressed in degrees counterclockwise from the vertical, of the dominant vertical strokes of the font. The value is negative for fonts that slope to the right, as almost all italic fonts do.



MACROMAN
final public static String MACROMAN(Code)
A possible encoding.



NOT_CACHED
final public static boolean NOT_CACHED(Code)
if the font doesn't have to be cached



NOT_EMBEDDED
final public static boolean NOT_EMBEDDED(Code)
if the font doesn't have to be embedded



RESOURCE_PATH
final public static String RESOURCE_PATH(Code)
The path to the font resources.



SYMBOL
final public static String SYMBOL(Code)
This is a possible value of a base 14 type 1 font



TIMES_BOLD
final public static String TIMES_BOLD(Code)
This is a possible value of a base 14 type 1 font



TIMES_BOLDITALIC
final public static String TIMES_BOLDITALIC(Code)
This is a possible value of a base 14 type 1 font



TIMES_ITALIC
final public static String TIMES_ITALIC(Code)
This is a possible value of a base 14 type 1 font



TIMES_ROMAN
final public static String TIMES_ROMAN(Code)
This is a possible value of a base 14 type 1 font



WINANSI
final public static String WINANSI(Code)
A possible encoding.



ZAPFDINGBATS
final public static String ZAPFDINGBATS(Code)
This is a possible value of a base 14 type 1 font



charBBoxes
protected int charBBoxes(Code)



differences
protected String differences(Code)
encoding names



directTextToByte
protected boolean directTextToByte(Code)
Converts char directly to byte by casting.



embedded
protected boolean embedded(Code)
true if the font is to be embedded in the PDF



encoding
protected String encoding(Code)
encoding used with this font



fastWinansi
protected boolean fastWinansi(Code)



fontCache
protected static HashMap fontCache(Code)
cache for the fonts already used.



fontSpecific
protected boolean fontSpecific(Code)
true if the font must use it's built in encoding. In that case the encoding is only used to map a char to the position inside the font, not to the expected char name.



fontType
int fontType(Code)
The font type.



forceWidthsOutput
protected boolean forceWidthsOutput(Code)
Forces the output of the width array. Only matters for the 14 built-in fonts.



notdef
final public static String notdef(Code)
a not defined character in a custom PDF encoding



specialMap
protected IntHashtable specialMap(Code)
Custom encodings use this map to key the Unicode character to the single byte code.



subset
protected boolean subset(Code)
Indicates if all the glyphs and widths for that particular encoding should be included in the document.



subsetRanges
protected ArrayList subsetRanges(Code)



unicodeDifferences
protected char unicodeDifferences(Code)
same as differences but with the unicode codes



widths
protected int widths(Code)
table of characters widths for this encoding




Constructor Detail
BaseFont
protected BaseFont()(Code)
Creates new BaseFont




Method Detail
addSubsetRange
public void addSubsetRange(int[] range)(Code)
Adds a character range when subsetting. The range is an int array where the first element is the start range inclusive and the second element is the end range inclusive. Several ranges are allowed in the same array.
Parameters:
  range - the character range



charExists
public boolean charExists(char c)(Code)
Checks if a character exists in this font.
Parameters:
  c - the character to check true if the character has a glyph,false otherwise



convertToBytes
byte[] convertToBytes(String text)(Code)
Converts a String to a byte array according to the font's encoding.
Parameters:
  text - the String to be converted an array of byte representing the conversion according to the font's encoding



convertToBytes
byte[] convertToBytes(char char1)(Code)
Converts a char to a byte array according to the font's encoding.
Parameters:
  char1 - the char to be converted an array of byte representing the conversion according to the font's encoding



correctArabicAdvance
public void correctArabicAdvance()(Code)
iText expects Arabic Diactrics (tashkeel) to have zero advance but some fonts, most notably those that come with Windows, like times.ttf, have non-zero advance for those characters. This method makes those character to have zero width advance and work correctly in the iText Arabic shaping and reordering context.



createEncoding
protected void createEncoding()(Code)
Creates the widths and the differences arrays



createFont
public static BaseFont createFont(String name, String encoding, boolean embedded) throws DocumentException, IOException(Code)
Creates a new font. This font can be one of the 14 built in types, a Type1 font referred to by an AFM or PFM file, a TrueType font (simple or collection) or a CJK font from the Adobe Asian Font Pack. TrueType fonts and CJK fonts can have an optional style modifier appended to the name. These modifiers are: Bold, Italic and BoldItalic. An example would be "STSong-Light,Bold". Note that this modifiers do not work if the font is embedded. Fonts in TrueType collections are addressed by index such as "msgothic.ttc,1". This would get the second font (indexes start at 0), in this case "MS PGothic".

The fonts are cached and if they already exist they are extracted from the cache, not parsed again.

Besides the common encodings described by name, custom encodings can also be made. These encodings will only work for the single byte fonts Type1 and TrueType. The encoding string starts with a '#' followed by "simple" or "full". If "simple" there is a decimal for the first character position and then a list of hex values representing the Unicode codes that compose that encoding.
The "simple" encoding is recommended for TrueType fonts as the "full" encoding risks not matching the character with the right glyph if not done with care.
The "full" encoding is specially aimed at Type1 fonts where the glyphs have to be described by non standard names like the Tex math fonts. Each group of three elements compose a code position: the one byte code order in decimal or as 'x' (x cannot be the space), the name and the Unicode character used to access the glyph. The space must be assigned to character position 32 otherwise text justification will not work.

Example for a "simple" encoding that includes the Unicode character space, A, B and ecyrillic:

 "# simple 32 0020 0041 0042 0454"
 

Example for a "full" encoding for a Type1 Tex font:

 "# full 'A' nottriangeqlleft 0041 'B' dividemultiply 0042 32 space 0020"
 

This method calls:

 createFont(name, encoding, embedded, true, null, null);
 

Parameters:
  name - the name of the font or it's location on file
Parameters:
  encoding - the encoding to be applied to this font
Parameters:
  embedded - true if the font is to be embedded in the PDF returns a new font. This font may come from the cache
throws:
  DocumentException - the font is invalid
throws:
  IOException - the font file could not be read



createFont
public static BaseFont createFont(String name, String encoding, boolean embedded, boolean cached, byte ttfAfm, byte pfb) throws DocumentException, IOException(Code)
Creates a new font. This font can be one of the 14 built in types, a Type1 font referred to by an AFM or PFM file, a TrueType font (simple or collection) or a CJK font from the Adobe Asian Font Pack. TrueType fonts and CJK fonts can have an optional style modifier appended to the name. These modifiers are: Bold, Italic and BoldItalic. An example would be "STSong-Light,Bold". Note that this modifiers do not work if the font is embedded. Fonts in TrueType collections are addressed by index such as "msgothic.ttc,1". This would get the second font (indexes start at 0), in this case "MS PGothic".

The fonts may or may not be cached depending on the flag cached. If the byte arrays are present the font will be read from them instead of the name. A name is still required to identify the font type.

Besides the common encodings described by name, custom encodings can also be made. These encodings will only work for the single byte fonts Type1 and TrueType. The encoding string starts with a '#' followed by "simple" or "full". If "simple" there is a decimal for the first character position and then a list of hex values representing the Unicode codes that compose that encoding.
The "simple" encoding is recommended for TrueType fonts as the "full" encoding risks not matching the character with the right glyph if not done with care.
The "full" encoding is specially aimed at Type1 fonts where the glyphs have to be described by non standard names like the Tex math fonts. Each group of three elements compose a code position: the one byte code order in decimal or as 'x' (x cannot be the space), the name and the Unicode character used to access the glyph. The space must be assigned to character position 32 otherwise text justification will not work.

Example for a "simple" encoding that includes the Unicode character space, A, B and ecyrillic:

 "# simple 32 0020 0041 0042 0454"
 

Example for a "full" encoding for a Type1 Tex font:

 "# full 'A' nottriangeqlleft 0041 'B' dividemultiply 0042 32 space 0020"
 

Parameters:
  name - the name of the font or it's location on file
Parameters:
  encoding - the encoding to be applied to this font
Parameters:
  embedded - true if the font is to be embedded in the PDF
Parameters:
  cached - true if the font comes from the cache or is added tothe cache if new, false if the font is always created new
Parameters:
  ttfAfm - the true type font or the afm in a byte array
Parameters:
  pfb - the pfb in a byte array returns a new font. This font may come from the cache but only if cachedis true, otherwise it will always be created new
throws:
  DocumentException - the font is invalid
throws:
  IOException - the font file could not be read



createFont
public static BaseFont createFont(String name, String encoding, boolean embedded, boolean cached, byte ttfAfm, byte pfb, boolean noThrow) throws DocumentException, IOException(Code)
Creates a new font. This font can be one of the 14 built in types, a Type1 font referred to by an AFM or PFM file, a TrueType font (simple or collection) or a CJK font from the Adobe Asian Font Pack. TrueType fonts and CJK fonts can have an optional style modifier appended to the name. These modifiers are: Bold, Italic and BoldItalic. An example would be "STSong-Light,Bold". Note that this modifiers do not work if the font is embedded. Fonts in TrueType collections are addressed by index such as "msgothic.ttc,1". This would get the second font (indexes start at 0), in this case "MS PGothic".

The fonts may or may not be cached depending on the flag cached. If the byte arrays are present the font will be read from them instead of the name. A name is still required to identify the font type.

Besides the common encodings described by name, custom encodings can also be made. These encodings will only work for the single byte fonts Type1 and TrueType. The encoding string starts with a '#' followed by "simple" or "full". If "simple" there is a decimal for the first character position and then a list of hex values representing the Unicode codes that compose that encoding.
The "simple" encoding is recommended for TrueType fonts as the "full" encoding risks not matching the character with the right glyph if not done with care.
The "full" encoding is specially aimed at Type1 fonts where the glyphs have to be described by non standard names like the Tex math fonts. Each group of three elements compose a code position: the one byte code order in decimal or as 'x' (x cannot be the space), the name and the Unicode character used to access the glyph. The space must be assigned to character position 32 otherwise text justification will not work.

Example for a "simple" encoding that includes the Unicode character space, A, B and ecyrillic:

 "# simple 32 0020 0041 0042 0454"
 

Example for a "full" encoding for a Type1 Tex font:

 "# full 'A' nottriangeqlleft 0041 'B' dividemultiply 0042 32 space 0020"
 

Parameters:
  name - the name of the font or it's location on file
Parameters:
  encoding - the encoding to be applied to this font
Parameters:
  embedded - true if the font is to be embedded in the PDF
Parameters:
  cached - true if the font comes from the cache or is added tothe cache if new, false if the font is always created new
Parameters:
  ttfAfm - the true type font or the afm in a byte array
Parameters:
  pfb - the pfb in a byte array
Parameters:
  noThrow - if true will not throw an exception if the font is not recognized and will return null, if false will throwan exception if the font is not recognized. Note that even if true an exception may be thrown in some circumstances.This parameter is useful for FontFactory that may have to check many invalid font names before finding the right one returns a new font. This font may come from the cache but only if cachedis true, otherwise it will always be created new
throws:
  DocumentException - the font is invalid
throws:
  IOException - the font file could not be read



createFont
public static BaseFont createFont(PRIndirectReference fontRef)(Code)
Creates a font based on an existing document font. The created font font may not behave as expected, depending on the encoding or subset.
Parameters:
  fontRef - the reference to the document font the font



createSubsetPrefix
public static String createSubsetPrefix()(Code)
Creates a unique subset prefix to be added to the font name when the font is embedded and subset. the subset prefix



enumerateTTCNames
public static String[] enumerateTTCNames(String ttcFile) throws DocumentException, IOException(Code)
Enumerates the postscript font names present inside a True Type Collection.
Parameters:
  ttcFile - the file name of the font
throws:
  DocumentException - on error
throws:
  IOException - on error the postscript font names



enumerateTTCNames
public static String[] enumerateTTCNames(byte ttcArray) throws DocumentException, IOException(Code)
Enumerates the postscript font names present inside a True Type Collection.
Parameters:
  ttcArray - the font as a byte array
throws:
  DocumentException - on error
throws:
  IOException - on error the postscript font names



getAllFontNames
public static Object[] getAllFontNames(String name, String encoding, byte ttfAfm) throws DocumentException, IOException(Code)
Gets all the names from the font. Only the required tables are read.
Parameters:
  name - the name of the font
Parameters:
  encoding - the encoding of the font
Parameters:
  ttfAfm - the true type font or the afm in a byte array
throws:
  DocumentException - on error
throws:
  IOException - on error an array of Object[] built with {getPostscriptFontName(), getFamilyFontName(), getFullFontName()}



getAscent
public int getAscent(String text)(Code)
Gets the ascent of a String in normalized 1000 units. The ascent will always be greater than or equal to zero even if all the characters have a lower ascent.
Parameters:
  text - the String to get the ascent of the ascent in normalized 1000 units



getAscentPoint
public float getAscentPoint(String text, float fontSize)(Code)
Gets the ascent of a String in points. The ascent will always be greater than or equal to zero even if all the characters have a lower ascent.
Parameters:
  text - the String to get the ascent of
Parameters:
  fontSize - the size of the font the ascent in points



getBaseName
protected static String getBaseName(String name)(Code)
Gets the name without the modifiers Bold, Italic or BoldItalic.
Parameters:
  name - the full name of the font the name without the modifiers Bold, Italic or BoldItalic



getCharBBox
public int[] getCharBBox(char c)(Code)
Gets the smallest box enclosing the character contours. It will return null if the font has not the information or the character has no contours, as in the case of the space, for example. Characters with no contours may also return [0,0,0,0].
Parameters:
  c - the character to get the contour bounding box from an array of four floats with the bounding box in the format [llx,lly,urx,ury] ornull



getCidCode
public char getCidCode(char c)(Code)
Gets the CID code given an Unicode. It has only meaning with CJK fonts.
Parameters:
  c - the Unicode the CID equivalent



getCodePagesSupported
public String[] getCodePagesSupported()(Code)
Gets the code pages supported by the font. This has only meaning with True Type fonts. the code pages supported by the font



getDescent
public int getDescent(String text)(Code)
Gets the descent of a String in normalized 1000 units. The descent will always be less than or equal to zero even if all the characters have an higher descent.
Parameters:
  text - the String to get the descent of the dexcent in normalized 1000 units



getDescentPoint
public float getDescentPoint(String text, float fontSize)(Code)
Gets the descent of a String in points. The descent will always be less than or equal to zero even if all the characters have an higher descent.
Parameters:
  text - the String to get the descent of
Parameters:
  fontSize - the size of the font the dexcent in points



getDifferences
public String[] getDifferences()(Code)
Gets the array with the names of the characters. the array with the names of the characters



getDocumentFonts
public static ArrayList getDocumentFonts(PdfReader reader)(Code)
Gets a list of all document fonts. Each element of the ArrayList contains a Object[]{String,PRIndirectReference} with the font name and the indirect reference to it.
Parameters:
  reader - the document where the fonts are to be listed from the list of fonts and references



getDocumentFonts
public static ArrayList getDocumentFonts(PdfReader reader, int page)(Code)
Gets a list of the document fonts in a particular page. Each element of the ArrayList contains a Object[]{String,PRIndirectReference} with the font name and the indirect reference to it.
Parameters:
  reader - the document where the fonts are to be listed from
Parameters:
  page - the page to list the fonts from the list of fonts and references



getEncoding
public String getEncoding()(Code)
Gets the encoding used to convert String into byte[]. the encoding name



getFamilyFontName
abstract public String[][] getFamilyFontName()(Code)
Gets the family name of the font. If it is a True Type font each array element will have {Platform ID, Platform Encoding ID, Language ID, font name}. The interpretation of this values can be found in the Open Type specification, chapter 2, in the 'name' table.
For the other fonts the array has a single element with {"", "", "", font name}. the family name of the font



getFontDescriptor
abstract public float getFontDescriptor(int key, float fontSize)(Code)
Gets the font parameter identified by key. Valid values for key are ASCENT, AWT_ASCENT, CAPHEIGHT, DESCENT, AWT_DESCENT, ITALICANGLE, BBOXLLX, BBOXLLY, BBOXURX and BBOXURY.
Parameters:
  key - the parameter to be extracted
Parameters:
  fontSize - the font size in points the parameter in points



getFontType
public int getFontType()(Code)
Gets the font type. The font types can be: FONT_TYPE_T1, FONT_TYPE_TT, FONT_TYPE_CJK and FONT_TYPE_TTUNI. the font type



getFullFontName
abstract public String[][] getFullFontName()(Code)
Gets the full name of the font. If it is a True Type font each array element will have {Platform ID, Platform Encoding ID, Language ID, font name}. The interpretation of this values can be found in the Open Type specification, chapter 2, in the 'name' table.
For the other fonts the array has a single element with {"", "", "", font name}. the full name of the font



getFullFontName
public static String[][] getFullFontName(String name, String encoding, byte ttfAfm) throws DocumentException, IOException(Code)
Gets the full name of the font. If it is a True Type font each array element will have {Platform ID, Platform Encoding ID, Language ID, font name}. The interpretation of this values can be found in the Open Type specification, chapter 2, in the 'name' table.
For the other fonts the array has a single element with {"", "", "", font name}.
Parameters:
  name - the name of the font
Parameters:
  encoding - the encoding of the font
Parameters:
  ttfAfm - the true type font or the afm in a byte array
throws:
  DocumentException - on error
throws:
  IOException - on error the full name of the font



getKerning
abstract public int getKerning(char char1, char char2)(Code)
Gets the kerning between two Unicode chars.
Parameters:
  char1 - the first char
Parameters:
  char2 - the second char the kerning to be applied in normalized 1000 units



getPostscriptFontName
abstract public String getPostscriptFontName()(Code)
Gets the postscript font name. the postscript font name



getRawCharBBox
abstract protected int[] getRawCharBBox(int c, String name)(Code)



getRawWidth
abstract int getRawWidth(int c, String name)(Code)
Gets the width from the font according to the Unicode char c or the name. If the name is null it's a symbolic font.
Parameters:
  c - the unicode char
Parameters:
  name - the glyph name the width of the char



getResourceStream
public static InputStream getResourceStream(String key)(Code)
Gets the font resources.
Parameters:
  key - the full name of the resource the InputStream to get the resource ornull if not found



getResourceStream
public static InputStream getResourceStream(String key, ClassLoader loader)(Code)
Gets the font resources.
Parameters:
  key - the full name of the resource
Parameters:
  loader - the ClassLoader to load the resource or null to try the ones available the InputStream to get the resource ornull if not found



getUnicodeDifferences
char getUnicodeDifferences(int index)(Code)
Gets the Unicode character corresponding to the byte output to the pdf stream.
Parameters:
  index - the byte index the Unicode character



getUnicodeDifferences
public char[] getUnicodeDifferences()(Code)
Gets the array with the unicode characters. the array with the unicode characters



getUnicodeEquivalent
public char getUnicodeEquivalent(char c)(Code)
Gets the Unicode equivalent to a CID. The (inexistent) CID is translated as '\n'. It has only meaning with CJK fonts with Identity encoding.
Parameters:
  c - the CID code the Unicode equivalent



getWidth
public int getWidth(char char1)(Code)
Gets the width of a char in normalized 1000 units.
Parameters:
  char1 - the unicode char to get the width of the width in normalized 1000 units



getWidth
public int getWidth(String text)(Code)
Gets the width of a String in normalized 1000 units.
Parameters:
  text - the String to get the witdth of the width in normalized 1000 units



getWidthPoint
public float getWidthPoint(String text, float fontSize)(Code)
Gets the width of a String in points.
Parameters:
  text - the String to get the witdth of
Parameters:
  fontSize - the font size the width in points



getWidthPoint
public float getWidthPoint(char char1, float fontSize)(Code)
Gets the width of a char in points.
Parameters:
  char1 - the char to get the witdth of
Parameters:
  fontSize - the font size the width in points



getWidthPointKerned
public float getWidthPointKerned(String text, float fontSize)(Code)
Gets the width of a String in points taking kerning into account.
Parameters:
  text - the String to get the witdth of
Parameters:
  fontSize - the font size the width in points



getWidths
public int[] getWidths()(Code)
Gets the font width array. the font width array



hasKernPairs
abstract public boolean hasKernPairs()(Code)
Checks if the font has any kerning pairs. true if the font has any kerning pairs



isDirectTextToByte
public boolean isDirectTextToByte()(Code)
Gets the direct conversion of char to byte. value of property directTextToByte.
See Also:   BaseFont.setDirectTextToByte(boolean directTextToByte)



isEmbedded
public boolean isEmbedded()(Code)
Gets the embedded flag. true if the font is embedded.



isFontSpecific
public boolean isFontSpecific()(Code)
Gets the symbolic flag of the font. true if the font is symbolic



isForceWidthsOutput
public boolean isForceWidthsOutput()(Code)
Gets the state of the property. value of property forceWidthsOutput



isSubset
public boolean isSubset()(Code)
Indicates if all the glyphs and widths for that particular encoding should be included in the document. false to include all the glyphs and widths.



normalizeEncoding
protected static String normalizeEncoding(String enc)(Code)
Normalize the encoding names. "winansi" is changed to "Cp1252" and "macroman" is changed to "MacRoman".
Parameters:
  enc - the encoding to be normalized the normalized encoding



setCharAdvance
public boolean setCharAdvance(char c, int advance)(Code)
Sets the character advance.
Parameters:
  c - the character
Parameters:
  advance - the character advance normalized to 1000 units true if the advance was set,false otherwise



setDirectTextToByte
public void setDirectTextToByte(boolean directTextToByte)(Code)
Sets the conversion of char directly to byte by casting. This is a low level feature to put the bytes directly in the content stream without passing through String.getBytes().
Parameters:
  directTextToByte - New value of property directTextToByte.



setForceWidthsOutput
public void setForceWidthsOutput(boolean forceWidthsOutput)(Code)
Set to true to force the generation of the widths array.
Parameters:
  forceWidthsOutput - true to force the generation of thewidths array



setKerning
abstract public boolean setKerning(char char1, char char2, int kern)(Code)
Sets the kerning between two Unicode chars.
Parameters:
  char1 - the first char
Parameters:
  char2 - the second char
Parameters:
  kern - the kerning to apply in normalized 1000 units true if the kerning was applied, false otherwise



setPostscriptFontName
abstract public void setPostscriptFontName(String name)(Code)
Sets the font name that will appear in the pdf font dictionary. Use with care as it can easily make a font unreadable if not embedded.
Parameters:
  name - the new font name



setSubset
public void setSubset(boolean subset)(Code)
Indicates if all the glyphs and widths for that particular encoding should be included in the document. When set to true only the glyphs used will be included in the font. When set to false and BaseFont.addSubsetRange(int[]) was not called the full font will be included otherwise just the characters ranges will be included.
Parameters:
  subset - new value of property subset



writeFont
abstract void writeFont(PdfWriter writer, PdfIndirectReference ref, Object params) throws DocumentException, IOException(Code)
Outputs to the writer the font dictionaries and streams.
Parameters:
  writer - the writer for this document
Parameters:
  ref - the font indirect reference
Parameters:
  params - several parameters that depend on the font type
throws:
  IOException - on error
throws:
  DocumentException - error in generating the object



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.