w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pdfdev.c File Reference
#include "config.h"
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include "system.h"
#include "mem.h"
#include "error.h"
#include "mfileio.h"
#include "numbers.h"
#include "dvi.h"
#include "tfm.h"
#include "pdfdev.h"
#include "pdfdoc.h"
#include "pdfobj.h"
#include "type1.h"
#include "type0.h"
#include "ttf.h"
#include "pkfont.h"
#include "pdfspecial.h"
#include "pdfparse.h"
#include "tpic.h"
#include "htex.h"
#include "mpost.h"
#include "psspecial.h"
#include "colorsp.h"
#include "pdflimits.h"
#include "twiddle.h"
#include "encodings.h"
#include "colors.h"
Include dependency graph for pdfdev.c:

Go to the source code of this file.

Classes

struct  dev_font
 
struct  map_record
 
struct  color
 

Macros

#define GRAPHICS_MODE   1
 
#define TEXT_MODE   2
 
#define STRING_MODE   3
 
#define HH_MODE   0
 
#define HV_MODE   1
 
#define VH_MODE   2
 
#define VV_MODE   3
 
#define WMODE_CHANGES(p, q)   ((abs(p-q) % 3) ? 1 : 0)
 
#define VERTFONT(p)   (p & 0x02)
 
#define VERTDIR(p)   (p & 0x01)
 
#define FORMAT_BUF_SIZE   4096
 
#define PDF_U   65800L /* Number of DVI units in a PDF unit */
 
#define CENTI_PDF_U   658 /* Number of DVI units in a centi PDF unit */
 
#define PHYSICAL   1
 
#define VIRTUAL   2
 
#define TYPE1   1
 
#define PK   2
 
#define TRUETYPE   3
 
#define TYPE0   4
 
#define DEFAULT_MAP_FILE   "pdfmfnt.map"
 
#define GRAY   1
 
#define RGB   2
 
#define CMYK   3
 

Functions

static void dev_clear_color_stack (void)
 
static void dev_clear_xform_stack (void)
 
void dev_set_page_size (double width, double height)
 
double dev_page_width (void)
 
double dev_page_height (void)
 
void dev_set_verbose (void)
 
void dev_set_debug (void)
 
double pdf_dev_scale (void)
 
void dev_fonts_need (unsigned n)
 
static void font_maps_need (int n)
 
static void init_map_record (struct map_record *r)
 
static void release_map_record (struct map_record *r)
 
static void fill_in_defaults (struct map_record *this_map_record)
 
void dev_read_mapfile (char *filename)
 
struct map_recordget_map_record (const char *tex_name)
 
static void set_text_matrix (spt_t xpos, spt_t ypos, double slant, double extend)
 
static void reset_text_state (void)
 
static void text_mode (void)
 
void graphics_mode (void)
 
static void string_mode (spt_t xpos, spt_t ypos, double slant, double extend)
 
static void dev_set_font (int font_id)
 
void dev_set_string (spt_t xpos, spt_t ypos, unsigned char *s, int length, spt_t width, int font_id)
 
void dev_init (double scale, double x_offset, double y_offset)
 
void dev_close (void)
 
void dev_add_comment (char *comment)
 
struct color color_by_name (char *s)
 
static void fill_page (void)
 
void dev_bg_rgb_color (double r, double g, double b)
 
void dev_bg_cmyk_color (double c, double m, double y, double k)
 
void dev_bg_gray (double value)
 
void dev_bg_named_color (char *s)
 
static void dev_set_color (struct color color)
 
void dev_do_color (void)
 
void dev_set_def_rgb_color (double r, double g, double b)
 
void dev_set_def_gray (double g)
 
void dev_set_def_named_color (char *s)
 
void dev_set_def_cmyk_color (double c, double m, double y, double k)
 
void dev_begin_named_color (char *s)
 
void dev_begin_rgb_color (double r, double g, double b)
 
void dev_begin_cmyk_color (double c, double m, double y, double k)
 
void dev_begin_gray (double value)
 
void dev_end_color (void)
 
void dev_begin_xform (double xscale, double yscale, double rotate, double x_user, double y_user)
 
void dev_end_xform (void)
 
int dev_xform_depth (void)
 
