Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
tfm.c File Reference
#include <config.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "mdvi.h"
#include "private.h"
+ Include dependency graph for tfm.c:

Go to the source code of this file.

Macros

#define TYPENAME(font)   ((font)->search.info ? (font)->search.info : "none")
 
#define XCONV(x)   FROUND(params->conv * (x) * params->hshrink)
 
#define YCONV(y)   FROUND(params->vconv * (y) * params->vshrink)
 

Functions

static int tfm_load_font __PROTO ((DviParams *, DviFont *))
 
static int tfm_font_get_glyph __PROTO ((DviParams *, DviFont *, int))
 
int get_tfm_chars (DviParams *params, DviFont *font, TFMInfo *info, int loaded)
 
static int tfm_load_font (DviParams *params, DviFont *font)
 
static int tfm_font_get_glyph (DviParams *params, DviFont *font, int code)
 

Variables

DviFontInfo tfm_font_info
 
DviFontInfo ofm_font_info
 
DviFontInfo afm_font_info
 

Macro Definition Documentation

#define TYPENAME (   font)    ((font)->search.info ? (font)->search.info : "none")

Definition at line 74 of file tfm.c.

#define XCONV (   x)    FROUND(params->conv * (x) * params->hshrink)

Definition at line 84 of file tfm.c.

#define YCONV (   y)    FROUND(params->vconv * (y) * params->vshrink)

Definition at line 85 of file tfm.c.

Function Documentation

static int tfm_load_font __PROTO ( (DviParams *, DviFont *)  )
static
static int tfm_font_get_glyph __PROTO ( (DviParams *, DviFont *, int)  )
static
int get_tfm_chars ( DviParams params,
DviFont font,
TFMInfo info,
int  loaded 
)

Definition at line 88 of file tfm.c.

89 {
90  Int32 z, alpha, beta;
91  int n;
92  DviFontChar *ch;
93  TFMChar *ptr;
94 
95  n = info->hic - info->loc + 1;
96  if(n != FONT_GLYPH_COUNT(font)) {
97  font->chars = mdvi_realloc(font->chars,
98  n * sizeof(DviFontChar));
99  }
100  font->loc = info->loc;
101  font->hic = info->hic;
102  ch = font->chars;
103  ptr = info->chars;
104 
105  /* Prepare z, alpha and beta for TFM width computation */
106  TFMPREPARE(font->scale, z, alpha, beta);
107 
108  /* get the character metrics */
109  for(n = info->loc; n <= info->hic; ch++, ptr++, n++) {
110  int a, b, c, d;
111 
112  ch->offset = ptr->present;
113  if(ch->offset == 0)
114  continue;
115  /* this is what we came here for */
116  ch->tfmwidth = TFMSCALE(z, ptr->advance, alpha, beta);
117  /* scale all other TFM units (so they are in DVI units) */
118  a = TFMSCALE(z, ptr->left, alpha, beta);
119  b = TFMSCALE(z, ptr->right, alpha, beta);
120  c = TFMSCALE(z, ptr->height, alpha, beta);
121  d = TFMSCALE(z, ptr->depth, alpha, beta);
122 
123  /* now convert to unscaled pixels */
124  ch->width = XCONV(b - a);
125  ch->height = YCONV(c - d);
126  if(ch->height < 0) ch->height = -ch->height;
127  ch->x = XCONV(a);
128  ch->y = YCONV(c);
129  /*
130  * the offset is not used, but we might as well set it to
131  * something meaningful (and it MUST be non-zero)
132  */
133  ch->flags = 0;
134  ch->code = n;
135  ch->glyph.data = NULL;
136  ch->grey.data = NULL;
137  ch->shrunk.data = NULL;
138  ch->loaded = loaded;
139  }
140 
141  return 0;
142 }

+ Here is the caller graph for this function:

static int tfm_font_get_glyph ( DviParams params,
DviFont font,
int  code 
)
static

Definition at line 195 of file tfm.c.

196 {
197  DviFontChar *ch;
198 
199  ch = FONTCHAR(font, code);
200  if(!glyph_present(ch))
201  return -1;
202  ch->glyph.x = ch->x;
203  ch->glyph.y = ch->y;
204  ch->glyph.w = ch->width;
205  ch->glyph.h = ch->height;
206  /*
207  * This has two purposes: (1) avoid unnecessary calls to this function,
208  * and (2) detect when the glyph data for a TFM font is actually used
209  * (we'll get a SEGV). Any occurrence of that is a bug.
210  */
212 
213  return 0;
214 }
static int tfm_load_font ( DviParams params,
DviFont font 
)
static

Definition at line 149 of file tfm.c.

150 {
151  TFMInfo *tfm;
152  int type;
153 
154  switch(font->search.info->kpse_type) {
155  case kpse_tfm_format:
156  type = DviFontTFM;
157  break;
158  case kpse_afm_format:
159  type = DviFontAFM;
160  break;
161  case kpse_ofm_format:
162  type = DviFontOFM;
163  break;
164  default:
165  return -1;
166  }
167 
168  /* we don't need this */
169  if(font->in) {
170  fclose(font->in);
171  font->in = NULL;
172  }
173  tfm = get_font_metrics(font->fontname, type, font->filename);
174  if(tfm == NULL)
175  return -1;
176 
177  if(tfm->checksum && font->checksum && tfm->checksum != font->checksum) {
178  mdvi_warning(_("%s: Checksum mismatch (got %u, expected %u)\n"),
179  font->fontname, (unsigned)tfm->checksum,
180  (unsigned)font->checksum);
181  }
182  font->checksum = tfm->checksum;
183  font->design = tfm->design;
184  font->loc = 0;
185  font->hic = 0;
186  font->chars = NULL;
187  get_tfm_chars(params, font, tfm, 1);
188 
189  /* free everything */
190  free_font_metrics(tfm);
191 
192  return 0;
193 }

Variable Documentation

DviFontInfo afm_font_info
Initial value:
= {
"AFM",
0,
NULL,
NULL,
NULL,
kpse_afm_format,
NULL
}

Definition at line 60 of file tfm.c.

DviFontInfo ofm_font_info
Initial value:
= {
"OFM",
0,
NULL,
NULL,
NULL,
kpse_ofm_format,
NULL
}

Definition at line 46 of file tfm.c.

DviFontInfo tfm_font_info
Initial value:
= {
"TFM",
0,
NULL,
NULL,
NULL,
kpse_tfm_format,
NULL
}

Definition at line 32 of file tfm.c.