Java Doc for CFFFontSubset.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.CFFFont
      com.lowagie.text.pdf.CFFFontSubset

CFFFontSubset
public class CFFFontSubset extends CFFFont (Code)
This Class subsets a CFF Type Font. The subset is preformed for CID fonts and NON CID fonts. The Charstring is subseted for both types. For CID fonts only the FDArray which are used are embedded. The Lsubroutines of the FDArrays used are subsetted as well. The Subroutine subset supports both Type1 and Type2 formatting altough only tested on Type2 Format. For Non CID the Lsubroutines are subsetted. On both types the Gsubroutines is subsetted. A font which was not of CID type is transformed into CID as a part of the subset process. The CID synthetic creation was written by Sivan Toledo (sivan@math.tau.ac.il)
author:
   Oren Manor (manorore@post.tau.ac.il) and Ygal Blum (blumygal@post.tau.ac.il)


Field Summary
 HashMapFDArrayUsed
    
 intGBias
    
 HashMapGlyphsUsed
    
 byte[]NewCharStringsIndex
    
 byte[]NewGSubrsIndex
    
 byte[][]NewLSubrsIndex
     An array of the new Indexs for the local Subr.
 byte[]NewSubrsIndexNonCID
    
 intNumOfHints
    
 LinkedListOutputList
    
final static  StringSubrsEscapeFuncs
    
final static  StringSubrsFunctions
    
 ArrayListglyphsInList
    
 HashMaphGSubrsUsed
    
 HashMap[]hSubrsUsed
    
 HashMaphSubrsUsedNonCID
    
 ArrayListlGSubrsUsed
    
 ArrayList[]lSubrsUsed
    
 ArrayListlSubrsUsedNonCID
    

Constructor Summary
public  CFFFontSubset(RandomAccessFileOrArray rf, HashMap GlyphsUsed)
    

Method Summary
protected  byte[]AssembleIndex(int[] NewOffsets, byte[] NewObjects)
     Function creates the new index, inserting the count,offsetsize,offset array and object array.
protected  voidBuildFDArrayUsed(int Font)
    
protected  voidBuildFDSubrsOffsets(int Font, int FD)
     The function finds for the FD array processed the local subr offset and its offset array.
protected  voidBuildGSubrsUsed(int Font)
    
protected  voidBuildIndexHeader(int Count, int Offsize, int First)
    
protected  voidBuildNewCharString(int FontIndex)
    
protected  byte[]BuildNewFile(int Font)
    
protected  byte[]BuildNewIndex(int[] Offsets, HashMap Used)
     Function builds the new offset array, object array and assembles the index.
protected  voidBuildNewLGSubrs(int Font)
     Function builds the new local & global subsrs indices.
protected  voidBuildSubrUsed(int Font, int FD, int SubrOffset, int[] SubrsOffsets, HashMap hSubr, ArrayList lSubr)
     Function uses ReadAsubr on the glyph used to build the LSubr & Gsubr HashMap. The HashMap (of the lsub only) is then scaned recursivly for Lsubr & Gsubrs calls.
protected  intCalcBias(int Offset, int Font)
    
protected  intCalcHints(int begin, int end, int LBias, int GBias, int[] LSubrsOffsets)
     The function reads the subroutine and returns the number of the hint in it.
 intCalcSubrOffsetSize(int Offset, int Size)
     Calculates how many byte it took to write the offset for the subrs in a specific private dict.
protected  voidCopyHeader()
    
 intCountCharset(int Offset, int NumofGlyphs)
    
 intCountRange(int NumofGlyphs, int Type)
    
protected  voidCreateCharset(OffsetItem charsetRef, int nglyphs)
     Function creates new CharSet for non-CID fonts.
protected  voidCreateFDArray(OffsetItem fdarrayRef, OffsetItem privateRef, int Font)
     Function creates new FDArray for non-CID fonts.
protected  voidCreateFDSelect(OffsetItem fdselectRef, int nglyphs)
     Function creates new FDSelect for non-CID fonts.
protected  voidCreateKeys(OffsetItem fdarrayRef, OffsetItem fdselectRef, OffsetItem charsetRef, OffsetItem charstringsRef)
    
