Back to index

tetex-bin  3.0
Classes | Typedefs | Functions | Variables
writeenc.c File Reference
#include "ptexlib.h"
#include "avlstuff.h"

Go to the source code of this file.

Classes

struct  encstruct_

Typedefs

typedef struct encstruct_ encstruct

Functions

void read_enc (enc_entry *e)
void write_enc (char **glyph_names, enc_entry *e, integer eobjnum)
static int comp_enc_entry (const void *pa, const void *pb, void *p)
enc_entryadd_enc (char *s)
boolean get_enc (fm_entry *fm)
void setcharmap (internalfontnumber f)
void enc_free ()

Variables

static const char perforce_id [] = "$Id: //depot/Build/source.development/TeX/texk/web2c/pdftexdir/writeenc.c#10 $"
static encstructepstart = NULL
struct avl_tableenc_tree = NULL

Class Documentation

struct encstruct_

Definition at line 85 of file writeenc.c.

Collaboration diagram for encstruct_:
Class Members
enc_entry entry
struct encstruct_ * next

Typedef Documentation

typedef struct encstruct_ encstruct

Function Documentation

enc_entry* add_enc ( char *  s)

Definition at line 104 of file writeenc.c.

{                           /* built-in encodings have s == NULL */
    int i;
    enc_entry *enc_ptr, etmp;
    static encstruct *ep;   /* pointer into linked list of encodings */
    void **aa;

    if (enc_tree == NULL) {
       enc_tree = avl_create(comp_enc_entry, NULL, &avl_xallocator);
       assert(enc_tree != NULL);
    }
    if (s != NULL) {
       etmp.name = s;
       enc_ptr = (enc_entry *) avl_find(enc_tree, &etmp);
       if (enc_ptr != NULL) /* encoding already registered */
           return enc_ptr;
    }
    if (epstart == NULL) {
       epstart = xtalloc(1, encstruct);
       ep = epstart;
    } else {
       ep->next = xtalloc(1, encstruct);
       ep = ep->next;
    }
    ep->next = NULL;
    enc_ptr = &(ep->entry);
    if (s != NULL) {
       enc_ptr->name = xstrdup(s);
       aa = avl_probe(enc_tree, enc_ptr);
       assert(aa != NULL);
    } else
       enc_ptr->name = NULL;
    enc_ptr->loaded = false;
    enc_ptr->updated = false;
    enc_ptr->firstfont = getnullfont();
    enc_ptr->objnum = 0;
    enc_ptr->glyph_names = xtalloc(MAX_CHAR_CODE + 1, char *);
    for (i = 0; i <= MAX_CHAR_CODE; i++)
       enc_ptr->glyph_names[i] = (char *) notdef;

    return enc_ptr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int comp_enc_entry ( const void pa,
const void pb,
void p 
) [static]

Definition at line 98 of file writeenc.c.

{
    return strcmp(((const enc_entry *) pa)->name,
                ((const enc_entry *) pb)->name);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 227 of file writeenc.c.

{
    int k;
    encstruct *p, *pn;
    enc_entry *e;

    for (p = epstart; p != NULL; p = pn) {
       e = &(p->entry);
       pn = p->next;
       xfree(e->name);
       if (e->loaded)              /* encoding has been loaded */
           for (k = 0; k <= MAX_CHAR_CODE; k++)
              if (e->glyph_names[k] != notdef)
                  xfree(e->glyph_names[k]);
       xfree(e->glyph_names);
       xfree(p);
    }
    if (enc_tree != NULL)
       avl_destroy(enc_tree, NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 154 of file writeenc.c.

{
    int i;
    char **glyph_names;
    if (is_reencoded(fm)) { /* external encoding vector available */
        read_enc(fm->encoding);
        return true;
    }
    if (!is_t1fontfile(fm)) /* get built-in encoding for T1 fonts only */
        return false;
    if (t1_read_enc(fm)) { /* encoding read into t1_builtin_glyph_names */
        fm->encoding = add_enc(NULL);
        glyph_names = (fm->encoding)->glyph_names;
        for (i = 0; i <= MAX_CHAR_CODE; i++)
            glyph_names[i] = t1_builtin_glyph_names[i];
        (fm->encoding)->loaded = true;
        return true;
    }
    return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 29 of file writeenc.c.

{
    assert(e != NULL);
    if (e->loaded)
        return;
    load_enc(e->name, e->glyph_names);
    e->loaded = true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void setcharmap ( internalfontnumber  f)

Definition at line 187 of file writeenc.c.

{
    fm_entry *fm;
    enc_entry *e;
    char **glyph_names;
    int i, k;
    if (pdfmovechars == 0 || fontbc[f] > 32 || !hasfmentry(f))
        return;
    if (fontec[f] < 128) {
        for (i = fontbc[f]; i <= 32; i++)
            pdfcharmap[f][i] = i + MOVE_CHARS_OFFSET;
        return;
    }
    fm = (fm_entry *) pdffontmap[f];
    if (pdfmovechars == 1 || !get_enc(fm))
        return;
    e = fm->encoding;
    if (e->firstfont != getnullfont()) {
        for (i = fontbc[f]; i <= 32; i++)
            pdfcharmap[f][i] = pdfcharmap[e->firstfont][i];
        return;
    }
    e->firstfont = f;
    glyph_names = e->glyph_names;
    for (i = 32, k = MAX_CHAR_CODE; i >= fontbc[f] && k > 127; i--) {
        if (glyph_names[i] == notdef)
            continue;
        while (glyph_names[k] != notdef && k > 127)
            k--;
        if (k < 128)
            return;
        glyph_names[k] = glyph_names[i];
        glyph_names[i] = (char*) notdef;
        pdfcharmap[f][i] = k;
    }
}

Here is the call graph for this function:

void write_enc ( char **  glyph_names,
enc_entry e,
integer  eobjnum 
)

Definition at line 43 of file writeenc.c.

{
    boolean is_notdef;
    int i;
    char **g;
    if (glyph_names == NULL) {
        assert(e != NULL);
        if (e->objnum != 0) /* the encoding has been written already */
            return;
        pdfnewdict(0, 0);
        e->objnum = objptr;
        g = e->glyph_names;
    }
    else {
        pdfbegindict(eobjnum);
        g = glyph_names;
    }
    pdf_printf("/Type /Encoding\n/Differences [ 0 /%s", g[0]);
    is_notdef = (g[0] == notdef);
    for (i = 1; i <= MAX_CHAR_CODE; i++) {
        if (g[i] == notdef) {
            if (!is_notdef) {
                pdf_printf(" %i/%s", i, notdef);
                is_notdef = true;
            }
        }
        else {
            if (is_notdef) {
                pdf_printf(" %i", i);
                is_notdef = false;
            }
            pdf_printf("/%s", g[i]);
        }
    }
    pdf_puts("]\n");
    pdfenddict();
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

struct avl_table* enc_tree = NULL

Definition at line 94 of file writeenc.c.

encstruct* epstart = NULL [static]

Definition at line 90 of file writeenc.c.

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

Definition at line 26 of file writeenc.c.