Back to index

texmacs  1.0.7.15
Classes | Defines | Typedefs | Functions
fontmap.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  fontmap_opt
struct  fontmap_rec
struct  fontmap_rec.charmap

Defines

#define FONTMAP_RMODE_REPLACE   0
#define FONTMAP_RMODE_APPEND   '+'
#define FONTMAP_RMODE_REMOVE   '-'
#define FONTMAP_OPT_NOEMBED   (1 << 1)
#define FONTMAP_OPT_VERT   (1 << 2)
#define FONTMAP_STYLE_NONE   0
#define FONTMAP_STYLE_BOLD   1
#define FONTMAP_STYLE_ITALIC   2
#define FONTMAP_STYLE_BOLDITALIC   3

Typedefs

typedef struct fontmap_opt fontmap_opt
typedef struct fontmap_rec fontmap_rec

Functions

void pdf_fontmap_set_verbose (void)
void pdf_init_fontmaps (void)
void pdf_close_fontmaps (void)
void pdf_init_fontmap_record (fontmap_rec *mrec)
void pdf_clear_fontmap_record (fontmap_rec *mrec)
int pdf_load_fontmap_file (const char *filename, int mode)
int pdf_read_fontmap_line (fontmap_rec *mrec, const char *mline, long mline_strlen, int format)
int pdf_append_fontmap_record (const char *kp, const fontmap_rec *mrec)
int pdf_remove_fontmap_record (const char *kp)
int pdf_insert_fontmap_record (const char *kp, const fontmap_rec *mrec)
fontmap_recpdf_lookup_fontmap_record (const char *kp)
int is_pdfm_mapline (const char *mline)

Class Documentation

struct fontmap_opt

Definition at line 41 of file fontmap.h.

Class Members
double bold
char * charcoll
double design_size
double extend
long flags
int index
long mapc
char * otl_tags
double slant
int stemv
int style
char * tounicode
struct fontmap_rec

Definition at line 58 of file fontmap.h.

Collaboration diagram for fontmap_rec:
Class Members
struct fontmap_rec charmap
char * enc_name
char * font_name
char * map_name
fontmap_opt opt
struct fontmap_rec.charmap

Definition at line 67 of file fontmap.h.

Class Members
char * sfd_name
char * subfont_id

Define Documentation

#define FONTMAP_OPT_NOEMBED   (1 << 1)

Definition at line 32 of file fontmap.h.

#define FONTMAP_OPT_VERT   (1 << 2)

Definition at line 33 of file fontmap.h.

#define FONTMAP_RMODE_APPEND   '+'

Definition at line 29 of file fontmap.h.

#define FONTMAP_RMODE_REMOVE   '-'

Definition at line 30 of file fontmap.h.

#define FONTMAP_RMODE_REPLACE   0

Definition at line 28 of file fontmap.h.

#define FONTMAP_STYLE_BOLD   1

Definition at line 36 of file fontmap.h.

#define FONTMAP_STYLE_BOLDITALIC   3

Definition at line 38 of file fontmap.h.

#define FONTMAP_STYLE_ITALIC   2

Definition at line 37 of file fontmap.h.

#define FONTMAP_STYLE_NONE   0

Definition at line 35 of file fontmap.h.


Typedef Documentation

typedef struct fontmap_opt fontmap_opt
typedef struct fontmap_rec fontmap_rec

Function Documentation

int is_pdfm_mapline ( const char *  mline)

Definition at line 924 of file fontmap.c.

{
  int   n = 0;
  char *p, *endptr;

  if (strchr(mline, '"') || strchr(mline, '<'))
    return -1; /* DVIPS/pdfTeX format */

  p      = (char *) mline;
  endptr = p + strlen(mline);

  skip_blank(&p, endptr);

  while (p < endptr) {
    /* Break if '-' preceeded by blanks is found. (DVIPDFM format) */
    if (*p == '-') return 1;
    for (n++; p < endptr && !ISBLANK(*p); p++);
    skip_blank(&p, endptr);
  }

  /* Two entries: TFM_NAME PS_NAME only (DVIPS format)
   * Otherwise (DVIPDFM format) */
  return (n == 2 ? 0 : 1);
}
int pdf_append_fontmap_record ( const char *  kp,
const fontmap_rec mrec 
)