protected  voidCreateNewStringIndex(int Font)
    
 voidCreateNonCIDPrivate(int Font, OffsetItem Subr)
    
 voidCreateNonCIDSubrs(int Font, IndexBaseItem PrivateBase, OffsetItem Subrs)
     the function marks the beginning of the subrs index and adds the subsetted subrs index to the output list.
protected  voidEmptyStack()
    
protected  voidHandelStack()
    
protected  voidPopStack()
    
public  byte[]Process(String fontName)
     The Process function extracts one font out of the CFF file and returns a subset version of the original.
protected  voidPushStack()
    
protected  voidReadASubr(int begin, int end, int GBias, int LBias, HashMap hSubr, ArrayList lSubr, int[] LSubrsOffsets)
     The function reads a subrs (glyph info) between begin and end.
protected  voidReadCommand()
    
protected  voidReadFDArray(int Font)
    
 voidReconstruct(int Font)
    
 voidReconstructFDArray(int Font, OffsetItem[] fdPrivate)
    
 voidReconstructPrivateDict(int Font, OffsetItem[] fdPrivate, IndexBaseItem[] fdPrivateBase, OffsetItem[] fdSubrs)
    
 voidReconstructPrivateSubrs(int Font, IndexBaseItem[] fdPrivateBase, OffsetItem[] fdSubrs)
    
protected  intStackOpp()
     Function checks the key and return the change to the stack after the operator The change in the stack.
protected  intcountEntireIndexRange(int indexOffset)
    
protected  voidreadFDSelect(int Font)
    

Field Detail
FDArrayUsed
HashMap FDArrayUsed(Code)
A HashMap for keeping the FDArrays being used by the font



GBias
int GBias(Code)
The bias for the global subroutines



GlyphsUsed
HashMap GlyphsUsed(Code)
A HashMap containing the glyphs used in the text after being converted to glyph number by the CMap



NewCharStringsIndex
byte[] NewCharStringsIndex(Code)
The new CharString of the font



NewGSubrsIndex
byte[] NewGSubrsIndex(Code)
The new global subroutines index of the font



NewLSubrsIndex
byte[][] NewLSubrsIndex(Code)
An array of the new Indexs for the local Subr. One index for each FontDict



NewSubrsIndexNonCID
byte[] NewSubrsIndexNonCID(Code)
The new subroutines index for a non-cid font



NumOfHints
int NumOfHints(Code)
Number of arguments to the stem operators in a subroutine calculated recursivly



OutputList
LinkedList OutputList(Code)
The linked list for generating the new font stream



SubrsEscapeFuncs
final static String SubrsEscapeFuncs(Code)
The Strings in this array represent Type1/Type2 escape operator names



SubrsFunctions
final static String SubrsFunctions(Code)
The Strings in this array represent Type1/Type2 operator names



glyphsInList
ArrayList glyphsInList(Code)
The GlyphsUsed keys as an ArrayList



hGSubrsUsed
HashMap hGSubrsUsed(Code)
A HashMap for keeping the Global subroutines used in the font



hSubrsUsed
HashMap[] hSubrsUsed(Code)
A HashMaps array for keeping the subroutines used in each FontDict



hSubrsUsedNonCID
HashMap hSubrsUsedNonCID(Code)
A HashMap for keeping the subroutines used in a non-cid font



lGSubrsUsed
ArrayList lGSubrsUsed(Code)
The Global SubroutinesUsed HashMaps as ArrayLists



lSubrsUsed
ArrayList[] lSubrsUsed(Code)
The SubroutinesUsed HashMaps as ArrayLists



lSubrsUsedNonCID
ArrayList lSubrsUsedNonCID(Code)
The SubroutinesUsed HashMap as ArrayList




Constructor Detail
CFFFontSubset
public CFFFontSubset(RandomAccessFileOrArray rf, HashMap GlyphsUsed)(Code)
C'tor for CFFFontSubset
Parameters:
  rf - - The font file
Parameters:
  GlyphsUsed - - a HashMap that contains the glyph used in the subset




Method Detail
AssembleIndex
protected byte[] AssembleIndex(int[] NewOffsets, byte[] NewObjects)(Code)
Function creates the new index, inserting the count,offsetsize,offset array and object array.
Parameters:
  NewOffsets - the subsetted offset array
