Back to index

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

Go to the source code of this file.

Functions

void tfm_set_verbose (void)
int tfm_open (const char *tex_name, int must_exist)
void tfm_close_all (void)
double tfm_get_width (int font_id, SIGNED_QUAD ch)
fixword tfm_get_fw_width (int font_id, SIGNED_QUAD ch)
fixword tfm_get_fw_height (int font_id, SIGNED_QUAD ch)
fixword tfm_get_fw_depth (int font_id, SIGNED_QUAD ch)
fixword tfm_string_width (int font_id, const unsigned char *s, unsigned len)
fixword tfm_string_depth (int font_id, const unsigned char *s, unsigned len)
fixword tfm_string_height (int font_id, const unsigned char *s, unsigned len)
double tfm_get_space (int font_id)
double tfm_get_design_size (int font_id)
int tfm_exists (const char *tfm_name)

Function Documentation

void tfm_close_all ( void  )

Definition at line 1018 of file tfm.c.

{
  int  i;

  if (fms) {
    for (i = 0; i < numfms; i++) {
      fm_clear(&(fms[i]));
    }
    RELEASE(fms);
  }
}

Here is the call graph for this function:

int tfm_exists ( const char *  tfm_name)

Definition at line 1271 of file tfm.c.

{
#ifdef NOKPSE
  char *fullname;

  fullname = kpse_find_file(tfm_name, kpse_ofm_format, 0);
  if (fullname) {
    RELEASE(fullname);
    return 1;
  }
  fullname = kpse_find_file(tfm_name, kpse_tfm_format, 0);
  if (fullname) {
    RELEASE(fullname);
    return 1;
  }
#else
#endif
  return 0;
}
double tfm_get_design_size ( int  font_id)

Definition at line 1236 of file tfm.c.

{
  CHECK_ID(font_id);

  return (double) (fms[font_id].designsize)/FWBASE*(72.0/72.27);
}

Here is the caller graph for this function:

fixword tfm_get_fw_depth ( int  font_id,
SIGNED_QUAD  ch 
)

Definition at line 1098 of file tfm.c.

{
  struct font_metric *fm;
  long idx = 0;

  CHECK_ID(font_id);

  fm = &(fms[font_id]);
  if (ch >= fm->firstchar && ch <= fm->lastchar) {
    switch (fm->charmap.type) {
    case MAPTYPE_CHAR:
      idx = lookup_char(fm->charmap.data, ch);
      if (idx < 0)
       ERROR("Invalid char: %ld\n", ch);
      break;
    case MAPTYPE_RANGE:
      idx = lookup_range(fm->charmap.data, ch);
      if (idx < 0)
       ERROR("Invalid char: %ld\n", ch);
      break;
    default:
      idx = ch;
    }
  } else {
    ERROR("Invalid char: %ld\n", ch);
  }

  return fm->depths[idx];
}

Here is the call graph for this function:

Here is the caller graph for this function:

fixword tfm_get_fw_height ( int  font_id,
SIGNED_QUAD  ch 
)

Definition at line 1067 of file tfm.c.

{
  struct font_metric *fm;
  long idx = 0;

  CHECK_ID(font_id);

  fm = &(fms[font_id]);
  if (ch >= fm->firstchar && ch <= fm->lastchar) {
    switch (fm->charmap.type) {
    case MAPTYPE_CHAR:
      idx = lookup_char(fm->charmap.data, ch);
      if (idx < 0)
       ERROR("Invalid char: %ld\n", ch);
      break;
    case MAPTYPE_RANGE:
      idx = lookup_range(fm->charmap.data, ch);
      if (idx < 0)
       ERROR("Invalid char: %ld\n", ch);
      break;
    default:
      idx = ch;
    }
  } else {
    ERROR("Invalid char: %ld\n", ch);
  }

  return fm->heights[idx];
}

Here is the call graph for this function:

Here is the caller graph for this function:

fixword tfm_get_fw_width ( int  font_id,
SIGNED_QUAD  ch 
)

Definition at line 1036 of file tfm.c.

{
  struct font_metric *fm;
  long idx = 0;

  CHECK_ID(font_id);

  fm = &(fms[font_id]);
  if (ch >= fm->firstchar && ch <= fm->lastchar) {
    switch (fm->charmap.type) {
    case MAPTYPE_CHAR:
      idx = lookup_char(fm->charmap.data, ch);
      if (idx < 0)
       ERROR("Invalid char: %ld\n", ch);
      break;
    case MAPTYPE_RANGE:
      idx = lookup_range(fm->charmap.data, ch);
      if (idx < 0)
       ERROR("Invalid char: %ld\n", ch);
      break;
    default:
      idx = ch;
    }
  } else {
    ERROR("Invalid char: %ld\n", ch);
  }

  return fm->widths[idx];
}