Definition at line 710 of file fontmap.c.

{
  fontmap_rec *mrec;
  char        *fnt_name, *sfd_name = NULL;

  if (!kp || fontmap_invalid(vp)) {
    WARN("Invalid fontmap record...");
    return -1;
  }

  if (verbose > 3)
    MESG("fontmap>> append key=\"%s\"...", kp);

  fnt_name = chop_sfd_name(kp, &sfd_name);
  if (fnt_name && sfd_name) {
    char  *tfm_name;
    char **subfont_ids;
    int    n = 0;
    subfont_ids = sfd_get_subfont_ids(sfd_name, &n);
    if (!subfont_ids)
      return  -1;
    while (n-- > 0) {
      tfm_name = make_subfont_name(kp, sfd_name, subfont_ids[n]);
      if (!tfm_name)
        continue;
      mrec = ht_lookup_table(fontmap, tfm_name, strlen(tfm_name));
      if (!mrec) {
        mrec = NEW(1, fontmap_rec);
        pdf_init_fontmap_record(mrec);
        mrec->map_name = mstrdup(kp); /* link */
        mrec->charmap.sfd_name   = mstrdup(sfd_name);
        mrec->charmap.subfont_id = mstrdup(subfont_ids[n]);
        ht_insert_table(fontmap, tfm_name, strlen(tfm_name), mrec);
      }
      RELEASE(tfm_name);
    }
    RELEASE(fnt_name);
    RELEASE(sfd_name);
  }

  mrec = ht_lookup_table(fontmap, kp, strlen(kp));
  if (!mrec) {
    mrec = NEW(1, fontmap_rec);
    pdf_copy_fontmap_record(mrec, vp);
    if (mrec->map_name && !strcmp(kp, mrec->map_name)) {
      RELEASE(mrec->map_name);
      mrec->map_name = NULL;
    }
    ht_insert_table(fontmap, kp, strlen(kp), mrec);
  }
  if (verbose > 3)
    MESG("\n");

  return  0;
}

Definition at line 84 of file fontmap.c.