Parameters:
  NewObjects - the subsetted object array the new index created



BuildFDArrayUsed
protected void BuildFDArrayUsed(int Font)(Code)
Function reads the FDSelect and builds the FDArrayUsed HashMap According to the glyphs used
Parameters:
  Font - the Number of font being processed



BuildFDSubrsOffsets
protected void BuildFDSubrsOffsets(int Font, int FD)(Code)
The function finds for the FD array processed the local subr offset and its offset array.
Parameters:
  Font - the font
Parameters:
  FD - The FDARRAY processed



BuildGSubrsUsed
protected void BuildGSubrsUsed(int Font)(Code)
Function scans the Glsubr used ArrayList to find recursive calls to Gsubrs and adds to Hashmap & ArrayList
Parameters:
  Font - the font



BuildIndexHeader
protected void BuildIndexHeader(int Count, int Offsize, int First)(Code)
Function Build the header of an index
Parameters:
  Count - the count field of the index
Parameters:
  Offsize - the offsize field of the index
Parameters:
  First - the first offset of the index



BuildNewCharString
protected void BuildNewCharString(int FontIndex) throws IOException(Code)
Function uses BuildNewIndex to create the new index of the subset charstrings
Parameters:
  FontIndex - the font
throws:
  IOException -



BuildNewFile
protected byte[] BuildNewFile(int Font)(Code)
The function builds the new output stream according to the subset process
Parameters:
  Font - the font the subseted font stream



BuildNewIndex
protected byte[] BuildNewIndex(int[] Offsets, HashMap Used) throws IOException(Code)
Function builds the new offset array, object array and assembles the index. used for creating the glyph and subrs subsetted index
Parameters:
  Offsets - the offset array of the original index
Parameters:
  Used - the hashmap of the used objects the new index subset version
throws:
  IOException -



BuildNewLGSubrs
protected void BuildNewLGSubrs(int Font) throws IOException(Code)
Function builds the new local & global subsrs indices. IF CID then All of the FD Array lsubrs will be subsetted.
Parameters:
  Font - the font
throws:
  IOException -



BuildSubrUsed
protected void BuildSubrUsed(int Font, int FD, int SubrOffset, int[] SubrsOffsets, HashMap hSubr, ArrayList lSubr)(Code)
Function uses ReadAsubr on the glyph used to build the LSubr & Gsubr HashMap. The HashMap (of the lsub only) is then scaned recursivly for Lsubr & Gsubrs calls.
Parameters:
  Font - the font
Parameters:
  FD - FD array processed. 0 indicates function was called by non CID font
Parameters:
  SubrOffset - the offset to the subr index to calc the bias
Parameters:
  SubrsOffsets - the offset array of the subr index
Parameters:
  hSubr - HashMap of the subrs used
Parameters:
  lSubr - ArrayList of the subrs used



CalcBias
protected int CalcBias(int Offset, int Font)(Code)
Function calcs bias according to the CharString type and the count of the subrs
Parameters:
  Offset - The offset to the relevent subrs index
Parameters:
  Font - the font The calculated Bias



CalcHints
protected int CalcHints(int begin, int end, int LBias, int GBias, int[] LSubrsOffsets)(Code)
The function reads the subroutine and returns the number of the hint in it. If a call to another subroutine is found the function calls recursively.
Parameters:
  begin - the start point of the subr
Parameters:
  end - the end point of the subr
Parameters:
  LBias - the bias of the Local Subrs
Parameters:
  GBias - the bias of the Global Subrs
Parameters:
  LSubrsOffsets - The Offsets array of the subroutines The number of hints in the subroutine read.



CalcSubrOffsetSize
int CalcSubrOffsetSize(int Offset, int Size)(Code)
Calculates how many byte it took to write the offset for the subrs in a specific private dict.
Parameters:
  Offset - The Offset for the private dict
Parameters:
  Size - The size of the private dict The size of the offset of the subrs in the private dict



CopyHeader
protected void CopyHeader()(Code)
Function Copies the header from the original fileto the output list



