Back to index

tetex-bin  3.0
Classes | Defines | Typedefs | Functions | Variables
writet1.c File Reference
#include "dvips.h"
#include "ptexmac.h"
#include <kpathsea/c-vararg.h>
#include <kpathsea/c-proto.h>

Go to the source code of this file.

Classes

struct  cc_entry
struct  cs_entry

Defines

#define fm_extend(f)   0
#define fm_slant(f)   0
#define is_reencoded(f)   (cur_enc_name != NULL)
#define is_subsetted(f)   true
#define is_included(f)   true
#define set_cur_file_name(s)   cur_file_name = s
#define t1_open()   ((t1_file = search(headerpath, cur_file_name, FOPEN_RBIN_MODE)) != NULL)
#define enc_open()   ((enc_file = search(encpath, cur_file_name, FOPEN_RBIN_MODE)) != NULL)
#define external_enc()   ext_glyph_names
#define full_file_name()   cur_file_name
#define get_length1()
#define get_length2()
#define get_length3()
#define is_used_char(c)   (grid[c] == 1)
#define out_eexec_char   t1_outhex
#define save_offset()
#define end_last_eexec_line()
#define t1_log(s)
#define t1_scan_only()
#define t1_include()
#define t1_putchar(c)   fputc(c, bitfile)
#define t1_scan_keys()
#define update_builtin_enc(font, glyph_names)
#define embed_all_glyphs(tex_font)   false
#define t1_char(c)   c
#define pdfmovechars   0
#define extra_charset()   dvips_extra_charset
#define make_subset_tag(a, b)
#define update_subset_tag()
#define t1_getchar()   getc(t1_file)
#define t1_ungetchar(c)   ungetc(c, t1_file)
#define t1_eof()   feof(t1_file)
#define t1_close()   xfclose(t1_file, cur_file_name)
#define enc_getchar()   getc(enc_file)
#define enc_eof()   feof(enc_file)
#define enc_close()   xfclose(enc_file, cur_file_name)
#define valid_code(c)   (c >= 0 && c <= MAX_CHAR_CODE)
#define T1_BUF_SIZE   0x10
#define ENC_BUF_SIZE   0x1000
#define ENC_STANDARD   0
#define ENC_BUILTIN   1
#define CS_HSTEM   1
#define CS_VSTEM   3
#define CS_VMOVETO   4
#define CS_RLINETO   5
#define CS_HLINETO   6
#define CS_VLINETO   7
#define CS_RRCURVETO   8
#define CS_CLOSEPATH   9
#define CS_CALLSUBR   10
#define CS_RETURN   11
#define CS_ESCAPE   12
#define CS_HSBW   13
#define CS_ENDCHAR   14
#define CS_RMOVETO   21
#define CS_HMOVETO   22
#define CS_VHCURVETO   30
#define CS_HVCURVETO   31
#define CS_1BYTE_MAX   (CS_HVCURVETO + 1)
#define CS_DOTSECTION   CS_1BYTE_MAX + 0
#define CS_VSTEM3   CS_1BYTE_MAX + 1
#define CS_HSTEM3   CS_1BYTE_MAX + 2
#define CS_SEAC   CS_1BYTE_MAX + 6
#define CS_SBW   CS_1BYTE_MAX + 7
#define CS_DIV   CS_1BYTE_MAX + 12
#define CS_CALLOTHERSUBR   CS_1BYTE_MAX + 16
#define CS_POP   CS_1BYTE_MAX + 17
#define CS_SETCURRENTPOINT   CS_1BYTE_MAX + 33
#define CS_2BYTE_MAX   (CS_SETCURRENTPOINT + 1)
#define CS_MAX   CS_2BYTE_MAX
#define str_prefix(s1, s2)   (strncmp(s1, s2, strlen(s2)) == 0)
#define t1_prefix(s)   str_prefix(t1_line_array, s)
#define t1_buf_prefix(s)   str_prefix(t1_buf_array, s)
#define t1_suffix(s)   str_suffix(t1_line_array, t1_line_ptr, s)
#define t1_buf_suffix(s)   str_suffix(t1_buf_array, t1_buf_ptr, s)
#define t1_charstrings()   strstr(t1_line_array, charstringname)
#define t1_subrs()   t1_prefix("/Subrs")
#define t1_end_eexec()   t1_suffix("mark currentfile closefile")
#define t1_cleartomark()   t1_prefix("cleartomark")
#define HEXLINE_WIDTH   64
#define check_subr(subr)
#define store_subr()   cs_store(true)
#define store_cs()   cs_store(false)
#define CC_STACK_SIZE   24
#define cc_pop(N)
#define stack_error(N)
#define cc_get(N)   ((N) < 0 ? *(stack_ptr + (N)) : *(cc_stack + (N)))
#define cc_push(V)   *stack_ptr++ = V
#define cc_clear()   stack_ptr = cc_stack
#define set_cc(N, B, A, C)
#define cs_getchar()   cdecrypt(*data++, &cr)
#define mark_subr(n)   cs_mark(0, n)
#define mark_cs(s)   cs_mark(s, 0)
#define t1_subr_flush()   t1_flush_cs(true)
#define t1_cs_flush()   t1_flush_cs(false)
#define POST_SUBRS_SCAN   5

Typedefs

typedef unsigned char byte
typedef char t1_line_entry
typedef char t1_buf_entry

Functions

FILEsearch ()
 define_array (t1_line)
 define_array (t1_buf)
static void pdftex_fail (char *fmt,...)
static void pdftex_warn (char *fmt,...)
static void end_hexline ()
static void t1_outhex (byte b)
static void enc_getline (void)
void load_enc (char *enc_name, char **glyph_names)
static void t1_check_pfa (void)
static int t1_getbyte (void)
static int hexval (int c)
static byte edecrypt (byte cipher)
static byte cdecrypt (byte cipher, unsigned short *cr)
static byte eencrypt (byte plain)
static byte cencrypt (byte plain, unsigned short *cr)
static char * eol (char *s)
static float t1_scan_num (char *p, char **r)
static boolean str_suffix (const char *begin_buf, const char *end_buf, const char *s)
static void t1_getline (void)
static void t1_putline (void)
static void t1_puts (const char *s)
static void t1_printf (const char *fmt,...)
static void t1_init_params (const char *open_name_prefix)
static void t1_close_font_file (const char *close_name_suffix)
static void t1_check_block_len (boolean decrypt)
static void t1_start_eexec (void)
static void t1_stop_eexec (void)
static void t1_scan_param (void)
static void copy_glyph_names (char **glyph_names, int a, int b)
static void t1_builtin_enc (void)
static void t1_check_end (void)
static boolean t1_open_fontfile (char *open_name_prefix)
static const char ** check_cs_token_pair ()
static void cs_store (boolean is_subr)
static void cc_init (void)
static void cs_warn (const char *cs_name, int subr, const char *fmt,...)
static void cs_mark (const char *cs_name, int subr)
static void t1_subset_ascii_part (void)
static void t1_flush_cs (boolean)
static void cs_init (void)
static void init_cs_entry (cs_entry *cs)
static void t1_mark_glyphs (void)
static void t1_read_subrs (void)
static void t1_subset_charstrings (void)
static void t1_subset_end (void)
void writet1 (void)
void t1_free ()
boolean t1_subset (char *fontfile, char *encfile, unsigned char *g)
boolean t1_subset_2 (char *fontfile, unsigned char *g, char *extraGlyphs)

Variables