{
  ASSERT(mrec);

  if (mrec->map_name)
    RELEASE(mrec->map_name);
  if (mrec->charmap.sfd_name)
    RELEASE(mrec->charmap.sfd_name);
  if (mrec->charmap.subfont_id)
    RELEASE(mrec->charmap.subfont_id);
  if (mrec->enc_name)
    RELEASE(mrec->enc_name);
  if (mrec->font_name)
    RELEASE(mrec->font_name);

  if (mrec->opt.tounicode)
    RELEASE(mrec->opt.tounicode);
  if (mrec->opt.otl_tags)
    RELEASE(mrec->opt.otl_tags);
  if (mrec->opt.charcoll)
    RELEASE(mrec->opt.charcoll);
  pdf_init_fontmap_record(mrec);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pdf_close_fontmaps ( void  )

Definition at line 1103 of file fontmap.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void pdf_fontmap_set_verbose ( void  )

Definition at line 45 of file fontmap.c.

{
  verbose++;
}

Definition at line 52 of file fontmap.c.

{
  ASSERT(mrec);

  mrec->map_name   = NULL;

  /* SFD char mapping */
  mrec->charmap.sfd_name   = NULL;
  mrec->charmap.subfont_id = NULL;
  /* for OFM */
  mrec->opt.mapc   = -1; /* compatibility */

  mrec->font_name  = NULL;
  mrec->enc_name   = NULL;

  mrec->opt.slant  = 0.0;
  mrec->opt.extend = 1.0;
  mrec->opt.bold   = 0.0;

  mrec->opt.flags  = 0;

  mrec->opt.design_size = -1.0;

  mrec->opt.tounicode = NULL;
  mrec->opt.otl_tags  = NULL; /* deactivated */
  mrec->opt.index     = 0;
  mrec->opt.charcoll  = NULL;
  mrec->opt.style     = FONTMAP_STYLE_NONE;
  mrec->opt.stemv     = -1; /* not given explicitly by an option */
}

Here is the caller graph for this function:

void pdf_init_fontmaps ( void  )

Definition at line 1096 of file fontmap.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int pdf_insert_fontmap_record ( const char *  kp,
const fontmap_rec mrec 
)

Definition at line 809 of file fontmap.c.

{
  fontmap_rec *mrec;
  char        *fnt_name, *sfd_name;

  if (!kp || fontmap_invalid(vp)) {
    WARN("Invalid fontmap record...");
    return -1;
  }

  if (verbose > 3)
    MESG("fontmap>> insert key=\"%s\"...", kp);

  fnt_name = chop_sfd_name(kp, &sfd_name);
  if (fnt_name && sfd_name) {
    char  *tfm_name;
    char **subfont_ids;
    int    n = 0;
    subfont_ids = sfd_get_subfont_ids(sfd_name, &n);
    if (!subfont_ids) {
      RELEASE(fnt_name);
      RELEASE(sfd_name);
      return  -1;
    }
    if (verbose > 3)
      MESG("\nfontmap>> Expand @%s@:", sfd_name);
    while (n-- > 0) {
      tfm_name = make_subfont_name(kp, sfd_name, subfont_ids[n]);
      if (!tfm_name)
        continue;
      if (verbose > 3)
        MESG(" %s", tfm_name);
      mrec = NEW(1, fontmap_rec);
      pdf_init_fontmap_record(mrec);
      mrec->map_name = mstrdup(kp); /* link to this entry */
      mrec->charmap.sfd_name   = mstrdup(sfd_name);
      mrec->charmap.subfont_id = mstrdup(subfont_ids[n]);
      ht_insert_table(fontmap, tfm_name, strlen(tfm_name), mrec);
      RELEASE(tfm_name);
    }
    RELEASE(fnt_name);
    RELEASE(sfd_name);
  }

  mrec = NEW(1, fontmap_rec);
  pdf_copy_fontmap_record(mrec, vp);
  if (mrec->map_name && !strcmp(kp, mrec->map_name)) {
    RELEASE(mrec->map_name);
    mrec->map_name = NULL;
  }
  ht_insert_table(fontmap, kp, strlen(kp), mrec);

  if (verbose > 3)
    MESG("\n");

  return  0;
}
int pdf_load_fontmap_file ( const char *  filename,
int  mode 
)

Definition at line 950 of file fontmap.c.

{
  fontmap_rec *mrec;
  FILE        *fp;
  char        *p = NULL, *endptr;
  long         llen, lpos  = 0;
  int          error = 0, format = 0;

  ASSERT(filename);
  ASSERT(fontmap) ;

  if (verbose)
    MESG("<FONTMAP:%s", filename);

  fp = DPXFOPEN(filename, DPX_RES_TYPE_FONTMAP);
  if (!fp) {
    WARN("Couldn't open font map file \"%s\".", filename);
    return  -1;
  }

  while (!error &&
         (p = readline(work_buffer, WORK_BUFFER_SIZE, fp)) != NULL) {
    int m;

    lpos++;
    llen   = strlen(work_buffer);
    endptr = p + llen;

    skip_blank(&p, endptr);
    if (p == endptr)
      continue;

    m = is_pdfm_mapline(p);

    if (format * m < 0) { /* mismatch */
      WARN("Found a mismatched fontmap line %d from %s.", lpos, filename);
      WARN("-- Ignore the current input buffer: %s", p);
      continue;
    } else
      format += m;

    mrec  = NEW(1, fontmap_rec);
    pdf_init_fontmap_record(mrec);

    /* format > 0: DVIPDFM, format <= 0: DVIPS/pdfTeX */
    error = pdf_read_fontmap_line(mrec, p, llen, format);
    if (error) {
      WARN("Invalid map record in fontmap line %d from %s.", lpos, filename);
      WARN("-- Ignore the current input buffer: %s", p);
      pdf_clear_fontmap_record(mrec);
      RELEASE(mrec);
      continue;
    } else {
      switch (mode) {
      case FONTMAP_RMODE_REPLACE:
        pdf_insert_fontmap_record(mrec->map_name, mrec);
        break;
      case FONTMAP_RMODE_APPEND:
        pdf_append_fontmap_record(mrec->map_name, mrec);
        break;
      case FONTMAP_RMODE_REMOVE:
        pdf_remove_fontmap_record(mrec->map_name);
        break;
      }
    }
    pdf_clear_fontmap_record(mrec);
    RELEASE(mrec);
  }
  DPXFCLOSE(fp);

  if (verbose)
    MESG(">");

  return  error;
}
fontmap_rec* pdf_lookup_fontmap_record ( const char *  kp)

Definition at line 1084 of file fontmap.c.

{
  fontmap_rec *mrec = NULL;

  if (fontmap && tfm_name)
    mrec = ht_lookup_table(fontmap, tfm_name, strlen(tfm_name));

  return  mrec;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pdf_read_fontmap_line ( fontmap_rec mrec,
const char *  mline,
long  mline_strlen,
int  format 
)

Definition at line 869 of file fontmap.c.

{
  int    error;
  char  *q, *p, *endptr;

  ASSERT(mrec);

  p      = (char *) mline;
  endptr = p + mline_len;

  skip_blank(&p, endptr);
  if (p >= endptr)
    return -1;

  q = parse_string_value(&p, endptr);
  if (!q)
    return -1;

  if (format > 0) /* DVIPDFM format */
    error = fontmap_parse_mapdef_dpm(mrec, p, endptr);
  else /* DVIPS/pdfTeX format */
    error = fontmap_parse_mapdef_dps(mrec, p, endptr);
  if (!error) {
    char  *fnt_name, *sfd_name = NULL;
    fnt_name = chop_sfd_name(q, &sfd_name);
    if (fnt_name && sfd_name) {
      if (!mrec->font_name) {
      /* In the case of subfonts, the base name (before the character '@')
       * will be used as a font_name by default.
       * Otherwise tex_name will be used as a font_name by default.
       */
        mrec->font_name = fnt_name;
      } else {
        RELEASE(fnt_name);
      }
      if (mrec->charmap.sfd_name)
        RELEASE(mrec->charmap.sfd_name);
      mrec->charmap.sfd_name = sfd_name ;
    }
    fill_in_defaults(mrec, q);
  }
  RELEASE(q);

  return  error;
}
int pdf_remove_fontmap_record ( const char *  kp)

Definition at line 767 of file fontmap.c.

{
  char  *fnt_name, *sfd_name = NULL;

  if (!kp)
    return  -1;

  if (verbose > 3)
    MESG("fontmap>> remove key=\"%s\"...", kp);

  fnt_name = chop_sfd_name(kp, &sfd_name);
  if (fnt_name && sfd_name) {
    char  *tfm_name;
    char **subfont_ids;
    int    n = 0;
    subfont_ids = sfd_get_subfont_ids(sfd_name, &n);
    if (!subfont_ids)
      return  -1;
    if (verbose > 3)
      MESG("\nfontmap>> Expand @%s@:", sfd_name);
    while (n-- > 0) {
      tfm_name = make_subfont_name(kp, sfd_name, subfont_ids[n]);
      if (!tfm_name)
        continue;
      if (verbose > 3)
        MESG(" %s", tfm_name);
      ht_remove_table(fontmap, tfm_name, strlen(tfm_name));
      RELEASE(tfm_name);
    }
    RELEASE(fnt_name);
    RELEASE(sfd_name);
  }

  ht_remove_table(fontmap, kp, strlen(kp));

  if (verbose > 3)
    MESG("\n");

  return  0;
}