CountCharset
int CountCharset(int Offset, int NumofGlyphs)(Code)
Calculates the length of the charset according to its format
Parameters:
  Offset - The Charset Offset
Parameters:
  NumofGlyphs - Number of glyphs in the font the length of the Charset



CountRange
int CountRange(int NumofGlyphs, int Type)(Code)
Function calculates the number of ranges in the Charset
Parameters:
  NumofGlyphs - The number of glyphs in the font
Parameters:
  Type - The format of the Charset The number of ranges in the Charset data structure



CreateCharset
protected void CreateCharset(OffsetItem charsetRef, int nglyphs)(Code)
Function creates new CharSet for non-CID fonts. The CharSet built uses a single range for all glyphs
Parameters:
  charsetRef - OffsetItem for the CharSet
Parameters:
  nglyphs - the number of glyphs in the font



CreateFDArray
protected void CreateFDArray(OffsetItem fdarrayRef, OffsetItem privateRef, int Font)(Code)
Function creates new FDArray for non-CID fonts. The FDArray built has only the "Private" operator that points to the font's original private dict
Parameters:
  fdarrayRef - OffsetItem for the FDArray
Parameters:
  privateRef - OffsetItem for the Private Dict
Parameters:
  Font - the font



CreateFDSelect
protected void CreateFDSelect(OffsetItem fdselectRef, int nglyphs)(Code)
Function creates new FDSelect for non-CID fonts. The FDSelect built uses a single range for all glyphs
Parameters:
  fdselectRef - OffsetItem for the FDSelect
Parameters:
  nglyphs - the number of glyphs in the font



CreateKeys
protected void CreateKeys(OffsetItem fdarrayRef, OffsetItem fdselectRef, OffsetItem charsetRef, OffsetItem charstringsRef)(Code)
Function adds the keys into the TopDict
Parameters:
  fdarrayRef - OffsetItem for the FDArray
Parameters:
  fdselectRef - OffsetItem for the FDSelect
Parameters:
  charsetRef - OffsetItem for the CharSet
Parameters:
  charstringsRef - OffsetItem for the CharString



CreateNewStringIndex
protected void CreateNewStringIndex(int Font)(Code)
Function takes the original string item and adds the new strings to accomodate the CID rules
Parameters:
  Font - the font



CreateNonCIDPrivate
void CreateNonCIDPrivate(int Font, OffsetItem Subr)(Code)
The function creates a private dict for a font that was not CID All the keys are copied as is except for the subrs key
Parameters:
  Font - the font
Parameters:
  Subr - The OffsetItem for the subrs of the private



CreateNonCIDSubrs
void CreateNonCIDSubrs(int Font, IndexBaseItem PrivateBase, OffsetItem Subrs)(Code)
the function marks the beginning of the subrs index and adds the subsetted subrs index to the output list.
Parameters:
  Font - the font
Parameters:
  PrivateBase - IndexBaseItem for the private that's referencing to the subrs
Parameters:
  Subrs - OffsetItem for the subrs



EmptyStack
protected void EmptyStack()(Code)
Empty the Type2 Stack



HandelStack
protected void HandelStack()(Code)
Function Checks how the current operator effects the run time stack after being run An operator may increase or decrease the stack size



PopStack
protected void PopStack()(Code)
Pop one element from the stack



Process
public byte[] Process(String fontName) throws IOException(Code)
The Process function extracts one font out of the CFF file and returns a subset version of the original.
Parameters:
  fontName - - The name of the font to be taken out of the CFF The new font stream
throws:
  IOException -



PushStack
protected void PushStack()(Code)
Add an item to the stack



ReadASubr
protected void ReadASubr(int begin, int end, int GBias, int LBias, HashMap hSubr, ArrayList lSubr, int[] LSubrsOffsets)(Code)
The function reads a subrs (glyph info) between begin and end. Adds calls to a Lsubr to the hSubr and lSubrs. Adds calls to a Gsubr to the hGSubr and lGSubrs.
Parameters:
  begin - the start point of the subr
Parameters:
  end - the end point of the subr
Parameters:
  GBias - the bias of the Global Subrs
Parameters:
  LBias - the bias of the Local Subrs
Parameters:
  hSubr - the HashMap for the lSubrs