static const char perforce_id [] = "$Id: //depot/Build/source.development/TeX/texk/web2c/pdftexdir/writet1.c#23 $"
static char * dvips_extra_charset
FILEbitfile
static char * cur_file_name
static char * cur_enc_name
static unsigned char * grid
static char * ext_glyph_names [MAX_CHAR_CODE+1]
static char print_buf [PRINTF_BUF_SIZE]
static int hexline_length
static char notdef [] = ".notdef"
static size_t last_ptr_index
static const char * standard_glyph_names [MAX_CHAR_CODE+1]
static char charstringname [] = "/CharStrings"
char ** t1_glyph_names
char * t1_builtin_glyph_names [MAX_CHAR_CODE+1]
static boolean read_encoding_only
static int t1_encoding
static unsigned short t1_dr
static unsigned short t1_er
static const unsigned short t1_c1 = 52845
static const unsigned short t1_c2 = 22719
static unsigned short t1_cslen
static short t1_lenIV
static char enc_line [ENC_BUF_SIZE]
static int cs_start
static cs_entrycs_tab
static cs_entrycs_ptr
static cs_entrycs_notdef
static char * cs_dict_start
static char * cs_dict_end
static int cs_count
static int cs_size
static int cs_size_pos
static cs_entrysubr_tab
static char * subr_array_start
static char * subr_array_end
static int subr_max
static int subr_size
static int subr_size_pos
static const char * cs_token_pairs_list [][2]
static const char ** cs_token_pair
static boolean t1_pfa
static boolean t1_cs
static boolean t1_scan
static boolean t1_eexec_encrypt
static boolean t1_synthetic
static int t1_in_eexec
static long t1_block_length
static int last_hexbyte
static FILEt1_file
static FILEenc_file
static integer cc_stack [CC_STACK_SIZE]
static integerstack_ptr = cc_stack
static cc_entry cc_tab [CS_MAX]
static boolean is_cc_init = false

Class Documentation

struct cc_entry

Definition at line 215 of file writet1.c.

Class Members
boolean bottom
boolean clear
byte nargs
boolean valid
struct cs_entry

Definition at line 222 of file writet1.c.

Class Members
unsigned short cslen
byte * data
unsigned short len
char * name
boolean used
boolean valid

Define Documentation

#define cc_clear ( )    stack_ptr = cc_stack

Definition at line 1178 of file writet1.c.

#define cc_get (   N)    ((N) < 0 ? *(stack_ptr + (N)) : *(cc_stack + (N)))

Definition at line 1175 of file writet1.c.

#define cc_pop (   N)
Value:
if (stack_ptr - cc_stack < (N))     \
        stack_error(N);                 \
    stack_ptr -= N

Definition at line 1148 of file writet1.c.

#define cc_push (   V)    *stack_ptr++ = V

Definition at line 1177 of file writet1.c.

#define CC_STACK_SIZE   24

Definition at line 1141 of file writet1.c.

#define check_subr (   subr)
Value:
if (subr >= subr_size || subr < 0) \
        pdftex_fail("Subrs array: entry index out of range (%i)",  subr);

Definition at line 1089 of file writet1.c.

#define CS_1BYTE_MAX   (CS_HVCURVETO + 1)

Definition at line 199 of file writet1.c.

#define CS_2BYTE_MAX   (CS_SETCURRENTPOINT + 1)

Definition at line 210 of file writet1.c.

#define CS_CALLOTHERSUBR   CS_1BYTE_MAX + 16

Definition at line 207 of file writet1.c.

#define CS_CALLSUBR   10

Definition at line 190 of file writet1.c.

#define CS_CLOSEPATH   9

Definition at line 189 of file writet1.c.

#define CS_DIV   CS_1BYTE_MAX + 12

Definition at line 206 of file writet1.c.

#define CS_DOTSECTION   CS_1BYTE_MAX + 0

Definition at line 201 of file writet1.c.

#define CS_ENDCHAR   14

Definition at line 194 of file writet1.c.

#define CS_ESCAPE   12

Definition at line 192 of file writet1.c.

#define cs_getchar ( )    cdecrypt(*data++, &cr)

Definition at line 1224 of file writet1.c.

#define CS_HLINETO   6

Definition at line 186 of file writet1.c.

#define CS_HMOVETO   22

Definition at line 196 of file writet1.c.

#define CS_HSBW   13

Definition at line 193 of file writet1.c.

#define CS_HSTEM   1

Definition at line 182 of file writet1.c.

#define CS_HSTEM3   CS_1BYTE_MAX + 2

Definition at line 203 of file writet1.c.

#define CS_HVCURVETO   31

Definition at line 198 of file writet1.c.

#define CS_MAX   CS_2BYTE_MAX

Definition at line 211 of file writet1.c.

#define CS_POP   CS_1BYTE_MAX + 17

Definition at line 208 of file writet1.c.

#define CS_RETURN   11

Definition at line 191 of file writet1.c.

#define CS_RLINETO   5

Definition at line 185 of file writet1.c.

#define CS_RMOVETO   21

Definition at line 195 of file writet1.c.

#define CS_RRCURVETO   8

Definition at line 188 of file writet1.c.

#define CS_SBW   CS_1BYTE_MAX + 7

Definition at line 205 of file writet1.c.

#define CS_SEAC   CS_1BYTE_MAX + 6

Definition at line 204 of file writet1.c.

#define CS_SETCURRENTPOINT   CS_1BYTE_MAX + 33

Definition at line 209 of file writet1.c.

#define CS_VHCURVETO   30

Definition at line 197 of file writet1.c.

#define CS_VLINETO   7

Definition at line 187 of file writet1.c.

#define CS_VMOVETO   4

Definition at line 184 of file writet1.c.

#define CS_VSTEM   3

Definition at line 183 of file writet1.c.

#define CS_VSTEM3   CS_1BYTE_MAX + 1

Definition at line 202 of file writet1.c.

#define embed_all_glyphs (   tex_font)    false

Definition at line 94 of file writet1.c.

#define ENC_BUF_SIZE   0x1000

Definition at line 177 of file writet1.c.

#define ENC_BUILTIN   1

Definition at line 180 of file writet1.c.

#define enc_close ( )    xfclose(enc_file, cur_file_name)

Definition at line 131 of file writet1.c.

#define enc_eof ( )    feof(enc_file)

Definition at line 130 of file writet1.c.

#define enc_getchar ( )    getc(enc_file)

Definition at line 129 of file writet1.c.

Definition at line 74 of file writet1.c.

#define ENC_STANDARD   0

Definition at line 179 of file writet1.c.

#define end_last_eexec_line ( )
Value:
hexline_length = HEXLINE_WIDTH; \
    end_hexline();                  \
    t1_eexec_encrypt = false

Definition at line 84 of file writet1.c.

#define external_enc ( )    ext_glyph_names

Definition at line 76 of file writet1.c.

Definition at line 104 of file writet1.c.

#define fm_extend (   f)    0

Definition at line 61 of file writet1.c.

#define fm_slant (   f)    0

Definition at line 63 of file writet1.c.

#define full_file_name ( )    cur_file_name

Definition at line 77 of file writet1.c.

#define get_length1 ( )

Definition at line 78 of file writet1.c.

#define get_length2 ( )

Definition at line 79 of file writet1.c.

#define get_length3 ( )

Definition at line 80 of file writet1.c.

#define HEXLINE_WIDTH   64

Definition at line 313 of file writet1.c.

#define is_included (   f)    true

Definition at line 69 of file writet1.c.

#define is_reencoded (   f)    (cur_enc_name != NULL)

Definition at line 65 of file writet1.c.

#define is_subsetted (   f)    true

Definition at line 67 of file writet1.c.

#define is_used_char (   c)    (grid[c] == 1)

Definition at line 81 of file writet1.c.

#define make_subset_tag (   a,
  b 
)

Definition at line 105 of file writet1.c.

#define mark_cs (   s)    cs_mark(s, 0)

Definition at line 1227 of file writet1.c.

#define mark_subr (   n)    cs_mark(0, n)

Definition at line 1226 of file writet1.c.

#define out_eexec_char   t1_outhex

Definition at line 82 of file writet1.c.

#define pdfmovechars   0

Definition at line 102 of file writet1.c.

#define POST_SUBRS_SCAN   5
#define save_offset ( )

Definition at line 83 of file writet1.c.

#define set_cc (   N,
  B,
  A,
  C 
)
Value:
cc_tab[N].nargs = A;   \
    cc_tab[N].bottom = B;  \
    cc_tab[N].clear = C;   \
    cc_tab[N].valid = true

Definition at line 1180 of file writet1.c.

#define set_cur_file_name (   s)    cur_file_name = s

Definition at line 71 of file writet1.c.

#define stack_error (   N)
Value:
{                \
    pdftex_warn("CharString: invalid access (%i) to stack (%i entries)", \
                 N, stack_ptr - cc_stack);                               \
    goto cs_error;                    \
}

Definition at line 1153 of file writet1.c.

#define store_cs ( )    cs_store(false)

Definition at line 1139 of file writet1.c.

#define store_subr ( )    cs_store(true)

Definition at line 1138 of file writet1.c.

#define str_prefix (   s1,
  s2 
)    (strncmp(s1, s2, strlen(s2)) == 0)

Definition at line 273 of file writet1.c.

#define t1_buf_prefix (   s)    str_prefix(t1_buf_array, s)

Definition at line 275 of file writet1.c.

#define T1_BUF_SIZE   0x10

Definition at line 176 of file writet1.c.

#define t1_buf_suffix (   s)    str_suffix(t1_buf_array, t1_buf_ptr, s)

Definition at line 277 of file writet1.c.

#define t1_char (   c)    c

Definition at line 101 of file writet1.c.

#define t1_charstrings ( )    strstr(t1_line_array, charstringname)

Definition at line 278 of file writet1.c.

#define t1_cleartomark ( )    t1_prefix("cleartomark")

Definition at line 281 of file writet1.c.

#define t1_close ( )    xfclose(t1_file, cur_file_name)

Definition at line 127 of file writet1.c.

#define t1_cs_flush ( )    t1_flush_cs(false)

Definition at line 1428 of file writet1.c.

#define t1_end_eexec ( )    t1_suffix("mark currentfile closefile")

Definition at line 280 of file writet1.c.

#define t1_eof ( )    feof(t1_file)

Definition at line 126 of file writet1.c.

#define t1_getchar ( )    getc(t1_file)

Definition at line 124 of file writet1.c.

#define t1_include ( )

Definition at line 90 of file writet1.c.

#define t1_log (   s)

Definition at line 88 of file writet1.c.

Definition at line 72 of file writet1.c.

#define t1_prefix (   s)    str_prefix(t1_line_array, s)

Definition at line 274 of file writet1.c.

#define t1_putchar (   c)    fputc(c, bitfile)

Definition at line 91 of file writet1.c.

#define t1_scan_keys ( )

Definition at line 92 of file writet1.c.

#define t1_scan_only ( )

Definition at line 89 of file writet1.c.

#define t1_subr_flush ( )    t1_flush_cs(true)

Definition at line 1427 of file writet1.c.

#define t1_subrs ( )    t1_prefix("/Subrs")

Definition at line 279 of file writet1.c.

#define t1_suffix (   s)    str_suffix(t1_line_array, t1_line_ptr, s)

Definition at line 276 of file writet1.c.

#define t1_ungetchar (   c)    ungetc(c, t1_file)

Definition at line 125 of file writet1.c.

#define update_builtin_enc (   font,
  glyph_names 
)

Definition at line 93 of file writet1.c.

#define update_subset_tag ( )

Definition at line 106 of file writet1.c.

#define valid_code (   c)    (c >= 0 && c <= MAX_CHAR_CODE)

Definition at line 133 of file writet1.c.


Typedef Documentation

typedef unsigned char byte

Definition at line 213 of file writet1.c.

typedef char t1_buf_entry

Definition at line 242 of file writet1.c.

typedef char t1_line_entry

Definition at line 238 of file writet1.c.


Function Documentation

static void cc_init ( void  ) [static]

Definition at line 1186 of file writet1.c.

{
    int i;
    if (is_cc_init)
        return;
    for (i = 0; i < CS_MAX; i++)
        cc_tab[i].valid = false;
    set_cc(CS_HSTEM,           true,   2, true);
    set_cc(CS_VSTEM,           true,   2, true);
    set_cc(CS_VMOVETO,         true,   1, true);
    set_cc(CS_RLINETO,         true,   2, true);
    set_cc(CS_HLINETO,         true,   1, true);
    set_cc(CS_VLINETO,         true,   1, true);
    set_cc(CS_RRCURVETO,       true,   6, true);
    set_cc(CS_CLOSEPATH,       false,  0, true);
    set_cc(CS_CALLSUBR,        false,  1, false);
    set_cc(CS_RETURN,          false,  0, false);
    /*
    set_cc(CS_ESCAPE,          false,  0, false);
    */
    set_cc(CS_HSBW,            true,   2, true);
    set_cc(CS_ENDCHAR,         false,  0, true);
    set_cc(CS_RMOVETO,         true,   2, true);
    set_cc(CS_HMOVETO,         true,   1, true);
    set_cc(CS_VHCURVETO,       true,   4, true);
    set_cc(CS_HVCURVETO,       true,   4, true);
    set_cc(CS_DOTSECTION,      false,  0, true);
    set_cc(CS_VSTEM3,          true,   6, true);
    set_cc(CS_HSTEM3,          true,   6, true);
    set_cc(CS_SEAC,            true,   5, true);
    set_cc(CS_SBW,             true,   4, true);
    set_cc(CS_DIV,             false,  2, false);
    set_cc(CS_CALLOTHERSUBR,   false,  0, false);
    set_cc(CS_POP,             false,  0, false);
    set_cc(CS_SETCURRENTPOINT, true,   2, true);
    is_cc_init = true;
}

Here is the caller graph for this function:

static byte cdecrypt ( byte  cipher,
unsigned short cr 
) [static]

Definition at line 459 of file writet1.c.

{
    byte plain = (cipher^(*cr >> 8));
    *cr = (cipher + *cr)*t1_c1 + t1_c2;
    return plain;
}
static byte cencrypt ( byte  plain,
unsigned short cr 
) [static]

Definition at line 473 of file writet1.c.

{
    byte cipher = (plain^(*cr >> 8));
    *cr = (cipher + *cr)*t1_c1 + t1_c2;
    return cipher;
}

Here is the caller graph for this function:

static const char** check_cs_token_pair ( ) [static]

Definition at line 1093 of file writet1.c.

{
    const char **p = (const char**) cs_token_pairs_list;
    for (; p[0] != NULL; ++p) 
        if (t1_buf_prefix(p[0]) && t1_buf_suffix(p[1]))
            return p;
    return NULL;
}

Here is the caller graph for this function:

static void copy_glyph_names ( char **  glyph_names,
int  a,
int  b 
) [static]

Definition at line 861 of file writet1.c.

{
    if (glyph_names[b] != notdef) {
        free(glyph_names[b]);
        glyph_names[b] = (char*) notdef;
    }
    if (glyph_names[a] != notdef) {
        glyph_names[b] = xstrdup(glyph_names[a]);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void cs_init ( void  ) [static]

Definition at line 1432 of file writet1.c.

Here is the caller graph for this function:

static void cs_mark ( const char *  cs_name,
int  subr 
) [static]

Definition at line 1242 of file writet1.c.

{
    byte *data;
    int i, b, cs_len;
    integer a, a1, a2;
    unsigned short cr;
    static integer lastargOtherSubr3 = 3; /* the argument of last call to 
                                             OtherSubrs[3] */
    cs_entry *ptr;
    cc_entry *cc;
    if (cs_name == NULL) {
        check_subr(subr);
        ptr = subr_tab + subr;
        if (!ptr->valid)
            return;
    }
    else {
        if (cs_notdef != NULL && 
            (cs_name == notdef || strcmp(cs_name, notdef) == 0))
            ptr = cs_notdef;
        else {
            for (ptr = cs_tab; ptr < cs_ptr; ptr++)
                if (strcmp(ptr->name, cs_name) == 0)
                    break;
            if (ptr == cs_ptr) {
                pdftex_warn("glyph `%s' undefined", cs_name);
                return;
            }
            if (ptr->name == notdef)
                cs_notdef = ptr;
        }
    }
    /* only marked CharString entries and invalid entries can be skipped;
       valid marked subrs must be parsed to keep the stack in sync */
    if (!ptr->valid || (ptr->used && cs_name != NULL))
        return; 
    ptr->used = true;
    cr = 4330; 
    cs_len = ptr->cslen;
    data = ptr->data + 4;
    for (i = 0; i < t1_lenIV; i++, cs_len--)
        cs_getchar();
    while (cs_len > 0) {
        --cs_len;
        b = cs_getchar();
        if (b >= 32) {
            if (b <= 246)
                a = b - 139;
            else if (b <= 250) {
                --cs_len;
                a = ((b - 247) << 8) + 108 + cs_getchar();
            } 
            else if (b <= 254) {
                --cs_len;
                a = -((b - 251) << 8) - 108 - cs_getchar();
            } 
            else {
                cs_len -= 4;
                a =  (cs_getchar() & 0xff) << 24;
                a |= (cs_getchar() & 0xff) << 16;
                a |= (cs_getchar() & 0xff) <<  8;
                a |= (cs_getchar() & 0xff) <<  0;
                if (sizeof(integer) > 4 && (a & 0x80000000))
                    a |= ~0x7FFFFFFF;
            }
            cc_push(a);
        }
        else {
            if (b == CS_ESCAPE) {
                b = cs_getchar() + CS_1BYTE_MAX;
                cs_len--;
            }
            if (b >= CS_MAX) {
                cs_warn(cs_name, subr, "command value out of range: %i", (int)b);
                goto cs_error;
            }
            cc = cc_tab + b;
            if (!cc->valid) {
                cs_warn(cs_name, subr, "command not valid: %i", (int)b);
                goto cs_error;
            }
            if (cc->bottom) {
                if (stack_ptr - cc_stack < cc->nargs)
                    cs_warn(cs_name, subr, 
                            "less arguments on stack (%i) than required (%i)",
                            (int)(stack_ptr - cc_stack), (int)cc->nargs);
                else if (stack_ptr - cc_stack > cc->nargs)
                    cs_warn(cs_name, subr, 
                            "more arguments on stack (%i) than required (%i)",
                            (int)(stack_ptr - cc_stack), (int)cc->nargs);
            }
            switch (cc - cc_tab) {
            case CS_CALLSUBR:
                a1 = cc_get(-1);
                cc_pop(1);
                mark_subr(a1);
                if (!subr_tab[a1].valid) {
                    cs_warn(cs_name, subr, 
                            "cannot call subr (%i)", (int)a1);
                    goto cs_error;
                }
                break;
            case CS_DIV:
                cc_pop(2);
                cc_push(0);
                break;
            case CS_CALLOTHERSUBR:
                if (cc_get(-1) == 3)
                    lastargOtherSubr3 = cc_get(-3);
                a1 = cc_get(-2) + 2;
                cc_pop(a1);
                break;
            case CS_POP:
                cc_push(lastargOtherSubr3);
                /* the only case when we care about the value being pushed onto
                   stack is when POP follows CALLOTHERSUBR (changing hints by
                   OtherSubrs[3]) 
                 */
                break;
            case CS_SEAC:
                a1 = cc_get(3);
                a2 = cc_get(4);
                cc_clear();
                mark_cs(standard_glyph_names[a1]);
                mark_cs(standard_glyph_names[a2]);
                break;
            default:
                if (cc->clear)
                    cc_clear();
            }
        }
    }
    return;
cs_error: /* an error occured during parsing */
    cc_clear();
    ptr->valid = false;
    ptr->used = false;
}

Here is the call graph for this function:

static void cs_store ( boolean  is_subr) [static]

Definition at line 1102 of file writet1.c.

{
    char *p;
    cs_entry *ptr;
    int subr;
    for (p = t1_line_array, t1_buf_ptr = t1_buf_array; *p != ' '; *t1_buf_ptr++ = *p++);
    *t1_buf_ptr = 0;
    if (is_subr) {
        subr = t1_scan_num(p + 1, 0);
        check_subr(subr);
        ptr = subr_tab + subr;
    }
    else {
        ptr = cs_ptr++;
        if (cs_ptr - cs_tab > cs_size)
            pdftex_fail("CharStrings dict: more entries than dict size (%i)", cs_size);
        if (strcmp(t1_buf_array + 1, notdef) == 0) /* skip the slash */
            ptr->name = (char*) notdef;
        else
            ptr->name = xstrdup(t1_buf_array + 1); 
    }
    /* copy " RD " + cs data to t1_buf_array */
    memcpy(t1_buf_array, t1_line_array + cs_start - 4, (unsigned)(t1_cslen + 4));
    /* copy the end of cs data to t1_buf_array */
    for (p = t1_line_array + cs_start + t1_cslen, t1_buf_ptr = t1_buf_array + t1_cslen + 4; 
         *p != 10; *t1_buf_ptr++ = *p++);
    *t1_buf_ptr++ = 10;
    if (is_subr && cs_token_pair == NULL)
        cs_token_pair = check_cs_token_pair();
    ptr->len = t1_buf_ptr - t1_buf_array;
    ptr->cslen = t1_cslen;
    ptr->data = xtalloc(ptr->len, byte);
    memcpy(ptr->data, t1_buf_array, ptr->len);
    ptr->valid = true;
}

Here is the call graph for this function:

static void cs_warn ( const char *  cs_name,
int  subr,
const char *  fmt,
  ... 
) [static]

Definition at line 1229 of file writet1.c.

{
    char buf[SMALL_BUF_SIZE];
    va_list args;
    va_start(args, fmt);
    vsprintf(buf, fmt, args);
    va_end(args);
    if (cs_name == NULL)
        pdftex_warn("Subr (%i): %s", (int)subr, buf);
    else
        pdftex_warn("CharString (/%s): %s", cs_name, buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

define_array ( t1_line  )
define_array ( t1_buf  )
static byte edecrypt ( byte  cipher) [static]

Definition at line 446 of file writet1.c.

{
    byte plain;
    if (t1_pfa) {
        while (cipher == 10 || cipher == 13)
            cipher = t1_getbyte();
        last_hexbyte = cipher = (hexval(cipher) << 4) + hexval(t1_getbyte());
    }
    plain = (cipher^(t1_dr >> 8));
    t1_dr = (cipher + t1_dr)*t1_c1 + t1_c2;
    return plain;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static byte eencrypt ( byte  plain) [static]

Definition at line 466 of file writet1.c.

{
    byte cipher = (plain^(t1_er >> 8));
    t1_er = (cipher + t1_er)*t1_c1 + t1_c2;
    return cipher;
}

Here is the caller graph for this function:

static void enc_getline ( void  ) [static]

Definition at line 334 of file writet1.c.

{
    char *p;
    int c;
restart:
    if (enc_eof())
        pdftex_fail("unexpected end of file");
    p = enc_line;
    do {
        c = enc_getchar();
        append_char_to_buf(c, p, enc_line, ENC_BUF_SIZE);
    } while (c != 10);
    append_eol(p, enc_line, ENC_BUF_SIZE);
    if (p - enc_line < 2 || *enc_line == '%')
        goto restart;
}
static void end_hexline ( ) [static]

Definition at line 315 of file writet1.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static char* eol ( char *  s) [static]

Definition at line 480 of file writet1.c.

{
    char *p = strend(s);
    if (p - s > 1 && p[-1] != 10) {
        *p++ = 10;
        *p = 0;
    }
    return p;
}

Here is the caller graph for this function:

static int hexval ( int  c) [static]

Definition at line 434 of file writet1.c.

{
    if (c >= 'A' && c <= 'F')
        return c - 'A' + 10;
    else if (c >= 'a' && c <= 'f')
        return c - 'a' + 10;
    else if (c >= '0' && c <= '9')
        return c - '0';
    else
        return -1;
}

Here is the caller graph for this function:

static void init_cs_entry ( cs_entry cs) [static]

Definition at line 1443 of file writet1.c.

{
    cs->data = NULL;
    cs->name = NULL;
    cs->len = 0;
    cs->cslen = 0;
    cs->used = false;
    cs->valid = false;
}

Here is the caller graph for this function:

void load_enc ( char *  enc_name,
char **  glyph_names 
)

Definition at line 351 of file writet1.c.

{
    char buf[ENC_BUF_SIZE], *p, *r;
    int names_count;
    set_cur_file_name(enc_name);
    if (!enc_open()) {
        pdftex_warn("cannot open encoding file for reading");
        cur_file_name = NULL;
        return;
    }
    t1_log("{");
    t1_log(cur_file_name = full_file_name());
    enc_getline();
    if (*enc_line != '/' || (r = strchr(enc_line, '[')) == NULL) {
        remove_eol(r, enc_line);
        pdftex_fail("invalid encoding vector (a name or `[' missing): `%s'", enc_line);
    }
    names_count = 0;
    r++; /* skip '[' */
    skip(r, ' ');
    for (;;) {
        while (*r == '/') {
            for (p = buf, r++; *r != ' ' && *r != 10 && *r != ']' && *r != '/'; *p++ = *r++);
            *p = 0;
            skip(r, ' ');
            if (names_count > MAX_CHAR_CODE)
                pdftex_fail("encoding vector contains more than %i names",
                            (int)(MAX_CHAR_CODE + 1));
            if (strcmp(buf, notdef) != 0)
                glyph_names[names_count] = xstrdup(buf);
            names_count++;
        }
        if (*r != 10 && *r != '%') {
            if (strncmp(r, "] def", strlen("] def")) == 0) 
                goto done;
            else {
                remove_eol(r, enc_line);
                pdftex_fail("invalid encoding vector: a name or `] def' expected: `%s'", enc_line);
            }
        }
        enc_getline();
        r = enc_line;
    }
done:
    enc_close();
    t1_log("}");
    cur_file_name = NULL;
}

Here is the call graph for this function:

static void pdftex_fail ( char *  fmt,
  ... 
) [static]

Definition at line 284 of file writet1.c.

{
    va_list args;
    va_start(args, fmt);
    fputs("\nError: module writet1", stderr);
    if (cur_file_name)
        fprintf(stderr, " (file %s)", cur_file_name);
    fputs(": ", stderr);
    vsprintf(print_buf, fmt, args);
    fputs(print_buf, stderr);
    fputs("\n ==> Fatal error occurred, the output PS file is not finished!\n", stderr);
    va_end(args);
    exit(-1);
}

Here is the call graph for this function:

static void pdftex_warn ( char *  fmt,
  ... 
) [static]

Definition at line 299 of file writet1.c.

{
    va_list args;
    va_start(args, fmt);
    fputs("\nWarning: module writet1 of dvips", stderr);
    if (cur_file_name)
        fprintf(stderr, " (file %s)", cur_file_name);
    fputs(": ", stderr);
    vsprintf(print_buf, fmt, args);
    fputs(print_buf, stderr);
    fputs("\n", stderr);
    va_end(args);
}

Here is the call graph for this function:

FILE* search ( )
static boolean str_suffix ( const char *  begin_buf,
const char *  end_buf,
const char *  s 
) [static]

Definition at line 506 of file writet1.c.

{
    const char *s1 = end_buf - 1, 
               *s2 = strend(s) - 1;
    if (*s1 == 10)
        s1--;
    while (s1 >= begin_buf && s2 >= s) {
        if (*s1-- != *s2--)
            return false;
    }
    return s2 < s;
}
static void t1_builtin_enc ( void  ) [static]

Definition at line 872 of file writet1.c.

{
    int i, a, b, c, counter = 0;
    char *r, *p;
   /*
    * At this moment "/Encoding" is the prefix of t1_line_array
    */
    if (t1_suffix("def")) { /* predefined encoding */
        sscanf(t1_line_array + strlen("/Encoding"), "%256s", t1_buf_array);
        if (strcmp(t1_buf_array, "StandardEncoding") == 0) {
            for (i = 0; i <= MAX_CHAR_CODE; i++)
                if (standard_glyph_names[i] == notdef)
                    t1_builtin_glyph_names[i] = (char*) notdef;
                else
                    t1_builtin_glyph_names[i] = xstrdup(standard_glyph_names[i]);
            t1_encoding = ENC_STANDARD;
        }
        else 
            pdftex_fail("cannot subset font (unknown predefined encoding `%s')", 
                        t1_buf_array);
        return;
    } else
        t1_encoding = ENC_BUILTIN;
   /*
    * At this moment "/Encoding" is the prefix of t1_line_array, and the encoding is
    * not a predefined encoding
    * 
    * We have two possible forms of Encoding vector. The first case is
    * 
    *     /Encoding [/a /b /c...] readonly def
    * 
    * and the second case can look like
    * 
    *     /Encoding 256 array 0 1 255 {1 index exch /.notdef put} for
    *     dup 0 /x put
    *     dup 1 /y put
    *     ...
    *     readonly def
    */
    for (i = 0; i <= MAX_CHAR_CODE; i++)
        t1_builtin_glyph_names[i] = (char*) notdef;
    if (t1_prefix("/Encoding [") || t1_prefix("/Encoding[")) { /* the first case */
        r = strchr(t1_line_array, '[') + 1;
        skip(r, ' ');
        for(;;) {
            while (*r == '/') {
                for (p = t1_buf_array, r++;
                     *r != 32 && *r != 10 && *r != ']' && *r != '/';
                     *p++ = *r++);
                *p = 0;
                skip(r, ' ');
                if (counter > MAX_CHAR_CODE)
                    pdftex_fail("encoding vector contains more than %i names",
                            (int)(MAX_CHAR_CODE + 1));
                if (strcmp(t1_buf_array, notdef) != 0)
                    t1_builtin_glyph_names[counter] = xstrdup(t1_buf_array);
                counter++;
            }
            if (*r != 10 && *r != '%') {
                if (str_prefix(r, "] def") || str_prefix(r, "] readonly def"))
                    break;
                else {
                    remove_eol(r, t1_line_array);
                    pdftex_fail("a name or `] def' or `] readonly def' expected: `%s'",
                                t1_line_array);
                }
            }
            t1_getline();
            r = t1_line_array;
        }
    }
    else { /* the second case */
        p = strchr(t1_line_array, 10); 
        for (;;) {
            if (*p == 10) {
                t1_getline();
                p = t1_line_array;
            }
            /*
             check for `dup <index> <glyph> put'
             */
            if (sscanf(p, "dup %i%256s put", &i, t1_buf_array) == 2 && 
                *t1_buf_array == '/' && valid_code(i)) {
                if (strcmp(t1_buf_array + 1, notdef) != 0)
                    t1_builtin_glyph_names[i] = xstrdup(t1_buf_array + 1);
                p = strstr(p, " put") + strlen(" put");
                skip(p, ' ');
            }
            /*
             check for `dup dup <to> exch <from> get put'
             */
            else if (sscanf(p, "dup dup %i exch %i get put", &b, &a) == 2 &&
                     valid_code(a) && valid_code(b)) {
                copy_glyph_names(t1_builtin_glyph_names, a, b);
                p = strstr(p, " get put") + strlen(" get put");
                skip(p, ' ');
            }
            /*
             check for `dup dup <from> <size> getinterval <to> exch putinterval'
             */
            else if (sscanf(p, "dup dup %i %i getinterval %i exch putinterval", 
                            &a, &c, &b) == 3 && 
                     valid_code(a) && valid_code(b) && valid_code(c)) {
                for (i = 0; i < c; i++)
                    copy_glyph_names(t1_builtin_glyph_names, a + i, b + i);
                p = strstr(p, " putinterval") + strlen(" putinterval");
                skip(p, ' ');
            }
            /*
             check for `def' or `readonly def'
             */
            else if ((p == t1_line_array || (p > t1_line_array && p[-1] == ' ')) &&
                     strcmp(p, "def\n") == 0)
                return;
            /* 
             skip an unrecognizable word 
             */
            else {
                while (*p != ' ' && *p != 10)
                    p++;    
                skip(p, ' ');
            }
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void t1_check_block_len ( boolean  decrypt) [static]

Definition at line 628 of file writet1.c.

{
    int l, c;
    if (t1_block_length == 0)
       return;
    c = t1_getbyte();
    if (decrypt) 
        c = edecrypt(c);
    l = t1_block_length;
    if (!(l == 0 && (c == 10 || c == 13))) {
        pdftex_warn("%i bytes more than expected were ignored", l + 1);
        while (l-- > 0)
            t1_getbyte();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void t1_check_end ( void  ) [static]

Definition at line 998 of file writet1.c.

{
    if (t1_eof())
        return;
    t1_getline();
    if (t1_prefix("{restore}"))
        t1_putline();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void t1_check_pfa ( void  ) [static]

Definition at line 400 of file writet1.c.

{
    int c = t1_getchar();
    if (c != 128)
        t1_pfa = true;
    else 
        t1_pfa = false;
    t1_ungetchar(c);
}

Here is the caller graph for this function:

static void t1_close_font_file ( const char *  close_name_suffix) [static]

Definition at line 621 of file writet1.c.

{
    t1_log(close_name_suffix);
    t1_close();
    cur_file_name = NULL;
}

Here is the caller graph for this function:

static void t1_flush_cs ( boolean  is_subr) [static]

Definition at line 1526 of file writet1.c.

{
    char *p;
    byte *r, *return_cs = NULL;
    cs_entry *tab, *end_tab, *ptr;
    char *start_line, *line_end;
    int count, size_pos;
    unsigned short cr, cs_len;
    if (is_subr) {
        start_line = subr_array_start;
        line_end = subr_array_end;
        size_pos = subr_size_pos;
        tab = subr_tab;
        count = subr_max + 1;
        end_tab = subr_tab + count;
    }
    else {
        start_line = cs_dict_start;
        line_end = cs_dict_end;
        size_pos = cs_size_pos;
        tab =  cs_tab;
        end_tab = cs_ptr;
        count = cs_count;
    }
    t1_line_ptr = t1_line_array;
    for (p = start_line; p - start_line < size_pos;)
        *t1_line_ptr++ = *p++;
    while (isdigit(*p))
        p++;
    sprintf(t1_line_ptr, "%u", count);
    strcat(t1_line_ptr, p);
    t1_line_ptr = eol(t1_line_array);
    t1_putline();

    /* create return_cs to replace unsused subr's */
    if (is_subr) {
        cr = 4330;
        cs_len = 0;
        return_cs = xtalloc(t1_lenIV + 1, byte);
        if (t1_lenIV > 0) {
            for (cs_len = 0, r = return_cs; cs_len < t1_lenIV; cs_len++, r++)
                *r = cencrypt(0x00, &cr);
            *r = cencrypt(CS_RETURN, &cr);
        }
        else {
            *return_cs = CS_RETURN;
        }
        cs_len++;
    }

    for (ptr = tab; ptr < end_tab; ptr++) {
        if (ptr->used) {
            if (is_subr)
                sprintf(t1_line_array, "dup %u %u", ptr - tab, ptr->cslen);
            else
                sprintf(t1_line_array, "/%s %u", ptr->name, ptr->cslen);
            p = strend(t1_line_array);
            memcpy(p, ptr->data, ptr->len);
            t1_line_ptr = p + ptr->len;
            t1_putline();
        }
        else {
            /* replace unsused subr's by return_cs */
            if (is_subr) {
                sprintf(t1_line_array, "dup %u %u%s ", ptr - tab, cs_len,
                        cs_token_pair[0]);
                p = strend(t1_line_array);
                memcpy(p, return_cs, cs_len);
                t1_line_ptr = p + cs_len;
                t1_putline();
                sprintf(t1_line_array, " %s", cs_token_pair[1]);
                t1_line_ptr = eol(t1_line_array);
                t1_putline();
            }
        }
        xfree(ptr->data);
        if (ptr->name != notdef)
            xfree(ptr->name);
    }
    sprintf(t1_line_array, "%s", line_end);
    t1_line_ptr = eol(t1_line_array);
    t1_putline();
    if (is_subr)
        xfree(return_cs);
    xfree(tab);
    xfree(start_line);
    xfree(line_end);
}

Here is the call graph for this function:

void t1_free ( void  )

Definition at line 1755 of file writet1.c.

{
    xfree(t1_line_array);
    xfree(t1_buf_array);
}
static int t1_getbyte ( void  ) [static]

Definition at line 410 of file writet1.c.

{
    int c = t1_getchar();
    if (t1_pfa)
        return c;
    if (t1_block_length == 0) {
        if (c != 128)
            pdftex_fail("invalid marker");
        c = t1_getchar();
        if (c == 3) {
            while (!t1_eof())
                t1_getchar();
            return EOF;
        }
        t1_block_length = t1_getchar() & 0xff;
        t1_block_length |= (t1_getchar() & 0xff) << 8;
        t1_block_length |= (t1_getchar() & 0xff) << 16;
        t1_block_length |= (t1_getchar() & 0xff) << 24;
        c = t1_getchar();
    }
    t1_block_length--;
    return c;
}

Here is the caller graph for this function:

static void t1_getline ( void  ) [static]

Definition at line 520 of file writet1.c.

{
    int c, l, eexec_scan;
    char *p;
    static const char eexec_str[] = "currentfile eexec";
    static int eexec_len = 17; /* strlen(eexec_str) */
restart:
    if (t1_eof())
        pdftex_fail("unexpected end of file");
    t1_line_ptr = t1_line_array;
    alloc_array(t1_line, 1, T1_BUF_SIZE);
    t1_cslen = 0;
    eexec_scan = 0;
    c = t1_getbyte();
    if (c == EOF)
        goto exit;
    while (!t1_eof()) {
        if (t1_in_eexec == 1) 
            c = edecrypt(c);
        alloc_array(t1_line, 1, T1_BUF_SIZE);
        append_char_to_buf(c, t1_line_ptr, t1_line_array, t1_line_limit);
        if (t1_in_eexec == 0 && eexec_scan >= 0 && eexec_scan < eexec_len) {
            if (t1_line_array[eexec_scan] == eexec_str[eexec_scan])
                eexec_scan++;
            else
                eexec_scan = -1;
        }
        if (c == 10 || (t1_pfa && eexec_scan == eexec_len && c == 32))
            break;
        if (t1_cs && t1_cslen == 0 && (t1_line_ptr - t1_line_array > 4) && 
           (t1_suffix(" RD ") || t1_suffix(" -| "))) {
            p = t1_line_ptr - 5;
            while (*p != ' ')
                p--;
            t1_cslen = l = t1_scan_num(p + 1, 0);
            cs_start = t1_line_ptr - t1_line_array; /* cs_start is an index now */
            alloc_array(t1_line, l, T1_BUF_SIZE);
            while (l-- > 0)
                *t1_line_ptr++ = edecrypt(t1_getbyte());
        }
        c = t1_getbyte();
    }
    alloc_array(t1_line, 2, T1_BUF_SIZE); /* append_eol can append 2 chars */
    append_eol(t1_line_ptr, t1_line_array, t1_line_limit);
    if (t1_line_ptr - t1_line_array < 2)
        goto restart;
    if (eexec_scan == eexec_len)
        t1_in_eexec = 1;
exit:
    /* ensure that t1_buf_array has as much room as t1_line_array */
    t1_buf_ptr = t1_buf_array;
    alloc_array(t1_buf, t1_line_limit, t1_line_limit);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void t1_init_params ( const char *  open_name_prefix) [static]

Definition at line 605 of file writet1.c.

{
    t1_log(open_name_prefix);
    t1_log(cur_file_name);
    t1_lenIV = 4;
    t1_dr = 55665;
    t1_er = 55665;
    t1_in_eexec = 0;
    t1_cs = false;
    t1_scan = true;
    t1_synthetic = false;
    t1_eexec_encrypt = false;
    t1_block_length = 0;
    t1_check_pfa();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void t1_mark_glyphs ( void  ) [static]

Definition at line 1615 of file writet1.c.

{
    int i;
    char *charset = extra_charset();
    char *g, *s, *r;
    cs_entry *ptr;
    if (t1_synthetic || embed_all_glyphs(tex_font)) { /* mark everything */
        if (cs_tab != NULL)
            for (ptr = cs_tab; ptr < cs_ptr; ptr++)
                if (ptr->valid)
                    ptr->used = true;
        if (subr_tab != NULL) {
            for (ptr = subr_tab; ptr - subr_tab < subr_size; ptr++)
                if (ptr->valid)
                    ptr->used = true;
            subr_max = subr_size - 1;
        }
        return;
    }
    mark_cs(notdef);
    for (i = 0; i <= MAX_CHAR_CODE; i++)
        if (is_used_char(i)) {
            if (t1_glyph_names[i] == notdef)
                pdftex_warn("character %i is mapped to %s", i, notdef);
            else
                mark_cs(t1_glyph_names[i]);
        }
    if (charset == NULL)
        goto set_subr_max;
    g = s = charset + 1; /* skip the first '/' */
    r = strend(g);
    while (g < r) {
        while (*s != '/' && s < r)
            s++;
        *s = 0; /* terminate g by rewriting '/' to 0 */
        mark_cs(g);
        g = s + 1;
    }
set_subr_max:
    if (subr_tab != NULL)
        for (subr_max = -1, ptr = subr_tab; ptr - subr_tab < subr_size; ptr++)
            if (ptr->used && ptr - subr_tab > subr_max)
                subr_max = ptr - subr_tab;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static boolean t1_open_fontfile ( char *  open_name_prefix) [static]

Definition at line 1080 of file writet1.c.

{
    if (!t1_open())
        return false;
    t1_init_params(open_name_prefix);
    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void t1_outhex ( byte  b) [static]

Definition at line 323 of file writet1.c.

{
    static char *hexdigits = "0123456789ABCDEF";
    t1_putchar(hexdigits[b/16]);
    t1_putchar(hexdigits[b%16]);
    hexline_length += 2;
    end_hexline();
}

Here is the call graph for this function:

static void t1_printf ( const char *  fmt,
  ... 
) [static]

Definition at line 596 of file writet1.c.

{
    va_list args;
    va_start(args, fmt);
    vsprintf(t1_line_array, fmt, args);
    t1_puts(t1_line_array);                                    
    va_end(args);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void t1_putline ( void  ) [static]

Definition at line 574 of file writet1.c.

{
    char *p = t1_line_array;
    if (t1_line_ptr - t1_line_array <= 1)
        return;
    if (t1_eexec_encrypt)  {
        while (p < t1_line_ptr)
            out_eexec_char(eencrypt(*p++));
    }
    else 
        while (p < t1_line_ptr)
            t1_putchar(*p++);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void t1_puts ( const char *  s) [static]

Definition at line 588 of file writet1.c.

{
    if (s != t1_line_array)
        strcpy(t1_line_array, s);
    t1_line_ptr = strend(t1_line_array);
    t1_putline();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void t1_read_subrs ( void  ) [static]

Definition at line 1455 of file writet1.c.

{
    int i, s;
    cs_entry *ptr;
    t1_getline();
    while (!(t1_charstrings() || t1_subrs())) {
        t1_scan_param(); 
        t1_putline();
        t1_getline();
    }
found:
    t1_cs = true;
    t1_scan = false;
    if (!t1_subrs())
       return;
    subr_size_pos = strlen("/Subrs") + 1; 
    /* subr_size_pos points to the number indicating dict size after "/Subrs" */
    subr_size = t1_scan_num(t1_line_array + subr_size_pos, 0);
    if (subr_size == 0) {
        while (!t1_charstrings())
            t1_getline();
        return;
    }
    subr_tab = xtalloc(subr_size, cs_entry);
    for (ptr = subr_tab; ptr - subr_tab < subr_size; ptr++)
        init_cs_entry(ptr);
    subr_array_start = xstrdup(t1_line_array);
    t1_getline();
    while (t1_cslen) {
        store_subr();
        t1_getline();
    }
    /* mark the first four entries without parsing */
    for (i = 0; i < subr_size && i < 4; i++)
        subr_tab[i].used = true;
    /* the end of the Subrs array might have more than one line so we need to
       concatnate them to subr_array_end. Unfortunately some fonts don't have
       the Subrs array followed by the CharStrings dict immediately (synthetic
       fonts). If we cannot find CharStrings in next POST_SUBRS_SCAN lines then
       we will treat the font as synthetic and ignore everything until next
       Subrs is found
     */
#define POST_SUBRS_SCAN     5
    s = 0;
    *t1_buf_array = 0;
    for (i = 0; i < POST_SUBRS_SCAN; i++) {
        if (t1_charstrings())
               break;
        s += t1_line_ptr - t1_line_array;
        alloc_array(t1_buf, s, T1_BUF_SIZE);
        strcat(t1_buf_array, t1_line_array);
        t1_getline();
    }
    subr_array_end = xstrdup(t1_buf_array);
    if (i == POST_SUBRS_SCAN) { /* CharStrings not found; 
                                   suppose synthetic font */
        for (ptr = subr_tab; ptr - subr_tab < subr_size; ptr++)
            if (ptr->valid)
                xfree(ptr->data);
        xfree(subr_tab);
        xfree(subr_array_start);
        xfree(subr_array_end);
        cs_init();
        t1_cs = false;
        t1_synthetic = true;
        while (!(t1_charstrings() || t1_subrs()))
            t1_getline();
        goto found;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static float t1_scan_num ( char *  p,
char **  r 
) [static]

Definition at line 490 of file writet1.c.

{
    float f;
    skip(p, ' ');
    if (sscanf(p, "%g", &f) != 1) {
        remove_eol(p, t1_line_array);
        pdftex_fail("a number expected: `%s'", t1_line_array);
    }
    if (r != NULL) {
        for (; isdigit(*p) || *p == '.' || 
               *p == 'e' || *p == 'E' || *p == '+' || *p == '-'; p++);
        *r = p;
    }
    return f;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void t1_scan_param ( void  ) [static]

Definition at line 849 of file writet1.c.

{
    static const char *lenIV = "/lenIV";
    if (!t1_scan || *t1_line_array != '/')
        return;
    if (t1_prefix(lenIV)) {
        t1_lenIV = t1_scan_num(t1_line_array + strlen(lenIV), 0);
        return;
    }
    t1_scan_keys();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void t1_start_eexec ( void  ) [static]

Definition at line 644 of file writet1.c.

{
    int i;
    if (is_included(fm_cur)) {
        get_length1();
        save_offset();
    }
    if (!t1_pfa)
        t1_check_block_len(false);
    for (t1_line_ptr = t1_line_array, i = 0; i < 4; i++) {
        edecrypt(t1_getbyte());
        *t1_line_ptr++ = 0;
    }
    t1_eexec_encrypt = true;
    if (is_included(fm_cur))
        t1_putline(); /* to put the first four bytes */
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void t1_stop_eexec ( void  ) [static]

Definition at line 662 of file writet1.c.

{
    int c;
    if (is_included(fm_cur)) {
        get_length2();
        save_offset();
    }
    end_last_eexec_line();
    if (!t1_pfa)
        t1_check_block_len(true);
    else {
        c = edecrypt(t1_getbyte());
        if (!(c == 10 || c == 13)) {
            if (last_hexbyte == 0)
                t1_puts("00");
            else
                pdftex_warn("unexpected data after eexec");
        }
    }
    t1_cs = false;
    t1_in_eexec = 2;
}

Here is the call graph for this function:

Here is the caller graph for this function:

boolean t1_subset ( char *  fontfile,
char *  encfile,
unsigned char *  g 
)

Definition at line 1762 of file writet1.c.

{
    int i;
    cur_enc_name = encfile;
    for (i = 0; i <= MAX_CHAR_CODE; i++)
        ext_glyph_names[i] = (char*) notdef;
    if (cur_enc_name != NULL)
        load_enc(cur_enc_name, ext_glyph_names);
    grid = g;
    cur_file_name = fontfile;
    hexline_length = 0;
    writet1();
    for (i = 0; i <= MAX_CHAR_CODE; i++)
        if (ext_glyph_names[i] != notdef)
            free(ext_glyph_names[i]);
    return 1 ; /* note:  there *is* no unsuccessful return */
}

Here is the call graph for this function:

boolean t1_subset_2 ( char *  fontfile,
unsigned char *  g,
char *  extraGlyphs 
)

Definition at line 1780 of file writet1.c.

{
    int i;
    for (i = 0; i <= MAX_CHAR_CODE; i++)
        ext_glyph_names[i] = (char*) notdef;
    grid = g;
    cur_file_name = fontfile;
    hexline_length = 0;
    dvips_extra_charset = extraGlyphs ;
    writet1();
    for (i = 0; i <= MAX_CHAR_CODE; i++)
        if (ext_glyph_names[i] != notdef)
            free(ext_glyph_names[i]);
    return 1 ; /* note:  there *is* no unsuccessful return */
}

Here is the call graph for this function:

static void t1_subset_ascii_part ( void  ) [static]

Definition at line 1381 of file writet1.c.

{
    int i, j;
    save_offset();
    t1_getline();
    while (!t1_prefix("/Encoding")) {
        t1_scan_param();
        t1_putline();
        t1_getline();
    }
    t1_builtin_enc(); 
    if (is_reencoded(fm_cur))
        t1_glyph_names = external_enc();
    else {
        t1_glyph_names = t1_builtin_glyph_names;
        update_builtin_enc(tex_font, t1_glyph_names); 
    }
    if (is_included(fm_cur) && is_subsetted(fm_cur)) {
        make_subset_tag(fm_cur, t1_glyph_names);
        update_subset_tag();
    }
    if (pdfmovechars == 0 && t1_encoding == ENC_STANDARD)
        t1_puts("/Encoding StandardEncoding def\n");
    else {
        t1_puts("/Encoding 256 array\n0 1 255 {1 index exch /.notdef put} for\n");
        for (i = 0, j = 0; i <= MAX_CHAR_CODE; i++) {
            if (is_used_char(i) && t1_glyph_names[i] != notdef) {
                j++;
                t1_printf("dup %i /%s put\n", (int)t1_char(i), t1_glyph_names[i]);
            }
        }
        /* We didn't mark anything for the Encoding array. */
        /* We add "dup 0 /.notdef put" for compatibility   */
        /* with Acrobat 5.0.                               */
        if (j == 0)
            t1_puts("dup 0 /.notdef put\n");
        t1_puts("readonly def\n");
    }
    do {
        t1_getline();
        t1_scan_param();
        if (!t1_prefix("/UniqueID")) /* ignore UniqueID for subsetted fonts */
            t1_putline();
    } while (t1_in_eexec == 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void t1_subset_charstrings ( void  ) [static]

Definition at line 1660 of file writet1.c.

{
    cs_entry *ptr;
    cs_size_pos = strstr(t1_line_array, charstringname) + strlen(charstringname)
                  - t1_line_array + 1; 
    /* cs_size_pos points to the number indicating
       dict size after "/CharStrings" */
    cs_size = t1_scan_num(t1_line_array + cs_size_pos, 0);
    cs_ptr = cs_tab = xtalloc(cs_size, cs_entry);
    for (ptr = cs_tab; ptr - cs_tab < cs_size; ptr++)
        init_cs_entry(ptr);
    cs_notdef = NULL;
    cs_dict_start = xstrdup(t1_line_array);
    t1_getline();
    while (t1_cslen) {
        store_cs();
        t1_getline();
    }
    cs_dict_end = xstrdup(t1_line_array);
    t1_mark_glyphs();
    if (subr_tab != NULL) {
        if (cs_token_pair == NULL)
            pdftex_fail("This Type 1 font uses mismatched subroutine begin/end token pairs.");
        t1_subr_flush();
    }
    for (cs_count = 0, ptr = cs_tab; ptr < cs_ptr; ptr++)
        if (ptr->used)
            cs_count++;
    t1_cs_flush();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void t1_subset_end ( void  ) [static]

Definition at line 1691 of file writet1.c.

{
    if (t1_synthetic) { /* copy to "dup /FontName get exch definefont pop" */
        while (!strstr(t1_line_array, "definefont")) {
            t1_getline();
            t1_putline();
        }
        while (!t1_end_eexec())
            t1_getline();   /* ignore the rest */
        t1_putline();       /* write "mark currentfile closefile" */
    }
    else while (!t1_end_eexec()) { /* copy to "mark currentfile closefile" */
        t1_getline();
        t1_putline();
    }
    t1_stop_eexec();
    while (!t1_cleartomark()) {
        t1_getline();
        t1_putline();
    }
    if (!t1_synthetic)  /* don't check "{restore}if" for synthetic fonts */
        t1_check_end(); /* write "{restore}if" if found */
    get_length3();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void writet1 ( void  )

Definition at line 1716 of file writet1.c.

{
    read_encoding_only = false;
#ifdef pdfTeX
    if (strcasecmp(strend(fm_fontfile(fm_cur)) - 4, ".otf") == 0) {
        if (!is_included(fm_cur) || is_subsetted(fm_cur))
            pdftex_fail("OTF fonts must be included entirely");
        writeotf();
        is_otf_font = true;
        return;
    }
#endif
    if (!is_included(fm_cur)) { /* scan parameters from font file */
        if (!t1_open_fontfile("{"))
            return;
        t1_scan_only();
        t1_close_font_file("}");
        return;
    }
    if (!is_subsetted(fm_cur)) { /* include entire font */
        if (!t1_open_fontfile("<<"))
            return;
        t1_include();
        t1_close_font_file(">>");
        return;
    } 
    /* partial downloading */
    if (!t1_open_fontfile("<"))
        return;
    t1_subset_ascii_part();
    t1_start_eexec();
    cc_init();
    cs_init();
    t1_read_subrs();
    t1_subset_charstrings();
    t1_subset_end();
    t1_close_font_file(">");
}

Here is the call graph for this function:


Variable Documentation

Definition at line 93 of file dvips.c.

Definition at line 1143 of file writet1.c.

cc_entry cc_tab[CS_MAX] [static]

Definition at line 1144 of file writet1.c.

char charstringname[] = "/CharStrings" [static]

Definition at line 169 of file writet1.c.

int cs_count [static]

Definition at line 249 of file writet1.c.

char * cs_dict_end [static]

Definition at line 248 of file writet1.c.

char* cs_dict_start [static]

Definition at line 248 of file writet1.c.

cs_entry * cs_notdef [static]

Definition at line 247 of file writet1.c.

cs_entry * cs_ptr [static]

Definition at line 247 of file writet1.c.

int cs_size [static]

Definition at line 249 of file writet1.c.

int cs_size_pos [static]

Definition at line 249 of file writet1.c.

int cs_start [static]

Definition at line 245 of file writet1.c.

cs_entry* cs_tab [static]

Definition at line 247 of file writet1.c.

const char** cs_token_pair [static]

Definition at line 264 of file writet1.c.

const char* cs_token_pairs_list[][2] [static]
Initial value:
 {
  {" RD", "NP"},
  {" -|", "|"},
  {" RD", "noaccess put"},
  {" -|", "noaccess put"},
  {NULL, NULL}
}

Definition at line 257 of file writet1.c.

char* cur_enc_name [static]

Definition at line 112 of file writet1.c.

char* cur_file_name [static]

Definition at line 111 of file writet1.c.

char* dvips_extra_charset [static]

Definition at line 108 of file writet1.c.

FILE* enc_file [static]

Definition at line 271 of file writet1.c.

char enc_line[ENC_BUF_SIZE] [static]

Definition at line 235 of file writet1.c.

char* ext_glyph_names[MAX_CHAR_CODE+1] [static]

Definition at line 114 of file writet1.c.

unsigned char* grid [static]

Definition at line 113 of file writet1.c.

int hexline_length [static]

Definition at line 116 of file writet1.c.

boolean is_cc_init = false [static]

Definition at line 1145 of file writet1.c.

int last_hexbyte [static]

Definition at line 269 of file writet1.c.

Definition at line 118 of file writet1.c.

char notdef[] = ".notdef" [static]

Definition at line 117 of file writet1.c.

const char perforce_id[] = "$Id: //depot/Build/source.development/TeX/texk/web2c/pdftexdir/writet1.c#23 $" [static]

Definition at line 23 of file writet1.c.

char print_buf[PRINTF_BUF_SIZE] [static]

Definition at line 115 of file writet1.c.

Definition at line 173 of file writet1.c.

integer * stack_ptr = cc_stack [static]

Definition at line 1143 of file writet1.c.

Definition at line 135 of file writet1.c.

char * subr_array_end [static]

Definition at line 252 of file writet1.c.

char* subr_array_start [static]

Definition at line 252 of file writet1.c.

int subr_max [static]

Definition at line 253 of file writet1.c.

int subr_size [static]

Definition at line 253 of file writet1.c.

int subr_size_pos [static]

Definition at line 253 of file writet1.c.

cs_entry* subr_tab [static]

Definition at line 251 of file writet1.c.

long t1_block_length [static]

Definition at line 268 of file writet1.c.

Definition at line 172 of file writet1.c.

const unsigned short t1_c1 = 52845 [static]

Definition at line 232 of file writet1.c.

const unsigned short t1_c2 = 22719 [static]

Definition at line 232 of file writet1.c.

boolean t1_cs [static]

Definition at line 266 of file writet1.c.

unsigned short t1_cslen [static]

Definition at line 233 of file writet1.c.

unsigned short t1_dr [static]

Definition at line 231 of file writet1.c.

Definition at line 266 of file writet1.c.

int t1_encoding [static]

Definition at line 174 of file writet1.c.

unsigned short t1_er [static]

Definition at line 231 of file writet1.c.

FILE* t1_file [static]

Definition at line 270 of file writet1.c.

Definition at line 171 of file writet1.c.

int t1_in_eexec [static]

Definition at line 267 of file writet1.c.

short t1_lenIV [static]

Definition at line 234 of file writet1.c.

boolean t1_pfa [static]

Definition at line 266 of file writet1.c.

boolean t1_scan [static]

Definition at line 266 of file writet1.c.

Definition at line 266 of file writet1.c.