Here is the call graph for this function:

Here is the caller graph for this function:

double tfm_get_space ( int  font_id)
double tfm_get_width ( int  font_id,
SIGNED_QUAD  ch 
)

Definition at line 1134 of file tfm.c.

{
  return ((double) tfm_get_fw_width(font_id, ch)/FWBASE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int tfm_open ( const char *  tex_name,
int  must_exist 
)

Definition at line 946 of file tfm.c.

{
  FILE *tfm_file;
  int i;
  UNSIGNED_QUAD tfm_file_size;
  char *tex_name = NULL;

  {
    // find tex_name
    int i = strlen(tfm_name)-1;
    while (i>=0) {
      if (tfm_name[i] != '/') i--;
      else break;
    }
    i++;
    tex_name = NEW(strlen(tfm_name+i),char);
    strcpy(tex_name,tfm_name+i);
  }
  
  
  for (i = 0; i < numfms; i++) {
    if (!strcmp(tex_name, fms[i].tex_name))
      return i;
  }

  tfm_file = MFOPEN(tfm_name, FOPEN_RBIN_MODE);
  
#if 0
  if (verbose) {
    if (format == TFM_FORMAT)
      MESG("(TFM:%s", tfm_name);
    else if (format == OFM_FORMAT)
      MESG("(OFM:%s", tfm_name);
    if (verbose > 1)
      MESG("[%s]", file_name);
  }
#endif
  
  
  tfm_file_size = file_size(tfm_file);
  if (tfm_file_size < 24) {
    ERROR("TFM file too small to be a valid file.");
  }
  
  
  if (!tfm_file) {
    ERROR("Could not open specified TFM file \"%s\".", tfm_name);
  }
  
  
  fms_need(numfms + 1);
  fm_init(fms + numfms);
  
  {
    read_tfm(&fms[numfms], tfm_file, tfm_file_size);
  }
  
  MFCLOSE(tfm_file);
  
  fms[numfms].tex_name = NEW(strlen(tex_name)+1, char);
  strcpy(fms[numfms].tex_name, tex_name);
  
  if (verbose) 
    MESG(")");
  
  RELEASE(tex_name);
  
  return numfms++;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tfm_set_verbose ( void  )

Definition at line 328 of file tfm.c.

{
  verbose++;
}
fixword tfm_string_depth ( int  font_id,
const unsigned char *  s,
unsigned  len 
)

Definition at line 1182 of file tfm.c.

{
  fixword result = 0;
  struct font_metric *fm;
  unsigned i;

  CHECK_ID(font_id);

  fm = &(fms[font_id]);
#ifndef WITHOUT_ASCII_PTEX
  if (fm->source == SOURCE_TYPE_JFM) {
    for (i = 0; i < len/2; i++) {
      SIGNED_QUAD ch;

      ch = (s[2*i] << 8)|s[2*i+1];
      result += tfm_get_fw_depth(font_id, ch);
    }
  } else
#endif
    for (i = 0; i < len; i++) {
      result = MAX(result, tfm_get_fw_depth(font_id, s[i]));
    }

  return result;
}

Here is the call graph for this function:

fixword tfm_string_height ( int  font_id,
const unsigned char *  s,
unsigned  len 
)

Definition at line 1209 of file tfm.c.

{
  fixword result = 0;
  struct font_metric *fm;
  unsigned i;

  CHECK_ID(font_id);

  fm = &(fms[font_id]);
#ifndef WITHOUT_ASCII_PTEX
  if (fm->source == SOURCE_TYPE_JFM) {
    for (i = 0; i < len/2; i++) {
      SIGNED_QUAD ch;

      ch = (s[2*i] << 8)|s[2*i+1];
      result += tfm_get_fw_height(font_id, ch);
    }
  } else
#endif
    for (i = 0; i < len; i++) {
      result = MAX(result, tfm_get_fw_height(font_id, s[i]));
    }

  return result;
}

Here is the call graph for this function:

fixword tfm_string_width ( int  font_id,
const unsigned char *  s,
unsigned  len 
)

Definition at line 1155 of file tfm.c.

{
  fixword result = 0;
  struct font_metric *fm;
  unsigned i;

  CHECK_ID(font_id);

  fm = &(fms[font_id]);
#ifndef WITHOUT_ASCII_PTEX
  if (fm->source == SOURCE_TYPE_JFM) {
    for (i = 0; i < len/2; i++) {
      SIGNED_QUAD ch;

      ch = (s[2*i] << 8)|s[2*i+1];
      result += tfm_get_fw_width(font_id, ch);
    }
  } else
#endif
    for (i = 0; i < len; i++) {
      result += tfm_get_fw_width(font_id, s[i]);
    }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function: