KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pdfbox > ttf > GlyphData


1 /**
2  * Copyright (c) 2004, www.pdfbox.org
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. Neither the name of pdfbox; nor the names of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * http://www.pdfbox.org
29  *
30  */

31 package org.pdfbox.ttf;
32
33 import java.io.IOException JavaDoc;
34
35 import org.pdfbox.util.BoundingBox;
36
37 /**
38  * A glyph data record in the glyf table.
39  *
40  * @author Ben Litchfield (ben@csh.rit.edu)
41  * @version $Revision: 1.1 $
42  */

43 public class GlyphData
44 {
45     private static final int FLAG_ON_CURVE = 1;
46     private static final int FLAG_SHORT_X = 1<<1;
47     private static final int FLAG_SHORT_Y = 1<<2;
48     private static final int FLAG_X_MAGIC = 1<<3;
49     private static final int FLAG_Y_MAGIC = 1<<4;
50    
51     private BoundingBox boundingBox = new BoundingBox();
52     private short numberOfContours;
53     private int[] endPointsOfContours;
54     private byte[] instructions;
55     private int[] flags;
56     private short[] xCoordinates;
57     private short[] yCoordinates;
58     
59     /**
60      * This will read the required data from the stream.
61      *
62      * @param ttf The font that is being read.
63      * @param data The stream to read the data from.
64      * @throws IOException If there is an error reading the data.
65      */

66     public void initData( TrueTypeFont ttf, TTFDataStream data ) throws IOException JavaDoc
67     {
68         numberOfContours = data.readSignedShort();
69         boundingBox.setLowerLeftX( data.readSignedShort() );
70         boundingBox.setLowerLeftY( data.readSignedShort() );
71         boundingBox.setUpperRightX( data.readSignedShort() );
72         boundingBox.setUpperRightY( data.readSignedShort() );
73         /**if( numberOfContours > 0 )
74         {
75             endPointsOfContours = new int[ numberOfContours ];
76             for( int i=0; i<numberOfContours; i++ )
77             {
78                 endPointsOfContours[i] = data.readUnsignedShort();
79             }
80             int instructionLength = data.readUnsignedShort();
81             instructions = data.read( instructionLength );
82             
83             //BJL It is possible to read some more information here but PDFBox
84             //does not need it at this time so just ignore it.
85             
86             //not sure if the length of the flags is the number of contours??
87             //flags = new int[numberOfContours];
88             //first read the flags, and just so the TTF can save a couples bytes
89             //we need to check some bit masks to see if there are more bytes or not.
90             //int currentFlagIndex = 0;
91             //int currentFlag =
92             
93             
94         }*/

95     }
96     
97     /**
98      * @return Returns the boundingBox.
99      */

100     public BoundingBox getBoundingBox()
101     {
102         return boundingBox;
103     }
104     /**
105      * @param boundingBoxValue The boundingBox to set.
106      */

107     public void setBoundingBox(BoundingBox boundingBoxValue)
108     {
109         this.boundingBox = boundingBoxValue;
110     }
111     /**
112      * @return Returns the numberOfContours.
113      */

114     public short getNumberOfContours()
115     {
116         return numberOfContours;
117     }
118     /**
119      * @param numberOfContoursValue The numberOfContours to set.
120      */

121     public void setNumberOfContours(short numberOfContoursValue)
122     {
123         this.numberOfContours = numberOfContoursValue;
124     }
125 }
126
Popular Tags