Back to index

texmacs  1.0.7.15
Defines | Typedefs | Functions | Variables
load_tfm.cpp File Reference
#include "load_tex.hpp"
#include "analyze.hpp"
#include "timer.hpp"

Go to the source code of this file.

Defines

#define byte0(i)   (((i)>>24)&255)
#define byte1(i)   (((i)>>16)&255)
#define byte2(i)   (((i)>>8)&255)
#define byte3(i)   ((i)&255)
#define word0(i)   (((i)>>16)&65535)
#define word1(i)   ((i)&65535)
#define byte1a(i)   (((i)>>20)&15)
#define byte1b(i)   (((i)>>16)&15)
#define byte2x(i)   (((i)>>10)&63)
#define word1x(i)   ((i)&32767)
#define conv(x)   ((SI) (((double) (x))*unit))
#define ADVANCE(k)
#define SKIP

Typedefs

typedef rep< tex_font_metric > rep_tex_font_metric

Functions

 RESOURCE_CODE (tex_font_metric)
double fixed (int i)
void print (tex_font_metric tfm)
tex_font_metric load_tfm (url file_name, string family, int size)

Variables

static const char * HOR_RULE = "---------------------------------------------------------------------------\n"

Define Documentation

#define ADVANCE (   k)
Value:
x += conv (w(stack[sp--]) + k);          \
  x_bis= x;                                \
  if (pos < n-sp) xpos [pos++] = x;

Definition at line 225 of file load_tfm.cpp.

#define byte0 (   i)    (((i)>>24)&255)

Definition at line 57 of file load_tfm.cpp.

#define byte1 (   i)    (((i)>>16)&255)

Definition at line 58 of file load_tfm.cpp.

#define byte1a (   i)    (((i)>>20)&15)

Definition at line 64 of file load_tfm.cpp.

#define byte1b (   i)    (((i)>>16)&15)

Definition at line 65 of file load_tfm.cpp.

#define byte2 (   i)    (((i)>>8)&255)

Definition at line 59 of file load_tfm.cpp.

#define byte2x (   i)    (((i)>>10)&63)

Definition at line 66 of file load_tfm.cpp.

#define byte3 (   i)    ((i)&255)

Definition at line 60 of file load_tfm.cpp.

#define conv (   x)    ((SI) (((double) (x))*unit))

Definition at line 223 of file load_tfm.cpp.

#define SKIP
Value:
sp--;                                    \
  if (pos < n-sp) {                        \
    x_bis += conv (w(stack[sp+1]));        \
    xpos [pos++] = x_bis;                  \
  }

Definition at line 230 of file load_tfm.cpp.

#define word0 (   i)    (((i)>>16)&65535)

Definition at line 61 of file load_tfm.cpp.

#define word1 (   i)    ((i)&65535)

Definition at line 62 of file load_tfm.cpp.

#define word1x (   i)    ((i)&32767)

Definition at line 67 of file load_tfm.cpp.


Typedef Documentation

typedef rep<tex_font_metric> rep_tex_font_metric

Definition at line 23 of file load_tfm.cpp.


Function Documentation

double fixed ( int  i)

Definition at line 303 of file load_tfm.cpp.

              {
  double x= ((double) i) / ((double) (1<<20));
  int j= (int) (1000*x);
  return ((double) j)*0.001;
}

Here is the caller graph for this function:

tex_font_metric load_tfm ( url  file_name,
string  family,
int  size 
)

