Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

FoFiTrueType.h

Go to the documentation of this file.
00001 //========================================================================
00002 //
00003 // FoFiTrueType.h
00004 //
00005 // Copyright 1999-2003 Glyph & Cog, LLC
00006 //
00007 //========================================================================
00008 
00009 #ifndef FOFITRUETYPE_H
00010 #define FOFITRUETYPE_H
00011 
00012 #include <aconf.h>
00013 
00014 #ifdef USE_GCC_PRAGMAS
00015 #pragma interface
00016 #endif
00017 
00018 #include "gtypes.h"
00019 #include "FoFiBase.h"
00020 
00021 class GHash;
00022 struct TrueTypeTable;
00023 struct TrueTypeCmap;
00024 
00025 //------------------------------------------------------------------------
00026 // FoFiTrueType
00027 //------------------------------------------------------------------------
00028 
00029 class FoFiTrueType: public FoFiBase {
00030 public:
00031 
00032   // Create a FoFiTrueType object from a memory buffer.
00033   static FoFiTrueType *make(char *fileA, int lenA);
00034 
00035   // Create a FoFiTrueType object from a file on disk.
00036   static FoFiTrueType *load(char *fileName);
00037 
00038   virtual ~FoFiTrueType();
00039 
00040   // Return the number of cmaps defined by this font.
00041   int getNumCmaps();
00042 
00043   // Return the platform ID of the <i>th cmap.
00044   int getCmapPlatform(int i);
00045 
00046   // Return the encoding ID of the <i>th cmap.
00047   int getCmapEncoding(int i);
00048 
00049   // Return the index of the cmap for <platform>, <encoding>.  Returns
00050   // -1 if there is no corresponding cmap.
00051   int findCmap(int platform, int encoding);
00052 
00053   // Return the GID corresponding to <c> according to the <i>th cmap.
00054   Gushort mapCodeToGID(int i, int c);
00055 
00056   // Returns the GID corresponding to <name> according to the post
00057   // table.  Returns 0 if there is no mapping for <name> or if the
00058   // font does not have a post table.
00059   int mapNameToGID(char *name);
00060 
00061   // Returns the least restrictive embedding licensing right (as
00062   // defined by the TrueType spec):
00063   // * 4: OS/2 table is missing or invalid
00064   // * 3: installable embedding
00065   // * 2: editable embedding
00066   // * 1: preview & print embedding
00067   // * 0: restricted license embedding
00068   int getEmbeddingRights();
00069 
00070   // Convert to a Type 42 font, suitable for embedding in a PostScript
00071   // file.  <psName> will be used as the PostScript font name (so we
00072   // don't need to depend on the 'name' table in the font).  The
00073   // <encoding> array specifies the mapping from char codes to names.
00074   // If <encoding> is NULL, the encoding is unknown or undefined.  The
00075   // <codeToGID> array specifies the mapping from char codes to GIDs.
00076   void convertToType42(char *psName, char **encoding,
00077                        Gushort *codeToGID,
00078                        FoFiOutputFunc outputFunc, void *outputStream);
00079 
00080   // Convert to a Type 2 CIDFont, suitable for embedding in a
00081   // PostScript file.  <psName> will be used as the PostScript font
00082   // name (so we don't need to depend on the 'name' table in the
00083   // font).  The <cidMap> array maps CIDs to GIDs; it has <nCIDs>
00084   // entries.
00085   void convertToCIDType2(char *psName, Gushort *cidMap, int nCIDs,
00086                          FoFiOutputFunc outputFunc, void *outputStream);
00087 
00088   // Convert to a Type 0 (but non-CID) composite font, suitable for
00089   // embedding in a PostScript file.  <psName> will be used as the
00090   // PostScript font name (so we don't need to depend on the 'name'
00091   // table in the font).  The <cidMap> array maps CIDs to GIDs; it has
00092   // <nCIDs> entries.
00093   void convertToType0(char *psName, Gushort *cidMap, int nCIDs,
00094                       FoFiOutputFunc outputFunc, void *outputStream);
00095 
00096   // Write a clean TTF file, filling in missing tables and correcting
00097   // various other errors.  If the font is complete and correct, it
00098   // will be written unmodified.
00099   void writeTTF(FoFiOutputFunc outputFunc, void *outputStream);
00100 
00101 private:
00102 
00103   FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA);
00104   void cvtEncoding(char **encoding,
00105                    FoFiOutputFunc outputFunc,
00106                    void *outputStream);
00107   void cvtCharStrings(char **encoding,
00108                       Gushort *codeToGID,
00109                       FoFiOutputFunc outputFunc,
00110                       void *outputStream);
00111   void cvtSfnts(FoFiOutputFunc outputFunc,
00112                 void *outputStream, GString *name);
00113   void dumpString(Guchar *s, int length,
00114                   FoFiOutputFunc outputFunc,
00115                   void *outputStream);
00116   Guint computeTableChecksum(Guchar *data, int length);
00117   void parse();
00118   void readPostTable();
00119   int seekTable(char *tag);
00120 
00121   TrueTypeTable *tables;
00122   int nTables;
00123   TrueTypeCmap *cmaps;
00124   int nCmaps;
00125   int nGlyphs;
00126   int locaFmt;
00127   int bbox[4];
00128   GHash *nameToGID;
00129 
00130   GBool parsedOk;
00131 };
00132 
00133 #endif

Generated on Wed Nov 3 12:58:55 2004 for Lemur Toolkit by doxygen1.2.18