Back to index

texmacs  1.0.7.15
cff.h
Go to the documentation of this file.
00001 /*  $Header: /home/cvsroot/dvipdfmx/src/cff.h,v 1.10 2008/10/13 19:42:48 matthias Exp $
00002     
00003     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
00004 
00005     Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata,
00006     the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
00007     
00008     This program is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012     
00013     This program is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017     
00018     You should have received a copy of the GNU General Public License
00019     along with this program; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00021 */
00022 
00023 #ifndef _CFF_H_
00024 #define _CFF_H_
00025 
00026 #include "mfileio.h"
00027 #include "cff_types.h"
00028 
00029 /* Flag */
00030 #define FONTTYPE_CIDFONT  (1 << 0)
00031 #define FONTTYPE_FONT     (1 << 1)
00032 #define FONTTYPE_MMASTER  (1 << 2)
00033 
00034 #define ENCODING_STANDARD (1 << 3)
00035 #define ENCODING_EXPERT   (1 << 4)
00036 
00037 #define CHARSETS_ISOADOBE (1 << 5)
00038 #define CHARSETS_EXPERT   (1 << 6)
00039 #define CHARSETS_EXPSUB   (1 << 7)
00040 
00041 #define HAVE_STANDARD_ENCODING (ENCODING_STANDARD|ENCODING_EXPERT)
00042 #define HAVE_STANDARD_CHARSETS \
00043   (CHARSETS_ISOADOBE|CHARSETS_EXPERT|CHARSETS_EXPSUB)
00044 
00045 #define CFF_STRING_NOTDEF 65535
00046 
00047 typedef struct
00048 {
00049   char         *fontname; /* FontName */
00050 
00051   /* - CFF structure - */
00052   cff_header    header;   /* CFF Header */
00053   cff_index    *name;     /* Name INDEX */
00054   cff_dict     *topdict;  /* Top DICT (single) */
00055   cff_index    *string;   /* String INDEX */
00056   cff_index    *gsubr;    /* Global Subr INDEX */
00057   cff_encoding *encoding; /* Encodings */
00058   cff_charsets *charsets; /* Charsets  */
00059   cff_fdselect *fdselect; /* FDSelect, CIDFont only */
00060   cff_index    *cstrings; /* CharStrings */
00061   cff_dict    **fdarray;  /* CIDFont only */
00062   cff_dict    **private;  /* per-Font DICT */
00063   cff_index   **subrs;    /* Local Subr INDEX, per-Private DICT */
00064 
00065   /* -- extra data -- */
00066   l_offset    offset;     /* non-zero for OpenType or PostScript wrapped */
00067   l_offset    gsubr_offset;
00068   card16      num_glyphs; /* number of glyphs (CharString INDEX count) */
00069   card8       num_fds;    /* number of Font DICT */
00070 
00071   /* Updated String INDEX.
00072    * Please fix this. We should separate input and output.
00073    */
00074   cff_index  *_string;
00075 
00076   FILE         *stream;
00077   int           filter;   /* not used, ASCII Hex filter if needed */
00078 
00079   int           index;    /* CFF fontset index */
00080   int           flag;     /* Flag: see above */
00081 } cff_font;
00082 
00083 extern cff_font *cff_open  (FILE *file, long offset, int idx);
00084 extern void      cff_close (cff_font *cff);
00085 
00086 #define cff_seek_set(c, p) seek_absolute (((c)->stream), ((c)->offset) + (p));
00087 
00088 /* CFF Header */
00089 extern long cff_put_header (cff_font *cff, card8 *dest, long destlen);
00090 
00091 /* CFF INDEX */
00092 extern cff_index *cff_get_index        (cff_font *cff);
00093 extern cff_index *cff_get_index_header (cff_font *cff);
00094 extern void       cff_release_index    (cff_index *idx);
00095 extern cff_index *cff_new_index        (card16 count);
00096 extern long       cff_index_size       (cff_index *idx);
00097 extern long       cff_pack_index       (cff_index *idx, card8 *dest, long destlen);
00098 
00099 /* Name INDEX */
00100 extern char *cff_get_name (cff_font *cff);
00101 extern long  cff_set_name (cff_font *cff, char *name);
00102 
00103 /* Global and Local Subrs INDEX */
00104 extern long  cff_read_subrs (cff_font *cff);
00105 
00106 /* Encoding */
00107 extern long   cff_read_encoding    (cff_font *cff);
00108 extern long   cff_pack_encoding    (cff_font *cff, card8 *dest, long destlen);
00109 extern card16 cff_encoding_lookup  (cff_font *cff, card8 code);
00110 extern void   cff_release_encoding (cff_encoding *encoding);
00111 
00112 /* Charsets */
00113 extern long   cff_read_charsets    (cff_font *cff);
00114 extern long   cff_pack_charsets    (cff_font *cff, card8 *dest, long destlen);
00115 
00116 /* Returns GID of PS name "glyph" */
00117 extern card16 cff_glyph_lookup     (cff_font *cff, const char *glyph);
00118 /* Returns GID of glyph with SID/CID "cid" */
00119 extern card16 cff_charsets_lookup  (cff_font *cff, card16 cid);
00120 extern void   cff_release_charsets (cff_charsets *charset);
00121 /* Returns SID or CID */
00122 extern card16 cff_charsets_lookup_inverse (cff_font *cff, card16 gid);
00123 
00124 /* FDSelect */
00125 extern long  cff_read_fdselect    (cff_font *cff);
00126 extern long  cff_pack_fdselect    (cff_font *cff, card8 *dest, long destlen);
00127 extern card8 cff_fdselect_lookup  (cff_font *cff, card16 gid);
00128 extern void  cff_release_fdselect (cff_fdselect *fdselect);
00129 
00130 /* Font DICT(s) */
00131 extern long  cff_read_fdarray (cff_font *cff);
00132 
00133 /* Private DICT(s) */
00134 extern long  cff_read_private (cff_font *cff);
00135 
00136 /* String */
00137 extern int   cff_match_string  (cff_font *cff, const char *str, s_SID sid);
00138 extern char *cff_get_string    (cff_font *cff, s_SID id);
00139 extern long  cff_get_sid       (cff_font *cff, char *str);
00140 extern s_SID cff_add_string    (cff_font *cff, const char *str, int unique);
00141 extern void  cff_update_string (cff_font *cff);
00142 
00143 #define cff_is_stdstr(s) (cff_get_sid(NULL, (s)) >= 0)
00144 
00145 #endif /* _CFF_H_ */