Parameters:
  lSubr - the ArrayList for the lSubrs



ReadCommand
protected void ReadCommand()(Code)
The function reads the next command after the file pointer is set



ReadFDArray
protected void ReadFDArray(int Font)(Code)
Read the FDArray count, offsize and Offset array
Parameters:
  Font -



Reconstruct
void Reconstruct(int Font)(Code)
Function reconstructs the FDArray, PrivateDict and LSubr for CID fonts
Parameters:
  Font - the font



ReconstructFDArray
void ReconstructFDArray(int Font, OffsetItem[] fdPrivate)(Code)
Function subsets the FDArray and builds the new one with new offsets
Parameters:
  Font - The font
Parameters:
  fdPrivate - OffsetItem Array (one for each FDArray)



ReconstructPrivateDict
void ReconstructPrivateDict(int Font, OffsetItem[] fdPrivate, IndexBaseItem[] fdPrivateBase, OffsetItem[] fdSubrs)(Code)
Function Adds the new private dicts (only for the FDs used) to the list
Parameters:
  Font - the font
Parameters:
  fdPrivate - OffsetItem array one element for each private
Parameters:
  fdPrivateBase - IndexBaseItem array one element for each private
Parameters:
  fdSubrs - OffsetItem array one element for each private



ReconstructPrivateSubrs
void ReconstructPrivateSubrs(int Font, IndexBaseItem[] fdPrivateBase, OffsetItem[] fdSubrs)(Code)
Function Adds the new LSubrs dicts (only for the FDs used) to the list
Parameters:
  Font - The index of the font
Parameters:
  fdPrivateBase - The IndexBaseItem array for the linked list
Parameters:
  fdSubrs - OffsetItem array for the linked list



StackOpp
protected int StackOpp()(Code)
Function checks the key and return the change to the stack after the operator The change in the stack. 2-> flush the stack



countEntireIndexRange
protected int countEntireIndexRange(int indexOffset)(Code)
Function computes the size of an index
Parameters:
  indexOffset - The offset for the computed index The size of the index



readFDSelect
protected void readFDSelect(int Font)(Code)
Read the FDSelect of the font and compute the array and its length
Parameters:
  Font - The index of the font being processed



Fields inherited from com.lowagie.text.pdf.CFFFont
protected int arg_count(Code)(Java Doc)
protected Object[] args(Code)(Java Doc)
protected RandomAccessFileOrArray buf(Code)(Java Doc)
protected Font[] fonts(Code)(Java Doc)
protected int gsubrIndexOffset(Code)(Java Doc)
protected int[] gsubrOffsets(Code)(Java Doc)
protected String key(Code)(Java Doc)
protected int nameIndexOffset(Code)(Java Doc)
protected int[] nameOffsets(Code)(Java Doc)
int nextIndexOffset(Code)(Java Doc)
final static String operatorNames(Code)(Java Doc)
final static String standardStrings(Code)(Java Doc)
protected int stringIndexOffset(Code)(Java Doc)
protected int[] stringOffsets(Code)(Java Doc)
protected int topdictIndexOffset(Code)(Java Doc)
protected int[] topdictOffsets(Code)(Java Doc)

Methods inherited from com.lowagie.text.pdf.CFFFont
void ReadEncoding(int nextIndexOffset)(Code)(Java Doc)
public boolean exists(String fontName)(Code)(Java Doc)
public byte[] getCID(String fontName)(Code)(Java Doc)
char getCard16()(Code)(Java Doc)
char getCard8()(Code)(Java Doc)
protected void getDictItem()(Code)(Java Doc)
protected RangeItem getEntireIndexRange(int indexOffset)(Code)(Java Doc)
int[] getIndex(int nextIndexOffset)(Code)(Java Doc)
int getInt()(Code)(Java Doc)
public String[] getNames()(Code)(Java Doc)
int getOffset(int offSize)(Code)(Java Doc)
int getPosition()(Code)(Java Doc)
short getShort()(Code)(Java Doc)
public String getString(char sid)(Code)(Java Doc)
public boolean isCID(String fontName)(Code)(Java Doc)
void seek(int offset)(Code)(Java Doc)

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.