Definition at line 373 of file load_tfm.cpp.

                                                  {
  tex_font_metric tfm=
    tm_new<tex_font_metric_rep> (family * as_string (size) * ".tfm");

  int i= 0;
  string s;
  (void) load_string (file_name, s, true);
  bench_start ("decode tfm");

  parse (s, i, tfm->lf);
  parse (s, i, tfm->lh);
  parse (s, i, tfm->bc);
  parse (s, i, tfm->ec);
  parse (s, i, tfm->nw);
  parse (s, i, tfm->nh);
  parse (s, i, tfm->nd);
  parse (s, i, tfm->ni);
  parse (s, i, tfm->nl);
  parse (s, i, tfm->nk);
  parse (s, i, tfm->ne);
  parse (s, i, tfm->np);

  if ((tfm->lf-6) !=
      (tfm->lh + (tfm->ec + 1 - tfm->bc) +
       tfm->nw + tfm->nh + tfm->nd + tfm->ni +
       tfm->nl + tfm->nk + tfm->ne + tfm->np))
    FAILED ("invalid tfm file");
  
  parse (s, i, tfm->header, tfm->lh);
  parse (s, i, tfm->char_info, tfm->ec+1- tfm->bc);
  parse (s, i, tfm->width, tfm->nw);
  parse (s, i, tfm->height, tfm->nh);
  parse (s, i, tfm->depth, tfm->nd);
  parse (s, i, tfm->italic, tfm->ni);
  parse (s, i, tfm->lig_kern, tfm->nl);
  parse (s, i, tfm->kern, tfm->nk);
  parse (s, i, tfm->exten, tfm->ne);
  parse (s, i, tfm->param, tfm->np);
  
  tfm->left= tfm->right= tfm->left_prog= tfm->right_prog= -1;
  if (tfm->nl > 0) {
    int l= tfm->lig_kern [0];
    int r= tfm->lig_kern [tfm->nl- 1];
    if (byte0 (l) == 255) tfm->right= byte1 (l);
    if (byte0 (r) == 255) tfm->left_prog= word1 (r);
  }

  tfm->size= (tfm->header[1] + (1<<19)) >> 20;

  bench_cumul ("decode tfm");
  return tfm;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void print ( tex_font_metric  tfm)

Definition at line 310 of file load_tfm.cpp.

                            {
  int i;
  cout << HOR_RULE;
  cout << "name:        " << tfm->res_name << "\n";
  cout << HOR_RULE;
  cout << "checksum:    " << tfm->header[0] << "\n";
  cout << "design size: " << fixed (tfm->header[1]) << "\n";

  cout << HOR_RULE;
  for (i=tfm->bc; i<=tfm->ec; i++) {
    cout << "character ";
    if ((i&127)<32) cout << i << ":\t";
    else cout << ((char) i) << ":\t";
    cout << "w=" << fixed (tfm->w(i)) << ", ";
    cout << "h=" << fixed (tfm->h(i)) << ", ";
    cout << "d=" << fixed (tfm->d(i)) << ", ";
    cout << "i=" << fixed (tfm->i(i));
    switch (tfm->tag (i)) {
    case 1: cout << " [lig " << tfm->rem(i) << "]"; break;
    case 2: cout << " [list " << tfm->rem(i) << "]"; break;
    case 3: cout << " [ext "
               << (int) tfm->top(i) << ", "
               << (int) tfm->mid(i) << ", " 
               << (int) tfm->bot(i) << ", " 
               << (int) tfm->rep(i) << "]"; break;
    }
    cout << "\n";
  }

  cout << HOR_RULE;
  if (tfm->left!=-1)
    cout << "Left boundary character:  " << tfm->left << "\n";
  if (tfm->right!=-1)
    cout << "Right boundary character: " << tfm->right << "\n";
  if (tfm->left_prog!=-1) 
    cout << "Left boundary program:    " << tfm->left_prog << "\n";
  if (tfm->right_prog!=-1)
    cout << "Right boundary program:   " << tfm->right_prog << "\n";
  if ((tfm->left==-1) && (tfm->right==-1) &&
      (tfm->left_prog==-1) && (tfm->right_prog==-1))
    cout << "No boundary characters or programs\n";

  cout << HOR_RULE;
  cout << "Slope:         " << tfm->slope () << "\n";
  cout << "Space:         " << fixed (tfm->spc ()) << "\n";
  cout << "Space_stretch: " << fixed (tfm->spc_stretch ()) << "\n";
  cout << "Space_shrink:  " << fixed (tfm->spc_shrink ()) << "\n";
  cout << "X height:      " << fixed (tfm->x_height ()) << "\n";
  cout << "Quad space:    " << fixed (tfm->spc_quad ()) << "\n";
  cout << "Extra space:   " << fixed (tfm->spc_extra ()) << "\n";

  cout << HOR_RULE;
  for (i=7; i<tfm->np; i++)
    cout << "Parameter " << i << ": " << fixed (tfm->parameter (i)) << "\n";

  cout << HOR_RULE;
}

Here is the call graph for this function:

RESOURCE_CODE ( tex_font_metric  )

Variable Documentation

const char* HOR_RULE = "---------------------------------------------------------------------------\n" [static]

Definition at line 300 of file load_tfm.cpp.