Back to index

texmacs  1.0.7.15
pdfdev.h
Go to the documentation of this file.
00001 /*  $Header: /home/cvsroot/dvipdfmx/src/pdfdev.h,v 1.25 2008/12/11 16:03:05 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     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
00009 
00010     This program is free software; you can redistribute it and/or modify
00011     it under the terms of the GNU General Public License as published by
00012     the Free Software Foundation; either version 2 of the License, or
00013     (at your option) any later version.
00014     
00015     This program is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018     GNU General Public License for more details.
00019     
00020     You should have received a copy of the GNU General Public License
00021     along with this program; if not, write to the Free Software
00022     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00023 */
00024 
00025 #ifndef _PDFDEV_H_
00026 #define _PDFDEV_H_
00027 
00028 #include "numbers.h"
00029 #include "pdfobj.h"
00030 #include "pdfcolor.h"
00031 
00032 typedef signed long spt_t;
00033 
00034 typedef struct pdf_tmatrix
00035 {
00036   double a, b, c, d, e, f;
00037 } pdf_tmatrix;
00038 
00039 typedef struct pdf_rect
00040 {
00041   double llx, lly, urx, ury;
00042 } pdf_rect;
00043 
00044 typedef struct pdf_coord
00045 {
00046   double x, y;
00047 } pdf_coord;
00048 
00049 /* The name transform_info is misleading.
00050  * I'll put this here for a moment...
00051  */
00052 typedef struct
00053 {
00054   /* Physical dimensions
00055    *
00056    * If those values are given, images will be scaled
00057    * and/or shifted to fit within a box described by
00058    * those values.
00059    */
00060   double      width;
00061   double      height;
00062   double      depth;
00063 
00064   pdf_tmatrix matrix; /* transform matrix */
00065   pdf_rect    bbox;   /* user_bbox */
00066 
00067   int         flags;
00068 } transform_info;
00069 #define INFO_HAS_USER_BBOX (1 << 0)
00070 #define INFO_HAS_WIDTH     (1 << 1)
00071 #define INFO_HAS_HEIGHT    (1 << 2)
00072 #define INFO_DO_CLIP       (1 << 3)
00073 #define INFO_DO_HIDE       (1 << 4)
00074 extern void   transform_info_clear (transform_info *info);
00075 
00076 
00077 extern void   pdf_dev_set_verbose (void);
00078 
00079 /* Not in spt_t. */
00080 extern int    pdf_sprint_matrix (char *buf, const pdf_tmatrix *p);
00081 extern int    pdf_sprint_rect   (char *buf, const pdf_rect    *p);
00082 extern int    pdf_sprint_coord  (char *buf, const pdf_coord   *p);
00083 extern int    pdf_sprint_length (char *buf, double value);
00084 extern int    pdf_sprint_number (char *buf, double value);
00085 
00086 /* unit_conv: multiplier for input unit (spt_t) to bp conversion.
00087  * precision: How many fractional digits preserved in output (not real
00088  *            accuracy control).
00089  * is_bw:     Ignore color related special instructions.
00090  */
00091 extern void   pdf_init_device   (double unit_conv, int precision, int is_bw);
00092 extern void   pdf_close_device  (void);
00093 
00094 /* returns 1.0/unit_conv */
00095 extern double dev_unit_dviunit  (void);
00096 
00097 #if 0
00098 /* DVI interpreter knows text positioning in relative motion.
00099  * However, pdf_dev_set_string() recieves text string with placement
00100  * in absolute position in user space, and it convert absolute
00101  * positioning back to relative positioning. It is quite wasteful.
00102  *
00103  * TeX using DVI register stack operation to do CR and then use down
00104  * command for LF. DVI interpreter knows hint for current leading
00105  * and others (raised or lowered), but they are mostly lost in
00106  * pdf_dev_set_string().
00107  */
00108 
00109 typedef struct
00110 {
00111   int      argc;
00112 
00113   struct {
00114     int    is_kern; /* kern or string */
00115 
00116     spt_t  kern;    /* negative kern means space */
00117 
00118     int    offset;  /* offset to sbuf   */
00119     int    length;  /* length of string */
00120   } args[];
00121 
00122   unsigned char sbuf[PDF_STRING_LEN_MAX];
00123 
00124 } pdf_text_string;
00125 
00126 /* Something for handling raise, leading, etc. here. */
00127 
00128 #endif
00129 
00130 /* Draw texts and rules:
00131  *
00132  * xpos, ypos, width, and height are all fixed-point numbers
00133  * converted to big-points by multiplying unit_conv (dvi2pts).
00134  * They must be position in the user space.
00135  *
00136  * ctype:
00137  *   0 - input string is in multi-byte encoding.
00138  *   1 - input string is in 8-bit encoding.
00139  *   2 - input string is in 16-bit encoding.
00140  */
00141 extern void   pdf_dev_set_string (spt_t xpos, spt_t ypos,
00142                               const void *instr_ptr, int instr_len,
00143                               spt_t text_width,
00144                               int   font_id, int ctype);
00145 
00146 extern spt_t pdf_dev_string_width(int font_id, unsigned char *str, unsigned len);
00147 
00148 extern void   pdf_dev_set_raw_glyph (spt_t xpos, spt_t ypos, 
00149                                      unsigned char glyph, int font_id);
00150 
00151 extern void   pdf_dev_set_rule   (spt_t xpos, spt_t ypos,
00152                               spt_t width, spt_t height);
00153 
00154 /* Place XObject */
00155 extern int    pdf_dev_put_image  (int xobj_id,
00156                               transform_info *p, double ref_x, double ref_y);
00157 
00158 /* The design_size and ptsize required by PK font support...
00159  */
00160 extern int    pdf_dev_locate_font (const char *font_name, spt_t ptsize);
00161 
00162 extern int    pdf_dev_physical_font (const char *font_name, spt_t ptsize, const char *font_file, const char *tfm_file);
00163 
00164 
00165 extern int    pdf_dev_setfont     (const char *font_name, spt_t ptsize);
00166 
00167 /* The following two routines are NOT WORKING.
00168  * Dvipdfmx doesn't manage gstate well..
00169  */
00170 #if 0
00171 /* pdf_dev_translate() or pdf_dev_concat() should be used. */
00172 extern void   pdf_dev_set_origin (double orig_x, double orig_y);
00173 #endif
00174 /* Always returns 1.0, please rename this. */
00175 extern double pdf_dev_scale      (void);
00176 
00177 /* Access text state parameters. */
00178 #if 0
00179 extern int    pdf_dev_currentfont     (void); /* returns font_id */
00180 extern double pdf_dev_get_font_ptsize (int font_id);
00181 #endif
00182 extern int    pdf_dev_get_font_wmode  (int font_id); /* ps: special support want this (pTeX). */
00183 
00184 /* Text composition (direction) mode
00185  * This affects only when auto_rotate is enabled.
00186  */
00187 extern int    pdf_dev_get_dirmode     (void);
00188 extern void   pdf_dev_set_dirmode     (int dir_mode);
00189 
00190 /* Set rect to rectangle in device space.
00191  * Unit conversion spt_t to bp and transformation applied within it.
00192  */
00193 extern void   pdf_dev_set_rect   (pdf_rect *rect,
00194                               spt_t x_pos, spt_t y_pos,
00195                               spt_t width, spt_t height, spt_t depth);
00196 
00197 /* Accessor to various device parameters.
00198  */
00199 #define PDF_DEV_PARAM_AUTOROTATE  1
00200 #define PDF_DEV_PARAM_COLORMODE   2
00201 
00202 extern int    pdf_dev_get_param (int param_type);
00203 extern void   pdf_dev_set_param (int param_type, int value);
00204 
00205 /* Text composition mode is ignored (always same as font's
00206  * writing mode) and glyph rotation is not enabled if
00207  * auto_rotate is unset.
00208  */
00209 #define pdf_dev_set_autorotate(v) pdf_dev_set_param(PDF_DEV_PARAM_AUTOROTATE, (v))
00210 #define pdf_dev_set_colormode(v)  pdf_dev_set_param(PDF_DEV_PARAM_COLORMODE,  (v))
00211 
00212 /*
00213  * For pdf_doc, pdf_draw and others.
00214  */
00215 
00216 /* Force reselecting font:
00217  * XFrom (content grabbing) and Metapost support want them.
00218  */
00219 extern void   pdf_dev_reset_fonts (void);
00220 
00221 /* Initialization of transformation matrix with M and others.
00222  * They are called within pdf_doc_begin_page() and pdf_doc_end_page().
00223  */
00224 extern void   pdf_dev_bop (const pdf_tmatrix *M);
00225 extern void   pdf_dev_eop (void);
00226 
00227 /* Text is normal and line art is not normal in dvipdfmx. So we don't have
00228  * begin_text (BT in PDF) and end_text (ET), but instead we have graphics_mode()
00229  * to terminate text section. pdf_dev_flushpath() and others call this.
00230  */
00231 extern void   graphics_mode (void);
00232 
00233 extern void   pdf_dev_get_coord(double *xpos, double *ypos);
00234 extern void   pdf_dev_push_coord(double xpos, double ypos);
00235 extern void   pdf_dev_pop_coord(void);
00236 
00237 #endif /* _PDFDEV_H_ */