Home » pdfbox-1.1.0-src » org.apache.fontbox.ttf » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.fontbox.ttf;
   18   
   19   import java.io.IOException;
   20   
   21   import org.apache.fontbox.util.BoundingBox;
   22   
   23   /**
   24    * A glyph data record in the glyf table.
   25    * 
   26    * @author Ben Litchfield (ben@benlitchfield.com)
   27    * @version $Revision: 1.1 $
   28    */
   29   public class GlyphData
   30   {
   31       private static final int FLAG_ON_CURVE = 1;
   32       private static final int FLAG_SHORT_X = 1<<1;
   33       private static final int FLAG_SHORT_Y = 1<<2;
   34       private static final int FLAG_X_MAGIC = 1<<3;
   35       private static final int FLAG_Y_MAGIC = 1<<4;
   36      
   37       private BoundingBox boundingBox = new BoundingBox();
   38       private short numberOfContours;
   39       private int[] endPointsOfContours;
   40       private byte[] instructions;
   41       private int[] flags;
   42       private short[] xCoordinates;
   43       private short[] yCoordinates;
   44       
   45       /**
   46        * This will read the required data from the stream.
   47        * 
   48        * @param ttf The font that is being read.
   49        * @param data The stream to read the data from.
   50        * @throws IOException If there is an error reading the data.
   51        */
   52       public void initData( TrueTypeFont ttf, TTFDataStream data ) throws IOException
   53       {
   54           numberOfContours = data.readSignedShort();
   55           boundingBox.setLowerLeftX( data.readSignedShort() );
   56           boundingBox.setLowerLeftY( data.readSignedShort() );
   57           boundingBox.setUpperRightX( data.readSignedShort() );
   58           boundingBox.setUpperRightY( data.readSignedShort() );
   59           /**if( numberOfContours > 0 )
   60           {
   61               endPointsOfContours = new int[ numberOfContours ];
   62               for( int i=0; i<numberOfContours; i++ )
   63               {
   64                   endPointsOfContours[i] = data.readUnsignedShort();
   65               }
   66               int instructionLength = data.readUnsignedShort();
   67               instructions = data.read( instructionLength );
   68               
   69               //BJL It is possible to read some more information here but PDFBox
   70               //does not need it at this time so just ignore it.
   71               
   72               //not sure if the length of the flags is the number of contours??
   73               //flags = new int[numberOfContours];
   74               //first read the flags, and just so the TTF can save a couples bytes
   75               //we need to check some bit masks to see if there are more bytes or not.
   76               //int currentFlagIndex = 0;
   77               //int currentFlag = 
   78               
   79               
   80           }*/
   81       }
   82       
   83       /**
   84        * @return Returns the boundingBox.
   85        */
   86       public BoundingBox getBoundingBox()
   87       {
   88           return boundingBox;
   89       }
   90       /**
   91        * @param boundingBoxValue The boundingBox to set.
   92        */
   93       public void setBoundingBox(BoundingBox boundingBoxValue)
   94       {
   95           this.boundingBox = boundingBoxValue;
   96       }
   97       /**
   98        * @return Returns the numberOfContours.
   99        */
  100       public short getNumberOfContours()
  101       {
  102           return numberOfContours;
  103       }
  104       /**
  105        * @param numberOfContoursValue The numberOfContours to set.
  106        */
  107       public void setNumberOfContours(short numberOfContoursValue)
  108       {
  109           this.numberOfContours = numberOfContoursValue;
  110       }
  111   }

Home » pdfbox-1.1.0-src » org.apache.fontbox.ttf » [javadoc | source]