Back to index

texmacs  1.0.7.15
Functions
t1_load.h File Reference
#include "cff.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

cff_fontt1_load_font (char **enc_vec, int mode, FILE *fp)
int is_pfb (FILE *fp)
int t1_get_fontname (FILE *fp, char *fontname)
char * t1_get_standard_glyph (int code)

Function Documentation

int is_pfb ( FILE *  fp)

Definition at line 977 of file t1_load.c.

{
  char sig[15];
  int i, ch;

  rewind(fp);
  if ((ch = fgetc(fp)) != 128 ||
      (ch = fgetc (fp)) < 0 || ch > 3) {
    return 0;
  }
  for (i = 0; i < 4; i++) {
    if ((ch = fgetc(fp)) < 0) {
      return 0;
    }
  }
  for (i = 0; i < 14; i++) {
    if ((ch = fgetc(fp)) < 0) {
      return 0;
    }
    sig[i] = (char) ch;
  }
  if (!memcmp(sig, "%!PS-AdobeFont", 14) ||
      !memcmp(sig, "%!FontType1", 11)) {
    return 1;
  } else if (!memcmp(sig, "%!PS", 4)) {
    sig[14] = '\0';
    WARN("Ambiguous PostScript resource type: %s", sig);
    return 1;
  } else {
    WARN("Not a PFB font file?");
    return 0;
  }

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int t1_get_fontname ( FILE *  fp,
char *  fontname 
)

Definition at line 1086 of file t1_load.c.

{
  unsigned char *buffer, *start, *end;
  long  length;
  char *key;
  int   fn_found = 0;

  rewind(fp);
  buffer = get_pfb_segment(fp, PFB_SEG_TYPE_ASCII, &length);
  if (buffer == NULL || length == 0)
    ERROR("Reading PFB (ASCII part) file failed.");
  start = buffer;
  end   = buffer + length;

  if (seek_operator(&start, end, "begin") < 0) {
    RELEASE(buffer);
    return -1;
  }

  while (!fn_found && start < end &&
        (key = get_next_key(&start, end)) != NULL) {
    if (!strcmp(key, "FontName")) {
      char *strval;
      if (parse_svalue(&start, end, &strval) == 1) {
       if (strlen(strval) > TYPE1_NAME_LEN_MAX) {
         WARN("FontName \"%s\" too long. (%d bytes)", strval, strlen(strval));
         strval[TYPE1_NAME_LEN_MAX] = '\0';
       }
       strcpy(fontname, strval);
       RELEASE(strval);
       fn_found = 1;
      }
    }
    RELEASE(key);
  }
  RELEASE(buffer);

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* t1_get_standard_glyph ( int  code)

Definition at line 1077 of file t1_load.c.

{
  if (!StandardEncoding[code])
    return NULL;

  return (char *) StandardEncoding[code];
}

Here is the caller graph for this function:

cff_font* t1_load_font ( char **  enc_vec,
int  mode,
FILE *  fp 
)

Definition at line 1161 of file t1_load.c.

{
  long length;
  cff_font *cff;
  unsigned char *buffer, *start, *end;

  rewind(fp);
  /* ASCII section */
  buffer = get_pfb_segment(fp, PFB_SEG_TYPE_ASCII, &length);
  if (buffer == NULL || length == 0) {
    ERROR("Reading PFB (ASCII part) file failed.");
    return NULL;
  }

  cff = NEW(1, cff_font);
  init_cff_font(cff);

  start = buffer; end = buffer + length;
  if (parse_part1(cff, enc_vec, &start, end, mode) < 0) {
    cff_close(cff);
    RELEASE(buffer);
    ERROR("Reading PFB (ASCII part) file failed.");
    return NULL;
  }
  RELEASE(buffer);

  /* Binary section */
  buffer = get_pfb_segment(fp, PFB_SEG_TYPE_BINARY, &length);
  if (buffer == NULL || length == 0) {
    cff_close(cff);
    RELEASE(buffer);
    ERROR("Reading PFB (BINARY part) file failed.");
    return NULL;
  } else {
    t1_decrypt(T1_EEKEY, buffer, buffer, 0, length);
  }
  start = buffer + 4; end = buffer + length;
  if (parse_part2(cff, &start, end, mode) < 0) {
    cff_close(cff);
    RELEASE(buffer);
    ERROR("Reading PFB (BINARY part) file failed.");
    return NULL;
  }
  RELEASE(buffer);

  cff_update_string(cff);

  /* Remaining section ignored. */

  return cff;
}

Here is the call graph for this function:

Here is the caller graph for this function: