Back to index

texmacs  1.0.7.15
Functions
subfont.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void subfont_set_verbose (void)
void release_sfd_record (void)
unsigned short lookup_sfd_record (int rec_id, unsigned char code)
int sfd_load_record (const char *sfd_name, const char *subfont_id)
char ** sfd_get_subfont_ids (const char *sfd_name, int *num_subfonts)

Function Documentation

unsigned short lookup_sfd_record ( int  rec_id,
unsigned char  code 
)

Definition at line 451 of file subfont.c.

{
  if (!sfd_record ||
       rec_id < 0 || rec_id >= num_sfd_records)
    ERROR("Invalid subfont_id: %d", rec_id);
  return sfd_record[rec_id].vector[c];
}
void release_sfd_record ( void  )

Definition at line 460 of file subfont.c.

Here is the call graph for this function:

Here is the caller graph for this function:

char** sfd_get_subfont_ids ( const char *  sfd_name,
int *  num_subfonts 
)

Definition at line 341 of file subfont.c.

{
  int  sfd_id;

  if (!sfd_name)
    return  NULL;

  sfd_id = find_sfd_file(sfd_name);
  if (sfd_id < 0)
    return  NULL;

  if (num_ids)
    *num_ids = sfd_files[sfd_id].num_subfonts;
  return  sfd_files[sfd_id].sub_id;
}

Here is the call graph for this function:

int sfd_load_record ( const char *  sfd_name,
const char *  subfont_id 
)

Definition at line 361 of file subfont.c.

{
  int               rec_id = -1;
  struct sfd_file_ *sfd;
  FILE             *fp;
  int               sfd_id, i, error = 0;
  char             *p, *q;

  if (!sfd_name || !subfont_id)
    return  -1;

  sfd_id = find_sfd_file(sfd_name);
  if (sfd_id < 0)
    return  -1;

  sfd = &sfd_files[sfd_id];
  /* Check if we already loaded mapping table. */
  for (i = 0;
       i < sfd->num_subfonts && strcmp(sfd->sub_id[i], subfont_id); i++);
  if (i == sfd->num_subfonts) {
    WARN("Subfont id=\"%s\" not exist in SFD file \"%s\"...",
         subfont_id, sfd->ident);
    return  -1;
  } else if (sfd->rec_id[i] >= 0) {
    return  sfd->rec_id[i];
  }

  if (verbose > 3) {
    MESG("\nsubfont>> Loading SFD mapping table for <%s,%s>...",
         sfd->ident, subfont_id);
  }

  /* reopen */
  fp = DPXFOPEN(sfd->ident, DPX_RES_TYPE_SFD);
  if (!fp) {
    return  -1;
    /* ERROR("Could not open SFD file \"%s\"", sfd_name); */
  }

  /* Seek to record for 'sub_name'. */
  while ((p = readline(line_buf, LINE_BUF_SIZE, fp))) {
    for ( ; *p && isspace(*p); p++);
    if (*p == 0)
      continue; /* empty line */

    /* q = parse_ident(&p, p + strlen(p)); */
    for (q = p; *p && !isspace(*p); p++);
    *p = '\0'; p++;
    if (!strcmp(q, subfont_id)) {
      if (num_sfd_records >= max_sfd_records) {
        max_sfd_records += 16;
        sfd_record = RENEW(sfd_record, max_sfd_records, struct sfd_rec_);
      }
      clear_vector(sfd_record[num_sfd_records].vector);
      error = read_sfd_record(&sfd_record[num_sfd_records], p);
      if (error)
        WARN("Error occured while reading SFD file: file=\"%s\" subfont_id=\"%s\"",
             sfd->ident, subfont_id);
      else {
        rec_id = num_sfd_records++;
      }
    }
  }
  if (rec_id < 0) {
    WARN("Failed to load subfont mapping table for SFD=\"%s\" subfont_id=\"%s\"",
         sfd->ident, subfont_id);
  }
  sfd->rec_id[i] = rec_id;
  DPXFCLOSE(fp);

  if (verbose > 3) {
    int __i;
    if (rec_id >= 0) {
      MESG(" at id=\"%d\"", rec_id);
      MESG("\nsubfont>> Content of mapping table:");
      for (__i = 0; __i < 256; __i++) {
        if (__i % 16 == 0)
          MESG("\nsubfont>>  ");
        MESG(" %04x", sfd_record[rec_id].vector[__i]);
      }
    }
    MESG("\n");
  }

  return  rec_id;
}

Here is the call graph for this function:

void subfont_set_verbose ( void  )

Definition at line 38 of file subfont.c.

{
  verbose++;
}