void dev_close_all_xforms (int depth)
 
void dev_reselect_font (void)
 
static void bop_font_reset (void)
 
void dev_bop (void)
 
void dev_eop (void)
 
int dev_locate_font (const char *tex_name, spt_t ptsize)
 
void dev_close_all_fonts (void)
 
void dev_rule (spt_t xpos, spt_t ypos, spt_t width, spt_t height)
 
double dev_phys_x (void)
 
double dev_phys_y (void)
 
static int src_special (char *buffer, UNSIGNED_QUAD size)
 
static int om_special (char *buffer, UNSIGNED_QUAD size)
 
void dev_do_special (void *buffer, UNSIGNED_QUAD size, spt_t x_user, spt_t y_user)
 
void dev_link_annot (unsigned char flag)
 
void dev_stack_depth (unsigned int depth)
 
void dev_tag_depth (void)
 
void dev_untag_depth (void)
 
void dev_expand_box (spt_t width, spt_t height, spt_t depth)
 
int dev_wmode (void)
 
void dev_set_wmode (int dir)
 
void dev_start_mp_mode (void)
 
void dev_end_mp_mode (void)
 

Variables

double hoffset = 72.0
 
double voffset =72.0
 
static double dvi2pts = 0.0
 
static double page_width =612.0
 
static double page_height =792.0
 
int page_size_readonly = 0
 
static int debug = 0
 
static int verbose = 0
 
int motion_state = 1
 
int text_wmode = 0
 
int text_wmode_save = 0
 
int force_reset = 0
 
int mp_mode = 0
 
static char format_buffer [4096]
 
static spt_t text_xorigin = 0
 
static spt_t text_yorigin = 0
 
static spt_t text_offset = 0
 
double text_slant = 0.0
 
double text_extend = 1.0
 
unsigned num_dev_fonts = 0
 
unsigned num_phys_fonts = 0
 
int current_font = -1
 
static struct dev_fontdev_font = NULL
 
static unsigned max_device_fonts = 0
 
struct map_recordfont_map = NULL
 
unsigned int num_font_map = 0
 
unsigned int max_font_map = 0
 
struct color colorstack [32u]
 
struct color background [32u] = { 1 , 1.0, 1.0, 1.0, 1.0}
 
struct color default_color [32u] = { 1 , 0.0, 0.0, 0.0, 0.0}
 
static int num_colors = 0
 
static int num_transforms = 0
 
static unsigned dvi_stack_depth = 0
 
static int dvi_tagged_depth = -1
 
static unsigned char link_annot = 1
 

Macro Definition Documentation

◆ CENTI_PDF_U

#define CENTI_PDF_U   658 /* Number of DVI units in a centi PDF unit */

Definition at line 158 of file pdfdev.c.

◆ CMYK

#define CMYK   3

Definition at line 705 of file pdfdev.c.

◆ DEFAULT_MAP_FILE

#define DEFAULT_MAP_FILE   "pdfmfnt.map"

Definition at line 191 of file pdfdev.c.

◆ FORMAT_BUF_SIZE

#define FORMAT_BUF_SIZE   4096

Definition at line 132 of file pdfdev.c.

◆ GRAPHICS_MODE

#define GRAPHICS_MODE   1

Definition at line 109 of file pdfdev.c.

◆ GRAY

#define GRAY   1

Definition at line 703 of file pdfdev.c.

◆ HH_MODE

#define HH_MODE   0

Definition at line 120 of file pdfdev.c.

◆ HV_MODE

#define HV_MODE   1

Definition at line 121 of file pdfdev.c.

◆ PDF_U

#define PDF_U   65800L /* Number of DVI units in a PDF unit */

Definition at line 157 of file pdfdev.c.

◆ PHYSICAL

#define PHYSICAL   1

Definition at line 183 of file pdfdev.c.

◆ PK

#define PK   2

Definition at line 187 of file pdfdev.c.

◆ RGB

#define RGB   2

Definition at line 704 of file pdfdev.c.

◆ STRING_MODE

#define STRING_MODE   3

Definition at line 111 of file pdfdev.c.

◆ TEXT_MODE

#define TEXT_MODE   2

Definition at line 110 of file pdfdev.c.

◆ TRUETYPE

#define TRUETYPE   3

Definition at line 188 of file pdfdev.c.

◆ TYPE0

#define TYPE0   4

Definition at line 189 of file pdfdev.c.

◆ TYPE1

#define TYPE1   1

Definition at line 186 of file pdfdev.c.

◆ VERTDIR

#define VERTDIR (   p)    (p & 0x01)

Definition at line 128 of file pdfdev.c.

◆ VERTFONT

#define VERTFONT (   p)    (p & 0x02)

Definition at line 127 of file pdfdev.c.

◆ VH_MODE

#define VH_MODE   2

Definition at line 122 of file pdfdev.c.

◆ VIRTUAL

#define VIRTUAL   2

Definition at line 184 of file pdfdev.c.

◆ VV_MODE

#define VV_MODE   3

Definition at line 123 of file pdfdev.c.

◆ WMODE_CHANGES

#define WMODE_CHANGES (   p,
  q 
)    ((abs(p-q) % 3) ? 1 : 0)

Definition at line 126 of file pdfdev.c.

Function Documentation

◆ bop_font_reset()

static void bop_font_reset ( void  )
static

Definition at line 1052 of file pdfdev.c.

References dev_reselect_font().

Referenced by dev_bop().

◆ color_by_name()

struct color color_by_name ( char *  s)

Definition at line 693 of file pdfdev.c.

References comment, and pdf_doc_creator().

Referenced by dev_begin_named_color(), dev_bg_named_color(), and dev_set_def_named_color().

◆ dev_add_comment()

void dev_add_comment ( char *  comment)

Definition at line 693 of file pdfdev.c.

◆ dev_begin_cmyk_color()

void dev_begin_cmyk_color ( double  c,
double  m,
double  y,
double  k 
)

◆ dev_begin_gray()

void dev_begin_gray ( double  value)

◆ dev_begin_named_color()

void dev_begin_named_color ( char *  s)

◆ dev_begin_rgb_color()

void dev_begin_rgb_color ( double  r,
double  g,
double  b 
)

◆ dev_begin_xform()

void dev_begin_xform ( double  xscale,
double  yscale,
double  rotate,
double  x_user,
double  y_user 
)

Definition at line 980 of file pdfdev.c.

References c, cos(), e, fprintf, MAX_TRANSFORMS, num_transforms, pdf_doc_add_to_page(), rotate, ROUND, s, sin(), sprintf, strlen(), work_buffer, xscale, and yscale.

Referenced by do_bxform().

◆ dev_bg_cmyk_color()

void dev_bg_cmyk_color ( double  c,
double  m,
double  y,
double  k 
)

Definition at line 771 of file pdfdev.c.

References background, c, color::c1, color::c2, color::c3, color::c4, CMYK, color::colortype, k, m, and y.

Referenced by dev_bg_named_color(), do_background_special(), and do_bgcolor().

◆ dev_bg_gray()

void dev_bg_gray ( double  value)

Definition at line 781 of file pdfdev.c.

References background, color::c1, color::colortype, and GRAY.

Referenced by dev_bg_named_color(), do_background_special(), and do_bgcolor().

◆ dev_bg_named_color()

void dev_bg_named_color ( char *  s)

◆ dev_bg_rgb_color()

void dev_bg_rgb_color ( double  r,
double  g,
double  b 
)

Definition at line 762 of file pdfdev.c.

References b, background, color::c1, color::c2, color::c3, color::colortype, g, r, and RGB.

Referenced by dev_bg_named_color(), do_background_special(), and do_bgcolor().

◆ dev_bop()

◆ dev_clear_color_stack()

static void dev_clear_color_stack ( void  )
static

Definition at line 805 of file pdfdev.c.

References num_colors.

Referenced by dev_init().

◆ dev_clear_xform_stack()

static void dev_clear_xform_stack ( void  )
static

Definition at line 974 of file pdfdev.c.

References num_transforms.

Referenced by dev_init().

◆ dev_close()

void dev_close ( void  )

Definition at line 685 of file pdfdev.c.

References dev_page_height(), hoffset, pdf_doc_set_origin(), and voffset.

Referenced by dvi_close().

◆ dev_close_all_fonts()

◆ dev_close_all_xforms()

void dev_close_all_xforms ( int  depth)

Definition at line 1021 of file pdfdev.c.

References depth, dev_do_color(), dev_reselect_font(), fprintf, num_transforms, and pdf_doc_add_to_page().

Referenced by dev_eop(), and end_form_xobj().

◆ dev_do_color()

◆ dev_do_special()

void dev_do_special ( void buffer,
UNSIGNED_QUAD  size,
spt_t  x_user,
spt_t  y_user 
)

◆ dev_end_color()

void dev_end_color ( void  )

Definition at line 962 of file pdfdev.c.

References dev_do_color(), fprintf, and num_colors.

Referenced by do_color_special(), do_ecolor(), and do_egray().

◆ dev_end_mp_mode()

void dev_end_mp_mode ( void  )

Definition at line 1483 of file pdfdev.c.

References mp_mode, text_wmode, and text_wmode_save.

Referenced by mp_include().

◆ dev_end_xform()

void dev_end_xform ( void  )

Definition at line 999 of file pdfdev.c.

References dev_do_color(), dev_reselect_font(), fprintf, num_transforms, and pdf_doc_add_to_page().

Referenced by do_exform().

◆ dev_eop()

◆ dev_expand_box()

void dev_expand_box ( spt_t  width,
spt_t  height,
spt_t  depth 
)

◆ dev_fonts_need()

void dev_fonts_need ( unsigned  n)

Definition at line 208 of file pdfdev.c.

References MAX, max_device_fonts, MAX_FONTS, n, and RENEW.

Referenced by dev_locate_font().

◆ dev_init()

void dev_init ( double  scale,
double  x_offset,
double  y_offset 
)

◆ dev_link_annot()

void dev_link_annot ( unsigned char  flag)

Definition at line 1402 of file pdfdev.c.

References flag, and link_annot.

Referenced by pdf_parse_special().

◆ dev_locate_font()

◆ dev_page_height()

double dev_page_height ( void  )

Definition at line 92 of file pdfdev.c.

References page_height, and page_size_readonly.

Referenced by dev_close(), dev_phys_y(), fill_page(), finish_page_tree(), and pdf_doc_set_box().

◆ dev_page_width()

double dev_page_width ( void  )

Definition at line 86 of file pdfdev.c.

References page_size_readonly, and page_width.

Referenced by fill_page(), finish_page_tree(), and pdf_doc_set_box().

◆ dev_phys_x()

double dev_phys_x ( void  )

Definition at line 1347 of file pdfdev.c.

References dvi_dev_xpos(), dvi_tell_mag(), and hoffset.

Referenced by dev_expand_box(), do_ann(), do_bead(), and lookup_reference().

◆ dev_phys_y()

double dev_phys_y ( void  )

◆ dev_read_mapfile()

◆ dev_reselect_font()

◆ dev_rule()

void dev_rule ( spt_t  xpos,
spt_t  ypos,
spt_t  width,
spt_t  height 
)

Definition at line 1298 of file pdfdev.c.

References CENTI_PDF_U, centi_u_to_a(), format_buffer, graphics_mode(), height, IDIVRND, len, p1, p2, pdf_doc_add_to_page(), w, and width.

Referenced by dvi_rule().

◆ dev_set_color()

static void dev_set_color ( struct color  color)
static

◆ dev_set_debug()

void dev_set_debug ( void  )

Definition at line 104 of file pdfdev.c.

References debug.

◆ dev_set_def_cmyk_color()

void dev_set_def_cmyk_color ( double  c,
double  m,
double  y,
double  k 
)

◆ dev_set_def_gray()

void dev_set_def_gray ( double  g)

Definition at line 868 of file pdfdev.c.

References color::c1, color::colortype, default_color, dev_do_color(), g, and GRAY.

Referenced by dev_set_def_named_color(), do_color_special(), and do_scolor().

◆ dev_set_def_named_color()

void dev_set_def_named_color ( char *  s)

◆ dev_set_def_rgb_color()

void dev_set_def_rgb_color ( double  r,
double  g,
double  b 
)

◆ dev_set_font()

◆ dev_set_page_size()

void dev_set_page_size ( double  width,
double  height 
)

◆ dev_set_string()

◆ dev_set_verbose()

void dev_set_verbose ( void  )

Definition at line 100 of file pdfdev.c.

References verbose.

Referenced by do_args().

◆ dev_set_wmode()

void dev_set_wmode ( int  dir)

Definition at line 1464 of file pdfdev.c.

References dir, force_reset, text_wmode, and WMODE_CHANGES.

Referenced by do_dir(), dvi_dir(), and dvi_pop().

◆ dev_stack_depth()

void dev_stack_depth ( unsigned int  depth)

Definition at line 1407 of file pdfdev.c.

References depth, dvi_stack_depth, dvi_tagged_depth, link_annot, and pdf_doc_flush_annot().

Referenced by dvi_do_page().

◆ dev_start_mp_mode()

void dev_start_mp_mode ( void  )

Definition at line 1476 of file pdfdev.c.

References HH_MODE, mp_mode, text_wmode, and text_wmode_save.

Referenced by mp_include().

◆ dev_tag_depth()

void dev_tag_depth ( void  )

Definition at line 1425 of file pdfdev.c.

References dvi_compute_boxes(), dvi_stack_depth, and dvi_tagged_depth.

Referenced by pdf_doc_begin_annot().

◆ dev_untag_depth()

void dev_untag_depth ( void  )

Definition at line 1432 of file pdfdev.c.

References dvi_compute_boxes(), and dvi_tagged_depth.

Referenced by pdf_doc_end_annot().

◆ dev_wmode()

int dev_wmode ( void  )

Definition at line 1459 of file pdfdev.c.

References text_wmode, and VERTDIR.

Referenced by embed_image().

◆ dev_xform_depth()

int dev_xform_depth ( void  )

Definition at line 1016 of file pdfdev.c.

References num_transforms.

Referenced by begin_form_xobj().

◆ fill_in_defaults()

static void fill_in_defaults ( struct map_record this_map_record)
static

◆ fill_page()

◆ font_maps_need()

static void font_maps_need ( int  n)
static

Definition at line 224 of file pdfdev.c.

References font_map, MAX, max_font_map, MAX_FONTS, n, and RENEW.

Referenced by dev_read_mapfile().

◆ get_map_record()

struct map_record* get_map_record ( const char *  tex_name)

◆ graphics_mode()

void graphics_mode ( void  )

◆ init_map_record()

static void init_map_record ( struct map_record r)
static

Definition at line 233 of file pdfdev.c.

References NULL, and r.

Referenced by dev_read_mapfile().

◆ om_special()

static int om_special ( char *  buffer,
UNSIGNED_QUAD  size 
)
static

Definition at line 1368 of file pdfdev.c.

References buffer, end, check-static-inits::result, size, skip_white(), start, and strncmp().

Referenced by dev_do_special().

◆ pdf_dev_scale()

double pdf_dev_scale ( void  )

Definition at line 163 of file pdfdev.c.

References dvi2pts.

◆ release_map_record()

static void release_map_record ( struct map_record r)
static

Definition at line 244 of file pdfdev.c.

References r, and RELEASE.

Referenced by dev_close_all_fonts().

◆ reset_text_state()

static void reset_text_state ( void  )
static

◆ set_text_matrix()

static void set_text_matrix ( spt_t  xpos,
spt_t  ypos,
double  slant,
double  extend 
)
static

◆ src_special()

static int src_special ( char *  buffer,
UNSIGNED_QUAD  size 
)
static

Definition at line 1357 of file pdfdev.c.

References buffer, end, check-static-inits::result, size, skip_white(), start, and strncmp().

Referenced by dev_do_special().

◆ string_mode()

◆ text_mode()

static void text_mode ( void  )
static

Variable Documentation

◆ background

struct color background[ 32u ] = { 1 , 1.0, 1.0, 1.0, 1.0}

◆ colorstack

◆ current_font

int current_font = -1

Definition at line 181 of file pdfdev.c.

Referenced by dev_reselect_font(), dev_set_font(), and dev_set_string().

◆ debug

int debug = 0
static

Definition at line 98 of file pdfdev.c.

Referenced by dev_bop(), dev_eop(), dev_init(), and dev_set_debug().

◆ default_color

struct color default_color[ 32u ] = { 1 , 0.0, 0.0, 0.0, 0.0}

◆ dev_font

struct dev_font * dev_font = NULL
static

◆ dvi2pts

double dvi2pts = 0.0
static

Definition at line 60 of file pdfdev.c.

Referenced by dev_expand_box(), dev_init(), dev_locate_font(), pdf_dev_scale(), and pdf_init_device().

◆ dvi_stack_depth

unsigned dvi_stack_depth = 0
static

Definition at line 1398 of file pdfdev.c.

Referenced by dev_expand_box(), dev_stack_depth(), and dev_tag_depth().

◆ dvi_tagged_depth

int dvi_tagged_depth = -1
static

Definition at line 1399 of file pdfdev.c.

Referenced by dev_expand_box(), dev_stack_depth(), dev_tag_depth(), and dev_untag_depth().

◆ font_map

◆ force_reset

int force_reset = 0

◆ format_buffer

char format_buffer[4096]
static

◆ hoffset

double hoffset = 72.0

◆ link_annot

unsigned char link_annot = 1
static

Definition at line 1400 of file pdfdev.c.

Referenced by dev_expand_box(), dev_link_annot(), and dev_stack_depth().

◆ max_device_fonts

unsigned max_device_fonts = 0
static

Definition at line 206 of file pdfdev.c.

Referenced by dev_fonts_need().

◆ max_font_map

unsigned int max_font_map = 0

Definition at line 222 of file pdfdev.c.

Referenced by font_maps_need().

◆ motion_state

int motion_state = 1

Definition at line 113 of file pdfdev.c.

Referenced by dev_set_string(), graphics_mode(), string_mode(), and text_mode().

◆ mp_mode

int mp_mode = 0

Definition at line 130 of file pdfdev.c.

Referenced by dev_end_mp_mode(), dev_set_font(), and dev_start_mp_mode().

◆ num_colors

◆ num_dev_fonts

unsigned num_dev_fonts = 0

◆ num_font_map

unsigned int num_font_map = 0

Definition at line 222 of file pdfdev.c.

Referenced by dev_close_all_fonts(), dev_read_mapfile(), get_map_record(), and vf_locate_font().

◆ num_phys_fonts

unsigned num_phys_fonts = 0

Definition at line 180 of file pdfdev.c.

Referenced by dev_locate_font().

◆ num_transforms

int num_transforms = 0
static

◆ page_height

double page_height =792.0
static

◆ page_size_readonly

int page_size_readonly = 0

Definition at line 74 of file pdfdev.c.

Referenced by dev_page_height(), dev_page_width(), and dev_set_page_size().

◆ page_width

double page_width =612.0
static

◆ text_extend

double text_extend = 1.0

Definition at line 177 of file pdfdev.c.

Referenced by dev_bop(), dev_reselect_font(), dev_set_font(), and reset_text_state().

◆ text_offset

spt_t text_offset = 0
static

Definition at line 176 of file pdfdev.c.

Referenced by dev_set_string(), reset_text_state(), string_mode(), and text_mode().

◆ text_slant

double text_slant = 0.0

Definition at line 177 of file pdfdev.c.

Referenced by dev_bop(), dev_reselect_font(), dev_set_font(), and reset_text_state().

◆ text_wmode

◆ text_wmode_save

int text_wmode_save = 0

Definition at line 125 of file pdfdev.c.

Referenced by dev_end_mp_mode(), and dev_start_mp_mode().

◆ text_xorigin

spt_t text_xorigin = 0
static

Definition at line 175 of file pdfdev.c.

Referenced by dev_set_string(), pdf_dev_set_string(), reset_text_state(), and string_mode().

◆ text_yorigin

spt_t text_yorigin = 0
static

Definition at line 175 of file pdfdev.c.

Referenced by dev_set_string(), pdf_dev_set_string(), reset_text_state(), and string_mode().

◆ verbose

int verbose = 0
static

Definition at line 98 of file pdfdev.c.

Referenced by dev_locate_font(), dev_read_mapfile(), and dev_set_verbose().

◆ voffset

double voffset =72.0